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