vdb-ai-chat 1.0.14 → 1.0.16

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.
Files changed (40) hide show
  1. package/dist/chat-widget.js +1 -1
  2. package/lib/commonjs/api.js +44 -3
  3. package/lib/commonjs/api.js.map +1 -1
  4. package/lib/commonjs/components/ChatWidget.js +129 -34
  5. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  6. package/lib/commonjs/components/MessageBubble.js +3 -1
  7. package/lib/commonjs/components/MessageBubble.js.map +1 -1
  8. package/lib/commonjs/components/ProductsListView.js +2 -3
  9. package/lib/commonjs/components/ProductsListView.js.map +1 -1
  10. package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
  11. package/lib/commonjs/components/utils.js +436 -5
  12. package/lib/commonjs/components/utils.js.map +1 -1
  13. package/lib/module/api.js +43 -3
  14. package/lib/module/api.js.map +1 -1
  15. package/lib/module/components/ChatWidget.js +131 -36
  16. package/lib/module/components/ChatWidget.js.map +1 -1
  17. package/lib/module/components/MessageBubble.js +3 -1
  18. package/lib/module/components/MessageBubble.js.map +1 -1
  19. package/lib/module/components/ProductsListView.js +2 -3
  20. package/lib/module/components/ProductsListView.js.map +1 -1
  21. package/lib/module/components/SuggestionsRow.js.map +1 -1
  22. package/lib/module/components/utils.js +434 -4
  23. package/lib/module/components/utils.js.map +1 -1
  24. package/lib/module/hooks/useAnalytics.js.map +1 -1
  25. package/lib/typescript/api.d.ts +12 -0
  26. package/lib/typescript/api.d.ts.map +1 -1
  27. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  28. package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
  29. package/lib/typescript/components/ProductsListView.d.ts.map +1 -1
  30. package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
  31. package/lib/typescript/components/utils.d.ts +6 -0
  32. package/lib/typescript/components/utils.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/api.ts +69 -7
  35. package/src/components/ChatWidget.tsx +187 -36
  36. package/src/components/MessageBubble.tsx +15 -4
  37. package/src/components/ProductsListView.tsx +32 -17
  38. package/src/components/SuggestionsRow.tsx +1 -7
  39. package/src/components/utils.ts +545 -7
  40. package/src/hooks/useAnalytics.tsx +2 -2
@@ -9,7 +9,11 @@ import {
9
9
  Image,
10
10
  Pressable,
11
11
  } from "react-native";
12
- import { getUserCurrencySymbol, formatPriceValue, roundUpPrices } from "./utils";
12
+ import {
13
+ getUserCurrencySymbol,
14
+ formatPriceValue,
15
+ roundUpPrices,
16
+ } from "./utils";
13
17
  import { useTheme } from "styled-components/native";
14
18
  import { DefaultTheme } from "styled-components/native";
15
19
  import styled from "styled-components/native";
@@ -132,8 +136,10 @@ const renderToken = (
132
136
  shouldRound: boolean = false
133
137
  ): React.ReactNode => {
134
138
  const TextView = token.style === "secondary" ? TextStyleTwo : TextStyleOne;
135
- const PrefixTextView = token.prefixStyle === "secondary" ? TextStyleTwo : TextStyleOne;
136
- const SuffixTextView = token.suffixStyle === "secondary" ? TextStyleTwo : TextStyleOne;
139
+ const PrefixTextView =
140
+ token.prefixStyle === "secondary" ? TextStyleTwo : TextStyleOne;
141
+ const SuffixTextView =
142
+ token.suffixStyle === "secondary" ? TextStyleTwo : TextStyleOne;
137
143
  const currency = userCurrency || "$";
138
144
  const theme = useTheme();
139
145
  switch (token.type) {
@@ -154,7 +160,9 @@ const renderToken = (
154
160
  }
155
161
  return (
156
162
  <React.Fragment key={index}>
157
- {token.prefix && <PrefixTextView theme={theme}>{token.prefix}</PrefixTextView>}
163
+ {token.prefix && (
164
+ <PrefixTextView theme={theme}>{token.prefix}</PrefixTextView>
165
+ )}
158
166
  <TextView theme={theme}>{value}</TextView>
159
167
  </React.Fragment>
160
168
  );
@@ -178,14 +186,15 @@ const renderToken = (
178
186
  case "priceField": {
179
187
  const value = item[token.field!];
180
188
  const formattedPrice = formatPriceValue(token.field!, value, shouldRound);
181
- console.log("formattedPrice", formattedPrice);
182
-
189
+
183
190
  return (
184
191
  <View key={index} style={styles.rowCenter}>
185
192
  {token.prefix && <TextView theme={theme}>{token.prefix}</TextView>}
186
193
  {value && <TextView theme={theme}>{currency}</TextView>}
187
194
  <TextView theme={theme}>{formattedPrice ?? "-"}</TextView>
188
- {token.suffix && <SuffixTextView theme={theme}>{token.suffix}</SuffixTextView>}
195
+ {token.suffix && (
196
+ <SuffixTextView theme={theme}>{token.suffix}</SuffixTextView>
197
+ )}
189
198
  </View>
190
199
  );
191
200
  }
@@ -237,10 +246,7 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
237
246
  contentContainerStyle={styles.listContent}
238
247
  >
239
248
  {data.map((dataItem: any, index: number) => (
240
- <Pressable
241
- key={dataItem.id}
242
- onPress={() => onItemPress?.(dataItem)}
243
- >
249
+ <Pressable key={dataItem.id} onPress={() => onItemPress?.(dataItem)}>
244
250
  {(state) => (
245
251
  // @ts-ignore
246
252
  <ListItemParent theme={theme} hovered={state.hovered}>
@@ -250,7 +256,13 @@ const ProductsListViewComponent: React.FC<ProductsListViewProps> = ({
250
256
  </View>
251
257
  <View style={styles.tokens}>
252
258
  {DIAMOND_TOKENS.map((token, tokenIndex) =>
253
- renderToken(token, dataItem, userCurrency, tokenIndex, shouldRound)
259
+ renderToken(
260
+ token,
261
+ dataItem,
262
+ userCurrency,
263
+ tokenIndex,
264
+ shouldRound
265
+ )
254
266
  )}
255
267
  </View>
256
268
  </View>
@@ -331,12 +343,15 @@ const ButtonText = styled.Text<{ theme: DefaultTheme }>`
331
343
  font-weight: 600;
332
344
  `;
333
345
 
334
- const ListItemParent = styled.Pressable<{ theme: DefaultTheme, hovered?: boolean }>`
346
+ const ListItemParent = styled.View<{ theme: DefaultTheme; hovered?: boolean }>`
335
347
  padding-vertical: 2px;
336
- background-color: ${({ theme, hovered }: { theme: DefaultTheme, hovered?: boolean }) =>
337
- hovered
338
- ? theme["core-02"] || "#EDEDF2"
339
- : "transparent"};
348
+ background-color: ${({
349
+ theme,
350
+ hovered,
351
+ }: {
352
+ theme: DefaultTheme;
353
+ hovered?: boolean;
354
+ }) => (hovered ? theme["secondary-bg-hover"] || "#EDEDF2" : "transparent")};
340
355
  `;
341
356
 
342
357
  const styles = StyleSheet.create({
@@ -1,11 +1,5 @@
1
1
  import React, { memo } from "react";
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- ScrollView,
8
- } from "react-native";
2
+ import { View, StyleSheet, ScrollView } from "react-native";
9
3
  import styled from "styled-components/native";
10
4
  import { useTheme } from "styled-components/native";
11
5
  import { DefaultTheme } from "styled-components/native";
@@ -68,7 +68,6 @@ export const getUserCurrencySymbol = async (): Promise<string | null> => {
68
68
  return userData.currency_symbol || "$";
69
69
  };
70
70
 
71
-
72
71
  export const roundUpPrices = async (): Promise<boolean> => {
73
72
  const userInfo = await Storage.getJSON<UserDetails>("persist:userInfo", {});
74
73
  const userData = userInfo?.user as UserDetails;
@@ -79,21 +78,23 @@ export const roundUpPrices = async (): Promise<boolean> => {
79
78
 
80
79
  // Helper to add commas to a number
81
80
  export function formatWithCommas(value: number | string): string {
82
- const num = typeof value === 'string' ? parseFloat(value) : value;
81
+ const num = typeof value === "string" ? parseFloat(value) : value;
83
82
  if (isNaN(num)) return String(value);
84
83
  return num.toLocaleString();
85
84
  }
86
85
 
87
86
  // Format price values according to requirements
88
- export function formatPriceValue(key: string, value: any, shouldRound: boolean) {
89
- console.log("formatPriceValue", key, value);
90
-
91
- if (key === 'price_per_carat') {
87
+ export function formatPriceValue(
88
+ key: string,
89
+ value: any,
90
+ shouldRound: boolean
91
+ ) {
92
+ if (key === "price_per_carat") {
92
93
  // Remove decimals, round, add commas
93
94
  const num = Math.round(Number(value));
94
95
  return formatWithCommas(num);
95
96
  }
96
- if (key === 'total_sales_price') {
97
+ if (key === "total_sales_price") {
97
98
  let num = Number(value);
98
99
  if (shouldRound) {
99
100
  num = Math.round(num);
@@ -194,3 +195,540 @@ export const useDeviceType = () => {
194
195
  const isLargeScreen = isDesktop && !isTablet && !isMobile;
195
196
  return { isMobile, isTablet, isDesktop, isLargeScreen };
196
197
  };
198
+
199
+ export const generateSavedSearchName = (search_params: any) => {
200
+ let options: { [k: string]: any } = {};
201
+ let title_parts = [];
202
+
203
+ //is featured items
204
+ options.featured =
205
+ !!search_params?.featured && search_params?.featured === "true"
206
+ ? "true"
207
+ : "false";
208
+
209
+ //Shape
210
+ if (search_params?.shapes && search_params?.shapes?.length) {
211
+ options.shapes = search_params?.shapes || [];
212
+ title_parts.push(options.shapes.join(", "));
213
+ }
214
+
215
+ //Carat Weight
216
+ let carat_title = "";
217
+ if (search_params?.size_from || search_params?.minCarat) {
218
+ options.minCarat = search_params?.size_from ?? search_params?.minCarat;
219
+ carat_title += options.minCarat + "ct.";
220
+ }
221
+ if (search_params?.size_to || search_params?.maxCarat) {
222
+ options.maxCarat = search_params?.size_to ?? search_params?.maxCarat;
223
+ carat_title += " - " + options.maxCarat + "ct.";
224
+ }
225
+ title_parts.push(carat_title);
226
+
227
+ // Color (simple)
228
+ if (search_params?.color_from || search_params?.simpleColors?.length) {
229
+ let color_title = "";
230
+ options.simpleColors = [];
231
+ options.simpleColors.push(search_params?.color_from ?? []);
232
+ color_title += search_params?.color_from;
233
+ if (search_params?.color_to) {
234
+ if (!options.simpleColors) options.simpleColors = [];
235
+ options.simpleColors.push(search_params?.color_to ?? []);
236
+ color_title += " - " + search_params?.color_to;
237
+ }
238
+ if (search_params?.simpleColors && search_params?.simpleColors?.length) {
239
+ options.simpleColors = search_params?.simpleColors || [];
240
+ color_title = options.simpleColors.join(" - ");
241
+ }
242
+ if (color_title) title_parts.push(color_title);
243
+ }
244
+
245
+ // Fancy Color
246
+ if (
247
+ (search_params?.fancy_colors && search_params?.fancy_colors?.length) ||
248
+ (search_params?.fancyColors1 && search_params.fancyColors1?.length)
249
+ ) {
250
+ options.fancyColors1 =
251
+ search_params?.fancy_colors || search_params?.fancyColors1 || [];
252
+ let color_title = "Fancy Color" + ": " + options.fancyColors1.join(" - ");
253
+ title_parts.push(color_title);
254
+ }
255
+
256
+ //Fancy Color Overtones
257
+ if (
258
+ (search_params?.fancy_color_overtones &&
259
+ search_params?.fancy_color_overtones?.length) ||
260
+ (search_params?.fancyColorsOvertones &&
261
+ search_params.fancyColorsOvertones?.length)
262
+ ) {
263
+ options.fancyColorsOvertones =
264
+ search_params?.fancy_color_overtones ||
265
+ search_params?.fancyColorsOvertones ||
266
+ [];
267
+ let overtone_color_title =
268
+ "FC Overtone" + ": " + options?.fancyColorsOvertones?.join(", ");
269
+ title_parts.push(overtone_color_title);
270
+ }
271
+
272
+ // Clarity
273
+ options.clarities = [];
274
+ if (search_params?.clarity_from) {
275
+ options.clarities.push(search_params?.clarity_from);
276
+ }
277
+ if (search_params?.clarity_to) {
278
+ options.clarities.push(search_params?.clarity_to);
279
+ }
280
+ if (search_params?.clarities?.length)
281
+ options.clarities = search_params?.clarities ?? [];
282
+ if (options?.clarities?.length)
283
+ title_parts.push(options?.clarities.join(" - "));
284
+
285
+ // Cut
286
+ options.cutGrades = [];
287
+ if (search_params?.cut_from) {
288
+ options.cutGrades.push(search_params?.cut_from);
289
+ }
290
+ if (search_params?.cut_to) {
291
+ options.cutGrades.push(search_params?.cut_to);
292
+ }
293
+ if (search_params.cutGrades?.length)
294
+ options.cutGrades = search_params.cutGrades;
295
+ if (options.cutGrades.length) {
296
+ let cutTitle = "Cut" + ": " + options.cutGrades.join(" - ");
297
+ title_parts.push(cutTitle);
298
+ }
299
+
300
+ // Polish
301
+ options.polishes = [];
302
+ if (search_params?.polish_from) {
303
+ options.polishes.push(search_params?.polish_from);
304
+ }
305
+ if (search_params?.polish_to) {
306
+ options.polishes.push(search_params?.polish_to);
307
+ }
308
+ if (search_params?.polishes?.length)
309
+ options.polishes = search_params?.polishes;
310
+ if (options.polishes?.length) {
311
+ let polishTitle = "Pol" + ": " + options.polishes.join(" - ");
312
+ title_parts.push(polishTitle);
313
+ }
314
+
315
+ // Symmetry
316
+ options.symmetries = [];
317
+ if (search_params?.polish_from) {
318
+ options.symmetries.push(search_params?.symmetry_from);
319
+ }
320
+ if (search_params?.polish_to) {
321
+ options.symmetries.push(search_params?.symmetry_to);
322
+ }
323
+ if (search_params.symmetries?.length)
324
+ options.symmetries = search_params.symmetries;
325
+ if (options.symmetries?.length) {
326
+ let symTitle = "Sym" + ": " + options.symmetries.join(" - ");
327
+ title_parts.push(symTitle);
328
+ }
329
+
330
+ // Fluorescence
331
+ if (search_params?.fluorescence_intensities?.length) {
332
+ options.fluorescences = search_params?.fluorescence_intensities || [];
333
+ } else if (search_params?.fluorescences?.length) {
334
+ options.fluorescences = search_params?.fluorescences || [];
335
+ }
336
+ if (options?.fluorescences?.length > 0) {
337
+ let flour_values = "Flour" + ": " + options.fluorescences.join(", ");
338
+ title_parts.push(flour_values);
339
+ }
340
+
341
+ // Lab
342
+ if (search_params?.labs && search_params?.labs?.length) {
343
+ options.labs = search_params?.labs || [];
344
+ let labTitle = "Lab" + ": " + options.labs.join(", ");
345
+ title_parts.push(labTitle);
346
+ }
347
+
348
+ //Depth
349
+ let depth_title = "";
350
+ if (
351
+ (search_params?.depth_percent_from &&
352
+ search_params?.depth_percent_from >= 0) ||
353
+ (search_params?.minDepth && search_params?.minDepth >= 0)
354
+ ) {
355
+ options.minDepth =
356
+ search_params?.depth_percent_from ?? search_params.minDepth;
357
+ depth_title += "Depth" + ": " + options.minDepth;
358
+ }
359
+ if (
360
+ (search_params?.depth_percent_to && search_params?.depth_percent_to >= 0) ||
361
+ (search_params?.maxDepth && search_params?.maxDepth >= 0)
362
+ ) {
363
+ options.maxDepth =
364
+ search_params?.depth_percent_to ?? search_params?.maxDepth;
365
+ depth_title += " - " + options.maxDepth + "%";
366
+ }
367
+ if (depth_title) title_parts.push(depth_title);
368
+
369
+ //table title
370
+ let table_title = "";
371
+ if (
372
+ (search_params?.table_percent_from &&
373
+ search_params?.table_percent_from >= 0) ||
374
+ (search_params?.minTable && search_params?.minTable >= 0)
375
+ ) {
376
+ options.minTable =
377
+ search_params?.table_percent_from ?? search_params?.minTable;
378
+ table_title += "table" + ": " + options.minTable;
379
+ }
380
+ if (
381
+ (search_params?.table_percent_to && search_params?.table_percent_to >= 0) ||
382
+ (search_params?.maxTable && search_params?.maxTable >= 0)
383
+ ) {
384
+ options.maxTable =
385
+ search_params?.table_percent_to ?? search_params?.maxTable;
386
+ table_title += " - " + options.maxTable + "%";
387
+ }
388
+ if (table_title) title_parts.push(table_title);
389
+
390
+ // Meas Length
391
+ let measLengthTitle = "";
392
+ let measLengthLabel = "Meas Length";
393
+ if (search_params?.meas_length_from || search_params?.meas_length_to) {
394
+ options.meas_length_from = search_params?.meas_length_from ?? "0";
395
+ measLengthTitle = measLengthLabel + ": " + options.meas_length_from;
396
+ }
397
+ if (search_params?.meas_length_to) {
398
+ options.meas_length_to = search_params?.meas_length_to;
399
+ measLengthTitle += " - " + options.meas_length_to;
400
+ }
401
+ if (measLengthTitle) title_parts.push(measLengthTitle);
402
+
403
+ // Meas Width
404
+ let measWidthTitle = "";
405
+ let measWidthLabel = "Meas Width";
406
+ if (search_params?.meas_width_from || search_params?.meas_width_to) {
407
+ options.meas_width_from = search_params?.meas_width_from ?? "0";
408
+ measWidthTitle = measWidthLabel + ": " + options.meas_width_from;
409
+ }
410
+ if (search_params?.meas_width_to) {
411
+ options.meas_width_to = search_params?.meas_width_to;
412
+ measWidthTitle += " - " + options.meas_width_to;
413
+ }
414
+ if (measWidthTitle) title_parts.push(measWidthTitle);
415
+
416
+ // meas_depth
417
+ if (search_params?.meas_height_from || search_params?.meas_height_to) {
418
+ options.meas_height_from = search_params?.meas_height_from ?? "0";
419
+ } else if (search_params?.minDepth || search_params?.maxDepth) {
420
+ options.meas_height_from = search_params?.minDepth ?? "0";
421
+ }
422
+ if (search_params?.meas_height_to) {
423
+ options.meas_height_to = search_params?.meas_height_to;
424
+ } else if (search_params?.maxDepth) {
425
+ options.meas_height_to = search_params?.maxDepth;
426
+ }
427
+ if (options.meas_height_from && options.meas_height_to) {
428
+ let measDepthTitle =
429
+ "Meas Depth" +
430
+ ": " +
431
+ options.meas_height_from +
432
+ " - " +
433
+ options.meas_height_to;
434
+ title_parts.push(measDepthTitle);
435
+ }
436
+
437
+ // Meas Ratio
438
+ if (search_params?.meas_ratio_from || search_params?.meas_ratio_to) {
439
+ options.meas_ratio_from = search_params?.meas_ratio_from ?? "0";
440
+ }
441
+ if (search_params?.meas_ratio_to) {
442
+ options.meas_ratio_to = search_params?.meas_ratio_to;
443
+ }
444
+ if (search_params?.meas_ratio_from && search_params?.meas_ratio_to) {
445
+ let measTitle =
446
+ " Ratio" + ": " + options.meas_ratio_from + " - " + options.meas_ratio_to;
447
+ title_parts.push(measTitle);
448
+ }
449
+
450
+ //Total Price
451
+ let budget_title = "";
452
+ let totalPriceLabel = "Total";
453
+ if (
454
+ (search_params?.price_total_from && search_params?.price_total_from) ||
455
+ (search_params?.minBudget && search_params?.minBudget)
456
+ ) {
457
+ options.minBudget =
458
+ search_params?.price_total_from ?? search_params?.minBudget;
459
+ budget_title += totalPriceLabel + ": " + options.minBudget;
460
+ }
461
+ if (
462
+ (search_params?.price_total_to && search_params?.price_total_to >= 0) ||
463
+ (search_params?.maxBudget && search_params?.maxBudget >= 0)
464
+ ) {
465
+ options.maxBudget =
466
+ search_params?.price_total_to ?? search_params?.maxBudget;
467
+ budget_title += " - " + options.maxBudget;
468
+ }
469
+ if (budget_title) title_parts.push(budget_title);
470
+
471
+ // Price per Carat
472
+ let price_per_carat_title = "";
473
+ let ppcLabel = "PPC";
474
+ if (search_params?.price_per_carat_from || search_params?.minPricePerCt) {
475
+ options.minPricePerCt =
476
+ search_params?.price_per_carat_from ?? search_params?.minPricePerCt;
477
+ price_per_carat_title += ppcLabel + ": " + options.minPricePerCt;
478
+ }
479
+ if (search_params?.price_per_carat_to || search_params?.maxPricePerCt) {
480
+ options.maxPricePerCt =
481
+ search_params?.price_per_carat_to ?? search_params?.maxPricePerCt;
482
+ price_per_carat_title += " - " + options.maxPricePerCt;
483
+ }
484
+ if (price_per_carat_title) title_parts.push(price_per_carat_title);
485
+
486
+ // Location
487
+ if (search_params?.location_for) {
488
+ options.location_for = search_params?.location_for || "";
489
+ title_parts.push(options.location_for);
490
+ }
491
+
492
+ //Location
493
+ if (
494
+ search_params?.vendor_locations &&
495
+ search_params?.vendor_locations?.length
496
+ ) {
497
+ options.vendor_locations = search_params?.vendor_locations || [];
498
+ let locationTitle = "Item Loc" + ": " + options.vendor_locations.join(", ");
499
+ title_parts.push(locationTitle);
500
+ }
501
+
502
+ // Supplier
503
+ if (
504
+ (search_params?.company_names && search_params?.company_names?.length) ||
505
+ (search_params?.companyNames && search_params?.companyNames?.length)
506
+ ) {
507
+ options.companyNames =
508
+ search_params?.company_names || search_params?.companyNames || [];
509
+ let supplerTitle = "Supplier" + ": " + options.companyNames.join(",");
510
+ title_parts.push(supplerTitle);
511
+ }
512
+
513
+ //Countries
514
+ if (search_params?.countries && search_params?.countries?.length) {
515
+ options.countries = search_params?.countries || [];
516
+ title_parts.push(options.countries.join(", "));
517
+ }
518
+
519
+ //Cities
520
+ if (search_params?.cities && search_params?.citie?.length) {
521
+ options.cities = search_params?.cities || [];
522
+ title_parts.push(options.cities.join(", "));
523
+ }
524
+
525
+ // Growth
526
+ if (search_params?.growth_type && search_params?.growth_type?.length) {
527
+ options.growth_type = search_params?.growth_type || [];
528
+ let growthTitle = "Growth" + ": " + options.growth_type.join(",");
529
+ title_parts.push(growthTitle);
530
+ }
531
+
532
+ // Total or Price per carat
533
+ options.total_or_price_per_carat =
534
+ search_params?.total_or_price_per_carat || "";
535
+
536
+ //Argyle
537
+ options.argyle = search_params?.argyle || {};
538
+
539
+ //Group IDs
540
+ if (search_params?.group_ids && search_params?.group_ids?.length) {
541
+ options.group_ids = search_params?.group_ids || [];
542
+ title_parts.push(options.group_ids.join(", "));
543
+ }
544
+
545
+ //Certifications
546
+ if (search_params?.certifications && search_params?.certifications?.length) {
547
+ options.certifications = search_params?.certifications || [];
548
+ title_parts.push(options.certifications.join(", "));
549
+ }
550
+
551
+ //parcel
552
+ if (search_params?.parcel) {
553
+ options.parcel = search_params?.parcel;
554
+ title_parts.push("Parcel");
555
+ }
556
+
557
+ //3X
558
+ if (search_params?.three_x && search_params?.three_x === true) {
559
+ options.three_x = true;
560
+ title_parts.push("3X");
561
+ }
562
+
563
+ //Hearts and Arrows (H&A)
564
+ if (
565
+ search_params?.hearts_and_arrows &&
566
+ search_params?.hearts_and_arrows === "Hearts and Arrows"
567
+ ) {
568
+ options.hearts_and_arrows = search_params?.hearts_and_arrows;
569
+ title_parts.push("H&A");
570
+ }
571
+
572
+ //Enhancements
573
+ if (search_params?.enhancements && search_params?.enhancements?.length) {
574
+ options.enhancements = search_params?.enhancements || [];
575
+ if (options.enhancements.indexOf("HPHT") !== -1) {
576
+ options.enhancements[options.enhancements.indexOf("HPHT")] =
577
+ "Color Enhanced";
578
+ }
579
+ title_parts.push(options.enhancements.join(", "));
580
+ }
581
+
582
+ //Eye Clean
583
+ if (search_params?.eye_clean && Array.isArray(search_params.eye_clean)) {
584
+ options.eye_clean = search_params.eye_clean;
585
+ title_parts.push(options.eye_clean.join(", "));
586
+ }
587
+
588
+ //No BGM
589
+ if (search_params?.no_bgm) {
590
+ options.no_bgm = search_params?.no_bgm;
591
+ title_parts.push("No BGM");
592
+ }
593
+
594
+ //3VG+
595
+ if (search_params?.three_vg_plus) {
596
+ options.three_vg_plus = search_params?.three_vg_plus;
597
+ title_parts.push("3VG+");
598
+ }
599
+
600
+ //8X
601
+ if (search_params?.eight_x) {
602
+ options.eight_x = search_params?.eight_x;
603
+ title_parts.push("8X");
604
+ }
605
+
606
+ //Inclusion Pattern
607
+ if (search_params?.inclusion_pattern) {
608
+ options.inclusion_pattern = search_params?.inclusion_pattern;
609
+ }
610
+
611
+ //Intensity Black Code
612
+ if (search_params?.intensity_black_code) {
613
+ options.intensity_black_code = search_params?.intensity_black_code;
614
+ }
615
+
616
+ //Inclusion Open
617
+ if (search_params?.inclusion_open) {
618
+ options.inclusion_open = search_params?.inclusion_open;
619
+ }
620
+
621
+ //With Images
622
+ if (search_params?.with_images) {
623
+ options.with_images = search_params?.with_images;
624
+ }
625
+
626
+ //Certified Pairs
627
+ if (search_params?.certified_pairs) {
628
+ options.certified_pairs = search_params?.certified_pairs;
629
+ }
630
+
631
+ //With Available Items
632
+ if (search_params?.with_available_items) {
633
+ options.with_available_items = search_params?.with_available_items;
634
+ }
635
+
636
+ //Pair
637
+ if (search_params?.pair) {
638
+ options.pair = search_params?.pair;
639
+ }
640
+
641
+ //Discount Percent
642
+ if (search_params?.discount_percent_from) {
643
+ options.discount_percent_from = search_params?.discount_percent_from;
644
+ }
645
+ if (search_params?.discount_percent_to) {
646
+ options.discount_percent_to = search_params?.discount_percent_to;
647
+ }
648
+
649
+ let crownTitle = "";
650
+ let crownTitleLabel = "Crown";
651
+ // Crown Height
652
+ if (
653
+ search_params?.crown_percent_from &&
654
+ search_params?.crown_percent_from >= 0
655
+ ) {
656
+ options.crown_percent_from = search_params?.crown_percent_from;
657
+ crownTitle += crownTitleLabel + ": " + options.crown_percent_from + "%";
658
+ }
659
+ if (search_params?.crown_percent_to && search_params?.crown_percent_to >= 0) {
660
+ options.crown_percent_to = search_params?.crown_percent_to;
661
+ crownTitle +=
662
+ crownTitle === ""
663
+ ? crownTitleLabel + ": 0% - " + options.crown_percent_to + "%"
664
+ : " - " + options.crown_percent_to + "%";
665
+ }
666
+
667
+ // Crown Angle
668
+ if (search_params?.crown_angle_from && search_params?.crown_angle_from >= 0) {
669
+ options.crown_angle_from = search_params?.crown_angle_from;
670
+ crownTitle +=
671
+ crownTitle === ""
672
+ ? crownTitleLabel + ": " + options.crown_angle_from + "°"
673
+ : ", " + options.crown_angle_from + "°";
674
+ }
675
+ if (search_params?.crown_angle_to && search_params?.crown_angle_to >= 0) {
676
+ options.crown_angle_to = search_params?.crown_angle_to;
677
+ crownTitle +=
678
+ crownTitle === ""
679
+ ? "0° - " + options.crown_angle_to + "°"
680
+ : search_params?.crown_angle_from === undefined
681
+ ? ", 0° - " + options.crown_angle_to + "°"
682
+ : " - " + options.crown_angle_to + "°";
683
+ }
684
+ if (crownTitle) title_parts.push(crownTitle);
685
+
686
+ let pavilionTitle = "";
687
+ let pavilionTitleLabel = "Pavilion";
688
+ // Pavilion Depth
689
+ if (
690
+ search_params?.pavilion_percent_from &&
691
+ search_params?.pavilion_percent_from > 0
692
+ ) {
693
+ options.pavilion_percent_from = search_params?.pavilion_percent_from;
694
+ pavilionTitle +=
695
+ pavilionTitleLabel + ": " + options.pavilion_percent_from + "%";
696
+ }
697
+ if (
698
+ search_params?.pavilion_percent_to &&
699
+ search_params?.pavilion_percent_to > 0
700
+ ) {
701
+ options.pavilion_percent_to = search_params?.pavilion_percent_to;
702
+ pavilionTitle +=
703
+ pavilionTitle === ""
704
+ ? pavilionTitleLabel + ": 0% - " + options.pavilion_percent_to + "%"
705
+ : " - " + options.pavilion_percent_to + "%";
706
+ }
707
+
708
+ // Pavilion Angle
709
+ if (
710
+ search_params?.pavilion_angle_from &&
711
+ search_params?.pavilion_angle_from > 0
712
+ ) {
713
+ options.pavilion_angle_from = search_params?.pavilion_angle_from;
714
+ pavilionTitle +=
715
+ pavilionTitle === ""
716
+ ? pavilionTitleLabel + ": " + options.pavilion_angle_from + "°"
717
+ : ", " + options.pavilion_angle_from + "°";
718
+ }
719
+ if (
720
+ search_params?.pavilion_angle_to &&
721
+ search_params?.pavilion_angle_to > 0
722
+ ) {
723
+ options.pavilion_angle_to = search_params?.pavilion_angle_to;
724
+ pavilionTitle +=
725
+ pavilionTitle === ""
726
+ ? "0° - " + options.pavilion_angle_to + "°"
727
+ : search_params?.pavilion_angle_from === undefined
728
+ ? ", 0° - " + options.pavilion_angle_to + "°"
729
+ : " - " + options.pavilion_angle_to + "°";
730
+ }
731
+ if (pavilionTitle) title_parts.push(pavilionTitle);
732
+
733
+ return { title: title_parts.filter(Boolean).join(" | "), options: options };
734
+ };