@behio/storefront-sdk 1.9.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -42,6 +42,9 @@ __export(react_exports, {
42
42
  useAuth: () => useAuth,
43
43
  useBehio: () => useBehio,
44
44
  useBehioClient: () => useBehioClient,
45
+ useBlogPost: () => useBlogPost,
46
+ useBlogPosts: () => useBlogPosts,
47
+ useBlogs: () => useBlogs,
45
48
  useBundle: () => useBundle,
46
49
  useBundles: () => useBundles,
47
50
  useCart: () => useCart,
@@ -95,6 +98,8 @@ __export(react_exports, {
95
98
  useShopInfo: () => useShopInfo,
96
99
  useShopScripts: () => useShopScripts,
97
100
  useShopSeo: () => useShopSeo,
101
+ useSiteForm: () => useSiteForm,
102
+ useSiteFormSubmit: () => useSiteFormSubmit,
98
103
  useSubmitQuote: () => useSubmitQuote,
99
104
  useSubmitReturn: () => useSubmitReturn,
100
105
  useSubmitReview: () => useSubmitReview,
@@ -109,6 +114,38 @@ var import_react2 = require("react");
109
114
  var import_react_query = require("@tanstack/react-query");
110
115
 
111
116
  // src/types.ts
117
+ var BE_CODE_TO_ERROR = {
118
+ "be.storefront.cartIsEmpty": "CART_EMPTY",
119
+ "be.storefront.productNotFound": "PRODUCT_NOT_FOUND",
120
+ "be.storefront.productNotAvailable": "PRODUCT_NOT_FOUND",
121
+ "be.storefront.invalidEmailOrPassword": "INVALID_CREDENTIALS",
122
+ "be.storefront.currentPasswordIncorrect": "INVALID_CREDENTIALS",
123
+ "be.storefront.discountExpired": "DISCOUNT_EXPIRED",
124
+ "be.storefront.discountExpiredOrLimit": "DISCOUNT_EXPIRED",
125
+ "be.storefront.invalidDiscountCode": "INVALID_DISCOUNT",
126
+ "be.storefront.discountInvalid": "INVALID_DISCOUNT",
127
+ "be.storefront.discountInactive": "INVALID_DISCOUNT",
128
+ "be.storefront.discountWrongCurrency": "INVALID_DISCOUNT",
129
+ "be.storefront.discountNotApplicable": "INVALID_DISCOUNT",
130
+ "be.storefront.discountNotYetValid": "INVALID_DISCOUNT",
131
+ "be.storefront.discountUsageLimitReached": "INVALID_DISCOUNT",
132
+ "be.storefront.discountLimitedToGroups": "INVALID_DISCOUNT",
133
+ "be.storefront.tokenInvalid": "TOKEN_INVALID",
134
+ "be.storefront.orderAccessTokenInvalid": "TOKEN_INVALID",
135
+ "be.storefront.resetTokenInvalid": "TOKEN_INVALID",
136
+ "be.storefront.invalidVerificationToken": "TOKEN_INVALID",
137
+ "be.storefront.invalidRefreshToken": "TOKEN_INVALID",
138
+ "be.storefront.refreshTokenExpired": "TOKEN_EXPIRED",
139
+ "be.storefront.apiKeyExpired": "TOKEN_EXPIRED",
140
+ "be.storefront.customerEmailTaken": "EMAIL_ALREADY_EXISTS",
141
+ "be.storefront.orderNotCancellable": "ORDER_NOT_CANCELLABLE",
142
+ "be.storefront.orderCancelledNotReturnable": "ORDER_NOT_CANCELLABLE",
143
+ "be.validation.failed": "VALIDATION_ERROR",
144
+ "be.forms.formNotFound": "NOT_FOUND",
145
+ "be.forms.validationFailed": "VALIDATION_ERROR",
146
+ "be.forms.consentRequired": "VALIDATION_ERROR",
147
+ "be.forms.tooLarge": "VALIDATION_ERROR"
148
+ };
112
149
  var BehioApiError = class _BehioApiError extends Error {
113
150
  constructor(status, body, message) {
114
151
  super(message || `API Error ${status}`);
@@ -125,6 +162,11 @@ var BehioApiError = class _BehioApiError extends Error {
125
162
  if (status === 409) return "EMAIL_ALREADY_EXISTS";
126
163
  if (status === 429) return "RATE_LIMITED";
127
164
  if (status >= 500) return "INTERNAL_ERROR";
165
+ const rawCode = body?.code;
166
+ if (typeof rawCode === "string") {
167
+ const mapped = BE_CODE_TO_ERROR[rawCode];
168
+ if (mapped) return mapped;
169
+ }
128
170
  const msg = (body?.message || "").toLowerCase();
129
171
  if (msg.includes("invalid") && msg.includes("password"))
130
172
  return "INVALID_CREDENTIALS";
@@ -230,6 +272,8 @@ var BehioStorefront = class {
230
272
  this.orders = new OrdersModule(this);
231
273
  this.customer = new CustomerModule(this);
232
274
  this.pages = new PagesModule(this);
275
+ this.blog = new BlogModule(this);
276
+ this.forms = new FormsModule(this);
233
277
  this.wishlist = new WishlistModule(this);
234
278
  this.reviews = new ReviewsModule(this);
235
279
  this.returns = new ReturnsModule(this);
@@ -932,16 +976,27 @@ var CatalogModule = class {
932
976
  { body: input }
933
977
  );
934
978
  }
935
- /** List configured payment methods (filtered by currency). */
979
+ /**
980
+ * List configured payment methods (filtered by currency). `locale` picks the
981
+ * language of `instruments[].label` / `swifts[].label` (SDK 1.14.0); pass the
982
+ * locale of the page so the instrument tiles read in the shopper's language.
983
+ */
936
984
  async listPaymentMethods(opts) {
937
985
  const query = {};
938
986
  if (opts?.currency) query.currency = opts.currency;
987
+ if (opts?.locale) query.locale = opts.locale;
988
+ if (opts?.country) query.country = opts.country;
989
+ if (opts?.shippingMethodId) query.shippingMethodId = opts.shippingMethodId;
939
990
  return this.client.request(
940
991
  "GET",
941
992
  "/catalog/payment-methods",
942
993
  { query }
943
994
  );
944
995
  }
996
+ /** Alias of `listPaymentMethods` (SDK 1.14.0). */
997
+ paymentMethods(opts) {
998
+ return this.listPaymentMethods(opts);
999
+ }
945
1000
  };
946
1001
  var AuthModule = class {
947
1002
  constructor(client) {
@@ -1095,6 +1150,26 @@ var CartModule = class {
1095
1150
  this.client.emit("cart:updated", res.data);
1096
1151
  return res;
1097
1152
  }
1153
+ /**
1154
+ * Tell the cart where the order will ship (and, for B2B, the buyer's VAT
1155
+ * ID) so the VAT breakdown matches the checkout before the address form:
1156
+ * destination-country rate (OSS), 0 % export outside the EU, or reverse
1157
+ * charge for an EU business with a VIES-valid VAT ID. `cart.vatMode` says
1158
+ * which rule applied. SDK 1.17.0.
1159
+ *
1160
+ * ```ts
1161
+ * await client.cart.setDestination({ country: "SK" });
1162
+ * await client.cart.setDestination({ vatId: "SK2020000001" }); // "" clears
1163
+ * ```
1164
+ */
1165
+ async setDestination(input) {
1166
+ const res = await this.client.request("PUT", "/cart/destination", {
1167
+ body: input
1168
+ });
1169
+ if (res.error) return res;
1170
+ this.client.emit("cart:updated", res.data);
1171
+ return res;
1172
+ }
1098
1173
  /** Update item quantity */
1099
1174
  async updateQuantity(itemId, quantity) {
1100
1175
  const res = await this.client.request(
@@ -1246,6 +1321,30 @@ var OrdersModule = class {
1246
1321
  constructor(client) {
1247
1322
  this.client = client;
1248
1323
  }
1324
+ /**
1325
+ * Ask the backend to re-check this order's payment with the gateway.
1326
+ *
1327
+ * Call it on the thank-you page the customer lands on after paying, BEFORE
1328
+ * you read the order. Some gateways (Tatrapay+) have no server-to-server
1329
+ * notification at all, so the customer's return is the only fast way the
1330
+ * payment gets confirmed; for the others it is a safety net for a lost
1331
+ * notification.
1332
+ *
1333
+ * The response is deliberately opaque (`{ok: true}` every time, even for an
1334
+ * order number that does not exist): order numbers are sequential, so
1335
+ * anything else would turn this into a probe for other people's orders.
1336
+ * Read the actual state afterwards through a path that proves entitlement
1337
+ * ({@link get}, {@link track} or the guest access-code flow).
1338
+ *
1339
+ * Never throws for a missing order and never blocks the page: treat a
1340
+ * failure as "not confirmed yet", the backend poller catches up on its own.
1341
+ */
1342
+ async syncPaymentOnReturn(orderNumber) {
1343
+ return this.client.request(
1344
+ "POST",
1345
+ `/payments/return/${orderNumber}`
1346
+ );
1347
+ }
1249
1348
  /** List customer orders (requires auth) */
1250
1349
  async list(options) {
1251
1350
  return this.client.request(
@@ -1598,6 +1697,59 @@ var PagesModule = class {
1598
1697
  });
1599
1698
  }
1600
1699
  };
1700
+ var BlogModule = class {
1701
+ constructor(client) {
1702
+ this.client = client;
1703
+ }
1704
+ /** List the site's blogs (active only). */
1705
+ async list(locale) {
1706
+ return this.client.request("GET", "/blogs", {
1707
+ query: { locale }
1708
+ });
1709
+ }
1710
+ /** Published posts of one blog, newest first (featured first), paginated. */
1711
+ async posts(handle, query = {}) {
1712
+ return this.client.request("GET", `/blogs/${handle}/posts`, {
1713
+ query: {
1714
+ locale: query.locale,
1715
+ page: query.page,
1716
+ limit: query.limit,
1717
+ tag: query.tag
1718
+ }
1719
+ });
1720
+ }
1721
+ /** One published post with sanitised HTML content and related posts. */
1722
+ async post(handle, slug, locale) {
1723
+ return this.client.request("GET", `/blogs/${handle}/posts/${slug}`, {
1724
+ query: { locale }
1725
+ });
1726
+ }
1727
+ };
1728
+ var FormsModule = class {
1729
+ constructor(client) {
1730
+ this.client = client;
1731
+ }
1732
+ /** Public definition of one form (fields + settings). 404 for an unknown or inactive slug. */
1733
+ async get(slug) {
1734
+ return this.client.request(
1735
+ "GET",
1736
+ `/forms/${encodeURIComponent(slug)}`
1737
+ );
1738
+ }
1739
+ /**
1740
+ * Submit a response. On `be.forms.validationFailed` the returned error
1741
+ * carries per-field codes: read them with `formFieldErrors(error)`. Other
1742
+ * rejections: `be.forms.consentRequired`, `be.forms.tooLarge`,
1743
+ * `be.forms.formNotFound`; rate limit 10 submits per minute per visitor.
1744
+ */
1745
+ async submit(slug, input) {
1746
+ return this.client.request(
1747
+ "POST",
1748
+ `/forms/${encodeURIComponent(slug)}/submit`,
1749
+ { body: input, auth: false }
1750
+ );
1751
+ }
1752
+ };
1601
1753
  var WishlistModule = class {
1602
1754
  constructor(client) {
1603
1755
  this.client = client;
@@ -3185,9 +3337,10 @@ var import_react_query27 = require("@tanstack/react-query");
3185
3337
  function usePaymentMethods(options) {
3186
3338
  const { client, currency: activeCurrency } = useBehio();
3187
3339
  const currency = options?.currency ?? activeCurrency;
3340
+ const locale = options?.locale;
3188
3341
  const { data, isLoading, error, refetch } = (0, import_react_query27.useQuery)({
3189
- queryKey: ["behio", "payment-methods", currency ?? ""],
3190
- queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency })),
3342
+ queryKey: ["behio", "payment-methods", currency ?? "", locale ?? ""],
3343
+ queryFn: () => unwrap(client.catalog.listPaymentMethods({ currency, ...locale ? { locale } : {} })),
3191
3344
  enabled: options?.enabled !== false
3192
3345
  });
3193
3346
  return { methods: data?.items ?? [], isLoading, error, refetch };
@@ -3565,11 +3718,134 @@ function usePage(slug, locale, options) {
3565
3718
  });
3566
3719
  }
3567
3720
 
3568
- // src/react/hooks/use-shop-info.ts
3721
+ // src/react/hooks/use-blog.ts
3569
3722
  var import_react_query36 = require("@tanstack/react-query");
3570
- function useShopInfo(options) {
3723
+ function useBlogs(locale, options) {
3571
3724
  const { client } = useBehio();
3572
3725
  return (0, import_react_query36.useQuery)({
3726
+ queryKey: ["behio", "blogs", locale],
3727
+ queryFn: async () => {
3728
+ const result = await unwrap(client.blog.list(locale));
3729
+ return result.blogs;
3730
+ },
3731
+ enabled: options?.enabled !== false
3732
+ });
3733
+ }
3734
+ function useBlogPosts(handle, query, options) {
3735
+ const { client } = useBehio();
3736
+ return (0, import_react_query36.useQuery)({
3737
+ queryKey: ["behio", "blog", handle, "posts", query?.locale, query?.page, query?.limit, query?.tag],
3738
+ queryFn: () => unwrap(client.blog.posts(handle, query)),
3739
+ enabled: options?.enabled !== false && !!handle
3740
+ });
3741
+ }
3742
+ function useBlogPost(handle, slug, locale, options) {
3743
+ const { client } = useBehio();
3744
+ return (0, import_react_query36.useQuery)({
3745
+ queryKey: ["behio", "blog", handle, "post", slug, locale],
3746
+ queryFn: () => unwrap(client.blog.post(handle, slug, locale)),
3747
+ enabled: options?.enabled !== false && !!handle && !!slug
3748
+ });
3749
+ }
3750
+
3751
+ // src/react/hooks/use-site-form.ts
3752
+ var import_react17 = require("react");
3753
+ var import_react_query37 = require("@tanstack/react-query");
3754
+
3755
+ // src/errors.ts
3756
+ function bodyOf(err) {
3757
+ const body = err instanceof BehioApiError ? err.body : err && typeof err === "object" && "body" in err ? err.body : err;
3758
+ return body && typeof body === "object" ? body : null;
3759
+ }
3760
+ function errorCode(err) {
3761
+ const body = bodyOf(err);
3762
+ if (!body) return null;
3763
+ const code = body.code ?? body.key;
3764
+ return typeof code === "string" && code.startsWith("be.") ? code : null;
3765
+ }
3766
+ function errorParams(err) {
3767
+ const body = bodyOf(err);
3768
+ const params = body?.params;
3769
+ return params && typeof params === "object" && !Array.isArray(params) ? params : {};
3770
+ }
3771
+ var FORM_FIELD_ERROR_CODES = /* @__PURE__ */ new Set([
3772
+ "required",
3773
+ "invalid",
3774
+ "tooShort",
3775
+ "tooLong",
3776
+ "min",
3777
+ "max",
3778
+ "notOption",
3779
+ "pattern"
3780
+ ]);
3781
+ function formFieldErrors(err) {
3782
+ if (errorCode(err) !== "be.forms.validationFailed") return [];
3783
+ const raw = errorParams(err).errors;
3784
+ if (!Array.isArray(raw)) return [];
3785
+ const out = [];
3786
+ for (const entry of raw) {
3787
+ if (typeof entry !== "string") continue;
3788
+ const idx = entry.lastIndexOf(":");
3789
+ if (idx <= 0) continue;
3790
+ const key = entry.slice(0, idx);
3791
+ const code = entry.slice(idx + 1);
3792
+ if (!FORM_FIELD_ERROR_CODES.has(code)) continue;
3793
+ out.push({ key, code });
3794
+ }
3795
+ return out;
3796
+ }
3797
+
3798
+ // src/react/hooks/use-site-form.ts
3799
+ function useSiteForm(slug, options) {
3800
+ const { client } = useBehio();
3801
+ return (0, import_react_query37.useQuery)({
3802
+ queryKey: ["behio", "form", slug],
3803
+ queryFn: () => unwrap(client.forms.get(slug)),
3804
+ enabled: options?.enabled !== false && !!slug
3805
+ });
3806
+ }
3807
+ function useSiteFormSubmit(slug) {
3808
+ const { client } = useBehio();
3809
+ const mutation = (0, import_react_query37.useMutation)({
3810
+ mutationFn: (input) => unwrap(client.forms.submit(slug, input))
3811
+ });
3812
+ const sdkError = mutation.error instanceof UnwrappedError ? mutation.error.sdkError : null;
3813
+ const fieldErrors = (0, import_react17.useMemo)(() => {
3814
+ const out = {};
3815
+ for (const e of formFieldErrors(sdkError)) out[e.key] = e.code;
3816
+ return out;
3817
+ }, [sdkError]);
3818
+ const errorCode2 = (0, import_react17.useMemo)(() => {
3819
+ const body = sdkError?.body;
3820
+ const code = body?.code ?? body?.key;
3821
+ return typeof code === "string" ? code : sdkError ? sdkError.code : null;
3822
+ }, [sdkError]);
3823
+ const submit = (0, import_react17.useCallback)(
3824
+ (input) => mutation.mutateAsync(input).catch(() => null),
3825
+ [mutation]
3826
+ );
3827
+ return {
3828
+ /** Resolves to the result, or null when the submit was rejected (see `fieldErrors` / `errorCode`). */
3829
+ submit,
3830
+ isSubmitting: mutation.isPending,
3831
+ isSuccess: mutation.isSuccess,
3832
+ /** `{ok, id, message, redirectUrl}` after a successful submit. */
3833
+ result: mutation.data ?? null,
3834
+ /** Field key -> validation code after a rejected submit. */
3835
+ fieldErrors,
3836
+ /** Backend error key (`be.forms.*`) or SDK code when the rejection is not per field. */
3837
+ errorCode: errorCode2,
3838
+ /** Raw SDK error (pass to `errorMessage(error, locale)` for a sentence). */
3839
+ error: sdkError,
3840
+ reset: mutation.reset
3841
+ };
3842
+ }
3843
+
3844
+ // src/react/hooks/use-shop-info.ts
3845
+ var import_react_query38 = require("@tanstack/react-query");
3846
+ function useShopInfo(options) {
3847
+ const { client } = useBehio();
3848
+ return (0, import_react_query38.useQuery)({
3573
3849
  queryKey: ["behio", "shop-info"],
3574
3850
  queryFn: () => unwrap(client.getShopInfo()),
3575
3851
  enabled: options?.enabled !== false
@@ -3577,10 +3853,10 @@ function useShopInfo(options) {
3577
3853
  }
3578
3854
 
3579
3855
  // src/react/hooks/use-shop-scripts.ts
3580
- var import_react_query37 = require("@tanstack/react-query");
3856
+ var import_react_query39 = require("@tanstack/react-query");
3581
3857
  function useShopScripts(options) {
3582
3858
  const { client } = useBehio();
3583
- return (0, import_react_query37.useQuery)({
3859
+ return (0, import_react_query39.useQuery)({
3584
3860
  queryKey: ["behio", "shop-scripts"],
3585
3861
  queryFn: () => unwrap(client.getShopScripts()),
3586
3862
  enabled: options?.enabled !== false
@@ -3588,11 +3864,11 @@ function useShopScripts(options) {
3588
3864
  }
3589
3865
 
3590
3866
  // src/react/hooks/use-shop-seo.ts
3591
- var import_react_query38 = require("@tanstack/react-query");
3867
+ var import_react_query40 = require("@tanstack/react-query");
3592
3868
  function useShopSeo(options) {
3593
3869
  const { client } = useBehio();
3594
3870
  const { locale, initialData, enabled = true } = options ?? {};
3595
- return (0, import_react_query38.useQuery)({
3871
+ return (0, import_react_query40.useQuery)({
3596
3872
  queryKey: ["behio", "shop-seo", locale ?? "_default"],
3597
3873
  queryFn: () => unwrap(client.getShopSeo(locale)),
3598
3874
  initialData,
@@ -3652,23 +3928,23 @@ function CurrencySwitcher({
3652
3928
  }
3653
3929
 
3654
3930
  // src/react/components/storefront-scripts.tsx
3655
- var import_react17 = require("react");
3931
+ var import_react18 = require("react");
3656
3932
 
3657
3933
  // src/react/hooks/use-consent.ts
3658
- var import_react_query39 = require("@tanstack/react-query");
3934
+ var import_react_query41 = require("@tanstack/react-query");
3659
3935
  function useCookieConsent(visitorId) {
3660
3936
  const { client } = useBehio();
3661
- const qc = (0, import_react_query39.useQueryClient)();
3662
- const query = (0, import_react_query39.useQuery)({
3937
+ const qc = (0, import_react_query41.useQueryClient)();
3938
+ const query = (0, import_react_query41.useQuery)({
3663
3939
  queryKey: ["behio", "consent", visitorId],
3664
3940
  queryFn: () => unwrap(client.consent.get(visitorId)),
3665
3941
  enabled: Boolean(visitorId)
3666
3942
  });
3667
- const recordMutation = (0, import_react_query39.useMutation)({
3943
+ const recordMutation = (0, import_react_query41.useMutation)({
3668
3944
  mutationFn: (input) => unwrap(client.consent.record(input)),
3669
3945
  onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
3670
3946
  });
3671
- const revokeMutation = (0, import_react_query39.useMutation)({
3947
+ const revokeMutation = (0, import_react_query41.useMutation)({
3672
3948
  mutationFn: () => unwrap(client.consent.revoke(visitorId)),
3673
3949
  onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
3674
3950
  });
@@ -3742,8 +4018,8 @@ function injectHtml(target, html) {
3742
4018
  }
3743
4019
  function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
3744
4020
  const { data } = useShopScripts();
3745
- const [visitorId, setVisitorId] = (0, import_react17.useState)(visitorIdProp ?? "");
3746
- (0, import_react17.useEffect)(() => {
4021
+ const [visitorId, setVisitorId] = (0, import_react18.useState)(visitorIdProp ?? "");
4022
+ (0, import_react18.useEffect)(() => {
3747
4023
  if (visitorIdProp) return;
3748
4024
  try {
3749
4025
  const v = localStorage.getItem(VISITOR_KEY);
@@ -3753,15 +4029,15 @@ function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
3753
4029
  }, [visitorIdProp]);
3754
4030
  const { data: consent } = useCookieConsent(visitorId || void 0);
3755
4031
  const analyticsOk = Boolean(consent?.analytics);
3756
- const scripts = (0, import_react17.useMemo)(
4032
+ const scripts = (0, import_react18.useMemo)(
3757
4033
  () => (data?.scripts ?? []).filter((s) => !s.consentRequired || analyticsOk),
3758
4034
  [data, analyticsOk]
3759
4035
  );
3760
- const signature = (0, import_react17.useMemo)(
4036
+ const signature = (0, import_react18.useMemo)(
3761
4037
  () => JSON.stringify(scripts.map((s) => [s.id, s.type, s.placement, s.value])),
3762
4038
  [scripts]
3763
4039
  );
3764
- (0, import_react17.useEffect)(() => {
4040
+ (0, import_react18.useEffect)(() => {
3765
4041
  if (typeof document === "undefined") return;
3766
4042
  const added = [];
3767
4043
  for (const s of scripts) {
@@ -3778,7 +4054,7 @@ function StorefrontScripts({ visitorId: visitorIdProp } = {}) {
3778
4054
  }
3779
4055
 
3780
4056
  // src/react/components/behio-analytics.tsx
3781
- var import_react18 = require("react");
4057
+ var import_react19 = require("react");
3782
4058
 
3783
4059
  // src/react/hooks/use-behio-client.ts
3784
4060
  function useBehioClient() {
@@ -3788,7 +4064,7 @@ function useBehioClient() {
3788
4064
  // src/react/components/behio-analytics.tsx
3789
4065
  function BehioAnalyticsTracker() {
3790
4066
  const client = useBehioClient();
3791
- (0, import_react18.useEffect)(() => {
4067
+ (0, import_react19.useEffect)(() => {
3792
4068
  if (typeof window === "undefined") return;
3793
4069
  const w = window;
3794
4070
  if (w.__behioAnalytics) return;
@@ -4027,10 +4303,10 @@ function utmFromSearch(search) {
4027
4303
  }
4028
4304
 
4029
4305
  // src/react/hooks/use-bundles.ts
4030
- var import_react_query40 = require("@tanstack/react-query");
4306
+ var import_react_query42 = require("@tanstack/react-query");
4031
4307
  function useBundles(options) {
4032
4308
  const { client } = useBehio();
4033
- return (0, import_react_query40.useQuery)({
4309
+ return (0, import_react_query42.useQuery)({
4034
4310
  queryKey: ["behio", "bundles"],
4035
4311
  queryFn: () => unwrap(client.catalog.getBundles()),
4036
4312
  enabled: options?.enabled ?? true,
@@ -4039,7 +4315,7 @@ function useBundles(options) {
4039
4315
  }
4040
4316
  function useBundle(slug, options) {
4041
4317
  const { client } = useBehio();
4042
- return (0, import_react_query40.useQuery)({
4318
+ return (0, import_react_query42.useQuery)({
4043
4319
  queryKey: ["behio", "bundle", slug],
4044
4320
  queryFn: () => unwrap(client.catalog.getBundle(slug)),
4045
4321
  enabled: Boolean(slug) && (options?.enabled ?? true),
@@ -4048,10 +4324,10 @@ function useBundle(slug, options) {
4048
4324
  }
4049
4325
 
4050
4326
  // src/react/hooks/use-product-group.ts
4051
- var import_react_query41 = require("@tanstack/react-query");
4327
+ var import_react_query43 = require("@tanstack/react-query");
4052
4328
  function useProductGroup(slug, options) {
4053
4329
  const { client } = useBehio();
4054
- return (0, import_react_query41.useQuery)({
4330
+ return (0, import_react_query43.useQuery)({
4055
4331
  queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
4056
4332
  queryFn: () => unwrap(
4057
4333
  client.catalog.getProductGroup(slug, {
@@ -4065,10 +4341,10 @@ function useProductGroup(slug, options) {
4065
4341
  }
4066
4342
 
4067
4343
  // src/react/hooks/use-cross-sell.ts
4068
- var import_react_query42 = require("@tanstack/react-query");
4344
+ var import_react_query44 = require("@tanstack/react-query");
4069
4345
  function useCrossSell(productSlug, options) {
4070
4346
  const { client } = useBehio();
4071
- return (0, import_react_query42.useQuery)({
4347
+ return (0, import_react_query44.useQuery)({
4072
4348
  queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
4073
4349
  queryFn: () => unwrap(
4074
4350
  client.catalog.getCrossSell(productSlug, {
@@ -4082,10 +4358,10 @@ function useCrossSell(productSlug, options) {
4082
4358
  }
4083
4359
 
4084
4360
  // src/react/hooks/use-product-promotions.ts
4085
- var import_react_query43 = require("@tanstack/react-query");
4361
+ var import_react_query45 = require("@tanstack/react-query");
4086
4362
  function useProductPromotions(productSlug, options) {
4087
4363
  const { client } = useBehio();
4088
- return (0, import_react_query43.useQuery)({
4364
+ return (0, import_react_query45.useQuery)({
4089
4365
  queryKey: ["behio", "product-promotions", productSlug],
4090
4366
  queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
4091
4367
  enabled: Boolean(productSlug) && (options?.enabled ?? true),
@@ -4094,11 +4370,11 @@ function useProductPromotions(productSlug, options) {
4094
4370
  }
4095
4371
 
4096
4372
  // src/react/hooks/use-gift-card.ts
4097
- var import_react_query44 = require("@tanstack/react-query");
4373
+ var import_react_query46 = require("@tanstack/react-query");
4098
4374
  function useGiftCardBalance(code, options) {
4099
4375
  const { client } = useBehio();
4100
4376
  const trimmed = code?.trim();
4101
- return (0, import_react_query44.useQuery)({
4377
+ return (0, import_react_query46.useQuery)({
4102
4378
  queryKey: ["behio", "gift-card-balance", trimmed],
4103
4379
  queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
4104
4380
  enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
@@ -4106,20 +4382,20 @@ function useGiftCardBalance(code, options) {
4106
4382
  }
4107
4383
 
4108
4384
  // src/react/hooks/use-wishlist.ts
4109
- var import_react_query45 = require("@tanstack/react-query");
4385
+ var import_react_query47 = require("@tanstack/react-query");
4110
4386
  function useWishlist(options) {
4111
4387
  const { client } = useBehio();
4112
- const qc = (0, import_react_query45.useQueryClient)();
4113
- const query = (0, import_react_query45.useQuery)({
4388
+ const qc = (0, import_react_query47.useQueryClient)();
4389
+ const query = (0, import_react_query47.useQuery)({
4114
4390
  queryKey: ["behio", "wishlist"],
4115
4391
  queryFn: () => unwrap(client.wishlist.get()),
4116
4392
  enabled: options?.enabled ?? true
4117
4393
  });
4118
- const addMutation = (0, import_react_query45.useMutation)({
4394
+ const addMutation = (0, import_react_query47.useMutation)({
4119
4395
  mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
4120
4396
  onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
4121
4397
  });
4122
- const removeMutation = (0, import_react_query45.useMutation)({
4398
+ const removeMutation = (0, import_react_query47.useMutation)({
4123
4399
  mutationFn: (productId) => unwrap(client.wishlist.remove(productId)),
4124
4400
  onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
4125
4401
  });
@@ -4133,7 +4409,7 @@ function useWishlist(options) {
4133
4409
  }
4134
4410
  function useIsInWishlist(productId) {
4135
4411
  const { client } = useBehio();
4136
- return (0, import_react_query45.useQuery)({
4412
+ return (0, import_react_query47.useQuery)({
4137
4413
  queryKey: ["behio", "wishlist-check", productId],
4138
4414
  queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
4139
4415
  enabled: Boolean(productId)
@@ -4141,10 +4417,10 @@ function useIsInWishlist(productId) {
4141
4417
  }
4142
4418
 
4143
4419
  // src/react/hooks/use-reviews.ts
4144
- var import_react_query46 = require("@tanstack/react-query");
4420
+ var import_react_query48 = require("@tanstack/react-query");
4145
4421
  function useProductReviews(productId, options) {
4146
4422
  const { client } = useBehio();
4147
- return (0, import_react_query46.useQuery)({
4423
+ return (0, import_react_query48.useQuery)({
4148
4424
  queryKey: ["behio", "reviews", productId, options?.page ?? 1],
4149
4425
  queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
4150
4426
  enabled: Boolean(productId) && (options?.enabled ?? true)
@@ -4152,30 +4428,30 @@ function useProductReviews(productId, options) {
4152
4428
  }
4153
4429
  function useSubmitReview() {
4154
4430
  const { client } = useBehio();
4155
- const qc = (0, import_react_query46.useQueryClient)();
4156
- return (0, import_react_query46.useMutation)({
4431
+ const qc = (0, import_react_query48.useQueryClient)();
4432
+ return (0, import_react_query48.useMutation)({
4157
4433
  mutationFn: (input) => unwrap(client.reviews.submit(input)),
4158
4434
  onSuccess: (_, input) => qc.invalidateQueries({ queryKey: ["behio", "reviews", input.productId] })
4159
4435
  });
4160
4436
  }
4161
4437
 
4162
4438
  // src/react/hooks/use-returns.ts
4163
- var import_react_query47 = require("@tanstack/react-query");
4439
+ var import_react_query49 = require("@tanstack/react-query");
4164
4440
  function useLookupReturnableOrder() {
4165
4441
  const { client } = useBehio();
4166
- return (0, import_react_query47.useMutation)({
4442
+ return (0, import_react_query49.useMutation)({
4167
4443
  mutationFn: ({ orderNumber, email }) => unwrap(client.returns.lookupOrder(orderNumber, email))
4168
4444
  });
4169
4445
  }
4170
4446
  function useSubmitReturn() {
4171
4447
  const { client } = useBehio();
4172
- return (0, import_react_query47.useMutation)({
4448
+ return (0, import_react_query49.useMutation)({
4173
4449
  mutationFn: (input) => unwrap(client.returns.submit(input))
4174
4450
  });
4175
4451
  }
4176
4452
  function useReturnStatus(returnId, email) {
4177
4453
  const { client } = useBehio();
4178
- return (0, import_react_query47.useQuery)({
4454
+ return (0, import_react_query49.useQuery)({
4179
4455
  queryKey: ["behio", "return-status", returnId],
4180
4456
  queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
4181
4457
  enabled: Boolean(returnId && email)
@@ -4183,16 +4459,16 @@ function useReturnStatus(returnId, email) {
4183
4459
  }
4184
4460
 
4185
4461
  // src/react/hooks/use-quotes.ts
4186
- var import_react_query48 = require("@tanstack/react-query");
4462
+ var import_react_query50 = require("@tanstack/react-query");
4187
4463
  function useSubmitQuote() {
4188
4464
  const { client } = useBehio();
4189
- return (0, import_react_query48.useMutation)({
4465
+ return (0, import_react_query50.useMutation)({
4190
4466
  mutationFn: (input) => unwrap(client.quotes.submit(input))
4191
4467
  });
4192
4468
  }
4193
4469
  function useQuoteStatus(quoteId, email) {
4194
4470
  const { client } = useBehio();
4195
- return (0, import_react_query48.useQuery)({
4471
+ return (0, import_react_query50.useQuery)({
4196
4472
  queryKey: ["behio", "quote-status", quoteId],
4197
4473
  queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
4198
4474
  enabled: Boolean(quoteId && email)
@@ -4200,10 +4476,10 @@ function useQuoteStatus(quoteId, email) {
4200
4476
  }
4201
4477
 
4202
4478
  // src/react/hooks/use-back-in-stock.ts
4203
- var import_react_query49 = require("@tanstack/react-query");
4479
+ var import_react_query51 = require("@tanstack/react-query");
4204
4480
  function useNotifyWhenAvailable() {
4205
4481
  const { client } = useBehio();
4206
- return (0, import_react_query49.useMutation)({
4482
+ return (0, import_react_query51.useMutation)({
4207
4483
  mutationFn: ({ productId, email }) => unwrap(client.catalog.notifyWhenAvailable(productId, email))
4208
4484
  });
4209
4485
  }
@@ -4340,6 +4616,9 @@ async function revokeAnalyticsConsent(client) {
4340
4616
  useAuth,
4341
4617
  useBehio,
4342
4618
  useBehioClient,
4619
+ useBlogPost,
4620
+ useBlogPosts,
4621
+ useBlogs,
4343
4622
  useBundle,
4344
4623
  useBundles,
4345
4624
  useCart,
@@ -4393,6 +4672,8 @@ async function revokeAnalyticsConsent(client) {
4393
4672
  useShopInfo,
4394
4673
  useShopScripts,
4395
4674
  useShopSeo,
4675
+ useSiteForm,
4676
+ useSiteFormSubmit,
4396
4677
  useSubmitQuote,
4397
4678
  useSubmitReturn,
4398
4679
  useSubmitReview,