vdb-ai-chat 1.0.78 → 1.0.79
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 +79 -72
- package/lib/commonjs/components/ChatWidget.js +3 -1
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/MessageBubble.js +22 -2
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/module/components/ChatWidget.js +3 -1
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/MessageBubble.js +22 -2
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble.d.ts +2 -0
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/ChatWidget.tsx +7 -0
- package/src/components/MessageBubble.tsx +27 -1
package/dist/chat-widget.js
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
font-size: 13px;
|
|
64
64
|
font-style: normal;
|
|
65
65
|
font-weight: 500;
|
|
66
|
-
`,Ei=e=>{let{backgroundColor:n,productName:r,productColor:i,height:o=24}=e;const a=Wt();return t.createElement(Si,{backgroundColor:n,height:o},t.createElement(xi,{color:a[i],selectable:!0},r??""))},Ci=e=>{let{message:n,userTheme:r,hasResults:i,totalResults:o,shownResults:a,onSuggestionSelect:s,isLatest:l,isTyping:u}=e;const{t:
|
|
66
|
+
`,Ei=e=>{let{backgroundColor:n,productName:r,productColor:i,height:o=24}=e;const a=Wt();return t.createElement(Si,{backgroundColor:n,height:o},t.createElement(xi,{color:a[i],selectable:!0},r??""))},Ci=e=>{let{message:n,userTheme:r,hasResults:i,totalResults:o,shownResults:a,onSuggestionSelect:s,isLatest:l,isTyping:u,showShowResultsButton:c,onViewAll:d}=e;const{t:h}=Br(),f="user"===n.role,p=Wt(),m="string"==typeof n?.search_payload?.lab_grown?"true"===n?.search_payload?.lab_grown:"boolean"==typeof n?.search_payload?.lab_grown&&n?.search_payload?.lab_grown,g=m?vi.LAB_GROWN_DIAMOND:vi.DIAMOND,v=(m?h("product.labGrownDiamond.text","Lab-Grown Diamond"):h("product.naturalDiamond.text","Natural Diamond"))+("pair"===n?.search_payload?.pair?` ${h("product.pair.text","Pair")}`:"")+(Number(o)>1?h("product.pluralSuffix.text","s"):""),y=e=>t.createElement(Oi,null,e.map((e,n)=>{return"text"===e.type?t.createElement(t.Fragment,{key:n},(r=e.content,i=!!e.bold,o=`p${n}`,r.trim().split(/\s+/).filter(Boolean).map((e,n,r)=>t.createElement(Ti,{key:`${o}-${n}`,isUser:f,isBold:i,theme:p},n<r.length-1?`${e} `:e)))):t.createElement(t.Fragment,{key:n},e.node);var r,i,o}));return t.createElement(Ai,{theme:p,userTheme:r,isUser:f},t.createElement(Ri,{theme:p,userTheme:r,isUser:f},"assistant"===n.role&&i&&"number"==typeof o?t.createElement(t.Fragment,null,y([{type:"text",content:h("results.found.text","Found")},{type:"node",node:t.createElement(Ti,{isUser:f,isBold:!0,theme:p},` ${Number(o).toLocaleString()} `)},{type:"node",node:t.createElement(t.Fragment,null,t.createElement(Ti,{isUser:f,isBold:!1,theme:p}," "),t.createElement(Ei,{productName:v,productColor:yi(g),backgroundColor:bi(g)}),t.createElement(Ti,{isUser:f,isBold:!1,theme:p}," "))},{type:"text",content:h("results.matchPreferences.text","that match your preferences:")}]),t.createElement(Ti,{isUser:f,isBold:!0,theme:p},`${pi(n.search_payload,!0,h)?.title}`),c&&t.createElement(Ii,{onPress:()=>{d?.(n)}},t.createElement(Ni,{theme:p},h("chat.showResults.button","Show Results")))):"assistant"===n.role&&n?.search_payload&&Object.keys(n.search_payload).length>0&&!i&&"number"==typeof o?t.createElement(t.Fragment,null,y([{type:"text",content:h("results.found.text","Found")},{type:"node",node:t.createElement(Ti,{isUser:f,isBold:!0,theme:p}," 0 ")},{type:"node",node:t.createElement(t.Fragment,null,t.createElement(Ti,{isUser:f,isBold:!1,theme:p}," "),t.createElement(Ei,{productName:v,productColor:yi(g),backgroundColor:bi(g)}),t.createElement(Ti,{isUser:f,isBold:!1,theme:p}," "))},{type:"text",content:h("results.matchPreferences.text","that match your preferences:")}]),t.createElement(Ti,{isUser:f,isBold:!0,theme:p},`${pi(n.search_payload,!0,h)?.title}`),t.createElement(Oi,null,t.createElement(Ti,{isUser:f,isBold:!1,theme:p},h("results.noResultsSuggestion.text","Try modifying your search criteria to explore more options.")))):"assistant"===n.role&&i?null:t.createElement(Ti,{isUser:f,theme:p},n.text||""),"assistant"===n.role&&Array.isArray(n.suggestions)&&n.suggestions.length>0&&l&&!u&&!(n.search_payload&&"object"==typeof n.search_payload&&Object.keys(n.search_payload).length>0)&&t.createElement(Pi,{theme:p},t.createElement(Zr,{suggestions:n.suggestions,onSelect:e=>s?.(e),variant:"inline"}))))},ki=(0,t.memo)(Ci),Ai=vn.View`
|
|
67
67
|
padding-horizontal: 8px;
|
|
68
68
|
margin-vertical: 0;
|
|
69
69
|
width: 100%;
|
|
@@ -93,7 +93,14 @@
|
|
|
93
93
|
flex-direction: row;
|
|
94
94
|
align-items: center;
|
|
95
95
|
flex-wrap: wrap;
|
|
96
|
-
|
|
96
|
+
`,Ii=vn.TouchableOpacity`
|
|
97
|
+
margin-top: 4px;
|
|
98
|
+
`,Ni=vn.Text`
|
|
99
|
+
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378f6"}};
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
font-weight: 500;
|
|
102
|
+
font-family: Roboto-Medium;
|
|
103
|
+
`;let Li=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&&(Li=e)}catch{}const Di=vn.Pressable`
|
|
97
104
|
border-width: 1;
|
|
98
105
|
border-radius: 8px;
|
|
99
106
|
padding-horizontal: 4px;
|
|
@@ -107,10 +114,10 @@
|
|
|
107
114
|
`:Vt`
|
|
108
115
|
border-color: ${e=>{let{theme:t}=e;return t["core-03"]||"#D5D5DC"}};
|
|
109
116
|
`}}
|
|
110
|
-
`,
|
|
117
|
+
`,Mi=vn.Text`
|
|
111
118
|
font-size: 12px;
|
|
112
119
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#666"}};
|
|
113
|
-
`,
|
|
120
|
+
`,Fi=vn.View`
|
|
114
121
|
flex-direction: row;
|
|
115
122
|
justify-content: space-between;
|
|
116
123
|
align-items: center;
|
|
@@ -123,7 +130,7 @@
|
|
|
123
130
|
align-self: flex-start;
|
|
124
131
|
width: 100%;
|
|
125
132
|
`}};
|
|
126
|
-
`,
|
|
133
|
+
`,Vi=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"}}),zi=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(Fi,{isUser:s},t.createElement(n.A,{style:Vi.timeContainer},t.createElement(Mi,{theme:a},ti(r.createdAt,c))),h?t.createElement(n.A,{style:Vi.likeDislikeContainer},t.createElement(Di,{type:"like",style:e=>[e?.hovered&&Vi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.LIKE,String(l),r.id),disabled:!h},t.createElement(Li,{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(Di,{type:"dislike",style:e=>[e?.hovered&&Vi.borderButtonHover],reaction:r.reaction,onPress:()=>o(ni.DISLIKE,String(l),r.id),disabled:!h},t.createElement(Li,{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)},ji={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},Bi="v3",Hi=e=>`${e}${Bi}/agent_conversations`,$i=e=>`${e}${Bi}/vdb/search_diamonds`,Wi=(e,t,n)=>`${e}${Bi}/agent_conversations/${t}/conversation_messages/${n}/reaction`;async function Ui(){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="";try{const e=JSON.parse(t);n=e?.installationIdentifier?JSON.parse(e.installationIdentifier):""}catch{n=""}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(Hi(e),{method:"POST",headers:await Ki(),body:Object.keys(o).length?JSON.stringify(o):void 0});if(!a.ok)throw new Error(`POST ${Hi(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($i(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
134
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
128
135
|
font-family: "Roboto";
|
|
129
136
|
font-size: 13px;
|
|
@@ -131,7 +138,7 @@
|
|
|
131
138
|
font-weight: 400;
|
|
132
139
|
line-height: 18px;
|
|
133
140
|
text-align: center;
|
|
134
|
-
`,
|
|
141
|
+
`,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
142
|
justify-content: center;
|
|
136
143
|
align-items: center;
|
|
137
144
|
width: ${e=>{let{width:t}=e;return t||"100%"}};
|
|
@@ -141,105 +148,105 @@
|
|
|
141
148
|
border-radius: ${e=>{let{borderRadius:t}=e;return t>0?t:8}}px;
|
|
142
149
|
border-width: ${e=>{let{type:t}=e;return t===gi.secondary?2:0}}px;
|
|
143
150
|
border-color: ${e=>{let{borderColor:t,theme:n}=e;return n[t]}};
|
|
144
|
-
`,
|
|
151
|
+
`,ho=(vn.Text`
|
|
145
152
|
color: ${e=>{let{color:t}=e;return t||"#FFFFFF"}};
|
|
146
153
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto-Regular"}};
|
|
147
154
|
font-weight: ${e=>{let{isBold:t}=e;return t?"500":"400"}};
|
|
148
155
|
font-size: 14px;
|
|
149
156
|
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(
|
|
157
|
+
`,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
158
|
padding-horizontal: 8px;
|
|
152
|
-
`,
|
|
159
|
+
`,go=vn.View`
|
|
153
160
|
margin-top: 8px;
|
|
154
161
|
align-items: flex-start;
|
|
155
162
|
justify-content: center;
|
|
156
|
-
`,
|
|
163
|
+
`,vo=vn.Text`
|
|
157
164
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378F6"}};
|
|
158
165
|
font-size: 14px;
|
|
159
166
|
font-weight: 500;
|
|
160
167
|
font-family: "Roboto-Medium";
|
|
161
|
-
`,
|
|
168
|
+
`,yo=vn.Text`
|
|
162
169
|
font-size: 13px;
|
|
163
170
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
164
171
|
font-weight: 400;
|
|
165
172
|
font-family: "Roboto-Regular";
|
|
166
173
|
font-style: normal;
|
|
167
|
-
`,
|
|
174
|
+
`,bo=vn.Text`
|
|
168
175
|
font-size: 13px;
|
|
169
176
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
170
177
|
font-weight: 500;
|
|
171
178
|
font-family: "Roboto-Medium";
|
|
172
179
|
font-style: normal;
|
|
173
|
-
`,
|
|
180
|
+
`,_o=vn.Text`
|
|
174
181
|
color: ${e=>{let{theme:t}=e;return t["primary-cont"]||"#ffffff"}};
|
|
175
182
|
font-size: 14px;
|
|
176
183
|
font-weight: 500;
|
|
177
184
|
font-family: "Roboto-Medium";
|
|
178
|
-
`,
|
|
185
|
+
`,wo=vn.View`
|
|
179
186
|
padding-vertical: 12px;
|
|
180
187
|
border-bottom-width: 1px;
|
|
181
188
|
border-bottom-color: ${e=>{let{theme:t}=e;return t["core-03"]||"#D5D5DC"}};
|
|
182
189
|
background-color: ${e=>{let{theme:t,hovered:n}=e;return n?t["secondary-bg-hover"]||"#EDEDF2":"transparent"}};
|
|
183
|
-
`,
|
|
190
|
+
`,So=vn.View`
|
|
184
191
|
flex-direction: row;
|
|
185
192
|
justify-content: space-between;
|
|
186
193
|
align-items: center;
|
|
187
194
|
width: 100%;
|
|
188
|
-
`,
|
|
195
|
+
`,xo=vn.View`
|
|
189
196
|
flex-direction: row;
|
|
190
197
|
justify-content: space-between;
|
|
191
198
|
align-items: center;
|
|
192
199
|
gap: 8px;
|
|
193
|
-
`,
|
|
200
|
+
`,Eo=vn.View`
|
|
194
201
|
flex-direction: row;
|
|
195
202
|
justify-content: space-between;
|
|
196
203
|
align-items: center;
|
|
197
204
|
gap: 4px;
|
|
198
|
-
`,
|
|
205
|
+
`,Co=vn.View`
|
|
199
206
|
flex-direction: row;
|
|
200
207
|
justify-content: space-between;
|
|
201
208
|
align-items: center;
|
|
202
209
|
width: 100%;
|
|
203
|
-
`,
|
|
210
|
+
`,ko=vn.View`
|
|
204
211
|
flex-direction: row;
|
|
205
212
|
justify-content: space-between;
|
|
206
213
|
align-items: center;
|
|
207
214
|
gap: 8px;
|
|
208
|
-
`,
|
|
215
|
+
`,Ao=vn.View`
|
|
209
216
|
flex-direction: row;
|
|
210
217
|
justify-content: space-between;
|
|
211
218
|
align-items: center;
|
|
212
219
|
gap: 4px;
|
|
213
|
-
`,
|
|
220
|
+
`,Ro=vn.View`
|
|
214
221
|
flex-direction: row;
|
|
215
222
|
align-items: center;
|
|
216
|
-
`,
|
|
223
|
+
`,To=vn.View`
|
|
217
224
|
flex-direction: row;
|
|
218
225
|
justify-content: space-between;
|
|
219
226
|
align-items: center;
|
|
220
227
|
gap: 4px;
|
|
221
|
-
`,
|
|
228
|
+
`,Po=vn.View`
|
|
222
229
|
flex-direction: row;
|
|
223
230
|
align-items: center;
|
|
224
231
|
width: 65px;
|
|
225
232
|
justify-content: flex-end;
|
|
226
|
-
`,
|
|
233
|
+
`,Oo=vn.View`
|
|
227
234
|
flex-direction: row;
|
|
228
235
|
align-items: center;
|
|
229
236
|
gap: 2px;
|
|
230
|
-
`,
|
|
237
|
+
`,Io=vn.View`
|
|
231
238
|
flex-direction: row;
|
|
232
239
|
align-items: center;
|
|
233
240
|
gap: 2px;
|
|
234
|
-
`,
|
|
241
|
+
`,No=vn.View`
|
|
235
242
|
flex-direction: row;
|
|
236
243
|
align-items: center;
|
|
237
244
|
gap: 2px;
|
|
238
|
-
`,
|
|
245
|
+
`,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
246
|
border-radius: 8px;
|
|
240
247
|
overflow: hidden;
|
|
241
248
|
padding-horizontal: 8px;
|
|
242
|
-
`,
|
|
249
|
+
`,Bo=vn.View`
|
|
243
250
|
flex-direction: row;
|
|
244
251
|
align-items: center;
|
|
245
252
|
justify-content: center;
|
|
@@ -251,184 +258,184 @@
|
|
|
251
258
|
border-color: ${e=>{let{theme:t}=e;return t["diam-01"]||"#3378F6"}};
|
|
252
259
|
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
260
|
opacity: ${e=>{let{disabled:t}=e;return t?.6:1}};
|
|
254
|
-
`,
|
|
261
|
+
`,Ho=vn.Text`
|
|
255
262
|
font-size: 14px;
|
|
256
263
|
font-weight: 500;
|
|
257
264
|
font-family: "Roboto-Medium";
|
|
258
265
|
color: ${e=>{let{theme:t}=e;return t["diam-01"]||"#3378F6"}};
|
|
259
|
-
|
|
266
|
+
`,$o=vn.Text`
|
|
260
267
|
font-size: 16px;
|
|
261
|
-
`,
|
|
268
|
+
`,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
269
|
padding-horizontal: 8px;
|
|
263
270
|
gap: 12px;
|
|
264
|
-
`,
|
|
271
|
+
`,qo=vn.View`
|
|
265
272
|
border-radius: 12px;
|
|
266
273
|
border-width: ${e=>{let{isBestPick:t}=e;return t?"2px":"1px"}};
|
|
267
274
|
border-color: ${e=>{let{theme:t,isBestPick:n}=e;return n?"#22C55E":t["core-03"]||"#D5D5DC"}};
|
|
268
275
|
background-color: ${e=>{let{theme:t,hovered:n}=e;return n?t["secondary-bg-hover"]||"#EDEDF2":t["core-01"]||"#FFFFFF"}};
|
|
269
276
|
overflow: hidden;
|
|
270
|
-
`,
|
|
277
|
+
`,Yo=vn.View`
|
|
271
278
|
flex-direction: row;
|
|
272
279
|
justify-content: space-between;
|
|
273
280
|
align-items: flex-start;
|
|
274
|
-
`,
|
|
281
|
+
`,Go=vn.View`
|
|
275
282
|
padding-vertical: 6px;
|
|
276
283
|
padding-horizontal: 12px;
|
|
277
284
|
background-color: ${e=>{let{backgroundColor:t}=e;return t}};
|
|
278
285
|
border-bottom-right-radius: 12px;
|
|
279
|
-
`,
|
|
286
|
+
`,Xo=vn.Text`
|
|
280
287
|
font-size: 11px;
|
|
281
288
|
font-weight: 600;
|
|
282
289
|
font-family: "Roboto-Medium";
|
|
283
290
|
color: #ffffff;
|
|
284
291
|
text-transform: uppercase;
|
|
285
292
|
letter-spacing: 0.5px;
|
|
286
|
-
`,
|
|
293
|
+
`,Jo=vn.View`
|
|
287
294
|
flex-direction: row;
|
|
288
295
|
align-items: baseline;
|
|
289
296
|
padding: 8px 12px;
|
|
290
297
|
gap: 4px;
|
|
291
|
-
`,
|
|
298
|
+
`,Qo=vn.Text`
|
|
292
299
|
font-size: 18px;
|
|
293
300
|
font-weight: 700;
|
|
294
301
|
font-family: "Roboto-Bold";
|
|
295
302
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
296
|
-
`,
|
|
303
|
+
`,Zo=vn.Text`
|
|
297
304
|
font-size: 11px;
|
|
298
305
|
font-weight: 400;
|
|
299
306
|
font-family: "Roboto-Regular";
|
|
300
307
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
301
|
-
`,
|
|
308
|
+
`,ea=vn.View`
|
|
302
309
|
padding: 12px 16px 16px;
|
|
303
310
|
gap: 10px;
|
|
304
|
-
`,
|
|
311
|
+
`,ta=vn.View`
|
|
305
312
|
flex-direction: row;
|
|
306
313
|
justify-content: space-between;
|
|
307
314
|
align-items: center;
|
|
308
|
-
`,
|
|
315
|
+
`,na=vn.View`
|
|
309
316
|
flex-direction: row;
|
|
310
317
|
gap: 6px;
|
|
311
318
|
flex-wrap: wrap;
|
|
312
319
|
flex: 1;
|
|
313
|
-
`,
|
|
320
|
+
`,ra=vn.View`
|
|
314
321
|
flex-direction: row;
|
|
315
322
|
gap: 12px;
|
|
316
|
-
`,
|
|
323
|
+
`,ia=vn.Text`
|
|
317
324
|
font-size: 13px;
|
|
318
325
|
font-weight: ${e=>{let{bold:t}=e;return t?"500":"400"}};
|
|
319
326
|
font-family: ${e=>{let{bold:t}=e;return t?"Roboto-Medium":"Roboto-Regular"}};
|
|
320
327
|
color: ${e=>{let{theme:t,bold:n}=e;return n?t["core-05"]||"#020001":t["core-06"]||"#4F4E57"}};
|
|
321
|
-
`,
|
|
328
|
+
`,oa=vn.View`
|
|
322
329
|
align-items: flex-end;
|
|
323
|
-
`,
|
|
330
|
+
`,aa=vn.Text`
|
|
324
331
|
font-size: 16px;
|
|
325
332
|
font-weight: 600;
|
|
326
333
|
font-family: "Roboto-Medium";
|
|
327
334
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
328
|
-
`,
|
|
335
|
+
`,sa=vn.View`
|
|
329
336
|
background-color: ${e=>{let{theme:t}=e;return t["core-02"]||"#F5F5F5"}};
|
|
330
337
|
padding: 12px;
|
|
331
338
|
border-radius: 8px;
|
|
332
339
|
margin-top: 4px;
|
|
333
|
-
`,
|
|
340
|
+
`,la=vn.Text`
|
|
334
341
|
font-size: 13px;
|
|
335
342
|
font-weight: 400;
|
|
336
343
|
font-family: "Roboto-Regular";
|
|
337
344
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
338
345
|
line-height: 20px;
|
|
339
|
-
`,
|
|
346
|
+
`,ua=vn.View`
|
|
340
347
|
gap: 6px;
|
|
341
|
-
`,
|
|
348
|
+
`,ca=vn.View`
|
|
342
349
|
flex-direction: row;
|
|
343
350
|
align-items: center;
|
|
344
351
|
gap: 6px;
|
|
345
|
-
`,
|
|
352
|
+
`,da=vn.Text`
|
|
346
353
|
font-size: 12px;
|
|
347
|
-
`,
|
|
354
|
+
`,ha=vn.Text`
|
|
348
355
|
font-size: 12px;
|
|
349
356
|
font-weight: 500;
|
|
350
357
|
font-family: "Roboto-Medium";
|
|
351
358
|
color: ${e=>{let{theme:t}=e;return t["core-05"]||"#020001"}};
|
|
352
|
-
`,
|
|
359
|
+
`,fa=vn.View`
|
|
353
360
|
flex-direction: row;
|
|
354
361
|
align-items: flex-start;
|
|
355
362
|
gap: 6px;
|
|
356
363
|
padding-left: 4px;
|
|
357
|
-
`,
|
|
364
|
+
`,pa=vn.Text`
|
|
358
365
|
font-size: 14px;
|
|
359
366
|
color: ${e=>{let{color:t}=e;return t}};
|
|
360
367
|
line-height: 18px;
|
|
361
|
-
`,
|
|
368
|
+
`,ma=vn.Text`
|
|
362
369
|
font-size: 12px;
|
|
363
370
|
font-weight: 400;
|
|
364
371
|
font-family: "Roboto-Regular";
|
|
365
372
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
366
373
|
flex: 1;
|
|
367
374
|
line-height: 18px;
|
|
368
|
-
`,
|
|
375
|
+
`,ga=vn.View`
|
|
369
376
|
background-color: ${e=>{let{theme:t}=e;return t["core-02"]||"#F5F5F5"}};
|
|
370
377
|
padding: 10px 12px;
|
|
371
378
|
border-radius: 8px;
|
|
372
|
-
`,
|
|
379
|
+
`,va=vn.Text`
|
|
373
380
|
font-size: 12px;
|
|
374
381
|
font-weight: 400;
|
|
375
382
|
font-family: "Roboto-Regular";
|
|
376
383
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
377
384
|
line-height: 18px;
|
|
378
|
-
`,
|
|
385
|
+
`,ya=vn.View`
|
|
379
386
|
flex-direction: row;
|
|
380
387
|
justify-content: flex-end;
|
|
381
388
|
margin-top: 4px;
|
|
382
|
-
`,
|
|
389
|
+
`,ba=vn.View`
|
|
383
390
|
padding-vertical: 8px;
|
|
384
391
|
padding-horizontal: 16px;
|
|
385
392
|
border-radius: 8px;
|
|
386
393
|
background-color: ${e=>{let{theme:t}=e;return(t["link-static"]||"#3378F6")+"15"}};
|
|
387
|
-
`,
|
|
394
|
+
`,_a=vn.Text`
|
|
388
395
|
font-size: 13px;
|
|
389
396
|
font-weight: 500;
|
|
390
397
|
font-family: "Roboto-Medium";
|
|
391
398
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378F6"}};
|
|
392
|
-
`,
|
|
399
|
+
`,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
400
|
padding-vertical: 32px;
|
|
394
401
|
padding-horizontal: 16px;
|
|
395
402
|
gap: 8px;
|
|
396
|
-
`,
|
|
403
|
+
`,Ka=vn.Text`
|
|
397
404
|
color: ${e=>{let{theme:t}=e;return t["core-05"]}};
|
|
398
405
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
399
406
|
font-size: 24px;
|
|
400
407
|
font-style: normal;
|
|
401
408
|
font-weight: 500;
|
|
402
409
|
line-height: 32px;
|
|
403
|
-
`,
|
|
410
|
+
`,qa=vn.Text`
|
|
404
411
|
color: ${e=>{let{theme:t}=e;return t["core-06"]}};
|
|
405
412
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
406
413
|
font-size: 17px;
|
|
407
414
|
font-style: normal;
|
|
408
415
|
font-weight: 500;
|
|
409
416
|
line-height: 24px;
|
|
410
|
-
`,
|
|
417
|
+
`,Ya=vn.Text`
|
|
411
418
|
color: ${e=>{let{color:t}=e;return t||"#9138AE"}};
|
|
412
419
|
font-family: ${e=>{let{isBold:t}=e;return t?"Roboto-Medium":"Roboto"}};
|
|
413
420
|
font-size: 17px;
|
|
414
421
|
font-style: normal;
|
|
415
422
|
font-weight: 500;
|
|
416
423
|
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}),C&&_?.(ci.AI_CHAT_WIDGET,{action:di.CLASSIC_SEARCH_FILTERS,classic_search_filters:C});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*(oe[i.id]||1)),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`
|
|
424
|
+
`,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)(()=>({...ji,...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){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=`${Wi(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(Hi(e),{method:"POST",headers:await Ki(),body:JSON.stringify(u)});if(!c.ok)throw new Error(`POST ${Hi(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}),C&&_?.(ci.AI_CHAT_WIDGET,{action:di.CLASSIC_SEARCH_FILTERS,classic_search_filters:C});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&&(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($i(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(Hi(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 ${Hi(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(Hi(e),{method:"POST",headers:await Ki(),body:JSON.stringify(a)});if(!s.ok)throw new Error(`POST ${Hi(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,showShowResultsButton:w&&"assistant"===i.role&&i.search_payload&&Object.keys(i.search_payload).length>0,onViewAll:Le}),"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*(oe[i.id]||1)),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(zi,{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
425
|
background-color: ${e=>{let{theme:t}=e;return t["core-01"]||"#FFFFFF"}};
|
|
419
426
|
flex: 1;
|
|
420
427
|
width: 100%;
|
|
421
|
-
`,
|
|
428
|
+
`,Ja=vn.View`
|
|
422
429
|
padding: 8px;
|
|
423
430
|
flex-direction: row;
|
|
424
431
|
justify-content: space-between;
|
|
425
432
|
align-items: center;
|
|
426
433
|
background-color: ${e=>{let{theme:t}=e;return t["core-01"]||"#FFFFFF"}};
|
|
427
|
-
`,
|
|
434
|
+
`,Qa=vn.Text`
|
|
428
435
|
font-size: 13px;
|
|
429
436
|
font-weight: 400;
|
|
430
437
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
431
|
-
`,
|
|
438
|
+
`,Za=vn.View`
|
|
432
439
|
padding-vertical: 12px;
|
|
433
440
|
padding-horizontal: 16px;
|
|
434
441
|
flex-direction: column;
|
|
@@ -441,22 +448,22 @@
|
|
|
441
448
|
align-self: center;
|
|
442
449
|
width: 100%;
|
|
443
450
|
`}};
|
|
444
|
-
`,
|
|
451
|
+
`,es=vn.View`
|
|
445
452
|
border-top-color: ${e=>{let{theme:t}=e;return t["core-03"]||"#E0E0E0"}};
|
|
446
453
|
border-top-width: 1;
|
|
447
|
-
`,
|
|
454
|
+
`,ts=vn.View`
|
|
448
455
|
padding: 12px;
|
|
449
456
|
align-items: center;
|
|
450
457
|
justify-content: center;
|
|
451
458
|
flex-direction: row;
|
|
452
459
|
gap: 8px;
|
|
453
|
-
`,
|
|
460
|
+
`,ns=vn.Text`
|
|
454
461
|
font-size: 12px;
|
|
455
462
|
color: ${e=>{let{theme:t}=e;return t["core-06"]||"#4F4E57"}};
|
|
456
|
-
`,
|
|
463
|
+
`,rs=vn.Text`
|
|
457
464
|
color: ${e=>{let{theme:t}=e;return t["link-static"]||"#3378f6"}};
|
|
458
465
|
text-align: right;
|
|
459
466
|
font-size: 13px;
|
|
460
467
|
font-weight: 500;
|
|
461
468
|
line-height: 136%;
|
|
462
|
-
`,
|
|
469
|
+
`,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:Hi(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})()})();
|