vdb-ai-chat 1.0.51 → 1.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-widget.js +69 -69
- package/lib/commonjs/api.js +26 -3
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +13 -2
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/utils.js +42 -33
- package/lib/commonjs/components/utils.js.map +1 -1
- package/lib/module/api.js +24 -3
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/ChatWidget.js +14 -3
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/utils.js +42 -33
- package/lib/module/components/utils.js.map +1 -1
- package/lib/typescript/api.d.ts +9 -0
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
- package/lib/typescript/components/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +25 -3
- package/src/components/ChatWidget.tsx +14 -1
- package/src/components/utils.ts +42 -33
package/dist/chat-widget.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
font-weight: 500;
|
|
50
50
|
font-family: "Roboto-Medium";
|
|
51
51
|
text-align: left;
|
|
52
|
-
`,Qr=i.A.create({scroll:{maxWidth:"80%",alignSelf:"flex-start",paddingHorizontal:8},scrollInline:{maxWidth:"100%",alignSelf:"stretch",paddingHorizontal:0},container:{paddingVertical:0,flexDirection:"column",justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch"},containerInline:{gap:6},spacer:{width:4,height:4}}),Zr=(0,t.memo)(Gr),ei=a(3384).A.get("window");function ti(e,t){const n=new Date(e);let r=n.getHours();const i=n.getMinutes(),o=r>=12?t("time.pm.text","pm"):t("time.am.text","am");return r%=12,r=r||12,`${r}:${i<10?`0${i}`:i} ${o}`}let ni=function(e){return e.LIKE="1",e.DISLIKE="2",e.UNSET="0",e}({});const ri=async()=>{const e=await Nr("persist:userInfo",{}),t=e?.user;return t.currency_symbol||"$"},ii=async()=>(await Nr("persist:userInfo",{}),!0);function oi(e){const t="string"==typeof e?parseFloat(e):e;return isNaN(t)?String(e):t.toLocaleString()}function ai(e,t,n){if("price_per_carat"===e)return oi(Math.round(Number(t)));if("total_sales_price"===e){let e=Number(t);return n&&(e=Math.round(e)),oi(e)}return oi(t)}const si=async()=>{try{const e=await Nr("persist:userInfo",{});if(!e?.user)return null;if("string"==typeof e.user)try{return JSON.parse(e.user)}catch{return null}return e.user}catch{return null}};let li=function(e){return e.WEB="web",e.IOS="ios",e.ANDROID="android",e}({}),ui=function(e){return e.WIDGET_OPENED="ai_chat_widget_opened",e.WIDGET_CLOSED="ai_chat_widget_closed",e.CHAT_CLEARED="ai_chat_cleared",e}({}),ci=function(e){return e.AI_CHAT_WIDGET="ai_chat_widget",e}({}),di=function(e){return e.WIDGET_OPENED="widget_opened",e.WIDGET_CLOSED="widget_closed",e.CHAT_CLEARED="chat_cleared",e.PRODUCT_PREVIEW_CLICKED="product_preview_clicked",e.SHOW_ALL_RESULTS_CLICKED="show_all_results_clicked",e.SEARCH_INITIATED="search_initiated",e.NO_RESULTS_FOUND="no_results_found",e.RECOMMENDATION_REQUESTED="recommendation_requested",e.RECOMMENDATION_RECEIVED="recommendation_received",e}({});const hi=()=>{const e=navigator.userAgent||navigator.vendor||window.opera;return/iPad/.test(e)||/\bMac/.test(e)&&navigator.maxTouchPoints>0&&!/iPhone/.test(e)},fi=e=>{let{searchPayload:t,priceMode:n,vdbSetting:r,searchResultViewType:i}=e;return(t?.cut_from||t?.cut_to||t?.polish_from||t?.polish_to||t?.symmetry_from||t?.symmetry_to)&&(t.cutGrades=[],t.polishes=[],t.symmetries=[],t?.shapes||(t.shapes=[])),t?.cut_from&&t.cutGrades.push(t?.cut_from),t?.cut_to&&t.cutGrades.push(t?.cut_to),t?.polish_from&&t.polishes.push(t?.polish_from),t?.polish_to&&t.polishes.push(t?.polish_to),t?.symmetry_from&&t.symmetries.push(t?.symmetry_from),t?.symmetry_to&&t.symmetries.push(t?.symmetry_to),t?.three_x&&(t.cut_from="Excellent",t.cut_to="Ideal",t.polish_from="Excellent",t.polish_to="Ideal",t.symmetry_from="Excellent",t.symmetry_to="Ideal",t.cps_three_x_options=["Ideal","Excellent"],delete t.cutGrades,delete t.polishes,delete t.symmetries),t?.three_vg_plus&&(t.cut_from="Very Good",t.cut_to="Ideal",t.polish_from="Very Good",t.polish_to="Ideal",t.symmetry_from="Very Good",t.symmetry_to="Ideal",t.cps_three_vg_plus_options=["Ideal","Very Good"],delete t.cutGrades,delete t.polishes,delete t.symmetries),t?.eight_x&&(t.cut_from="8X",t.cut_to="Ideal",t.polish_from="8X",t.polish_to="Ideal",t.symmetry_from="8X",t.symmetry_to="Ideal",t.cps_eight_x_options=["Ideal","8X"],delete t.cutGrades,delete t.polishes,delete t.symmetries),t?.page_size&&delete t.page_size,t.price_mode=n,t.vdb_setting=r?"true":"false",t.results_view_type=i||"grid",t.featured=t.featured||"false",t.pair="pair"===t.pair?"pair":"other",t.with_available_items=!!t.with_available_items,t.page_number&&delete t.page_number,t.preference=t.preference||[],t.depth_percent_from=t.depth_percent_from??"0",t.depth_percent_to=t.depth_percent_to??"100",t.table_percent_from=t.table_percent_from??"0",t.table_percent_to=t.table_percent_to??"100",(t.price_total_from||t.price_total_to)&&(t.total_or_price_per_carat="total_sales_price"),(t.price_per_carat_from||t.price_per_carat_to)&&(t.total_or_price_per_carat="price_per_carat"),t.cert_num&&(t.cert_num=(e=>{const t=e.trim(),n=t.toLowerCase(),r=n.split(",");return r.length>1?r.map(e=>e.trim().replace(/^vdb-?/i,"")).join(","):n.startsWith("vdb-")?t.replace(/^VDB-/i,""):n.startsWith("vdb")?t.replace(/^VDB/i,""):t})(t.cert_num),delete t.pair),t},pi=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r={},i=[];const o=(e,t)=>n?n(e):t,a=o("search.carat.text","ct.");if(r.featured=e?.featured&&"true"===e?.featured?"true":"false",e?.shapes&&e?.shapes?.length)if(r.shapes=e?.shapes||[],t&&r.shapes.length>3){const e=r.shapes.slice(0,3),t=r.shapes.length-3,o=n?n("search.more.text","+ {{count}} more",{count:t}):`+ ${t} more`,a=`${e.join(", ")} ${o}`;i.push(a)}else i.push(r.shapes.join(", "));let s="";if((e?.size_from||e?.minCarat)&&(r.minCarat=e?.size_from??e?.minCarat,s+=r.minCarat+a),(e?.size_to||e?.maxCarat)&&(r.maxCarat=e?.size_to??e?.maxCarat,s+=" - "+r.maxCarat+a),i.push(s),e?.color_from||e?.simpleColors?.length){let t="";r.simpleColors=[],r.simpleColors.push(e?.color_from??[]),t+=e?.color_from,e?.color_to&&(r.simpleColors||(r.simpleColors=[]),r.simpleColors.push(e?.color_to??[]),t+=" - "+e?.color_to),e?.simpleColors&&e?.simpleColors?.length&&(r.simpleColors=e?.simpleColors||[],t=r.simpleColors.join(" - ")),t&&i.push(t)}if(e?.fancy_colors&&e?.fancy_colors?.length||e?.fancyColors1&&e.fancyColors1?.length){r.fancyColors1=e?.fancy_colors||e?.fancyColors1||[];let t=o("search.fancyColor.text","Fancy Color")+": "+r.fancyColors1.join(" - ");i.push(t)}if(e?.fancy_color_overtones&&e?.fancy_color_overtones?.length||e?.fancyColorsOvertones&&e.fancyColorsOvertones?.length){r.fancyColorsOvertones=e?.fancy_color_overtones||e?.fancyColorsOvertones||[];let t=o("search.fcOvertone.text","FC Overtone")+": "+r?.fancyColorsOvertones?.join(", ");i.push(t)}if(r.clarities=[],e?.clarity_from&&r.clarities.push(e?.clarity_from),e?.clarity_to&&r.clarities.push(e?.clarity_to),e?.clarities?.length&&(r.clarities=e?.clarities??[]),r?.clarities?.length&&i.push(r?.clarities.join(" - ")),r.cutGrades=[],e?.cut_from&&r.cutGrades.push(e?.cut_from),e?.cut_to&&r.cutGrades.push(e?.cut_to),e.cutGrades?.length&&(r.cutGrades=e.cutGrades),r.cutGrades.length){let e=o("search.cut.text","Cut")+": "+r.cutGrades.join(" - ");i.push(e)}if(r.polishes=[],e?.polish_from&&r.polishes.push(e?.polish_from),e?.polish_to&&r.polishes.push(e?.polish_to),e?.polishes?.length&&(r.polishes=e?.polishes),r.polishes?.length){let e=o("search.polish.text","Pol")+": "+r.polishes.join(" - ");i.push(e)}if(r.symmetries=[],e?.symmetry_from&&r.symmetries.push(e?.symmetry_from),e?.symmetry_to&&r.symmetries.push(e?.symmetry_to),e.symmetries?.length&&(r.symmetries=e.symmetries),r.symmetries?.length){let e=o("search.symmetry.text","Sym")+": "+r.symmetries.join(" - ");i.push(e)}if(e?.fluorescence_intensities?.length?r.fluorescences=e?.fluorescence_intensities||[]:e?.fluorescences?.length&&(r.fluorescences=e?.fluorescences||[]),r?.fluorescences?.length>0){let e=o("search.fluorescence.text","Flour")+": "+r.fluorescences.join(", ");i.push(e)}if(e?.labs&&e?.labs?.length){r.labs=e?.labs||[];let t=o("search.lab.text","Lab")+": "+r.labs.join(", ");i.push(t)}let l="";(e?.depth_percent_from&&e?.depth_percent_from>=0||e?.minDepth&&e?.minDepth>=0)&&(r.minDepth=e?.depth_percent_from??e.minDepth,l+=o("search.depth.text","Depth")+": "+r.minDepth),(e?.depth_percent_to&&e?.depth_percent_to>=0||e?.maxDepth&&e?.maxDepth>=0)&&(r.maxDepth=e?.depth_percent_to??e?.maxDepth,l+=" - "+r.maxDepth+"%"),l&&i.push(l);let u="";(e?.table_percent_from&&e?.table_percent_from>=0||e?.minTable&&e?.minTable>=0)&&(r.minTable=e?.table_percent_from??e?.minTable,u+=o("search.tableLabel.text","table")+": "+r.minTable),(e?.table_percent_to&&e?.table_percent_to>=0||e?.maxTable&&e?.maxTable>=0)&&(r.maxTable=e?.table_percent_to??e?.maxTable,u+=" - "+r.maxTable+"%"),u&&i.push(u);let c="",d=o("search.measLength.text","Meas Length");(e?.meas_length_from||e?.meas_length_to)&&(r.meas_length_from=e?.meas_length_from??"0",c=d+": "+r.meas_length_from),e?.meas_length_to&&(r.meas_length_to=e?.meas_length_to,c+=" - "+r.meas_length_to),c&&i.push(c);let h="",f=o("search.measWidth.text","Meas Width");if((e?.meas_width_from||e?.meas_width_to)&&(r.meas_width_from=e?.meas_width_from??"0",h=f+": "+r.meas_width_from),e?.meas_width_to&&(r.meas_width_to=e?.meas_width_to,h+=" - "+r.meas_width_to),h&&i.push(h),e?.meas_height_from||e?.meas_height_to?r.meas_height_from=e?.meas_height_from??"0":(e?.minDepth||e?.maxDepth)&&(r.meas_height_from=e?.minDepth??"0"),e?.meas_height_to?r.meas_height_to=e?.meas_height_to:e?.maxDepth&&(r.meas_height_to=e?.maxDepth),r.meas_height_from&&r.meas_height_to){let e=o("search.measDepth.text","Meas Depth")+": "+r.meas_height_from+" - "+r.meas_height_to;i.push(e)}if((e?.meas_ratio_from||e?.meas_ratio_to)&&(r.meas_ratio_from=e?.meas_ratio_from??"0"),e?.meas_ratio_to&&(r.meas_ratio_to=e?.meas_ratio_to),e?.meas_ratio_from&&e?.meas_ratio_to){let e=o("search.ratio.text","Ratio")+": "+r.meas_ratio_from+" - "+r.meas_ratio_to;i.push(e)}let p="",m=o("search.totalPrice.text","Total");(e?.price_total_from&&e?.price_total_from||e?.minBudget&&e?.minBudget)&&(r.minBudget=e?.price_total_from??e?.minBudget,p+=m+": "+r.minBudget),(e?.price_total_to&&e?.price_total_to>=0||e?.maxBudget&&e?.maxBudget>=0)&&(r.maxBudget=e?.price_total_to??e?.maxBudget,p+=" - "+r.maxBudget),p&&i.push(p);let g="",v=o("search.pricePerCarat.text","PPC");if((e?.price_per_carat_from||e?.minPricePerCt)&&(r.minPricePerCt=e?.price_per_carat_from??e?.minPricePerCt,g+=v+": "+r.minPricePerCt),(e?.price_per_carat_to||e?.maxPricePerCt)&&(r.maxPricePerCt=e?.price_per_carat_to??e?.maxPricePerCt,g+=" - "+r.maxPricePerCt),g&&i.push(g),e?.location_for&&(r.location_for=e?.location_for||"",i.push(r.location_for)),e?.vendor_locations&&e?.vendor_locations?.length){r.vendor_locations=e?.vendor_locations||[];let t=o("search.itemLocation.text","Item Loc")+(!0===e?.exclude_locations?" "+o("search.diamond.excluded.text","(Excluded)"):"")+": "+r.vendor_locations.join(", ");i.push(t)}if(e?.company_names&&e?.company_names?.length||e?.companyNames&&e?.companyNames?.length){r.companyNames=e?.company_names||e?.companyNames||[];let t=o("search.supplier.text","Supplier")+(!0===e?.exclude_suppliers?" "+o("search.diamond.excluded.text","(Excluded)"):"")+": "+r.companyNames.join(",");i.push(t)}if(e?.countries&&e?.countries?.length&&(r.countries=e?.countries||[],i.push(r.countries.join(", "))),e?.cities&&e?.citie?.length&&(r.cities=e?.cities||[],i.push(r.cities.join(", "))),e?.growth_type&&e?.growth_type?.length){r.growth_type=e?.growth_type||[];let t="Growth: "+r.growth_type.join(",");i.push(t)}r.total_or_price_per_carat=e?.total_or_price_per_carat||"",r.argyle=e?.argyle||{},e?.group_ids&&e?.group_ids?.length&&(r.group_ids=e?.group_ids||[],i.push(r.group_ids.join(", "))),e?.certifications&&e?.certifications?.length&&(r.certifications=e?.certifications||[],i.push(r.certifications.join(", "))),e?.parcel&&(r.parcel=e?.parcel,i.push(o("search.parcel.text","Parcel"))),e?.three_x&&!0===e?.three_x&&(r.three_x=!0,i.push(o("search.threeX.text","3X"))),e?.hearts_and_arrows&&"Hearts and Arrows"===e?.hearts_and_arrows&&(r.hearts_and_arrows=e?.hearts_and_arrows,i.push(o("search.heartsAndArrows.text","H&A"))),e?.enhancements&&e?.enhancements?.length&&(r.enhancements=e?.enhancements||[],-1!==r.enhancements.indexOf("HPHT")&&(r.enhancements[r.enhancements.indexOf("HPHT")]=o("search.colorEnhanced.text","Color Enhanced")),i.push(r.enhancements.join(", "))),e?.eye_clean&&Array.isArray(e.eye_clean)&&(r.eye_clean=e.eye_clean,i.push(r.eye_clean.join(", "))),e?.no_bgm&&(r.no_bgm=e?.no_bgm,i.push(o("search.noBgm.text","No BGM"))),e?.three_vg_plus&&(r.three_vg_plus=e?.three_vg_plus,i.push(o("search.threeVgPlus.text","3VG+"))),e?.eight_x&&(r.eight_x=e?.eight_x,i.push(o("search.eightX.text","8X"))),e?.inclusion_pattern&&(r.inclusion_pattern=e?.inclusion_pattern),e?.intensity_black_code&&(r.intensity_black_code=e?.intensity_black_code),e?.inclusion_open&&(r.inclusion_open=e?.inclusion_open),e?.with_images&&(r.with_images=e?.with_images),e?.certified_pairs&&(r.certified_pairs=e?.certified_pairs),e?.with_available_items&&(r.with_available_items=e?.with_available_items),e?.pair&&(r.pair=e?.pair),e?.discount_percent_from&&(r.discount_percent_from=e?.discount_percent_from),e?.discount_percent_to&&(r.discount_percent_to=e?.discount_percent_to);let y="",b=o("search.crown.text","Crown");e?.crown_percent_from&&e?.crown_percent_from>=0&&(r.crown_percent_from=e?.crown_percent_from,y+=b+": "+r.crown_percent_from+"%"),e?.crown_percent_to&&e?.crown_percent_to>=0&&(r.crown_percent_to=e?.crown_percent_to,y+=""===y?b+": 0% - "+r.crown_percent_to+"%":" - "+r.crown_percent_to+"%"),e?.crown_angle_from&&e?.crown_angle_from>=0&&(r.crown_angle_from=e?.crown_angle_from,y+=""===y?b+": "+r.crown_angle_from+"°":", "+r.crown_angle_from+"°"),e?.crown_angle_to&&e?.crown_angle_to>=0&&(r.crown_angle_to=e?.crown_angle_to,y+=""===y?"0° - "+r.crown_angle_to+"°":void 0===e?.crown_angle_from?", 0° - "+r.crown_angle_to+"°":" - "+r.crown_angle_to+"°"),y&&i.push(y);let _="",w=o("search.pavilion.text","Pavilion");return e?.pavilion_percent_from&&e?.pavilion_percent_from>0&&(r.pavilion_percent_from=e?.pavilion_percent_from,_+=w+": "+r.pavilion_percent_from+"%"),e?.pavilion_percent_to&&e?.pavilion_percent_to>0&&(r.pavilion_percent_to=e?.pavilion_percent_to,_+=""===_?w+": 0% - "+r.pavilion_percent_to+"%":" - "+r.pavilion_percent_to+"%"),e?.pavilion_angle_from&&e?.pavilion_angle_from>0&&(r.pavilion_angle_from=e?.pavilion_angle_from,_+=""===_?w+": "+r.pavilion_angle_from+"°":", "+r.pavilion_angle_from+"°"),e?.pavilion_angle_to&&e?.pavilion_angle_to>0&&(r.pavilion_angle_to=e?.pavilion_angle_to,_+=""===_?"0° - "+r.pavilion_angle_to+"°":void 0===e?.pavilion_angle_from?", 0° - "+r.pavilion_angle_to+"°":" - "+r.pavilion_angle_to+"°"),_&&i.push(_),{title:i.filter(Boolean).join(" | "),options:r}};let mi=function(e){return e.diam="diam",e.gem="gem",e.jewelry="jewelry",e.lab="lab",e.default="default",e}({}),gi=function(e){return e[e.primary=0]="primary",e[e.secondary=1]="secondary",e[e.tertiary=2]="tertiary",e}({}),vi=function(e){return e.DIAMOND="diamond",e.LAB_GROWN_DIAMOND="lab_grown_diamond",e.GEMSTONE="gemstone",e.JEWELRY="jewelry",e.LABGROWN_JEWELRY="lab_grown_jewelry",e}({});const yi=e=>{switch(e){case vi.DIAMOND:case"Natural":return"diam-06";case vi.GEMSTONE:return"gem-06";case vi.JEWELRY:return"jewelry-06";case vi.LAB_GROWN_DIAMOND:case"Lab-Grown":case vi.LABGROWN_JEWELRY:return"lab-06";default:return"diam-06"}},bi=e=>{switch(e){case vi.DIAMOND:return"diam-03";case vi.GEMSTONE:return"gem-03";case vi.JEWELRY:return"jewelry-03";case vi.LAB_GROWN_DIAMOND:case vi.LABGROWN_JEWELRY:return"lab-03";default:return"diam-03"}},_i=e=>{if(e)return["Champagne","Cognac","Chameleon"].includes(e)},wi=(e,t)=>{let n=null;return n=e?_i(t?.fancy_color_overtone_long)?t?.is_fancy?`${t?.fancy_color_intensity_short||t?.color||""} ${t?.fancy_color_short||""}(${t?.fancy_color_overtone_long||""})`:`${t?.fancy_color_long||t?.color||""}`:t?.is_fancy?`${t?.fancy_color_intensity_short||t?.fancy_color_intensity||""} ${t?.fancy_color_overtone_short||""}${t?.fancy_color_short||""}`:`${t?.fancy_color_long||t?.color||""}`:_i(t?.fancy_color_overtone_long)?t?.is_fancy?[t?.fancy_color_intensity_long||t?.fancy_color_intensity,t?.fancy_color_long,t?.fancy_color_overtone_long?`(${t.fancy_color_overtone_long})`:null].filter(Boolean).join(" "):t?.fancy_color_long||t?.color||"":t?.is_fancy?[t?.fancy_color_intensity_long||t?.fancy_color_intensity,t?.fancy_color_overtone_long,t?.fancy_color_long].filter(Boolean).join(" "):t?.fancy_color_long||t?.color||"",""===n?"-":n},Si=vn.View`
|
|
52
|
+
`,Qr=i.A.create({scroll:{maxWidth:"80%",alignSelf:"flex-start",paddingHorizontal:8},scrollInline:{maxWidth:"100%",alignSelf:"stretch",paddingHorizontal:0},container:{paddingVertical:0,flexDirection:"column",justifyContent:"center",alignItems:"center",gap:4,alignSelf:"stretch"},containerInline:{gap:6},spacer:{width:4,height:4}}),Zr=(0,t.memo)(Gr),ei=a(3384).A.get("window");function ti(e,t){const n=new Date(e);let r=n.getHours();const i=n.getMinutes(),o=r>=12?t("time.pm.text","pm"):t("time.am.text","am");return r%=12,r=r||12,`${r}:${i<10?`0${i}`:i} ${o}`}let ni=function(e){return e.LIKE="1",e.DISLIKE="2",e.UNSET="0",e}({});const ri=async()=>{const e=await Nr("persist:userInfo",{}),t=e?.user;return t.currency_symbol||"$"},ii=async()=>(await Nr("persist:userInfo",{}),!0);function oi(e){const t="string"==typeof e?parseFloat(e):e;return isNaN(t)?String(e):t.toLocaleString()}function ai(e,t,n){if("price_per_carat"===e)return oi(Math.round(Number(t)));if("total_sales_price"===e){let e=Number(t);return n&&(e=Math.round(e)),oi(e)}return oi(t)}const si=async()=>{try{const e=await Nr("persist:userInfo",{});if(!e?.user)return null;if("string"==typeof e.user)try{return JSON.parse(e.user)}catch{return null}return e.user}catch{return null}};let li=function(e){return e.WEB="web",e.IOS="ios",e.ANDROID="android",e}({}),ui=function(e){return e.WIDGET_OPENED="ai_chat_widget_opened",e.WIDGET_CLOSED="ai_chat_widget_closed",e.CHAT_CLEARED="ai_chat_cleared",e}({}),ci=function(e){return e.AI_CHAT_WIDGET="ai_chat_widget",e}({}),di=function(e){return e.WIDGET_OPENED="widget_opened",e.WIDGET_CLOSED="widget_closed",e.CHAT_CLEARED="chat_cleared",e.PRODUCT_PREVIEW_CLICKED="product_preview_clicked",e.SHOW_ALL_RESULTS_CLICKED="show_all_results_clicked",e.SEARCH_INITIATED="search_initiated",e.NO_RESULTS_FOUND="no_results_found",e.RECOMMENDATION_REQUESTED="recommendation_requested",e.RECOMMENDATION_RECEIVED="recommendation_received",e}({});const hi=()=>{const e=navigator.userAgent||navigator.vendor||window.opera;return/iPad/.test(e)||/\bMac/.test(e)&&navigator.maxTouchPoints>0&&!/iPhone/.test(e)},fi=e=>{let{searchPayload:t,priceMode:n,vdbSetting:r,searchResultViewType:i}=e;return(t?.cut_from||t?.cut_to||t?.polish_from||t?.polish_to||t?.symmetry_from||t?.symmetry_to)&&(t.cutGrades=[],t.polishes=[],t.symmetries=[],t?.shapes||(t.shapes=[])),t?.cut_from&&t.cutGrades.push(t?.cut_from),t?.cut_to&&t.cutGrades.push(t?.cut_to),t?.polish_from&&t.polishes.push(t?.polish_from),t?.polish_to&&t.polishes.push(t?.polish_to),t?.symmetry_from&&t.symmetries.push(t?.symmetry_from),t?.symmetry_to&&t.symmetries.push(t?.symmetry_to),t?.three_x&&(t.lab_grown?(t.cutGrades=["Excellent","8X"],t.polishes=["Excellent","8X"],t.symmetries=["Excellent","8X"],t.cps_three_x_options=["8X","Excellent"],t.cut_from="Excellent",t.cut_to="8X",t.polish_from="Excellent",t.polish_to="8X",t.symmetry_from="Excellent",t.symmetry_to="8X"):(t.cutGrades=["Excellent","Excellent"],t.polishes=["Excellent","Excellent"],t.symmetries=["Excellent","Excellent"],t.cut_from="Excellent",t.cut_to="Excellent",t.polish_from="Excellent",t.polish_to="Excellent",t.symmetry_from="Excellent",t.symmetry_to="Excellent"),delete t.three_x),t?.three_vg_plus&&t.lab_grown&&(t.cutGrades=["Very Good","8X"],t.polishes=["Very Good","8X"],t.symmetries=["Very Good","8X"],t.cut_from="Very Good",t.cut_to="8X",t.polish_from="Very Good",t.polish_to="8X",t.symmetry_from="Very Good",t.symmetry_to="8X",t.cps_three_vg_plus_options=["8X","Very Good"]),t?.eight_x&&t.lab_grown&&(t.cutGrades=["8X","8X"],t.polishes=["8X","8X"],t.symmetries=["8X","8X"],t.cut_from="8X",t.cut_to="8X",t.polish_from="8X",t.polish_to="8X",t.symmetry_from="8X",t.symmetry_to="8X"),t?.page_size&&delete t.page_size,t.price_mode=n,t.vdb_setting=r?"true":"false",t.results_view_type=i||"grid",t.featured=t.featured||"false",t.pair="pair"===t.pair?"pair":"other",t.with_available_items=!!t.with_available_items,t.page_number&&delete t.page_number,t.preference=t.preference||[],t.depth_percent_from=t.depth_percent_from??"0",t.depth_percent_to=t.depth_percent_to??"100",t.table_percent_from=t.table_percent_from??"0",t.table_percent_to=t.table_percent_to??"100",(t.price_total_from||t.price_total_to)&&(t.total_or_price_per_carat="total_sales_price"),(t.price_per_carat_from||t.price_per_carat_to)&&(t.total_or_price_per_carat="price_per_carat"),t.cert_num&&(t.cert_num=(e=>{const t=e.trim(),n=t.toLowerCase(),r=n.split(",");return r.length>1?r.map(e=>e.trim().replace(/^vdb-?/i,"")).join(","):n.startsWith("vdb-")?t.replace(/^VDB-/i,""):n.startsWith("vdb")?t.replace(/^VDB/i,""):t})(t.cert_num),delete t.pair),t},pi=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r={},i=[];const o=(e,t)=>n?n(e):t,a=o("search.carat.text","ct.");if(r.featured=e?.featured&&"true"===e?.featured?"true":"false",e?.shapes&&e?.shapes?.length)if(r.shapes=e?.shapes||[],t&&r.shapes.length>3){const e=r.shapes.slice(0,3),t=r.shapes.length-3,o=n?n("search.more.text","+ {{count}} more",{count:t}):`+ ${t} more`,a=`${e.join(", ")} ${o}`;i.push(a)}else i.push(r.shapes.join(", "));let s="";if((e?.size_from||e?.minCarat)&&(r.minCarat=e?.size_from??e?.minCarat,s+=r.minCarat+a),(e?.size_to||e?.maxCarat)&&(r.maxCarat=e?.size_to??e?.maxCarat,s+=" - "+r.maxCarat+a),i.push(s),e?.color_from||e?.simpleColors?.length){let t="";r.simpleColors=[],r.simpleColors.push(e?.color_from??[]),t+=e?.color_from,e?.color_to&&(r.simpleColors||(r.simpleColors=[]),r.simpleColors.push(e?.color_to??[]),t+=" - "+e?.color_to),e?.simpleColors&&e?.simpleColors?.length&&(r.simpleColors=e?.simpleColors||[],t=r.simpleColors.join(" - ")),t&&i.push(t)}if(e?.fancy_colors&&e?.fancy_colors?.length||e?.fancyColors1&&e.fancyColors1?.length){r.fancyColors1=e?.fancy_colors||e?.fancyColors1||[];let t=o("search.fancyColor.text","Fancy Color")+": "+r.fancyColors1.join(" - ");i.push(t)}if(e?.fancy_color_overtones&&e?.fancy_color_overtones?.length||e?.fancyColorsOvertones&&e.fancyColorsOvertones?.length){r.fancyColorsOvertones=e?.fancy_color_overtones||e?.fancyColorsOvertones||[];let t=o("search.fcOvertone.text","FC Overtone")+": "+r?.fancyColorsOvertones?.join(", ");i.push(t)}if(r.clarities=[],e?.clarity_from&&r.clarities.push(e?.clarity_from),e?.clarity_to&&r.clarities.push(e?.clarity_to),e?.clarities?.length&&(r.clarities=e?.clarities??[]),r?.clarities?.length&&i.push(r?.clarities.join(" - ")),r.cutGrades=[],e?.cut_from&&r.cutGrades.push(e?.cut_from),e?.cut_to&&r.cutGrades.push(e?.cut_to),e.cutGrades?.length&&(r.cutGrades=e.cutGrades),r.cutGrades.length){let e=o("search.cut.text","Cut")+": "+r.cutGrades.join(" - ");i.push(e)}if(r.polishes=[],e?.polish_from&&r.polishes.push(e?.polish_from),e?.polish_to&&r.polishes.push(e?.polish_to),e?.polishes?.length&&(r.polishes=e?.polishes),r.polishes?.length){let e=o("search.polish.text","Pol")+": "+r.polishes.join(" - ");i.push(e)}if(r.symmetries=[],e?.polish_from&&r.symmetries.push(e?.symmetry_from),e?.polish_to&&r.symmetries.push(e?.symmetry_to),e.symmetries?.length&&(r.symmetries=e.symmetries),r.symmetries?.length){let e=o("search.symmetry.text","Sym")+": "+r.symmetries.join(" - ");i.push(e)}if(e?.fluorescence_intensities?.length?r.fluorescences=e?.fluorescence_intensities||[]:e?.fluorescences?.length&&(r.fluorescences=e?.fluorescences||[]),r?.fluorescences?.length>0){let e=o("search.fluorescence.text","Flour")+": "+r.fluorescences.join(", ");i.push(e)}if(e?.labs&&e?.labs?.length){r.labs=e?.labs||[];let t=o("search.lab.text","Lab")+": "+r.labs.join(", ");i.push(t)}let l="";(e?.depth_percent_from&&e?.depth_percent_from>=0||e?.minDepth&&e?.minDepth>=0)&&(r.minDepth=e?.depth_percent_from??e.minDepth,l+=o("search.depth.text","Depth")+": "+r.minDepth),(e?.depth_percent_to&&e?.depth_percent_to>=0||e?.maxDepth&&e?.maxDepth>=0)&&(r.maxDepth=e?.depth_percent_to??e?.maxDepth,l+=" - "+r.maxDepth+"%"),l&&i.push(l);let u="";(e?.table_percent_from&&e?.table_percent_from>=0||e?.minTable&&e?.minTable>=0)&&(r.minTable=e?.table_percent_from??e?.minTable,u+=o("search.tableLabel.text","table")+": "+r.minTable),(e?.table_percent_to&&e?.table_percent_to>=0||e?.maxTable&&e?.maxTable>=0)&&(r.maxTable=e?.table_percent_to??e?.maxTable,u+=" - "+r.maxTable+"%"),u&&i.push(u);let c="",d=o("search.measLength.text","Meas Length");(e?.meas_length_from||e?.meas_length_to)&&(r.meas_length_from=e?.meas_length_from??"0",c=d+": "+r.meas_length_from),e?.meas_length_to&&(r.meas_length_to=e?.meas_length_to,c+=" - "+r.meas_length_to),c&&i.push(c);let h="",f=o("search.measWidth.text","Meas Width");if((e?.meas_width_from||e?.meas_width_to)&&(r.meas_width_from=e?.meas_width_from??"0",h=f+": "+r.meas_width_from),e?.meas_width_to&&(r.meas_width_to=e?.meas_width_to,h+=" - "+r.meas_width_to),h&&i.push(h),e?.meas_height_from||e?.meas_height_to?r.meas_height_from=e?.meas_height_from??"0":(e?.minDepth||e?.maxDepth)&&(r.meas_height_from=e?.minDepth??"0"),e?.meas_height_to?r.meas_height_to=e?.meas_height_to:e?.maxDepth&&(r.meas_height_to=e?.maxDepth),r.meas_height_from&&r.meas_height_to){let e=o("search.measDepth.text","Meas Depth")+": "+r.meas_height_from+" - "+r.meas_height_to;i.push(e)}if((e?.meas_ratio_from||e?.meas_ratio_to)&&(r.meas_ratio_from=e?.meas_ratio_from??"0"),e?.meas_ratio_to&&(r.meas_ratio_to=e?.meas_ratio_to),e?.meas_ratio_from&&e?.meas_ratio_to){let e=o("search.ratio.text","Ratio")+": "+r.meas_ratio_from+" - "+r.meas_ratio_to;i.push(e)}let p="",m=o("search.totalPrice.text","Total");(e?.price_total_from&&e?.price_total_from||e?.minBudget&&e?.minBudget)&&(r.minBudget=e?.price_total_from??e?.minBudget,p+=m+": "+r.minBudget),(e?.price_total_to&&e?.price_total_to>=0||e?.maxBudget&&e?.maxBudget>=0)&&(r.maxBudget=e?.price_total_to??e?.maxBudget,p+=" - "+r.maxBudget),p&&i.push(p);let g="",v=o("search.pricePerCarat.text","PPC");if((e?.price_per_carat_from||e?.minPricePerCt)&&(r.minPricePerCt=e?.price_per_carat_from??e?.minPricePerCt,g+=v+": "+r.minPricePerCt),(e?.price_per_carat_to||e?.maxPricePerCt)&&(r.maxPricePerCt=e?.price_per_carat_to??e?.maxPricePerCt,g+=" - "+r.maxPricePerCt),g&&i.push(g),e?.location_for&&(r.location_for=e?.location_for||"",i.push(r.location_for)),e?.vendor_locations&&e?.vendor_locations?.length){r.vendor_locations=e?.vendor_locations||[];let t=o("search.itemLocation.text","Item Loc")+(!0===e?.exclude_locations?" "+o("search.diamond.excluded.text","(Excluded)"):"")+": "+r.vendor_locations.join(", ");i.push(t)}if(e?.company_names&&e?.company_names?.length||e?.companyNames&&e?.companyNames?.length){r.companyNames=e?.company_names||e?.companyNames||[];let t=o("search.supplier.text","Supplier")+(!0===e?.exclude_suppliers?" "+o("search.diamond.excluded.text","(Excluded)"):"")+": "+r.companyNames.join(",");i.push(t)}if(e?.countries&&e?.countries?.length&&(r.countries=e?.countries||[],i.push(r.countries.join(", "))),e?.cities&&e?.citie?.length&&(r.cities=e?.cities||[],i.push(r.cities.join(", "))),e?.growth_type&&e?.growth_type?.length){r.growth_type=e?.growth_type||[];let t="Growth: "+r.growth_type.join(",");i.push(t)}r.total_or_price_per_carat=e?.total_or_price_per_carat||"",r.argyle=e?.argyle||{},e?.group_ids&&e?.group_ids?.length&&(r.group_ids=e?.group_ids||[],i.push(r.group_ids.join(", "))),e?.certifications&&e?.certifications?.length&&(r.certifications=e?.certifications||[],i.push(r.certifications.join(", "))),e?.parcel&&(r.parcel=e?.parcel,i.push(o("search.parcel.text","Parcel"))),e?.three_x&&!0===e?.three_x&&(r.three_x=!0,i.push(o("search.threeX.text","3X"))),e?.hearts_and_arrows&&"Hearts and Arrows"===e?.hearts_and_arrows&&(r.hearts_and_arrows=e?.hearts_and_arrows,i.push(o("search.heartsAndArrows.text","H&A"))),e?.enhancements&&e?.enhancements?.length&&(r.enhancements=e?.enhancements||[],-1!==r.enhancements.indexOf("HPHT")&&(r.enhancements[r.enhancements.indexOf("HPHT")]=o("search.colorEnhanced.text","Color Enhanced")),i.push(r.enhancements.join(", "))),e?.eye_clean&&Array.isArray(e.eye_clean)&&(r.eye_clean=e.eye_clean,i.push(r.eye_clean.join(", "))),e?.no_bgm&&(r.no_bgm=e?.no_bgm,i.push(o("search.noBgm.text","No BGM"))),e?.three_vg_plus&&(r.three_vg_plus=e?.three_vg_plus,i.push(o("search.threeVgPlus.text","3VG+"))),e?.eight_x&&(r.eight_x=e?.eight_x,i.push(o("search.eightX.text","8X"))),e?.inclusion_pattern&&(r.inclusion_pattern=e?.inclusion_pattern),e?.intensity_black_code&&(r.intensity_black_code=e?.intensity_black_code),e?.inclusion_open&&(r.inclusion_open=e?.inclusion_open),e?.with_images&&(r.with_images=e?.with_images),e?.certified_pairs&&(r.certified_pairs=e?.certified_pairs),e?.with_available_items&&(r.with_available_items=e?.with_available_items),e?.pair&&(r.pair=e?.pair),e?.discount_percent_from&&(r.discount_percent_from=e?.discount_percent_from),e?.discount_percent_to&&(r.discount_percent_to=e?.discount_percent_to);let y="",b=o("search.crown.text","Crown");e?.crown_percent_from&&e?.crown_percent_from>=0&&(r.crown_percent_from=e?.crown_percent_from,y+=b+": "+r.crown_percent_from+"%"),e?.crown_percent_to&&e?.crown_percent_to>=0&&(r.crown_percent_to=e?.crown_percent_to,y+=""===y?b+": 0% - "+r.crown_percent_to+"%":" - "+r.crown_percent_to+"%"),e?.crown_angle_from&&e?.crown_angle_from>=0&&(r.crown_angle_from=e?.crown_angle_from,y+=""===y?b+": "+r.crown_angle_from+"°":", "+r.crown_angle_from+"°"),e?.crown_angle_to&&e?.crown_angle_to>=0&&(r.crown_angle_to=e?.crown_angle_to,y+=""===y?"0° - "+r.crown_angle_to+"°":void 0===e?.crown_angle_from?", 0° - "+r.crown_angle_to+"°":" - "+r.crown_angle_to+"°"),y&&i.push(y);let _="",w=o("search.pavilion.text","Pavilion");return e?.pavilion_percent_from&&e?.pavilion_percent_from>0&&(r.pavilion_percent_from=e?.pavilion_percent_from,_+=w+": "+r.pavilion_percent_from+"%"),e?.pavilion_percent_to&&e?.pavilion_percent_to>0&&(r.pavilion_percent_to=e?.pavilion_percent_to,_+=""===_?w+": 0% - "+r.pavilion_percent_to+"%":" - "+r.pavilion_percent_to+"%"),e?.pavilion_angle_from&&e?.pavilion_angle_from>0&&(r.pavilion_angle_from=e?.pavilion_angle_from,_+=""===_?w+": "+r.pavilion_angle_from+"°":", "+r.pavilion_angle_from+"°"),e?.pavilion_angle_to&&e?.pavilion_angle_to>0&&(r.pavilion_angle_to=e?.pavilion_angle_to,_+=""===_?"0° - "+r.pavilion_angle_to+"°":void 0===e?.pavilion_angle_from?", 0° - "+r.pavilion_angle_to+"°":" - "+r.pavilion_angle_to+"°"),_&&i.push(_),{title:i.filter(Boolean).join(" | "),options:r}};let mi=function(e){return e.diam="diam",e.gem="gem",e.jewelry="jewelry",e.lab="lab",e.default="default",e}({}),gi=function(e){return e[e.primary=0]="primary",e[e.secondary=1]="secondary",e[e.tertiary=2]="tertiary",e}({}),vi=function(e){return e.DIAMOND="diamond",e.LAB_GROWN_DIAMOND="lab_grown_diamond",e.GEMSTONE="gemstone",e.JEWELRY="jewelry",e.LABGROWN_JEWELRY="lab_grown_jewelry",e}({});const yi=e=>{switch(e){case vi.DIAMOND:case"Natural":return"diam-06";case vi.GEMSTONE:return"gem-06";case vi.JEWELRY:return"jewelry-06";case vi.LAB_GROWN_DIAMOND:case"Lab-Grown":case vi.LABGROWN_JEWELRY:return"lab-06";default:return"diam-06"}},bi=e=>{switch(e){case vi.DIAMOND:return"diam-03";case vi.GEMSTONE:return"gem-03";case vi.JEWELRY:return"jewelry-03";case vi.LAB_GROWN_DIAMOND:case vi.LABGROWN_JEWELRY:return"lab-03";default:return"diam-03"}},_i=e=>{if(e)return["Champagne","Cognac","Chameleon"].includes(e)},wi=(e,t)=>{let n=null;return n=e?_i(t?.fancy_color_overtone_long)?t?.is_fancy?`${t?.fancy_color_intensity_short||t?.color||""} ${t?.fancy_color_short||""}(${t?.fancy_color_overtone_long||""})`:`${t?.fancy_color_long||t?.color||""}`:t?.is_fancy?`${t?.fancy_color_intensity_short||t?.fancy_color_intensity||""} ${t?.fancy_color_overtone_short||""}${t?.fancy_color_short||""}`:`${t?.fancy_color_long||t?.color||""}`:_i(t?.fancy_color_overtone_long)?t?.is_fancy?[t?.fancy_color_intensity_long||t?.fancy_color_intensity,t?.fancy_color_long,t?.fancy_color_overtone_long?`(${t.fancy_color_overtone_long})`:null].filter(Boolean).join(" "):t?.fancy_color_long||t?.color||"":t?.is_fancy?[t?.fancy_color_intensity_long||t?.fancy_color_intensity,t?.fancy_color_overtone_long,t?.fancy_color_long].filter(Boolean).join(" "):t?.fancy_color_long||t?.color||"",""===n?"-":n},Si=vn.View`
|
|
53
53
|
background-color: ${e=>{let{theme:t,backgroundColor:n}=e;return t[n]}};
|
|
54
54
|
align-items: center;
|
|
55
55
|
justify-content: center;
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
align-self: flex-start;
|
|
124
124
|
width: 100%;
|
|
125
125
|
`}};
|
|
126
|
-
`,Mi=i.A.create({rowContainer:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:8,marginTop:0,marginBottom:12,width:"100%"},alignRight:{alignSelf:"flex-end"},alignLeft:{alignSelf:"flex-start"},likeDislikeContainer:{flexDirection:"row",gap:6},timeContainer:{margin:0},borderButtonHover:{backgroundColor:"#EDEDF2"}}),Fi=e=>{let{message:r,priceMode:i,handleFeedbackAction:o}=e;const a=Wt(),s="user"===r.role,[l,u]=t.useState(null),{t:c}=Br();t.useEffect(()=>{(async()=>{const e=await(async e=>{const t=await async function(){const e=await Nr("persist:userInfo",{}),t=JSON.parse(e?.user||"{}");return t?.token||""}(),n=await Nr("vdbchat_conversations",null);if(!n||n.token!==t)return null;const r=n.conversations||{};let i=e;if(void 0===i){const e=await Nr("persist:userInfo",{}),t=e?.user;i=String(t?.price_mode)||""}return String(r[i]?.conversation_id)||null})(i);u(e)})()},[i]);const d="string"==typeof r.id&&r.id.length>0&&!r.id.startsWith("bot-loading-"),h="assistant"===r.role&&!r.isLoading&&d&&Object.keys(r.search_payload||{}).length>0&&!!l;return t.createElement(Di,{isUser:s},t.createElement(n.A,{style:Mi.timeContainer},t.createElement(Li,{theme:a},ti(r.createdAt,c))),h?t.createElement(n.A,{style:Mi.likeDislikeContainer},t.createElement(Ni,{type:"like",style:e=>[e?.hovered&&Mi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.LIKE,String(l),r.id),disabled:!h},t.createElement(Ii,{source:{uri:"https://cdn.vdbapp.com/ai/chat-widget/assets/img/like.svg"},resizeMode:"contain",style:{width:20,height:20,tintColor:r.reaction===ni.LIKE?a["success-01"]||"#00B140":a["core-05"]||"#020001"}})),t.createElement(Ni,{type:"dislike",style:e=>[e?.hovered&&Mi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.DISLIKE,String(l),r.id),disabled:!h},t.createElement(Ii,{source:{uri:"https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike.svg"},resizeMode:"contain",style:{width:20,height:20,tintColor:r.reaction===ni.DISLIKE?a["error-01"]||"#D0021B":a["core-05"]||"#020001"}}))):null)},Vi={primaryColor:"#0b93f6",backgroundColor:"#ffffff",inputColor:"#FFF",inputBackgroundColor:"#FFFFFF",inputBorderRadius:8,inputTextColor:"#000000",userBubbleColor:"#4F4E57",userTextColor:"#ffffff",botBubbleColor:"#EDEDF2",botTextColor:"#000000",borderRadius:8,fontFamily:void 0,fontSize:16},zi="v3",ji=e=>`${e}${zi}/agent_conversations`,Bi=e=>`${e}${zi}/vdb/search_diamonds`,Hi=(e,t,n)=>`${e}${zi}/agent_conversations/${t}/conversation_messages/${n}/reaction`;
|
|
126
|
+
`,Mi=i.A.create({rowContainer:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:8,marginTop:0,marginBottom:12,width:"100%"},alignRight:{alignSelf:"flex-end"},alignLeft:{alignSelf:"flex-start"},likeDislikeContainer:{flexDirection:"row",gap:6},timeContainer:{margin:0},borderButtonHover:{backgroundColor:"#EDEDF2"}}),Fi=e=>{let{message:r,priceMode:i,handleFeedbackAction:o}=e;const a=Wt(),s="user"===r.role,[l,u]=t.useState(null),{t:c}=Br();t.useEffect(()=>{(async()=>{const e=await(async e=>{const t=await async function(){const e=await Nr("persist:userInfo",{}),t=JSON.parse(e?.user||"{}");return t?.token||""}(),n=await Nr("vdbchat_conversations",null);if(!n||n.token!==t)return null;const r=n.conversations||{};let i=e;if(void 0===i){const e=await Nr("persist:userInfo",{}),t=e?.user;i=String(t?.price_mode)||""}return String(r[i]?.conversation_id)||null})(i);u(e)})()},[i]);const d="string"==typeof r.id&&r.id.length>0&&!r.id.startsWith("bot-loading-"),h="assistant"===r.role&&!r.isLoading&&d&&Object.keys(r.search_payload||{}).length>0&&!!l;return t.createElement(Di,{isUser:s},t.createElement(n.A,{style:Mi.timeContainer},t.createElement(Li,{theme:a},ti(r.createdAt,c))),h?t.createElement(n.A,{style:Mi.likeDislikeContainer},t.createElement(Ni,{type:"like",style:e=>[e?.hovered&&Mi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.LIKE,String(l),r.id),disabled:!h},t.createElement(Ii,{source:{uri:"https://cdn.vdbapp.com/ai/chat-widget/assets/img/like.svg"},resizeMode:"contain",style:{width:20,height:20,tintColor:r.reaction===ni.LIKE?a["success-01"]||"#00B140":a["core-05"]||"#020001"}})),t.createElement(Ni,{type:"dislike",style:e=>[e?.hovered&&Mi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.DISLIKE,String(l),r.id),disabled:!h},t.createElement(Ii,{source:{uri:"https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike.svg"},resizeMode:"contain",style:{width:20,height:20,tintColor:r.reaction===ni.DISLIKE?a["error-01"]||"#D0021B":a["core-05"]||"#020001"}}))):null)},Vi={primaryColor:"#0b93f6",backgroundColor:"#ffffff",inputColor:"#FFF",inputBackgroundColor:"#FFFFFF",inputBorderRadius:8,inputTextColor:"#000000",userBubbleColor:"#4F4E57",userTextColor:"#ffffff",botBubbleColor:"#EDEDF2",botTextColor:"#000000",borderRadius:8,fontFamily:void 0,fontSize:16},zi="v3",ji=e=>`${e}${zi}/agent_conversations`,Bi=e=>`${e}${zi}/vdb/search_diamonds`,Hi=(e,t,n)=>`${e}${zi}/agent_conversations/${t}/conversation_messages/${n}/reaction`;let $i=null;function Wi(e){$i=e}async function Ui(){if($i)return $i;const e=await Nr("persist:userInfo",{}),t=JSON.parse(e?.user||"{}");return t?.token||""}async function Ki(){const e=await Ui(),t=await Pr("persist:appState")||"{}";let n="web";try{const e=JSON.parse(t);n=e?.installationIdentifier?JSON.parse(e.installationIdentifier):"web"}catch{n="web"}return{"Content-Type":"application/json",Accept:"application/json, text/plain, */*",Authorization:`Token token=${e},installation_identifier=${n}`,Cookie:`vdb-server_session=${await Pr("session_cookie")||""}`}}async function qi(){const e=await Ui(),t=await Nr("vdbchat_conversations",null);return t&&t.token===e?t.conversations||{}:(await Ir("vdbchat_conversations"),{})}async function Yi(e){const t=await Ui(),n=await Nr("vdbchat_conversations",null),r={token:t,conversations:e,chat_has_initialized:n?.token===t?n.chat_has_initialized:void 0};await Lr("vdbchat_conversations",r)}async function Gi(e){const t=await Ui(),n=await Nr("vdbchat_conversations",null);n?.token!==t?await Lr("vdbchat_conversations",{token:t,conversations:{},chat_has_initialized:e}):await Lr("vdbchat_conversations",{...n,chat_has_initialized:e})}async function Xi(e,t){const n=Array.isArray(e)?e:e?.messages;if(!Array.isArray(n))return[];const r=await Nr("persist:userInfo",{}),i=JSON.parse(r?.searchResultViewType||"{}"),o=JSON.parse(await Pr("persist:root")||"{}"),a="string"==typeof o?.selectedGroups?JSON.parse(o.selectedGroups)?.selectedGroups:o?.selectedGroups?.selectedGroups||{};return n.map((e,n)=>{const r=("string"==typeof e.lab_grown?"true"===e.lab_grown:"boolean"==typeof e.lab_grown&&e.lab_grown)?vi.LAB_GROWN_DIAMOND:vi.DIAMOND,o=i?.[r??"default"];let s=a[r??""],l=!1;s?s.includes(0)&&(l=!0,s=s.filter(e=>0!==e)):s&&0!==s.length||(l=!0);let u={};return s&&s.length>0&&(u=Object.assign(u,{group_ids:s})),{id:String(e.id??`${e.role}-${n}-${e.created_at??Date.now()}`),role:"user"===e.role?"user":"assistant",text:String(e.content??e.text??""),createdAt:"string"==typeof e.created_at?Date.parse(e.created_at):"number"==typeof e.createdAt?e.createdAt:Date.now(),search_payload:e.search_payload&&Object.keys(e.search_payload).length>0?fi({searchPayload:{...e.search_payload,...u},priceMode:t,vdbSetting:l,searchResultViewType:o}):{},reaction:String(e.reaction??"0"),suggestions:Array.isArray(e.suggestions)?e.suggestions:void 0,recommendation_payload:e.recommendation_payload??null}})}async function Ji(e,t,n){const r=await qi(),i=r?.[n??""]?.conversation_id??null;if(void 0===n)return;const o={};i&&(o.conversation_id=Number.isNaN(Number(i))?i:Number(i));const a=await fetch(ji(e),{method:"POST",headers:await Ki(),body:Object.keys(o).length?JSON.stringify(o):void 0});if(!a.ok)throw new Error(`POST ${ji(e)} failed with ${a.status}`);const s=await a.json();if(s&&null!=s.conversation_id&&n){const e={...r};e[n]={conversation_id:s.conversation_id},await Yi(e)}return s}async function Qi(e,t){const n=await fetch(Bi(e),{method:"POST",headers:await Ki(),body:JSON.stringify({vdb:{...t,page_size:50,page_number:1}})});if(!n.ok)throw new Error(`POST failed with ${n.status}`);return await n.json()}function Zi(e){return{diamond_id:String(e.id),price:e.total_sales_price,carat:e.size,shape:e.shape_short||e.shape,cut:e.cut_short||e.cut,color:e.color_short||e.color,clarity:e.clarity_short||e.clarity,lab:e.lab_short||e.lab,polish:e.polish_short||e.polish,symmetry:e.symmetry_short||e.symmetry,fluorescence:e.fluorescence_intensity_short||e.fluorescence,table_percent:e.table_percent,depth_percent:e.depth_percent,has_image:Boolean(e.image_url||e.has_image),has_video:Boolean(e.video_url||e.has_video)}}const eo=vn.Text`
|
|
127
127
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
128
128
|
font-family: "Roboto";
|
|
129
129
|
font-size: 13px;
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
font-weight: 400;
|
|
132
132
|
line-height: 18px;
|
|
133
133
|
text-align: center;
|
|
134
|
-
`,
|
|
134
|
+
`,to=i.A.create({container:{alignSelf:"stretch",paddingVertical:6,backgroundColor:"transparent",alignItems:"center",justifyContent:"center"}}),no=e=>{let{active:r}=e;const{t:i}=Br();return r?t.createElement(n.A,{style:to.container},t.createElement(eo,null,i("beta.notice.text","This beta feature uses AI-generated results that should be verified."))):null};var ro=a(6413),io=a(8506);let oo=yt.A;if("web"!==r.A.OS)try{const e=Object(function(){var e=new Error("Cannot find module 'expo-image'");throw e.code="MODULE_NOT_FOUND",e}());e&&(oo=e)}catch{}const ao=e=>{let{data:r,onViewAll:i,onItemPress:o,item:a}=e;const{t:s}=Br();return r&&r.length?t.createElement(n.A,{style:so.wrapper},t.createElement(gt.A,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:so.listContent},r.map(e=>t.createElement(ro.A,{key:e.id,onPress:()=>{o?.(e)}},t.createElement(n.A,{key:e.id,style:so.card},e.image_thumb_url?t.createElement(oo,{style:so.image,source:{uri:e.image_thumb_url}}):null,t.createElement(n.A,{style:so.content},t.createElement(io.A,{numberOfLines:2,style:so.title},e.short_title),t.createElement(io.A,{style:so.price},"$",e.total_sales_price)))))),a?.search_payload?.cert_num?null:t.createElement(ro.A,{style:so.button,activeOpacity:.8,onPress:i},t.createElement(io.A,{style:so.buttonText},s("results.viewAll.text","View All {{total}} diamonds",{total:""})," ",">>"))):null},so=i.A.create({wrapper:{paddingHorizontal:12,marginHorizontal:12,marginBottom:12,paddingTop:6,paddingBottom:14,backgroundColor:"#fff",borderRadius:8,borderWidth:1,borderColor:"#e8e8e8",elevation:3,shadowColor:"#000",shadowOpacity:.08,shadowOffset:{width:0,height:2},shadowRadius:6},listContent:{gap:12,paddingVertical:6},card:{width:150,backgroundColor:"#fff",borderRadius:14,overflow:"hidden",borderColor:"#e8e8e8",borderWidth:1,elevation:3,shadowColor:"#000",shadowOpacity:.08,shadowOffset:{width:0,height:2},shadowRadius:6},image:{width:"100%",height:120,borderBottomWidth:1,borderBottomColor:"#e8e8e8"},content:{padding:10,gap:4},title:{fontSize:13,color:"#222",fontWeight:"500"},price:{marginTop:4,fontSize:14,fontWeight:"700",color:"#000"},button:{marginTop:12,alignSelf:"center",paddingHorizontal:20,paddingVertical:8,backgroundColor:"#804195",borderRadius:20,width:300,alignItems:"center"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"}}),lo=(0,t.memo)(ao);var uo=a(4129);const co=vn.Pressable`
|
|
135
135
|
justify-content: center;
|
|
136
136
|
align-items: center;
|
|
137
137
|
width: ${e=>{let{width:t}=e;return t||"100%"}};
|
|
@@ -141,105 +141,105 @@
|
|
|
141
141
|
border-radius: ${e=>{let{borderRadius:t}=e;return t>0?t:8}}px;
|
|
142
142
|
border-width: ${e=>{let{type:t}=e;return t===gi.secondary?2:0}}px;
|
|
143
143
|
border-color: ${e=>{let{borderColor:t,theme:n}=e;return n[t]}};
|
|
144
|
-
`,
|
|
144
|
+
`,ho=(vn.Text`
|
|
145
145
|
color: ${e=>{let{color:t}=e;return t||"#FFFFFF"}};
|
|
146
146
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto-Regular"}};
|
|
147
147
|
font-weight: ${e=>{let{isBold:t}=e;return t?"500":"400"}};
|
|
148
148
|
font-size: 14px;
|
|
149
149
|
font-style: normal;
|
|
150
|
-
`,e=>{let{category:n=mi.default,type:r=gi.primary,disabled:i=!1,loading:o,onPress:a,height:s,width:l,borderRadius:u,isDisableInteraction:c=!1,maxWidth:d,style:h,children:f}=e;const p=Wt(),[m,g]=(0,t.useState)(!1),{textColor:v,background:y,borderColor:b,hover:_}=((e,t,n)=>{if(n){if(t===gi.primary)return{textColor:"primary-cont-disabled",background:"primary-bg-disabled",borderColor:"transparent",hover:"transparent"};if(t===gi.secondary)return{textColor:"secondary-cont-disabled",background:"transparent",borderColor:"secondary-bor-disabled",hover:"transparent"};if(t===gi.tertiary)return{textColor:"tertiary-cont-disabled",background:"tertiary-bg-disabled",borderColor:"transparent",hover:"transparent"}}return t===gi.primary?e===mi.default?{textColor:"primary-cont",background:"primary-bg-static",borderColor:"transparent",hover:"primary-bg-hover"}:{textColor:`${e}-05`,background:`${e}-01`,borderColor:"transparent",hover:`${e}-02`}:t===gi.secondary?e===mi.default?{textColor:"secondary-cont",background:"transparent",borderColor:"secondary-bor-static",hover:"secondary-bg-hover"}:{textColor:`${e}-06`,background:"transparent",borderColor:`${e}-01`,hover:`${e}-03`}:t===gi.tertiary?e===mi.default?{textColor:"tertiary-cont",background:"tertiary-bg-static",borderColor:"transparent",hover:"transparent"}:{textColor:`${e}-06`,background:`${e}-03`,borderColor:"transparent",hover:"transparent"}:{textColor:"primary-cont",background:"primary-bg-static",borderColor:"transparent",hover:"primary-bg-hover"}})(n,r,i);return t.createElement(
|
|
150
|
+
`,e=>{let{category:n=mi.default,type:r=gi.primary,disabled:i=!1,loading:o,onPress:a,height:s,width:l,borderRadius:u,isDisableInteraction:c=!1,maxWidth:d,style:h,children:f}=e;const p=Wt(),[m,g]=(0,t.useState)(!1),{textColor:v,background:y,borderColor:b,hover:_}=((e,t,n)=>{if(n){if(t===gi.primary)return{textColor:"primary-cont-disabled",background:"primary-bg-disabled",borderColor:"transparent",hover:"transparent"};if(t===gi.secondary)return{textColor:"secondary-cont-disabled",background:"transparent",borderColor:"secondary-bor-disabled",hover:"transparent"};if(t===gi.tertiary)return{textColor:"tertiary-cont-disabled",background:"tertiary-bg-disabled",borderColor:"transparent",hover:"transparent"}}return t===gi.primary?e===mi.default?{textColor:"primary-cont",background:"primary-bg-static",borderColor:"transparent",hover:"primary-bg-hover"}:{textColor:`${e}-05`,background:`${e}-01`,borderColor:"transparent",hover:`${e}-02`}:t===gi.secondary?e===mi.default?{textColor:"secondary-cont",background:"transparent",borderColor:"secondary-bor-static",hover:"secondary-bg-hover"}:{textColor:`${e}-06`,background:"transparent",borderColor:`${e}-01`,hover:`${e}-03`}:t===gi.tertiary?e===mi.default?{textColor:"tertiary-cont",background:"tertiary-bg-static",borderColor:"transparent",hover:"transparent"}:{textColor:`${e}-06`,background:`${e}-03`,borderColor:"transparent",hover:"transparent"}:{textColor:"primary-cont",background:"primary-bg-static",borderColor:"transparent",hover:"primary-bg-hover"}})(n,r,i);return t.createElement(co,{onPress:a,disabled:i||o||c,textColor:v,background:y,borderColor:b,borderRadius:u,onHoverIn:()=>g(!0),onHoverOut:()=>g(!1),height:s,width:l,maxWidth:d,type:r,style:e=>{let{pressed:t}=e;return[{...h,backgroundColor:t||m?p[_]:p[y]}]}},o?t.createElement(vt.A,{color:p[v]}):f)});let fo=null;if("web"!==r.A.OS)try{const e=Object(function(){var e=new Error("Cannot find module 'expo-image'");throw e.code="MODULE_NOT_FOUND",e}());e&&(fo=e)}catch{}const po=e=>{let{data:r,totalResults:i,onViewAll:o,onItemPress:a,showMoreResults:s,showLessResults:l,trackAnalyticsEvent:u,currentPage:c=1,isLoadingMore:d=!1,item:h}=e;if(!r||!r.length)return null;const f=Wt(),{t:p}=Br(),[m,g]=(0,t.useState)(null),[v,y]=(0,t.useState)(!1),b=h?.search_payload,_="string"==typeof b.lab_grown?"true"===b.lab_grown:"boolean"==typeof b.lab_grown&&b.lab_grown;_?vi.LAB_GROWN_DIAMOND:vi.DIAMOND,(0,t.useEffect)(()=>{(async()=>{const e=await ri();g(e)})(),(async()=>{const e=await ii();y(e)})()},[]);const w=function(e,t){return!(e>=6)&&(!!t&&(!(t<=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:0))&&!(t<=5*e)))};return t.createElement(mo,{theme:f},t.createElement(gt.A,{showsVerticalScrollIndicator:!1},r.map((e,r)=>t.createElement(uo.A,{key:e.id,onPress:()=>(e=>{a?.(e)})(e)},r=>t.createElement(wo,{theme:f,hovered:r.hovered},t.createElement(n.A,null,t.createElement(n.A,{style:Do.left},t.createElement(n.A,{style:Do.tokens},t.createElement(So,null,t.createElement(xo,null,t.createElement(No,null,t.createElement(bo,null,`${e.shape_short??"-"}`),t.createElement(bo,null,`${e.size??"-"}ct`),t.createElement(bo,null,`${wi(!0,e)??"-"}`),t.createElement(bo,null,`${e.clarity_short??"-"}`),t.createElement(bo,null,`${e.lab_short??"-"}`)),t.createElement(n.A,{style:{flexDirection:"row",alignItems:"center"}},t.createElement(yo,null,e.cut_short??"-"),t.createElement(yo,null,"/"),t.createElement(yo,null,e.polish_short??"-"),t.createElement(yo,null,"/"),t.createElement(yo,null,e.symmetry_short??"-")),t.createElement(yo,null,e.fluorescence_intensity_short??"-")),t.createElement(Eo,null,t.createElement(Ro,null,e.price_per_carat?t.createElement(bo,null,m||"$"):t.createElement(t.Fragment,null),t.createElement(bo,null,ai("price_per_carat",e.price_per_carat,v)??"-")),t.createElement(yo,null,p("product.pricePerCarat.text","p/ct")))),t.createElement(Co,null,t.createElement(ko,null,t.createElement(Oo,null,t.createElement(yo,null,p("product.depth.text","D")),t.createElement(bo,null,e.depth_percent?e.depth_percent+"%":"-")),t.createElement(Io,null,t.createElement(yo,null,p("product.table.text","T")),t.createElement(bo,null,e.table_percent?e.table_percent+"%":"-")),t.createElement(Lo,null,t.createElement(yo,null,e.measurement??"-"))),t.createElement(Ao,null,_?t.createElement(t.Fragment,null):t.createElement(bo,null,e.discount_percent?e.discount_percent+"%":"-"),t.createElement(To,null,t.createElement(Po,null,e.total_sales_price?t.createElement(bo,null,m||"$"):t.createElement(t.Fragment,null),t.createElement(bo,null,ai("total_sales_price",e.total_sales_price,v)??"-")),t.createElement(yo,null,p("product.total.text","total")))))))))))),s&&w(c,i,r.length)&&t.createElement(go,null,t.createElement(uo.A,{onPress:s,disabled:d},t.createElement(vo,{theme:f},d?p("results.loading.text","Loading..."):p("results.showMore.text","Show more")))),l&&((e,t)=>!(e<=1)&&!w(e,i,t))(c,r.length)&&t.createElement(go,null,t.createElement(uo.A,{onPress:l},t.createElement(vo,{theme:f},p("results.showLess.text","Show less")))),h?.search_payload?.cert_num?null:t.createElement(ho,{category:_?mi.lab:mi.diam,height:32,type:gi.primary,borderRadius:8,style:{marginTop:12},onPress:()=>(e=>{o?.(e)})(h)},t.createElement(_o,null,p("results.viewAll.text","View All {{total}} diamonds",{total:Number(i).toLocaleString()}))))},mo=vn.View`
|
|
151
151
|
padding-horizontal: 8px;
|
|
152
|
-
`,
|
|
152
|
+
`,go=vn.View`
|
|
153
153
|
margin-top: 8px;
|
|
154
154
|
align-items: flex-start;
|
|
155
155
|
justify-content: center;
|
|
156
|
-
`,
|
|
156
|
+
`,vo=vn.Text`
|
|
157
157
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378F6"}};
|
|
158
158
|
font-size: 14px;
|
|
159
159
|
font-weight: 500;
|
|
160
160
|
font-family: "Roboto-Medium";
|
|
161
|
-
`,
|
|
161
|
+
`,yo=vn.Text`
|
|
162
162
|
font-size: 13px;
|
|
163
163
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
164
164
|
font-weight: 400;
|
|
165
165
|
font-family: "Roboto-Regular";
|
|
166
166
|
font-style: normal;
|
|
167
|
-
`,
|
|
167
|
+
`,bo=vn.Text`
|
|
168
168
|
font-size: 13px;
|
|
169
169
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
170
170
|
font-weight: 500;
|
|
171
171
|
font-family: "Roboto-Medium";
|
|
172
172
|
font-style: normal;
|
|
173
|
-
`,
|
|
173
|
+
`,_o=vn.Text`
|
|
174
174
|
color: ${e=>{let{theme:t}=e;return t["primary-cont"]||"#ffffff"}};
|
|
175
175
|
font-size: 14px;
|
|
176
176
|
font-weight: 500;
|
|
177
177
|
font-family: "Roboto-Medium";
|
|
178
|
-
`,
|
|
178
|
+
`,wo=vn.View`
|
|
179
179
|
padding-vertical: 12px;
|
|
180
180
|
border-bottom-width: 1px;
|
|
181
181
|
border-bottom-color: ${e=>{let{theme:t}=e;return t["core-03"]||"#D5D5DC"}};
|
|
182
182
|
background-color: ${e=>{let{theme:t,hovered:n}=e;return n?t["secondary-bg-hover"]||"#EDEDF2":"transparent"}};
|
|
183
|
-
`,
|
|
183
|
+
`,So=vn.View`
|
|
184
184
|
flex-direction: row;
|
|
185
185
|
justify-content: space-between;
|
|
186
186
|
align-items: center;
|
|
187
187
|
width: 100%;
|
|
188
|
-
`,
|
|
188
|
+
`,xo=vn.View`
|
|
189
189
|
flex-direction: row;
|
|
190
190
|
justify-content: space-between;
|
|
191
191
|
align-items: center;
|
|
192
192
|
gap: 8px;
|
|
193
|
-
`,
|
|
193
|
+
`,Eo=vn.View`
|
|
194
194
|
flex-direction: row;
|
|
195
195
|
justify-content: space-between;
|
|
196
196
|
align-items: center;
|
|
197
197
|
gap: 4px;
|
|
198
|
-
`,
|
|
198
|
+
`,Co=vn.View`
|
|
199
199
|
flex-direction: row;
|
|
200
200
|
justify-content: space-between;
|
|
201
201
|
align-items: center;
|
|
202
202
|
width: 100%;
|
|
203
|
-
`,
|
|
203
|
+
`,ko=vn.View`
|
|
204
204
|
flex-direction: row;
|
|
205
205
|
justify-content: space-between;
|
|
206
206
|
align-items: center;
|
|
207
207
|
gap: 8px;
|
|
208
|
-
`,
|
|
208
|
+
`,Ao=vn.View`
|
|
209
209
|
flex-direction: row;
|
|
210
210
|
justify-content: space-between;
|
|
211
211
|
align-items: center;
|
|
212
212
|
gap: 4px;
|
|
213
|
-
`,
|
|
213
|
+
`,Ro=vn.View`
|
|
214
214
|
flex-direction: row;
|
|
215
215
|
align-items: center;
|
|
216
|
-
`,
|
|
216
|
+
`,To=vn.View`
|
|
217
217
|
flex-direction: row;
|
|
218
218
|
justify-content: space-between;
|
|
219
219
|
align-items: center;
|
|
220
220
|
gap: 4px;
|
|
221
|
-
`,
|
|
221
|
+
`,Po=vn.View`
|
|
222
222
|
flex-direction: row;
|
|
223
223
|
align-items: center;
|
|
224
224
|
width: 65px;
|
|
225
225
|
justify-content: flex-end;
|
|
226
|
-
`,
|
|
226
|
+
`,Oo=vn.View`
|
|
227
227
|
flex-direction: row;
|
|
228
228
|
align-items: center;
|
|
229
229
|
gap: 2px;
|
|
230
|
-
`,
|
|
230
|
+
`,Io=vn.View`
|
|
231
231
|
flex-direction: row;
|
|
232
232
|
align-items: center;
|
|
233
233
|
gap: 2px;
|
|
234
|
-
`,
|
|
234
|
+
`,No=vn.View`
|
|
235
235
|
flex-direction: row;
|
|
236
236
|
align-items: center;
|
|
237
237
|
gap: 2px;
|
|
238
|
-
`,
|
|
238
|
+
`,Lo=vn.View``,Do=i.A.create({listContent:{gap:8},left:{flexDirection:"row",alignItems:"flex-start",minWidth:0},serialContainer:{alignItems:"flex-start",justifyContent:"center",marginRight:4},tokens:{flexDirection:"row",flexWrap:"wrap",gap:2,flex:1,minWidth:0},lineBreak:{width:"100%",height:0},rowCenter:{flexDirection:"row",alignItems:"center"}}),Mo=(0,t.memo)(po),Fo=e=>{let{data:n,onViewAll:r,onItemPress:i,variant:o="list",totalResults:a,item:s,showMoreResults:l,showLessResults:u,trackAnalyticsEvent:c,currentPage:d=1,isLoadingMore:h=!1}=e;return n&&n.length?"list"===o?t.createElement(Mo,{data:n,onViewAll:r,onItemPress:i,totalResults:a,item:s,showMoreResults:l,showLessResults:u,trackAnalyticsEvent:c,currentPage:d,isLoadingMore:h}):t.createElement(lo,{data:n,onViewAll:r,onItemPress:i,totalResults:a,item:s}):null},Vo=e=>{let{messageId:i,payload:o,onFetched:a,priceMode:s,apiUrl:l}=e;const{ref:u,inView:c}=function(){const e=(0,t.useRef)(null),[n,i]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{if("web"!==r.A.OS)return void i(!0);const t=e.current;if(!t||"undefined"==typeof IntersectionObserver)return void i(!0);const n=new IntersectionObserver(e=>{const t=e[0];i(t.isIntersecting)},{root:null,rootMargin:"0px",threshold:.1});return n.observe(t),()=>{n.disconnect()}},[]),{ref:e,inView:n}}(),d=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{d.current||o&&"object"==typeof o&&c&&(d.current=!0,(async()=>{try{const e=await Qi(l,o);a(i,e)}catch(e){console.error("Lazy fetch products failed",e)}})())},[c,i,a,o,s]),t.createElement(n.A,{ref:u,style:{height:1}})},zo=vn.View``,jo=vn(uo.A)`
|
|
239
239
|
border-radius: 8px;
|
|
240
240
|
overflow: hidden;
|
|
241
241
|
padding-horizontal: 8px;
|
|
242
|
-
`,
|
|
242
|
+
`,Bo=vn.View`
|
|
243
243
|
flex-direction: row;
|
|
244
244
|
align-items: center;
|
|
245
245
|
justify-content: center;
|
|
@@ -251,184 +251,184 @@
|
|
|
251
251
|
border-color: ${e=>{let{theme:t}=e;return t["diam-01"]||"#3378F6"}};
|
|
252
252
|
background-color: ${e=>{let{theme:t,pressed:n,hovered:r,disabled:i}=e;return i?t["core-02"]||"#F5F5F5":n?t["diam-01"]+"20"||0:r?t["diam-01"]+"10"||0:"transparent"}};
|
|
253
253
|
opacity: ${e=>{let{disabled:t}=e;return t?.6:1}};
|
|
254
|
-
`,
|
|
254
|
+
`,Ho=vn.Text`
|
|
255
255
|
font-size: 14px;
|
|
256
256
|
font-weight: 500;
|
|
257
257
|
font-family: "Roboto-Medium";
|
|
258
258
|
color: ${e=>{let{theme:t}=e;return t["diam-01"]||"#3378F6"}};
|
|
259
|
-
|
|
259
|
+
`,$o=vn.Text`
|
|
260
260
|
font-size: 16px;
|
|
261
|
-
`,
|
|
261
|
+
`,Wo=e=>{let{onPress:n,loading:r=!1,disabled:i=!1}=e;const o=Wt(),{t:a}=Br();return t.createElement(zo,null,t.createElement(jo,{onPress:n,disabled:r||i,theme:o},e=>{let{pressed:n,hovered:s}=e;return t.createElement(Bo,{theme:o,pressed:n,hovered:s,disabled:r||i},r?t.createElement(t.Fragment,null,t.createElement(vt.A,{size:"small",color:o["link-static"]||"#3378F6"}),t.createElement(Ho,{theme:o},a("recommendation.analyzing.text","Analyzing diamonds..."))):t.createElement(t.Fragment,null,t.createElement($o,{theme:o},"✨"),t.createElement(Ho,{theme:o},a("recommendation.cta.text","Find My Best Match"))))}))},Uo=e=>{let{recommendations:n,onItemPress:r}=e;const i=Wt(),{t:o}=Br(),[a,s]=(0,t.useState)(null),[l,u]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{(async()=>{const e=await ri();s(e)})(),(async()=>{const e=await ii();u(e)})()},[]),!n||0===n.length)return null;const c=e=>{switch(e){case"best_pick":return"#22C55E";case"runner_up":return"#F59E0B";default:return i["core-06"]||"#6B7280"}};return t.createElement(Ko,{theme:i},n.map((e,n)=>t.createElement(uo.A,{key:e.id||n,onPress:()=>(e=>{r?.(e)})(e)},n=>t.createElement(qo,{theme:i,hovered:n.hovered,isBestPick:"best_pick"===e.recommendationType},t.createElement(Yo,null,t.createElement(Go,{backgroundColor:c(e.recommendationType)},t.createElement(Xo,null,(e=>{switch(e){case"best_pick":return o("recommendation.bestPick.label","Best Pick");case"runner_up":return o("recommendation.runnerUp.label","Runner-Up");case"also_recommended":return o("recommendation.alsoRecommended.label","Also Recommended");default:return o("recommendation.alternative.label","Alternative")}})(e.recommendationType))),null!=e.score&&t.createElement(Jo,{theme:i},t.createElement(Qo,{theme:i},e.score),t.createElement(Zo,{theme:i},o("recommendation.score.label","score")))),t.createElement(ea,null,t.createElement(ta,null,t.createElement(na,null,t.createElement(ia,{theme:i,bold:!0},e.shape_short??e.shape??"-"),t.createElement(ia,{theme:i,bold:!0},e.size??e.carat??"-","ct"),t.createElement(ia,{theme:i,bold:!0},wi(!0,e)??e.color??"-"),t.createElement(ia,{theme:i,bold:!0},e.clarity_short??e.clarity??"-"),t.createElement(ia,{theme:i,bold:!0},e.lab_short??e.lab??"-")),t.createElement(oa,null,t.createElement(aa,{theme:i},e.total_sales_price||e.price?`${a||"$"}${ai("total_sales_price",e.total_sales_price||e.price,l)}`:"-"))),t.createElement(ra,null,t.createElement(ia,{theme:i},e.cut_short??e.cut??"-","/",e.polish_short??e.polish??"-","/",e.symmetry_short??e.symmetry??"-"),t.createElement(ia,{theme:i},e.fluorescence_intensity_short??e.fluorescence??"-")),"best_pick"===e.recommendationType&&e.recommendation_pitch&&t.createElement(sa,{theme:i},t.createElement(la,{theme:i},e.recommendation_pitch)),"best_pick"===e.recommendationType&&e.strengths&&e.strengths.length>0&&t.createElement(ua,null,t.createElement(ca,null,t.createElement(da,null,"✓"),t.createElement(ha,{theme:i},o("recommendation.strengths.label","Strengths"))),e.strengths.map((e,n)=>t.createElement(fa,{key:n},t.createElement(pa,{color:"#22C55E"},"•"),t.createElement(ma,{theme:i},e)))),"best_pick"===e.recommendationType&&e.concerns&&e.concerns.length>0&&t.createElement(ua,null,t.createElement(ca,null,t.createElement(da,null,"⚠"),t.createElement(ha,{theme:i},o("recommendation.concerns.label","Considerations"))),e.concerns.map((e,n)=>t.createElement(fa,{key:n},t.createElement(pa,{color:"#F59E0B"},"•"),t.createElement(ma,{theme:i},e)))),"best_pick"!==e.recommendationType&&e.reason&&t.createElement(ga,{theme:i},t.createElement(va,{theme:i},e.reason)),t.createElement(ya,null,t.createElement(ba,{theme:i},t.createElement(_a,{theme:i},o("recommendation.viewDiamond.text","View Diamond")))))))))},Ko=vn.View`
|
|
262
262
|
padding-horizontal: 8px;
|
|
263
263
|
gap: 12px;
|
|
264
|
-
`,
|
|
264
|
+
`,qo=vn.View`
|
|
265
265
|
border-radius: 12px;
|
|
266
266
|
border-width: ${e=>{let{isBestPick:t}=e;return t?"2px":"1px"}};
|
|
267
267
|
border-color: ${e=>{let{theme:t,isBestPick:n}=e;return n?"#22C55E":t["core-03"]||"#D5D5DC"}};
|
|
268
268
|
background-color: ${e=>{let{theme:t,hovered:n}=e;return n?t["secondary-bg-hover"]||"#EDEDF2":t["core-01"]||"#FFFFFF"}};
|
|
269
269
|
overflow: hidden;
|
|
270
|
-
`,
|
|
270
|
+
`,Yo=vn.View`
|
|
271
271
|
flex-direction: row;
|
|
272
272
|
justify-content: space-between;
|
|
273
273
|
align-items: flex-start;
|
|
274
|
-
`,
|
|
274
|
+
`,Go=vn.View`
|
|
275
275
|
padding-vertical: 6px;
|
|
276
276
|
padding-horizontal: 12px;
|
|
277
277
|
background-color: ${e=>{let{backgroundColor:t}=e;return t}};
|
|
278
278
|
border-bottom-right-radius: 12px;
|
|
279
|
-
`,
|
|
279
|
+
`,Xo=vn.Text`
|
|
280
280
|
font-size: 11px;
|
|
281
281
|
font-weight: 600;
|
|
282
282
|
font-family: "Roboto-Medium";
|
|
283
283
|
color: #ffffff;
|
|
284
284
|
text-transform: uppercase;
|
|
285
285
|
letter-spacing: 0.5px;
|
|
286
|
-
`,
|
|
286
|
+
`,Jo=vn.View`
|
|
287
287
|
flex-direction: row;
|
|
288
288
|
align-items: baseline;
|
|
289
289
|
padding: 8px 12px;
|
|
290
290
|
gap: 4px;
|
|
291
|
-
`,
|
|
291
|
+
`,Qo=vn.Text`
|
|
292
292
|
font-size: 18px;
|
|
293
293
|
font-weight: 700;
|
|
294
294
|
font-family: "Roboto-Bold";
|
|
295
295
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
296
|
-
`,
|
|
296
|
+
`,Zo=vn.Text`
|
|
297
297
|
font-size: 11px;
|
|
298
298
|
font-weight: 400;
|
|
299
299
|
font-family: "Roboto-Regular";
|
|
300
300
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
301
|
-
`,
|
|
301
|
+
`,ea=vn.View`
|
|
302
302
|
padding: 12px 16px 16px;
|
|
303
303
|
gap: 10px;
|
|
304
|
-
`,
|
|
304
|
+
`,ta=vn.View`
|
|
305
305
|
flex-direction: row;
|
|
306
306
|
justify-content: space-between;
|
|
307
307
|
align-items: center;
|
|
308
|
-
`,
|
|
308
|
+
`,na=vn.View`
|
|
309
309
|
flex-direction: row;
|
|
310
310
|
gap: 6px;
|
|
311
311
|
flex-wrap: wrap;
|
|
312
312
|
flex: 1;
|
|
313
|
-
`,
|
|
313
|
+
`,ra=vn.View`
|
|
314
314
|
flex-direction: row;
|
|
315
315
|
gap: 12px;
|
|
316
|
-
`,
|
|
316
|
+
`,ia=vn.Text`
|
|
317
317
|
font-size: 13px;
|
|
318
318
|
font-weight: ${e=>{let{bold:t}=e;return t?"500":"400"}};
|
|
319
319
|
font-family: ${e=>{let{bold:t}=e;return t?"Roboto-Medium":"Roboto-Regular"}};
|
|
320
320
|
color: ${e=>{let{theme:t,bold:n}=e;return n?t["core-05"]||"#020001":t["core-06"]||"#4F4E57"}};
|
|
321
|
-
`,
|
|
321
|
+
`,oa=vn.View`
|
|
322
322
|
align-items: flex-end;
|
|
323
|
-
`,
|
|
323
|
+
`,aa=vn.Text`
|
|
324
324
|
font-size: 16px;
|
|
325
325
|
font-weight: 600;
|
|
326
326
|
font-family: "Roboto-Medium";
|
|
327
327
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
328
|
-
`,
|
|
328
|
+
`,sa=vn.View`
|
|
329
329
|
background-color: ${e=>{let{theme:t}=e;return t["core-02"]||"#F5F5F5"}};
|
|
330
330
|
padding: 12px;
|
|
331
331
|
border-radius: 8px;
|
|
332
332
|
margin-top: 4px;
|
|
333
|
-
`,
|
|
333
|
+
`,la=vn.Text`
|
|
334
334
|
font-size: 13px;
|
|
335
335
|
font-weight: 400;
|
|
336
336
|
font-family: "Roboto-Regular";
|
|
337
337
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
338
338
|
line-height: 20px;
|
|
339
|
-
`,
|
|
339
|
+
`,ua=vn.View`
|
|
340
340
|
gap: 6px;
|
|
341
|
-
`,
|
|
341
|
+
`,ca=vn.View`
|
|
342
342
|
flex-direction: row;
|
|
343
343
|
align-items: center;
|
|
344
344
|
gap: 6px;
|
|
345
|
-
`,
|
|
345
|
+
`,da=vn.Text`
|
|
346
346
|
font-size: 12px;
|
|
347
|
-
`,
|
|
347
|
+
`,ha=vn.Text`
|
|
348
348
|
font-size: 12px;
|
|
349
349
|
font-weight: 500;
|
|
350
350
|
font-family: "Roboto-Medium";
|
|
351
351
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
352
|
-
`,
|
|
352
|
+
`,fa=vn.View`
|
|
353
353
|
flex-direction: row;
|
|
354
354
|
align-items: flex-start;
|
|
355
355
|
gap: 6px;
|
|
356
356
|
padding-left: 4px;
|
|
357
|
-
`,
|
|
357
|
+
`,pa=vn.Text`
|
|
358
358
|
font-size: 14px;
|
|
359
359
|
color: ${e=>{let{color:t}=e;return t}};
|
|
360
360
|
line-height: 18px;
|
|
361
|
-
`,
|
|
361
|
+
`,ma=vn.Text`
|
|
362
362
|
font-size: 12px;
|
|
363
363
|
font-weight: 400;
|
|
364
364
|
font-family: "Roboto-Regular";
|
|
365
365
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
366
366
|
flex: 1;
|
|
367
367
|
line-height: 18px;
|
|
368
|
-
`,
|
|
368
|
+
`,ga=vn.View`
|
|
369
369
|
background-color: ${e=>{let{theme:t}=e;return t["core-02"]||"#F5F5F5"}};
|
|
370
370
|
padding: 10px 12px;
|
|
371
371
|
border-radius: 8px;
|
|
372
|
-
`,
|
|
372
|
+
`,va=vn.Text`
|
|
373
373
|
font-size: 12px;
|
|
374
374
|
font-weight: 400;
|
|
375
375
|
font-family: "Roboto-Regular";
|
|
376
376
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
377
377
|
line-height: 18px;
|
|
378
|
-
`,
|
|
378
|
+
`,ya=vn.View`
|
|
379
379
|
flex-direction: row;
|
|
380
380
|
justify-content: flex-end;
|
|
381
381
|
margin-top: 4px;
|
|
382
|
-
`,
|
|
382
|
+
`,ba=vn.View`
|
|
383
383
|
padding-vertical: 8px;
|
|
384
384
|
padding-horizontal: 16px;
|
|
385
385
|
border-radius: 8px;
|
|
386
386
|
background-color: ${e=>{let{theme:t}=e;return(t["link-static"]||"#3378F6")+"15"}};
|
|
387
|
-
`,
|
|
387
|
+
`,_a=vn.Text`
|
|
388
388
|
font-size: 13px;
|
|
389
389
|
font-weight: 500;
|
|
390
390
|
font-family: "Roboto-Medium";
|
|
391
391
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378F6"}};
|
|
392
|
-
`,
|
|
392
|
+
`,wa=(0,t.memo)(Uo),Sa=e=>{let t="web";if(e)switch(e){case"Linux":t="android";break;case"iPhone":t="ios";break;default:t="web"}else t=String(r.A.OS);return(e=>{switch(e){case li.WEB:return 0;case li.IOS:return 1;case li.ANDROID:default:return 2}})(t).toString()},xa=async()=>{const e=await si(),t="web"===r.A.OS?{system_type_enum:Sa(null),platform_action_enum:"0"}:{};return{user_company_id:e?.company_id?.toString(),user_company_name:e?.company,user_email:e?.email,user_id:e?.id?.toString(),user_name:e?.first_name?`${e?.first_name} ${e?.last_name}`:void 0,user_price_mode:e?.price_mode?.toString(),price_mode:e?.price_mode?.toString(),has_plan_details:!!e?.plan_details,userAgent:"web"===r.A.OS?navigator.userAgent:"",...t}};var Ea=a(7918),Ca=a.n(Ea),ka=a(5685);var Aa=a(5556),Ra=a.n(Aa);const Ta=Ra().oneOfType([Ra().string,Ra().number]),Pa={all:Ra().bool,grid:Ra().bool,aural:Ra().bool,braille:Ra().bool,handheld:Ra().bool,print:Ra().bool,projection:Ra().bool,screen:Ra().bool,tty:Ra().bool,tv:Ra().bool,embossed:Ra().bool},Oa={orientation:Ra().oneOf(["portrait","landscape"]),scan:Ra().oneOf(["progressive","interlace"]),aspectRatio:Ra().string,deviceAspectRatio:Ra().string,height:Ta,deviceHeight:Ta,width:Ta,deviceWidth:Ta,color:Ra().bool,colorIndex:Ra().bool,monochrome:Ra().bool,resolution:Ta,type:Object.keys(Pa)},{type:Ia,...Na}=Oa,La={minAspectRatio:Ra().string,maxAspectRatio:Ra().string,minDeviceAspectRatio:Ra().string,maxDeviceAspectRatio:Ra().string,minHeight:Ta,maxHeight:Ta,minDeviceHeight:Ta,maxDeviceHeight:Ta,minWidth:Ta,maxWidth:Ta,minDeviceWidth:Ta,maxDeviceWidth:Ta,minColor:Ra().number,maxColor:Ra().number,minColorIndex:Ra().number,maxColorIndex:Ra().number,minMonochrome:Ra().number,maxMonochrome:Ra().number,minResolution:Ta,maxResolution:Ta,...Na};var Da={all:{...Pa,...La},types:Pa,matchers:Oa,features:La};const Ma=(0,t.createContext)(void 0),Fa=e=>{if(e)return Object.keys(e).reduce((t,n)=>(t[(0,ka.default)(n)]=e[n],t),{})},Va=()=>{const e=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{e.current=!0},[]),e.current},za=e=>{const n=()=>(e=>e.query||(e=>{const t=[];return Object.keys(Da.all).forEach(n=>{const r=e[n];null!=r&&t.push(((e,t)=>{const n=(0,ka.default)(e);return"number"==typeof t&&(t=`${t}px`),!0===t?n:!1===t?`not ${n}`:`(${n}: ${t})`})(n,r))}),t.join(" and ")})(e))(e),[r,i]=(0,t.useState)(n);return(0,t.useEffect)(()=>{const e=n();r!==e&&i(e)},[e]),r},ja=(e,n,r)=>{const i=(e=>{const n=(0,t.useContext)(Ma),r=()=>Fa(e)||Fa(n),[i,o]=(0,t.useState)(r);return(0,t.useEffect)(()=>{const e=r();(function(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t),i=n.length;if(r.length!==i)return!1;for(let r=0;r<i;r++){const i=n[r];if(e[i]!==t[i]||!Object.prototype.hasOwnProperty.call(t,i))return!1}return!0})(i,e)||o(e)},[e,n]),i})(n),o=za(e);if(!o)throw new Error("Invalid or missing MediaQuery!");const a=((e,n)=>{const r=()=>Ca()(e,n||{},!!n),[i,o]=(0,t.useState)(r),a=Va();return(0,t.useEffect)(()=>{if(a){const e=r();return o(e),()=>{e&&e.dispose()}}},[e,n]),i})(o,i),s=(e=>{const[n,r]=(0,t.useState)(e.matches);return(0,t.useEffect)(()=>{const t=e=>{r(e.matches)};return e.addListener(t),r(e.matches),()=>{e.removeListener(t)}},[e]),n})(a),l=Va();return(0,t.useEffect)(()=>{l&&r&&r(s)},[s]),(0,t.useEffect)(()=>()=>{a&&a.dispose()},[]),s},Ba={transparent:"transparent","main-01":"#292735","main-02":"#37363F","main-03":"#E3E3E9","main-04":"#3378F6","main-05":"#ffffff","main-06":"#292735","diam-01":"#804195","diam-02":"#713782","diam-03":"#EEE1F3","diam-04":"#9138AE","diam-05":"#ffffff","diam-06":"#9138AE","core-01":"#ffffff","core-02":"#EDEDF2","core-03":"#D5D5DC","core-04":"#ACACB3","core-05":"#020001","core-06":"#4F4E57","extra-01":"#A1A0AB","extra-02":"#292735","extra-03":"#E4E4EC","extra-04":"#DADAE0","extra-05":"#ffffff","extra-06":"#4F4E57","gem-01":"#3B72CC","gem-02":"#3C62A0","gem-03":"#DCE6F6","gem-04":"#3E76D2","gem-05":"#ffffff","gem-06":"#3E76D2","jewelry-01":"#58B8A5","jewelry-02":"#4CA191","jewelry-03":"#D6F1ED","jewelry-04":"#27AC92","jewelry-05":"#ffffff","jewelry-06":"#27AC92","lab-01":"#E97F5B","lab-02":"#DA704B","lab-03":"#F9E2D9","lab-04":"#E87B56","lab-05":"#ffffff","lab-06":"#E87B56","over-01":"#000000b3","over-02":"rgba(55,54,64,0.3)","over-03":"rgba(255,255,255,0.7)","over-04":"#ffffff","cont-00":"#ffffff","success-02":"#DBFFE4","success-01":"#00B140","error-02":"#FFE2E0","error-01":"#D0021B","warn-02":"#FFF8DB","warn-01":"#FFA500","primary-bg-static":"#292735","primary-bg-hover":"#37363F","primary-bg-disabled":"#D5D5DC","primary-cont":"#ffffff","primary-cont-disabled":"#ACACB3","secondary-bor-disabled":"#D5D5DC","secondary-cont-disabled":"#ACACB3","secondary-bg-hover":"#E3E3E9","secondary-bor-hover":"#37363F","secondary-bor-static":"#292735","secondary-cont":"#292735","tertiary-bg-static":"#E3E3E9","tertiary-bg-disabled":"#D5D5DC","tertiary-cont":"#292735","tertiary-cont-disabled":"#ACACB3","link-static":"#3378F6","link-hover":"#292735","option-bg-static":"#E4E4EC","option-bg-hover":"#DADAE0","option-bg-active":"#A1A0AB","option-cont":"#4F4E57","option-cont-active":"#ffffff","knob-bg-hover":"#E4E4EC","knob-bg-active":"#292735","knob-cont":"#ffffff","knob-bor":"#292735","toggle-bg-static":"#DADAE0","toggle-bg-on":"#292735","toggle-cont":"#ffffff","option-bg-disabled":"#D5D5DC","option-cont-disabled":"#ACACB3","knob-bg-disabled-off":"#EDEDF2","knob-bg-disabled-on":"#D5D5DC","knob-cont-disabled-on":"#ffffff","toggle-bg-disabled":"#D5D5DC","toggle-cont-disabled":"#EDEDF2","header-cont":"#ffffff","header-btn-cont":"#ffffff","header-bg-static":"#37363F","header-btn-bg-hover":"#37363F","header-btn-bg-active":"#E3E3E9","header-btn-bg-static":"#292735","header-btn-bor-hover":"#292735","header-btn-cont-active":"#292735","knob-bg-static":"#ffffff",Shadows:{Huge:{x:"2",y:"16",blur:"32",type:"dropShadow",color:"#37364066",spread:"-8"},Gentle:{x:"1",y:"2",blur:"4",type:"dropShadow",color:"#37364014",spread:"-2"},Normal:{x:"2",y:"8",blur:"24",type:"dropShadow",color:"#37364042",spread:"-6"},"Bottom-scroll":{x:"0",y:"-8",blur:"24",type:"dropShadow",color:"#37364029",spread:"-8"}}};let Ha=null;if("web"!==r.A.OS)try{Ha=a(Object(function(){var e=new Error("Cannot find module 'expo-device'");throw e.code="MODULE_NOT_FOUND",e}()))}catch{}const $a=e=>{let{children:n}=e;const[i,o]=(0,t.useState)(Ba);if((0,t.useEffect)(()=>{(async()=>{try{const e=JSON.parse(await Pr("persist:root")||"{}"),t=e.theme?JSON.parse(e.theme):null;t&&o(t)}catch{}})()},[]),"web"===r.A.OS&&window.matchMedia("print").matches)return null;const a=ja({maxWidth:767}),s=ja({minWidth:767,maxWidth:1279}),l=ja({minWidth:1279}),{width:u}=ei,c=a||u<=767,d=s||u>767&&u<=1279||"iPadOS"===Ha?.osName||hi(),h=(l||u>1279)&&!("iPadOS"===Ha?.osName||hi()),f=h&&!d&&!c,p={isMobile:c,isTablet:d,isDesktop:h,isLargeScreen:f},m=(0,t.useMemo)(()=>({...i,...p}),[i,c,d,h,f]);return t.createElement(Ut,{theme:m},n)},Wa=e=>{let{username:n,theme:r,productType:i}=e;return t.createElement(Ua,null,t.createElement(Ka,{isBold:!0},"Hi, ",n,"!"),t.createElement(qa,{isBold:!1},"Describe the diamond you're looking for — for example,"," ",t.createElement(Ya,{color:r[yi(i)]},"2ct F VS2 under $10,000")," ","or"," ",t.createElement(Ya,{color:r[yi(i)]},"1–2ct D–F VS pear")," ","— and I'll take it from there."))},Ua=vn.View`
|
|
393
393
|
padding-vertical: 32px;
|
|
394
394
|
padding-horizontal: 16px;
|
|
395
395
|
gap: 8px;
|
|
396
|
-
`,
|
|
396
|
+
`,Ka=vn.Text`
|
|
397
397
|
color: ${e=>{let{theme:t}=e;return t["core-05"]}};
|
|
398
398
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
399
399
|
font-size: 24px;
|
|
400
400
|
font-style: normal;
|
|
401
401
|
font-weight: 500;
|
|
402
402
|
line-height: 32px;
|
|
403
|
-
`,
|
|
403
|
+
`,qa=vn.Text`
|
|
404
404
|
color: ${e=>{let{theme:t}=e;return t["core-06"]}};
|
|
405
405
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
406
406
|
font-size: 17px;
|
|
407
407
|
font-style: normal;
|
|
408
408
|
font-weight: 500;
|
|
409
409
|
line-height: 24px;
|
|
410
|
-
`,
|
|
410
|
+
`,Ya=vn.Text`
|
|
411
411
|
color: ${e=>{let{color:t}=e;return t||"#9138AE"}};
|
|
412
412
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
413
413
|
font-size: 17px;
|
|
414
414
|
font-style: normal;
|
|
415
415
|
font-weight: 500;
|
|
416
416
|
line-height: 24px;
|
|
417
|
-
`,qa=(0,t.forwardRef)((i,o)=>{let{apiUrl:a,userToken:s,priceMode:l,userName:u,modalHeight:c,theme:d,initialMessages:h=[],placeholder:f,onClose:p,onClearChat:m,onViewAllPress:g,onItemPress:v,isBetaMode:y,activeProductType:b,trackAnalyticsEvent:_,fromFilterScreen:w,fromFilterSplitScreen:S,translations:x,locale:E="en",classic_search_filters:C={},showWelcomeScreen:k,setShowWelcomeScreen:A}=i;const{t:R}=Br(),[T,P]=(0,t.useState)(h),[O,I]=(0,t.useState)(""),[N,L]=(0,t.useState)(!1),[D,M]=(0,t.useState)(null),[F,V]=(0,t.useState)(null),[z,j]=(0,t.useState)(""),[B,H]=(0,t.useState)({}),[$,W]=(0,t.useState)(new Set),[U,K]=(0,t.useState)(l||null),[q,Y]=(0,t.useState)(s||""),[G,X]=(0,t.useState)(!1),[J,Q]=(0,t.useState)(!0),[Z,ee]=(0,t.useState)(null),[te,ne]=(0,t.useState)(void 0),[re,ie]=(0,t.useState)(1),[oe,ae]=(0,t.useState)({}),[se,le]=(0,t.useState)(new Set),[ue,ce]=(0,t.useState)(new Set),[de,he]=(0,t.useState)(new Set),[fe,pe]=(0,t.useState)({}),[me,ge]=(0,t.useState)(null),[ve,ye]=(0,t.useState)(new Set),be=(0,t.useRef)(null),_e=(0,t.useRef)(null),we=(0,t.useRef)(!0),Se=(0,t.useRef)(0),xe=(0,t.useRef)(0),Ee=(0,t.useRef)(!1),Ce=(0,t.useRef)(!1),ke=(0,t.useRef)(!1),Ae=(0,t.useMemo)(()=>({...Vi,...d||{}}),[d]),{_identify:Re}=(()=>{const e=(0,t.useContext)(ht);return{trackEvent:async(t,n)=>{const r=await wa(),i=e||window.analytics;i&&await i.track(t,{...r,...n})},_identify:async(t,n)=>{const r=e||window.analytics;r&&await r.identify(t,n)},_track:async(t,n)=>{const i=await wa();if(o=i?.userAgent,o&&/^Mozilla\/5\.0 \([^;]+; CPU [^)]+ like Mac OS X\) AppleWebKit\/600\.1\.4 \(KHTML, like Gecko\) Version\/\d\.0 Mobile\/10B329 Safari\/8536\.25$/.test(o))return void console.warn("Skipping tracking for Segment user agent:",i.userAgent);var o;if(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!e&&"web"===r.A.OS||[/bot/i,/crawl/i,/spider/i,/HeadlessChrome/i,/PhantomJS/i,/slurp/i,/curl/i,/wget/i,/httpclient/i].some(t=>t.test(e))}(i?.userAgent))return void console.warn("Skipping tracking for bot user agent:",i.userAgent);const a=e||window.analytics;if(!a)return;const s=await si();s?.id?await a.identify(`${s.id}`,{name:`${s.first_name} ${s.last_name}`,email:s.email,country:s.country}):(console.error("Track Event tracked without user:",t,JSON.stringify(n)),console.error("Can't identify as user is not logged in",JSON.stringify(s))),await a.track(t,{...i,...n})}}})(),Te=Boolean(y),Pe=Wt(),Oe=Pe.isTablet,{globalData:Ie}=function(){const[e,n]=(0,t.useState)(null),[r,i]=(0,t.useState)(!0),[o,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{(async()=>{try{i(!0);const e=await Pr("persist:root");if(!e)return void n(null);const t=JSON.parse(e),r="string"==typeof t?.globalData?JSON.parse(t.globalData):t?.globalData;n(r||null)}catch(e){a(e instanceof Error?e:new Error("Failed to get global data")),n(null)}finally{i(!1)}})()},[]),{globalData:e,loading:r,error:o,refetch:async()=>{try{i(!0);const e=await Pr("persist:root");if(!e)return void n(null);const t=JSON.parse(e),r="string"==typeof t?.globalData?JSON.parse(t.globalData):t?.globalData;n(r||null),a(null)}catch(e){a(e instanceof Error?e:new Error("Failed to get global data")),n(null)}finally{i(!1)}}}}();(0,t.useEffect)(()=>{jr({locale:E,translations:x})},[]),(0,t.useEffect)(()=>{(async function(){const e=await $i(),t=await Nr("vdbchat_conversations",null);return!(!t||t.token!==e)&&!0===t.chat_has_initialized})().then(ee)},[]),(0,t.useEffect)(()=>{(async(e,t)=>{if(!Dr.isInitialized)return;const n=await Vr(),r=zr(n,t),i=Fr(r);Dr.addResourceBundle(e,"translation",i,!0,!0),Dr.language!==e&&Dr.changeLanguage(e)})(E,x)},[E,x]),(0,t.useEffect)(()=>{(async()=>{try{if(!s){const e=await Nr("persist:userInfo",{}),t=JSON.parse(e?.user||"{}"),n=t?.token||"";n&&Y(n)}}catch(e){console.error("Failed to load auth data from storage",e)}})()},[s]);const Ne=async()=>{b&&await Lr("external_context",b)};(0,t.useEffect)(()=>{0===T.length&&Ne()},[T]),(0,t.useEffect)(()=>{Ne()},[b]);const Le=(0,t.useCallback)(e=>{let t=e?.search_payload;const n=JSON.stringify(t),i=e?.search_payload;if(!i)return;const o="string"==typeof i.lab_grown?"true"===i.lab_grown:"boolean"==typeof i.lab_grown&&i.lab_grown,s=`${a}webapp/${o?"lab-grown-diamonds":"natural-diamonds"}/search?priceMode=${U}&productType=${o?vi.LAB_GROWN_DIAMOND:vi.DIAMOND}&fromNewFilterScreen=false&filterSplitStep=1§ionName=${"pair"===t.pair?"Pairs":"Single Stones"}&breadCrumbLabel=Stone%20Search&enterSecondFlow=false&saved_search=${encodeURIComponent(n)}`;g?g(s,i):"web"===r.A.OS&&window.open(s,"_parent")},[a,U,g]),De=(0,t.useCallback)(e=>{const t=`${a}webapp/${e.type===vi.LAB_GROWN_DIAMOND?"lab-grown-diamonds":"natural-diamonds"}/item-detail/${e.id}?productType=${e.type}&priceMode=${U}&breadCrumbLabel=Stone%20Details`;v?v(t,e):"web"===r.A.OS&&window.open(t,"_parent")},[a,U,v]),Me=(0,t.useMemo)(()=>Boolean(q),[q]),Fe=(0,t.useMemo)(()=>({conversationId:q}),[q]),Ve=(0,t.useCallback)(async(e,t,n)=>{try{let r="0";P(e=>{const t=e.find(e=>e.id===n);return r=t?.reaction||"0",e});const i=r===e?ni.UNSET:e,o=await(async(e,t,n,r)=>{const i=`${Hi(e,n,r)}`,o={reaction:t};return await fetch(i,{method:"POST",headers:await Wi(),body:JSON.stringify(o)})})(a,i,t,n);o.ok?P(e=>e.map(e=>e.id===n?{...e,reaction:i}:e)):console.error("Feedback API failed",o.status)}catch(e){console.error("Feedback API error",e)}},[]);(0,t.useEffect)(()=>{let e=!1;return h.length||(async()=>{if(Me)try{const t=await Gi(a,0,U);if(!e){const e=(await Yi(t,U)).reverse();if(void 0!==t?.has_more&&Q(t.has_more),void 0!==t?.next_cursor&&ne(t.next_cursor),ke.current=!1,Ee.current=!1,0===e.length){const e={id:"",role:"assistant",text:R("chat.welcome.message.text",'Describe the diamond you\'re looking for — for example, "2ct F VS2 under $10,000" or "1–2ct D–F VS pear" — and I\'ll take it from there.'),createdAt:Date.now(),isLoading:!1,suggestions:[],search_payload:{},reaction:"0"};P([e]),Q(!1)}else P(e),ee(!0)}}catch(e){console.error("Failed to fetch initial messages",e)}})(),()=>{e=!0}},[a,Fe,h.length,Me,U]),(0,t.useEffect)(()=>{if(0===T.length)return;const e=T.filter(e=>"assistant"===e.role&&e.recommendation_payload&&Object.keys(e.recommendation_payload).length>0);0!==e.length?e.forEach(e=>{const t=T.findIndex(t=>t.id===e.id);if(t<=0)return;let n;for(let e=t-1;e>=0;e--){const t=T[e];if("assistant"===t.role&&t.search_payload&&Object.keys(t.search_payload).length>0){n=t;break}}if(!n)return;if(fe[n.id])return void(ve.has(e.id)&&ye(t=>{const n=new Set(t);return n.delete(e.id),n}));const r=B[n.id]?.response?.body?.diamonds;if(!r||0===r.length)return void(ve.has(e.id)||(ye(t=>new Set(t).add(e.id)),P(t=>t.map(t=>t.id===e.id?{...t,text:R("recommendation.loading.text","Analyzing your diamonds to find the best match"),isLoading:!0}:t))));ce(e=>new Set(e).add(n.id));const i=e.recommendation_payload,o=[],a=e=>r.find(t=>String(t.id)===String(e));if(i?.best_pick){const e=a(i.best_pick.stock_item_id);e&&o.push({...e,recommendationType:"best_pick",score:i.best_pick.score,recommendation_pitch:i.best_pick.recommendation_pitch,strengths:i.best_pick.strengths,concerns:i.best_pick.concerns})}if(i?.runner_up){const e=a(i.runner_up.stock_item_id);e&&o.push({...e,recommendationType:"runner_up",score:i.runner_up.score,reason:i.runner_up.reason})}i?.also_recommended&&i.also_recommended.forEach(e=>{const t=a(e.stock_item_id);t&&o.push({...t,recommendationType:"also_recommended",score:e.score,reason:e.reason})}),o.length>0&&(pe(e=>({...e,[n.id]:o})),ye(t=>{const n=new Set(t);return n.delete(e.id),n}),P(t=>t.map(t=>t.id===e.id?{...t,text:R("recommendation.result.text","Here are my top recommendations based on your search results:"),isLoading:!1,isRecommendation:!0,sourceMessageId:n.id}:t)))}):ve.size>0&&ye(new Set)},[T,B,R]);const ze=(0,t.useCallback)(async e=>{const t=e.trim();if(!t||N)return;const n=await Nr("external_context"),r={id:`user-${Date.now()}`,role:"user",text:t,createdAt:Date.now(),external_context:n||null},i=`bot-loading-${Date.now()}`,o={id:i,role:"assistant",text:R("chat.thinking.text","Thinking"),createdAt:Date.now(),reaction:"0",isLoading:!0,search_payload:{}};P(e=>[...e,r,o]),M(i),L(!0);try{if(!Me)return void P(e=>e.map(e=>e.id===i?{...e,text:R("chat.authError.text","Chat is unavailable (missing user authentication)."),isLoading:!1}:e));const e=[...T,r],n=we.current?C:{};we.current=!1;const o=await async function(e,t,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const a=await Ui(),s=a?.[i]?.conversation_id??null;if(void 0===i)return null;const l=await Nr("external_context");l&&await Ir("external_context");const u={query:t,external_context:l||null,...Object.keys(o).length>0&&{classic_search_filters:o}};s&&(u.conversation_id=Number.isNaN(Number(s))?s:Number(s));const c=await fetch(ji(e),{method:"POST",headers:await Wi(),body:JSON.stringify(u)});if(!c.ok)throw new Error(`POST ${ji(e)} failed with ${c.status}`);const d=await c.json();if(d&&null!=d.conversation_id&&i){const e={...a};e[i]={conversation_id:d.conversation_id},await Ki(e)}return d}(a,t,Fe,e,U,n),s=(await Yi(o,U)).find(e=>"assistant"===e.role);if(s?.text){if(s?.search_payload&&"object"==typeof s.search_payload&&Object.keys(s.search_payload).length>0){const e=await Xi(a,s.search_payload);_?.(ci.AI_CHAT_WIDGET,{action:di.SEARCH_INITIATED,search_payload:s.search_payload});const t=e&&e.response&&e.response.body&&Array.isArray(e.response.body.diamonds)&&e.response.body.diamonds.length>0;t?w&&t&&Le({search_payload:s.search_payload}):_?.(ci.AI_CHAT_WIDGET,{action:di.NO_RESULTS_FOUND,search_payload:s.search_payload}),H(t=>({...t,[s.id]:e}))}M(null),P(e=>e.map(e=>e.id===i?{...e,id:s.id,text:"",isLoading:!1,suggestions:s.suggestions,search_payload:s.search_payload??{}}:e)),setTimeout(()=>{V(s.id),j(s.text),be.current?.scrollToEnd({animated:!0})},50)}else P(e=>e.map(e=>e.id===i?{...e,isLoading:!1}:e))}catch(e){P(e=>e.map(e=>e.id===i?{...e,text:R("chat.error.text","Sorry, something went wrong. Please try again."),isLoading:!1}:e)),console.error(e)}finally{L(!1),M(null),_e.current?.focus()}},[a,N,T,Fe,Me,U,Le,w,C]),je=(0,t.useCallback)(async()=>{const e=O.trim();e&&(I(""),ze(e),w&&k&&!1===Z&&(qi(!0).then(()=>ee(!0)),A?.(!1)))},[O,ze,w,S,k,Z]),Be=(0,t.useCallback)(e=>{ze(e)},[ze]),He=(0,t.useCallback)(async e=>{const t=e.id;try{W(e=>new Set(e).add(t));const n=e?.search_payload;if(!n||0===Object.keys(n).length)return;const r=await Xi(a,n);H(e=>({...e,[t]:r}))}catch(e){console.error("Reload results failed",e)}finally{W(e=>{const n=new Set(e);return n.delete(t),n})}},[]),$e=(0,t.useCallback)(async(e,t)=>{if(se.has(e))return;const n=(oe[e]||1)+1;if(!(n>6))try{le(t=>new Set(t).add(e));const r=await async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const r=await fetch(Bi(e),{method:"POST",headers:await Wi(),body:JSON.stringify({vdb:{...t,page_size:5,page_number:n}})});if(!r.ok)throw new Error(`POST failed with ${r.status}`);return await r.json()}(a,t,n);r?.response?.body?.diamonds&&(H(t=>{const n=t[e];if(!n)return t;const i=n.response?.body?.diamonds||[],o=r.response.body.diamonds;return{...t,[e]:{...n,response:{...n.response,body:{...n.response.body,diamonds:[...i,...o]}}}}}),ae(t=>({...t,[e]:n})))}catch(e){console.error("Failed to load more results:",e)}finally{le(t=>{const n=new Set(t);return n.delete(e),n})}},[a,se,oe]),We=(0,t.useCallback)(async(e,t)=>{try{const n=await Xi(a,t);n?.response?.body?.diamonds&&(H(t=>({...t,[e]:n})),ae(t=>({...t,[e]:1})))}catch(e){console.error("Failed to show less results:",e)}},[a]),Ue=(0,t.useCallback)(async e=>{const t=B[e]?.response?.body?.diamonds;if(!t||0===t.length)return;const n=await Nr("vdbchat_conversations",null),r=n?.conversations?.[U??""]?.conversation_id;if(!r)return void console.error("No conversation ID found for recommendations");ce(t=>new Set(t).add(e)),he(t=>new Set(t).add(e));const i=`recommendation-loading-${Date.now()}`,o={id:i,role:"assistant",text:R("recommendation.loading.text","Analyzing your diamonds to find the best match"),createdAt:Date.now(),isLoading:!0,reaction:"0"};P(e=>[...e,o]),ge(i);try{const n=t.slice(0,50).map(Ji),o=await async function(e,t,n){const r=await fetch(ji(e),{method:"POST",headers:await Wi(),body:JSON.stringify({conversation_id:t,agent_mode:"recommendation",query:"Recommend from my visible results",visible_items:n.slice(0,50)})});if(!r.ok)throw new Error(`POST ${ji(e)} recommendation failed with ${r.status}`);return await r.json()}(a,r,n),s=o.messages?.find(e=>"assistant"===e.role&&null!=e.recommendation_payload),l=s?.recommendation_payload,u=s?.content||R("recommendation.result.text","Here are my top recommendations based on your search results:"),c=[],d=e=>t.find(t=>String(t.id)===String(e));if(l?.best_pick){const e=d(l.best_pick.stock_item_id);e&&c.push({...e,recommendationType:"best_pick",score:l.best_pick.score,recommendation_pitch:l.best_pick.recommendation_pitch,strengths:l.best_pick.strengths,concerns:l.best_pick.concerns})}if(l?.runner_up){const e=d(l.runner_up.stock_item_id);e&&c.push({...e,recommendationType:"runner_up",score:l.runner_up.score,reason:l.runner_up.reason})}l?.also_recommended&&l.also_recommended.forEach(e=>{const t=d(e.stock_item_id);t&&c.push({...t,recommendationType:"also_recommended",score:e.score,reason:e.reason})}),pe(t=>({...t,[e]:c}));const h=`recommendation-${e}-${Date.now()}`;P(t=>t.map(t=>t.id===i?{...t,id:h,text:c.length>0?u:R("recommendation.noResults.text","I couldn't generate recommendations at this time. Please try again."),isLoading:!1,isRecommendation:!0,sourceMessageId:e}:t)),_?.(ci.AI_CHAT_WIDGET,{action:di.RECOMMENDATION_RECEIVED,recommendation_count:c.length})}catch(e){console.error("Failed to get recommendations:",e),P(e=>e.map(e=>e.id===i?{...e,text:R("recommendation.error.text","I couldn't generate a recommendation right now. Please try again."),isLoading:!1}:e))}finally{he(t=>{const n=new Set(t);return n.delete(e),n}),ge(null)}},[a,B,U,R,_]),Ke=(0,t.useCallback)(async()=>{if(G||!J||!Me)return;Ce.current=!0;const e=xe.current;X(!0);try{const t=await async function(e,t,n,r){const i=await Ui(),o=i?.[t??""]?.conversation_id??null;if(!o)return{messages:[],has_more:!1};const a={conversation_id:Number.isNaN(Number(o))?o:Number(o),fetch_history:!0};void 0!==n&&(a.cursor=n),void 0!==r&&(a.page=r);const s=await fetch(ji(e),{method:"POST",headers:await Wi(),body:JSON.stringify(a)});if(!s.ok)throw new Error(`POST ${ji(e)} failed with ${s.status}`);const l=await s.json();return{messages:l.messages||[],conversation_id:l.conversation_id,has_more:l.has_more??!1,next_cursor:l.next_cursor,total_count:l.total_count}}(a,U,te,re+1),n=(await Yi(t,U)).reverse();n.length>0?(P(e=>{const t=new Set(e.map(e=>e.id)),r=n.filter(e=>!t.has(e.id));return console.log("[...newMessages, ...prev]",[...r,...e]),[...r,...e]}),ie(e=>e+1),requestAnimationFrame(()=>{const t=xe.current-e;t>0&&be.current&&be.current.scrollTo({y:Se.current+t,animated:!1}),Ce.current=!1})):Ce.current=!1,Q(t.has_more??n.length>0),ne(t.next_cursor)}catch(e){console.error("Failed to load older messages",e),Ce.current=!1}finally{X(!1)}},[G,J,Me,a,U,te,re]);(0,t.useEffect)(()=>{const e=()=>{setTimeout(()=>{try{be.current?.scrollToEnd({animated:!0})}catch(e){}},100)},t="ios"===r.A.OS?"keyboardWillShow":"keyboardDidShow",n="ios"===r.A.OS?"keyboardWillHide":"keyboardDidHide",i=pt.A.addListener(t,e),o=pt.A.addListener(n,e);return()=>{i.remove(),o.remove()}},[]),(0,t.useEffect)(()=>(e.A.addListener("clearChat",Ye),e.A.addListener("changePriceMode",e=>qe(e.priceMode)),qe(),(async()=>{const e=await si(),t=e?.id,n=JSON.stringify(e?.email)??void 0;t&&Re(`${t}`,{email:n}).then()})(),()=>{e.A.removeAllListeners("clearChat"),e.A.removeAllListeners("changePriceMode")}),[]);const qe=async e=>{if(!e&&l&&(e=l),!e){let t=await Nr("persist:userInfo",{user:void 0});t=t&&t.user?JSON.parse(t.user):{},e=t?.price_mode}K(void 0===e?null:String(e))},Ye=(0,t.useCallback)(async()=>{try{await qi(!1),ee(!1);const e=await Nr("vdbchat_conversations",null);if(e&&U&&e.conversations?.[U]){const t={...e.conversations};delete t[U],await Lr("vdbchat_conversations",{token:e.token,conversations:t,chat_has_initialized:!1})}P([]),H({}),W(new Set),L(!1),M(null),V(null),j(""),Q(!0),ne(void 0),ie(1),ce(new Set),he(new Set),pe({}),ge(null),ye(new Set),ke.current=!1,Ee.current=!1,Ce.current=!1;const t=await Gi(a,0,U),n=(await Yi(t,U)).reverse();if(0===n.length){const e={id:"",role:"assistant",text:R("chat.welcome.message.text",'Describe the diamond you\'re looking for — for example, "2ct F VS2 under $10,000" or "1–2ct D–F VS pear" — and I\'ll take it from there.'),createdAt:Date.now(),isLoading:!1,suggestions:[],reaction:"0",search_payload:{}};P([e])}else P(n);m?.()}catch(e){console.error("Failed to clear chat",e)}},[a,U]);(0,t.useEffect)(()=>{if(!D||F)return;let e=0;const t=R("chat.thinking.text","Thinking"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>e.id===D&&e.isLoading?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[D,F,R]),(0,t.useEffect)(()=>{if(!me)return;let e=0;const t=R("recommendation.loading.text","Analyzing your diamonds to find the best match"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>e.id===me&&e.isLoading?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[me,R]),(0,t.useEffect)(()=>{if(0===ve.size)return;let e=0;const t=R("recommendation.loading.text","Analyzing your diamonds to find the best match"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>ve.has(e.id)?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[ve,R]),(0,t.useImperativeHandle)(o,()=>({clearChat:Ye}),[Ye]);const Ge=(0,t.useRef)(0);return(0,t.useEffect)(()=>{if(!F||!z)return void(Ge.current=0);Ge.current=0;const e=z.length,t=F,n=z,r=setInterval(()=>{Ge.current+=1;const i=Ge.current,o=n.slice(0,i);P(e=>e.map(e=>e.id===t?{...e,text:o}:e)),i>=e&&(clearInterval(r),V(null),j(""),P(e=>e.map(e=>e.id===t?{...e,isLoading:!1}:e)))},25);return()=>{clearInterval(r)}},[F,z]),t.createElement(Ba,null,t.createElement(Ya,{theme:Pe},t.createElement(mt.A,{style:{flex:1},behavior:"ios"===r.A.OS?"padding":"height",keyboardVerticalOffset:w?150:100},w&&!S&&!1===Z?t.createElement(Ha,{username:u||"",theme:Pe,productType:b}):t.createElement(t.Fragment,null,T?.[0]?.createdAt&&t.createElement(Ga,{theme:Pe},t.createElement(ns,{onPress:Ye},t.createElement(ts,null,R("chatbot.clearChat.text","Clear Chat"))),t.createElement(Xa,{theme:Pe},R("chat.chatStartedAt.text","Chat Started at {{time}}",{time:ti(T[0].createdAt,R)}))),t.createElement(gt.A,{ref:be,keyboardShouldPersistTaps:"handled",onScroll:e=>{const{contentOffset:t,contentSize:n,layoutMeasurement:r}=e.nativeEvent;Se.current=t.y;const i=n.height-(r.height+t.y);Ee.current=i>100,t.y<50&&J&&!G&&!Ce.current&&Ke()},scrollEventThrottle:16,style:c?{height:c,backgroundColor:Pe["core-01"]||"#FFFFFF"}:{backgroundColor:Pe["core-01"]||"#FFFFFF"},contentContainerStyle:{backgroundColor:Pe["core-01"]||Ae?.listContentBackgroundColor||"#FFFFFF",...rs.listContent,justifyContent:0===T.length?"center":"flex-end",minHeight:c||void 0,...Oe?{maxWidth:608,alignSelf:"center",width:"100%"}:{}},onContentSizeChange:(e,t)=>{xe.current=t,Ce.current||G||(ke.current?Ee.current||be.current?.scrollToEnd({animated:!1}):(be.current?.scrollToEnd({animated:!1}),ke.current=!0))}},G&&t.createElement(Za,null,t.createElement(vt.A,{size:"small",color:Pe["core-06"]||"#4F4E57"}),t.createElement(es,{theme:Pe},R("chat.loadingOlder.text","Loading older messages..."))),(()=>{const e=[...T];let r=null;for(let t=e.length-1;t>=0;t--){const n=e[t],i=Boolean(B[n.id]?.response?.body?.diamonds?.length>0);if("assistant"===n.role&&n.search_payload&&Object.keys(n.search_payload).length>0&&i){r=n.id;break}}return e.map((i,o)=>{const s=o===e.length-1,l=i.id===r,u=Boolean(B[i.id]?.response?.body?.diamonds&&B[i.id]?.response?.body?.diamonds.length>0);return t.createElement(n.A,{key:i.id+o,style:{gap:12}},t.createElement(ki,{message:i,userTheme:Ae,priceMode:U,handleFeedbackAction:Ve,onReloadResults:He,reloading:$.has(i.id),hasResults:u,totalResults:B[i.id]?.response?.header?B[i.id].response.header?.total_diamonds_found??0:null,shownResults:B[i.id]?.response?.body?.diamonds.length||0,onSuggestionSelect:Be,isLatest:s,isTyping:F===i.id}),"assistant"===i.role&&i.search_payload&&Object.keys(i.search_payload).length>0&&!B[i.id]&&t.createElement(Mo,{apiUrl:a,priceMode:U,messageId:i.id,payload:i.search_payload,onFetched:(e,t)=>{H(n=>({...n,[e]:t}))}}),"assistant"===i.role&&u&&!w&&t.createElement(Do,{data:(B[i.id]?.response?.body?.diamonds||[]).slice(0,5),totalResults:B[i.id]?.response?.header?.total_diamonds_found||0,onViewAll:Le,onItemPress:De,item:i,showMoreResults:()=>$e(i.id,i.search_payload),showLessResults:()=>We(i.id,i.search_payload),trackAnalyticsEvent:_,currentPage:oe[i.id]||1,isLoadingMore:se.has(i.id)}),"assistant"===i.role&&u&&l&&Ie?.ai_chat_bot?.show_recommendation&&!ue.has(i.id)&&t.createElement(Ho,{onPress:()=>Ue(i.id),loading:de.has(i.id)}),i.isRecommendation&&i.sourceMessageId&&i.sourceMessageId===r&&fe[i.sourceMessageId]&&fe[i.sourceMessageId].length>0&&t.createElement(ba,{recommendations:fe[i.sourceMessageId],onItemPress:De}),t.createElement(Fi,{message:i,priceMode:U||"",handleFeedbackAction:Ve,onReloadResults:He,reloading:$.has(i.id),hasResults:u}))})})()),t.createElement(Qa,null)),t.createElement(Ja,{theme:Pe},t.createElement(Wr,{value:O,onChangeText:I,onSend:je,disabled:N,placeholder:f,theme:Ae,inputRef:_e}),t.createElement(eo,{active:Te})))))});qa.displayName="ChatWidget";const Ya=vn.View`
|
|
417
|
+
`,Ga=(0,t.forwardRef)((i,o)=>{let{apiUrl:a,userToken:s,priceMode:l,userName:u,modalHeight:c,theme:d,initialMessages:h=[],placeholder:f,onClose:p,onClearChat:m,onViewAllPress:g,onItemPress:v,isBetaMode:y,activeProductType:b,trackAnalyticsEvent:_,fromFilterScreen:w,fromFilterSplitScreen:S,translations:x,locale:E="en",classic_search_filters:C={},showWelcomeScreen:k,setShowWelcomeScreen:A}=i;const{t:R}=Br(),[T,P]=(0,t.useState)(h),[O,I]=(0,t.useState)(""),[N,L]=(0,t.useState)(!1),[D,M]=(0,t.useState)(null),[F,V]=(0,t.useState)(null),[z,j]=(0,t.useState)(""),[B,H]=(0,t.useState)({}),[$,W]=(0,t.useState)(new Set),[U,K]=(0,t.useState)(l||null),[q,Y]=(0,t.useState)(s||""),[G,X]=(0,t.useState)(!1),[J,Q]=(0,t.useState)(!0),[Z,ee]=(0,t.useState)(null),[te,ne]=(0,t.useState)(void 0),[re,ie]=(0,t.useState)(1),[oe,ae]=(0,t.useState)({}),[se,le]=(0,t.useState)(new Set),[ue,ce]=(0,t.useState)(new Set),[de,he]=(0,t.useState)(new Set),[fe,pe]=(0,t.useState)({}),[me,ge]=(0,t.useState)(null),[ve,ye]=(0,t.useState)(new Set),be=(0,t.useRef)(null),_e=(0,t.useRef)(null),we=(0,t.useRef)(!0),Se=(0,t.useRef)(0),xe=(0,t.useRef)(0),Ee=(0,t.useRef)(!1),Ce=(0,t.useRef)(!1),ke=(0,t.useRef)(!1),Ae=(0,t.useMemo)(()=>({...Vi,...d||{}}),[d]),{_identify:Re}=(()=>{const e=(0,t.useContext)(ht);return{trackEvent:async(t,n)=>{const r=await xa(),i=e||window.analytics;i&&await i.track(t,{...r,...n})},_identify:async(t,n)=>{const r=e||window.analytics;r&&await r.identify(t,n)},_track:async(t,n)=>{const i=await xa();if(o=i?.userAgent,o&&/^Mozilla\/5\.0 \([^;]+; CPU [^)]+ like Mac OS X\) AppleWebKit\/600\.1\.4 \(KHTML, like Gecko\) Version\/\d\.0 Mobile\/10B329 Safari\/8536\.25$/.test(o))return void console.warn("Skipping tracking for Segment user agent:",i.userAgent);var o;if(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return!e&&"web"===r.A.OS||[/bot/i,/crawl/i,/spider/i,/HeadlessChrome/i,/PhantomJS/i,/slurp/i,/curl/i,/wget/i,/httpclient/i].some(t=>t.test(e))}(i?.userAgent))return void console.warn("Skipping tracking for bot user agent:",i.userAgent);const a=e||window.analytics;if(!a)return;const s=await si();s?.id?await a.identify(`${s.id}`,{name:`${s.first_name} ${s.last_name}`,email:s.email,country:s.country}):(console.error("Track Event tracked without user:",t,JSON.stringify(n)),console.error("Can't identify as user is not logged in",JSON.stringify(s))),await a.track(t,{...i,...n})}}})(),Te=Boolean(y),Pe=Wt(),Oe=Pe.isTablet,{globalData:Ie}=function(){const[e,n]=(0,t.useState)(null),[r,i]=(0,t.useState)(!0),[o,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{(async()=>{try{i(!0);const e=await Pr("persist:root");if(!e)return void n(null);const t=JSON.parse(e),r="string"==typeof t?.globalData?JSON.parse(t.globalData):t?.globalData;n(r||null)}catch(e){a(e instanceof Error?e:new Error("Failed to get global data")),n(null)}finally{i(!1)}})()},[]),{globalData:e,loading:r,error:o,refetch:async()=>{try{i(!0);const e=await Pr("persist:root");if(!e)return void n(null);const t=JSON.parse(e),r="string"==typeof t?.globalData?JSON.parse(t.globalData):t?.globalData;n(r||null),a(null)}catch(e){a(e instanceof Error?e:new Error("Failed to get global data")),n(null)}finally{i(!1)}}}}();(0,t.useEffect)(()=>{jr({locale:E,translations:x})},[]),(0,t.useEffect)(()=>{(async function(){const e=await Ui(),t=await Nr("vdbchat_conversations",null);return!(!t||t.token!==e)&&!0===t.chat_has_initialized})().then(ee)},[]),(0,t.useEffect)(()=>{(async(e,t)=>{if(!Dr.isInitialized)return;const n=await Vr(),r=zr(n,t),i=Fr(r);Dr.addResourceBundle(e,"translation",i,!0,!0),Dr.language!==e&&Dr.changeLanguage(e)})(E,x)},[E,x]),(0,t.useEffect)(()=>((async()=>{try{if(s)Wi(s),Y(s);else{Wi(null);const e=await Nr("persist:userInfo",{}),t=JSON.parse(e?.user||"{}"),n=t?.token||"";n&&Y(n)}}catch(e){console.error("Failed to load auth data from storage",e)}})(),()=>{Wi(null)}),[s]);const Ne=async()=>{b&&await Lr("external_context",b)};(0,t.useEffect)(()=>{0===T.length&&Ne()},[T]),(0,t.useEffect)(()=>{Ne()},[b]);const Le=(0,t.useCallback)(e=>{let t=e?.search_payload;const n=JSON.stringify(t),i=e?.search_payload;if(!i)return;const o="string"==typeof i.lab_grown?"true"===i.lab_grown:"boolean"==typeof i.lab_grown&&i.lab_grown,s=`${a}webapp/${o?"lab-grown-diamonds":"natural-diamonds"}/search?priceMode=${U}&productType=${o?vi.LAB_GROWN_DIAMOND:vi.DIAMOND}&fromNewFilterScreen=false&filterSplitStep=1§ionName=${"pair"===t.pair?"Pairs":"Single Stones"}&breadCrumbLabel=Stone%20Search&enterSecondFlow=false&saved_search=${encodeURIComponent(n)}`;g?g(s,i):"web"===r.A.OS&&window.open(s,"_parent")},[a,U,g]),De=(0,t.useCallback)(e=>{const t=`${a}webapp/${e.type===vi.LAB_GROWN_DIAMOND?"lab-grown-diamonds":"natural-diamonds"}/item-detail/${e.id}?productType=${e.type}&priceMode=${U}&breadCrumbLabel=Stone%20Details`;v?v(t,e):"web"===r.A.OS&&window.open(t,"_parent")},[a,U,v]),Me=(0,t.useMemo)(()=>Boolean(q),[q]),Fe=(0,t.useMemo)(()=>({conversationId:q}),[q]),Ve=(0,t.useCallback)(async(e,t,n)=>{try{let r="0";P(e=>{const t=e.find(e=>e.id===n);return r=t?.reaction||"0",e});const i=r===e?ni.UNSET:e,o=await(async(e,t,n,r)=>{const i=`${Hi(e,n,r)}`,o={reaction:t};return await fetch(i,{method:"POST",headers:await Ki(),body:JSON.stringify(o)})})(a,i,t,n);o.ok?P(e=>e.map(e=>e.id===n?{...e,reaction:i}:e)):console.error("Feedback API failed",o.status)}catch(e){console.error("Feedback API error",e)}},[]);(0,t.useEffect)(()=>{let e=!1;return h.length||(async()=>{if(Me)try{const t=await Ji(a,0,U);if(!e){const e=(await Xi(t,U)).reverse();if(void 0!==t?.has_more&&Q(t.has_more),void 0!==t?.next_cursor&&ne(t.next_cursor),ke.current=!1,Ee.current=!1,0===e.length){const e={id:"",role:"assistant",text:R("chat.welcome.message.text",'Describe the diamond you\'re looking for — for example, "2ct F VS2 under $10,000" or "1–2ct D–F VS pear" — and I\'ll take it from there.'),createdAt:Date.now(),isLoading:!1,suggestions:[],search_payload:{},reaction:"0"};P([e]),Q(!1)}else P(e),ee(!0)}}catch(e){console.error("Failed to fetch initial messages",e)}})(),()=>{e=!0}},[a,Fe,h.length,Me,U]),(0,t.useEffect)(()=>{if(0===T.length)return;const e=T.filter(e=>"assistant"===e.role&&e.recommendation_payload&&Object.keys(e.recommendation_payload).length>0);0!==e.length?e.forEach(e=>{const t=T.findIndex(t=>t.id===e.id);if(t<=0)return;let n;for(let e=t-1;e>=0;e--){const t=T[e];if("assistant"===t.role&&t.search_payload&&Object.keys(t.search_payload).length>0){n=t;break}}if(!n)return;if(fe[n.id])return void(ve.has(e.id)&&ye(t=>{const n=new Set(t);return n.delete(e.id),n}));const r=B[n.id]?.response?.body?.diamonds;if(!r||0===r.length)return void(ve.has(e.id)||(ye(t=>new Set(t).add(e.id)),P(t=>t.map(t=>t.id===e.id?{...t,text:R("recommendation.loading.text","Analyzing your diamonds to find the best match"),isLoading:!0}:t))));ce(e=>new Set(e).add(n.id));const i=e.recommendation_payload,o=[],a=e=>r.find(t=>String(t.id)===String(e));if(i?.best_pick){const e=a(i.best_pick.stock_item_id);e&&o.push({...e,recommendationType:"best_pick",score:i.best_pick.score,recommendation_pitch:i.best_pick.recommendation_pitch,strengths:i.best_pick.strengths,concerns:i.best_pick.concerns})}if(i?.runner_up){const e=a(i.runner_up.stock_item_id);e&&o.push({...e,recommendationType:"runner_up",score:i.runner_up.score,reason:i.runner_up.reason})}i?.also_recommended&&i.also_recommended.forEach(e=>{const t=a(e.stock_item_id);t&&o.push({...t,recommendationType:"also_recommended",score:e.score,reason:e.reason})}),o.length>0&&(pe(e=>({...e,[n.id]:o})),ye(t=>{const n=new Set(t);return n.delete(e.id),n}),P(t=>t.map(t=>t.id===e.id?{...t,text:R("recommendation.result.text","Here are my top recommendations based on your search results:"),isLoading:!1,isRecommendation:!0,sourceMessageId:n.id}:t)))}):ve.size>0&&ye(new Set)},[T,B,R]);const ze=(0,t.useCallback)(async e=>{const t=e.trim();if(!t||N)return;const n=await Nr("external_context"),r={id:`user-${Date.now()}`,role:"user",text:t,createdAt:Date.now(),external_context:n||null},i=`bot-loading-${Date.now()}`,o={id:i,role:"assistant",text:R("chat.thinking.text","Thinking"),createdAt:Date.now(),reaction:"0",isLoading:!0,search_payload:{}};P(e=>[...e,r,o]),M(i),L(!0);try{if(!Me)return void P(e=>e.map(e=>e.id===i?{...e,text:R("chat.authError.text","Chat is unavailable (missing user authentication)."),isLoading:!1}:e));const e=[...T,r],n=we.current?C:{};we.current=!1;const o=await async function(e,t,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const a=await qi(),s=a?.[i]?.conversation_id??null;if(void 0===i)return null;const l=await Nr("external_context");l&&await Ir("external_context");const u={query:t,external_context:l||null,...Object.keys(o).length>0&&{classic_search_filters:o}};s&&(u.conversation_id=Number.isNaN(Number(s))?s:Number(s));const c=await fetch(ji(e),{method:"POST",headers:await Ki(),body:JSON.stringify(u)});if(!c.ok)throw new Error(`POST ${ji(e)} failed with ${c.status}`);const d=await c.json();if(d&&null!=d.conversation_id&&i){const e={...a};e[i]={conversation_id:d.conversation_id},await Yi(e)}return d}(a,t,Fe,e,U,n),s=(await Xi(o,U)).find(e=>"assistant"===e.role);if(s?.text){if(s?.search_payload&&"object"==typeof s.search_payload&&Object.keys(s.search_payload).length>0){const e=await Qi(a,s.search_payload);_?.(ci.AI_CHAT_WIDGET,{action:di.SEARCH_INITIATED,search_payload:s.search_payload});const t=e&&e.response&&e.response.body&&Array.isArray(e.response.body.diamonds)&&e.response.body.diamonds.length>0;t?w&&t&&Le({search_payload:s.search_payload}):_?.(ci.AI_CHAT_WIDGET,{action:di.NO_RESULTS_FOUND,search_payload:s.search_payload}),H(t=>({...t,[s.id]:e}))}M(null),P(e=>e.map(e=>e.id===i?{...e,id:s.id,text:"",isLoading:!1,suggestions:s.suggestions,search_payload:s.search_payload??{}}:e)),setTimeout(()=>{V(s.id),j(s.text),be.current?.scrollToEnd({animated:!0})},50)}else P(e=>e.map(e=>e.id===i?{...e,isLoading:!1}:e))}catch(e){P(e=>e.map(e=>e.id===i?{...e,text:R("chat.error.text","Sorry, something went wrong. Please try again."),isLoading:!1}:e)),console.error(e)}finally{L(!1),M(null),_e.current?.focus()}},[a,N,T,Fe,Me,U,Le,w,C]),je=(0,t.useCallback)(async()=>{const e=O.trim();e&&(I(""),ze(e),w&&!S&&k&&!1===Z&&(Gi(!0).then(()=>ee(!0)),A?.(!1)))},[O,ze,w,S,k,Z]),Be=(0,t.useCallback)(e=>{ze(e)},[ze]),He=(0,t.useCallback)(async e=>{const t=e.id;try{W(e=>new Set(e).add(t));const n=e?.search_payload;if(!n||0===Object.keys(n).length)return;const r=await Qi(a,n);H(e=>({...e,[t]:r}))}catch(e){console.error("Reload results failed",e)}finally{W(e=>{const n=new Set(e);return n.delete(t),n})}},[]),$e=(0,t.useCallback)(async(e,t)=>{if(se.has(e))return;const n=(oe[e]||1)+1;if(!(n>6))try{le(t=>new Set(t).add(e));const r=await async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const r=await fetch(Bi(e),{method:"POST",headers:await Ki(),body:JSON.stringify({vdb:{...t,page_size:5,page_number:n}})});if(!r.ok)throw new Error(`POST failed with ${r.status}`);return await r.json()}(a,t,n);r?.response?.body?.diamonds&&(H(t=>{const n=t[e];if(!n)return t;const i=n.response?.body?.diamonds||[],o=r.response.body.diamonds;return{...t,[e]:{...n,response:{...n.response,body:{...n.response.body,diamonds:[...i,...o]}}}}}),ae(t=>({...t,[e]:n})))}catch(e){console.error("Failed to load more results:",e)}finally{le(t=>{const n=new Set(t);return n.delete(e),n})}},[a,se,oe]),We=(0,t.useCallback)(async(e,t)=>{try{const n=await Qi(a,t);n?.response?.body?.diamonds&&(H(t=>({...t,[e]:n})),ae(t=>({...t,[e]:1})))}catch(e){console.error("Failed to show less results:",e)}},[a]),Ue=(0,t.useCallback)(async e=>{const t=B[e]?.response?.body?.diamonds;if(!t||0===t.length)return;const n=await Nr("vdbchat_conversations",null),r=n?.conversations?.[U??""]?.conversation_id;if(!r)return void console.error("No conversation ID found for recommendations");ce(t=>new Set(t).add(e)),he(t=>new Set(t).add(e));const i=`recommendation-loading-${Date.now()}`,o={id:i,role:"assistant",text:R("recommendation.loading.text","Analyzing your diamonds to find the best match"),createdAt:Date.now(),isLoading:!0,reaction:"0"};P(e=>[...e,o]),ge(i);try{const n=t.slice(0,50).map(Zi),o=await async function(e,t,n){const r=await fetch(ji(e),{method:"POST",headers:await Ki(),body:JSON.stringify({conversation_id:t,agent_mode:"recommendation",query:"Recommend from my visible results",visible_items:n.slice(0,50)})});if(!r.ok)throw new Error(`POST ${ji(e)} recommendation failed with ${r.status}`);return await r.json()}(a,r,n),s=o.messages?.find(e=>"assistant"===e.role&&null!=e.recommendation_payload),l=s?.recommendation_payload,u=s?.content||R("recommendation.result.text","Here are my top recommendations based on your search results:"),c=[],d=e=>t.find(t=>String(t.id)===String(e));if(l?.best_pick){const e=d(l.best_pick.stock_item_id);e&&c.push({...e,recommendationType:"best_pick",score:l.best_pick.score,recommendation_pitch:l.best_pick.recommendation_pitch,strengths:l.best_pick.strengths,concerns:l.best_pick.concerns})}if(l?.runner_up){const e=d(l.runner_up.stock_item_id);e&&c.push({...e,recommendationType:"runner_up",score:l.runner_up.score,reason:l.runner_up.reason})}l?.also_recommended&&l.also_recommended.forEach(e=>{const t=d(e.stock_item_id);t&&c.push({...t,recommendationType:"also_recommended",score:e.score,reason:e.reason})}),pe(t=>({...t,[e]:c}));const h=`recommendation-${e}-${Date.now()}`;P(t=>t.map(t=>t.id===i?{...t,id:h,text:c.length>0?u:R("recommendation.noResults.text","I couldn't generate recommendations at this time. Please try again."),isLoading:!1,isRecommendation:!0,sourceMessageId:e}:t)),_?.(ci.AI_CHAT_WIDGET,{action:di.RECOMMENDATION_RECEIVED,recommendation_count:c.length})}catch(e){console.error("Failed to get recommendations:",e),P(e=>e.map(e=>e.id===i?{...e,text:R("recommendation.error.text","I couldn't generate a recommendation right now. Please try again."),isLoading:!1}:e))}finally{he(t=>{const n=new Set(t);return n.delete(e),n}),ge(null)}},[a,B,U,R,_]),Ke=(0,t.useCallback)(async()=>{if(G||!J||!Me)return;Ce.current=!0;const e=xe.current;X(!0);try{const t=await async function(e,t,n,r){const i=await qi(),o=i?.[t??""]?.conversation_id??null;if(!o)return{messages:[],has_more:!1};const a={conversation_id:Number.isNaN(Number(o))?o:Number(o),fetch_history:!0};void 0!==n&&(a.cursor=n),void 0!==r&&(a.page=r);const s=await fetch(ji(e),{method:"POST",headers:await Ki(),body:JSON.stringify(a)});if(!s.ok)throw new Error(`POST ${ji(e)} failed with ${s.status}`);const l=await s.json();return{messages:l.messages||[],conversation_id:l.conversation_id,has_more:l.has_more??!1,next_cursor:l.next_cursor,total_count:l.total_count}}(a,U,te,re+1),n=(await Xi(t,U)).reverse();n.length>0?(P(e=>{const t=new Set(e.map(e=>e.id)),r=n.filter(e=>!t.has(e.id));return console.log("[...newMessages, ...prev]",[...r,...e]),[...r,...e]}),ie(e=>e+1),requestAnimationFrame(()=>{const t=xe.current-e;t>0&&be.current&&be.current.scrollTo({y:Se.current+t,animated:!1}),Ce.current=!1})):Ce.current=!1,Q(t.has_more??n.length>0),ne(t.next_cursor)}catch(e){console.error("Failed to load older messages",e),Ce.current=!1}finally{X(!1)}},[G,J,Me,a,U,te,re]);(0,t.useEffect)(()=>{const e=()=>{setTimeout(()=>{try{be.current?.scrollToEnd({animated:!0})}catch(e){}},100)},t="ios"===r.A.OS?"keyboardWillShow":"keyboardDidShow",n="ios"===r.A.OS?"keyboardWillHide":"keyboardDidHide",i=pt.A.addListener(t,e),o=pt.A.addListener(n,e);return()=>{i.remove(),o.remove()}},[]),(0,t.useEffect)(()=>(e.A.addListener("clearChat",Ye),e.A.addListener("changePriceMode",e=>qe(e.priceMode)),qe(),(async()=>{const e=await si(),t=e?.id,n=JSON.stringify(e?.email)??void 0;t&&Re(`${t}`,{email:n}).then()})(),()=>{e.A.removeAllListeners("clearChat"),e.A.removeAllListeners("changePriceMode")}),[]);const qe=async e=>{if(!e&&l&&(e=l),!e){let t=await Nr("persist:userInfo",{user:void 0});t=t&&t.user?JSON.parse(t.user):{},e=t?.price_mode}K(void 0===e?null:String(e))},Ye=(0,t.useCallback)(async()=>{try{await Gi(!1),ee(!1);const e=await Nr("vdbchat_conversations",null);if(e&&U&&e.conversations?.[U]){const t={...e.conversations};delete t[U],await Lr("vdbchat_conversations",{token:e.token,conversations:t,chat_has_initialized:!1})}P([]),H({}),W(new Set),L(!1),M(null),V(null),j(""),Q(!0),ne(void 0),ie(1),ce(new Set),he(new Set),pe({}),ge(null),ye(new Set),ke.current=!1,Ee.current=!1,Ce.current=!1;const t=await Ji(a,0,U),n=(await Xi(t,U)).reverse();if(0===n.length){const e={id:"",role:"assistant",text:R("chat.welcome.message.text",'Describe the diamond you\'re looking for — for example, "2ct F VS2 under $10,000" or "1–2ct D–F VS pear" — and I\'ll take it from there.'),createdAt:Date.now(),isLoading:!1,suggestions:[],reaction:"0",search_payload:{}};P([e])}else P(n);m?.()}catch(e){console.error("Failed to clear chat",e)}},[a,U]);(0,t.useEffect)(()=>{if(!D||F)return;let e=0;const t=R("chat.thinking.text","Thinking"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>e.id===D&&e.isLoading?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[D,F,R]),(0,t.useEffect)(()=>{if(!me)return;let e=0;const t=R("recommendation.loading.text","Analyzing your diamonds to find the best match"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>e.id===me&&e.isLoading?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[me,R]),(0,t.useEffect)(()=>{if(0===ve.size)return;let e=0;const t=R("recommendation.loading.text","Analyzing your diamonds to find the best match"),n=setInterval(()=>{e=(e+1)%3;const n=".".repeat(e+1);P(e=>e.map(e=>ve.has(e.id)?{...e,text:`${t}${n}`}:e))},500);return()=>{clearInterval(n)}},[ve,R]),(0,t.useImperativeHandle)(o,()=>({clearChat:Ye}),[Ye]);const Ge=(0,t.useRef)(0);return(0,t.useEffect)(()=>{if(!F||!z)return void(Ge.current=0);Ge.current=0;const e=z.length,t=F,n=z,r=setInterval(()=>{Ge.current+=1;const i=Ge.current,o=n.slice(0,i);P(e=>e.map(e=>e.id===t?{...e,text:o}:e)),i>=e&&(clearInterval(r),V(null),j(""),P(e=>e.map(e=>e.id===t?{...e,isLoading:!1}:e)))},25);return()=>{clearInterval(r)}},[F,z]),t.createElement($a,null,t.createElement(Xa,{theme:Pe},t.createElement(mt.A,{style:{flex:1},behavior:"ios"===r.A.OS?"padding":"height",keyboardVerticalOffset:w?150:100},w&&!S&&!1===Z?t.createElement(Wa,{username:u||"",theme:Pe,productType:b}):t.createElement(t.Fragment,null,T?.[0]?.createdAt&&t.createElement(Ja,{theme:Pe},t.createElement(is,{onPress:Ye},t.createElement(rs,null,R("chatbot.clearChat.text","Clear Chat"))),t.createElement(Qa,{theme:Pe},R("chat.chatStartedAt.text","Chat Started at {{time}}",{time:ti(T[0].createdAt,R)}))),t.createElement(gt.A,{ref:be,keyboardShouldPersistTaps:"handled",onScroll:e=>{const{contentOffset:t,contentSize:n,layoutMeasurement:r}=e.nativeEvent;Se.current=t.y;const i=n.height-(r.height+t.y);Ee.current=i>100,t.y<50&&J&&!G&&!Ce.current&&Ke()},scrollEventThrottle:16,style:c?{height:c,backgroundColor:Pe["core-01"]||"#FFFFFF"}:{backgroundColor:Pe["core-01"]||"#FFFFFF"},contentContainerStyle:{backgroundColor:Pe["core-01"]||Ae?.listContentBackgroundColor||"#FFFFFF",...os.listContent,justifyContent:0===T.length?"center":"flex-end",minHeight:c||void 0,...Oe?{maxWidth:608,alignSelf:"center",width:"100%"}:{}},onContentSizeChange:(e,t)=>{xe.current=t,Ce.current||G||(ke.current?Ee.current||be.current?.scrollToEnd({animated:!1}):(be.current?.scrollToEnd({animated:!1}),ke.current=!0))}},G&&t.createElement(ts,null,t.createElement(vt.A,{size:"small",color:Pe["core-06"]||"#4F4E57"}),t.createElement(ns,{theme:Pe},R("chat.loadingOlder.text","Loading older messages..."))),(()=>{const e=[...T];let r=null;for(let t=e.length-1;t>=0;t--){const n=e[t],i=Boolean(B[n.id]?.response?.body?.diamonds?.length>0);if("assistant"===n.role&&n.search_payload&&Object.keys(n.search_payload).length>0&&i){r=n.id;break}}return e.map((i,o)=>{const s=o===e.length-1,l=i.id===r,u=Boolean(B[i.id]?.response?.body?.diamonds&&B[i.id]?.response?.body?.diamonds.length>0);return t.createElement(n.A,{key:i.id+o,style:{gap:12}},t.createElement(ki,{message:i,userTheme:Ae,priceMode:U,handleFeedbackAction:Ve,onReloadResults:He,reloading:$.has(i.id),hasResults:u,totalResults:B[i.id]?.response?.header?B[i.id].response.header?.total_diamonds_found??0:null,shownResults:B[i.id]?.response?.body?.diamonds.length||0,onSuggestionSelect:Be,isLatest:s,isTyping:F===i.id}),"assistant"===i.role&&i.search_payload&&Object.keys(i.search_payload).length>0&&!B[i.id]&&t.createElement(Vo,{apiUrl:a,priceMode:U,messageId:i.id,payload:i.search_payload,onFetched:(e,t)=>{H(n=>({...n,[e]:t}))}}),"assistant"===i.role&&u&&!w&&t.createElement(Fo,{data:(B[i.id]?.response?.body?.diamonds||[]).slice(0,5),totalResults:B[i.id]?.response?.header?.total_diamonds_found||0,onViewAll:Le,onItemPress:De,item:i,showMoreResults:()=>$e(i.id,i.search_payload),showLessResults:()=>We(i.id,i.search_payload),trackAnalyticsEvent:_,currentPage:oe[i.id]||1,isLoadingMore:se.has(i.id)}),"assistant"===i.role&&u&&l&&Ie?.ai_chat_bot?.show_recommendation&&!ue.has(i.id)&&t.createElement(Wo,{onPress:()=>Ue(i.id),loading:de.has(i.id)}),i.isRecommendation&&i.sourceMessageId&&i.sourceMessageId===r&&fe[i.sourceMessageId]&&fe[i.sourceMessageId].length>0&&t.createElement(wa,{recommendations:fe[i.sourceMessageId],onItemPress:De}),t.createElement(Fi,{message:i,priceMode:U||"",handleFeedbackAction:Ve,onReloadResults:He,reloading:$.has(i.id),hasResults:u}))})})()),t.createElement(es,null)),t.createElement(Za,{theme:Pe},t.createElement(Wr,{value:O,onChangeText:I,onSend:je,disabled:N,placeholder:f,theme:Ae,inputRef:_e}),t.createElement(no,{active:Te})))))});Ga.displayName="ChatWidget";const Xa=vn.View`
|
|
418
418
|
background-color: ${e=>{let{theme:t}=e;return t["core-01"]||"#FFFFFF"}};
|
|
419
419
|
flex: 1;
|
|
420
420
|
width: 100%;
|
|
421
|
-
`,
|
|
421
|
+
`,Ja=vn.View`
|
|
422
422
|
padding: 8px;
|
|
423
423
|
flex-direction: row;
|
|
424
424
|
justify-content: space-between;
|
|
425
425
|
align-items: center;
|
|
426
426
|
background-color: ${e=>{let{theme:t}=e;return t["core-01"]||"#FFFFFF"}};
|
|
427
|
-
`,
|
|
427
|
+
`,Qa=vn.Text`
|
|
428
428
|
font-size: 13px;
|
|
429
429
|
font-weight: 400;
|
|
430
430
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
431
|
-
`,
|
|
431
|
+
`,Za=vn.View`
|
|
432
432
|
padding-vertical: 12px;
|
|
433
433
|
padding-horizontal: 16px;
|
|
434
434
|
flex-direction: column;
|
|
@@ -441,22 +441,22 @@
|
|
|
441
441
|
align-self: center;
|
|
442
442
|
width: 100%;
|
|
443
443
|
`}};
|
|
444
|
-
`,
|
|
444
|
+
`,es=vn.View`
|
|
445
445
|
border-top-color: ${e=>{let{theme:t}=e;return t["core-03"]||"#E0E0E0"}};
|
|
446
446
|
border-top-width: 1;
|
|
447
|
-
`,
|
|
447
|
+
`,ts=vn.View`
|
|
448
448
|
padding: 12px;
|
|
449
449
|
align-items: center;
|
|
450
450
|
justify-content: center;
|
|
451
451
|
flex-direction: row;
|
|
452
452
|
gap: 8px;
|
|
453
|
-
`,
|
|
453
|
+
`,ns=vn.Text`
|
|
454
454
|
font-size: 12px;
|
|
455
455
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
456
|
-
`,
|
|
456
|
+
`,rs=vn.Text`
|
|
457
457
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378f6"}};
|
|
458
458
|
text-align: right;
|
|
459
459
|
font-size: 13px;
|
|
460
460
|
font-weight: 500;
|
|
461
461
|
line-height: 136%;
|
|
462
|
-
`,
|
|
462
|
+
`,is=vn.TouchableOpacity``,os=i.A.create({listContent:{paddingVertical:8,flexGrow:1,justifyContent:"flex-end"},loading:{paddingVertical:8,alignItems:"center"}}),as=i.A.create({root:{flex:1,height:"100%",width:"100%"}});window.createChatWidget=function(e){const{id:i="chat-widget",apiUrl:a,theme:s,height:l="500px",width:u="360px",button:c={label:"",icon:"",iconColor:"transparent",labelColor:"transparent",backgroundColor:"transparent",borderRadius:"9999px",padding:"0",buttonPosition:{bottom:"60px",right:"44px"}},segmentWriteKey:d,isBetaMode:h,locale:f,translations:p}=e;(f||p)&&jr({locale:f,translations:p});const m=`${i}-modal`,g=`${i}-launcher`;let v=document.getElementById(g);v||(v=document.createElement("button"),v.id=g,v.type="button",v.innerText=c.label||"",v.innerHTML=c.icon||"<svg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 72 72' fill='none'> <g filter='url(#filter0_d_10_66)'> <g clip-path='url(#clip0_10_66)'> <foreignObject x='-33.12' y='-33.12' width='138.24' height='138.24'><div xmlns='http://www.w3.org/1999/xhtml' style='backdrop-filter:blur(1px);clip-path:url(#bgblur_1_10_66_clip_path);height:100%;width:100%'></div></foreignObject><g filter='url(#filter1_g_10_66)' data-figma-bg-blur-radius='2'> <rect width='72' height='72' fill='white' fill-opacity='0.05'/> </g> <g filter='url(#filter2_iii_10_66)'> <rect width='72' height='72' rx='36' fill='url(#paint0_linear_10_66)' fill-opacity='0.7'/> <rect x='0.5' y='0.5' width='71' height='71' rx='35.5' stroke='white' stroke-opacity='0.2'/> </g> <path d='M36 20C36 20 36.8828 28.2399 40.3215 31.6785C43.7601 35.1172 52 36 52 36C52 36 43.7601 36.8828 40.3215 40.3215C36.8828 43.7601 36 52 36 52C36 52 35.1172 43.7601 31.6785 40.3215C28.2399 36.8828 20 36 20 36C20 36 28.2399 35.1172 31.6785 31.6785C35.1172 28.2399 36 20 36 20Z' fill='white'/> </g> </g> <defs> <filter id='filter0_d_10_66' x='0' y='0' width='112' height='112' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'> <feFlood flood-opacity='0' result='BackgroundImageFix'/> <feColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/> <feOffset dx='20' dy='20'/> <feGaussianBlur stdDeviation='10'/> <feComposite in2='hardAlpha' operator='out'/> <feColorMatrix type='matrix' values='0 0 0 0 0.862354 0 0 0 0 0.862354 0 0 0 0 0.89855 0 0 0 0.2 0'/> <feBlend mode='normal' in2='BackgroundImageFix' result='effect1_dropShadow_10_66'/> <feBlend mode='normal' in='SourceGraphic' in2='effect1_dropShadow_10_66' result='shape'/> </filter> <filter id='filter1_g_10_66' x='-33.12' y='-33.12' width='138.24' height='138.24' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'> <feFlood flood-opacity='0' result='BackgroundImageFix'/> <feBlend mode='normal' in='SourceGraphic' in2='BackgroundImageFix' result='shape'/> <feTurbulence type='fractalNoise' baseFrequency='0.012303149327635765 0.012303149327635765' numOctaves='3' seed='8425'/> <feDisplacementMap in='shape' scale='66.239997863769531' xChannelSelector='R' yChannelSelector='G' result='displacedImage' width='100%' height='100%'/> <feMerge result='effect1_texture_10_66'> <feMergeNode in='displacedImage'/> </feMerge> </filter> <clipPath id='bgblur_1_10_66_clip_path' transform='translate(33.12 33.12)'><rect width='72' height='72'/> </clipPath><filter id='filter2_iii_10_66' x='-1' y='-2' width='74' height='76' filterUnits='userSpaceOnUse' color-interpolation-filters='sRGB'> <feFlood flood-opacity='0' result='BackgroundImageFix'/> <feBlend mode='normal' in='SourceGraphic' in2='BackgroundImageFix' result='shape'/> <feColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/> <feOffset/> <feGaussianBlur stdDeviation='7'/> <feComposite in2='hardAlpha' operator='arithmetic' k2='-1' k3='1'/> <feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.3 0'/> <feBlend mode='normal' in2='shape' result='effect1_innerShadow_10_66'/> <feColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/> <feOffset dx='-1' dy='-3'/> <feGaussianBlur stdDeviation='1'/> <feComposite in2='hardAlpha' operator='arithmetic' k2='-1' k3='1'/> <feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.1 0'/> <feBlend mode='normal' in2='effect1_innerShadow_10_66' result='effect2_innerShadow_10_66'/> <feColorMatrix in='SourceAlpha' type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' result='hardAlpha'/> <feOffset dx='1' dy='3'/> <feGaussianBlur stdDeviation='1'/> <feComposite in2='hardAlpha' operator='arithmetic' k2='-1' k3='1'/> <feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.3 0'/> <feBlend mode='normal' in2='effect2_innerShadow_10_66' result='effect3_innerShadow_10_66'/> </filter> <linearGradient id='paint0_linear_10_66' x1='4.5' y1='16' x2='67.5' y2='52.5' gradientUnits='userSpaceOnUse'> <stop stop-color='#C000FF'/> <stop offset='1' stop-color='#2BFFCA'/> </linearGradient> <clipPath id='clip0_10_66'> <rect width='72' height='72' rx='36' fill='white'/> </clipPath> </defs> </svg>",v.style.color=c.iconColor||"#ffffff",v.style.position="fixed",v.style.zIndex="2147483000",v.style.borderRadius="100px",v.style.padding="0",v.style.width="56px",v.style.height="56px",v.style.backgroundColor=c.backgroundColor||"transparent",v.style.color=c.labelColor||"transparent",v.style.border="none",v.style.cursor="pointer",v.style.boxShadow="0 4px 12px rgba(0,0,0,0.2)",v.style.fontFamily="system-ui, -apple-system, BlinkMacSystemFont, sans-serif",v.style.fontSize="14px",v.style.bottom=c.buttonPosition?.bottom||"24px",c.buttonPosition?.top&&(v.style.top=c.buttonPosition.top),v.style.right=c.buttonPosition?.right||"20px",c.buttonPosition?.left&&(v.style.left=c.buttonPosition.left),document.body.appendChild(v));let y=document.getElementById(m);y||(y=document.createElement("div"),y.id=m,y.style.position="fixed",y.style.zIndex="2147483000",y.style.bottom=c.modalPosition?.bottom||"30px",c.modalPosition?.top&&(y.style.top=c.modalPosition.top),y.style.right=c.modalPosition?.right||"30px",c.modalPosition?.left&&(y.style.left=c.modalPosition.left),y.style.width=u,y.style.height=l,y.style.maxWidth="30%",y.style.maxHeight="80%",y.style.backgroundColor="#ffffff",y.style.borderRadius="12px",y.style.overflow="hidden",y.style.boxShadow="0 16px 40px rgba(0,0,0,0.25)",y.style.display="none",y.style.opacity="0",y.style.transform="translateY(16px) scale(0.98)",y.style.transition="transform 220ms ease-out, opacity 220ms ease-out",document.body.appendChild(y)),function(e,i,a,s,l,u,c,d,h){const f=(0,o.H)(e),p=(e,t)=>{const n={source:"vdb-ai-chat",type:e,payload:t},r=JSON.stringify(n),i=window.ReactNativeWebView;if(i?.postMessage)i.postMessage(r);else{try{window.parent?.postMessage(n,"*")}catch{}try{window.dispatchEvent(new CustomEvent("vdb-ai-event",{detail:n}))}catch{}}},m=t.createElement(n.A,{style:as.root},t.createElement(Ga,{apiUrl:ji(i),theme:a,onClose:s,onClearChat:()=>{},onViewAllPress:(e,t)=>{p("ai_view_all",{url:e,payload:t}),s?.()},onItemPress:(e,t)=>{p("ai_item_click",{url:e,item:t}),s?.()},isBetaMode:h,classic_search_filters:void 0}));if(f.render(m),"web"===r.A.OS&&u)try{const e="undefined"!=typeof navigator&&(navigator.userAgent.includes("Edg")||navigator.userAgent.includes("Edge"));dt.load({writeKey:u,trackAppLifecycleEvents:!1,flushAt:e?1:10,flushInterval:1e4,maxBatchSize:e?1:10}).then(async e=>{let[n]=e;n?.debug?.(!0),window.analytics=n,n.page?.();try{const e=await si(),t=e?.id;t&&n.identify(t)}catch{}const r=t.createElement(ft,{client:n},m);f.render(r)}).catch(e=>{console.error("[Segment] init failed",e)})}catch(e){console.error("[Segment] init failed",e)}}(y,a,s,()=>_(!1),0,d,0,0,h);let b=!1;const _=e=>{b=e,e?(y.style.display="block",requestAnimationFrame(()=>{y.style.opacity="1",y.style.transform="translateY(0px) scale(1)";const e=document.getElementById("chat-input");e&&e.focus()})):(y.style.opacity="0",y.style.transform="translateY(16px) scale(0.98)",setTimeout(()=>{b||(y.style.display="none")},230))};v.onclick=()=>{try{const e=window.analytics;e&&(b?e.track(ui.WIDGET_CLOSED,{userAgent:"undefined"!=typeof navigator?navigator.userAgent:""}).then?.():e.track(ui.WIDGET_OPENED,{userAgent:"undefined"!=typeof navigator?navigator.userAgent:""}).then?.())}catch(e){}_(!b)}},window.clearChat=function(){e.A.emit("clearChat")},window.changePriceMode=function(t){e.A.emit("changePriceMode",{priceMode:t})},window.setTranslations=async e=>{try{const t=await Pr("persist:root"),n=t?JSON.parse(t):{};let r="string"==typeof n?.globalData?JSON.parse(n.globalData):n?.globalData||{};if(r.ai_chat_bot={...r.ai_chat_bot,translations:e},n.globalData=JSON.stringify(r),await Or("persist:root",JSON.stringify(n)),Dr.isInitialized){const t=Fr(e);Dr.addResourceBundle(Dr.language,"translation",t,!0,!0)}}catch{}},window.getTranslations=async()=>{const e=await Vr();return e&&Object.keys(e).length>0?e:Er},window.changeLanguage=async e=>{const t=await Vr(),n=zr(t,void 0),r=Fr(n);Dr.addResourceBundle(e,"translation",r,!0,!0),await Dr.changeLanguage(e)},window.initI18n=jr})()})();
|