@depict-ai/react-ui 1.5.3 → 1.5.5

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