@bikdotai/bik-component-library 0.0.719-beta.1 → 0.0.720-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsTrend.d.ts +0 -1
  2. package/dist/cjs/components/analytics-chips-and-dropdowns/AnalyticsTrend.js +1 -1
  3. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/StackedBarChart/StackedBarChart.js +1 -1
  4. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/StackedBarChart/StackedBarChart.model.d.ts +1 -5
  5. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraph.js +1 -1
  6. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraphModel.d.ts +0 -11
  7. package/dist/cjs/components/bik-chatbot/components/ChatWindow.js +9 -7
  8. package/dist/cjs/components/bik-chatbot/contexts/AIContext.js +1 -1
  9. package/dist/cjs/components/bik-chatbot/services/callToChatbot.d.ts +1 -1
  10. package/dist/cjs/components/bik-chatbot/services/useAIChat.js +1 -1
  11. package/dist/cjs/components/bik-layout/SidebarStyles.js +1 -1
  12. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsTrend.d.ts +0 -1
  13. package/dist/esm/components/analytics-chips-and-dropdowns/AnalyticsTrend.js +1 -1
  14. package/dist/esm/components/analytics-chips-and-dropdowns/chart/StackedBarChart/StackedBarChart.js +1 -1
  15. package/dist/esm/components/analytics-chips-and-dropdowns/chart/StackedBarChart/StackedBarChart.model.d.ts +1 -5
  16. package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraph.js +1 -1
  17. package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraphModel.d.ts +0 -11
  18. package/dist/esm/components/bik-chatbot/components/ChatWindow.js +14 -12
  19. package/dist/esm/components/bik-chatbot/contexts/AIContext.js +1 -1
  20. package/dist/esm/components/bik-chatbot/services/callToChatbot.d.ts +1 -1
  21. package/dist/esm/components/bik-chatbot/services/useAIChat.js +1 -1
  22. package/dist/esm/components/bik-layout/SidebarStyles.js +1 -1
  23. package/package.json +1 -1
  24. package/dist/cjs/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraphModel.js +0 -1
  25. package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraphModel.js +0 -1
@@ -4,7 +4,6 @@ export interface AnalyticsTrendInterface {
4
4
  value?: number | string;
5
5
  trendPercent?: number;
6
6
  trendRaw?: number;
7
- trendRawString?: string;
8
7
  formatVal?: boolean;
9
8
  timeline?: 'today' | 'yesterday' | '7 days' | '30 days' | 'custom';
10
9
  customRange?: Date[];
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("react"),n=require("../shimmer/ShimmerComponent/ShimmerStyled.js"),i=require("../../utils/DateUtils.js"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/arrow_down.svg.js"),o=require("../../assets/icons/arrow_up.svg.js"),l=require("../../assets/icons/info.svg.js"),a=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),x=require("../TypographyStyle.js"),u=require("./chart/utils/calcPercentage.js"),d=require("./CommonStyles.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=m(t);const j=n=>{let{percent:l,direction:a,timeline:d,customRange:m,trendRaw:p,trendRawString:j,prefixSymbol:g,trendIconStyle:h,isInternationalStore:y,tooltipTimelineText:R,customTimelineText:b}=n;const f=()=>{const e=((null!=p?p:0)>0?"+":"")+(null!=g?g:"");return void 0===p?"--":`${null!=e?e:""}${(()=>{let e="--";if(p)return e=String(y?u.truncateValueForInternationalStore(Math.abs(p)):u.truncateValueForIndianStore(Math.abs(p))),p<0?"-"+e:e})()}`},[S,O]=t.useState(f()),[T,v]=t.useState(b||"");t.useEffect((()=>{b||v("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&m?i.default.getAnalyticsCustomDateTimelineText(m):"")}),[d,m]),t.useEffect((()=>{O(f())}),[p]);const E="negative"===a?r.default:o.default,C="negative"===a?s.COLORS.background.negative.vibrant:"positive"===a?s.COLORS.background.positive.vibrant:s.COLORS.content.placeholder;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof l&&e.jsxRuntimeExports.jsx(E,{color:C,height:16,width:16,style:Object.assign({marginRight:2},null!=h?h:{})}),"number"==typeof l&&a&&e.jsxRuntimeExports.jsxs(x.Caption,Object.assign({style:{color:C}},{children:["neutral"===a?0:l<1e3?l:">999","%"]})),!!p&&e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:`(${S})`})),!p&&((null==j?void 0:j.length)||0)>0&&e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:`${j}`})),d&&(R?e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:R,placement:"bottom"},{children:e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:b||T}))})):e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:b||T})))]}))};exports.AnalyticsTrend=t=>{let{title:i,value:r,trendPercent:o,type:m="horizontal",timeline:g,customRange:h,tooltip:y,card:R=!0,rightSeparator:b=!1,size:f="big",share:S=!1,formatVal:O,prefixSymbol:T,trailingIcon:v,onTrailIconClick:E,iconTooltipBody:C,funnelPercent:w,isLoading:I,trendRaw:$,trendRawString:L,suffixText:q,trendStyle:D,trendContainerStyle:F,trendIconStyle:M,containerStyle:k,prevTrendDiff:P,relativePercentageDiff:V,isInternationalStore:_,Icon:z,iconContainerStyle:A,tooltipTimelineText:N,customTimelineText:B}=t;const W="big"===f?x.TitleLarge:x.TitleMedium,U=void 0!==o?o<0?"negative":0===o?"neutral":"positive":void 0,G=void 0!==o?S?Math.round(o):Math.abs(Math.round(o)):void 0;return e.jsxRuntimeExports.jsx(d.AnalyticsTrendContainer,Object.assign({card:R,style:Object.assign({},k)},{children:e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:z?12:4,borderRightWidth:b?1:0,borderRightColor:s.COLORS.stroke.primary,borderRightStyle:"solid",paddingLeft:R?0:24,paddingRight:R?0:24,height:"100%",justifyContent:z?"flex-start":"space-between",alignItems:"center"},null!=F?F:{})},{children:[!!z&&e.jsxRuntimeExports.jsx(d.IconContainer,Object.assign({style:Object.assign({},A)},{children:e.jsxRuntimeExports.jsx(z,{})})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=D?D:{})},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(x.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:i})),y&&e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:y,placement:"right",width:300},{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",cursor:"pointer",height:"100%"}},{children:e.jsxRuntimeExports.jsx(l.default,{color:s.COLORS.content.primary,height:16,width:16})}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},S?{justifyContent:"space-between"}:{})},{children:[I&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{width:108,height:26}),!I&&e.jsxRuntimeExports.jsx(W,Object.assign({style:{color:s.COLORS.content.primary}},{children:void 0===r?"--":"number"==typeof r&&O?r>999?_?`${null!=T?T:""}${u.truncateValueForInternationalStore(r)} ${null!=q?q:""}`:`${null!=T?T:""}${u.truncateValueForIndianStore(r)} ${null!=q?q:""}`:`${null!=T?T:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(r)} ${null!=q?q:""}`:`${null!=T?T:""}${r} ${null!=q?q:""}`})),"number"==typeof V&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${V}%`,theme:"light",type:"neutral"}),"horizontal"===m&&!I&&!S&&e.jsxRuntimeExports.jsx(j,{timeline:g,customRange:h,percent:G,direction:U,trendRaw:$,trendRawString:L,prefixSymbol:T,trendIconStyle:M,isInternationalStore:_,tooltipTimelineText:N,customTimelineText:B}),I&&!S&&"horizontal"===m&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{height:20,width:141,marginTop:6}),"vertical"===m&&!I&&void 0!==w&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${w} %`,theme:"light",type:"neutral"}),S&&!I&&void 0!==G&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${G} %`,theme:"light",type:"neutral"}),S||I||!P||0==P?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(a.Tag,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(P),theme:"light",type:"neutral"})]})),"vertical"===m&&!I&&!S&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsxRuntimeExports.jsx(j,{timeline:g,customRange:h,percent:G,direction:U,trendRaw:$,trendRawString:L,prefixSymbol:T,trendIconStyle:M,isInternationalStore:_,tooltipTimelineText:N,customTimelineText:B})})),I&&"vertical"===m&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{height:20,width:141,marginTop:6})]})),C&&!I&&e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:C,placement:"right"},{children:v&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"icon--holder",onClick:E},{children:p.default.createElement(v,{height:20,width:20,color:s.COLORS.content.secondary})}))}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("react"),n=require("../shimmer/ShimmerComponent/ShimmerStyled.js"),i=require("../../utils/DateUtils.js"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/arrow_down.svg.js"),o=require("../../assets/icons/arrow_up.svg.js"),l=require("../../assets/icons/info.svg.js"),a=require("../tag/Tag.js"),c=require("../tooltips/Tooltip.js"),x=require("../TypographyStyle.js"),u=require("./chart/utils/calcPercentage.js"),d=require("./CommonStyles.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=m(t);const j=n=>{let{percent:l,direction:a,timeline:d,customRange:m,trendRaw:p,prefixSymbol:j,trendIconStyle:g,isInternationalStore:h,tooltipTimelineText:y,customTimelineText:R}=n;const b=()=>{const e=((null!=p?p:0)>0?"+":"")+(null!=j?j:"");return void 0===p?"--":`${null!=e?e:""}${(()=>{let e="--";if(p)return e=String(h?u.truncateValueForInternationalStore(Math.abs(p)):u.truncateValueForIndianStore(Math.abs(p))),p<0?"-"+e:e})()}`},[f,O]=t.useState(b()),[S,T]=t.useState(R||"");t.useEffect((()=>{R||T("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&m?i.default.getAnalyticsCustomDateTimelineText(m):"")}),[d,m]),t.useEffect((()=>{O(b())}),[p]);const v="negative"===a?r.default:o.default,E="negative"===a?s.COLORS.background.negative.vibrant:"positive"===a?s.COLORS.background.positive.vibrant:s.COLORS.content.placeholder;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof l&&e.jsxRuntimeExports.jsx(v,{color:E,height:16,width:16,style:Object.assign({marginRight:2},null!=g?g:{})}),"number"==typeof l&&a&&e.jsxRuntimeExports.jsxs(x.Caption,Object.assign({style:{color:E}},{children:["neutral"===a?0:l<1e3?l:">999","%"]})),!!p&&e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:`(${f})`})),d&&(y?e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:y,placement:"bottom"},{children:e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:R||S}))})):e.jsxRuntimeExports.jsx(x.Caption,Object.assign({style:{marginLeft:4,color:s.COLORS.content.placeholder}},{children:R||S})))]}))};exports.AnalyticsTrend=t=>{let{title:i,value:r,trendPercent:o,type:m="horizontal",timeline:g,customRange:h,tooltip:y,card:R=!0,rightSeparator:b=!1,size:f="big",share:O=!1,formatVal:S,prefixSymbol:T,trailingIcon:v,onTrailIconClick:E,iconTooltipBody:C,funnelPercent:w,isLoading:I,trendRaw:$,suffixText:L,trendStyle:q,trendContainerStyle:D,trendIconStyle:F,containerStyle:M,prevTrendDiff:k,relativePercentageDiff:P,isInternationalStore:V,Icon:_,iconContainerStyle:z,tooltipTimelineText:A,customTimelineText:N}=t;const B="big"===f?x.TitleLarge:x.TitleMedium,W=void 0!==o?o<0?"negative":0===o?"neutral":"positive":void 0,U=void 0!==o?O?Math.round(o):Math.abs(Math.round(o)):void 0;return e.jsxRuntimeExports.jsx(d.AnalyticsTrendContainer,Object.assign({card:R,style:Object.assign({},M)},{children:e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:_?12:4,borderRightWidth:b?1:0,borderRightColor:s.COLORS.stroke.primary,borderRightStyle:"solid",paddingLeft:R?0:24,paddingRight:R?0:24,height:"100%",justifyContent:_?"flex-start":"space-between",alignItems:"center"},null!=D?D:{})},{children:[!!_&&e.jsxRuntimeExports.jsx(d.IconContainer,Object.assign({style:Object.assign({},z)},{children:e.jsxRuntimeExports.jsx(_,{})})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=q?q:{})},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(x.BodyCaption,Object.assign({style:{color:s.COLORS.content.secondary}},{children:i})),y&&e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:y,placement:"right",width:300},{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",cursor:"pointer",height:"100%"}},{children:e.jsxRuntimeExports.jsx(l.default,{color:s.COLORS.content.primary,height:16,width:16})}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},O?{justifyContent:"space-between"}:{})},{children:[I&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{width:108,height:26}),!I&&e.jsxRuntimeExports.jsx(B,Object.assign({style:{color:s.COLORS.content.primary}},{children:void 0===r?"--":"number"==typeof r&&S?r>999?V?`${null!=T?T:""}${u.truncateValueForInternationalStore(r)} ${null!=L?L:""}`:`${null!=T?T:""}${u.truncateValueForIndianStore(r)} ${null!=L?L:""}`:`${null!=T?T:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(r)} ${null!=L?L:""}`:`${null!=T?T:""}${r} ${null!=L?L:""}`})),"number"==typeof P&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${P}%`,theme:"light",type:"neutral"}),"horizontal"===m&&!I&&!O&&e.jsxRuntimeExports.jsx(j,{timeline:g,customRange:h,percent:U,direction:W,trendRaw:$,prefixSymbol:T,trendIconStyle:F,isInternationalStore:V,tooltipTimelineText:A,customTimelineText:N}),I&&!O&&"horizontal"===m&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{height:20,width:141,marginTop:6}),"vertical"===m&&!I&&void 0!==w&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${w} %`,theme:"light",type:"neutral"}),O&&!I&&void 0!==U&&e.jsxRuntimeExports.jsx(a.Tag,{tagText:`${U} %`,theme:"light",type:"neutral"}),O||I||!k||0==k?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(a.Tag,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(k),theme:"light",type:"neutral"})]})),"vertical"===m&&!I&&!O&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsxRuntimeExports.jsx(j,{timeline:g,customRange:h,percent:U,direction:W,trendRaw:$,prefixSymbol:T,trendIconStyle:F,isInternationalStore:V,tooltipTimelineText:A,customTimelineText:N})})),I&&"vertical"===m&&e.jsxRuntimeExports.jsx(n.ShimmerComponentStyled,{height:20,width:141,marginTop:6})]})),C&&!I&&e.jsxRuntimeExports.jsx(c.Tooltip,Object.assign({body:C,placement:"right"},{children:v&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"icon--holder",onClick:E},{children:p.default.createElement(v,{height:20,width:20,color:s.COLORS.content.secondary})}))}))]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("../../../../assets/icons/maximize.svg.js"),i=require("chart.js"),o=require("chartjs-plugin-datalabels"),a=require("react"),l=require("react-chartjs-2"),n=require("../../../icon-button/IconButton.js"),s=require("../../../modals/styledModal.js"),r=require("../../../TypographyStyle.js"),d=require("../../../../constants/Theme.js"),c=require("../utils/calcPercentage.js"),u=require("./StackedBarChart.model.js"),x=require("./StackedBarChart.styles.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=v(o);i.Chart.register(i.CategoryScale,i.LinearScale,i.BarElement,i.Tooltip,i.Legend,p.default);exports.StackedBarChart=i=>{var o,v,p,O,g,A,b,h,R,j,y,m,f,C,I,T,E,S,N,H,L,k,F,P,B,_,G,w,D,q,Z,z,M,W,$,V,Y,J,K,Q,U,X,ee,te,ie;const{headerIcons:oe=[],legendsAndIconDirection:ae="row"}=i,[le,ne]=a.useState(!1),se=[250,1e3,800,1500,300,600],re=0===i.yAxis.data.length,de=["#5E07BB","#9E77ED","#D2AEFF","#F7D7FF","#CDE1FF","#92AFFA","#3935E1"],ce=["#E6C7FF","#FEC6C6","#FEDEF3","#DEEFFF","#FFD8B1","#C7E5FF","#FFD3E6","#C9FFE5","#FFE3C7","#D9D9FF"],ue=i.customBarColors?i.customBarColors:i.customColourScaleBrand||i.customColourScalePastel?i.colorSchema===u.COLOR_SCHEMA.PASTEL?i.customColourScalePastel:i.customColourScaleBrand:i.colorSchema===u.COLOR_SCHEMA.PASTEL?ce:de,xe=i.customHoverColour,ve=a.useMemo((()=>{var e,t,o;return Object.assign(Object.assign({barPercentage:(null==i?void 0:i.barPercentage)||.4,categoryPercentage:1,pointStyle:"circle",barWidth:i.barWidth,borderRadius:(null==i?void 0:i.borderRadius)||void 0},"object"==typeof(null==i?void 0:i.borderRadius)?{borderSkipped:!1}:{}),(null===(e=null==i?void 0:i.addBarGap)||void 0===e?void 0:e.flag)?{borderWidth:{top:(null===(t=null==i?void 0:i.addBarGap)||void 0===t?void 0:t.value)||2,bottom:(null===(o=null==i?void 0:i.addBarGap)||void 0===o?void 0:o.value)||2,right:0,left:0},borderColor:"transparent"}:{})}),[i.barWidth,null==i?void 0:i.borderRadius,null==i?void 0:i.barPercentage,null==i?void 0:i.addBarGap]),pe={};i.yAxis.data.map((e=>{e.map((e=>{pe[e.name]?pe[e.name].push(e.value):pe[e.name]=[e.value]}))}));const Oe=Object.keys(pe).map(((e,t)=>Object.assign({label:e,data:pe[e],backgroundColor:null==ue?void 0:ue[t],hoverBackgroundColor:void 0===xe?void 0:xe[t]},ve))),ge=i.renderInHeightWiseManner?Oe.map(((e,t)=>Object.assign(Object.assign({},e),{order:e.data.reduce(((e,t)=>e+(t||0)),0)}))).sort(((e,t)=>t.order-e.order)):Oe;let Ae=i.xAxis.data.map((e=>"string"==typeof e?e:e.name)),be=ge;if(i.truncateBars){const e=((e,t,i)=>{if(t.length<=i)return{truncatedData:e,truncatedLabels:t,originalData:e,originalLabels:t};const o=e.map((e=>e.slice(0,i))),a=e.map((e=>e.slice(i).reduce(((e,t)=>e+t),0)));o.forEach(((e,t)=>e.push(a[t])));const l=t.slice(0,i);return l.push("Others"),{truncatedData:o,truncatedLabels:l,originalData:e,originalLabels:t}})(ge.map((e=>e.data)),Ae,i.truncateBars);ge.forEach(((t,i)=>t.data=e.truncatedData[i])),Ae=e.truncatedLabels,be=e.originalData.map(((e,t)=>Object.assign(Object.assign({},ge[t]),{data:e})))}const he={plugins:{legend:{display:!re&&!i.customLegend,labels:{usePointStyle:!0,fontSize:2}},tooltip:{enabled:!re,callbacks:{label:null===(o=i.tooltipConfig)||void 0===o?void 0:o.labelCallback,title:null===(v=i.tooltipConfig)||void 0===v?void 0:v.titleCallback,footer:null===(p=i.tooltipConfig)||void 0===p?void 0:p.footerCallback},footerFont:null===(g=null===(O=i.tooltipConfig)||void 0===O?void 0:O.footerStyles)||void 0===g?void 0:g.footerFont},datalabels:{display:null!==(A=i.showTotal)&&void 0!==A&&A,anchor:"end",align:"end",clamp:!0,formatter:(e,t)=>{var i;const o=t.datasetIndex,a=t.chart.data.datasets;if(o!==a.length-1)return"";const l=t.dataIndex;let n=0;for(let e=0;e<a.length;e++)n+=null!==(i=a[e].data[l])&&void 0!==i?i:0;return n?n<1e3?n:(n/1e3).toString().substring(0,4)+"k":""},color:d.COLORS.content.secondary}},layout:{padding:{right:i.showTotal&&i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?50:0,top:i.showTotal&&i.orientation!=u.GRAPH_ORIENTATION.HORIZONTAL?50:0}},responsive:!0,maintainAspectRatio:!1,legend:{display:!i.customLegend,labels:{usePointStyle:!0}},indexAxis:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"y":"x",scales:{x:{title:{display:!!(i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(b=i.yAxis)||void 0===b?void 0:b.title:null===(h=i.xAxis)||void 0===h?void 0:h.title),text:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(R=i.yAxis)||void 0===R?void 0:R.title:null===(j=i.xAxis)||void 0===j?void 0:j.title,color:null!==(f=i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(y=i.yAxis)||void 0===y?void 0:y.titleColor:null===(m=i.xAxis)||void 0===m?void 0:m.titleColor)&&void 0!==f?f:d.COLORS.content.secondary,font:{size:d.FONTS.caption.fontSize}},grid:{display:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL&&(void 0===(null===(C=null==i?void 0:i.showGridLines)||void 0===C?void 0:C.x)||(null===(I=null==i?void 0:i.showGridLines)||void 0===I?void 0:I.x)),color:d.COLORS.background.base},ticks:{fontSize:d.FONTS.caption.fontSize,color:null!==(T=i.yAxis.labelColor)&&void 0!==T?T:d.COLORS.content.secondary,callback:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?e=>{var t;return`${i.isInternationalStore?c.truncateValueForInternationalStore(e):c.truncateValueForIndianStore(e)}${(null===(t=i.yAxis)||void 0===t?void 0:t.axisSuffix)||""}`}:(null===(E=i.xAxis)||void 0===E?void 0:E.axisSuffix)?e=>`${e}${i.xAxis.axisSuffix}`:void 0},stacked:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"boolean"!=typeof(null===(S=i.yAxis)||void 0===S?void 0:S.stacked)||(null===(N=i.yAxis)||void 0===N?void 0:N.stacked):"boolean"!=typeof(null===(H=i.xAxis)||void 0===H?void 0:H.stacked)||(null===(L=i.xAxis)||void 0===L?void 0:L.stacked)},y:Object.assign(Object.assign({},(null===(k=null==i?void 0:i.equalHeight)||void 0===k?void 0:k.flag)?{suggestedMin:-(null==i?void 0:i.equalHeight.max),suggestedMax:null==i?void 0:i.equalHeight.max}:{}),{max:null===(F=null==i?void 0:i.yAxis)||void 0===F?void 0:F.max,title:{display:!!(i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(P=i.xAxis)||void 0===P?void 0:P.title:null===(B=i.yAxis)||void 0===B?void 0:B.title),text:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(_=i.xAxis)||void 0===_?void 0:_.title:null===(G=i.yAxis)||void 0===G?void 0:G.title,color:null!==(q=i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(w=i.xAxis)||void 0===w?void 0:w.titleColor:null===(D=i.yAxis)||void 0===D?void 0:D.titleColor)&&void 0!==q?q:d.COLORS.content.secondary,font:{size:d.FONTS.caption.fontSize}},grid:{display:i.orientation!==u.GRAPH_ORIENTATION.HORIZONTAL&&(void 0===(null===(Z=null==i?void 0:i.showGridLines)||void 0===Z?void 0:Z.y)||(null===(z=null==i?void 0:i.showGridLines)||void 0===z?void 0:z.y)),color:d.COLORS.background.base},ticks:Object.assign(Object.assign({stepSize:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(M=i.xAxis)||void 0===M?void 0:M.stepSize:null===(W=i.yAxis)||void 0===W?void 0:W.stepSize,fontSize:d.FONTS.caption.fontSize,color:null!==($=i.xAxis.labelColor)&&void 0!==$?$:d.COLORS.content.secondary},re?{min:0,max:2e3,stepSize:200}:{}),{callback:(null==i?void 0:i.ticksCallback)?null==i?void 0:i.ticksCallback:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?e=>{var t;return`${i.isInternationalStore?c.truncateValueForInternationalStore(e):c.truncateValueForIndianStore(e)}${(null===(t=i.xAxis)||void 0===t?void 0:t.axisSuffix)||""}`}:(null===(V=i.yAxis)||void 0===V?void 0:V.axisSuffix)?e=>`${e}${i.yAxis.axisSuffix}`:void 0}),stacked:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"boolean"!=typeof(null===(Y=i.xAxis)||void 0===Y?void 0:Y.stacked)||(null===(J=i.xAxis)||void 0===J?void 0:J.stacked):"boolean"!=typeof(null===(K=i.yAxis)||void 0===K?void 0:K.stacked)||(null===(Q=i.yAxis)||void 0===Q?void 0:Q.stacked)})},onClick:(e,t)=>{if(!i.onBarClick)return;const o=t[0].datasetIndex,a=t[0].index,l=e.chart.data.datasets[o].label,n=e.chart.data.labels[a];i.onBarClick(n,l)},onHover:(e,t)=>{i.onBarClick&&t.length&&(e.native.target.style.cursor="pointer")}};i.orientation&&i.orientation!==u.GRAPH_ORIENTATION.VERTICAL?delete he.scales.y.ticks.callback:delete he.scales.x.ticks.callback;const Re={labels:Ae,datasets:re?[{data:se,backgroundColor:"rgba(0,0,0,0)"}]:ge},je={labels:i.xAxis.data.map((e=>"string"==typeof e?e:e.name)),datasets:re?[{data:se,backgroundColor:"rgba(0,0,0,0)"}]:be},ye=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e.jsxRuntimeExports.jsx("div",Object.assign({style:{overflowY:"scroll",display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:i.allowChartPopup&&!t?"flex-start":"flex-end",flexWrap:"wrap"}},{children:Oe.map((t=>e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:t.backgroundColor,width:"16px",height:"16px",borderRadius:"2px"}}),e.jsxRuntimeExports.jsx(r.BodyTiny,Object.assign({color:d.COLORS.content.secondary},{children:t.label}))]}),t.label.replace(" ","_"))))}))};return e.jsxRuntimeExports.jsxs(x.GraphContainerWrapper,Object.assign({style:null!==(U=i.wrapperStyle)&&void 0!==U?U:{},padding:i.outerPadding,customLegend:i.customLegend},{children:[i.chartHeading&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:i.hideHeading?"flex-end":"space-between"}},{children:[!0!==i.hideHeading&&e.jsxRuntimeExports.jsx(r.TitleRegular,Object.assign({color:null!==(X=i.chartHeading.color)&&void 0!==X?X:d.COLORS.content.secondary},{children:i.chartHeading.heading})),i.allowChartPopup&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",justifyContent:"flex-end"}},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(n.IconButton,{Icon:t.default,onClick:()=>{ne(!0)}})})}))]})),i.customLegend&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:ae,justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(x.HeaderIconWrapper,{children:oe.map(((t,i)=>e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx("div",{children:t})},i)))}),ye()]})),e.jsxRuntimeExports.jsx("div",Object.assign({className:"graph__wrapper"},{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:null!==(ee=i.graphCanvasHeight)&&void 0!==ee?ee:500,width:null!==(te=i.graphCanvasWidth)&&void 0!==te?te:"auto"}},{children:e.jsxRuntimeExports.jsx(l.Bar,{options:he,data:Re})}))})),le&&e.jsxRuntimeExports.jsx(s.StyledModal,Object.assign({open:le,onClose:()=>ne(!1),closeOnOutsideClick:!0,headingTitle:null===(ie=i.chartHeading)||void 0===ie?void 0:ie.heading,width:"85%"},{children:e.jsxRuntimeExports.jsxs("div",Object.assign({className:"graph__wrapper",style:{padding:"8px"}},{children:[i.customLegend&&ye(!0),e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:"70vh",width:"100%",padding:"16px",borderRadius:"8px"}},{children:e.jsxRuntimeExports.jsx(l.Bar,{options:he,data:je})}))]}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),t=require("../../../../assets/icons/maximize.svg.js"),i=require("chart.js"),o=require("chartjs-plugin-datalabels"),a=require("react"),l=require("react-chartjs-2"),n=require("../../../icon-button/IconButton.js"),s=require("../../../modals/styledModal.js"),r=require("../../../TypographyStyle.js"),d=require("../../../../constants/Theme.js"),c=require("../utils/calcPercentage.js"),u=require("./StackedBarChart.model.js"),x=require("./StackedBarChart.styles.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=v(o);i.Chart.register(i.CategoryScale,i.LinearScale,i.BarElement,i.Tooltip,i.Legend,p.default);exports.StackedBarChart=i=>{var o,v,p,g,O,b,h,R,A,j,y,m,C,I,T,E,f,N,S,H,L,k,F,P,_,G,B,w,D,q,Z,z,M,W,V,Y,J,K,Q,U,X,$;const{headerIcons:ee=[],legendsAndIconDirection:te="row"}=i,[ie,oe]=a.useState(!1),ae=[250,1e3,800,1500,300,600],le=0===i.yAxis.data.length,ne=void 0===i.customColourScaleBrand&&void 0===i.customColourScalePastel?i.colorSchema===u.COLOR_SCHEMA.PASTEL?["#E6C7FF","#FEC6C6","#FEDEF3","#DEEFFF","#FFD8B1","#C7E5FF","#FFD3E6","#C9FFE5","#FFE3C7","#D9D9FF"]:["#5E07BB","#9E77ED","#D2AEFF","#F7D7FF","#CDE1FF","#92AFFA","#3935E1"]:i.colorSchema===u.COLOR_SCHEMA.PASTEL?i.customColourScalePastel:i.customColourScaleBrand,se=i.customHoverColour,re=a.useMemo((()=>{var e,t,o;return Object.assign(Object.assign({barPercentage:(null==i?void 0:i.barPercentage)||.4,categoryPercentage:1,pointStyle:"circle",barWidth:i.barWidth,borderRadius:(null==i?void 0:i.borderRadius)||void 0},"object"==typeof(null==i?void 0:i.borderRadius)?{borderSkipped:!1}:{}),(null===(e=null==i?void 0:i.addBarGap)||void 0===e?void 0:e.flag)?{borderWidth:{top:(null===(t=null==i?void 0:i.addBarGap)||void 0===t?void 0:t.value)||2,bottom:(null===(o=null==i?void 0:i.addBarGap)||void 0===o?void 0:o.value)||2,right:0,left:0},borderColor:"transparent"}:{})}),[i.barWidth,null==i?void 0:i.borderRadius,null==i?void 0:i.barPercentage,null==i?void 0:i.addBarGap]),de={};i.yAxis.data.map((e=>{e.map((e=>{de[e.name]?de[e.name].push(e.value):de[e.name]=[e.value]}))}));const ce=Object.keys(de).map(((e,t)=>Object.assign({label:e,data:de[e],backgroundColor:null==ne?void 0:ne[t],hoverBackgroundColor:void 0===se?void 0:se[t]},re)));let ue=i.xAxis.data.map((e=>"string"==typeof e?e:e.name)),xe=ce;if(i.truncateBars){const e=((e,t,i)=>{if(t.length<=i)return{truncatedData:e,truncatedLabels:t,originalData:e,originalLabels:t};const o=e.map((e=>e.slice(0,i))),a=e.map((e=>e.slice(i).reduce(((e,t)=>e+t),0)));o.forEach(((e,t)=>e.push(a[t])));const l=t.slice(0,i);return l.push("Others"),{truncatedData:o,truncatedLabels:l,originalData:e,originalLabels:t}})(ce.map((e=>e.data)),ue,i.truncateBars);ce.forEach(((t,i)=>t.data=e.truncatedData[i])),ue=e.truncatedLabels,xe=e.originalData.map(((e,t)=>Object.assign(Object.assign({},ce[t]),{data:e})))}const ve={plugins:{legend:{display:!le&&!i.customLegend,labels:{usePointStyle:!0,fontSize:2}},tooltip:{enabled:!le,callbacks:{label:null===(o=i.tooltipConfig)||void 0===o?void 0:o.labelCallback,title:null===(v=i.tooltipConfig)||void 0===v?void 0:v.titleCallback,footer:null===(p=i.tooltipConfig)||void 0===p?void 0:p.footerCallback},footerFont:null===(O=null===(g=i.tooltipConfig)||void 0===g?void 0:g.footerStyles)||void 0===O?void 0:O.footerFont},datalabels:{display:null!==(b=i.showTotal)&&void 0!==b&&b,anchor:"end",align:"end",clamp:!0,formatter:(e,t)=>{var i;const o=t.datasetIndex,a=t.chart.data.datasets;if(o!==a.length-1)return"";const l=t.dataIndex;let n=0;for(let e=0;e<a.length;e++)n+=null!==(i=a[e].data[l])&&void 0!==i?i:0;return n?n<1e3?n:(n/1e3).toString().substring(0,4)+"k":""},color:d.COLORS.content.secondary}},layout:{padding:{right:i.showTotal&&i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?50:0,top:i.showTotal&&i.orientation!=u.GRAPH_ORIENTATION.HORIZONTAL?50:0}},responsive:!0,maintainAspectRatio:!1,legend:{display:!i.customLegend,labels:{usePointStyle:!0}},indexAxis:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"y":"x",scales:{x:{title:{display:!!(i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(h=i.yAxis)||void 0===h?void 0:h.title:null===(R=i.xAxis)||void 0===R?void 0:R.title),text:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(A=i.yAxis)||void 0===A?void 0:A.title:null===(j=i.xAxis)||void 0===j?void 0:j.title,color:null!==(C=i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(y=i.yAxis)||void 0===y?void 0:y.titleColor:null===(m=i.xAxis)||void 0===m?void 0:m.titleColor)&&void 0!==C?C:d.COLORS.content.secondary,font:{size:d.FONTS.caption.fontSize}},grid:{display:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL&&(void 0===(null===(I=null==i?void 0:i.showGridLines)||void 0===I?void 0:I.x)||(null===(T=null==i?void 0:i.showGridLines)||void 0===T?void 0:T.x)),color:d.COLORS.background.base},ticks:{fontSize:d.FONTS.caption.fontSize,color:null!==(E=i.yAxis.labelColor)&&void 0!==E?E:d.COLORS.content.secondary,callback:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?i.isInternationalStore?c.truncateValueForInternationalStore:c.truncateValueForIndianStore:void 0},stacked:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"boolean"!=typeof(null===(f=i.yAxis)||void 0===f?void 0:f.stacked)||(null===(N=i.yAxis)||void 0===N?void 0:N.stacked):"boolean"!=typeof(null===(S=i.xAxis)||void 0===S?void 0:S.stacked)||(null===(H=i.xAxis)||void 0===H?void 0:H.stacked)},y:Object.assign(Object.assign({},(null===(L=null==i?void 0:i.equalHeight)||void 0===L?void 0:L.flag)?{suggestedMin:-(null==i?void 0:i.equalHeight.max),suggestedMax:null==i?void 0:i.equalHeight.max}:{}),{title:{display:!!(i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(k=i.xAxis)||void 0===k?void 0:k.title:null===(F=i.yAxis)||void 0===F?void 0:F.title),text:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(P=i.xAxis)||void 0===P?void 0:P.title:null===(_=i.yAxis)||void 0===_?void 0:_.title,color:null!==(w=i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(G=i.xAxis)||void 0===G?void 0:G.titleColor:null===(B=i.yAxis)||void 0===B?void 0:B.titleColor)&&void 0!==w?w:d.COLORS.content.secondary,font:{size:d.FONTS.caption.fontSize}},grid:{display:i.orientation!==u.GRAPH_ORIENTATION.HORIZONTAL&&(void 0===(null===(D=null==i?void 0:i.showGridLines)||void 0===D?void 0:D.y)||(null===(q=null==i?void 0:i.showGridLines)||void 0===q?void 0:q.y)),color:d.COLORS.background.base},ticks:Object.assign(Object.assign({stepSize:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?null===(Z=i.xAxis)||void 0===Z?void 0:Z.stepSize:null===(z=i.yAxis)||void 0===z?void 0:z.stepSize,fontSize:d.FONTS.caption.fontSize,color:null!==(M=i.xAxis.labelColor)&&void 0!==M?M:d.COLORS.content.secondary},le?{min:0,max:2e3,stepSize:200}:{}),{callback:(null==i?void 0:i.ticksCallback)?null==i?void 0:i.ticksCallback:i.orientation!==u.GRAPH_ORIENTATION.VERTICAL?i.isInternationalStore?c.truncateValueForInternationalStore:c.truncateValueForIndianStore:void 0}),stacked:i.orientation===u.GRAPH_ORIENTATION.HORIZONTAL?"boolean"!=typeof(null===(W=i.xAxis)||void 0===W?void 0:W.stacked)||(null===(V=i.xAxis)||void 0===V?void 0:V.stacked):"boolean"!=typeof(null===(Y=i.yAxis)||void 0===Y?void 0:Y.stacked)||(null===(J=i.yAxis)||void 0===J?void 0:J.stacked)})},onClick:(e,t)=>{if(!i.onBarClick)return;const o=t[0].datasetIndex,a=t[0].index,l=e.chart.data.datasets[o].label,n=e.chart.data.labels[a];i.onBarClick(n,l)},onHover:(e,t)=>{i.onBarClick&&t.length&&(e.native.target.style.cursor="pointer")}};i.orientation&&i.orientation!==u.GRAPH_ORIENTATION.VERTICAL?delete ve.scales.y.ticks.callback:delete ve.scales.x.ticks.callback;const pe={labels:ue,datasets:le?[{data:ae,backgroundColor:"rgba(0,0,0,0)"}]:ce},ge={labels:i.xAxis.data.map((e=>"string"==typeof e?e:e.name)),datasets:le?[{data:ae,backgroundColor:"rgba(0,0,0,0)"}]:xe},Oe=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e.jsxRuntimeExports.jsx("div",Object.assign({style:{overflowY:"scroll",display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:i.allowChartPopup&&!t?"flex-start":"flex-end",flexWrap:"wrap"}},{children:ce.map((t=>e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:t.backgroundColor,width:"16px",height:"16px",borderRadius:"2px"}}),e.jsxRuntimeExports.jsx(r.BodyTiny,Object.assign({color:d.COLORS.content.secondary},{children:t.label}))]}),t.label.replace(" ","_"))))}))};return e.jsxRuntimeExports.jsxs(x.GraphContainerWrapper,Object.assign({style:null!==(K=i.wrapperStyle)&&void 0!==K?K:{},padding:i.outerPadding,customLegend:i.customLegend},{children:[i.chartHeading&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:i.hideHeading?"flex-end":"space-between"}},{children:[!0!==i.hideHeading&&e.jsxRuntimeExports.jsx(r.TitleRegular,Object.assign({color:null!==(Q=i.chartHeading.color)&&void 0!==Q?Q:d.COLORS.content.secondary},{children:i.chartHeading.heading})),i.allowChartPopup&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",justifyContent:"flex-end"}},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(n.IconButton,{Icon:t.default,onClick:()=>{oe(!0)}})})}))]})),i.customLegend&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:te,justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(x.HeaderIconWrapper,{children:ee.map(((t,i)=>e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx("div",{children:t})},i)))}),Oe()]})),e.jsxRuntimeExports.jsx("div",Object.assign({className:"graph__wrapper"},{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:null!==(U=i.graphCanvasHeight)&&void 0!==U?U:500,width:null!==(X=i.graphCanvasWidth)&&void 0!==X?X:"auto"}},{children:e.jsxRuntimeExports.jsx(l.Bar,{options:ve,data:pe})}))})),ie&&e.jsxRuntimeExports.jsx(s.StyledModal,Object.assign({open:ie,onClose:()=>oe(!1),closeOnOutsideClick:!0,headingTitle:null===($=i.chartHeading)||void 0===$?void 0:$.heading,width:"85%"},{children:e.jsxRuntimeExports.jsxs("div",Object.assign({className:"graph__wrapper",style:{padding:"8px"}},{children:[i.customLegend&&Oe(!0),e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:"70vh",width:"100%",padding:"16px",borderRadius:"8px"}},{children:e.jsxRuntimeExports.jsx(l.Bar,{options:ve,data:ge})}))]}))}))]}))};
@@ -7,8 +7,6 @@ export interface AxisDetailsI {
7
7
  labelColor?: string;
8
8
  stepSize?: number;
9
9
  stacked?: boolean;
10
- axisSuffix?: string;
11
- max?: number;
12
10
  }
13
11
  export interface XAxisDataI {
14
12
  name: string;
@@ -60,7 +58,6 @@ export interface StackedBarGraphI {
60
58
  customColourScaleBrand?: string[];
61
59
  customColourScalePastel?: string[];
62
60
  customHoverColour?: string[];
63
- customBarColors?: string[];
64
61
  isInternationalStore?: boolean;
65
62
  truncateBars?: number;
66
63
  allowChartPopup?: boolean;
@@ -84,8 +81,7 @@ export interface StackedBarGraphI {
84
81
  flag: boolean;
85
82
  value: number;
86
83
  };
87
- ticksCallback?: (value: number | string) => string;
84
+ ticksCallback?: (value: number) => string;
88
85
  legendsAndIconDirection?: 'row-reverse' | 'row';
89
86
  headerIcons?: React.ReactNode[];
90
- renderInHeightWiseManner?: boolean;
91
87
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),i=require("chart.js"),t=require("react-chartjs-2"),r=require("../../../TypographyStyle.js"),a=require("../../../../constants/Theme.js"),n=require("../LineChart/LineChart.styled.js"),o=require("../utils/calcPercentage.js"),s=require("./VerticalBarAndLinearGraph.styles.js"),l=require("./VerticalBarAndLinearGraphModel.js");i.Chart.register(i.CategoryScale,i.LinearScale,i.BarElement,i.Tooltip);exports.VerticalBarAndLinearGraph=i=>{var x,d,c,p,u,g,b,A,j,h;const O=[0,0,0,0,0,0],m=-1===i.barAxis.data.findIndex((e=>0!==e)),S=-1===i.lineAxis.data.findIndex((e=>0!==e)),f=!i.lineAxis2||-1===i.lineAxis2.data.findIndex((e=>0!==e)),y={min:0,max:2e3,stepSize:200},R=[{legend:i.barAxis.title,color:i.barAxis.graphColor},{legend:i.lineAxis.title,color:i.lineAxis.graphColor},...i.lineAxis2?[{legend:i.lineAxis2.title,color:i.lineAxis2.graphColor}]:[]],C={responsive:!0,plugins:{legend:{display:!1}},scales:{x:{title:{display:!!i.xAxis.title,text:i.xAxis.title,color:i.xAxis.titleColor,font:{size:a.FONTS.caption.fontSize}},grid:{display:!1,borderColor:a.COLORS.background.base},ticks:{fontSize:a.FONTS.caption.fontSize,color:null!==(x=i.xAxis.labelColor)&&void 0!==x?x:a.COLORS.content.secondary,callback:(null===(d=i.xAxis)||void 0===d?void 0:d.axisSuffix)?e=>`${e}${i.xAxis.axisSuffix}`:void 0}},bar:{position:"left",title:{display:!!i.barAxis.title,text:i.barAxis.title,color:i.barAxis.titleColor,font:{size:a.FONTS.caption.fontSize}},grid:{borderColor:"white",color:a.COLORS.background.base},max:null===(c=null==i?void 0:i.barAxis)||void 0===c?void 0:c.max,ticks:Object.assign(Object.assign({fontSize:a.FONTS.caption.fontSize,color:null!==(p=i.barAxis.labelColor)&&void 0!==p?p:a.COLORS.content.secondary},m?y:{}),{callback:i.orientation===l.GRAPH_ORIENTATION.HORIZONTAL?e=>{var t;return`${i.isInternationalStore?o.truncateValueForInternationalStore(e):o.truncateValueForIndianStore(e)}${(null===(t=i.barAxis)||void 0===t?void 0:t.axisSuffix)||""}`}:(null===(u=i.barAxis)||void 0===u?void 0:u.axisSuffix)?e=>`${e}${i.barAxis.axisSuffix}`:void 0})},line:{position:"right",title:{display:!!i.lineAxis.title,text:i.lineAxis.title,color:i.lineAxis.titleColor,font:{size:a.FONTS.caption.fontSize}},max:null===(g=null==i?void 0:i.lineAxis)||void 0===g?void 0:g.max,grid:{display:!1,borderColor:"white",color:a.COLORS.background.base},ticks:Object.assign(Object.assign({fontSize:a.FONTS.caption.fontSize,color:null!==(b=i.lineAxis.labelColor)&&void 0!==b?b:a.COLORS.content.secondary},S?y:{}),{callback:i.orientation===l.GRAPH_ORIENTATION.HORIZONTAL?e=>{var t;return`${i.isInternationalStore?o.truncateValueForInternationalStore(e):o.truncateValueForIndianStore(e)}${(null===(t=i.lineAxis)||void 0===t?void 0:t.axisSuffix)||""}`}:(null===(A=i.lineAxis)||void 0===A?void 0:A.axisSuffix)?e=>`${e}${i.lineAxis.axisSuffix}`:void 0}),display:!0}},maintainAspectRatio:!1};i.orientation&&i.orientation!==l.GRAPH_ORIENTATION.VERTICAL?(delete C.scales.bar.ticks.callback,delete C.scales.line.ticks.callback):delete C.scales.x.ticks.callback;const v={labels:i.xAxis.forceShowXAxis?i.xAxis.data.map((e=>e.toString())):m&&S&&f?["-","-","-","-","-","-"]:i.xAxis.data.map((e=>e.toString())),datasets:[{yAxisID:"line",type:"line",data:i.noDummyValues?i.lineAxis.data:S?O:i.lineAxis.data,borderColor:i.lineAxis.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1},...i.lineAxis2?[{yAxisID:"line",type:"line",data:i.noDummyValues?i.lineAxis2.data:f?O:i.lineAxis2.data,borderColor:i.lineAxis2.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1}]:[],{yAxisID:"bar",type:"bar",data:i.noDummyValues?i.barAxis.data:m?O:i.barAxis.data,backgroundColor:i.barAxis.graphColor||"rgba(0,0,0,0)",barPercentage:.4,categoryPercentage:1,borderRadius:4}]};return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:2}},{children:[i.customLegend?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:"flex-end",flexWrap:"wrap"}},{children:R.map(((i,t)=>{let{legend:n,color:o}=i;return n?e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:o,width:"16px",height:"16px",borderRadius:"2px"}}),e.jsxRuntimeExports.jsx(r.BodyTiny,Object.assign({color:a.COLORS.content.secondary},{children:n}))]}),t):null}))})):e.jsxRuntimeExports.jsx(n.LegendWrapper,Object.assign({position:"center"},{children:R.map(((i,t)=>{let{legend:a,color:o}=i;return a?e.jsxRuntimeExports.jsxs(n.LegendContainer,{children:[e.jsxRuntimeExports.jsx(n.LegendColor,{color:o}),e.jsxRuntimeExports.jsx(r.SmallRegular,Object.assign({color:"#667085"},{children:a}))]},t):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}))})),e.jsxRuntimeExports.jsxs(s.GraphContainerWrapper,{children:[i.chartHeading&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginBottom:24}},{children:e.jsxRuntimeExports.jsx(r.TitleRegular,Object.assign({color:null!==(j=i.chartHeading.color)&&void 0!==j?j:a.COLORS.content.secondary},{children:i.chartHeading.heading}))})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:null!==(h=i.graphCanvasHeight)&&void 0!==h?h:500}},{children:e.jsxRuntimeExports.jsx(t.Chart,{type:"bar",data:v,options:C})}))]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../node_modules/react/jsx-runtime.js"),i=require("chart.js"),t=require("react-chartjs-2"),r=require("../../../TypographyStyle.js"),o=require("../../../../constants/Theme.js"),s=require("../LineChart/LineChart.styled.js"),a=require("./VerticalBarAndLinearGraph.styles.js");i.Chart.register(i.CategoryScale,i.LinearScale,i.BarElement,i.Tooltip);exports.VerticalBarAndLinearGraph=i=>{var n,l,x,c,d;const p=[0,0,0,0,0,0],g=-1===i.barAxis.data.findIndex((e=>0!==e)),b=-1===i.lineAxis.data.findIndex((e=>0!==e)),u={min:0,max:2e3,stepSize:200},j=[{legend:i.barAxis.title,color:i.barAxis.graphColor},{legend:i.lineAxis.title,color:i.lineAxis.graphColor}],h={responsive:!0,plugins:{legend:{display:!1}},scales:{x:{title:{display:!!i.xAxis.title,text:i.xAxis.title,color:i.xAxis.titleColor,font:{size:o.FONTS.caption.fontSize}},grid:{display:!1,borderColor:o.COLORS.background.base},ticks:{fontSize:o.FONTS.caption.fontSize,color:null!==(n=i.xAxis.labelColor)&&void 0!==n?n:o.COLORS.content.secondary}},bar:{position:"left",title:{display:!!i.barAxis.title,text:i.barAxis.title,color:i.barAxis.titleColor,font:{size:o.FONTS.caption.fontSize}},grid:{borderColor:"white",color:o.COLORS.background.base},ticks:Object.assign({fontSize:o.FONTS.caption.fontSize,color:null!==(l=i.barAxis.labelColor)&&void 0!==l?l:o.COLORS.content.secondary},g?u:{})},line:{position:"right",title:{display:!!i.lineAxis.title,text:i.lineAxis.title,color:i.lineAxis.titleColor,font:{size:o.FONTS.caption.fontSize}},grid:{display:!1,borderColor:"white",color:o.COLORS.background.base},ticks:Object.assign({fontSize:o.FONTS.caption.fontSize,color:null!==(x=i.lineAxis.labelColor)&&void 0!==x?x:o.COLORS.content.secondary},b?u:{}),display:!0}},maintainAspectRatio:!1},A={labels:i.xAxis.forceShowXAxis?i.xAxis.data.map((e=>e.toString())):g&&b?["-","-","-","-","-","-"]:i.xAxis.data.map((e=>e.toString())),datasets:[{yAxisID:"line",type:"line",data:b?p:i.lineAxis.data,borderColor:i.lineAxis.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1},{yAxisID:"bar",type:"bar",data:g?p:i.barAxis.data,backgroundColor:i.barAxis.graphColor||"rgba(0,0,0,0)",barPercentage:.4,categoryPercentage:1,borderRadius:4}]};return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:2}},{children:[e.jsxRuntimeExports.jsx(s.LegendWrapper,Object.assign({position:"center"},{children:j.map(((i,t)=>{let{legend:o,color:a}=i;return o?e.jsxRuntimeExports.jsxs(s.LegendContainer,{children:[e.jsxRuntimeExports.jsx(s.LegendColor,{color:a}),e.jsxRuntimeExports.jsx(r.SmallRegular,Object.assign({color:"#667085"},{children:o}))]},t):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}))})),e.jsxRuntimeExports.jsxs(a.GraphContainerWrapper,{children:[i.chartHeading&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginBottom:24}},{children:e.jsxRuntimeExports.jsx(r.TitleRegular,Object.assign({color:null!==(c=i.chartHeading.color)&&void 0!==c?c:o.COLORS.content.secondary},{children:i.chartHeading.heading}))})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{height:null!==(d=i.graphCanvasHeight)&&void 0!==d?d:500}},{children:e.jsxRuntimeExports.jsx(t.Chart,{type:"bar",data:A,options:h})}))]})]}))};
@@ -4,17 +4,11 @@ export interface AxisDetailsI {
4
4
  data: number[] | string[];
5
5
  labelColor?: string;
6
6
  graphColor?: string;
7
- axisSuffix?: string;
8
- max?: number;
9
7
  }
10
8
  export interface ChartHeadingI {
11
9
  heading: string;
12
10
  color?: string;
13
11
  }
14
- export declare enum GRAPH_ORIENTATION {
15
- VERTICAL = "vertical",
16
- HORIZONTAL = "horizontal"
17
- }
18
12
  export interface VerticalBarAndLinearGraphI {
19
13
  graphCanvasHeight?: number;
20
14
  tickColor?: string;
@@ -24,10 +18,5 @@ export interface VerticalBarAndLinearGraphI {
24
18
  forceShowXAxis?: boolean;
25
19
  };
26
20
  lineAxis: AxisDetailsI;
27
- lineAxis2?: AxisDetailsI;
28
21
  barAxis: AxisDetailsI;
29
- isInternationalStore?: boolean;
30
- customLegend?: boolean;
31
- orientation?: GRAPH_ORIENTATION;
32
- noDummyValues?: boolean;
33
22
  }
@@ -130,13 +130,14 @@
130
130
  padding: 8px 16px;
131
131
  border-radius: 8px;
132
132
  font-size: 13px;
133
- cursor: pointer;
133
+ cursor: ${e=>e.disabled?"not-allowed":"pointer"};
134
134
  transition: all 0.2s ease;
135
135
  text-align: left;
136
136
  max-width: 280px;
137
137
  align-self: flex-end;
138
+ opacity: ${e=>e.disabled?.5:1};
138
139
 
139
- &:hover {
140
+ &:hover:not(:disabled) {
140
141
  background: linear-gradient(
141
142
  92.69deg,
142
143
  rgba(255, 230, 238, 0.7) 0.37%,
@@ -145,7 +146,7 @@
145
146
  border-color: #f472b6;
146
147
  }
147
148
 
148
- &:active {
149
+ &:active:not(:disabled) {
149
150
  transform: scale(0.98);
150
151
  }
151
152
  `,v=d.default.div`
@@ -162,16 +163,17 @@
162
163
  border-radius: 8px;
163
164
  font-size: 13px;
164
165
  border: 1px solid #fecaca;
165
- cursor: pointer;
166
+ cursor: ${e=>e.disabled?"not-allowed":"pointer"};
166
167
  transition: all 0.2s ease;
167
168
  text-align: left;
169
+ opacity: ${e=>e.disabled?.5:1};
168
170
 
169
- &:hover {
171
+ &:hover:not(:disabled) {
170
172
  background: #fee2e2;
171
173
  border-color: #fca5a5;
172
174
  }
173
175
 
174
- &:active {
176
+ &:active:not(:disabled) {
175
177
  transform: scale(0.98);
176
178
  }
177
179
  `,E=d.default.div`
@@ -249,4 +251,4 @@
249
251
  -webkit-text-fill-color: transparent;
250
252
  background-clip: text;
251
253
  display: inline-block;
252
- `;exports.CustomGradientText=T,exports.default=r=>{let{messages:o,onSend:d,header:O="Create with AI",placeholder:C="Discover the right event & launch campaigns for better conversions...",suggestions:z=["Top festivals for marketing","Top events this week?","Top August festivals near you"],iceBreakers:B,videoStarter:$,disabled:q=!1,isThinking:A=!1,onIceBreakerClick:M,chatState:_,chatWindowHeight:I,inputDisabled:D=!1}=r;const[L,H]=i.useState(""),[W,K]=i.useState(!1),[P,G]=i.useState(!1),N=i.useRef(null),V=i.useRef(null),J=W||A,Q=q||D,U=_||(W||A?"thinking":P&&L.trim().length>0?"typing":0===o.length?"conversation-starter":o.length>0?"conversation":"default"),X=()=>{!L.trim()||Q||J||(d(L),H(""),K(!0),setTimeout((()=>K(!1)),1500))},Y=L.trim().length>0,Z=Q||J||!Y;i.useEffect((()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})}),[o,W,A]);const ee=I||"100%";return e.jsxRuntimeExports.jsxs(l,Object.assign({chatState:U,style:{height:ee}},{children:[e.jsxRuntimeExports.jsxs(x,{children:[e.jsxRuntimeExports.jsx(t.default,{height:24,width:24}),e.jsxRuntimeExports.jsx("div",Object.assign({className:"header-text"},{children:O}))]}),e.jsxRuntimeExports.jsxs(c,{children:[e.jsxRuntimeExports.jsxs(p,{children:["conversation-starter"===U&&$&&e.jsxRuntimeExports.jsxs(u,{children:[e.jsxRuntimeExports.jsx(h,{children:e.jsxRuntimeExports.jsx(g,Object.assign({onClick:$.onPlay},{children:e.jsxRuntimeExports.jsx("svg",Object.assign({viewBox:"0 0 24 24",fill:"currentColor"},{children:e.jsxRuntimeExports.jsx("path",{d:"M8 5v14l11-7z"})}))}))}),e.jsxRuntimeExports.jsxs(b,{children:[e.jsxRuntimeExports.jsx(n.BodySecondary,Object.assign({style:{fontWeight:500,marginBottom:"4px"}},{children:$.title})),e.jsxRuntimeExports.jsx(n.BodyCaption,{children:$.description})]})]}),o.map((t=>e.jsxRuntimeExports.jsx(f,Object.assign({role:t.role},{children:"assistant"===t.role?e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:s.renderMarkdownLite(t.content)}}):e.jsxRuntimeExports.jsx("div",Object.assign({style:{whiteSpace:"pre-wrap"}},{children:t.content}))}),t.id))),(W||A)&&e.jsxRuntimeExports.jsx(a.default,{}),e.jsxRuntimeExports.jsx("div",{ref:N})]}),B&&"conversation-starter"===U&&e.jsxRuntimeExports.jsx(m,{children:e.jsxRuntimeExports.jsx(j,{children:B.map((t=>e.jsxRuntimeExports.jsx(k,Object.assign({onClick:()=>{q||(null==M||M(t),d(t.text))}},{children:e.jsxRuntimeExports.jsx(T,{children:t.text})}),t.id)))})}),!B&&z.length>0&&"default"===U&&e.jsxRuntimeExports.jsx(v,{children:e.jsxRuntimeExports.jsx(w,{children:z.map((t=>e.jsxRuntimeExports.jsx(y,Object.assign({onClick:()=>!q&&d(t)},{children:t}),t)))})}),e.jsxRuntimeExports.jsx(E,{children:e.jsxRuntimeExports.jsxs(R,{children:[e.jsxRuntimeExports.jsx(F,{ref:V,value:L,onChange:e=>{if(Q)return;const t=e.target.value;H(t),G(t.trim().length>0);const i=V.current;i&&(i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,117)}px`)},placeholder:C,onKeyDown:e=>{Q||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!J&&L.trim()&&X())},disabled:Q,hasText:Y,chatState:U}),e.jsxRuntimeExports.jsx(S,Object.assign({onClick:X,disabled:Z,hasText:Y,"aria-label":"Send"},{children:e.jsxRuntimeExports.jsxs("svg",Object.assign({viewBox:"0 0 24 24",width:"20",height:"20",stroke:"white",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},{children:[e.jsxRuntimeExports.jsx("path",{d:"M6 12h12"}),e.jsxRuntimeExports.jsx("path",{d:"M12 6l6 6-6 6"})]}))}))]})})]})]}))};
254
+ `;exports.CustomGradientText=T,exports.default=r=>{let{messages:o,onSend:d,header:$="Create with AI",placeholder:O="Discover the right event & launch campaigns for better conversions...",suggestions:C=["Top festivals for marketing","Top events this week?","Top August festivals near you"],iceBreakers:z,videoStarter:B,disabled:q=!1,isThinking:A=!1,onIceBreakerClick:M,chatState:_,chatWindowHeight:I,inputDisabled:D=!1}=r;const[L,H]=i.useState(""),[W,K]=i.useState(!1),[P,G]=i.useState(!1),N=i.useRef(null),V=i.useRef(null),J=W||A,Q=q||D,U=_||(W||A?"thinking":P&&L.trim().length>0?"typing":0===o.length?"conversation-starter":o.length>0?"conversation":"default"),X=()=>{!L.trim()||Q||J||(d(L),H(""),K(!0),setTimeout((()=>K(!1)),1500))},Y=L.trim().length>0,Z=Q||J||!Y;i.useEffect((()=>{var e;null===(e=N.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})}),[o,W,A]);const ee=I||"100%";return e.jsxRuntimeExports.jsxs(l,Object.assign({chatState:U,style:{height:ee}},{children:[e.jsxRuntimeExports.jsxs(x,{children:[e.jsxRuntimeExports.jsx(t.default,{height:24,width:24}),e.jsxRuntimeExports.jsx("div",Object.assign({className:"header-text"},{children:$}))]}),e.jsxRuntimeExports.jsxs(c,{children:[e.jsxRuntimeExports.jsxs(p,{children:["conversation-starter"===U&&B&&e.jsxRuntimeExports.jsxs(u,{children:[e.jsxRuntimeExports.jsx(h,{children:e.jsxRuntimeExports.jsx(g,Object.assign({onClick:B.onPlay},{children:e.jsxRuntimeExports.jsx("svg",Object.assign({viewBox:"0 0 24 24",fill:"currentColor"},{children:e.jsxRuntimeExports.jsx("path",{d:"M8 5v14l11-7z"})}))}))}),e.jsxRuntimeExports.jsxs(b,{children:[e.jsxRuntimeExports.jsx(n.BodySecondary,Object.assign({style:{fontWeight:500,marginBottom:"4px"}},{children:B.title})),e.jsxRuntimeExports.jsx(n.BodyCaption,{children:B.description})]})]}),o.map((t=>e.jsxRuntimeExports.jsx(f,Object.assign({role:t.role},{children:"assistant"===t.role?e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:s.renderMarkdownLite(t.content)}}):e.jsxRuntimeExports.jsx("div",Object.assign({style:{whiteSpace:"pre-wrap"}},{children:t.content}))}),t.id))),(W||A)&&e.jsxRuntimeExports.jsx(a.default,{}),e.jsxRuntimeExports.jsx("div",{ref:N})]}),z&&"conversation-starter"===U&&e.jsxRuntimeExports.jsx(m,{children:e.jsxRuntimeExports.jsx(j,{children:z.map((t=>e.jsxRuntimeExports.jsx(k,Object.assign({disabled:Q,onClick:()=>{Q||(null==M||M(t),d(t.text))}},{children:e.jsxRuntimeExports.jsx(T,{children:t.text})}),t.id)))})}),!z&&C.length>0&&"default"===U&&e.jsxRuntimeExports.jsx(v,{children:e.jsxRuntimeExports.jsx(w,{children:C.map((t=>e.jsxRuntimeExports.jsx(y,Object.assign({disabled:Q,onClick:()=>!Q&&d(t)},{children:t}),t)))})}),e.jsxRuntimeExports.jsx(E,{children:e.jsxRuntimeExports.jsxs(R,{children:[e.jsxRuntimeExports.jsx(F,{ref:V,value:L,onChange:e=>{if(Q)return;const t=e.target.value;H(t),G(t.trim().length>0);const i=V.current;i&&(i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,117)}px`)},placeholder:O,onKeyDown:e=>{Q||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!J&&L.trim()&&X())},disabled:Q,hasText:Y,chatState:U}),e.jsxRuntimeExports.jsx(S,Object.assign({onClick:X,disabled:Z,hasText:Y,"aria-label":"Send"},{children:e.jsxRuntimeExports.jsxs("svg",Object.assign({viewBox:"0 0 24 24",width:"20",height:"20",stroke:"white",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},{children:[e.jsxRuntimeExports.jsx("path",{d:"M6 12h12"}),e.jsxRuntimeExports.jsx("path",{d:"M12 6l6 6-6 6"})]}))}))]})})]})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("../../../node_modules/react/jsx-runtime.js"),t=require("react"),o=require("../services/useAIChat.js"),r=require("../types/ai.js"),n=require("../services/callToChatbot.js");const i=t.createContext(null);exports.AIProvider=a=>{let{children:u,systemPrompt:l,systemId:d,functions:c,tools:m,functionHandler:p,onMessageReceived:v,displayInUI:f,maxToolCalls:x,maxTokens:A,requestExecutor:E,baseUrl:g,endpointPath:I,responseFormat:y,conversationId:h="default-session",customModel:C,onSystemReady:L}=a;const[q,j]=t.useState(null),[P,_]=t.useState(!0),[b,M]=t.useState(null),w=t.useRef(null);t.useEffect((()=>l?E&&g?void M(null):(M("Chatbot authentication not configured: RequestExecutor and baseUrl are required"),void _(!1)):(M("systemPrompt is required for generic mode"),void _(!1))),[l,E,g]);const D=t.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{_(!0),M(null);const e=C||r.DEFAULT_MODEL;if(!r.ALLOWED_MODELS.includes(e))throw new Error(`Unsupported model: ${C||"default"}. Allowed models are: ${r.ALLOWED_MODELS.join(", ")}`);j({id:d||"generic",name:d?`${d} `:"Generic AI Assistant",model:e,systemPrompt:l,functions:c,tools:m})}catch(e){const s=(null==e?void 0:e.message)||"Failed to create AI system";M(s)}finally{_(!1)}}))),[C,l,d,c]);t.useEffect((()=>{l&&D()}),[D]),t.useEffect((()=>{q&&L&&q.id!==w.current&&(w.current=q.id,L(q)),q||(w.current=null)}),[q]);const{messages:O,conversation:R,sendMessage:T,isApiCallInProgress:U}=o.useAIChat({system:q||{id:"loading",name:"Loading...",model:r.DEFAULT_MODEL,systemPrompt:"Loading...",functions:[]},conversationId:h,skipInitialization:!q,customFunctions:c,functionHandler:p,responseFormat:y,onMessageReceived:v,displayInUI:f,maxToolCalls:x,maxTokens:A,apiAdapter:E&&g?n.createExecutorApiAdapter(E,g,I||void 0):()=>{throw new Error("Chatbot authentication not configured: RequestExecutor is required")}}),F={isReady:!!q&&!P,isLoading:P,isApiCallInProgress:U,system:q,messages:O,conversation:R,sendMessage:T,error:b};return s.jsxRuntimeExports.jsx(i.Provider,Object.assign({value:F},{children:u}))},exports.useAIContext=()=>{const e=t.useContext(i);if(!e)throw new Error("useAIContext must be used within an AIProvider");return e};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("../../../node_modules/react/jsx-runtime.js"),t=require("react"),o=require("../services/callToChatbot.js"),r=require("../services/useAIChat.js"),n=require("../types/ai.js");const i=t.createContext(null);exports.AIProvider=a=>{let{children:u,systemPrompt:l,systemId:d,functions:c,tools:m,functionHandler:p,onMessageReceived:v,displayInUI:f,maxToolCalls:x,maxTokens:A,requestExecutor:E,baseUrl:g,endpointPath:I,responseFormat:y,conversationId:h="default-session",customModel:C,onSystemReady:L}=a;const[q,j]=t.useState(null),[P,_]=t.useState(!0),[b,M]=t.useState(null),w=t.useRef(null);t.useEffect((()=>l?E&&g?void M(null):(M("Chatbot authentication not configured: RequestExecutor and baseUrl are required"),void _(!1)):(M("systemPrompt is required for generic mode"),void _(!1))),[l,E,g]);const D=t.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{_(!0),M(null);const e=C||n.DEFAULT_MODEL;if(!n.ALLOWED_MODELS.includes(e))throw new Error(`Unsupported model: ${C||"default"}. Allowed models are: ${n.ALLOWED_MODELS.join(", ")}`);j({id:d||"generic",name:d?`${d} `:"Generic AI Assistant",model:e,systemPrompt:l,functions:c,tools:m})}catch(e){const s=(null==e?void 0:e.message)||"Failed to create AI system";M(s)}finally{_(!1)}}))),[C,l,d,c]);t.useEffect((()=>{l&&D()}),[D]),t.useEffect((()=>{q&&L&&q.id!==w.current&&(w.current=q.id,L(q)),q||(w.current=null)}),[q]);const{messages:O,conversation:R,sendMessage:T,isApiCallInProgress:U}=r.useAIChat({system:q||{id:"loading",name:"Loading...",model:n.DEFAULT_MODEL,systemPrompt:"Loading...",functions:[]},conversationId:h,skipInitialization:!q,customFunctions:c,functionHandler:p,responseFormat:y,onMessageReceived:v,displayInUI:f,maxToolCalls:x,maxTokens:A,apiAdapter:E&&g?o.createExecutorApiAdapter(E,g,I||void 0):()=>{throw new Error("Chatbot authentication not configured: RequestExecutor is required")}}),F={isReady:!!q&&!P,isLoading:P,isApiCallInProgress:U,system:q,messages:O,conversation:R,sendMessage:T,error:b};return s.jsxRuntimeExports.jsx(i.Provider,Object.assign({value:F},{children:u}))},exports.useAIContext=()=>{const e=t.useContext(i);if(!e)throw new Error("useAIContext must be used within an AIProvider");return e};
@@ -1,4 +1,4 @@
1
- import { FunctionDefinition, GenericAIResponse, ApiRequestExecutor, ChatMessageItem, FunctionCallOutputItem, APIAdapter } from '../types';
1
+ import { APIAdapter, ApiRequestExecutor, ChatMessageItem, FunctionCallOutputItem, FunctionDefinition, GenericAIResponse } from '../types';
2
2
  export declare function createExecutorApiAdapter(executor: ApiRequestExecutor, baseUrl: string, endpointPath?: string): APIAdapter;
3
3
  export declare function callToChatbot(history: {
4
4
  role: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react"),t=require("../types/chat.js"),a=require("./aiService.js"),n=require("./db.js");exports.useAIChat=function(i){var o=this;let{system:r,conversationId:c,skipInitialization:d=!1,customFunctions:l,functionHandler:g,responseFormat:u,onMessageReceived:m,displayInUI:b,maxToolCalls:j,maxTokens:p,apiAdapter:O}=i;const[v,I]=s.useState((()=>t.createSessionRecord(c))),[S,f]=s.useState([]),[w,y]=s.useState(),[h,A]=s.useState(!1);s.useEffect((()=>{n.loadSession(c).then((e=>{var s;e&&(I(e),f(e.messages),y(null===(s=e.metadata)||void 0===s?void 0:s.lastResponseId))}))}),[c]);const R=s.useMemo((()=>d?null:new a.AIService({system:Object.assign(Object.assign({},r),{handleCallback:(e,s)=>{var t;null===(t=r.handleCallback)||void 0===t||t.call(r,e,s)}}),dispatchMessage:e=>{f((s=>[...s,e])),I((s=>{const t=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,e]});return n.saveSession(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:w})})),t}))},customFunctions:l,functionHandler:g,responseFormat:u,onMessageReceived:m,displayInUI:b,maxToolCalls:j,maxTokens:p,apiAdapter:O})),[r.id,d,p]);return{messages:S,conversation:v,sendMessage:function(s){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return e.__awaiter(o,void 0,void 0,(function*(){if(!R)return;const e={id:`u-${Date.now()}`,role:"user",content:s,timestamp:Date.now()};f((s=>[...s,e])),I((s=>{const t=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,e]});return n.saveSession(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:w})})),t})),A(!0);try{const s=yield R.generate([...S,e].map((e=>({role:e.role,content:e.content}))),c,t,w);(null==s?void 0:s.responseId)&&(y(s.responseId),I((e=>{const t=Object.assign(Object.assign({},e),{metadata:Object.assign(Object.assign({},e.metadata||{}),{lastResponseId:s.responseId})});return n.saveSession(t.sessionId,t),t})))}catch(e){const s=(null==e?void 0:e.message)||"Something went wrong. Please try again.",t={id:`err-${Date.now()}`,role:"system",content:s,timestamp:Date.now()};f((e=>[...e,t])),I((e=>{const s=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,t]});return n.saveSession(s.sessionId,Object.assign(Object.assign({},s),{metadata:Object.assign(Object.assign({},s.metadata||{}),{lastResponseId:w})})),s}))}finally{A(!1)}}))},isApiCallInProgress:h}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react"),t=require("../types/chat.js"),a=require("./aiService.js"),n=require("./db.js");exports.useAIChat=function(i){var o=this;let{system:r,conversationId:c,skipInitialization:d=!1,customFunctions:l,functionHandler:g,responseFormat:u,onMessageReceived:m,displayInUI:b,maxToolCalls:j,maxTokens:p,apiAdapter:O}=i;const[v,I]=s.useState((()=>t.createSessionRecord(c))),[S,f]=s.useState([]),[w,y]=s.useState(),[h,A]=s.useState(!1);s.useEffect((()=>{n.loadSession(c).then((e=>{var s;e&&(I(e),f(e.messages),y(null===(s=e.metadata)||void 0===s?void 0:s.lastResponseId))}))}),[c]);const R=s.useMemo((()=>d?null:new a.AIService({system:Object.assign(Object.assign({},r),{handleCallback:(e,s)=>{var t;null===(t=r.handleCallback)||void 0===t||t.call(r,e,s)}}),dispatchMessage:e=>{f((s=>[...s,e])),I((s=>{const t=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,e]});return n.saveSession(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:w})})),t}))},customFunctions:l,functionHandler:g,responseFormat:u,onMessageReceived:m,displayInUI:b,maxToolCalls:j,maxTokens:p,apiAdapter:O})),[r.id,d,b,u,j,p]);return{messages:S,conversation:v,sendMessage:function(s){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return e.__awaiter(o,void 0,void 0,(function*(){if(!R)return;const e={id:`u-${Date.now()}`,role:"user",content:s,timestamp:Date.now()};f((s=>[...s,e])),I((s=>{const t=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,e]});return n.saveSession(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:w})})),t})),A(!0);try{const s=yield R.generate([...S,e].map((e=>({role:e.role,content:e.content}))),c,t,w);(null==s?void 0:s.responseId)&&(y(s.responseId),I((e=>{const t=Object.assign(Object.assign({},e),{metadata:Object.assign(Object.assign({},e.metadata||{}),{lastResponseId:s.responseId})});return n.saveSession(t.sessionId,t),t})))}catch(e){const s=(null==e?void 0:e.message)||"Something went wrong. Please try again.",t={id:`err-${Date.now()}`,role:"system",content:s,timestamp:Date.now()};f((e=>[...e,t])),I((e=>{const s=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,t]});return n.saveSession(s.sessionId,Object.assign(Object.assign({},s),{metadata:Object.assign(Object.assign({},s.metadata||{}),{lastResponseId:w})})),s}))}finally{A(!1)}}))},isApiCallInProgress:h}};
@@ -159,7 +159,7 @@
159
159
  position: ${e=>e.postion?e.postion:"sticky"};
160
160
  top: ${e=>e.top?e.top:0}px;
161
161
  left: ${e=>e.left?e.left:0}px; //88
162
- width: ${e=>e.width?e.width:200}px;
162
+ width: ${e=>e.width?e.width:240}px;
163
163
  z-index: ${e=>e.zIndex?e.zIndex:2};
164
164
  background-color: ${e=>"brand"==e.theme?"#381062":t.COLORS.surface.standard};
165
165
  height: ${e=>e.isNewSidebar?"fit-content":"100vh"};
@@ -4,7 +4,6 @@ export interface AnalyticsTrendInterface {
4
4
  value?: number | string;
5
5
  trendPercent?: number;
6
6
  trendRaw?: number;
7
- trendRawString?: string;
8
7
  formatVal?: boolean;
9
8
  timeline?: 'today' | 'yesterday' | '7 days' | '30 days' | 'custom';
10
9
  customRange?: Date[];
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import t,{useState as i,useEffect as n}from"react";import{ShimmerComponentStyled as r}from"../shimmer/ShimmerComponent/ShimmerStyled.js";import s from"../../utils/DateUtils.js";import{COLORS as o}from"../../constants/Theme.js";import l from"../../assets/icons/arrow_down.svg.js";import a from"../../assets/icons/arrow_up.svg.js";import c from"../../assets/icons/info.svg.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as m}from"../tooltips/Tooltip.js";import{BodyCaption as g,Caption as h,TitleLarge as p,TitleMedium as j}from"../TypographyStyle.js";import{truncateValueForInternationalStore as y,truncateValueForIndianStore as x}from"./chart/utils/calcPercentage.js";import{AnalyticsTrendContainer as u,IconContainer as b}from"./CommonStyles.js";const f=i=>{let{title:n,value:s,trendPercent:l,type:a="horizontal",timeline:h,customRange:f,tooltip:T,card:S=!0,rightSeparator:w=!1,size:O="big",share:$=!1,formatVal:I,prefixSymbol:R,trailingIcon:C,onTrailIconClick:D,iconTooltipBody:L,funnelPercent:M,isLoading:k,trendRaw:z,trendRawString:F,suffixText:P,trendStyle:N,trendContainerStyle:_,trendIconStyle:W,containerStyle:A,prevTrendDiff:B,relativePercentageDiff:E,isInternationalStore:U,Icon:V,iconContainerStyle:q,tooltipTimelineText:G,customTimelineText:H}=i;const J="big"===O?p:j,K=void 0!==l?l<0?"negative":0===l?"neutral":"positive":void 0,Q=void 0!==l?$?Math.round(l):Math.abs(Math.round(l)):void 0;return e.jsx(u,Object.assign({card:S,style:Object.assign({},A)},{children:e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:V?12:4,borderRightWidth:w?1:0,borderRightColor:o.stroke.primary,borderRightStyle:"solid",paddingLeft:S?0:24,paddingRight:S?0:24,height:"100%",justifyContent:V?"flex-start":"space-between",alignItems:"center"},null!=_?_:{})},{children:[!!V&&e.jsx(b,Object.assign({style:Object.assign({},q)},{children:e.jsx(V,{})})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=N?N:{})},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsx(g,Object.assign({style:{color:o.content.secondary}},{children:n})),T&&e.jsx(m,Object.assign({body:T,placement:"right",width:300},{children:e.jsx("div",Object.assign({style:{display:"flex",cursor:"pointer",height:"100%"}},{children:e.jsx(c,{color:o.content.primary,height:16,width:16})}))}))]})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},$?{justifyContent:"space-between"}:{})},{children:[k&&e.jsx(r,{width:108,height:26}),!k&&e.jsx(J,Object.assign({style:{color:o.content.primary}},{children:void 0===s?"--":"number"==typeof s&&I?s>999?U?`${null!=R?R:""}${y(s)} ${null!=P?P:""}`:`${null!=R?R:""}${x(s)} ${null!=P?P:""}`:`${null!=R?R:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(s)} ${null!=P?P:""}`:`${null!=R?R:""}${s} ${null!=P?P:""}`})),"number"==typeof E&&e.jsx(d,{tagText:`${E}%`,theme:"light",type:"neutral"}),"horizontal"===a&&!k&&!$&&e.jsx(v,{timeline:h,customRange:f,percent:Q,direction:K,trendRaw:z,trendRawString:F,prefixSymbol:R,trendIconStyle:W,isInternationalStore:U,tooltipTimelineText:G,customTimelineText:H}),k&&!$&&"horizontal"===a&&e.jsx(r,{height:20,width:141,marginTop:6}),"vertical"===a&&!k&&void 0!==M&&e.jsx(d,{tagText:`${M} %`,theme:"light",type:"neutral"}),$&&!k&&void 0!==Q&&e.jsx(d,{tagText:`${Q} %`,theme:"light",type:"neutral"}),$||k||!B||0==B?e.jsx(e.Fragment,{}):e.jsx(d,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(B),theme:"light",type:"neutral"})]})),"vertical"===a&&!k&&!$&&e.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsx(v,{timeline:h,customRange:f,percent:Q,direction:K,trendRaw:z,trendRawString:F,prefixSymbol:R,trendIconStyle:W,isInternationalStore:U,tooltipTimelineText:G,customTimelineText:H})})),k&&"vertical"===a&&e.jsx(r,{height:20,width:141,marginTop:6})]})),L&&!k&&e.jsx(m,Object.assign({body:L,placement:"right"},{children:C&&e.jsx("div",Object.assign({className:"icon--holder",onClick:D},{children:t.createElement(C,{height:20,width:20,color:o.content.secondary})}))}))]}))}))},v=t=>{let{percent:r,direction:c,timeline:d,customRange:g,trendRaw:p,trendRawString:j,prefixSymbol:u,trendIconStyle:b,isInternationalStore:f,tooltipTimelineText:v,customTimelineText:T}=t;const S=()=>{const e=((null!=p?p:0)>0?"+":"")+(null!=u?u:"");return void 0===p?"--":`${null!=e?e:""}${(()=>{let e="--";if(p)return e=String(f?y(Math.abs(p)):x(Math.abs(p))),p<0?"-"+e:e})()}`},[w,O]=i(S()),[$,I]=i(T||"");n((()=>{T||I("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&g?s.getAnalyticsCustomDateTimelineText(g):"")}),[d,g]),n((()=>{O(S())}),[p]);const R="negative"===c?l:a,C="negative"===c?o.background.negative.vibrant:"positive"===c?o.background.positive.vibrant:o.content.placeholder;return e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof r&&e.jsx(R,{color:C,height:16,width:16,style:Object.assign({marginRight:2},null!=b?b:{})}),"number"==typeof r&&c&&e.jsxs(h,Object.assign({style:{color:C}},{children:["neutral"===c?0:r<1e3?r:">999","%"]})),!!p&&e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:`(${w})`})),!p&&((null==j?void 0:j.length)||0)>0&&e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:`${j}`})),d&&(v?e.jsx(m,Object.assign({body:v,placement:"bottom"},{children:e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:T||$}))})):e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:T||$})))]}))};export{f as AnalyticsTrend};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import t,{useState as i,useEffect as n}from"react";import{ShimmerComponentStyled as s}from"../shimmer/ShimmerComponent/ShimmerStyled.js";import r from"../../utils/DateUtils.js";import{COLORS as o}from"../../constants/Theme.js";import l from"../../assets/icons/arrow_down.svg.js";import a from"../../assets/icons/arrow_up.svg.js";import c from"../../assets/icons/info.svg.js";import{Tag as d}from"../tag/Tag.js";import{Tooltip as m}from"../tooltips/Tooltip.js";import{BodyCaption as g,Caption as h,TitleLarge as p,TitleMedium as j}from"../TypographyStyle.js";import{truncateValueForInternationalStore as y,truncateValueForIndianStore as x}from"./chart/utils/calcPercentage.js";import{AnalyticsTrendContainer as u,IconContainer as b}from"./CommonStyles.js";const f=i=>{let{title:n,value:r,trendPercent:l,type:a="horizontal",timeline:h,customRange:f,tooltip:T,card:O=!0,rightSeparator:S=!1,size:w="big",share:$=!1,formatVal:I,prefixSymbol:R,trailingIcon:C,onTrailIconClick:D,iconTooltipBody:M,funnelPercent:k,isLoading:L,trendRaw:z,suffixText:F,trendStyle:P,trendContainerStyle:N,trendIconStyle:_,containerStyle:W,prevTrendDiff:A,relativePercentageDiff:B,isInternationalStore:E,Icon:U,iconContainerStyle:V,tooltipTimelineText:q,customTimelineText:G}=i;const H="big"===w?p:j,J=void 0!==l?l<0?"negative":0===l?"neutral":"positive":void 0,K=void 0!==l?$?Math.round(l):Math.abs(Math.round(l)):void 0;return e.jsx(u,Object.assign({card:O,style:Object.assign({},W)},{children:e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:U?12:4,borderRightWidth:S?1:0,borderRightColor:o.stroke.primary,borderRightStyle:"solid",paddingLeft:O?0:24,paddingRight:O?0:24,height:"100%",justifyContent:U?"flex-start":"space-between",alignItems:"center"},null!=N?N:{})},{children:[!!U&&e.jsx(b,Object.assign({style:Object.assign({},V)},{children:e.jsx(U,{})})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"column",gap:4,height:"100%"},null!=P?P:{})},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:4,alignItems:"center"}},{children:[e.jsx(g,Object.assign({style:{color:o.content.secondary}},{children:n})),T&&e.jsx(m,Object.assign({body:T,placement:"right",width:300},{children:e.jsx("div",Object.assign({style:{display:"flex",cursor:"pointer",height:"100%"}},{children:e.jsx(c,{color:o.content.primary,height:16,width:16})}))}))]})),e.jsxs("div",Object.assign({style:Object.assign({display:"flex",flexDirection:"row",gap:12,alignItems:"center"},$?{justifyContent:"space-between"}:{})},{children:[L&&e.jsx(s,{width:108,height:26}),!L&&e.jsx(H,Object.assign({style:{color:o.content.primary}},{children:void 0===r?"--":"number"==typeof r&&I?r>999?E?`${null!=R?R:""}${y(r)} ${null!=F?F:""}`:`${null!=R?R:""}${x(r)} ${null!=F?F:""}`:`${null!=R?R:""}${new Intl.NumberFormat("en-IN",{maximumFractionDigits:2}).format(r)} ${null!=F?F:""}`:`${null!=R?R:""}${r} ${null!=F?F:""}`})),"number"==typeof B&&e.jsx(d,{tagText:`${B}%`,theme:"light",type:"neutral"}),"horizontal"===a&&!L&&!$&&e.jsx(v,{timeline:h,customRange:f,percent:K,direction:J,trendRaw:z,prefixSymbol:R,trendIconStyle:_,isInternationalStore:E,tooltipTimelineText:q,customTimelineText:G}),L&&!$&&"horizontal"===a&&e.jsx(s,{height:20,width:141,marginTop:6}),"vertical"===a&&!L&&void 0!==k&&e.jsx(d,{tagText:`${k} %`,theme:"light",type:"neutral"}),$&&!L&&void 0!==K&&e.jsx(d,{tagText:`${K} %`,theme:"light",type:"neutral"}),$||L||!A||0==A?e.jsx(e.Fragment,{}):e.jsx(d,{tagText:(e=>{const t=Math.abs(e);return t%1!=0?`${t.toFixed(1)} %`:`${t} %`})(A),theme:"light",type:"neutral"})]})),"vertical"===a&&!L&&!$&&e.jsx("div",Object.assign({style:{marginTop:10}},{children:e.jsx(v,{timeline:h,customRange:f,percent:K,direction:J,trendRaw:z,prefixSymbol:R,trendIconStyle:_,isInternationalStore:E,tooltipTimelineText:q,customTimelineText:G})})),L&&"vertical"===a&&e.jsx(s,{height:20,width:141,marginTop:6})]})),M&&!L&&e.jsx(m,Object.assign({body:M,placement:"right"},{children:C&&e.jsx("div",Object.assign({className:"icon--holder",onClick:D},{children:t.createElement(C,{height:20,width:20,color:o.content.secondary})}))}))]}))}))},v=t=>{let{percent:s,direction:c,timeline:d,customRange:g,trendRaw:p,prefixSymbol:j,trendIconStyle:u,isInternationalStore:b,tooltipTimelineText:f,customTimelineText:v}=t;const T=()=>{const e=((null!=p?p:0)>0?"+":"")+(null!=j?j:"");return void 0===p?"--":`${null!=e?e:""}${(()=>{let e="--";if(p)return e=String(b?y(Math.abs(p)):x(Math.abs(p))),p<0?"-"+e:e})()}`},[O,S]=i(T()),[w,$]=i(v||"");n((()=>{v||$("today"===d?"vs yesterday":"yesterday"===d?"vs 1 day before":"7 days"===d?"vs last 7 days":"30 days"===d?"vs last 30 days":"custom"===d&&g?r.getAnalyticsCustomDateTimelineText(g):"")}),[d,g]),n((()=>{S(T())}),[p]);const I="negative"===c?l:a,R="negative"===c?o.background.negative.vibrant:"positive"===c?o.background.positive.vibrant:o.content.placeholder;return e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",flexDirection:"row",flexWrap:"wrap"}},{children:["number"==typeof s&&e.jsx(I,{color:R,height:16,width:16,style:Object.assign({marginRight:2},null!=u?u:{})}),"number"==typeof s&&c&&e.jsxs(h,Object.assign({style:{color:R}},{children:["neutral"===c?0:s<1e3?s:">999","%"]})),!!p&&e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:`(${O})`})),d&&(f?e.jsx(m,Object.assign({body:f,placement:"bottom"},{children:e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:v||w}))})):e.jsx(h,Object.assign({style:{marginLeft:4,color:o.content.placeholder}},{children:v||w})))]}))};export{f as AnalyticsTrend};
@@ -1 +1 @@
1
- import{j as i}from"../../../../node_modules/react/jsx-runtime.js";import o from"../../../../assets/icons/maximize.svg.js";import{Chart as t,CategoryScale as e,LinearScale as a,BarElement as l,Tooltip as n,Legend as s}from"chart.js";import d from"chartjs-plugin-datalabels";import{useState as r,useMemo as c}from"react";import{Bar as u}from"react-chartjs-2";import{IconButton as v}from"../../../icon-button/IconButton.js";import{StyledModal as x}from"../../../modals/styledModal.js";import{TitleRegular as p,BodyTiny as g}from"../../../TypographyStyle.js";import{COLORS as b,FONTS as h}from"../../../../constants/Theme.js";import{truncateValueForInternationalStore as m,truncateValueForIndianStore as f}from"../utils/calcPercentage.js";import{GRAPH_ORIENTATION as y,COLOR_SCHEMA as j}from"./StackedBarChart.model.js";import{GraphContainerWrapper as A,HeaderIconWrapper as O}from"./StackedBarChart.styles.js";t.register(e,a,l,n,s,d);const C=t=>{var e,a,l,n,s,d,C,k,S,L,F,H,I,T,R,w,B,E,D,N,Z,z,P,G,$,W,_,M,q,V,Y,J,K,Q,U,X,ii,oi,ti,ei,ai,li,ni,si,di;const{headerIcons:ri=[],legendsAndIconDirection:ci="row"}=t,[ui,vi]=r(!1),xi=[250,1e3,800,1500,300,600],pi=0===t.yAxis.data.length,gi=["#5E07BB","#9E77ED","#D2AEFF","#F7D7FF","#CDE1FF","#92AFFA","#3935E1"],bi=["#E6C7FF","#FEC6C6","#FEDEF3","#DEEFFF","#FFD8B1","#C7E5FF","#FFD3E6","#C9FFE5","#FFE3C7","#D9D9FF"],hi=t.customBarColors?t.customBarColors:t.customColourScaleBrand||t.customColourScalePastel?t.colorSchema===j.PASTEL?t.customColourScalePastel:t.customColourScaleBrand:t.colorSchema===j.PASTEL?bi:gi,mi=t.customHoverColour,fi=c((()=>{var i,o,e;return Object.assign(Object.assign({barPercentage:(null==t?void 0:t.barPercentage)||.4,categoryPercentage:1,pointStyle:"circle",barWidth:t.barWidth,borderRadius:(null==t?void 0:t.borderRadius)||void 0},"object"==typeof(null==t?void 0:t.borderRadius)?{borderSkipped:!1}:{}),(null===(i=null==t?void 0:t.addBarGap)||void 0===i?void 0:i.flag)?{borderWidth:{top:(null===(o=null==t?void 0:t.addBarGap)||void 0===o?void 0:o.value)||2,bottom:(null===(e=null==t?void 0:t.addBarGap)||void 0===e?void 0:e.value)||2,right:0,left:0},borderColor:"transparent"}:{})}),[t.barWidth,null==t?void 0:t.borderRadius,null==t?void 0:t.barPercentage,null==t?void 0:t.addBarGap]),yi={};t.yAxis.data.map((i=>{i.map((i=>{yi[i.name]?yi[i.name].push(i.value):yi[i.name]=[i.value]}))}));const ji=Object.keys(yi).map(((i,o)=>Object.assign({label:i,data:yi[i],backgroundColor:null==hi?void 0:hi[o],hoverBackgroundColor:void 0===mi?void 0:mi[o]},fi))),Ai=t.renderInHeightWiseManner?ji.map(((i,o)=>Object.assign(Object.assign({},i),{order:i.data.reduce(((i,o)=>i+(o||0)),0)}))).sort(((i,o)=>o.order-i.order)):ji;let Oi=t.xAxis.data.map((i=>"string"==typeof i?i:i.name)),Ci=Ai;if(t.truncateBars){const i=((i,o,t)=>{if(o.length<=t)return{truncatedData:i,truncatedLabels:o,originalData:i,originalLabels:o};const e=i.map((i=>i.slice(0,t))),a=i.map((i=>i.slice(t).reduce(((i,o)=>i+o),0)));e.forEach(((i,o)=>i.push(a[o])));const l=o.slice(0,t);return l.push("Others"),{truncatedData:e,truncatedLabels:l,originalData:i,originalLabels:o}})(Ai.map((i=>i.data)),Oi,t.truncateBars);Ai.forEach(((o,t)=>o.data=i.truncatedData[t])),Oi=i.truncatedLabels,Ci=i.originalData.map(((i,o)=>Object.assign(Object.assign({},Ai[o]),{data:i})))}const ki={plugins:{legend:{display:!pi&&!t.customLegend,labels:{usePointStyle:!0,fontSize:2}},tooltip:{enabled:!pi,callbacks:{label:null===(e=t.tooltipConfig)||void 0===e?void 0:e.labelCallback,title:null===(a=t.tooltipConfig)||void 0===a?void 0:a.titleCallback,footer:null===(l=t.tooltipConfig)||void 0===l?void 0:l.footerCallback},footerFont:null===(s=null===(n=t.tooltipConfig)||void 0===n?void 0:n.footerStyles)||void 0===s?void 0:s.footerFont},datalabels:{display:null!==(d=t.showTotal)&&void 0!==d&&d,anchor:"end",align:"end",clamp:!0,formatter:(i,o)=>{var t;const e=o.datasetIndex,a=o.chart.data.datasets;if(e!==a.length-1)return"";const l=o.dataIndex;let n=0;for(let i=0;i<a.length;i++)n+=null!==(t=a[i].data[l])&&void 0!==t?t:0;return n?n<1e3?n:(n/1e3).toString().substring(0,4)+"k":""},color:b.content.secondary}},layout:{padding:{right:t.showTotal&&t.orientation===y.HORIZONTAL?50:0,top:t.showTotal&&t.orientation!=y.HORIZONTAL?50:0}},responsive:!0,maintainAspectRatio:!1,legend:{display:!t.customLegend,labels:{usePointStyle:!0}},indexAxis:t.orientation===y.HORIZONTAL?"y":"x",scales:{x:{title:{display:!!(t.orientation===y.HORIZONTAL?null===(C=t.yAxis)||void 0===C?void 0:C.title:null===(k=t.xAxis)||void 0===k?void 0:k.title),text:t.orientation===y.HORIZONTAL?null===(S=t.yAxis)||void 0===S?void 0:S.title:null===(L=t.xAxis)||void 0===L?void 0:L.title,color:null!==(I=t.orientation===y.HORIZONTAL?null===(F=t.yAxis)||void 0===F?void 0:F.titleColor:null===(H=t.xAxis)||void 0===H?void 0:H.titleColor)&&void 0!==I?I:b.content.secondary,font:{size:h.caption.fontSize}},grid:{display:t.orientation===y.HORIZONTAL&&(void 0===(null===(T=null==t?void 0:t.showGridLines)||void 0===T?void 0:T.x)||(null===(R=null==t?void 0:t.showGridLines)||void 0===R?void 0:R.x)),color:b.background.base},ticks:{fontSize:h.caption.fontSize,color:null!==(w=t.yAxis.labelColor)&&void 0!==w?w:b.content.secondary,callback:t.orientation===y.HORIZONTAL?i=>{var o;return`${t.isInternationalStore?m(i):f(i)}${(null===(o=t.yAxis)||void 0===o?void 0:o.axisSuffix)||""}`}:(null===(B=t.xAxis)||void 0===B?void 0:B.axisSuffix)?i=>`${i}${t.xAxis.axisSuffix}`:void 0},stacked:t.orientation===y.HORIZONTAL?"boolean"!=typeof(null===(E=t.yAxis)||void 0===E?void 0:E.stacked)||(null===(D=t.yAxis)||void 0===D?void 0:D.stacked):"boolean"!=typeof(null===(N=t.xAxis)||void 0===N?void 0:N.stacked)||(null===(Z=t.xAxis)||void 0===Z?void 0:Z.stacked)},y:Object.assign(Object.assign({},(null===(z=null==t?void 0:t.equalHeight)||void 0===z?void 0:z.flag)?{suggestedMin:-(null==t?void 0:t.equalHeight.max),suggestedMax:null==t?void 0:t.equalHeight.max}:{}),{max:null===(P=null==t?void 0:t.yAxis)||void 0===P?void 0:P.max,title:{display:!!(t.orientation===y.HORIZONTAL?null===(G=t.xAxis)||void 0===G?void 0:G.title:null===($=t.yAxis)||void 0===$?void 0:$.title),text:t.orientation===y.HORIZONTAL?null===(W=t.xAxis)||void 0===W?void 0:W.title:null===(_=t.yAxis)||void 0===_?void 0:_.title,color:null!==(V=t.orientation===y.HORIZONTAL?null===(M=t.xAxis)||void 0===M?void 0:M.titleColor:null===(q=t.yAxis)||void 0===q?void 0:q.titleColor)&&void 0!==V?V:b.content.secondary,font:{size:h.caption.fontSize}},grid:{display:t.orientation!==y.HORIZONTAL&&(void 0===(null===(Y=null==t?void 0:t.showGridLines)||void 0===Y?void 0:Y.y)||(null===(J=null==t?void 0:t.showGridLines)||void 0===J?void 0:J.y)),color:b.background.base},ticks:Object.assign(Object.assign({stepSize:t.orientation===y.HORIZONTAL?null===(K=t.xAxis)||void 0===K?void 0:K.stepSize:null===(Q=t.yAxis)||void 0===Q?void 0:Q.stepSize,fontSize:h.caption.fontSize,color:null!==(U=t.xAxis.labelColor)&&void 0!==U?U:b.content.secondary},pi?{min:0,max:2e3,stepSize:200}:{}),{callback:(null==t?void 0:t.ticksCallback)?null==t?void 0:t.ticksCallback:t.orientation===y.HORIZONTAL?i=>{var o;return`${t.isInternationalStore?m(i):f(i)}${(null===(o=t.xAxis)||void 0===o?void 0:o.axisSuffix)||""}`}:(null===(X=t.yAxis)||void 0===X?void 0:X.axisSuffix)?i=>`${i}${t.yAxis.axisSuffix}`:void 0}),stacked:t.orientation===y.HORIZONTAL?"boolean"!=typeof(null===(ii=t.xAxis)||void 0===ii?void 0:ii.stacked)||(null===(oi=t.xAxis)||void 0===oi?void 0:oi.stacked):"boolean"!=typeof(null===(ti=t.yAxis)||void 0===ti?void 0:ti.stacked)||(null===(ei=t.yAxis)||void 0===ei?void 0:ei.stacked)})},onClick:(i,o)=>{if(!t.onBarClick)return;const e=o[0].datasetIndex,a=o[0].index,l=i.chart.data.datasets[e].label,n=i.chart.data.labels[a];t.onBarClick(n,l)},onHover:(i,o)=>{t.onBarClick&&o.length&&(i.native.target.style.cursor="pointer")}};t.orientation&&t.orientation!==y.VERTICAL?delete ki.scales.y.ticks.callback:delete ki.scales.x.ticks.callback;const Si={labels:Oi,datasets:pi?[{data:xi,backgroundColor:"rgba(0,0,0,0)"}]:Ai},Li={labels:t.xAxis.data.map((i=>"string"==typeof i?i:i.name)),datasets:pi?[{data:xi,backgroundColor:"rgba(0,0,0,0)"}]:Ci},Fi=function(){let o=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return i.jsx("div",Object.assign({style:{overflowY:"scroll",display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:t.allowChartPopup&&!o?"flex-start":"flex-end",flexWrap:"wrap"}},{children:ji.map((o=>i.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[i.jsx("div",{style:{backgroundColor:o.backgroundColor,width:"16px",height:"16px",borderRadius:"2px"}}),i.jsx(g,Object.assign({color:b.content.secondary},{children:o.label}))]}),o.label.replace(" ","_"))))}))};return i.jsxs(A,Object.assign({style:null!==(ai=t.wrapperStyle)&&void 0!==ai?ai:{},padding:t.outerPadding,customLegend:t.customLegend},{children:[t.chartHeading&&i.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:t.hideHeading?"flex-end":"space-between"}},{children:[!0!==t.hideHeading&&i.jsx(p,Object.assign({color:null!==(li=t.chartHeading.color)&&void 0!==li?li:b.content.secondary},{children:t.chartHeading.heading})),t.allowChartPopup&&i.jsx("div",Object.assign({style:{display:"flex",justifyContent:"flex-end"}},{children:i.jsx("div",{children:i.jsx(v,{Icon:o,onClick:()=>{vi(!0)}})})}))]})),t.customLegend&&i.jsxs("div",Object.assign({style:{display:"flex",flexDirection:ci,justifyContent:"space-between"}},{children:[i.jsx(O,{children:ri.map(((o,t)=>i.jsx("div",{children:i.jsx("div",{children:o})},t)))}),Fi()]})),i.jsx("div",Object.assign({className:"graph__wrapper"},{children:i.jsx("div",Object.assign({style:{height:null!==(ni=t.graphCanvasHeight)&&void 0!==ni?ni:500,width:null!==(si=t.graphCanvasWidth)&&void 0!==si?si:"auto"}},{children:i.jsx(u,{options:ki,data:Si})}))})),ui&&i.jsx(x,Object.assign({open:ui,onClose:()=>vi(!1),closeOnOutsideClick:!0,headingTitle:null===(di=t.chartHeading)||void 0===di?void 0:di.heading,width:"85%"},{children:i.jsxs("div",Object.assign({className:"graph__wrapper",style:{padding:"8px"}},{children:[t.customLegend&&Fi(!0),i.jsx("div",Object.assign({style:{height:"70vh",width:"100%",padding:"16px",borderRadius:"8px"}},{children:i.jsx(u,{options:ki,data:Li})}))]}))}))]}))};export{C as StackedBarChart};
1
+ import{j as o}from"../../../../node_modules/react/jsx-runtime.js";import i from"../../../../assets/icons/maximize.svg.js";import{Chart as t,CategoryScale as e,LinearScale as a,BarElement as l,Tooltip as n,Legend as d}from"chart.js";import s from"chartjs-plugin-datalabels";import{useState as r,useMemo as c}from"react";import{Bar as u}from"react-chartjs-2";import{IconButton as v}from"../../../icon-button/IconButton.js";import{StyledModal as p}from"../../../modals/styledModal.js";import{TitleRegular as g,BodyTiny as x}from"../../../TypographyStyle.js";import{COLORS as b,FONTS as h}from"../../../../constants/Theme.js";import{truncateValueForInternationalStore as m,truncateValueForIndianStore as y}from"../utils/calcPercentage.js";import{COLOR_SCHEMA as f,GRAPH_ORIENTATION as j}from"./StackedBarChart.model.js";import{GraphContainerWrapper as O,HeaderIconWrapper as A}from"./StackedBarChart.styles.js";t.register(e,a,l,n,d,s);const C=t=>{var e,a,l,n,d,s,C,k,L,F,S,H,I,T,R,w,E,B,D,N,Z,z,P,G,W,_,q,M,V,Y,J,K,Q,U,X,$,oo,io,to,eo,ao,lo;const{headerIcons:no=[],legendsAndIconDirection:so="row"}=t,[ro,co]=r(!1),uo=[250,1e3,800,1500,300,600],vo=0===t.yAxis.data.length,po=void 0===t.customColourScaleBrand&&void 0===t.customColourScalePastel?t.colorSchema===f.PASTEL?["#E6C7FF","#FEC6C6","#FEDEF3","#DEEFFF","#FFD8B1","#C7E5FF","#FFD3E6","#C9FFE5","#FFE3C7","#D9D9FF"]:["#5E07BB","#9E77ED","#D2AEFF","#F7D7FF","#CDE1FF","#92AFFA","#3935E1"]:t.colorSchema===f.PASTEL?t.customColourScalePastel:t.customColourScaleBrand,go=t.customHoverColour,xo=c((()=>{var o,i,e;return Object.assign(Object.assign({barPercentage:(null==t?void 0:t.barPercentage)||.4,categoryPercentage:1,pointStyle:"circle",barWidth:t.barWidth,borderRadius:(null==t?void 0:t.borderRadius)||void 0},"object"==typeof(null==t?void 0:t.borderRadius)?{borderSkipped:!1}:{}),(null===(o=null==t?void 0:t.addBarGap)||void 0===o?void 0:o.flag)?{borderWidth:{top:(null===(i=null==t?void 0:t.addBarGap)||void 0===i?void 0:i.value)||2,bottom:(null===(e=null==t?void 0:t.addBarGap)||void 0===e?void 0:e.value)||2,right:0,left:0},borderColor:"transparent"}:{})}),[t.barWidth,null==t?void 0:t.borderRadius,null==t?void 0:t.barPercentage,null==t?void 0:t.addBarGap]),bo={};t.yAxis.data.map((o=>{o.map((o=>{bo[o.name]?bo[o.name].push(o.value):bo[o.name]=[o.value]}))}));const ho=Object.keys(bo).map(((o,i)=>Object.assign({label:o,data:bo[o],backgroundColor:null==po?void 0:po[i],hoverBackgroundColor:void 0===go?void 0:go[i]},xo)));let mo=t.xAxis.data.map((o=>"string"==typeof o?o:o.name)),yo=ho;if(t.truncateBars){const o=((o,i,t)=>{if(i.length<=t)return{truncatedData:o,truncatedLabels:i,originalData:o,originalLabels:i};const e=o.map((o=>o.slice(0,t))),a=o.map((o=>o.slice(t).reduce(((o,i)=>o+i),0)));e.forEach(((o,i)=>o.push(a[i])));const l=i.slice(0,t);return l.push("Others"),{truncatedData:e,truncatedLabels:l,originalData:o,originalLabels:i}})(ho.map((o=>o.data)),mo,t.truncateBars);ho.forEach(((i,t)=>i.data=o.truncatedData[t])),mo=o.truncatedLabels,yo=o.originalData.map(((o,i)=>Object.assign(Object.assign({},ho[i]),{data:o})))}const fo={plugins:{legend:{display:!vo&&!t.customLegend,labels:{usePointStyle:!0,fontSize:2}},tooltip:{enabled:!vo,callbacks:{label:null===(e=t.tooltipConfig)||void 0===e?void 0:e.labelCallback,title:null===(a=t.tooltipConfig)||void 0===a?void 0:a.titleCallback,footer:null===(l=t.tooltipConfig)||void 0===l?void 0:l.footerCallback},footerFont:null===(d=null===(n=t.tooltipConfig)||void 0===n?void 0:n.footerStyles)||void 0===d?void 0:d.footerFont},datalabels:{display:null!==(s=t.showTotal)&&void 0!==s&&s,anchor:"end",align:"end",clamp:!0,formatter:(o,i)=>{var t;const e=i.datasetIndex,a=i.chart.data.datasets;if(e!==a.length-1)return"";const l=i.dataIndex;let n=0;for(let o=0;o<a.length;o++)n+=null!==(t=a[o].data[l])&&void 0!==t?t:0;return n?n<1e3?n:(n/1e3).toString().substring(0,4)+"k":""},color:b.content.secondary}},layout:{padding:{right:t.showTotal&&t.orientation===j.HORIZONTAL?50:0,top:t.showTotal&&t.orientation!=j.HORIZONTAL?50:0}},responsive:!0,maintainAspectRatio:!1,legend:{display:!t.customLegend,labels:{usePointStyle:!0}},indexAxis:t.orientation===j.HORIZONTAL?"y":"x",scales:{x:{title:{display:!!(t.orientation===j.HORIZONTAL?null===(C=t.yAxis)||void 0===C?void 0:C.title:null===(k=t.xAxis)||void 0===k?void 0:k.title),text:t.orientation===j.HORIZONTAL?null===(L=t.yAxis)||void 0===L?void 0:L.title:null===(F=t.xAxis)||void 0===F?void 0:F.title,color:null!==(I=t.orientation===j.HORIZONTAL?null===(S=t.yAxis)||void 0===S?void 0:S.titleColor:null===(H=t.xAxis)||void 0===H?void 0:H.titleColor)&&void 0!==I?I:b.content.secondary,font:{size:h.caption.fontSize}},grid:{display:t.orientation===j.HORIZONTAL&&(void 0===(null===(T=null==t?void 0:t.showGridLines)||void 0===T?void 0:T.x)||(null===(R=null==t?void 0:t.showGridLines)||void 0===R?void 0:R.x)),color:b.background.base},ticks:{fontSize:h.caption.fontSize,color:null!==(w=t.yAxis.labelColor)&&void 0!==w?w:b.content.secondary,callback:t.orientation===j.HORIZONTAL?t.isInternationalStore?m:y:void 0},stacked:t.orientation===j.HORIZONTAL?"boolean"!=typeof(null===(E=t.yAxis)||void 0===E?void 0:E.stacked)||(null===(B=t.yAxis)||void 0===B?void 0:B.stacked):"boolean"!=typeof(null===(D=t.xAxis)||void 0===D?void 0:D.stacked)||(null===(N=t.xAxis)||void 0===N?void 0:N.stacked)},y:Object.assign(Object.assign({},(null===(Z=null==t?void 0:t.equalHeight)||void 0===Z?void 0:Z.flag)?{suggestedMin:-(null==t?void 0:t.equalHeight.max),suggestedMax:null==t?void 0:t.equalHeight.max}:{}),{title:{display:!!(t.orientation===j.HORIZONTAL?null===(z=t.xAxis)||void 0===z?void 0:z.title:null===(P=t.yAxis)||void 0===P?void 0:P.title),text:t.orientation===j.HORIZONTAL?null===(G=t.xAxis)||void 0===G?void 0:G.title:null===(W=t.yAxis)||void 0===W?void 0:W.title,color:null!==(M=t.orientation===j.HORIZONTAL?null===(_=t.xAxis)||void 0===_?void 0:_.titleColor:null===(q=t.yAxis)||void 0===q?void 0:q.titleColor)&&void 0!==M?M:b.content.secondary,font:{size:h.caption.fontSize}},grid:{display:t.orientation!==j.HORIZONTAL&&(void 0===(null===(V=null==t?void 0:t.showGridLines)||void 0===V?void 0:V.y)||(null===(Y=null==t?void 0:t.showGridLines)||void 0===Y?void 0:Y.y)),color:b.background.base},ticks:Object.assign(Object.assign({stepSize:t.orientation===j.HORIZONTAL?null===(J=t.xAxis)||void 0===J?void 0:J.stepSize:null===(K=t.yAxis)||void 0===K?void 0:K.stepSize,fontSize:h.caption.fontSize,color:null!==(Q=t.xAxis.labelColor)&&void 0!==Q?Q:b.content.secondary},vo?{min:0,max:2e3,stepSize:200}:{}),{callback:(null==t?void 0:t.ticksCallback)?null==t?void 0:t.ticksCallback:t.orientation!==j.VERTICAL?t.isInternationalStore?m:y:void 0}),stacked:t.orientation===j.HORIZONTAL?"boolean"!=typeof(null===(U=t.xAxis)||void 0===U?void 0:U.stacked)||(null===(X=t.xAxis)||void 0===X?void 0:X.stacked):"boolean"!=typeof(null===($=t.yAxis)||void 0===$?void 0:$.stacked)||(null===(oo=t.yAxis)||void 0===oo?void 0:oo.stacked)})},onClick:(o,i)=>{if(!t.onBarClick)return;const e=i[0].datasetIndex,a=i[0].index,l=o.chart.data.datasets[e].label,n=o.chart.data.labels[a];t.onBarClick(n,l)},onHover:(o,i)=>{t.onBarClick&&i.length&&(o.native.target.style.cursor="pointer")}};t.orientation&&t.orientation!==j.VERTICAL?delete fo.scales.y.ticks.callback:delete fo.scales.x.ticks.callback;const jo={labels:mo,datasets:vo?[{data:uo,backgroundColor:"rgba(0,0,0,0)"}]:ho},Oo={labels:t.xAxis.data.map((o=>"string"==typeof o?o:o.name)),datasets:vo?[{data:uo,backgroundColor:"rgba(0,0,0,0)"}]:yo},Ao=function(){let i=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return o.jsx("div",Object.assign({style:{overflowY:"scroll",display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:t.allowChartPopup&&!i?"flex-start":"flex-end",flexWrap:"wrap"}},{children:ho.map((i=>o.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[o.jsx("div",{style:{backgroundColor:i.backgroundColor,width:"16px",height:"16px",borderRadius:"2px"}}),o.jsx(x,Object.assign({color:b.content.secondary},{children:i.label}))]}),i.label.replace(" ","_"))))}))};return o.jsxs(O,Object.assign({style:null!==(io=t.wrapperStyle)&&void 0!==io?io:{},padding:t.outerPadding,customLegend:t.customLegend},{children:[t.chartHeading&&o.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:t.hideHeading?"flex-end":"space-between"}},{children:[!0!==t.hideHeading&&o.jsx(g,Object.assign({color:null!==(to=t.chartHeading.color)&&void 0!==to?to:b.content.secondary},{children:t.chartHeading.heading})),t.allowChartPopup&&o.jsx("div",Object.assign({style:{display:"flex",justifyContent:"flex-end"}},{children:o.jsx("div",{children:o.jsx(v,{Icon:i,onClick:()=>{co(!0)}})})}))]})),t.customLegend&&o.jsxs("div",Object.assign({style:{display:"flex",flexDirection:so,justifyContent:"space-between"}},{children:[o.jsx(A,{children:no.map(((i,t)=>o.jsx("div",{children:o.jsx("div",{children:i})},t)))}),Ao()]})),o.jsx("div",Object.assign({className:"graph__wrapper"},{children:o.jsx("div",Object.assign({style:{height:null!==(eo=t.graphCanvasHeight)&&void 0!==eo?eo:500,width:null!==(ao=t.graphCanvasWidth)&&void 0!==ao?ao:"auto"}},{children:o.jsx(u,{options:fo,data:jo})}))})),ro&&o.jsx(p,Object.assign({open:ro,onClose:()=>co(!1),closeOnOutsideClick:!0,headingTitle:null===(lo=t.chartHeading)||void 0===lo?void 0:lo.heading,width:"85%"},{children:o.jsxs("div",Object.assign({className:"graph__wrapper",style:{padding:"8px"}},{children:[t.customLegend&&Ao(!0),o.jsx("div",Object.assign({style:{height:"70vh",width:"100%",padding:"16px",borderRadius:"8px"}},{children:o.jsx(u,{options:fo,data:Oo})}))]}))}))]}))};export{C as StackedBarChart};
@@ -7,8 +7,6 @@ export interface AxisDetailsI {
7
7
  labelColor?: string;
8
8
  stepSize?: number;
9
9
  stacked?: boolean;
10
- axisSuffix?: string;
11
- max?: number;
12
10
  }
13
11
  export interface XAxisDataI {
14
12
  name: string;
@@ -60,7 +58,6 @@ export interface StackedBarGraphI {
60
58
  customColourScaleBrand?: string[];
61
59
  customColourScalePastel?: string[];
62
60
  customHoverColour?: string[];
63
- customBarColors?: string[];
64
61
  isInternationalStore?: boolean;
65
62
  truncateBars?: number;
66
63
  allowChartPopup?: boolean;
@@ -84,8 +81,7 @@ export interface StackedBarGraphI {
84
81
  flag: boolean;
85
82
  value: number;
86
83
  };
87
- ticksCallback?: (value: number | string) => string;
84
+ ticksCallback?: (value: number) => string;
88
85
  legendsAndIconDirection?: 'row-reverse' | 'row';
89
86
  headerIcons?: React.ReactNode[];
90
- renderInHeightWiseManner?: boolean;
91
87
  }
@@ -1 +1 @@
1
- import{j as i}from"../../../../node_modules/react/jsx-runtime.js";import{Chart as e,CategoryScale as o,LinearScale as t,BarElement as a,Tooltip as l}from"chart.js";import{Chart as s}from"react-chartjs-2";import{SmallRegular as r,TitleRegular as n,BodyTiny as d}from"../../../TypographyStyle.js";import{FONTS as x,COLORS as c}from"../../../../constants/Theme.js";import{LegendWrapper as p,LegendContainer as b,LegendColor as g}from"../LineChart/LineChart.styled.js";import{truncateValueForInternationalStore as A,truncateValueForIndianStore as f}from"../utils/calcPercentage.js";import{GraphContainerWrapper as u}from"./VerticalBarAndLinearGraph.styles.js";import{GRAPH_ORIENTATION as m}from"./VerticalBarAndLinearGraphModel.js";e.register(o,t,a,l);const h=e=>{var o,t,a,l,h,j,y,v,C,S;const k=[0,0,0,0,0,0],O=-1===e.barAxis.data.findIndex((i=>0!==i)),z=-1===e.lineAxis.data.findIndex((i=>0!==i)),I=!e.lineAxis2||-1===e.lineAxis2.data.findIndex((i=>0!==i)),$={min:0,max:2e3,stepSize:200},D=[{legend:e.barAxis.title,color:e.barAxis.graphColor},{legend:e.lineAxis.title,color:e.lineAxis.graphColor},...e.lineAxis2?[{legend:e.lineAxis2.title,color:e.lineAxis2.graphColor}]:[]],L={responsive:!0,plugins:{legend:{display:!1}},scales:{x:{title:{display:!!e.xAxis.title,text:e.xAxis.title,color:e.xAxis.titleColor,font:{size:x.caption.fontSize}},grid:{display:!1,borderColor:c.background.base},ticks:{fontSize:x.caption.fontSize,color:null!==(o=e.xAxis.labelColor)&&void 0!==o?o:c.content.secondary,callback:(null===(t=e.xAxis)||void 0===t?void 0:t.axisSuffix)?i=>`${i}${e.xAxis.axisSuffix}`:void 0}},bar:{position:"left",title:{display:!!e.barAxis.title,text:e.barAxis.title,color:e.barAxis.titleColor,font:{size:x.caption.fontSize}},grid:{borderColor:"white",color:c.background.base},max:null===(a=null==e?void 0:e.barAxis)||void 0===a?void 0:a.max,ticks:Object.assign(Object.assign({fontSize:x.caption.fontSize,color:null!==(l=e.barAxis.labelColor)&&void 0!==l?l:c.content.secondary},O?$:{}),{callback:e.orientation===m.HORIZONTAL?i=>{var o;return`${e.isInternationalStore?A(i):f(i)}${(null===(o=e.barAxis)||void 0===o?void 0:o.axisSuffix)||""}`}:(null===(h=e.barAxis)||void 0===h?void 0:h.axisSuffix)?i=>`${i}${e.barAxis.axisSuffix}`:void 0})},line:{position:"right",title:{display:!!e.lineAxis.title,text:e.lineAxis.title,color:e.lineAxis.titleColor,font:{size:x.caption.fontSize}},max:null===(j=null==e?void 0:e.lineAxis)||void 0===j?void 0:j.max,grid:{display:!1,borderColor:"white",color:c.background.base},ticks:Object.assign(Object.assign({fontSize:x.caption.fontSize,color:null!==(y=e.lineAxis.labelColor)&&void 0!==y?y:c.content.secondary},z?$:{}),{callback:e.orientation===m.HORIZONTAL?i=>{var o;return`${e.isInternationalStore?A(i):f(i)}${(null===(o=e.lineAxis)||void 0===o?void 0:o.axisSuffix)||""}`}:(null===(v=e.lineAxis)||void 0===v?void 0:v.axisSuffix)?i=>`${i}${e.lineAxis.axisSuffix}`:void 0}),display:!0}},maintainAspectRatio:!1};e.orientation&&e.orientation!==m.VERTICAL?(delete L.scales.bar.ticks.callback,delete L.scales.line.ticks.callback):delete L.scales.x.ticks.callback;const R={labels:e.xAxis.forceShowXAxis?e.xAxis.data.map((i=>i.toString())):O&&z&&I?["-","-","-","-","-","-"]:e.xAxis.data.map((i=>i.toString())),datasets:[{yAxisID:"line",type:"line",data:e.noDummyValues?e.lineAxis.data:z?k:e.lineAxis.data,borderColor:e.lineAxis.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1},...e.lineAxis2?[{yAxisID:"line",type:"line",data:e.noDummyValues?e.lineAxis2.data:I?k:e.lineAxis2.data,borderColor:e.lineAxis2.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1}]:[],{yAxisID:"bar",type:"bar",data:e.noDummyValues?e.barAxis.data:O?k:e.barAxis.data,backgroundColor:e.barAxis.graphColor||"rgba(0,0,0,0)",barPercentage:.4,categoryPercentage:1,borderRadius:4}]};return i.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:2}},{children:[e.customLegend?i.jsx("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"10px",padding:"0px 24px 12px 24px",justifyContent:"flex-end",flexWrap:"wrap"}},{children:D.map(((e,o)=>{let{legend:t,color:a}=e;return t?i.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"4px"}},{children:[i.jsx("div",{style:{backgroundColor:a,width:"16px",height:"16px",borderRadius:"2px"}}),i.jsx(d,Object.assign({color:c.content.secondary},{children:t}))]}),o):null}))})):i.jsx(p,Object.assign({position:"center"},{children:D.map(((e,o)=>{let{legend:t,color:a}=e;return t?i.jsxs(b,{children:[i.jsx(g,{color:a}),i.jsx(r,Object.assign({color:"#667085"},{children:t}))]},o):i.jsx(i.Fragment,{})}))})),i.jsxs(u,{children:[e.chartHeading&&i.jsx("div",Object.assign({style:{marginBottom:24}},{children:i.jsx(n,Object.assign({color:null!==(C=e.chartHeading.color)&&void 0!==C?C:c.content.secondary},{children:e.chartHeading.heading}))})),i.jsx("div",Object.assign({style:{height:null!==(S=e.graphCanvasHeight)&&void 0!==S?S:500}},{children:i.jsx(s,{type:"bar",data:R,options:L})}))]})]}))};export{h as VerticalBarAndLinearGraph};
1
+ import{j as i}from"../../../../node_modules/react/jsx-runtime.js";import{Chart as t,CategoryScale as e,LinearScale as o,BarElement as r,Tooltip as a}from"chart.js";import{Chart as s}from"react-chartjs-2";import{SmallRegular as l,TitleRegular as n}from"../../../TypographyStyle.js";import{FONTS as c,COLORS as d}from"../../../../constants/Theme.js";import{LegendWrapper as x,LegendContainer as p,LegendColor as g}from"../LineChart/LineChart.styled.js";import{GraphContainerWrapper as b}from"./VerticalBarAndLinearGraph.styles.js";t.register(e,o,r,a);const h=t=>{var e,o,r,a,h;const A=[0,0,0,0,0,0],j=-1===t.barAxis.data.findIndex((i=>0!==i)),m=-1===t.lineAxis.data.findIndex((i=>0!==i)),f={min:0,max:2e3,stepSize:200},y=[{legend:t.barAxis.title,color:t.barAxis.graphColor},{legend:t.lineAxis.title,color:t.lineAxis.graphColor}],C={responsive:!0,plugins:{legend:{display:!1}},scales:{x:{title:{display:!!t.xAxis.title,text:t.xAxis.title,color:t.xAxis.titleColor,font:{size:c.caption.fontSize}},grid:{display:!1,borderColor:d.background.base},ticks:{fontSize:c.caption.fontSize,color:null!==(e=t.xAxis.labelColor)&&void 0!==e?e:d.content.secondary}},bar:{position:"left",title:{display:!!t.barAxis.title,text:t.barAxis.title,color:t.barAxis.titleColor,font:{size:c.caption.fontSize}},grid:{borderColor:"white",color:d.background.base},ticks:Object.assign({fontSize:c.caption.fontSize,color:null!==(o=t.barAxis.labelColor)&&void 0!==o?o:d.content.secondary},j?f:{})},line:{position:"right",title:{display:!!t.lineAxis.title,text:t.lineAxis.title,color:t.lineAxis.titleColor,font:{size:c.caption.fontSize}},grid:{display:!1,borderColor:"white",color:d.background.base},ticks:Object.assign({fontSize:c.caption.fontSize,color:null!==(r=t.lineAxis.labelColor)&&void 0!==r?r:d.content.secondary},m?f:{}),display:!0}},maintainAspectRatio:!1},u={labels:t.xAxis.forceShowXAxis?t.xAxis.data.map((i=>i.toString())):j&&m?["-","-","-","-","-","-"]:t.xAxis.data.map((i=>i.toString())),datasets:[{yAxisID:"line",type:"line",data:m?A:t.lineAxis.data,borderColor:t.lineAxis.graphColor||"rgba(0,0,0,0)",borderWidth:2,fill:!1,pointRadius:1},{yAxisID:"bar",type:"bar",data:j?A:t.barAxis.data,backgroundColor:t.barAxis.graphColor||"rgba(0,0,0,0)",barPercentage:.4,categoryPercentage:1,borderRadius:4}]};return i.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:2}},{children:[i.jsx(x,Object.assign({position:"center"},{children:y.map(((t,e)=>{let{legend:o,color:r}=t;return o?i.jsxs(p,{children:[i.jsx(g,{color:r}),i.jsx(l,Object.assign({color:"#667085"},{children:o}))]},e):i.jsx(i.Fragment,{})}))})),i.jsxs(b,{children:[t.chartHeading&&i.jsx("div",Object.assign({style:{marginBottom:24}},{children:i.jsx(n,Object.assign({color:null!==(a=t.chartHeading.color)&&void 0!==a?a:d.content.secondary},{children:t.chartHeading.heading}))})),i.jsx("div",Object.assign({style:{height:null!==(h=t.graphCanvasHeight)&&void 0!==h?h:500}},{children:i.jsx(s,{type:"bar",data:u,options:C})}))]})]}))};export{h as VerticalBarAndLinearGraph};
@@ -4,17 +4,11 @@ export interface AxisDetailsI {
4
4
  data: number[] | string[];
5
5
  labelColor?: string;
6
6
  graphColor?: string;
7
- axisSuffix?: string;
8
- max?: number;
9
7
  }
10
8
  export interface ChartHeadingI {
11
9
  heading: string;
12
10
  color?: string;
13
11
  }
14
- export declare enum GRAPH_ORIENTATION {
15
- VERTICAL = "vertical",
16
- HORIZONTAL = "horizontal"
17
- }
18
12
  export interface VerticalBarAndLinearGraphI {
19
13
  graphCanvasHeight?: number;
20
14
  tickColor?: string;
@@ -24,10 +18,5 @@ export interface VerticalBarAndLinearGraphI {
24
18
  forceShowXAxis?: boolean;
25
19
  };
26
20
  lineAxis: AxisDetailsI;
27
- lineAxis2?: AxisDetailsI;
28
21
  barAxis: AxisDetailsI;
29
- isInternationalStore?: boolean;
30
- customLegend?: boolean;
31
- orientation?: GRAPH_ORIENTATION;
32
- noDummyValues?: boolean;
33
22
  }
@@ -1,4 +1,4 @@
1
- import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../../../assets/icons/Ai_event_generating.svg.js";import{useState as i,useRef as r,useEffect as n}from"react";import a from"styled-components";import{BodySecondary as o,BodyCaption as s}from"../../TypographyStyle.js";import{renderMarkdownLite as d}from"../utils/markdown.js";import l from"./ThinkingIndicator.js";const c=a.div`
1
+ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import i from"../../../assets/icons/Ai_event_generating.svg.js";import{useState as t,useRef as r,useEffect as n}from"react";import a from"styled-components";import{BodySecondary as o,BodyCaption as d}from"../../TypographyStyle.js";import{renderMarkdownLite as s}from"../utils/markdown.js";import l from"./ThinkingIndicator.js";const c=a.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: 100%;
@@ -130,13 +130,14 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
130
130
  padding: 8px 16px;
131
131
  border-radius: 8px;
132
132
  font-size: 13px;
133
- cursor: pointer;
133
+ cursor: ${e=>e.disabled?"not-allowed":"pointer"};
134
134
  transition: all 0.2s ease;
135
135
  text-align: left;
136
136
  max-width: 280px;
137
137
  align-self: flex-end;
138
+ opacity: ${e=>e.disabled?.5:1};
138
139
 
139
- &:hover {
140
+ &:hover:not(:disabled) {
140
141
  background: linear-gradient(
141
142
  92.69deg,
142
143
  rgba(255, 230, 238, 0.7) 0.37%,
@@ -145,7 +146,7 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
145
146
  border-color: #f472b6;
146
147
  }
147
148
 
148
- &:active {
149
+ &:active:not(:disabled) {
149
150
  transform: scale(0.98);
150
151
  }
151
152
  `,j=a.div`
@@ -162,26 +163,27 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
162
163
  border-radius: 8px;
163
164
  font-size: 13px;
164
165
  border: 1px solid #fecaca;
165
- cursor: pointer;
166
+ cursor: ${e=>e.disabled?"not-allowed":"pointer"};
166
167
  transition: all 0.2s ease;
167
168
  text-align: left;
169
+ opacity: ${e=>e.disabled?.5:1};
168
170
 
169
- &:hover {
171
+ &:hover:not(:disabled) {
170
172
  background: #fee2e2;
171
173
  border-color: #fca5a5;
172
174
  }
173
175
 
174
- &:active {
176
+ &:active:not(:disabled) {
175
177
  transform: scale(0.98);
176
178
  }
177
179
  `,T=a.div`
178
180
  padding: 16px;
179
181
  flex-shrink: 0;
180
- `,O=a.div`
182
+ `,$=a.div`
181
183
  position: relative;
182
184
  display: flex;
183
185
  width: 100%;
184
- `,S=a.textarea`
186
+ `,O=a.textarea`
185
187
  flex: 1;
186
188
  border: 1px solid ${e=>e.hasText?"#3b82f6":"#d1d5db"};
187
189
  border-radius: 12px;
@@ -208,7 +210,7 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
208
210
  &::placeholder {
209
211
  color: #9ca3af;
210
212
  }
211
- `,z=a.button`
213
+ `,S=a.button`
212
214
  position: absolute;
213
215
  bottom: 10px;
214
216
  right: 10px;
@@ -240,7 +242,7 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
240
242
  fill: white;
241
243
  font-weight: bold;
242
244
  }
243
- `,C=a.span`
245
+ `,z=a.span`
244
246
  background: linear-gradient(
245
247
  ${e=>e.angle||92.69}deg,
246
248
  ${e=>e.colors||"#ff166a 0.37%, #fb5f08 100%"}
@@ -249,4 +251,4 @@ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import t from"../
249
251
  -webkit-text-fill-color: transparent;
250
252
  background-clip: text;
251
253
  display: inline-block;
252
- `,$=a=>{let{messages:$,onSend:A,header:B="Create with AI",placeholder:I="Discover the right event & launch campaigns for better conversions...",suggestions:M=["Top festivals for marketing","Top events this week?","Top August festivals near you"],iceBreakers:_,videoStarter:D,disabled:H=!1,isThinking:L=!1,onIceBreakerClick:W,chatState:K,chatWindowHeight:E,inputDisabled:N=!1}=a;const[P,V]=i(""),[q,G]=i(!1),[J,Q]=i(!1),R=r(null),U=r(null),X=q||L,Y=H||N,Z=K||(q||L?"thinking":J&&P.trim().length>0?"typing":0===$.length?"conversation-starter":$.length>0?"conversation":"default"),ee=()=>{!P.trim()||Y||X||(A(P),V(""),G(!0),setTimeout((()=>G(!1)),1500))},te=P.trim().length>0,ie=Y||X||!te;n((()=>{var e;null===(e=R.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})}),[$,q,L]);const re=E||"100%";return e.jsxs(c,Object.assign({chatState:Z,style:{height:re}},{children:[e.jsxs(x,{children:[e.jsx(t,{height:24,width:24}),e.jsx("div",Object.assign({className:"header-text"},{children:B}))]}),e.jsxs(h,{children:[e.jsxs(g,{children:["conversation-starter"===Z&&D&&e.jsxs(p,{children:[e.jsx(b,{children:e.jsx(f,Object.assign({onClick:D.onPlay},{children:e.jsx("svg",Object.assign({viewBox:"0 0 24 24",fill:"currentColor"},{children:e.jsx("path",{d:"M8 5v14l11-7z"})}))}))}),e.jsxs(u,{children:[e.jsx(o,Object.assign({style:{fontWeight:500,marginBottom:"4px"}},{children:D.title})),e.jsx(s,{children:D.description})]})]}),$.map((t=>e.jsx(m,Object.assign({role:t.role},{children:"assistant"===t.role?e.jsx("div",{dangerouslySetInnerHTML:{__html:d(t.content)}}):e.jsx("div",Object.assign({style:{whiteSpace:"pre-wrap"}},{children:t.content}))}),t.id))),(q||L)&&e.jsx(l,{}),e.jsx("div",{ref:R})]}),_&&"conversation-starter"===Z&&e.jsx(k,{children:e.jsx(v,{children:_.map((t=>e.jsx(w,Object.assign({onClick:()=>{H||(null==W||W(t),A(t.text))}},{children:e.jsx(C,{children:t.text})}),t.id)))})}),!_&&M.length>0&&"default"===Z&&e.jsx(j,{children:e.jsx(y,{children:M.map((t=>e.jsx(F,Object.assign({onClick:()=>!H&&A(t)},{children:t}),t)))})}),e.jsx(T,{children:e.jsxs(O,{children:[e.jsx(S,{ref:U,value:P,onChange:e=>{if(Y)return;const t=e.target.value;V(t),Q(t.trim().length>0);const i=U.current;i&&(i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,117)}px`)},placeholder:I,onKeyDown:e=>{Y||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!X&&P.trim()&&ee())},disabled:Y,hasText:te,chatState:Z}),e.jsx(z,Object.assign({onClick:ee,disabled:ie,hasText:te,"aria-label":"Send"},{children:e.jsxs("svg",Object.assign({viewBox:"0 0 24 24",width:"20",height:"20",stroke:"white",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},{children:[e.jsx("path",{d:"M6 12h12"}),e.jsx("path",{d:"M12 6l6 6-6 6"})]}))}))]})})]})]}))};export{C as CustomGradientText,$ as default};
254
+ `,C=a=>{let{messages:C,onSend:A,header:B="Create with AI",placeholder:I="Discover the right event & launch campaigns for better conversions...",suggestions:M=["Top festivals for marketing","Top events this week?","Top August festivals near you"],iceBreakers:_,videoStarter:D,disabled:H=!1,isThinking:L=!1,onIceBreakerClick:W,chatState:K,chatWindowHeight:E,inputDisabled:N=!1}=a;const[P,V]=t(""),[q,G]=t(!1),[J,Q]=t(!1),R=r(null),U=r(null),X=q||L,Y=H||N,Z=K||(q||L?"thinking":J&&P.trim().length>0?"typing":0===C.length?"conversation-starter":C.length>0?"conversation":"default"),ee=()=>{!P.trim()||Y||X||(A(P),V(""),G(!0),setTimeout((()=>G(!1)),1500))},ie=P.trim().length>0,te=Y||X||!ie;n((()=>{var e;null===(e=R.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})}),[C,q,L]);const re=E||"100%";return e.jsxs(c,Object.assign({chatState:Z,style:{height:re}},{children:[e.jsxs(x,{children:[e.jsx(i,{height:24,width:24}),e.jsx("div",Object.assign({className:"header-text"},{children:B}))]}),e.jsxs(h,{children:[e.jsxs(g,{children:["conversation-starter"===Z&&D&&e.jsxs(p,{children:[e.jsx(b,{children:e.jsx(f,Object.assign({onClick:D.onPlay},{children:e.jsx("svg",Object.assign({viewBox:"0 0 24 24",fill:"currentColor"},{children:e.jsx("path",{d:"M8 5v14l11-7z"})}))}))}),e.jsxs(u,{children:[e.jsx(o,Object.assign({style:{fontWeight:500,marginBottom:"4px"}},{children:D.title})),e.jsx(d,{children:D.description})]})]}),C.map((i=>e.jsx(m,Object.assign({role:i.role},{children:"assistant"===i.role?e.jsx("div",{dangerouslySetInnerHTML:{__html:s(i.content)}}):e.jsx("div",Object.assign({style:{whiteSpace:"pre-wrap"}},{children:i.content}))}),i.id))),(q||L)&&e.jsx(l,{}),e.jsx("div",{ref:R})]}),_&&"conversation-starter"===Z&&e.jsx(k,{children:e.jsx(v,{children:_.map((i=>e.jsx(w,Object.assign({disabled:Y,onClick:()=>{Y||(null==W||W(i),A(i.text))}},{children:e.jsx(z,{children:i.text})}),i.id)))})}),!_&&M.length>0&&"default"===Z&&e.jsx(j,{children:e.jsx(y,{children:M.map((i=>e.jsx(F,Object.assign({disabled:Y,onClick:()=>!Y&&A(i)},{children:i}),i)))})}),e.jsx(T,{children:e.jsxs($,{children:[e.jsx(O,{ref:U,value:P,onChange:e=>{if(Y)return;const i=e.target.value;V(i),Q(i.trim().length>0);const t=U.current;t&&(t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,117)}px`)},placeholder:I,onKeyDown:e=>{Y||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),!X&&P.trim()&&ee())},disabled:Y,hasText:ie,chatState:Z}),e.jsx(S,Object.assign({onClick:ee,disabled:te,hasText:ie,"aria-label":"Send"},{children:e.jsxs("svg",Object.assign({viewBox:"0 0 24 24",width:"20",height:"20",stroke:"white",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},{children:[e.jsx("path",{d:"M6 12h12"}),e.jsx("path",{d:"M12 6l6 6-6 6"})]}))}))]})})]})]}))};export{z as CustomGradientText,C as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{j as o}from"../../../node_modules/react/jsx-runtime.js";import{useState as s,useRef as t,useEffect as n,useCallback as r,useContext as i,createContext as a}from"react";import{useAIChat as l}from"../services/useAIChat.js";import{DEFAULT_MODEL as d,ALLOWED_MODELS as c}from"../types/ai.js";import{createExecutorApiAdapter as u}from"../services/callToChatbot.js";const m=a(null),p=i=>{let{children:a,systemPrompt:p,systemId:f,functions:v,tools:g,functionHandler:y,onMessageReceived:I,displayInUI:h,maxToolCalls:x,maxTokens:j,requestExecutor:A,baseUrl:C,endpointPath:P,responseFormat:b,conversationId:w="default-session",customModel:q,onSystemReady:E}=i;const[R,M]=s(null),[T,U]=s(!0),[F,k]=s(null),L=t(null);n((()=>p?A&&C?void k(null):(k("Chatbot authentication not configured: RequestExecutor and baseUrl are required"),void U(!1)):(k("systemPrompt is required for generic mode"),void U(!1))),[p,A,C]);const $=r((()=>e(void 0,void 0,void 0,(function*(){try{U(!0),k(null);const e=q||d;if(!c.includes(e))throw new Error(`Unsupported model: ${q||"default"}. Allowed models are: ${c.join(", ")}`);M({id:f||"generic",name:f?`${f} `:"Generic AI Assistant",model:e,systemPrompt:p,functions:v,tools:g})}catch(e){const o=(null==e?void 0:e.message)||"Failed to create AI system";k(o)}finally{U(!1)}}))),[q,p,f,v]);n((()=>{p&&$()}),[$]),n((()=>{R&&E&&R.id!==L.current&&(L.current=R.id,E(R)),R||(L.current=null)}),[R]);const{messages:_,conversation:H,sendMessage:z,isApiCallInProgress:G}=l({system:R||{id:"loading",name:"Loading...",model:d,systemPrompt:"Loading...",functions:[]},conversationId:w,skipInitialization:!R,customFunctions:v,functionHandler:y,responseFormat:b,onMessageReceived:I,displayInUI:h,maxToolCalls:x,maxTokens:j,apiAdapter:A&&C?u(A,C,P||void 0):()=>{throw new Error("Chatbot authentication not configured: RequestExecutor is required")}}),O={isReady:!!R&&!T,isLoading:T,isApiCallInProgress:G,system:R,messages:_,conversation:H,sendMessage:z,error:F};return o.jsx(m.Provider,Object.assign({value:O},{children:a}))},f=()=>{const e=i(m);if(!e)throw new Error("useAIContext must be used within an AIProvider");return e};export{p as AIProvider,f as useAIContext};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{j as o}from"../../../node_modules/react/jsx-runtime.js";import{useState as s,useRef as t,useEffect as n,useCallback as r,useContext as i,createContext as a}from"react";import{createExecutorApiAdapter as l}from"../services/callToChatbot.js";import{useAIChat as d}from"../services/useAIChat.js";import{DEFAULT_MODEL as c,ALLOWED_MODELS as u}from"../types/ai.js";const m=a(null),p=i=>{let{children:a,systemPrompt:p,systemId:f,functions:v,tools:g,functionHandler:y,onMessageReceived:I,displayInUI:h,maxToolCalls:x,maxTokens:j,requestExecutor:A,baseUrl:C,endpointPath:P,responseFormat:b,conversationId:w="default-session",customModel:q,onSystemReady:E}=i;const[R,M]=s(null),[T,U]=s(!0),[F,k]=s(null),L=t(null);n((()=>p?A&&C?void k(null):(k("Chatbot authentication not configured: RequestExecutor and baseUrl are required"),void U(!1)):(k("systemPrompt is required for generic mode"),void U(!1))),[p,A,C]);const $=r((()=>e(void 0,void 0,void 0,(function*(){try{U(!0),k(null);const e=q||c;if(!u.includes(e))throw new Error(`Unsupported model: ${q||"default"}. Allowed models are: ${u.join(", ")}`);M({id:f||"generic",name:f?`${f} `:"Generic AI Assistant",model:e,systemPrompt:p,functions:v,tools:g})}catch(e){const o=(null==e?void 0:e.message)||"Failed to create AI system";k(o)}finally{U(!1)}}))),[q,p,f,v]);n((()=>{p&&$()}),[$]),n((()=>{R&&E&&R.id!==L.current&&(L.current=R.id,E(R)),R||(L.current=null)}),[R]);const{messages:_,conversation:H,sendMessage:z,isApiCallInProgress:G}=d({system:R||{id:"loading",name:"Loading...",model:c,systemPrompt:"Loading...",functions:[]},conversationId:w,skipInitialization:!R,customFunctions:v,functionHandler:y,responseFormat:b,onMessageReceived:I,displayInUI:h,maxToolCalls:x,maxTokens:j,apiAdapter:A&&C?l(A,C,P||void 0):()=>{throw new Error("Chatbot authentication not configured: RequestExecutor is required")}}),O={isReady:!!R&&!T,isLoading:T,isApiCallInProgress:G,system:R,messages:_,conversation:H,sendMessage:z,error:F};return o.jsx(m.Provider,Object.assign({value:O},{children:a}))},f=()=>{const e=i(m);if(!e)throw new Error("useAIContext must be used within an AIProvider");return e};export{p as AIProvider,f as useAIContext};
@@ -1,4 +1,4 @@
1
- import { FunctionDefinition, GenericAIResponse, ApiRequestExecutor, ChatMessageItem, FunctionCallOutputItem, APIAdapter } from '../types';
1
+ import { APIAdapter, ApiRequestExecutor, ChatMessageItem, FunctionCallOutputItem, FunctionDefinition, GenericAIResponse } from '../types';
2
2
  export declare function createExecutorApiAdapter(executor: ApiRequestExecutor, baseUrl: string, endpointPath?: string): APIAdapter;
3
3
  export declare function callToChatbot(history: {
4
4
  role: string;
@@ -1 +1 @@
1
- import{__awaiter as s}from"../../../_virtual/_tslib.js";import{useState as e,useEffect as t,useMemo as a}from"react";import{createSessionRecord as n}from"../types/chat.js";import{AIService as o}from"./aiService.js";import{loadSession as i,saveSession as c}from"./db.js";function r(r){var d=this;let{system:l,conversationId:m,skipInitialization:g=!1,customFunctions:p,functionHandler:b,responseFormat:j,onMessageReceived:u,displayInUI:O,maxToolCalls:I,maxTokens:v,apiAdapter:f}=r;const[w,y]=e((()=>n(m))),[h,D]=e([]),[R,A]=e(),[k,x]=e(!1);t((()=>{i(m).then((s=>{var e;s&&(y(s),D(s.messages),A(null===(e=s.metadata)||void 0===e?void 0:e.lastResponseId))}))}),[m]);const C=a((()=>g?null:new o({system:Object.assign(Object.assign({},l),{handleCallback:(s,e)=>{var t;null===(t=l.handleCallback)||void 0===t||t.call(l,s,e)}}),dispatchMessage:s=>{D((e=>[...e,s])),y((e=>{const t=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,s]});return c(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:R})})),t}))},customFunctions:p,functionHandler:b,responseFormat:j,onMessageReceived:u,displayInUI:O,maxToolCalls:I,maxTokens:v,apiAdapter:f})),[l.id,g,v]);return{messages:h,conversation:w,sendMessage:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return s(d,void 0,void 0,(function*(){if(!C)return;const s={id:`u-${Date.now()}`,role:"user",content:e,timestamp:Date.now()};D((e=>[...e,s])),y((e=>{const t=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,s]});return c(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:R})})),t})),x(!0);try{const e=yield C.generate([...h,s].map((s=>({role:s.role,content:s.content}))),m,t,R);(null==e?void 0:e.responseId)&&(A(e.responseId),y((s=>{const t=Object.assign(Object.assign({},s),{metadata:Object.assign(Object.assign({},s.metadata||{}),{lastResponseId:e.responseId})});return c(t.sessionId,t),t})))}catch(s){const e=(null==s?void 0:s.message)||"Something went wrong. Please try again.",t={id:`err-${Date.now()}`,role:"system",content:e,timestamp:Date.now()};D((s=>[...s,t])),y((s=>{const e=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,t]});return c(e.sessionId,Object.assign(Object.assign({},e),{metadata:Object.assign(Object.assign({},e.metadata||{}),{lastResponseId:R})})),e}))}finally{x(!1)}}))},isApiCallInProgress:k}}export{r as useAIChat};
1
+ import{__awaiter as s}from"../../../_virtual/_tslib.js";import{useState as e,useEffect as t,useMemo as a}from"react";import{createSessionRecord as n}from"../types/chat.js";import{AIService as o}from"./aiService.js";import{loadSession as i,saveSession as c}from"./db.js";function r(r){var d=this;let{system:l,conversationId:m,skipInitialization:g=!1,customFunctions:p,functionHandler:b,responseFormat:j,onMessageReceived:u,displayInUI:O,maxToolCalls:I,maxTokens:v,apiAdapter:f}=r;const[w,y]=e((()=>n(m))),[h,D]=e([]),[R,A]=e(),[k,x]=e(!1);t((()=>{i(m).then((s=>{var e;s&&(y(s),D(s.messages),A(null===(e=s.metadata)||void 0===e?void 0:e.lastResponseId))}))}),[m]);const C=a((()=>g?null:new o({system:Object.assign(Object.assign({},l),{handleCallback:(s,e)=>{var t;null===(t=l.handleCallback)||void 0===t||t.call(l,s,e)}}),dispatchMessage:s=>{D((e=>[...e,s])),y((e=>{const t=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,s]});return c(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:R})})),t}))},customFunctions:p,functionHandler:b,responseFormat:j,onMessageReceived:u,displayInUI:O,maxToolCalls:I,maxTokens:v,apiAdapter:f})),[l.id,g,O,j,I,v]);return{messages:h,conversation:w,sendMessage:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return s(d,void 0,void 0,(function*(){if(!C)return;const s={id:`u-${Date.now()}`,role:"user",content:e,timestamp:Date.now()};D((e=>[...e,s])),y((e=>{const t=Object.assign(Object.assign({},e),{updatedAt:Date.now(),messages:[...e.messages,s]});return c(t.sessionId,Object.assign(Object.assign({},t),{metadata:Object.assign(Object.assign({},t.metadata||{}),{lastResponseId:R})})),t})),x(!0);try{const e=yield C.generate([...h,s].map((s=>({role:s.role,content:s.content}))),m,t,R);(null==e?void 0:e.responseId)&&(A(e.responseId),y((s=>{const t=Object.assign(Object.assign({},s),{metadata:Object.assign(Object.assign({},s.metadata||{}),{lastResponseId:e.responseId})});return c(t.sessionId,t),t})))}catch(s){const e=(null==s?void 0:s.message)||"Something went wrong. Please try again.",t={id:`err-${Date.now()}`,role:"system",content:e,timestamp:Date.now()};D((s=>[...s,t])),y((s=>{const e=Object.assign(Object.assign({},s),{updatedAt:Date.now(),messages:[...s.messages,t]});return c(e.sessionId,Object.assign(Object.assign({},e),{metadata:Object.assign(Object.assign({},e.metadata||{}),{lastResponseId:R})})),e}))}finally{x(!1)}}))},isApiCallInProgress:k}}export{r as useAIChat};
@@ -159,7 +159,7 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
159
159
  position: ${e=>e.postion?e.postion:"sticky"};
160
160
  top: ${e=>e.top?e.top:0}px;
161
161
  left: ${e=>e.left?e.left:0}px; //88
162
- width: ${e=>e.width?e.width:200}px;
162
+ width: ${e=>e.width?e.width:240}px;
163
163
  z-index: ${e=>e.zIndex?e.zIndex:2};
164
164
  background-color: ${e=>"brand"==e.theme?"#381062":i.surface.standard};
165
165
  height: ${e=>e.isNewSidebar?"fit-content":"100vh"};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.719-beta.1",
3
+ "version": "0.0.720-beta.0",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GRAPH_ORIENTATION=void 0,(e=exports.GRAPH_ORIENTATION||(exports.GRAPH_ORIENTATION={})).VERTICAL="vertical",e.HORIZONTAL="horizontal";
@@ -1 +0,0 @@
1
- var o;!function(o){o.VERTICAL="vertical",o.HORIZONTAL="horizontal"}(o||(o={}));export{o as GRAPH_ORIENTATION};