cosmic-ai-genius 0.3.69 → 0.3.70

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.
@@ -512,7 +512,7 @@ Please choose files smaller than 6MB.`)}Ge.length>0&&ne(ft=>[...ft,...Ge]),pe.cu
512
512
 
513
513
  `).filter(gt=>gt.trim()).forEach(gt=>Kt(gt)),Ei&&wn&&Le(ot,wn,En,Ei,void 0).catch(rt=>{console.error("Failed to save message to IndexedDB:",rt)});break}Cn++;const It=Lt.decode(On,{stream:!0});Un+=It;const $t=Un.split(`
514
514
 
515
- `),St=$t.slice(0,-1);Un=$t[$t.length-1],St.forEach(rt=>Kt(rt))}}catch(ze){if(ze instanceof Error&&ze.name==="AbortError")return;if(!j.some(ft=>ft.role==="assistant")){let ft="Unable to connect to Genius Analytics. Please check your network connection and try again.";ze instanceof Error&&ze.message.includes("Authentication token not found")?ft="Session expired or not authenticated. Please log in to continue using Genius Analytics.":ze instanceof Error&&ze.message.includes("status 401")?ft="Invalid authentication credentials. Please log in with valid credentials.":ze instanceof Error&&ze.message.includes("status 403")?ft="Access denied. You don't have permission to access this data.":ze instanceof Error&&ze.message.includes("status 404")?ft="Analytics service not found. Please contact support if this issue persists.":ze instanceof Error&&ze.message.includes("status 500")?ft="Server error occurred. Our team has been notified. Please try again later.":ze instanceof Error&&ze.message.includes("Failed to fetch")&&(ft="Network error. Please check your internet connection and ensure the analytics service is accessible.");const Ct={id:(Date.now()+1).toString(),content:ft,role:"assistant",timestamp:new Date};O(Pt=>[...Pt,Ct])}}finally{B(!1),U(!1),P(null)}}},pn=async()=>{var ft;if(!b.trim()||w||z)return;const Re=b.trim();T(Re);const ot=new Date,Ge=Date.now(),ze=[];if(ee.length>0&&ee.forEach((Ct,Pt)=>{ze.push({id:`${Ge}-file-${Pt}`,content:"",role:"user",timestamp:ot,attachments:[Ct]})}),Re&&Re.trim()){const Ct={id:`${Ge}-text`,content:Re,role:"user",timestamp:ot};ze.push(Ct)}O(Ct=>[...Ct,...ze]),S(""),zt(),B(!0),U(!0),me.current=!1,setTimeout(()=>Ie(!0),100),i&&ze.forEach(Ct=>i(Ct));const mt=new AbortController;P(mt);try{if(se){try{await j4(Re,mt,O,U,Re,K,q,Le,m,J,t)}catch(It){if(It instanceof Error&&It.name==="AbortError")return;console.error("RCA Investigation error:",It);let $t="Unable to perform RCA investigation. Please try again.";It instanceof Error&&(It.message.includes("Authentication token not found")?$t="Session expired. Please log in to continue using RCA mode.":It.message.includes("status 401")?$t="Invalid authentication credentials for RCA investigation.":It.message.includes("status 403")?$t="Access denied. You don't have permission to perform RCA investigations.":It.message.includes("status 404")?$t="RCA investigation service not found. Please contact support.":It.message.includes("status 500")&&($t="Server error occurred during RCA investigation. Please try again later."));const St={id:(Date.now()+1).toString(),content:$t,role:"assistant",timestamp:new Date};O(rt=>[...rt,St])}B(!1),U(!1),P(null);return}const Ct=vw();if(!Ct)throw new Error("Authentication token not found");const Pt={"Content-Type":"application/json",Authorization:Ct},kt=new Date,qt=kt.getFullYear()+"-"+String(kt.getMonth()+1).padStart(2,"0")+"-"+String(kt.getDate()).padStart(2,"0")+"T"+String(kt.getHours()).padStart(2,"0")+":"+String(kt.getMinutes()).padStart(2,"0")+":"+String(kt.getSeconds()).padStart(2,"0")+"Z",Lt=await fetch(y,{method:"POST",headers:{...Pt,Accept:"text/event-stream"},body:JSON.stringify({query:Re,current_timestamp:qt,session_id:K,...g&&{moduleName:g},...ee.length>0&&{attachments:ee.map(It=>({data:It.base64,mime_type:It.type}))}}),signal:mt.signal});if(!Lt.ok)throw new Error(`API request failed with status ${Lt.status}`);const Yt=(ft=Lt.body)==null?void 0:ft.getReader();if(!Yt)throw new Error("Failed to get response reader");const wn=new TextDecoder;let Cn=null,Un="",_a=0,En="",Ei=null;const Kt={};let Wt=K;const On=It=>{var gt;if(!It.trim())return;const $t=It.split(`
515
+ `),St=$t.slice(0,-1);Un=$t[$t.length-1],St.forEach(rt=>Kt(rt))}}catch(ze){if(ze instanceof Error&&ze.name==="AbortError")return;if(!j.some(ft=>ft.role==="assistant")){let ft="Unable to connect to Genius Analytics. Please check your network connection and try again.";ze instanceof Error&&ze.message.includes("Authentication token not found")?ft="Session expired or not authenticated. Please log in to continue using Genius Analytics.":ze instanceof Error&&ze.message.includes("status 401")?ft="Invalid authentication credentials. Please log in with valid credentials.":ze instanceof Error&&ze.message.includes("status 403")?ft="Access denied. You don't have permission to access this data.":ze instanceof Error&&ze.message.includes("status 404")?ft="Analytics service not found. Please contact support if this issue persists.":ze instanceof Error&&ze.message.includes("status 500")?ft="Server error occurred. Our team has been notified. Please try again later.":ze instanceof Error&&ze.message.includes("Failed to fetch")&&(ft="Network error. Please check your internet connection and ensure the analytics service is accessible.");const Ct={id:(Date.now()+1).toString(),content:ft,role:"assistant",timestamp:new Date};O(Pt=>[...Pt,Ct])}}finally{B(!1),U(!1),P(null)}}},pn=async()=>{var ft;if(!b.trim()||w||z)return;t.onAnalyticsEvent&&j.length===0&&(console.log("Triggering input_submit analytics event for welcome screen input"),t.onAnalyticsEvent("input_submit",{action:"Submit",actionName:"Genius Input Submit",featureName:"Genius",component:"GeniusChatbotDashboard",inputType:"welcome_screen"}));const Re=b.trim();T(Re);const ot=new Date,Ge=Date.now(),ze=[];if(ee.length>0&&ee.forEach((Ct,Pt)=>{ze.push({id:`${Ge}-file-${Pt}`,content:"",role:"user",timestamp:ot,attachments:[Ct]})}),Re&&Re.trim()){const Ct={id:`${Ge}-text`,content:Re,role:"user",timestamp:ot};ze.push(Ct)}O(Ct=>[...Ct,...ze]),S(""),zt(),B(!0),U(!0),me.current=!1,setTimeout(()=>Ie(!0),100),i&&ze.forEach(Ct=>i(Ct));const mt=new AbortController;P(mt);try{if(se){try{await j4(Re,mt,O,U,Re,K,q,Le,m,J,t)}catch(It){if(It instanceof Error&&It.name==="AbortError")return;console.error("RCA Investigation error:",It);let $t="Unable to perform RCA investigation. Please try again.";It instanceof Error&&(It.message.includes("Authentication token not found")?$t="Session expired. Please log in to continue using RCA mode.":It.message.includes("status 401")?$t="Invalid authentication credentials for RCA investigation.":It.message.includes("status 403")?$t="Access denied. You don't have permission to perform RCA investigations.":It.message.includes("status 404")?$t="RCA investigation service not found. Please contact support.":It.message.includes("status 500")&&($t="Server error occurred during RCA investigation. Please try again later."));const St={id:(Date.now()+1).toString(),content:$t,role:"assistant",timestamp:new Date};O(rt=>[...rt,St])}B(!1),U(!1),P(null);return}const Ct=vw();if(!Ct)throw new Error("Authentication token not found");const Pt={"Content-Type":"application/json",Authorization:Ct},kt=new Date,qt=kt.getFullYear()+"-"+String(kt.getMonth()+1).padStart(2,"0")+"-"+String(kt.getDate()).padStart(2,"0")+"T"+String(kt.getHours()).padStart(2,"0")+":"+String(kt.getMinutes()).padStart(2,"0")+":"+String(kt.getSeconds()).padStart(2,"0")+"Z",Lt=await fetch(y,{method:"POST",headers:{...Pt,Accept:"text/event-stream"},body:JSON.stringify({query:Re,current_timestamp:qt,session_id:K,...g&&{moduleName:g},...ee.length>0&&{attachments:ee.map(It=>({data:It.base64,mime_type:It.type}))}}),signal:mt.signal});if(!Lt.ok)throw new Error(`API request failed with status ${Lt.status}`);const Yt=(ft=Lt.body)==null?void 0:ft.getReader();if(!Yt)throw new Error("Failed to get response reader");const wn=new TextDecoder;let Cn=null,Un="",_a=0,En="",Ei=null;const Kt={};let Wt=K;const On=It=>{var gt;if(!It.trim())return;const $t=It.split(`
516
516
  `);let St="",rt="";if($t.forEach(it=>{it.startsWith("event: ")?St=it.substring(7).trim():it.startsWith("data: ")&&(rt&&(rt+=`
517
517
  `),rt+=it.substring(6))}),rt)try{const it=JSON.parse(rt);if(St==="session_id"&&it.session_id)q(it.session_id),Wt=it.session_id;else if(St==="agent_text_output"||St==="final_output"){U(!1);const Xe=it.message||"";if(Un=Xe,Cn)O(_t=>_t.map(wt=>wt.id===Cn?{...wt,content:Xe,feedbackId:St==="final_output"&&it.feedback_id?it.feedback_id:wt.feedbackId}:wt));else{const _t={id:(Date.now()+Math.random()).toString(),content:Xe,role:"assistant",timestamp:new Date,feedbackId:St==="final_output"&&it.feedback_id?it.feedback_id:void 0};Cn=_t.id,O(wt=>[...wt,_t])}St==="final_output"&&(Un=Xe,Kt.finalOutputData=it,it.message_id&&J(it.message_id),Ei&&(m(Ei),Ei=null))}else if(St==="tool_output"&&(it.tool_name==="q_api_gemini"||(gt=it.tool_name)!=null&&gt.startsWith("q_api"))&&!Dl(it.input||"",t==null?void 0:t.qapiblacklistdomain)){const Xe=JSON.parse(it.output),_t=it.input?na(it.input,it.tool_name):"";if(Xe.length>0){const wt=Xe[0],vt=Object.keys(wt).find(dt=>dt.includes("_time"));if(vt){const dt=Object.keys(wt).filter(Ht=>Ht!==vt&&(Ht.includes("gateway")||Ht.includes("payment_method")||Ht.includes("dimension")||Ht.includes("group")||Ht.includes("category")||Ht.includes("payment_gateway")||typeof wt[Ht]=="string")),Ut=Object.keys(wt).filter(Ht=>Ht!==vt&&!dt.includes(Ht))[0];if(Ut){const Ht={groupbyKeys:dt,timeColumn:vt,metricColumns:[Ut],cardinality:"TOP_5",showCardinality:!0},Fi={metric_name_db:Ut,metric_label:Ut.replace(/_/g," "),metric_type:Oa(Ut)==="percentage"?"Rate":Oa(Ut)==="volume"?"Volume":Oa(Ut)==="latency"?"Latency":"Count"},ea={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,chartData:{},rawChartData:Xe,groupbyConfig:Ht,selectedMetrics:Fi};O(Ii=>[...Ii,ea]),Kt.rawChartData=Xe,Kt.groupbyConfig=Ht,Kt.selectedMetrics=Fi,Kt.description=_t}}else if(Xe.length===1){const dt=Object.keys(wt)[0];if(dt){const Mt={metric:dt.replace(/_/g," "),value:wt[dt]===null?"N/A":wt[dt]},Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,singleStat:Mt};O(Ht=>[...Ht,Ut]),Kt.singleStat=Mt,Kt.description=_t}}else{const dt=Mp(Xe);if(dt.isBarChart&&dt.groupKey&&dt.metricKey){const Mt=Ep(dt.metricKey);if(Mt.metric_type==="Volume"){const Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,volumeChartData:{rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,defaultChartType:"bar",showToggle:!0,title:Mt.metric_label}};O(Ht=>[...Ht,Ut]),Kt.volumeChartData={rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,defaultChartType:"bar",showToggle:!0,title:Mt.metric_label},Kt.description=_t}else{const Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,barChartData:{rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,isHorizontalBar:!0}};O(Ht=>[...Ht,Ut]),Kt.barChartData={rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,isHorizontalBar:!0},Kt.description=_t}}else{const Mt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,tableData:Xe};O(Ut=>[...Ut,Mt]),Kt.tableData=Xe,Kt.description=_t}}}}else if(St==="tool_output"&&it.tool_name==="display_message")try{const Xe=typeof it.output=="string"?JSON.parse(it.output):it.output,_t=it.input?na(it.input,it.tool_name):"";if(Xe&&Xe.status==="success"&&Xe.validated_config&&(!Xe.warnings||Xe.warnings.length===0)){const wt=Xe.validated_config,vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,directChartData:wt};O(dt=>[...dt,vt]),Kt.directChartData=wt,Kt.description=_t}else if(Xe&&Xe.chartType&&Xe.data&&Xe.metrics&&Xe.chartOptions&&Xe.displayOptions){const wt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,agenticChartData:Xe};O(vt=>[...vt,wt]),Kt.agenticChartData=Xe,Kt.description=_t}else Xe&&Xe.warnings&&Xe.warnings.length>0?console.warn("Display message tool has warnings, not rendering chart:",Xe.warnings):console.warn("Invalid display_message response format:",Xe)}catch(Xe){console.error("Error parsing display_message output:",Xe)}else if(St==="tool_output"&&it.tool_name==="chart_tool")try{const Xe=typeof it.output=="string"?JSON.parse(it.output):it.output,_t=it.input?na(it.input,it.tool_name):"";if(Xe&&Xe.status==="success"&&Xe.validated_config){const wt=Xe.validated_config,vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,directChartData:wt};O(dt=>[...dt,vt]),Kt.directChartData=wt,Kt.description=_t}else if(Xe&&Xe.chartType&&Xe.data&&Xe.metrics&&Xe.chartOptions&&Xe.displayOptions){const wt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,agenticChartData:Xe};O(vt=>[...vt,wt]),Kt.agenticChartData=Xe,Kt.description=_t}else console.warn("Invalid chart_tool response format:",Xe)}catch(Xe){console.error("Error parsing chart_tool output:",Xe)}else if(St==="tool_output"&&it.tool_name==="sr_analysis"){let Xe={};try{Xe=typeof it.output=="string"?JSON.parse(it.output):it.output}catch{Xe={}}Xe.is_SR_drop===!0&&(Ei={srOutput:Xe,srPayload:it.input?typeof it.input=="string"?JSON.parse(it.input):it.input:{},userEmail:Xe.parent_email||""})}else if(St==="tool_output"&&it.tool_name==="impact_analysis_q_api")try{const Xe=JSON.parse(it.output),_t=it.input?na(it.input,it.tool_name):"";if(Xe.length>0){const wt=Xe[0],vt=Object.keys(wt).find(dt=>dt.includes("_time"));if(vt){const dt=Object.keys(wt).filter(Ht=>Ht!==vt&&(Ht.includes("gateway")||Ht.includes("payment_method")||Ht.includes("dimension")||Ht.includes("group")||Ht.includes("category")||Ht.includes("payment_gateway")||typeof wt[Ht]=="string")),Ut=Object.keys(wt).filter(Ht=>Ht!==vt&&!dt.includes(Ht))[0];if(Ut){const Ht={groupbyKeys:dt,timeColumn:vt,metricColumns:[Ut],cardinality:"TOP_5",showCardinality:!0},Fi={metric_name_db:Ut,metric_label:Ut.replace(/_/g," "),metric_type:Oa(Ut)==="percentage"?"Rate":Oa(Ut)==="volume"?"Volume":Oa(Ut)==="latency"?"Latency":"Count"},ea={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,chartData:{},rawChartData:Xe,groupbyConfig:Ht,selectedMetrics:Fi};O(Ii=>[...Ii,ea]),Kt.impactAnalysisChartData={rawData:Xe,groupbyConfig:Ht,selectedMetrics:Fi,description:_t}}}else if(Xe.length===1){const dt=Object.keys(wt)[0];if(dt){const Mt={metric:dt.replace(/_/g," "),value:wt[dt]===null?"N/A":wt[dt]},Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,singleStat:Mt};O(Ht=>[...Ht,Ut]),Kt.impactAnalysisSingleStat={singleStat:Mt,description:_t}}}else{const dt=Mp(Xe);if(dt.isBarChart&&dt.groupKey&&dt.metricKey){const Mt=Ep(dt.metricKey);if(Mt.metric_type==="Volume"){const Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,volumeChartData:{rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,defaultChartType:"bar",showToggle:!0,title:Mt.metric_label}};O(Ht=>[...Ht,Ut]),Kt.impactAnalysisVolumeChart={data:Xe,groupKey:dt.groupKey,metricKey:dt.metricKey,selectedMetrics:Mt,description:_t}}else{const Ut={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,barChartData:{rawData:Xe,groupKey:dt.groupKey,selectedMetrics:Mt,isHorizontalBar:!0}};O(Ht=>[...Ht,Ut]),Kt.impactAnalysisBarChart={data:Xe,groupKey:dt.groupKey,metricKey:dt.metricKey,selectedMetrics:Mt,description:_t}}}else{const Mt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:_t,tableData:Xe};O(Ut=>[...Ut,Mt]),Kt.impactAnalysisTableData={tableData:Xe,description:_t}}}}}catch(Xe){console.error("🔍 ANALYTICS DEBUG: Error parsing impact_analysis_q_api output:",Xe)}}catch(it){console.error("Error parsing SSE data:",it,"Raw data:",rt)}};for(;;){const{done:It,value:$t}=await Yt.read();if(It){En.trim()&&En.split(`
518
518
 
@@ -679,7 +679,7 @@ Please choose files smaller than 6MB.`)}Ge.length>0&&ne(ft=>[...ft,...Ge]),pe.cu
679
679
 
680
680
  `).filter(Wt=>Wt).forEach(Wt=>{var $t,St;const On=($t=Wt.match(/event: (.*)/))==null?void 0:$t[1],It=Wt.match(/data: (.*)/);if(It)try{const rt=JSON.parse(It[1]);if(On==="session_id"&&rt.session_id)K(rt.session_id);else if(On==="agent_text_output"||On==="final_output"){v(!1);const gt=rt.message||"";if(Yt=gt,Lt)j(it=>it.map(Xe=>Xe.id===Lt?{...Xe,content:gt,feedbackId:On==="final_output"&&rt.feedback_id?rt.feedback_id:Xe.feedbackId}:Xe));else{Lt=(Date.now()+Math.random()).toString();const it={id:Lt,content:gt,role:"assistant",timestamp:new Date,feedbackId:On==="final_output"&&rt.feedback_id?rt.feedback_id:void 0};j(Xe=>[...Xe,it])}if(On==="final_output"){rt.message_id&&se(rt.message_id);const it=I||rt.session_id;it&&gt&&$e(Re,gt,{finalOutputData:rt},it).catch(_t=>{console.error("Failed to save message to IndexedDB:",_t)})}}else if(On==="tool_output"&&(rt.tool_name==="q_api_gemini"||(St=rt.tool_name)!=null&&St.startsWith("q_api"))&&!Dl(rt.input||"",t==null?void 0:t.qapiblacklistdomain)){const gt=JSON.parse(rt.output),it=rt.input?na(rt.input,rt.tool_name):"",Xe=De(I||rt.session_id||"",rt.feedback_id||"",`tool_output_${rt.tool_name}`);if(Ie(Xe))return;if(gt.length>0){const _t=gt[0],wt=Object.keys(_t).find(vt=>vt.includes("_time"));if(wt){const vt=Object.keys(_t).filter(Ut=>Ut!==wt&&(Ut.includes("gateway")||Ut.includes("payment_method")||Ut.includes("dimension")||Ut.includes("group")||Ut.includes("category")||Ut.includes("payment_gateway")||typeof _t[Ut]=="string")),Mt=Object.keys(_t).filter(Ut=>Ut!==wt&&!vt.includes(Ut))[0];if(Mt){const Ut=jp(gt,wt,Mt),Ht=Kn(Mt),Fi={chart:{type:"line"},title:{text:`${Mt.replace(/_/g," ")}`},credits:{enabled:!1},xAxis:{categories:Ut.categories,gridLineWidth:0,labels:{step:Lp(Ut.categories),formatter:function(){return String(this.value)},style:{color:"#9aa0a6"},rotation:0,align:"center"}},yAxis:{title:{text:""},gridLineColor:"#e0e0e0",gridLineDashStyle:"Dash",labels:{formatter:function(){return $a(Number(this.value),Ht)},style:{color:"#9aa0a6"}}},legend:{enabled:Ut.hasDimensions,align:"left",verticalAlign:"top",layout:"horizontal",y:10,itemStyle:{fontSize:"11px"},symbolRadius:0,symbolHeight:0,symbolWidth:0,useHTML:!0,labelFormatter:function(){return'<span style="display: inline-flex; align-items: center;"><span style="background-color: '+this.color+'; width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px;"></span>'+this.name+"</span>"}},plotOptions:{series:{marker:{enabled:!1,symbol:"circle",radius:3,states:{hover:{enabled:!0,radius:4}}},states:{hover:{lineWidthPlus:1}}}},tooltip:{shared:!0,useHTML:!0,backgroundColor:"rgba(255, 255, 255, 0)",borderWidth:0,shadow:!1,style:{padding:"0px"},formatter:function(){var ua,Us,ms,da,wi;const Ln=Kn(Mt),Qn=Ci=>Ci.replace(/_/g," ").replace(/\b\w/g,di=>di.toUpperCase());let Hn='<div style="border-radius: 12px; border: 1px solid #EAECF0; background: #FFF; box-shadow: 0px 6px 15px 0px rgba(0, 0, 0, 0.15), 0px 3px 2px -5px rgba(0, 0, 0, 0.04); padding: 16px;">';Hn+='<div style="display: flex; font-family: Inter, sans-serif; gap: 16px; align-items: stretch;">';const sr=this.points?this.points[0].color:this.color||"#7856FF";if(Hn+=`<div style="background:${sr}; width: 4px; flex-shrink: 0; border-radius: 4px; align-self: stretch;"></div>`,Hn+='<div style="display: flex; flex-direction: column; gap: 12px;">',Hn+='<div style="display: flex; flex-direction: column; gap: 4px;">',Hn+=`<div style="color: #525252; font-feature-settings: 'clig' off, 'liga' off; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 600; line-height: 18px;">${Qn(Mt)}</div>`,Hn+="</div>",Hn+='<div class="flex flex-col gap-1" style="display: flex; flex-direction: column; gap: 6px;">',this.points)[...this.points].sort((di,sa)=>(sa.y||0)-(di.y||0)).forEach(di=>{var ha,io;const sa=$a(di.y||0,Ln),ys=((ha=di.series)==null?void 0:ha.name)==="Overall",Or=ys?"bg-jp-2-gray-30 text-jp-2-gray-700":"bg-jp-2-green-50 text-jp-2-green-200",as=ys?"#E8E8E8":"#D4F4E5",La=ys?"#424242":"#008242";Hn+='<div class="flex items-center" style="display: flex; align-items: center;">',Hn+=`<div class="${Or} rounded p-1 font-semibold mr-1.5 my-1" style="background-color: ${as}; color: ${La}; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${sa}</div>`,Hn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((io=di.series)==null?void 0:io.name)||""}</div>`,Hn+="</div>"});else{const Ci=$a(this.y||0,Ln);Hn+='<div class="flex items-center" style="display: flex; align-items: center;">',Hn+=`<div class="bg-jp-2-green-50 text-jp-2-green-200 rounded p-1 font-semibold mr-1.5 my-1" style="background-color: #D4F4E5; color: #008242; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${Ci}</div>`,Hn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((ua=this.series)==null?void 0:ua.name)||""}</div>`,Hn+="</div>"}const is=((da=(ms=(Us=this.points)==null?void 0:Us[0])==null?void 0:ms.point)==null?void 0:da.originalTimestamp)||((wi=this.point)==null?void 0:wi.originalTimestamp),Ya=is?Nu(is):String(this.x);return Hn+=`<div class="font-medium text-jp-2-gray-300" style="font-weight: 500; color: #9AA0A6; font-size: 12px; margin-top: 4px;">${Ya}</div>`,Hn+="</div>",Hn+="</div>",Hn+="</div>",Hn+="</div>",Hn},xDateFormat:"%a, %d %B, %Y %H:%M"},series:Ut.series},ea={groupbyKeys:vt,timeColumn:wt,metricColumns:[Mt],cardinality:"TOP_5",showCardinality:!0},Ii={metric_name_db:Mt,metric_label:Mt.replace(/_/g," "),metric_type:Kn(Mt)==="percentage"?"Rate":Kn(Mt)==="volume"?"Volume":Kn(Mt)==="latency"?"Latency":"Count"},vn={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:it,chartData:Fi,rawChartData:gt,groupbyConfig:ea,selectedMetrics:Ii};j(Ln=>[...Ln,vn])}}else if(gt.length===1){const vt=Object.keys(_t)[0];if(vt){const dt={metric:vt.replace(/_/g," "),value:_t[vt]===null?"N/A":_t[vt]},Mt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:it,singleStat:dt};j(Ut=>[...Ut,Mt])}}else{const vt=Dp(gt);if(vt.isBarChart&&vt.groupKey&&vt.metricKey){const dt=Op(vt.metricKey);if(dt.metric_type==="Volume"){const Mt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:it,volumeChartData:{rawData:gt,groupKey:vt.groupKey,selectedMetrics:dt,defaultChartType:"bar",showToggle:!0,title:dt.metric_label}};j(Ut=>[...Ut,Mt])}else{const Mt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:it,barChartData:{rawData:gt,groupKey:vt.groupKey,selectedMetrics:dt,isHorizontalBar:!0}};j(Ut=>[...Ut,Mt])}}else{const dt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:it,tableData:gt};j(Mt=>[...Mt,dt])}}}Ve(Xe)}}catch(rt){console.error("Error parsing event data:",rt)}});break}const _a=qt.decode(Un,{stream:!0});wn+=_a;const En=wn.split(`
681
681
 
682
- `),Ei=En.slice(0,-1);wn=En[En.length-1],Ei.forEach(Kt=>{var It,$t;const Wt=(It=Kt.match(/event: (.*)/))==null?void 0:It[1],On=Kt.match(/data: (.*)/);if(On)try{const St=JSON.parse(On[1]);if(Wt==="session_id"&&St.session_id)K(St.session_id);else if(Wt==="agent_text_output"||Wt==="final_output"){v(!1);const rt=St.message||"";if(Yt=rt,Lt)j(gt=>gt.map(it=>it.id===Lt?{...it,content:rt,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:it.feedbackId}:it));else{Lt=(Date.now()+Math.random()).toString();const gt={id:Lt,content:rt,role:"assistant",timestamp:new Date,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:void 0};j(it=>[...it,gt])}if(Wt==="final_output"){St.message_id&&se(St.message_id);const gt=I||St.session_id;gt&&rt&&$e(Re,rt,{finalOutputData:St},gt).catch(Xe=>{console.error("Failed to save message to IndexedDB:",Xe)})}}else if(Wt==="tool_output"&&(St.tool_name==="q_api_gemini"||($t=St.tool_name)!=null&&$t.startsWith("q_api"))&&!Dl(St.input||"",t==null?void 0:t.qapiblacklistdomain)){const rt=JSON.parse(St.output),gt=St.input?na(St.input,St.tool_name):"";if(rt.length>0){const it=rt[0],Xe=Object.keys(it).find(_t=>_t.includes("_time"));if(Xe){const _t=Object.keys(it).filter(dt=>dt!==Xe&&(dt.includes("gateway")||dt.includes("payment_method")||dt.includes("dimension")||dt.includes("group")||dt.includes("category")||dt.includes("payment_gateway")||typeof it[dt]=="string")),vt=Object.keys(it).filter(dt=>dt!==Xe&&!_t.includes(dt))[0];if(vt){const dt=jp(rt,Xe,vt),Mt=Kn(vt),Ut={chart:{type:"line"},title:{text:`${vt.replace(/_/g," ")}`},credits:{enabled:!1},xAxis:{categories:dt.categories,gridLineWidth:0,labels:{step:Lp(dt.categories),formatter:function(){return String(this.value)},style:{color:"#9aa0a6"},rotation:0,align:"center"}},yAxis:{title:{text:""},gridLineColor:"#e0e0e0",gridLineDashStyle:"Dash",labels:{formatter:function(){return $a(Number(this.value),Mt)},style:{color:"#9aa0a6"}}},legend:{enabled:dt.hasDimensions,align:"center",verticalAlign:"top",layout:"horizontal",y:10,itemStyle:{fontSize:"11px"},symbolRadius:0,symbolHeight:0,symbolWidth:0,useHTML:!0,labelFormatter:function(){return'<span style="display: inline-flex; align-items: center;"><span style="background-color: '+this.color+'; width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px;"></span>'+this.name+"</span>"}},plotOptions:{series:{marker:{enabled:!1,symbol:"circle",radius:3,states:{hover:{enabled:!0,radius:4}}},states:{hover:{lineWidthPlus:1}}}},tooltip:{shared:!0,useHTML:!0,backgroundColor:"rgba(255, 255, 255, 0)",borderWidth:0,shadow:!1,style:{padding:"0px"},formatter:function(){var Ya,ua,Us,ms,da,wi;const vn=Kn(vt),Ln=Ci=>Ci.replace(/_/g," ").replace(/\b\w/g,di=>di.toUpperCase());let Qn='<div style="border-radius: 12px; border: 1px solid #EAECF0; background: #FFF; box-shadow: 0px 6px 15px 0px rgba(0, 0, 0, 0.15), 0px 3px 2px -5px rgba(0, 0, 0, 0.04); padding: 16px;">';Qn+='<div style="display: flex; font-family: Inter, sans-serif; gap: 16px; align-items: stretch;">';const Hn=((Ya=this.points)==null?void 0:Ya[0].color)||"#7856FF";if(Qn+=`<div style="background:${Hn}; width: 4px; flex-shrink: 0; border-radius: 4px; align-self: stretch;"></div>`,Qn+='<div style="display: flex; flex-direction: column; gap: 12px;">',Qn+='<div style="display: flex; flex-direction: column; gap: 4px;">',Qn+=`<div style="color: #525252; font-feature-settings: 'clig' off, 'liga' off; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 600; line-height: 18px;">${Ln(vt)}</div>`,Qn+="</div>",Qn+='<div class="flex flex-col gap-1" style="display: flex; flex-direction: column; gap: 6px;">',this.points)[...this.points].sort((di,sa)=>(sa.y||0)-(di.y||0)).forEach(di=>{var ha,io;const sa=$a(di.y||0,vn),ys=((ha=di.series)==null?void 0:ha.name)==="Overall",Or=ys?"bg-jp-2-gray-30 text-jp-2-gray-700":"bg-jp-2-green-50 text-jp-2-green-200",as=ys?"#E8E8E8":"#D4F4E5",La=ys?"#424242":"#008242";Qn+='<div class="flex items-center" style="display: flex; align-items: center;">',Qn+=`<div class="${Or} rounded p-1 font-semibold mr-1.5 my-1" style="background-color: ${as}; color: ${La}; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${sa}</div>`,Qn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((io=di.series)==null?void 0:io.name)||""}</div>`,Qn+="</div>"});else{const Ci=$a(this.y||0,vn);Qn+='<div class="flex items-center" style="display: flex; align-items: center;">',Qn+=`<div class="bg-jp-2-green-50 text-jp-2-green-200 rounded p-1 font-semibold mr-1.5 my-1" style="background-color: #D4F4E5; color: #008242; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${Ci}</div>`,Qn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((ua=this.series)==null?void 0:ua.name)||""}</div>`,Qn+="</div>"}const sr=((da=(ms=(Us=this.points)==null?void 0:Us[0])==null?void 0:ms.point)==null?void 0:da.originalTimestamp)||((wi=this.point)==null?void 0:wi.originalTimestamp),is=sr?Nu(sr):String(this.x);return Qn+=`<div class="font-medium text-jp-2-gray-300" style="font-weight: 500; color: #9AA0A6; font-size: 12px; margin-top: 4px;">${is}</div>`,Qn+="</div>",Qn+="</div>",Qn+="</div>",Qn+="</div>",Qn},xDateFormat:"%a, %d %B, %Y %H:%M"},series:dt.series},Ht={groupbyKeys:_t,timeColumn:Xe,metricColumns:[vt],cardinality:"TOP_5",showCardinality:!0},Fi={metric_name_db:vt,metric_label:vt.replace(/_/g," "),metric_type:Kn(vt)==="percentage"?"Rate":Kn(vt)==="volume"?"Volume":Kn(vt)==="latency"?"Latency":"Count"},ea={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,chartData:Ut,rawChartData:rt,groupbyConfig:Ht,selectedMetrics:Fi};j(vn=>[...vn,ea]);const Ii=I||St.session_id;Ii&&$e(Re,Yt,{chartData:Ut,description:gt},Ii)}}else if(rt.length===1){const _t=Object.keys(it)[0];if(_t){const wt={metric:_t.replace(/_/g," "),value:it[_t]===null?"N/A":it[_t]},vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,singleStat:wt};j(Mt=>[...Mt,vt]);const dt=I||St.session_id;dt&&$e(Re,Yt,{singleStat:wt,description:gt},dt)}}else{const _t=Dp(rt);if(_t.isBarChart&&_t.groupKey&&_t.metricKey){const wt=Op(_t.metricKey);if(wt.metric_type==="Volume"){const dt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,volumeChartData:{rawData:rt,groupKey:_t.groupKey,selectedMetrics:wt,defaultChartType:"bar",showToggle:!0,title:wt.metric_label}};j(Mt=>[...Mt,dt]);return}const vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,barChartData:{rawData:rt,groupKey:_t.groupKey,selectedMetrics:wt,isHorizontalBar:!0}};j(dt=>[...dt,vt])}else{const wt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,tableData:rt};j(dt=>[...dt,wt]);const vt=I||St.session_id;vt&&$e(Re,Yt,{tableData:rt,description:gt},vt)}}}}}catch(St){console.error("Error parsing event data:",St)}})}}else{const kt=await Pt.json(),qt={id:(Date.now()+1).toString(),content:kt.message||"Sorry, I couldn't process that.",role:"assistant",timestamp:new Date};j(Lt=>[...Lt,qt])}}catch(Ge){if(Ge instanceof Error&&Ge.name==="AbortError")return;if(console.error("Error sending message:",Ge),!S.some(mt=>mt.role==="assistant")){let mt="Unable to connect to Genius Analytics. Please check your network connection and try again.";Ge instanceof Error&&Ge.message.includes("Authentication token not found")?mt="Session expired or not authenticated. Please log in to continue using Genius Analytics.":Ge instanceof Error&&Ge.message.includes("status 401")?mt="Invalid authentication credentials. Please log in with valid credentials.":Ge instanceof Error&&Ge.message.includes("status 403")?mt="Access denied. You don't have permission to access this data.":Ge instanceof Error&&Ge.message.includes("status 404")?mt="Analytics service not found. Please contact support if this issue persists.":Ge instanceof Error&&Ge.message.includes("status 500")?mt="Server error occurred. Our team has been notified. Please try again later.":Ge instanceof Error&&Ge.message.includes("Failed to fetch")&&(mt="Network error. Please check your internet connection and ensure the analytics service is accessible.");const ft={id:(Date.now()+1).toString(),content:mt,role:"assistant",timestamp:new Date};j(Ct=>[...Ct,ft])}}finally{Y(!1),v(!1),M(null)}}},Sa=async()=>{if(!O.trim()||B||k)return;const Re=O.trim();L(Re);const ot={id:Date.now().toString(),content:Re,role:"user",timestamp:new Date};j(ze=>[...ze,ot]),w(""),Y(!0),v(!0),be.current=!1,setTimeout(()=>tn(!0),100),h&&h(ot);const Ge=new AbortController;M(Ge);try{if(pe){try{await z4(Re,Ge,j,v,Re,I,K,$e,se,t)}catch(kt){if(kt instanceof Error&&kt.name==="AbortError")return;console.error("RCA Investigation error:",kt);let qt="Unable to perform RCA investigation. Please try again.";kt instanceof Error&&(kt.message.includes("Authentication token not found")?qt="Session expired. Please log in to continue using RCA mode.":kt.message.includes("status 401")?qt="Invalid authentication credentials for RCA investigation.":kt.message.includes("status 403")?qt="Access denied. You don't have permission to perform RCA investigations.":kt.message.includes("status 404")?qt="RCA investigation service not found. Please contact support.":kt.message.includes("status 500")&&(qt="Server error occurred during RCA investigation. Please try again later."));const Lt={id:(Date.now()+1).toString(),content:qt,role:"assistant",timestamp:new Date};j(Yt=>[...Yt,Lt])}Y(!1),v(!1),M(null);return}const ze=x1();if(!ze)throw new Error("Authentication token not found");const mt={"Content-Type":"application/json",Accept:"text/event-stream",Authorization:ze},ft=new Date,Ct=ft.getFullYear()+"-"+String(ft.getMonth()+1).padStart(2,"0")+"-"+String(ft.getDate()).padStart(2,"0")+"T"+String(ft.getHours()).padStart(2,"0")+":"+String(ft.getMinutes()).padStart(2,"0")+":"+String(ft.getSeconds()).padStart(2,"0")+"Z",Pt=await fetch(b,{method:"POST",headers:{...mt,Accept:"text/event-stream"},body:JSON.stringify({query:ot.content,current_timestamp:Ct,session_id:I,...y&&{moduleName:y}}),signal:Ge.signal});if(!Pt.ok)throw new Error(`API request failed with status ${Pt.status}`);if(Pt.body){const kt=Pt.body.getReader(),qt=new TextDecoder;let Lt=null,Yt="";for(;;){const{done:wn,value:Cn}=await kt.read();if(wn){Yt.trim()&&Yt.split(`
682
+ `),Ei=En.slice(0,-1);wn=En[En.length-1],Ei.forEach(Kt=>{var It,$t;const Wt=(It=Kt.match(/event: (.*)/))==null?void 0:It[1],On=Kt.match(/data: (.*)/);if(On)try{const St=JSON.parse(On[1]);if(Wt==="session_id"&&St.session_id)K(St.session_id);else if(Wt==="agent_text_output"||Wt==="final_output"){v(!1);const rt=St.message||"";if(Yt=rt,Lt)j(gt=>gt.map(it=>it.id===Lt?{...it,content:rt,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:it.feedbackId}:it));else{Lt=(Date.now()+Math.random()).toString();const gt={id:Lt,content:rt,role:"assistant",timestamp:new Date,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:void 0};j(it=>[...it,gt])}if(Wt==="final_output"){St.message_id&&se(St.message_id);const gt=I||St.session_id;gt&&rt&&$e(Re,rt,{finalOutputData:St},gt).catch(Xe=>{console.error("Failed to save message to IndexedDB:",Xe)})}}else if(Wt==="tool_output"&&(St.tool_name==="q_api_gemini"||($t=St.tool_name)!=null&&$t.startsWith("q_api"))&&!Dl(St.input||"",t==null?void 0:t.qapiblacklistdomain)){const rt=JSON.parse(St.output),gt=St.input?na(St.input,St.tool_name):"";if(rt.length>0){const it=rt[0],Xe=Object.keys(it).find(_t=>_t.includes("_time"));if(Xe){const _t=Object.keys(it).filter(dt=>dt!==Xe&&(dt.includes("gateway")||dt.includes("payment_method")||dt.includes("dimension")||dt.includes("group")||dt.includes("category")||dt.includes("payment_gateway")||typeof it[dt]=="string")),vt=Object.keys(it).filter(dt=>dt!==Xe&&!_t.includes(dt))[0];if(vt){const dt=jp(rt,Xe,vt),Mt=Kn(vt),Ut={chart:{type:"line"},title:{text:`${vt.replace(/_/g," ")}`},credits:{enabled:!1},xAxis:{categories:dt.categories,gridLineWidth:0,labels:{step:Lp(dt.categories),formatter:function(){return String(this.value)},style:{color:"#9aa0a6"},rotation:0,align:"center"}},yAxis:{title:{text:""},gridLineColor:"#e0e0e0",gridLineDashStyle:"Dash",labels:{formatter:function(){return $a(Number(this.value),Mt)},style:{color:"#9aa0a6"}}},legend:{enabled:dt.hasDimensions,align:"center",verticalAlign:"top",layout:"horizontal",y:10,itemStyle:{fontSize:"11px"},symbolRadius:0,symbolHeight:0,symbolWidth:0,useHTML:!0,labelFormatter:function(){return'<span style="display: inline-flex; align-items: center;"><span style="background-color: '+this.color+'; width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px;"></span>'+this.name+"</span>"}},plotOptions:{series:{marker:{enabled:!1,symbol:"circle",radius:3,states:{hover:{enabled:!0,radius:4}}},states:{hover:{lineWidthPlus:1}}}},tooltip:{shared:!0,useHTML:!0,backgroundColor:"rgba(255, 255, 255, 0)",borderWidth:0,shadow:!1,style:{padding:"0px"},formatter:function(){var Ya,ua,Us,ms,da,wi;const vn=Kn(vt),Ln=Ci=>Ci.replace(/_/g," ").replace(/\b\w/g,di=>di.toUpperCase());let Qn='<div style="border-radius: 12px; border: 1px solid #EAECF0; background: #FFF; box-shadow: 0px 6px 15px 0px rgba(0, 0, 0, 0.15), 0px 3px 2px -5px rgba(0, 0, 0, 0.04); padding: 16px;">';Qn+='<div style="display: flex; font-family: Inter, sans-serif; gap: 16px; align-items: stretch;">';const Hn=((Ya=this.points)==null?void 0:Ya[0].color)||"#7856FF";if(Qn+=`<div style="background:${Hn}; width: 4px; flex-shrink: 0; border-radius: 4px; align-self: stretch;"></div>`,Qn+='<div style="display: flex; flex-direction: column; gap: 12px;">',Qn+='<div style="display: flex; flex-direction: column; gap: 4px;">',Qn+=`<div style="color: #525252; font-feature-settings: 'clig' off, 'liga' off; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 600; line-height: 18px;">${Ln(vt)}</div>`,Qn+="</div>",Qn+='<div class="flex flex-col gap-1" style="display: flex; flex-direction: column; gap: 6px;">',this.points)[...this.points].sort((di,sa)=>(sa.y||0)-(di.y||0)).forEach(di=>{var ha,io;const sa=$a(di.y||0,vn),ys=((ha=di.series)==null?void 0:ha.name)==="Overall",Or=ys?"bg-jp-2-gray-30 text-jp-2-gray-700":"bg-jp-2-green-50 text-jp-2-green-200",as=ys?"#E8E8E8":"#D4F4E5",La=ys?"#424242":"#008242";Qn+='<div class="flex items-center" style="display: flex; align-items: center;">',Qn+=`<div class="${Or} rounded p-1 font-semibold mr-1.5 my-1" style="background-color: ${as}; color: ${La}; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${sa}</div>`,Qn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((io=di.series)==null?void 0:io.name)||""}</div>`,Qn+="</div>"});else{const Ci=$a(this.y||0,vn);Qn+='<div class="flex items-center" style="display: flex; align-items: center;">',Qn+=`<div class="bg-jp-2-green-50 text-jp-2-green-200 rounded p-1 font-semibold mr-1.5 my-1" style="background-color: #D4F4E5; color: #008242; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${Ci}</div>`,Qn+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((ua=this.series)==null?void 0:ua.name)||""}</div>`,Qn+="</div>"}const sr=((da=(ms=(Us=this.points)==null?void 0:Us[0])==null?void 0:ms.point)==null?void 0:da.originalTimestamp)||((wi=this.point)==null?void 0:wi.originalTimestamp),is=sr?Nu(sr):String(this.x);return Qn+=`<div class="font-medium text-jp-2-gray-300" style="font-weight: 500; color: #9AA0A6; font-size: 12px; margin-top: 4px;">${is}</div>`,Qn+="</div>",Qn+="</div>",Qn+="</div>",Qn+="</div>",Qn},xDateFormat:"%a, %d %B, %Y %H:%M"},series:dt.series},Ht={groupbyKeys:_t,timeColumn:Xe,metricColumns:[vt],cardinality:"TOP_5",showCardinality:!0},Fi={metric_name_db:vt,metric_label:vt.replace(/_/g," "),metric_type:Kn(vt)==="percentage"?"Rate":Kn(vt)==="volume"?"Volume":Kn(vt)==="latency"?"Latency":"Count"},ea={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,chartData:Ut,rawChartData:rt,groupbyConfig:Ht,selectedMetrics:Fi};j(vn=>[...vn,ea]);const Ii=I||St.session_id;Ii&&$e(Re,Yt,{chartData:Ut,description:gt},Ii)}}else if(rt.length===1){const _t=Object.keys(it)[0];if(_t){const wt={metric:_t.replace(/_/g," "),value:it[_t]===null?"N/A":it[_t]},vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,singleStat:wt};j(Mt=>[...Mt,vt]);const dt=I||St.session_id;dt&&$e(Re,Yt,{singleStat:wt,description:gt},dt)}}else{const _t=Dp(rt);if(_t.isBarChart&&_t.groupKey&&_t.metricKey){const wt=Op(_t.metricKey);if(wt.metric_type==="Volume"){const dt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,volumeChartData:{rawData:rt,groupKey:_t.groupKey,selectedMetrics:wt,defaultChartType:"bar",showToggle:!0,title:wt.metric_label}};j(Mt=>[...Mt,dt]);return}const vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,barChartData:{rawData:rt,groupKey:_t.groupKey,selectedMetrics:wt,isHorizontalBar:!0}};j(dt=>[...dt,vt])}else{const wt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,tableData:rt};j(dt=>[...dt,wt]);const vt=I||St.session_id;vt&&$e(Re,Yt,{tableData:rt,description:gt},vt)}}}}}catch(St){console.error("Error parsing event data:",St)}})}}else{const kt=await Pt.json(),qt={id:(Date.now()+1).toString(),content:kt.message||"Sorry, I couldn't process that.",role:"assistant",timestamp:new Date};j(Lt=>[...Lt,qt])}}catch(Ge){if(Ge instanceof Error&&Ge.name==="AbortError")return;if(console.error("Error sending message:",Ge),!S.some(mt=>mt.role==="assistant")){let mt="Unable to connect to Genius Analytics. Please check your network connection and try again.";Ge instanceof Error&&Ge.message.includes("Authentication token not found")?mt="Session expired or not authenticated. Please log in to continue using Genius Analytics.":Ge instanceof Error&&Ge.message.includes("status 401")?mt="Invalid authentication credentials. Please log in with valid credentials.":Ge instanceof Error&&Ge.message.includes("status 403")?mt="Access denied. You don't have permission to access this data.":Ge instanceof Error&&Ge.message.includes("status 404")?mt="Analytics service not found. Please contact support if this issue persists.":Ge instanceof Error&&Ge.message.includes("status 500")?mt="Server error occurred. Our team has been notified. Please try again later.":Ge instanceof Error&&Ge.message.includes("Failed to fetch")&&(mt="Network error. Please check your internet connection and ensure the analytics service is accessible.");const ft={id:(Date.now()+1).toString(),content:mt,role:"assistant",timestamp:new Date};j(Ct=>[...Ct,ft])}}finally{Y(!1),v(!1),M(null)}}},Sa=async()=>{if(!O.trim()||B||k)return;t.onAnalyticsEvent&&S.length===0&&(console.log("Triggering input_submit analytics event for welcome screen input"),t.onAnalyticsEvent("input_submit",{action:"Submit",actionName:"Genius Input Submit",featureName:"Genius",component:"GeniusChatbotMobile",inputType:"welcome_screen"}));const Re=O.trim();L(Re);const ot={id:Date.now().toString(),content:Re,role:"user",timestamp:new Date};j(ze=>[...ze,ot]),w(""),Y(!0),v(!0),be.current=!1,setTimeout(()=>tn(!0),100),h&&h(ot);const Ge=new AbortController;M(Ge);try{if(pe){try{await z4(Re,Ge,j,v,Re,I,K,$e,se,t)}catch(kt){if(kt instanceof Error&&kt.name==="AbortError")return;console.error("RCA Investigation error:",kt);let qt="Unable to perform RCA investigation. Please try again.";kt instanceof Error&&(kt.message.includes("Authentication token not found")?qt="Session expired. Please log in to continue using RCA mode.":kt.message.includes("status 401")?qt="Invalid authentication credentials for RCA investigation.":kt.message.includes("status 403")?qt="Access denied. You don't have permission to perform RCA investigations.":kt.message.includes("status 404")?qt="RCA investigation service not found. Please contact support.":kt.message.includes("status 500")&&(qt="Server error occurred during RCA investigation. Please try again later."));const Lt={id:(Date.now()+1).toString(),content:qt,role:"assistant",timestamp:new Date};j(Yt=>[...Yt,Lt])}Y(!1),v(!1),M(null);return}const ze=x1();if(!ze)throw new Error("Authentication token not found");const mt={"Content-Type":"application/json",Accept:"text/event-stream",Authorization:ze},ft=new Date,Ct=ft.getFullYear()+"-"+String(ft.getMonth()+1).padStart(2,"0")+"-"+String(ft.getDate()).padStart(2,"0")+"T"+String(ft.getHours()).padStart(2,"0")+":"+String(ft.getMinutes()).padStart(2,"0")+":"+String(ft.getSeconds()).padStart(2,"0")+"Z",Pt=await fetch(b,{method:"POST",headers:{...mt,Accept:"text/event-stream"},body:JSON.stringify({query:ot.content,current_timestamp:Ct,session_id:I,...y&&{moduleName:y}}),signal:Ge.signal});if(!Pt.ok)throw new Error(`API request failed with status ${Pt.status}`);if(Pt.body){const kt=Pt.body.getReader(),qt=new TextDecoder;let Lt=null,Yt="";for(;;){const{done:wn,value:Cn}=await kt.read();if(wn){Yt.trim()&&Yt.split(`
683
683
 
684
684
  `).filter(Kt=>Kt).forEach(Kt=>{var It,$t;const Wt=(It=Kt.match(/event: (.*)/))==null?void 0:It[1],On=Kt.match(/data: (.*)/);if(On)try{const St=JSON.parse(On[1]);if(Wt==="session_id"&&St.session_id)K(St.session_id);else if(Wt==="agent_text_output"||Wt==="final_output"){v(!1);const rt=St.message||"";if(Lt)j(gt=>gt.map(it=>it.id===Lt?{...it,content:rt,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:it.feedbackId}:it));else{Lt=(Date.now()+Math.random()).toString();const gt={id:Lt,content:rt,role:"assistant",timestamp:new Date,feedbackId:Wt==="final_output"&&St.feedback_id?St.feedback_id:void 0};j(it=>[...it,gt])}if(Wt==="final_output"){St.message_id&&se(St.message_id);const gt=I||St.session_id;if(gt&&rt){const it={finalOutputData:St};$e(ot.content,rt,it,gt).catch(Xe=>{console.error("Failed to save message to IndexedDB:",Xe)})}}}else if(Wt==="tool_output"&&(St.tool_name==="q_api_gemini"||($t=St.tool_name)!=null&&$t.startsWith("q_api"))&&!Dl(St.input||"",t==null?void 0:t.qapiblacklistdomain)){const rt=JSON.parse(St.output),gt=St.input?na(St.input,St.tool_name):"";if(rt.length>0){const it=rt[0],Xe=Object.keys(it).find(_t=>_t.includes("_time"));if(Xe){const _t=Object.keys(it).filter(dt=>dt!==Xe&&(dt.includes("gateway")||dt.includes("payment_method")||dt.includes("dimension")||dt.includes("group")||dt.includes("category")||dt.includes("payment_gateway")||typeof it[dt]=="string")),vt=Object.keys(it).filter(dt=>dt!==Xe&&!_t.includes(dt))[0];if(vt){const dt=jp(rt,Xe,vt),Mt=Kn(vt),Ut={chart:{type:"line"},title:{text:`${vt.replace(/_/g," ")}`},credits:{enabled:!1},xAxis:{categories:dt.categories,gridLineWidth:0,labels:{step:Lp(dt.categories),formatter:function(){return String(this.value)},style:{color:"#9aa0a6"},rotation:0,align:"center"}},yAxis:{title:{text:""},gridLineColor:"#e0e0e0",gridLineDashStyle:"Dash",labels:{formatter:function(){return $a(Number(this.value),Mt)},style:{color:"#9aa0a6"}}},legend:{enabled:dt.hasDimensions,align:"center",verticalAlign:"top",layout:"horizontal",y:10,itemStyle:{fontSize:"11px"},symbolRadius:0,symbolHeight:0,symbolWidth:0,useHTML:!0,labelFormatter:function(){return'<span style="display: inline-flex; align-items: center;"><span style="background-color: '+this.color+'; width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px;"></span>'+this.name+"</span>"}},plotOptions:{series:{marker:{enabled:!1,symbol:"circle",radius:3,states:{hover:{enabled:!0,radius:4}}},states:{hover:{lineWidthPlus:1}}}},tooltip:{shared:!0,useHTML:!0,backgroundColor:"rgba(255, 255, 255, 0)",borderWidth:0,shadow:!1,style:{padding:"0px"},formatter:function(){var is,Ya,ua,Us,ms,da;const Ii=Kn(vt),vn=wi=>wi.replace(/_/g," ").replace(/\b\w/g,Ci=>Ci.toUpperCase());let Ln='<div style="border-radius: 12px; border: 1px solid #EAECF0; background: #FFF; box-shadow: 0px 6px 15px 0px rgba(0, 0, 0, 0.15), 0px 3px 2px -5px rgba(0, 0, 0, 0.04); padding: 16px;">';Ln+='<div style="display: flex; font-family: Inter, sans-serif; gap: 16px; align-items: stretch;">';const Qn=((is=this.points)==null?void 0:is[0].color)||"#7856FF";if(Ln+=`<div style="background:${Qn}; width: 4px; flex-shrink: 0; border-radius: 4px; align-self: stretch;"></div>`,Ln+='<div style="display: flex; flex-direction: column; gap: 12px;">',Ln+='<div style="display: flex; flex-direction: column; gap: 4px;">',Ln+=`<div style="color: #525252; font-feature-settings: 'clig' off, 'liga' off; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 600; line-height: 18px;">${vn(vt)}</div>`,Ln+="</div>",Ln+='<div class="flex flex-col gap-1" style="display: flex; flex-direction: column; gap: 6px;">',this.points)[...this.points].sort((Ci,di)=>(di.y||0)-(Ci.y||0)).forEach(Ci=>{var La,ha;const di=$a(Ci.y||0,Ii),sa=((La=Ci.series)==null?void 0:La.name)==="Overall",ys=sa?"bg-jp-2-gray-30 text-jp-2-gray-700":"bg-jp-2-green-50 text-jp-2-green-200",Or=sa?"#E8E8E8":"#D4F4E5",as=sa?"#424242":"#008242";Ln+='<div class="flex items-center" style="display: flex; align-items: center;">',Ln+=`<div class="${ys} rounded p-1 font-semibold mr-1.5 my-1" style="background-color: ${Or}; color: ${as}; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${di}</div>`,Ln+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((ha=Ci.series)==null?void 0:ha.name)||""}</div>`,Ln+="</div>"});else{const wi=$a(this.y||0,Ii);Ln+='<div class="flex items-center" style="display: flex; align-items: center;">',Ln+=`<div class="bg-jp-2-green-50 text-jp-2-green-200 rounded p-1 font-semibold mr-1.5 my-1" style="background-color: #D4F4E5; color: #008242; border-radius: 4px; padding: 4px 8px; font-weight: 600; margin-right: 8px; font-size: 12px;">${wi}</div>`,Ln+=`<div class="text-jp-2-gray-200 font-medium" style="color: #70747E; font-weight: 500; font-size: 12px;">${((Ya=this.series)==null?void 0:Ya.name)||""}</div>`,Ln+="</div>"}const Hn=((ms=(Us=(ua=this.points)==null?void 0:ua[0])==null?void 0:Us.point)==null?void 0:ms.originalTimestamp)||((da=this.point)==null?void 0:da.originalTimestamp),sr=Hn?Nu(Hn):String(this.x);return Ln+=`<div class="font-medium text-jp-2-gray-300" style="font-weight: 500; color: #9AA0A6; font-size: 12px; margin-top: 4px;">${sr}</div>`,Ln+="</div>",Ln+="</div>",Ln+="</div>",Ln+="</div>",Ln},xDateFormat:"%a, %d %B, %Y %H:%M"},series:dt.series},Ht={groupbyKeys:_t,timeColumn:Xe,metricColumns:[vt],cardinality:"TOP_5",showCardinality:!0},Fi={metric_name_db:vt,metric_label:vt.replace(/_/g," "),metric_type:Kn(vt)==="percentage"?"Rate":Kn(vt)==="volume"?"Volume":Kn(vt)==="latency"?"Latency":"Count"},ea={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,chartData:Ut,rawChartData:rt,groupbyConfig:Ht,selectedMetrics:Fi};j(Ii=>[...Ii,ea])}}else if(rt.length===1){const _t=Object.keys(it)[0];if(_t){const wt={metric:_t.replace(/_/g," "),value:it[_t]===null?"N/A":it[_t]},vt={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,singleStat:wt};j(dt=>[...dt,vt])}}else{const _t={id:(Date.now()+Math.random()).toString(),content:"",role:"assistant",timestamp:new Date,description:gt,tableData:rt};j(wt=>[...wt,_t])}}}}catch(St){console.error("Error parsing event data:",St)}});break}const Un=qt.decode(Cn,{stream:!0});Yt+=Un;const _a=Yt.split(`
685
685
 
@@ -720,8 +720,8 @@ Please choose files smaller than 6MB.`)}Ge.length>0&&ne(ft=>[...ft,...Ge]),pe.cu
720
720
  overflow-y: auto !important;
721
721
  padding-bottom: 100px !important;
722
722
  }
723
- `}),le.jsx(g4,{})]})]}):S.length===0?le.jsxs(le.Fragment,{children:[le.jsx(Sk,{message:(t==null?void 0:t.bannerDescription)||"",isVisible:E&&S.length===0,onClose:()=>X(!1),isCompact:!0}),le.jsx("div",{className:At["genius-chatbot-mobile-content"],children:le.jsx("div",{className:At["genius-chatbot-mobile-welcome"],children:le.jsxs("div",{className:At["genius-chatbot-mobile-branding"],children:[le.jsx("div",{className:At["genius-chatbot-mobile-logo-container"],children:le.jsx("div",{className:At["genius-chatbot-mobile-logo"],children:le.jsx("div",{className:At["genius-chatbot-mobile-logo-icon"],children:le.jsx(wS,{})})})}),le.jsx("div",{className:At["genius-chatbot-mobile-welcome-text"],children:le.jsxs("h2",{className:At["genius-chatbot-mobile-welcome-title"],children:["Meet Genius 👋",le.jsx("br",{}),le.jsx("span",{className:At["genius-chatbot-mobile-welcome-subtitle"],children:n})]})})]})})}),r.length>0&&le.jsx("div",{className:At["genius-chatbot-mobile-suggestions"],children:r.map((Re,ot)=>le.jsxs("button",{className:At["genius-chatbot-mobile-suggestion"],onClick:()=>Dr(Re),type:"button",children:[Re==="Weekly Updates"&&le.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le.jsx("path",{d:"M11.3333 2.66667H13.3333C13.687 2.66667 14.0261 2.80714 14.2761 3.05719C14.5262 3.30724 14.6667 3.64638 14.6667 4V13.3333C14.6667 13.687 14.5262 14.0261 14.2761 14.2761C14.0261 14.5262 13.687 14.6667 13.3333 14.6667H2.66667C2.31304 14.6667 1.97391 14.5262 1.72386 14.2761C1.47381 14.0261 1.33333 13.687 1.33333 13.3333V4C1.33333 3.64638 1.47381 3.30724 1.72386 3.05719C1.97391 2.80714 2.31304 2.66667 2.66667 2.66667H4.66667",stroke:"currentColor",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),le.jsx("path",{d:"M10.6667 1.33333V4M5.33333 1.33333V4M1.33333 6.66667H14.6667",stroke:"currentColor",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),le.jsx("span",{children:Re})]},ot))})]}):le.jsxs(le.Fragment,{children:[ne&&le.jsx("button",{className:At["genius-chatbot-mobile-scroll-button"],onClick:()=>{be.current=!1,tn(!0)},"aria-label":"Scroll to bottom",style:{position:"fixed",bottom:"90px",left:"50%",transform:"translateX(-50%)",borderRadius:"50%",padding:"8px",backgroundColor:"#fff",border:"2px solid #e1e1e1",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:100,outline:"none"},children:le.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:le.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 3C12.5523 3 13 3.44772 13 4V17.5858L17.2929 13.2929C17.6834 12.9024 18.3166 12.9024 18.7071 13.2929C19.0976 13.6834 19.0976 14.3166 18.7071 14.7071L12.7071 20.7071C12.3166 21.0976 11.6834 21.0976 11.2929 20.7071L5.29289 14.7071C4.90237 14.3166 4.90237 13.6834 5.29289 13.2929C5.68342 12.9024 6.31658 12.9024 6.70711 13.2929L11 17.5858V4C11 3.44772 11.4477 3 12 3Z",fill:"black"})})}),le.jsxs("div",{className:`${At["genius-chatbot-mobile-content"]} ${S.length>0?At["single-line"]:""}`,ref:me,onScroll:cn,children:[le.jsxs("div",{className:At["genius-chatbot-mobile-messages"],children:[S.map((Re,ot)=>Re.role==="assistant"?le.jsx(AT,{message:Re,showIcon:ot===0||S[ot-1].role!=="assistant",onTypingStateChange:A,onTypingUpdate:ci,skipAnimation:Re.isFromHistory||Re.skipAnimation,onRetry:xa,isLastMessage:!!Re.content&&ot===S.length-1&&!U,onDislike:()=>no(Re.id),endpoint:b,isMobile:!0,showCardinalityControl:!0},Re.id):le.jsx("div",{className:`${At["genius-dashboard-message"]} ${At[Re.role]}`,children:le.jsx("div",{className:At["genius-dashboard-message-bubble"],children:le.jsx("div",{className:At["genius-dashboard-message-content"],dangerouslySetInnerHTML:{__html:Re.content}})})},Re.id)),U&&le.jsxs("div",{className:`${At["genius-dashboard-message"]} ${At.assistant}`,children:[le.jsx("div",{className:At["genius-dashboard-assistant-icon"],children:le.jsx(_1,{})}),le.jsx("div",{className:At["genius-dashboard-thinking"],children:"Thinking"})]}),le.jsx("div",{ref:ye})]}),le.jsx("div",{ref:Ce,style:{height:"80px"}})]})]}),!J&&!m&&le.jsx("div",{className:`${At["genius-chatbot-mobile-input-section"]} ${S.length>0?At["single-line"]:""}`,children:le.jsxs("div",{className:`${At["genius-chatbot-mobile-input-container"]} ${S.length>0?At["single-line"]:""}`,children:[S.length>0?le.jsx("input",{ref:_e,type:"text",className:`${At["genius-chatbot-mobile-input"]} ${At["single-line-input"]}`,placeholder:i,value:O,onChange:Re=>w(Re.target.value),onKeyDown:pn,disabled:!1}):le.jsx("textarea",{ref:ke,className:At["genius-chatbot-mobile-input"],placeholder:i,value:O,onChange:Re=>w(Re.target.value),onKeyDown:pn,disabled:!1,rows:1}),le.jsxs("div",{className:`${At["genius-chatbot-mobile-input-row"]} ${S.length>0?At["single-line"]:""}`,children:[le.jsx("div",{style:{flex:1}}),le.jsxs("div",{className:At["genius-chatbot-mobile-input-actions"],children:[(t==null?void 0:t.showRCAToggle)===!0&&le.jsx("div",{className:At["genius-chatbot-mobile-rca-toggle-container"],children:le.jsxs("label",{className:At["genius-chatbot-mobile-rca-toggle-label"],children:[le.jsx("input",{type:"checkbox",checked:pe,onChange:Re=>ge(Re.target.checked),className:At["genius-chatbot-mobile-rca-toggle-input"],disabled:B||k}),le.jsx("span",{className:At["genius-chatbot-mobile-rca-toggle-slider"]}),le.jsx("span",{className:At["genius-chatbot-mobile-rca-toggle-text"],children:"RCA"})]})}),(t==null?void 0:t.showMicrophoneButton)!==!1&&le.jsx("button",{className:At["genius-chatbot-mobile-icon-button"],onClick:ui,"aria-label":"Voice input",type:"button",children:le.jsx(oD,{})}),B?le.jsx("button",{className:At["genius-chatbot-mobile-cancel-button"],onClick:qn,"aria-label":"Cancel",type:"button",children:le.jsx(vk,{})}):le.jsx("button",{className:At["genius-chatbot-mobile-send-button"],onClick:Sa,"aria-label":"Send message",type:"button",disabled:!O.trim()||k,children:le.jsx(qC,{})})]})]})]})})]})]})]})})},ln={"genius-chatbot-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-wrapper___hcV7q","genius-toggle-button":"genius-sdk__GeniusChatbot-module__genius-toggle-button___-dV4-","genius-chatbot-mobile-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-mobile-wrapper___19PVA","genius-voice-call-container":"genius-sdk__GeniusChatbot-module__genius-voice-call-container___csWeH","bottom-right":"genius-sdk__GeniusChatbot-module__bottom-right___1B1-1","bottom-left":"genius-sdk__GeniusChatbot-module__bottom-left___jW0dZ",center:"genius-sdk__GeniusChatbot-module__center___z23Ni","genius-chatbot-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-container___-1AXk",expanded:"genius-sdk__GeniusChatbot-module__expanded___egMCL","genius-chatbot-header":"genius-sdk__GeniusChatbot-module__genius-chatbot-header___KYNml","genius-chatbot-header-icons":"genius-sdk__GeniusChatbot-module__genius-chatbot-header-icons___eyLdP","genius-chatbot-icon-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-icon-button___nbVeQ","genius-chatbot-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-icon___JlAuk","genius-chatbot-body":"genius-sdk__GeniusChatbot-module__genius-chatbot-body___-0tRl","genius-chatbot-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-content___64G3h","genius-chatbot-branding":"genius-sdk__GeniusChatbot-module__genius-chatbot-branding___pISkM","genius-chatbot-logo-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo-container___7Gxbj","genius-chatbot-logo":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo___bcUEi","genius-chatbot-logo-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo-icon___vSlku","genius-chatbot-welcome":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome___uZmtS","genius-chatbot-welcome-title":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-title___-tIN4","genius-chatbot-welcome-emoji":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-emoji___zrXfE","genius-chatbot-welcome-subtitle":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-subtitle___ipNy2","genius-chatbot-messages-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-messages-container___lTB-Z","genius-chatbot-message":"genius-sdk__GeniusChatbot-module__genius-chatbot-message___5QQw9",user:"genius-sdk__GeniusChatbot-module__user___HfIkp",assistant:"genius-sdk__GeniusChatbot-module__assistant___ZGPHW","genius-chatbot-message-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-message-content___oW1RA","genius-chatbot-table-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-table-wrapper___fK97m","genius-chatbot-sources":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources___FeMnB","genius-chatbot-sources-header":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-header___faf7D","genius-chatbot-sources-chevron":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-chevron___UbDbJ","genius-chatbot-sources-list":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-list___R8Ido",slideIn:"genius-sdk__GeniusChatbot-module__slideIn___0VmGW","genius-chatbot-source-item":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-item___lgwoi","genius-chatbot-source-number":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-number___5MEOF","genius-dashboard-description":"genius-sdk__GeniusChatbot-module__genius-dashboard-description___PBOlN","genius-dashboard-value-pill":"genius-sdk__GeniusChatbot-module__genius-dashboard-value-pill___EH-fb","genius-chatbot-source-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-content___8DpLR","genius-chatbot-source-title":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-title___rmRJp","genius-chatbot-source-uri":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-uri___QZVuP","genius-chatbot-scroll-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-scroll-button___sHadA","genius-chatbot-input-section":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-section___qlp-I","genius-chatbot-suggestions":"genius-sdk__GeniusChatbot-module__genius-chatbot-suggestions___ewgwd","genius-chatbot-suggestion":"genius-sdk__GeniusChatbot-module__genius-chatbot-suggestion___Syi1o","genius-chatbot-input-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-container___U-16F","genius-chatbot-input-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-content___5qw6w","genius-chatbot-input-row":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-row___ZSuJF","genius-chatbot-input-actions":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-actions___EilGU","genius-chatbot-input":"genius-sdk__GeniusChatbot-module__genius-chatbot-input___xVIEY","genius-chatbot-send-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-send-button___GIS7-","genius-chatbot-send-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-send-icon___hFQPD"},Sw=({config:t={}})=>{const{apiKey:n="",baseUrl:i="",endpoints:r={},welcomeMessage:o="Your go-to for all payment related inquiries!",placeholder:u="Ask Genius",suggestions:d=["How to integrate?","Pricing Plan","Supported Gateways"],theme:h={},position:g="bottom-right",onMessage:y,onClose:b,onExpand:S,useStreaming:j=!0,variant:O="default",moduleName:w}=t,[B,Y]=je.useState(!1);je.useEffect(()=>{const ae=()=>{Y(window.innerWidth<=768)};return ae(),window.addEventListener("resize",ae),N4(),()=>{window.removeEventListener("resize",ae)}},[]),li.setOptions({breaks:!0,gfm:!0,pedantic:!1});const[U,v]=je.useState([]),[k,A]=je.useState(""),[D,M]=je.useState(!1),[I,K]=je.useState(!0),[q,z]=je.useState(!1),[R,G]=je.useState(new Set),[P,x]=je.useState(!1),T=je.useRef(null),L=je.useRef(null),E=je.useRef(null),X=je.useRef(!1),J=je.useRef(0),N=je.useRef(null),ie=()=>{if(!L.current)return!0;const{scrollTop:ae,scrollHeight:oe,clientHeight:de}=L.current;return oe-ae-de<100},ce=(ae=!1)=>{!L.current||!T.current||(ae||!X.current||ie())&&(T.current.scrollIntoView({behavior:"smooth",block:"end"}),X.current=!1)},m=()=>{L.current&&(N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ie()?(X.current=!1,x(!1)):(X.current=!0,x(!0))},100))};je.useEffect(()=>{U.length>J.current&&(J.current===0||!X.current)&&setTimeout(()=>ce(),100),J.current=U.length},[U]),je.useEffect(()=>{const ae=oe=>{oe.key==="Escape"&&W()};return document.addEventListener("keydown",ae),()=>{document.removeEventListener("keydown",ae),N.current&&clearTimeout(N.current)}},[]),je.useEffect(()=>{const ae=()=>{window.innerWidth<=768&&I&&K(!1)};return window.addEventListener("resize",ae),ae(),()=>{window.removeEventListener("resize",ae)}},[I]);const F=()=>{k.trim()||z(!0)},Q=()=>{z(!1)},H=async()=>{var de,pe;if(!k.trim()||D)return;const ae={id:Date.now().toString(),content:k,role:"user",timestamp:new Date};v(ge=>[...ge,ae]),A(""),M(!0),X.current=!1,setTimeout(()=>ce(!0),100),y&&y(ae);let oe;if(j&&r.stream)oe=r.stream;else if(!j&&r.chat)oe=r.chat;else if(i)oe=j?`${i}/chat/stream`:`${i}/chat`;else{const ge="https://genius.juspay.in";oe=j?`${ge}/chat/stream`:`${ge}/chat`}try{const ge={"Content-Type":"application/json",Accept:"text/event-stream"};n&&(ge.Authorization=`Bearer ${n}`);const ye=await fetch(oe,{method:"POST",headers:ge,body:JSON.stringify({message:ae.content,conversation_id:"demo-session",...w&&{moduleName:w}})});if(!ye.ok)throw new Error(`API request failed with status ${ye.status}`);if(j&&ye.body){console.log("Starting streaming response handling...");const _e=ye.body.getReader(),ke=new TextDecoder,Ce={id:(Date.now()+1).toString(),content:"",role:"assistant",timestamp:new Date,sources:[]};v(xe=>[...xe,Ce]);let me="",be=0;for(;;){const{done:xe,value:fe}=await _e.read();if(xe){console.log("Stream reading complete");break}const we=ke.decode(fe,{stream:!0});me+=we,console.log(`Received chunk ${++be}, buffer length: ${me.length}`);const Te=me.split(`
724
- `);me=Te.pop()||"";for(const Me of Te)if(Me.trim()!=="")if(Me.startsWith("data: ")){const Le=Me.slice(6);if(Le==="[DONE]"){console.log("Received [DONE] signal");continue}try{const De=JSON.parse(Le);if(console.log("Parsed SSE data:",De),De.text)Ce.content+=De.text,console.log(`Updated content, total length: ${Ce.content.length}`),v(Ie=>Ie.map(Ve=>Ve.id===Ce.id?{...Ve,content:Ce.content}:Ve));else if(De.type==="metadata"&&(De.metrics&&console.log("Response metrics:",De.metrics),De.grounding_metadata)){const Ie=[],Ve=new Set;De.grounding_metadata.forEach($e=>{var Qe;$e.title&&!Ve.has($e.title)&&(Ve.add($e.title),Ie.push({text:$e.text||((Qe=$e.rag_chunk)==null?void 0:Qe.text)||"",title:$e.title,uri:$e.uri||""}))}),Ce.sources=Ie,console.log(`Added ${Ie.length} sources`),v($e=>$e.map(Qe=>Qe.id===Ce.id?{...Qe,sources:Ce.sources}:Qe))}}catch(De){console.error("Error parsing SSE data:",De,"Line:",Me)}}else console.log("Non-data line:",Me)}}else{const _e=await ye.json(),ke=[];if((de=_e.grounding_metadata)!=null&&de.grounding_metadata){const me=new Set;_e.grounding_metadata.grounding_metadata.forEach(be=>{var xe;be.title&&!me.has(be.title)&&(me.add(be.title),ke.push({text:be.text||((xe=be.rag_chunk)==null?void 0:xe.text)||"",title:be.title,uri:be.uri||""}))})}const Ce={id:(Date.now()+1).toString(),content:_e.response||_e.message||"Sorry, I couldn't process that.",role:"assistant",timestamp:new Date,sources:ke};v(me=>[...me,Ce]),(pe=_e.grounding_metadata)!=null&&pe.metrics&&console.log("Response metrics:",_e.grounding_metadata.metrics)}}catch(ge){console.error("Error sending message:",ge);const ye={id:(Date.now()+1).toString(),content:"Sorry, I couldn't connect to the service. Please ensure the backend is running on port 8001.",role:"assistant",timestamp:new Date};v(_e=>[..._e,ye])}M(!1)},te=ae=>{var oe;A(ae),(oe=E.current)==null||oe.focus()},$=ae=>{ae.key==="Enter"&&!ae.shiftKey&&(ae.preventDefault(),H())},W=()=>{b&&b()},se=()=>{K(!I),S&&S()},ue=ae=>{G(oe=>{const de=new Set(oe);return de.has(ae)?de.delete(ae):de.add(ae),de})},ee=ae=>{let oe=li.parse(ae);return oe=oe.replace(/<table>/g,'<div class="genius-chatbot-table-wrapper"><table>').replace(/<\/table>/g,"</table></div>"),oe=oe.replace(/<a\s+href=/g,'<a target="_blank" rel="noopener noreferrer" href='),{__html:oe}},ne={...h};return q?le.jsx(XC,{onEnd:Q}):O==="dashboard"?B?le.jsx(I4,{config:t}):le.jsx(wU,{config:t}):le.jsx(wc,{children:le.jsx("div",{className:`${ln["genius-chatbot-wrapper"]} ${ln[g]} ${I?ln.expanded:""}`,children:le.jsxs("div",{className:ln["genius-chatbot-container"],style:ne,children:[le.jsxs("div",{className:ln["genius-chatbot-header"],children:[le.jsxs("div",{className:ln["genius-chatbot-header-icons"],children:[le.jsx("button",{className:ln["genius-chatbot-icon-button"],onClick:se,"aria-label":I?"Collapse chat":"Expand chat",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:I?le.jsx(sD,{}):le.jsx(aD,{})})}),le.jsx("button",{className:ln["genius-chatbot-icon-button"],"aria-label":"View history",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:le.jsx(SS,{})})})]}),le.jsx("button",{className:ln["genius-chatbot-icon-button"],onClick:W,"aria-label":"Close chat",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:le.jsx(_S,{})})})]}),le.jsx("div",{className:ln["genius-chatbot-body"],children:le.jsxs("div",{className:ln["genius-chatbot-content"],children:[U.length===0?le.jsxs("div",{className:ln["genius-chatbot-branding"],children:[le.jsx("div",{className:ln["genius-chatbot-logo-container"],children:le.jsx("div",{className:ln["genius-chatbot-logo"],children:le.jsx("div",{className:ln["genius-chatbot-logo-icon"],children:le.jsx(wS,{})})})}),le.jsxs("div",{className:ln["genius-chatbot-welcome"],children:[le.jsxs("h2",{className:ln["genius-chatbot-welcome-title"],children:["Meet Genius",le.jsx("span",{className:ln["genius-chatbot-welcome-emoji"],children:"👋"})]}),le.jsx("p",{className:ln["genius-chatbot-welcome-subtitle"],children:o})]})]}):le.jsxs("div",{className:ln["genius-chatbot-messages-container"],ref:L,onScroll:m,children:[U.map(ae=>le.jsxs("div",{className:`${ln["genius-chatbot-message"]} ${ln[ae.role]}`,children:[le.jsx("div",{className:ln["genius-chatbot-message-content"],dangerouslySetInnerHTML:ee(ae.content)}),ae.role==="assistant"&&ae.sources&&ae.sources.length>0&&le.jsxs("div",{className:ln["genius-chatbot-sources"],children:[le.jsxs("button",{className:ln["genius-chatbot-sources-header"],onClick:()=>ue(ae.id),type:"button",children:[le.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:R.has(ae.id)?"rotate(45deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:le.jsx("path",{d:"M6 1V11M1 6H11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),le.jsxs("span",{children:["Sources (",ae.sources.length,")"]}),le.jsx("svg",{className:ln["genius-chatbot-sources-chevron"],width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:R.has(ae.id)?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:le.jsx("path",{d:"M3.5 5.25L7 8.75L10.5 5.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),R.has(ae.id)&&le.jsx("div",{className:ln["genius-chatbot-sources-list"],children:ae.sources.map((oe,de)=>le.jsxs("div",{className:ln["genius-chatbot-source-item"],children:[le.jsx("div",{className:ln["genius-chatbot-source-number"],children:de+1}),le.jsxs("div",{className:ln["genius-chatbot-source-content"],children:[le.jsx("div",{className:ln["genius-chatbot-source-title"],children:oe.title.replace(/_/g," ").replace(".md","")}),oe.uri&&le.jsxs("div",{className:ln["genius-chatbot-source-uri"],children:[". ",oe.uri.split("/").pop()]})]})]},de))})]})]},ae.id)),D&&le.jsx("div",{className:`${ln["genius-chatbot-message"]} ${ln.assistant}`,children:le.jsx("span",{children:"Thinking..."})}),le.jsx("div",{ref:T})]}),P&&le.jsx("button",{className:ln["genius-chatbot-scroll-button"],onClick:()=>{X.current=!1,ce(!0)},"aria-label":"Scroll to bottom",children:le.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le.jsx("path",{d:"M10 14L6 10L7.4 8.6L10 11.2L12.6 8.6L14 10L10 14Z",fill:"currentColor"}),le.jsx("path",{d:"M10 10L6 6L7.4 4.6L10 7.2L12.6 4.6L14 6L10 10Z",fill:"currentColor"})]})}),le.jsxs("div",{className:ln["genius-chatbot-input-section"],children:[U.length===0&&d.length>0&&le.jsx("div",{className:ln["genius-chatbot-suggestions"],children:d.map((ae,oe)=>le.jsx("button",{className:ln["genius-chatbot-suggestion"],onClick:()=>te(ae),type:"button",children:ae},oe))}),le.jsx("div",{className:ln["genius-chatbot-input-container"],children:le.jsxs("div",{className:ln["genius-chatbot-input-content"],children:[le.jsx("div",{className:ln["genius-chatbot-input-row"],children:le.jsx("input",{ref:E,type:"text",className:ln["genius-chatbot-input"],placeholder:u,value:k,onChange:ae=>A(ae.target.value),onKeyDown:$,disabled:D})}),le.jsx("div",{className:ln["genius-chatbot-input-actions"],children:le.jsx("button",{className:ln["genius-chatbot-send-button"],onClick:k.trim()?H:F,"aria-label":k.trim()?"Send message":"Voice input",type:"button",children:le.jsx("div",{className:ln["genius-chatbot-send-icon"],children:k.trim()?le.jsx(qC,{}):le.jsx(rD,{})})})})]})})]})]})})]})})})},U4=je.createContext(void 0),H4=()=>{const t=je.useContext(U4);if(!t)throw new Error("useGeniusChatbot must be used within a GeniusChatbotProvider");return t},TU=({children:t,config:n={},defaultOpen:i=!1})=>{const[r,o]=je.useState(i),u=()=>o(!0),d=()=>o(!1),h=()=>o(!r),g=()=>{d(),n.onClose&&n.onClose()};return le.jsxs(U4.Provider,{value:{isOpen:r,openChatbot:u,closeChatbot:d,toggleChatbot:h},children:[t,r&&le.jsx(Sw,{config:{...n,onClose:g}})]})},_w={"genius-toggle-button":"genius-sdk__GeniusToggle-module__genius-toggle-button___-vqMH","genius-toggle-text":"genius-sdk__GeniusToggle-module__genius-toggle-text___t-WaO","genius-toggle-logo":"genius-sdk__GeniusToggle-module__genius-toggle-logo___NwizJ"},AU=()=>le.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:le.jsxs("g",{children:[le.jsx("path",{d:"M8 1C8 1.01048 8 1.021 8 1.03141C8.00279 5.97901 9.43359 8 15 8C9.43359 8 8.00279 10.021 8 14.9686C8 14.979 8 14.9895 8 15C8 14.9895 8 14.979 8 14.9686C7.99721 10.021 6.56641 8 1 8C6.56641 8 7.99721 5.97901 8 1.03141C8 1.021 8 1.01048 8 1Z",fill:"currentColor"}),le.jsx("path",{d:"M8 1C8.00284 5.95317 6.59995 8 1 8C6.59995 8 8.00284 10.0468 8 15C7.99716 10.0468 9.39995 8 15 8C9.39995 8 7.99716 5.95317 8 1Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})}),MU=({position:t="bottom-right",offsetX:n=20,offsetY:i=20})=>{const{openChatbot:r,isOpen:o}=H4(),u={position:"fixed",...t.includes("bottom")?{bottom:i}:{top:i},...t.includes("right")?{right:n}:{left:n}};return o?null:le.jsx(wc,{children:le.jsxs("button",{className:_w["genius-toggle-button"],onClick:r,"aria-label":"Open Genius chatbot",style:u,children:[le.jsx("span",{className:_w["genius-toggle-text"],children:"Ask Genius"}),le.jsx("div",{className:_w["genius-toggle-logo"],children:le.jsx(AU,{})})]})})};var Pv={exports:{}},Ey={},Bv={exports:{}},ww={};/**
723
+ `}),le.jsx(g4,{})]})]}):S.length===0?le.jsxs(le.Fragment,{children:[le.jsx(Sk,{message:(t==null?void 0:t.bannerDescription)||"",isVisible:E&&S.length===0,onClose:()=>X(!1),isCompact:!0}),le.jsx("div",{className:At["genius-chatbot-mobile-content"],children:le.jsx("div",{className:At["genius-chatbot-mobile-welcome"],children:le.jsxs("div",{className:At["genius-chatbot-mobile-branding"],children:[le.jsx("div",{className:At["genius-chatbot-mobile-logo-container"],children:le.jsx("div",{className:At["genius-chatbot-mobile-logo"],children:le.jsx("div",{className:At["genius-chatbot-mobile-logo-icon"],children:le.jsx(wS,{})})})}),le.jsx("div",{className:At["genius-chatbot-mobile-welcome-text"],children:le.jsxs("h2",{className:At["genius-chatbot-mobile-welcome-title"],children:["Meet Genius 👋",le.jsx("br",{}),le.jsx("span",{className:At["genius-chatbot-mobile-welcome-subtitle"],children:n})]})})]})})}),r.length>0&&le.jsx("div",{className:At["genius-chatbot-mobile-suggestions"],children:r.map((Re,ot)=>le.jsxs("button",{className:At["genius-chatbot-mobile-suggestion"],onClick:()=>Dr(Re),type:"button",children:[Re==="Weekly Updates"&&le.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le.jsx("path",{d:"M11.3333 2.66667H13.3333C13.687 2.66667 14.0261 2.80714 14.2761 3.05719C14.5262 3.30724 14.6667 3.64638 14.6667 4V13.3333C14.6667 13.687 14.5262 14.0261 14.2761 14.2761C14.0261 14.5262 13.687 14.6667 13.3333 14.6667H2.66667C2.31304 14.6667 1.97391 14.5262 1.72386 14.2761C1.47381 14.0261 1.33333 13.687 1.33333 13.3333V4C1.33333 3.64638 1.47381 3.30724 1.72386 3.05719C1.97391 2.80714 2.31304 2.66667 2.66667 2.66667H4.66667",stroke:"currentColor",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"}),le.jsx("path",{d:"M10.6667 1.33333V4M5.33333 1.33333V4M1.33333 6.66667H14.6667",stroke:"currentColor",strokeWidth:"1.33333",strokeLinecap:"round",strokeLinejoin:"round"})]}),le.jsx("span",{children:Re})]},ot))})]}):le.jsxs(le.Fragment,{children:[ne&&le.jsx("button",{className:At["genius-chatbot-mobile-scroll-button"],onClick:()=>{be.current=!1,tn(!0)},"aria-label":"Scroll to bottom",style:{position:"fixed",bottom:"90px",left:"50%",transform:"translateX(-50%)",borderRadius:"50%",padding:"8px",backgroundColor:"#fff",border:"2px solid #e1e1e1",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:100,outline:"none"},children:le.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:le.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 3C12.5523 3 13 3.44772 13 4V17.5858L17.2929 13.2929C17.6834 12.9024 18.3166 12.9024 18.7071 13.2929C19.0976 13.6834 19.0976 14.3166 18.7071 14.7071L12.7071 20.7071C12.3166 21.0976 11.6834 21.0976 11.2929 20.7071L5.29289 14.7071C4.90237 14.3166 4.90237 13.6834 5.29289 13.2929C5.68342 12.9024 6.31658 12.9024 6.70711 13.2929L11 17.5858V4C11 3.44772 11.4477 3 12 3Z",fill:"black"})})}),le.jsxs("div",{className:`${At["genius-chatbot-mobile-content"]} ${S.length>0?At["single-line"]:""}`,ref:me,onScroll:cn,children:[le.jsxs("div",{className:At["genius-chatbot-mobile-messages"],children:[S.map((Re,ot)=>Re.role==="assistant"?le.jsx(AT,{message:Re,showIcon:ot===0||S[ot-1].role!=="assistant",onTypingStateChange:A,onTypingUpdate:ci,skipAnimation:Re.isFromHistory||Re.skipAnimation,onRetry:xa,isLastMessage:!!Re.content&&ot===S.length-1&&!U,onDislike:()=>no(Re.id),endpoint:b,isMobile:!0,showCardinalityControl:!0},Re.id):le.jsx("div",{className:`${At["genius-dashboard-message"]} ${At[Re.role]}`,children:le.jsx("div",{className:At["genius-dashboard-message-bubble"],children:le.jsx("div",{className:At["genius-dashboard-message-content"],dangerouslySetInnerHTML:{__html:Re.content}})})},Re.id)),U&&le.jsxs("div",{className:`${At["genius-dashboard-message"]} ${At.assistant}`,children:[le.jsx("div",{className:At["genius-dashboard-assistant-icon"],children:le.jsx(_1,{})}),le.jsx("div",{className:At["genius-dashboard-thinking"],children:"Thinking"})]}),le.jsx("div",{ref:ye})]}),le.jsx("div",{ref:Ce,style:{height:"80px"}})]})]}),!J&&!m&&le.jsx("div",{className:`${At["genius-chatbot-mobile-input-section"]} ${S.length>0?At["single-line"]:""}`,children:le.jsxs("div",{className:`${At["genius-chatbot-mobile-input-container"]} ${S.length>0?At["single-line"]:""}`,children:[S.length>0?le.jsx("input",{ref:_e,type:"text",className:`${At["genius-chatbot-mobile-input"]} ${At["single-line-input"]}`,placeholder:i,value:O,onChange:Re=>w(Re.target.value),onKeyDown:pn,disabled:!1}):le.jsx("textarea",{ref:ke,className:At["genius-chatbot-mobile-input"],placeholder:i,value:O,onChange:Re=>w(Re.target.value),onKeyDown:pn,disabled:!1,rows:1}),le.jsxs("div",{className:`${At["genius-chatbot-mobile-input-row"]} ${S.length>0?At["single-line"]:""}`,children:[le.jsx("div",{style:{flex:1}}),le.jsxs("div",{className:At["genius-chatbot-mobile-input-actions"],children:[(t==null?void 0:t.showRCAToggle)===!0&&le.jsx("div",{className:At["genius-chatbot-mobile-rca-toggle-container"],children:le.jsxs("label",{className:At["genius-chatbot-mobile-rca-toggle-label"],children:[le.jsx("input",{type:"checkbox",checked:pe,onChange:Re=>ge(Re.target.checked),className:At["genius-chatbot-mobile-rca-toggle-input"],disabled:B||k}),le.jsx("span",{className:At["genius-chatbot-mobile-rca-toggle-slider"]}),le.jsx("span",{className:At["genius-chatbot-mobile-rca-toggle-text"],children:"RCA"})]})}),(t==null?void 0:t.showMicrophoneButton)!==!1&&le.jsx("button",{className:At["genius-chatbot-mobile-icon-button"],onClick:ui,"aria-label":"Voice input",type:"button",children:le.jsx(oD,{})}),B?le.jsx("button",{className:At["genius-chatbot-mobile-cancel-button"],onClick:qn,"aria-label":"Cancel",type:"button",children:le.jsx(vk,{})}):le.jsx("button",{className:At["genius-chatbot-mobile-send-button"],onClick:Sa,"aria-label":"Send message",type:"button",disabled:!O.trim()||k,children:le.jsx(qC,{})})]})]})]})})]})]})]})})},ln={"genius-chatbot-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-wrapper___hcV7q","genius-toggle-button":"genius-sdk__GeniusChatbot-module__genius-toggle-button___-dV4-","genius-chatbot-mobile-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-mobile-wrapper___19PVA","genius-voice-call-container":"genius-sdk__GeniusChatbot-module__genius-voice-call-container___csWeH","bottom-right":"genius-sdk__GeniusChatbot-module__bottom-right___1B1-1","bottom-left":"genius-sdk__GeniusChatbot-module__bottom-left___jW0dZ",center:"genius-sdk__GeniusChatbot-module__center___z23Ni","genius-chatbot-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-container___-1AXk",expanded:"genius-sdk__GeniusChatbot-module__expanded___egMCL","genius-chatbot-header":"genius-sdk__GeniusChatbot-module__genius-chatbot-header___KYNml","genius-chatbot-header-icons":"genius-sdk__GeniusChatbot-module__genius-chatbot-header-icons___eyLdP","genius-chatbot-icon-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-icon-button___nbVeQ","genius-chatbot-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-icon___JlAuk","genius-chatbot-body":"genius-sdk__GeniusChatbot-module__genius-chatbot-body___-0tRl","genius-chatbot-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-content___64G3h","genius-chatbot-branding":"genius-sdk__GeniusChatbot-module__genius-chatbot-branding___pISkM","genius-chatbot-logo-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo-container___7Gxbj","genius-chatbot-logo":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo___bcUEi","genius-chatbot-logo-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-logo-icon___vSlku","genius-chatbot-welcome":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome___uZmtS","genius-chatbot-welcome-title":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-title___-tIN4","genius-chatbot-welcome-emoji":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-emoji___zrXfE","genius-chatbot-welcome-subtitle":"genius-sdk__GeniusChatbot-module__genius-chatbot-welcome-subtitle___ipNy2","genius-chatbot-messages-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-messages-container___lTB-Z","genius-chatbot-message":"genius-sdk__GeniusChatbot-module__genius-chatbot-message___5QQw9",user:"genius-sdk__GeniusChatbot-module__user___HfIkp",assistant:"genius-sdk__GeniusChatbot-module__assistant___ZGPHW","genius-chatbot-message-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-message-content___oW1RA","genius-chatbot-table-wrapper":"genius-sdk__GeniusChatbot-module__genius-chatbot-table-wrapper___fK97m","genius-chatbot-sources":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources___FeMnB","genius-chatbot-sources-header":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-header___faf7D","genius-chatbot-sources-chevron":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-chevron___UbDbJ","genius-chatbot-sources-list":"genius-sdk__GeniusChatbot-module__genius-chatbot-sources-list___R8Ido",slideIn:"genius-sdk__GeniusChatbot-module__slideIn___0VmGW","genius-chatbot-source-item":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-item___lgwoi","genius-chatbot-source-number":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-number___5MEOF","genius-dashboard-description":"genius-sdk__GeniusChatbot-module__genius-dashboard-description___PBOlN","genius-dashboard-value-pill":"genius-sdk__GeniusChatbot-module__genius-dashboard-value-pill___EH-fb","genius-chatbot-source-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-content___8DpLR","genius-chatbot-source-title":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-title___rmRJp","genius-chatbot-source-uri":"genius-sdk__GeniusChatbot-module__genius-chatbot-source-uri___QZVuP","genius-chatbot-scroll-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-scroll-button___sHadA","genius-chatbot-input-section":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-section___qlp-I","genius-chatbot-suggestions":"genius-sdk__GeniusChatbot-module__genius-chatbot-suggestions___ewgwd","genius-chatbot-suggestion":"genius-sdk__GeniusChatbot-module__genius-chatbot-suggestion___Syi1o","genius-chatbot-input-container":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-container___U-16F","genius-chatbot-input-content":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-content___5qw6w","genius-chatbot-input-row":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-row___ZSuJF","genius-chatbot-input-actions":"genius-sdk__GeniusChatbot-module__genius-chatbot-input-actions___EilGU","genius-chatbot-input":"genius-sdk__GeniusChatbot-module__genius-chatbot-input___xVIEY","genius-chatbot-send-button":"genius-sdk__GeniusChatbot-module__genius-chatbot-send-button___GIS7-","genius-chatbot-send-icon":"genius-sdk__GeniusChatbot-module__genius-chatbot-send-icon___hFQPD"},Sw=({config:t={}})=>{const{apiKey:n="",baseUrl:i="",endpoints:r={},welcomeMessage:o="Your go-to for all payment related inquiries!",placeholder:u="Ask Genius",suggestions:d=["How to integrate?","Pricing Plan","Supported Gateways"],theme:h={},position:g="bottom-right",onMessage:y,onClose:b,onExpand:S,useStreaming:j=!0,variant:O="default",moduleName:w}=t,[B,Y]=je.useState(!1);je.useEffect(()=>{const ae=()=>{Y(window.innerWidth<=768)};return ae(),window.addEventListener("resize",ae),N4(),()=>{window.removeEventListener("resize",ae)}},[]),li.setOptions({breaks:!0,gfm:!0,pedantic:!1});const[U,v]=je.useState([]),[k,A]=je.useState(""),[D,M]=je.useState(!1),[I,K]=je.useState(!0),[q,z]=je.useState(!1),[R,G]=je.useState(new Set),[P,x]=je.useState(!1),T=je.useRef(null),L=je.useRef(null),E=je.useRef(null),X=je.useRef(!1),J=je.useRef(0),N=je.useRef(null),ie=()=>{if(!L.current)return!0;const{scrollTop:ae,scrollHeight:oe,clientHeight:de}=L.current;return oe-ae-de<100},ce=(ae=!1)=>{!L.current||!T.current||(ae||!X.current||ie())&&(T.current.scrollIntoView({behavior:"smooth",block:"end"}),X.current=!1)},m=()=>{L.current&&(N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ie()?(X.current=!1,x(!1)):(X.current=!0,x(!0))},100))};je.useEffect(()=>{U.length>J.current&&(J.current===0||!X.current)&&setTimeout(()=>ce(),100),J.current=U.length},[U]),je.useEffect(()=>{const ae=oe=>{oe.key==="Escape"&&W()};return document.addEventListener("keydown",ae),()=>{document.removeEventListener("keydown",ae),N.current&&clearTimeout(N.current)}},[]),je.useEffect(()=>{const ae=()=>{window.innerWidth<=768&&I&&K(!1)};return window.addEventListener("resize",ae),ae(),()=>{window.removeEventListener("resize",ae)}},[I]);const F=()=>{k.trim()||z(!0)},Q=()=>{z(!1)},H=async()=>{var de,pe;if(!k.trim()||D)return;t.onAnalyticsEvent&&U.length===0&&t.onAnalyticsEvent("input_submit",{action:"Submit",actionName:"Genius Input Submit",featureName:"Genius",component:"GeniusChatbot",inputType:"welcome_screen"});const ae={id:Date.now().toString(),content:k,role:"user",timestamp:new Date};v(ge=>[...ge,ae]),A(""),M(!0),X.current=!1,setTimeout(()=>ce(!0),100),y&&y(ae);let oe;if(j&&r.stream)oe=r.stream;else if(!j&&r.chat)oe=r.chat;else if(i)oe=j?`${i}/chat/stream`:`${i}/chat`;else{const ge="https://genius.juspay.in";oe=j?`${ge}/chat/stream`:`${ge}/chat`}try{const ge={"Content-Type":"application/json",Accept:"text/event-stream"};n&&(ge.Authorization=`Bearer ${n}`);const ye=await fetch(oe,{method:"POST",headers:ge,body:JSON.stringify({message:ae.content,conversation_id:"demo-session",...w&&{moduleName:w}})});if(!ye.ok)throw new Error(`API request failed with status ${ye.status}`);if(j&&ye.body){console.log("Starting streaming response handling...");const _e=ye.body.getReader(),ke=new TextDecoder,Ce={id:(Date.now()+1).toString(),content:"",role:"assistant",timestamp:new Date,sources:[]};v(xe=>[...xe,Ce]);let me="",be=0;for(;;){const{done:xe,value:fe}=await _e.read();if(xe){console.log("Stream reading complete");break}const we=ke.decode(fe,{stream:!0});me+=we,console.log(`Received chunk ${++be}, buffer length: ${me.length}`);const Te=me.split(`
724
+ `);me=Te.pop()||"";for(const Me of Te)if(Me.trim()!=="")if(Me.startsWith("data: ")){const Le=Me.slice(6);if(Le==="[DONE]"){console.log("Received [DONE] signal");continue}try{const De=JSON.parse(Le);if(console.log("Parsed SSE data:",De),De.text)Ce.content+=De.text,console.log(`Updated content, total length: ${Ce.content.length}`),v(Ie=>Ie.map(Ve=>Ve.id===Ce.id?{...Ve,content:Ce.content}:Ve));else if(De.type==="metadata"&&(De.metrics&&console.log("Response metrics:",De.metrics),De.grounding_metadata)){const Ie=[],Ve=new Set;De.grounding_metadata.forEach($e=>{var Qe;$e.title&&!Ve.has($e.title)&&(Ve.add($e.title),Ie.push({text:$e.text||((Qe=$e.rag_chunk)==null?void 0:Qe.text)||"",title:$e.title,uri:$e.uri||""}))}),Ce.sources=Ie,console.log(`Added ${Ie.length} sources`),v($e=>$e.map(Qe=>Qe.id===Ce.id?{...Qe,sources:Ce.sources}:Qe))}}catch(De){console.error("Error parsing SSE data:",De,"Line:",Me)}}else console.log("Non-data line:",Me)}}else{const _e=await ye.json(),ke=[];if((de=_e.grounding_metadata)!=null&&de.grounding_metadata){const me=new Set;_e.grounding_metadata.grounding_metadata.forEach(be=>{var xe;be.title&&!me.has(be.title)&&(me.add(be.title),ke.push({text:be.text||((xe=be.rag_chunk)==null?void 0:xe.text)||"",title:be.title,uri:be.uri||""}))})}const Ce={id:(Date.now()+1).toString(),content:_e.response||_e.message||"Sorry, I couldn't process that.",role:"assistant",timestamp:new Date,sources:ke};v(me=>[...me,Ce]),(pe=_e.grounding_metadata)!=null&&pe.metrics&&console.log("Response metrics:",_e.grounding_metadata.metrics)}}catch(ge){console.error("Error sending message:",ge);const ye={id:(Date.now()+1).toString(),content:"Sorry, I couldn't connect to the service. Please ensure the backend is running on port 8001.",role:"assistant",timestamp:new Date};v(_e=>[..._e,ye])}M(!1)},te=ae=>{var oe;A(ae),(oe=E.current)==null||oe.focus()},$=ae=>{ae.key==="Enter"&&!ae.shiftKey&&(ae.preventDefault(),H())},W=()=>{b&&b()},se=()=>{K(!I),S&&S()},ue=ae=>{G(oe=>{const de=new Set(oe);return de.has(ae)?de.delete(ae):de.add(ae),de})},ee=ae=>{let oe=li.parse(ae);return oe=oe.replace(/<table>/g,'<div class="genius-chatbot-table-wrapper"><table>').replace(/<\/table>/g,"</table></div>"),oe=oe.replace(/<a\s+href=/g,'<a target="_blank" rel="noopener noreferrer" href='),{__html:oe}},ne={...h};return q?le.jsx(XC,{onEnd:Q}):O==="dashboard"?B?le.jsx(I4,{config:t}):le.jsx(wU,{config:t}):le.jsx(wc,{children:le.jsx("div",{className:`${ln["genius-chatbot-wrapper"]} ${ln[g]} ${I?ln.expanded:""}`,children:le.jsxs("div",{className:ln["genius-chatbot-container"],style:ne,children:[le.jsxs("div",{className:ln["genius-chatbot-header"],children:[le.jsxs("div",{className:ln["genius-chatbot-header-icons"],children:[le.jsx("button",{className:ln["genius-chatbot-icon-button"],onClick:se,"aria-label":I?"Collapse chat":"Expand chat",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:I?le.jsx(sD,{}):le.jsx(aD,{})})}),le.jsx("button",{className:ln["genius-chatbot-icon-button"],"aria-label":"View history",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:le.jsx(SS,{})})})]}),le.jsx("button",{className:ln["genius-chatbot-icon-button"],onClick:W,"aria-label":"Close chat",children:le.jsx("div",{className:ln["genius-chatbot-icon"],children:le.jsx(_S,{})})})]}),le.jsx("div",{className:ln["genius-chatbot-body"],children:le.jsxs("div",{className:ln["genius-chatbot-content"],children:[U.length===0?le.jsxs("div",{className:ln["genius-chatbot-branding"],children:[le.jsx("div",{className:ln["genius-chatbot-logo-container"],children:le.jsx("div",{className:ln["genius-chatbot-logo"],children:le.jsx("div",{className:ln["genius-chatbot-logo-icon"],children:le.jsx(wS,{})})})}),le.jsxs("div",{className:ln["genius-chatbot-welcome"],children:[le.jsxs("h2",{className:ln["genius-chatbot-welcome-title"],children:["Meet Genius",le.jsx("span",{className:ln["genius-chatbot-welcome-emoji"],children:"👋"})]}),le.jsx("p",{className:ln["genius-chatbot-welcome-subtitle"],children:o})]})]}):le.jsxs("div",{className:ln["genius-chatbot-messages-container"],ref:L,onScroll:m,children:[U.map(ae=>le.jsxs("div",{className:`${ln["genius-chatbot-message"]} ${ln[ae.role]}`,children:[le.jsx("div",{className:ln["genius-chatbot-message-content"],dangerouslySetInnerHTML:ee(ae.content)}),ae.role==="assistant"&&ae.sources&&ae.sources.length>0&&le.jsxs("div",{className:ln["genius-chatbot-sources"],children:[le.jsxs("button",{className:ln["genius-chatbot-sources-header"],onClick:()=>ue(ae.id),type:"button",children:[le.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:R.has(ae.id)?"rotate(45deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:le.jsx("path",{d:"M6 1V11M1 6H11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),le.jsxs("span",{children:["Sources (",ae.sources.length,")"]}),le.jsx("svg",{className:ln["genius-chatbot-sources-chevron"],width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:R.has(ae.id)?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:le.jsx("path",{d:"M3.5 5.25L7 8.75L10.5 5.25",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),R.has(ae.id)&&le.jsx("div",{className:ln["genius-chatbot-sources-list"],children:ae.sources.map((oe,de)=>le.jsxs("div",{className:ln["genius-chatbot-source-item"],children:[le.jsx("div",{className:ln["genius-chatbot-source-number"],children:de+1}),le.jsxs("div",{className:ln["genius-chatbot-source-content"],children:[le.jsx("div",{className:ln["genius-chatbot-source-title"],children:oe.title.replace(/_/g," ").replace(".md","")}),oe.uri&&le.jsxs("div",{className:ln["genius-chatbot-source-uri"],children:[". ",oe.uri.split("/").pop()]})]})]},de))})]})]},ae.id)),D&&le.jsx("div",{className:`${ln["genius-chatbot-message"]} ${ln.assistant}`,children:le.jsx("span",{children:"Thinking..."})}),le.jsx("div",{ref:T})]}),P&&le.jsx("button",{className:ln["genius-chatbot-scroll-button"],onClick:()=>{X.current=!1,ce(!0)},"aria-label":"Scroll to bottom",children:le.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le.jsx("path",{d:"M10 14L6 10L7.4 8.6L10 11.2L12.6 8.6L14 10L10 14Z",fill:"currentColor"}),le.jsx("path",{d:"M10 10L6 6L7.4 4.6L10 7.2L12.6 4.6L14 6L10 10Z",fill:"currentColor"})]})}),le.jsxs("div",{className:ln["genius-chatbot-input-section"],children:[U.length===0&&d.length>0&&le.jsx("div",{className:ln["genius-chatbot-suggestions"],children:d.map((ae,oe)=>le.jsx("button",{className:ln["genius-chatbot-suggestion"],onClick:()=>te(ae),type:"button",children:ae},oe))}),le.jsx("div",{className:ln["genius-chatbot-input-container"],children:le.jsxs("div",{className:ln["genius-chatbot-input-content"],children:[le.jsx("div",{className:ln["genius-chatbot-input-row"],children:le.jsx("input",{ref:E,type:"text",className:ln["genius-chatbot-input"],placeholder:u,value:k,onChange:ae=>A(ae.target.value),onKeyDown:$,disabled:D})}),le.jsx("div",{className:ln["genius-chatbot-input-actions"],children:le.jsx("button",{className:ln["genius-chatbot-send-button"],onClick:k.trim()?H:F,"aria-label":k.trim()?"Send message":"Voice input",type:"button",children:le.jsx("div",{className:ln["genius-chatbot-send-icon"],children:k.trim()?le.jsx(qC,{}):le.jsx(rD,{})})})})]})})]})]})})]})})})},U4=je.createContext(void 0),H4=()=>{const t=je.useContext(U4);if(!t)throw new Error("useGeniusChatbot must be used within a GeniusChatbotProvider");return t},TU=({children:t,config:n={},defaultOpen:i=!1})=>{const[r,o]=je.useState(i),u=()=>o(!0),d=()=>o(!1),h=()=>o(!r),g=()=>{d(),n.onClose&&n.onClose()};return le.jsxs(U4.Provider,{value:{isOpen:r,openChatbot:u,closeChatbot:d,toggleChatbot:h,config:n},children:[t,r&&le.jsx(Sw,{config:{...n,onClose:g}})]})},_w={"genius-toggle-button":"genius-sdk__GeniusToggle-module__genius-toggle-button___-vqMH","genius-toggle-text":"genius-sdk__GeniusToggle-module__genius-toggle-text___t-WaO","genius-toggle-logo":"genius-sdk__GeniusToggle-module__genius-toggle-logo___NwizJ"},AU=()=>le.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:le.jsxs("g",{children:[le.jsx("path",{d:"M8 1C8 1.01048 8 1.021 8 1.03141C8.00279 5.97901 9.43359 8 15 8C9.43359 8 8.00279 10.021 8 14.9686C8 14.979 8 14.9895 8 15C8 14.9895 8 14.979 8 14.9686C7.99721 10.021 6.56641 8 1 8C6.56641 8 7.99721 5.97901 8 1.03141C8 1.021 8 1.01048 8 1Z",fill:"currentColor"}),le.jsx("path",{d:"M8 1C8.00284 5.95317 6.59995 8 1 8C6.59995 8 8.00284 10.0468 8 15C7.99716 10.0468 9.39995 8 15 8C9.39995 8 7.99716 5.95317 8 1Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})}),MU=({position:t="bottom-right",offsetX:n=20,offsetY:i=20})=>{const{openChatbot:r,isOpen:o,config:u}=H4(),d={position:"fixed",...t.includes("bottom")?{bottom:i}:{top:i},...t.includes("right")?{right:n}:{left:n}};if(o)return null;const h=()=>{u!=null&&u.onAnalyticsEvent&&u.onAnalyticsEvent("button_click",{action:"Click",actionName:"Genius Button Click web",featureName:"Genius",component:"GeniusToggle"}),r()};return le.jsx(wc,{children:le.jsxs("button",{className:_w["genius-toggle-button"],onClick:h,"aria-label":"Open Genius chatbot",style:d,children:[le.jsx("span",{className:_w["genius-toggle-text"],children:"Ask Genius"}),le.jsx("div",{className:_w["genius-toggle-logo"],children:le.jsx(AU,{})})]})})};var Pv={exports:{}},Ey={},Bv={exports:{}},ww={};/**
725
725
  * @license React
726
726
  * scheduler.production.js
727
727
  *