@depict-ai/react-ui 1.5.2 → 1.5.4

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/ES10/index.js ADDED
@@ -0,0 +1,843 @@
1
+ import { add_to_version_info as $jb2Oo$add_to_version_info, catchify as $jb2Oo$catchify, queueMacroTask as $jb2Oo$queueMacroTask, instant_exec_on_suspect_history_change as $jb2Oo$instant_exec_on_suspect_history_change, derror as $jb2Oo$derror } from "@depict-ai/utilishared/ES10";
2
+ import { CategoryTitle as $383b6fd56bf151bd$re_export$CategoryTitle, embedded_num_products as $383b6fd56bf151bd$re_export$EmbeddedNumProducts, DepictAPI as $jb2Oo$DepictAPI, ProductCardError as $jb2Oo$ProductCardError, DepictSearch as $jb2Oo$DepictSearch, DepictCategory as $jb2Oo$DepictCategory, get_search_query_updating_blocked_signal as $jb2Oo$get_search_query_updating_blocked_signal, SearchPage as $jb2Oo$SearchPage, defaultColsAtSize as $jb2Oo$defaultColsAtSize, defaultGridSpacing as $jb2Oo$defaultGridSpacing, CategoryPage as $jb2Oo$CategoryPage, defaultCategoryTitlePlugin as $jb2Oo$defaultCategoryTitlePlugin, BreadCrumbs as $jb2Oo$BreadCrumbs, QuickLinks as $jb2Oo$QuickLinks, ImagePlaceholder as $jb2Oo$ImagePlaceholder, TextPlaceholder as $jb2Oo$TextPlaceholder, open_modal_with_alignment as $jb2Oo$open_modal_with_alignment, SearchField as $jb2Oo$SearchField, fetchDepictRecommendations as $jb2Oo$fetchDepictRecommendations } from "@depict-ai/ui/ES10";
3
+ import { untrack as $jb2Oo$untrack, createRoot as $jb2Oo$createRoot, createEffect as $jb2Oo$createEffect, createMemo as $jb2Oo$createMemo, createComponent as $jb2Oo$createComponent, Show as $jb2Oo$Show, getOwner as $jb2Oo$getOwner, runWithOwner as $jb2Oo$runWithOwner, onCleanup as $jb2Oo$onCleanup, createSignal as $jb2Oo$createSignal, createComputed as $jb2Oo$createComputed } from "solid-js";
4
+ import { createElement as $jb2Oo$createElement, Fragment as $jb2Oo$Fragment, useEffect as $jb2Oo$useEffect, useState as $jb2Oo$useState, useRef as $jb2Oo$useRef, Component as $jb2Oo$Component, forwardRef as $jb2Oo$forwardRef, useCallback as $jb2Oo$useCallback } from "react";
5
+ import { defaultLocale as $jb2Oo$defaultLocale } from "@depict-ai/ui/locales/ES10";
6
+ import { render as $jb2Oo$render, hydrate as $jb2Oo$hydrate } from "solid-js/web";
7
+ import { jsx as $jb2Oo$jsx } from "react/jsx-runtime";
8
+ import { createPortal as $jb2Oo$createPortal } from "react-dom";
9
+ import { createStore as $jb2Oo$createStore, reconcile as $jb2Oo$reconcile } from "solid-js/store";
10
+ import { DPC as $jb2Oo$DPC } from "@depict-ai/dpc/ES10";
11
+
12
+ /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
13
+ // Note, if you add an export here, also add one in src-server/main.ts
14
+ import { register_es_version } from "../multi_import_deduplicator.mjs";
15
+ register_es_version("react-ui", "ES10");
16
+ const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "1.5.4";
17
+ const $8c691d7f86317052$export$8e769ad4338a911e = {
18
+ usedLocale: (0, $jb2Oo$createSignal)((0, $jb2Oo$defaultLocale)),
19
+ search_instances: new Map(),
20
+ category_instances: new Map(),
21
+ api: null,
22
+ dpc: null,
23
+ merchant: (0, $jb2Oo$createSignal)(),
24
+ market: (0, $jb2Oo$createSignal)(),
25
+ userId: (0, $jb2Oo$createSignal)(),
26
+ sessionId: (0, $jb2Oo$createSignal)(),
27
+ known_category_paths: new Set(),
28
+ search_page_path_: (0, $jb2Oo$createSignal)(),
29
+ search_page_in_dom: (0, $jb2Oo$createSignal)(false),
30
+ category_page_in_dom: (0, $jb2Oo$createSignal)(false),
31
+ provider_is_updating: (0, $jb2Oo$createSignal)(false)
32
+ };
33
+ class $88d93ed7309e90d1$export$d0f82e3ef89b1f22 extends (0, $jb2Oo$Component) {
34
+ constructor(props) {
35
+ super(props);
36
+ this.state = {
37
+ hasError: false
38
+ };
39
+ }
40
+ static getDerivedStateFromError() {
41
+ // Update state so the next render will show the fallback UI.
42
+ return {
43
+ hasError: true
44
+ };
45
+ }
46
+ componentDidCatch(error) {
47
+ this.props.on_error(error);
48
+ }
49
+ render() {
50
+ if (this.state.hasError)
51
+ // You can render any custom fallback UI
52
+ return (0, $jb2Oo$createElement)("div", {
53
+ children: "Component failed"
54
+ });
55
+ return this.props.children;
56
+ }
57
+ }
58
+ let $0dd9d9a9c7da4c1d$var$run_on_href_change;
59
+ let $0dd9d9a9c7da4c1d$var$old_href = location.href;
60
+ function $0dd9d9a9c7da4c1d$export$74f3924c5027fe1d(cb) {
61
+ $0dd9d9a9c7da4c1d$var$run_on_href_change = cb;
62
+ }
63
+ (0, $jb2Oo$instant_exec_on_suspect_history_change).add((0, $jb2Oo$catchify)(() => {
64
+ const {
65
+ href: href
66
+ } = location;
67
+ if ($0dd9d9a9c7da4c1d$var$run_on_href_change && $0dd9d9a9c7da4c1d$var$old_href !== href) $0dd9d9a9c7da4c1d$var$run_on_href_change(href);
68
+ $0dd9d9a9c7da4c1d$var$old_href = href;
69
+ }));
70
+ const $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52 = function () {
71
+ let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : location;
72
+ return url.pathname == (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0]);
73
+ }; // might have changed therefore get it from globalState
74
+ const $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4 = function () {
75
+ let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : location;
76
+ return (0, $8c691d7f86317052$export$8e769ad4338a911e).known_category_paths.has(url.pathname);
77
+ };
78
+ function $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef(_ref) {
79
+ let {
80
+ solid_component: solid_component,
81
+ props: props,
82
+ wrapper_type = "div",
83
+ wrapper_style = {},
84
+ hydrate_function_when_ssr: hydrate_function_when_ssr
85
+ } = _ref;
86
+ const [portals, set_portals] = (0, $jb2Oo$useState)([]);
87
+ const wrapper_element_ref = (0, $jb2Oo$useRef)();
88
+ const [[store, write_store]] = (0, $jb2Oo$useState)(() => (0, $jb2Oo$createStore)(props));
89
+ // Update store when props change
90
+ write_store((0, $jb2Oo$reconcile)(props));
91
+ (0, $jb2Oo$useEffect)(() => {
92
+ const wrapper_element = wrapper_element_ref.current;
93
+ // If someone only rendered a solid component on the client that *could* be hydrated (no childNodes) then we fall back to `render` to avoid solid complaining about not being able to hydrate or crashing because the result of generateHydrationScript hasn't run at all
94
+ // This can happen for HMR or when SSR capable components are only rendered on the client
95
+ const render_function = hydrate_function_when_ssr && wrapper_element.childNodes.length ? hydrate_function_when_ssr : (0, $jb2Oo$render);
96
+ const dispose = render_function(() => solid_component(store, set_portals), wrapper_element);
97
+ return dispose;
98
+ }, []);
99
+ return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, (0, $jb2Oo$createElement)(wrapper_type, {
100
+ ref: wrapper_element_ref,
101
+ style: wrapper_style,
102
+ ...(hydrate_function_when_ssr ? {
103
+ // We need this because on the server we put the solid SSR rendered string into html but it won't match on the client, luckily we can just suppress it
104
+ suppressHydrationWarning: true,
105
+ dangerouslySetInnerHTML: {
106
+ __html: ""
107
+ }
108
+ } : {})
109
+ }), ...portals);
110
+ }
111
+ function $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035(component, is_set) {
112
+ return function () {
113
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
114
+ const default_is_set = (0, $jb2Oo$createMemo)(() => !!((0, $8c691d7f86317052$export$8e769ad4338a911e).merchant[0]() && (0, $8c691d7f86317052$export$8e769ad4338a911e).market[0]())); // Apparently Show re-renders kids otherwise even if the falsiness of the condition doesn't change
115
+ const should_show = (0, $jb2Oo$createMemo)(prev => {
116
+ if (!prev && (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[0]())
117
+ // Why `!prev`? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7854#note_1495776987
118
+ // If we weren't showing the component and the DepictProvider is currently updating, wait for it to have finished updating before showing the component
119
+ // Otherwise as soon as tenant and market is set we render the CategoryPage, but we might not have a DepictCategory yet, see https://depictaiworkspace.slack.com/archives/C04UZ2Z0RNE/p1690895918347289?thread_ts=1688391305.529449&cid=C04UZ2Z0RNE
120
+ return false;
121
+ return (is_set || default_is_set)();
122
+ });
123
+ // @ts-ignore
124
+ return (0, $jb2Oo$createComponent)((0, $jb2Oo$Show), {
125
+ get when() {
126
+ return should_show();
127
+ },
128
+ get children() {
129
+ return component(...args);
130
+ }
131
+ });
132
+ };
133
+ }
134
+ async function $0dd9d9a9c7da4c1d$export$79c79419c1ef0081(_ref2) {
135
+ let {
136
+ display: display,
137
+ component_portals: component_portals,
138
+ set_portals: set_portals,
139
+ react_template: react_template
140
+ } = _ref2;
141
+ let set_react_has_ran_hooks;
142
+ let was_cleaned_up = false;
143
+ const react_has_ran_hooks = new Promise(r => set_react_has_ran_hooks = r);
144
+ const solid_container = document.createElement("div");
145
+ const owner = (0, $jb2Oo$getOwner)();
146
+ const reactProductCard = (0, $jb2Oo$jsx)(props => {
147
+ // Sneak in a hook into their product card component to know once react has finished rendering and running hooks
148
+ (0, $jb2Oo$useEffect)(set_react_has_ran_hooks, []);
149
+ return react_template(props);
150
+ }, {
151
+ display: display
152
+ });
153
+ const reactProductCardInErrorBoundary = (0, $jb2Oo$jsx)((0, $88d93ed7309e90d1$export$d0f82e3ef89b1f22), {
154
+ children: reactProductCard,
155
+ on_error: error => (0, $jb2Oo$runWithOwner)(owner, () => {
156
+ if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
157
+ throw new (0, $jb2Oo$ProductCardError)(error);
158
+ })
159
+ });
160
+ const portal = $jb2Oo$createPortal(reactProductCardInErrorBoundary, solid_container);
161
+ component_portals.add(portal);
162
+ set_portals([...component_portals]);
163
+ (0, $jb2Oo$onCleanup)(() => {
164
+ was_cleaned_up = true;
165
+ // this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
166
+ component_portals.delete(portal);
167
+ // Updating i.e. the merchant will cause a setState call while rendering the DepictProvider component which is illegal because it usually infinite loops react apps. In our case it doesn't though, so we just evade detection by doing it a microtask later. See also https://github.com/facebook/react/issues/18178#issuecomment-595846312
168
+ queueMicrotask(() => set_portals([...component_portals]));
169
+ });
170
+ await react_has_ran_hooks; // After react has created elements it still takes some time to actually connect the refs and run the hooks. We don't want to replace placeholders before then.
171
+ return [solid_container];
172
+ }
173
+ let $64144f6d578fd8ac$var$set = false;
174
+ let $64144f6d578fd8ac$var$padding_animation;
175
+ function $64144f6d578fd8ac$export$6453cbc34515a94d() {
176
+ var _window, _window$next, _window$next$router, _window$next$router$e;
177
+ const are_on_search_or_category_page = () => (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() || (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)();
178
+ if ($64144f6d578fd8ac$var$set) return; // Just being safe
179
+ $64144f6d578fd8ac$var$set = true;
180
+ // We used to initialise this variable with false which in some cases (scroll to top button in FloatingButtons) would cause the scroll to be blocked when it shouldn't (see https://depictaiworkspace.slack.com/archives/C058KQ3MU8Z/p1686141321127089?thread_ts=1686134246.109689&cid=C058KQ3MU8Z)
181
+ // I don't know why we'd want to initialise it with false? The only reason I can see is in the hopes of scroll restoration working on initial page load, but it basically never does due to react rendering and executing our component too late
182
+ let should_use_old_scroll = true;
183
+ const old_scrollTo = window.scrollTo;
184
+ const next_router_event_target = $64144f6d578fd8ac$var$make_next_router_event_target(); // So we can use once: true
185
+ window.scrollTo = function () {
186
+ if (should_use_old_scroll || process.env.__NEXT_SCROLL_RESTORATION || !are_on_search_or_category_page() || history.scrollRestoration === "manual" // I.e. Chimi has manual scroll restoration that we don't want to block https://depictaiworkspace.slack.com/archives/C058KQ3MU8Z/p1686658007164019?thread_ts=1686134246.109689&cid=C058KQ3MU8Z
187
+ ) {
188
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
189
+ return Reflect.apply(old_scrollTo, window, args);
190
+ } else should_use_old_scroll = true;
191
+ };
192
+ // When popping state, add padding in the same event as the "popstate" event (required) and then remove it once our stuff is in the DOM
193
+ addEventListener("popstate", (0, $jb2Oo$catchify)(() => {
194
+ if (!are_on_search_or_category_page()) {
195
+ $64144f6d578fd8ac$var$removeLotsOfPadding(); // Just making sure
196
+ return;
197
+ }
198
+ should_use_old_scroll = false;
199
+ const [get_search_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_in_dom;
200
+ const [get_category_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).category_page_in_dom;
201
+ const search_page_in_dom = (0, $jb2Oo$untrack)(get_search_page_in_dom);
202
+ const category_page_in_dom = (0, $jb2Oo$untrack)(get_category_page_in_dom);
203
+ const new_is_search = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)();
204
+ const new_is_category = (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)();
205
+ let accessor_to_wait_for;
206
+ if (search_page_in_dom && new_is_search || category_page_in_dom && new_is_category) {
207
+ // Already on the page we're going to
208
+ $64144f6d578fd8ac$var$removeLotsOfPadding();
209
+ return;
210
+ }
211
+ $64144f6d578fd8ac$var$addLotsOfPadding();
212
+ if (new_is_search && category_page_in_dom) accessor_to_wait_for = get_search_page_in_dom;else if (new_is_category && search_page_in_dom) accessor_to_wait_for = get_category_page_in_dom;else accessor_to_wait_for = new_is_search ? get_search_page_in_dom : get_category_page_in_dom;
213
+ (0, $jb2Oo$createRoot)(dispose => (0, $jb2Oo$createEffect)(() => {
214
+ if (accessor_to_wait_for()) {
215
+ $64144f6d578fd8ac$var$removeLotsOfPadding();
216
+ dispose();
217
+ }
218
+ }));
219
+ }));
220
+ (_window = window) === null || _window === void 0 || (_window$next = _window.next) === null || _window$next === void 0 || (_window$next$router = _window$next.router) === null || _window$next$router === void 0 || (_window$next$router$e = _window$next$router.events) === null || _window$next$router$e === void 0 || _window$next$router$e.on(
221
+ // We have to use the actual next router here, if we'd use next_router_event_target for this window.event wouldn't be the popstate anymore
222
+ "routeChangeStart", (0, $jb2Oo$catchify)(() => {
223
+ // this is for when we navigate to a new page (replaceState or pushState)
224
+ // We need to ensure that the page doesn't get shorter before the new history entry has been pushed
225
+ // There is beforeHistoryChange which fires literally the line of code before the history API is called, so we make the page long until a task after that
226
+ // The challenge is knowing on routeChangeStart if we're in a popstate (back/forward) or a pushState/replaceState
227
+ // We use the deprecated window.event property for that
228
+ // This is catchified, so we should see in sentry when it starts failing if browsers ever remove it???
229
+ if (window.event instanceof PopStateEvent) return;
230
+ $64144f6d578fd8ac$var$addLotsOfPadding();
231
+ next_router_event_target.addEventListener("beforeHistoryChange", (0, $jb2Oo$catchify)(() => (0, $jb2Oo$queueMacroTask)($64144f6d578fd8ac$var$removeLotsOfPadding)), {
232
+ once: true
233
+ });
234
+ }));
235
+ }
236
+ /*
237
+ Here we want to be able to add padding that *definitely* gets applied and then be able to revert precisely to what was before.
238
+ The best way to achieve this is using an animation that with the fill set to none. This is because animations have the absolute highest precedence in CSS, even higher than !important. Then, to revert to the old padding, we just play the animation which is 1ms long so, it immediately finishes and whatever was defined before takes precedence again.
239
+ */
240
+ function $64144f6d578fd8ac$var$addLotsOfPadding() {
241
+ var _history$state, _history$state$search, _history$state$search2;
242
+ if ($64144f6d578fd8ac$var$padding_animation) return; // We're already showing a bunch of padding
243
+ $64144f6d578fd8ac$var$padding_animation = document.body.animate({
244
+ paddingBottom: (((_history$state = history.state) === null || _history$state === void 0 ? void 0 : (_history$state$search = _history$state.search_scroll_restoration_data) === null || _history$state$search === void 0 ? void 0 : (_history$state$search2 = _history$state$search[0]) === null || _history$state$search2 === void 0 ? void 0 : _history$state$search2.min_results_loaded) || 150) * 500 + "px",
245
+ offset: 0
246
+ }, 1);
247
+ $64144f6d578fd8ac$var$padding_animation.pause();
248
+ }
249
+ function $64144f6d578fd8ac$var$removeLotsOfPadding() {
250
+ if ($64144f6d578fd8ac$var$padding_animation) {
251
+ $64144f6d578fd8ac$var$padding_animation.play();
252
+ $64144f6d578fd8ac$var$padding_animation = undefined;
253
+ }
254
+ }
255
+ function $64144f6d578fd8ac$var$make_next_router_event_target() {
256
+ var _window2, _window2$next, _window2$next$router, _window2$next$router$;
257
+ const next_router_event_target = new EventTarget();
258
+ (_window2 = window) === null || _window2 === void 0 || (_window2$next = _window2.next) === null || _window2$next === void 0 || (_window2$next$router = _window2$next.router) === null || _window2$next$router === void 0 || (_window2$next$router$ = _window2$next$router.events) === null || _window2$next$router$ === void 0 || _window2$next$router$.on("beforeHistoryChange", () => next_router_event_target.dispatchEvent(new CustomEvent("beforeHistoryChange")));
259
+ return next_router_event_target;
260
+ }
261
+ const $7abe9e29758fa0eb$export$599d4515591ef232 = (relativeUrl, isReplace, scroll) => {
262
+ let Page;
263
+ (function (Page) {
264
+ Page[Page["OTHER"] = 0] = "OTHER";
265
+ Page[Page["SEARCH"] = 1] = "SEARCH";
266
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
267
+ })(Page || (Page = {}));
268
+ const current_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
269
+ const target_u_o = new URL(relativeUrl, location.origin);
270
+ const target_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
271
+ window.next.router[isReplace ? "replace" : "push"](relativeUrl, undefined, {
272
+ shallow: current_page === target_page && target_page !== Page.OTHER,
273
+ scroll:
274
+ // Can't go shallowly to other pages
275
+ scroll
276
+ });
277
+ };
278
+ const $b34796f5ebe3470e$export$38b98fae14bd1f64 = () => {
279
+ if (!(0, $8c691d7f86317052$export$8e769ad4338a911e).dpc) throw new Error("Depict tracking is not configured. Wrap your app in a DepictProvider.");
280
+ return {
281
+ dpc: (0, $8c691d7f86317052$export$8e769ad4338a911e).dpc
282
+ };
283
+ };
284
+ const $b34796f5ebe3470e$export$47e064413edabf36 = (merchant, market, userId, sessionId) => {
285
+ if (!merchant) return;
286
+ try {
287
+ let {
288
+ dpc: dpc
289
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
290
+ if (!dpc) dpc = (0, $8c691d7f86317052$export$8e769ad4338a911e).dpc = new (0, $jb2Oo$DPC)(merchant, {
291
+ market: market
292
+ });
293
+ dpc.merchant = merchant;
294
+ dpc.market = market;
295
+ dpc.setUserId(userId);
296
+ dpc.setSessionId(sessionId);
297
+ } catch (e) {
298
+ // Make sure to not break the users app if we throw
299
+ queueMicrotask(() => {
300
+ throw e;
301
+ });
302
+ }
303
+ };
304
+ function $bef9f58602be2478$export$bae2769a30719c48(disposable, stateKey) {
305
+ const actual_function = dispose => {
306
+ var _globalState$enableCa;
307
+ const {
308
+ usedLocale: [get_locale],
309
+ merchant: [get_merchant],
310
+ market: [get_market],
311
+ search_query_url_param_name: search_query_url_param_name,
312
+ search_page_path_: [get_search_page_path]
313
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
314
+ const instance = new (0, $jb2Oo$DepictSearch)({
315
+ api: (0, $8c691d7f86317052$export$8e769ad4338a911e).api,
316
+ search_query_url_param_name: search_query_url_param_name,
317
+ market: (0, $jb2Oo$untrack)(get_market),
318
+ // TODO: check if we can do this
319
+ merchant: (0, $jb2Oo$untrack)(get_merchant),
320
+ enable_category_suggestions: (_globalState$enableCa = (0, $8c691d7f86317052$export$8e769ad4338a911e).enableCategorySuggestions) !== null && _globalState$enableCa !== void 0 ? _globalState$enableCa : false,
321
+ // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
322
+ localization: (0, $jb2Oo$untrack)(get_locale),
323
+ url_transformer: url => url.pathname = (0, $jb2Oo$untrack)(get_search_page_path),
324
+ on_navigation: (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation,
325
+ unique_instance_key_for_state: stateKey
326
+ });
327
+ (0, $jb2Oo$createComputed)(() => {
328
+ const new_merchant = get_merchant();
329
+ if (new_merchant) instance.merchant = new_merchant;
330
+ });
331
+ (0, $jb2Oo$createComputed)(() => {
332
+ const new_market = get_market();
333
+ if (new_market) instance.market = new_market;
334
+ });
335
+ (0, $jb2Oo$createComputed)(() => instance.localization = get_locale());
336
+ return {
337
+ instance: instance,
338
+ dispose: dispose,
339
+ users: 0
340
+ };
341
+ };
342
+ const function_length_0 = () => actual_function();
343
+ const function_length_1 = dispose => actual_function(dispose);
344
+ return (0, $jb2Oo$createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
345
+ }
346
+
347
+ function $b1c85026e863c95b$export$248b95d5073d5bab(disposable, stateKey) {
348
+ const actual_function = dispose => {
349
+ const {
350
+ usedLocale: [get_locale],
351
+ merchant: [get_merchant],
352
+ market: [get_market]
353
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
354
+ const instance = new (0, $jb2Oo$DepictCategory)({
355
+ api: (0, $8c691d7f86317052$export$8e769ad4338a911e).api,
356
+ market: (0, $jb2Oo$untrack)(get_market),
357
+ // TODO: check if we can do this
358
+ merchant: (0, $jb2Oo$untrack)(get_merchant),
359
+ localization: (0, $jb2Oo$untrack)(get_locale),
360
+ on_navigation: (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation,
361
+ unique_instance_key_for_state: stateKey
362
+ });
363
+ (0, $jb2Oo$createComputed)(() => {
364
+ const new_merchant = get_merchant();
365
+ if (new_merchant) instance.merchant = new_merchant;
366
+ });
367
+ (0, $jb2Oo$createComputed)(() => {
368
+ const new_market = get_market();
369
+ if (new_market) instance.market = new_market;
370
+ });
371
+ (0, $jb2Oo$createComputed)(() => instance.localization = get_locale());
372
+ return {
373
+ instance: instance,
374
+ dispose: dispose,
375
+ users: 0
376
+ };
377
+ };
378
+ const function_length_0 = () => actual_function();
379
+ const function_length_1 = dispose => actual_function(dispose);
380
+ return (0, $jb2Oo$createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
381
+ }
382
+
383
+ let $18e5b9f66c7ade8e$var$provider_instances = 0;
384
+ function $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b(props) {
385
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[1](true);
386
+ try {
387
+ return $18e5b9f66c7ade8e$var$ActualDepictProvider(props);
388
+ } finally {
389
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).provider_is_updating[1](false);
390
+ }
391
+ }
392
+ function $18e5b9f66c7ade8e$var$ActualDepictProvider(props) {
393
+ var _props$search;
394
+ const {
395
+ children: children,
396
+ navigateFunction: navigateFunction,
397
+ market: market,
398
+ merchant: merchant,
399
+ locale: locale,
400
+ metaData: metaData,
401
+ userId: userId,
402
+ sessionId: sessionId
403
+ } = props;
404
+ const usedLocale = locale !== null && locale !== void 0 ? locale : (0, $jb2Oo$defaultLocale);
405
+ const {
406
+ searchPagePath: searchPagePath,
407
+ urlParamName: urlParamName,
408
+ enableCategorySuggestions: enableCategorySuggestions
409
+ } = (_props$search = props.search) !== null && _props$search !== void 0 ? _props$search : {};
410
+ $18e5b9f66c7ade8e$var$multiple_depictprovider_guard();
411
+ // Will run on other prop changes, but harmless
412
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).userId[1](userId);
413
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).sessionId[1](sessionId);
414
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).usedLocale[1](usedLocale);
415
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).metaData = metaData;
416
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).search_query_url_param_name = urlParamName;
417
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).enableCategorySuggestions = enableCategorySuggestions;
418
+ (0, $b34796f5ebe3470e$export$47e064413edabf36)(merchant, market, userId, sessionId);
419
+ if (!market || !merchant) return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, children);
420
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).market[1](market);
421
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).merchant[1](merchant);
422
+ (0, $64144f6d578fd8ac$export$6453cbc34515a94d)();
423
+ try {
424
+ var _window, _window$next;
425
+ const {
426
+ search_instances: search_instances,
427
+ category_instances: category_instances,
428
+ api: api,
429
+ search_page_path_: [, set_search_page_path]
430
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
431
+ if (typeof ((_window = window) === null || _window === void 0 ? void 0 : (_window$next = _window.next) === null || _window$next === void 0 ? void 0 : _window$next.router) === "undefined" && !navigateFunction) throw new Error("You must provide a navigateFunction when not using Next.js.");
432
+ const on_navigation = _ref => {
433
+ let {
434
+ is_replace: is_replace,
435
+ new_url: new_url,
436
+ scroll: scroll
437
+ } = _ref;
438
+ const new_relative_url = new_url.origin === location.origin ? new_url.pathname + new_url.search + new_url.hash : new_url.href; // bail out of making URL relative if it's not possible
439
+ if (navigateFunction) navigateFunction(new_relative_url, {
440
+ replace: is_replace,
441
+ scroll: scroll
442
+ });else (0, $7abe9e29758fa0eb$export$599d4515591ef232)(new_relative_url, is_replace, scroll);
443
+ };
444
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).on_navigation = on_navigation;
445
+ if (!api) (0, $8c691d7f86317052$export$8e769ad4338a911e).api = new (0, $jb2Oo$DepictAPI)({
446
+ get_metadata: async () => (0, $8c691d7f86317052$export$8e769ad4338a911e).metaData,
447
+ get_user_id: () => (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).userId[0]),
448
+ get_session_id: () => (0, $jb2Oo$untrack)((0, $8c691d7f86317052$export$8e769ad4338a911e).sessionId[0])
449
+ });
450
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).api.page_url_creator = props.pageURLCreator;
451
+ if (searchPagePath) set_search_page_path($18e5b9f66c7ade8e$var$ensure_correct_formatting(searchPagePath));
452
+ if (!search_instances.get(undefined)) {
453
+ // Create initial search instance which always exists. It i.e. gards against the state getting deleted from history.state by someone pushing to it with an empty object, which commonly people copy from code snippets.
454
+ // Also, it emulates the behavior pre-supporting multiple "depict blocks" on the same page
455
+ const instance = (0, $bef9f58602be2478$export$bae2769a30719c48)(false);
456
+ search_instances.set(undefined, instance);
457
+ }
458
+ if (!category_instances.get(undefined)) {
459
+ const instance = (0, $b1c85026e863c95b$export$248b95d5073d5bab)(false);
460
+ category_instances.set(undefined, instance);
461
+ }
462
+ } catch (e) {
463
+ // Make sure to not break the users app if we throw
464
+ queueMicrotask(() => {
465
+ throw e;
466
+ });
467
+ }
468
+ return (0, $jb2Oo$createElement)((0, $jb2Oo$Fragment), null, children);
469
+ }
470
+ function $18e5b9f66c7ade8e$var$ensure_correct_formatting(path) {
471
+ // Make sure the path starts with a slash as it always will and is_page will fail otherwise
472
+ if (!path.startsWith("/")) return "/" + path;
473
+ return path;
474
+ }
475
+ function $18e5b9f66c7ade8e$var$multiple_depictprovider_guard() {
476
+ (0, $jb2Oo$useEffect)(() => {
477
+ $18e5b9f66c7ade8e$var$provider_instances++;
478
+ if ($18e5b9f66c7ade8e$var$provider_instances > 1) throw new Error("You are using multiple DepictProviders. This is not supported and will lead to unexpected behavior. You can create multiple SearchPage and CategoryPage components, but only one DepictProvider.");
479
+ return () => {
480
+ $18e5b9f66c7ade8e$var$provider_instances--;
481
+ };
482
+ }, []);
483
+ }
484
+ const $f6a205a95e4fdee3$export$80e99ee6b29cadd2 = /*#__PURE__*/(0, $jb2Oo$forwardRef)((_, ref) => {
485
+ return /*#__PURE__*/(0, $jb2Oo$createElement)("div", {
486
+ className: "depict aligner",
487
+ style: {
488
+ height: "100%"
489
+ },
490
+ ref: ref
491
+ });
492
+ });
493
+ function $fda7a7820477f957$export$f4d89133c6985668(type, stateKey, componentName) {
494
+ const instances = (0, $8c691d7f86317052$export$8e769ad4338a911e)[type + "_instances"];
495
+ if (!instances.get(undefined)) throw Error("".concat(componentName, ": State not set up. Did you forget to wrap your app in DepictProvider? Also make sure you've provided a merchant and a market."));
496
+ let instance = instances.get(stateKey);
497
+ if (!instance) {
498
+ instance = type === "search" ? (0, $bef9f58602be2478$export$bae2769a30719c48)(true, stateKey) : (0, $b1c85026e863c95b$export$248b95d5073d5bab)(true, stateKey);
499
+ instances.set(stateKey, instance);
500
+ }
501
+ instance.users++;
502
+ (0, $jb2Oo$onCleanup)(() => {
503
+ var _instance;
504
+ instance.users--;
505
+ if (!instance.users && (_instance = instance) !== null && _instance !== void 0 && _instance.dispose) {
506
+ // main instance is not disposable, and shouldn't be deletable either
507
+ instance.dispose();
508
+ instances.delete(stateKey);
509
+ }
510
+ });
511
+ return instance.instance;
512
+ }
513
+ const $d059770e7af9e2dc$var$rendered_components_with_state_key = new Set();
514
+ function $d059770e7af9e2dc$export$a54ec244c8863715(props) {
515
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
516
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($d059770e7af9e2dc$var$SolidSearchPage),
517
+ props: props
518
+ });
519
+ }
520
+ function $d059770e7af9e2dc$var$SolidSearchPage(props, set_portals) {
521
+ const depict_search = (0, $jb2Oo$createMemo)(() => {
522
+ const instance = (0, $fda7a7820477f957$export$f4d89133c6985668)("search", props.stateKey, "SearchPage");
523
+ (0, $jb2Oo$onCleanup)(() => {
524
+ var _get_search_query_upd;
525
+ // Make sure we don't block the search query updating signal when we switch to a new provider instance
526
+ (_get_search_query_upd = (0, $jb2Oo$get_search_query_updating_blocked_signal)(instance)) === null || _get_search_query_upd === void 0 || _get_search_query_upd[1](false);
527
+ });
528
+ return instance;
529
+ });
530
+ const update_updating_blocked_signal = () => {
531
+ // if search instances changes, also re-check for good measure (otherwise would have untrack around depict_search)
532
+ const signal = (0, $jb2Oo$get_search_query_updating_blocked_signal)(depict_search());
533
+ if (!signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
534
+ const [, write_signal] = signal;
535
+ // This causes a bug. To reproduce:
536
+ // 1. Go to front page
537
+ // 2. Make a search
538
+ // 3. Press back button
539
+ // 4. Open search modal
540
+ // 5. Check the list of previous queries - the query just made isn't shown
541
+ // This is because on the front page the search_query updating is blocked because it's not the search page, and that means that `filtered_previous_searches` in Autocomplete.tsx doesn't filter out the current search query
542
+ // Because it's so minor and would be quite hard to fix (one would need a second "actual search query" signal just for this purpose) it's wontfix for now
543
+ // EDIT: now that we're resetting this in the onCleanup of the memo above this might no longer be the case
544
+ write_signal(!(0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(location));
545
+ };
546
+ const [, set_search_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_in_dom;
547
+ const component_portals = new Set();
548
+ // We should only get here once react already has a DOM node which means we should be in the DOM
549
+ set_search_page_in_dom(true);
550
+ (0, $jb2Oo$onCleanup)(() => set_search_page_in_dom(false));
551
+ // react is really slow with disposing components, we want to avoid a flash of another search query when you click on a product and navigate away
552
+ (0, $0dd9d9a9c7da4c1d$export$74f3924c5027fe1d)(update_updating_blocked_signal); // if we navigate, re-check
553
+ (0, $jb2Oo$createComputed)(() => {
554
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0](); // if react defined path changes, re-check
555
+ update_updating_blocked_signal();
556
+ });
557
+ $d059770e7af9e2dc$var$search_page_path_checker();
558
+ return (0, $jb2Oo$createMemo)(() => {
559
+ const stateKey = (0, $jb2Oo$untrack)(() => props.stateKey);
560
+ if ($d059770e7af9e2dc$var$rendered_components_with_state_key.has(stateKey)) throw new Error("You have multiple SearchPage components with the same stateKey: ".concat(stateKey, ". Each SearchPage component must have a unique stateKey."));
561
+ $d059770e7af9e2dc$var$rendered_components_with_state_key.add(stateKey);
562
+ (0, $jb2Oo$onCleanup)(() => $d059770e7af9e2dc$var$rendered_components_with_state_key.delete(stateKey));
563
+ return (0, $jb2Oo$SearchPage)({
564
+ // Default config goes here
565
+ get include_input_field() {
566
+ return props.includeInputField;
567
+ },
568
+ get cols_at_size() {
569
+ var _props$columnsAtSize;
570
+ return (_props$columnsAtSize = props.columnsAtSize) !== null && _props$columnsAtSize !== void 0 ? _props$columnsAtSize : (0, $jb2Oo$defaultColsAtSize);
571
+ },
572
+ get grid_spacing() {
573
+ var _props$gridSpacing;
574
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
575
+ },
576
+ depict_search: depict_search(),
577
+ product_card_template: display => (0, $0dd9d9a9c7da4c1d$export$79c79419c1ef0081)({
578
+ display: display,
579
+ react_template: (0, $jb2Oo$untrack)(() => props.productCard),
580
+ component_portals: component_portals,
581
+ set_portals: set_portals
582
+ })
583
+ });
584
+ });
585
+ }
586
+ /**
587
+ * Users often set the searchPagePath to something without the market which breaks everything using the searchPagePath internally, notably refining the search query. Add a warning for them.
588
+ */
589
+ function $d059770e7af9e2dc$var$search_page_path_checker() {
590
+ let has_warned = false;
591
+ (0, $jb2Oo$createEffect)(() => {
592
+ if (has_warned) return;
593
+ const should_be_path = (0, $8c691d7f86317052$export$8e769ad4338a911e).search_page_path_[0]();
594
+ const {
595
+ pathname: pathname
596
+ } = location;
597
+ if (
598
+ // allow some variability just to be sure
599
+ should_be_path !== pathname && should_be_path + "/" !== pathname && should_be_path !== pathname + "/") {
600
+ (0, $jb2Oo$derror)("searchPagePath is set to", should_be_path, "but the SearchPage is rendered at", pathname, ". Please double-check your searchPagePath is where the SearchPage component ends up being rendered, after all redirects, unless you're sure this is intentional.");
601
+ has_warned = true;
602
+ }
603
+ });
604
+ }
605
+ const $e86a296a07b17ad5$var$rendered_components_with_state_key = new Set();
606
+ function $e86a296a07b17ad5$export$f7d2f673fc2f091d(props) {
607
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
608
+ // @ts-ignore
609
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($e86a296a07b17ad5$var$SolidCategoryPage),
610
+ props: props,
611
+ wrapper_type: "div",
612
+ wrapper_style: {}
613
+ });
614
+ }
615
+ function $e86a296a07b17ad5$var$SolidCategoryPage(props, set_portals) {
616
+ const depict_category = (0, $jb2Oo$createMemo)(() => (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "CategoryPage") // stateKey can change
617
+ );
618
+
619
+ const [category_state_set, set_category_state_set] = (0, $jb2Oo$createSignal)(false);
620
+ const component_portals = new Set();
621
+ const [, set_category_page_in_dom] = (0, $8c691d7f86317052$export$8e769ad4338a911e).category_page_in_dom;
622
+ // We should only get here once react already has a DOM node which means we should be in the DOM
623
+ set_category_page_in_dom(true);
624
+ (0, $jb2Oo$onCleanup)(() => set_category_page_in_dom(false));
625
+ (0, $jb2Oo$createComputed)(() => {
626
+ const {
627
+ categoryId: categoryId
628
+ } = props;
629
+ depict_category().category_id = categoryId;
630
+ if (categoryId) {
631
+ set_category_state_set(true);
632
+ (0, $8c691d7f86317052$export$8e769ad4338a911e).known_category_paths.add(location.pathname);
633
+ }
634
+ });
635
+ (0, $jb2Oo$createComputed)(() => depict_category().listing_type = props.listingType);
636
+ const category = () => (0, $jb2Oo$createMemo)(() => {
637
+ const stateKey = (0, $jb2Oo$untrack)(() => props.stateKey);
638
+ if ($e86a296a07b17ad5$var$rendered_components_with_state_key.has(stateKey)) throw new Error("You have multiple CategoryPage components with the same stateKey: ".concat(stateKey, ". Each CategoryPage component must have a unique stateKey."));
639
+ $e86a296a07b17ad5$var$rendered_components_with_state_key.add(stateKey);
640
+ (0, $jb2Oo$onCleanup)(() => $e86a296a07b17ad5$var$rendered_components_with_state_key.delete(stateKey));
641
+ return (0, $jb2Oo$CategoryPage)({
642
+ depict_category: depict_category(),
643
+ get cols_at_size() {
644
+ var _props$columnsAtSize;
645
+ return (_props$columnsAtSize = props.columnsAtSize) !== null && _props$columnsAtSize !== void 0 ? _props$columnsAtSize : (0, $jb2Oo$defaultColsAtSize);
646
+ },
647
+ get grid_spacing() {
648
+ var _props$gridSpacing;
649
+ return (_props$gridSpacing = props.gridSpacing) !== null && _props$gridSpacing !== void 0 ? _props$gridSpacing : (0, $jb2Oo$defaultGridSpacing);
650
+ },
651
+ category_title: (0, $jb2Oo$untrack)(() => props.categoryTitlePlugin) || (0, $jb2Oo$defaultCategoryTitlePlugin),
652
+ get show_breadcrumbs() {
653
+ return props.showBreadcrumbs;
654
+ },
655
+ get show_quicklinks() {
656
+ return props.showQuicklinks;
657
+ },
658
+ product_card_template: display => (0, $0dd9d9a9c7da4c1d$export$79c79419c1ef0081)({
659
+ display: display,
660
+ react_template: (0, $jb2Oo$untrack)(() => props.productCard),
661
+ component_portals: component_portals,
662
+ set_portals: set_portals
663
+ })
664
+ });
665
+ });
666
+ return (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)(category, category_state_set);
667
+ }
668
+ function $ec632214ac078e79$export$5646050d516e06bc(react_props) {
669
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
670
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($ec632214ac078e79$var$vanilla_breadcrumbs),
671
+ props: react_props
672
+ });
673
+ }
674
+ function $ec632214ac078e79$var$vanilla_breadcrumbs(props) {
675
+ // memo so stateKey can be dynamically changed
676
+ return (0, $jb2Oo$createMemo)(() => {
677
+ const depict_category = (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "BreadCrumbs");
678
+ return (0, $jb2Oo$BreadCrumbs)({
679
+ depict_category: depict_category
680
+ });
681
+ });
682
+ }
683
+ function $c61814cfb91ead09$export$466cdc317043f6cb() {
684
+ let react_props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
685
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
686
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)($c61814cfb91ead09$var$vanilla_quick_links),
687
+ props: react_props
688
+ });
689
+ }
690
+ function $c61814cfb91ead09$var$vanilla_quick_links(props) {
691
+ // memo so stateKey can be dynamically changed
692
+ return (0, $jb2Oo$createMemo)(() => {
693
+ const depict_category = (0, $fda7a7820477f957$export$f4d89133c6985668)("category", props.stateKey, "QuickLinks");
694
+ return (0, $jb2Oo$QuickLinks)({
695
+ depict_category: depict_category
696
+ });
697
+ });
698
+ }
699
+ const $6406849926c3f794$export$3f37af283f8fb843 = raw_react_props => {
700
+ const react_props = {
701
+ class: raw_react_props.className,
702
+ ...raw_react_props
703
+ };
704
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
705
+ solid_component: props_store => (0, $jb2Oo$ImagePlaceholder)(props_store),
706
+ props: react_props,
707
+ wrapper_type: "span",
708
+ hydrate_function_when_ssr: (0, $jb2Oo$hydrate)
709
+ });
710
+ };
711
+ const $2c7738b65cbcac1c$export$89c6019e4baa40b1 = raw_react_props => {
712
+ const react_props = {
713
+ class: raw_react_props.className,
714
+ ...raw_react_props
715
+ };
716
+ return (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
717
+ solid_component: props_store => (0, $jb2Oo$TextPlaceholder)(props_store),
718
+ props: react_props,
719
+ wrapper_type: "span",
720
+ hydrate_function_when_ssr: (0, $jb2Oo$hydrate),
721
+ wrapper_style: {
722
+ "height": "100%"
723
+ }
724
+ });
725
+ };
726
+ const $1283ca5a3f4a4617$export$d69d8daa20eae175 = createOpenModalParams => {
727
+ const {
728
+ location = "centered",
729
+ alignerRef: alignerRef,
730
+ stateKey: stateKey
731
+ } = createOpenModalParams;
732
+ let [deduped_variable, set_deduped_variable] = (0, $jb2Oo$useState)();
733
+ // When component using this hook unmounts, "untrack" our component and dispose the search instance if needed
734
+ (0, $jb2Oo$useEffect)(() => {
735
+ var _deduped_variable, _deduped_variable$;
736
+ return (_deduped_variable = deduped_variable) === null || _deduped_variable === void 0 ? void 0 : (_deduped_variable$ = _deduped_variable[1]) === null || _deduped_variable$ === void 0 ? void 0 : _deduped_variable$.call(_deduped_variable);
737
+ }, []);
738
+ const openModal = () => {
739
+ // Get the search instance and track this component, but only once (basically work around re-rendering)
740
+ // We have to do this in the openModal function since people might call this hook before creating DepictProvider
741
+ if (!deduped_variable) {
742
+ deduped_variable = (0, $jb2Oo$createRoot)(dispose => [(0, $fda7a7820477f957$export$f4d89133c6985668)("search", stateKey, "useSearchModal"), dispose]);
743
+ set_deduped_variable(deduped_variable);
744
+ }
745
+ const [search] = deduped_variable;
746
+ if (location === "aligned" && alignerRef !== null && alignerRef !== void 0 && alignerRef.current) (0, $jb2Oo$open_modal_with_alignment)({
747
+ "element": alignerRef.current,
748
+ "location": location,
749
+ "search": search
750
+ });else (0, $jb2Oo$open_modal_with_alignment)({
751
+ "location": "centered",
752
+ "search": search
753
+ });
754
+ };
755
+ return openModal;
756
+ };
757
+ function $356d18d3ed66814e$export$912994940e660d32() {
758
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
759
+ const open = (0, $1283ca5a3f4a4617$export$d69d8daa20eae175)({
760
+ globalState: $8c691d7f86317052$export$8e769ad4338a911e,
761
+ ...params
762
+ });
763
+ return {
764
+ open: open
765
+ };
766
+ }
767
+ const $4c71282d292aac6d$export$9bb30bbe003b82e0 = function () {
768
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
769
+ // We should just export a plain SearchField component here, not a weird hook thing, but I don't want to make a breaking change. Just fixing the re-rendering issue for now.
770
+ // Create signal that persists across renders
771
+ const [[get_aligner_signal_value, set_aligner_signal_value]] = (0, $jb2Oo$useState)((0, $jb2Oo$createSignal)());
772
+ // Update signal value when alignerRef changes
773
+ set_aligner_signal_value(props === null || props === void 0 ? void 0 : props.alignerRef);
774
+ // Make sure react never re-renders the actual SearchField component
775
+ const componentFunction = (0, $jb2Oo$useCallback)(() => (0, $0dd9d9a9c7da4c1d$export$f6e64e17bd69eeef)({
776
+ solid_component: (0, $0dd9d9a9c7da4c1d$export$e5139bbbb9a05035)(() => {
777
+ return (0, $jb2Oo$createMemo)(() => {
778
+ const depict_search = (0, $fda7a7820477f957$export$f4d89133c6985668)("search", props.stateKey, "useSearchField");
779
+ return (0, $jb2Oo$SearchField)({
780
+ depict_search: depict_search,
781
+ get aligner_ref() {
782
+ var _get_aligner_signal_v;
783
+ // React mutates the object at some random time so only get the current value once it actually is requested
784
+ return (_get_aligner_signal_v = get_aligner_signal_value()) === null || _get_aligner_signal_v === void 0 ? void 0 : _get_aligner_signal_v.current;
785
+ }
786
+ });
787
+ });
788
+ }),
789
+ props: {}
790
+ }), []);
791
+ return {
792
+ SearchField: componentFunction
793
+ };
794
+ };
795
+ function $1895644749ca8d8a$export$6501da23a2770fc() {
796
+ return {
797
+ fetchRecommendations: $1895644749ca8d8a$var$fetchRecommendations
798
+ };
799
+ }
800
+ function $1895644749ca8d8a$var$fetchRecommendations(opts) {
801
+ const {
802
+ merchant: [get_merchant],
803
+ market: [get_market],
804
+ userId: [get_userId],
805
+ sessionId: [get_sessionId]
806
+ } = (0, $8c691d7f86317052$export$8e769ad4338a911e);
807
+ const merchant = (0, $jb2Oo$untrack)(get_merchant);
808
+ const market = (0, $jb2Oo$untrack)(get_market);
809
+ if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
810
+ return (0, $jb2Oo$fetchDepictRecommendations)({
811
+ merchant: merchant,
812
+ market: market,
813
+ userId: (0, $jb2Oo$untrack)(get_userId),
814
+ sessionId: (0, $jb2Oo$untrack)(get_sessionId),
815
+ ...opts
816
+ });
817
+ }
818
+ const $05726fa9c7eda0a1$export$804fac5697cfbe35 = router => (relativeUrl, _ref) => {
819
+ let {
820
+ scroll: scroll,
821
+ replace: replace
822
+ } = _ref;
823
+ let Page;
824
+ (function (Page) {
825
+ Page[Page["OTHER"] = 0] = "OTHER";
826
+ Page[Page["SEARCH"] = 1] = "SEARCH";
827
+ Page[Page["CATEGORY"] = 2] = "CATEGORY";
828
+ })(Page || (Page = {}));
829
+ const current_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)() ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)() ? Page.CATEGORY : Page.OTHER;
830
+ const target_u_o = new URL(relativeUrl, location.origin);
831
+ const target_page = (0, $0dd9d9a9c7da4c1d$export$775e6b3892b5ad52)(target_u_o) ? Page.SEARCH : (0, $0dd9d9a9c7da4c1d$export$30c8a12df09be0e4)(target_u_o) ? Page.CATEGORY : Page.OTHER;
832
+ router[replace ? "replace" : "push"](relativeUrl, undefined, {
833
+ shallow: current_page === target_page && target_page !== Page.OTHER,
834
+ scroll:
835
+ // Can't go shallowly to other pages
836
+ scroll
837
+ });
838
+ };
839
+ const $a7dfdd84298ae791$export$b8a61e5c71402559 = {
840
+ nextRouterNavigation: $05726fa9c7eda0a1$export$804fac5697cfbe35
841
+ };
842
+ (0, $jb2Oo$add_to_version_info)("react-ui", (0, $9bd9bb8700ab2ada$export$83d89fbfd8236492));
843
+ export { $c61814cfb91ead09$export$466cdc317043f6cb as QuickLinks, $ec632214ac078e79$export$5646050d516e06bc as BreadCrumbs, $f6a205a95e4fdee3$export$80e99ee6b29cadd2 as ComponentAligner, $18e5b9f66c7ade8e$export$9fac37a9c21c2f3b as DepictProvider, $e86a296a07b17ad5$export$f7d2f673fc2f091d as CategoryPage, $d059770e7af9e2dc$export$a54ec244c8863715 as SearchPage, $6406849926c3f794$export$3f37af283f8fb843 as ImagePlaceholder, $2c7738b65cbcac1c$export$89c6019e4baa40b1 as TextPlaceholder, $356d18d3ed66814e$export$912994940e660d32 as useSearchModal, $4c71282d292aac6d$export$9bb30bbe003b82e0 as useSearchField, $1895644749ca8d8a$export$6501da23a2770fc as useFetchRecommendations, $b34796f5ebe3470e$export$38b98fae14bd1f64 as usePerformanceClient, $383b6fd56bf151bd$re_export$CategoryTitle as CategoryTitle, $383b6fd56bf151bd$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $9bd9bb8700ab2ada$export$83d89fbfd8236492 as version, $a7dfdd84298ae791$export$b8a61e5c71402559 as Navigation };