@e-llm-studio/federated-dashboard-components 2.2.9-rca-test-16 → 2.2.9-rca-test-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExecutiveDashboard/api/insightsApi.js +1 -1
- package/dist/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
- package/dist/ExecutiveDashboard/components/Graph/axisDomain.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/CommentsThread.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/InsightTabs.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/KpiChart.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/L1Report.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/NeedsAttention.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/ReportDrawer.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/agPrimitives.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/drillDay.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/insightsErrors.js +2 -0
- package/dist/ExecutiveDashboard/components/Insights/insightsErrors.js.map +1 -0
- package/dist/ExecutiveDashboard/components/Insights/insightsFormat.js +1 -1
- package/dist/ExecutiveDashboard/components/Insights/insightsUtils.js +1 -1
- package/dist/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.js +1 -1
- package/dist/ExecutiveDashboard/components/Table/TableCard.js +1 -1
- package/dist/HumanIntelligence/HumanChangesTableWrapper.js +1 -1
- package/dist/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.js +1 -1
- package/dist/HumanIntelligence/components/HumanChangesSummary/HumanChangesSummary.js +1 -1
- package/dist/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.js +1 -1
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js +2 -0
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js.map +1 -0
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js +2 -0
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js.map +1 -0
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js +2 -0
- package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js.map +1 -0
- package/dist/HumanIntelligence/hooks/accessToken.js +2 -0
- package/dist/HumanIntelligence/hooks/accessToken.js.map +1 -0
- package/dist/HumanIntelligence/hooks/useHumanChangesData.js +1 -1
- package/dist/HumanIntelligence/utils/inlineMarkup.js +1 -1
- package/dist/cjs/ExecutiveDashboard/api/insightsApi.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Graph/axisDomain.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/CommentsThread.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/InsightTabs.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/KpiChart.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/L1Report.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/NeedsAttention.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/ReportDrawer.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/agPrimitives.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/drillDay.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/insightsErrors.js +2 -0
- package/dist/cjs/ExecutiveDashboard/components/Insights/insightsErrors.js.map +1 -0
- package/dist/cjs/ExecutiveDashboard/components/Insights/insightsFormat.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Insights/insightsUtils.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.js +1 -1
- package/dist/cjs/ExecutiveDashboard/components/Table/TableCard.js +1 -1
- package/dist/cjs/HumanIntelligence/HumanChangesTableWrapper.js +1 -1
- package/dist/cjs/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.js +1 -1
- package/dist/cjs/HumanIntelligence/components/HumanChangesSummary/HumanChangesSummary.js +1 -1
- package/dist/cjs/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.js +1 -1
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js +2 -0
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js.map +1 -0
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js +2 -0
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js.map +1 -0
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js +2 -0
- package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js.map +1 -0
- package/dist/cjs/HumanIntelligence/hooks/accessToken.js +2 -0
- package/dist/cjs/HumanIntelligence/hooks/accessToken.js.map +1 -0
- package/dist/cjs/HumanIntelligence/hooks/useHumanChangesData.js +1 -1
- package/dist/cjs/HumanIntelligence/utils/inlineMarkup.js +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/ExecutiveDashboard/TestExecutiveDashboard.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/api/insightsApi.d.ts +9 -0
- package/dist/types/ExecutiveDashboard/api/insightsApi.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/LineChart.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/axisDomain.d.ts +4 -4
- package/dist/types/ExecutiveDashboard/components/Graph/axisDomain.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts +2 -0
- package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/AgReport.d.ts +18 -3
- package/dist/types/ExecutiveDashboard/components/Insights/AgReport.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/CommentsThread.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/DrillTable.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/InsightTabs.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/KpiChart.d.ts +28 -2
- package/dist/types/ExecutiveDashboard/components/Insights/KpiChart.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/L1Report.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/NeedsAttention.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/ReportDrawer.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/agPrimitives.d.ts +7 -1
- package/dist/types/ExecutiveDashboard/components/Insights/agPrimitives.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts +9 -4
- package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Insights/insightsErrors.d.ts +11 -0
- package/dist/types/ExecutiveDashboard/components/Insights/insightsErrors.d.ts.map +1 -0
- package/dist/types/ExecutiveDashboard/components/Insights/insightsFormat.d.ts +38 -0
- package/dist/types/ExecutiveDashboard/components/Insights/insightsFormat.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/components/Table/TableCard.d.ts +6 -1
- package/dist/types/ExecutiveDashboard/components/Table/TableCard.d.ts.map +1 -1
- package/dist/types/ExecutiveDashboard/types/insights.d.ts +10 -0
- package/dist/types/ExecutiveDashboard/types/insights.d.ts.map +1 -1
- package/dist/types/HumanIntelligence/HumanChangesTableWrapper.d.ts.map +1 -1
- package/dist/types/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.d.ts +2 -0
- package/dist/types/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.d.ts.map +1 -1
- package/dist/types/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.d.ts +2 -0
- package/dist/types/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.d.ts.map +1 -1
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.d.ts +5 -0
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.d.ts.map +1 -0
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/parser.d.ts +20 -0
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/parser.d.ts.map +1 -0
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/types.d.ts +45 -0
- package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/types.d.ts.map +1 -0
- package/dist/types/HumanIntelligence/hooks/accessToken.d.ts +13 -0
- package/dist/types/HumanIntelligence/hooks/accessToken.d.ts.map +1 -0
- package/dist/types/HumanIntelligence/hooks/useHumanChangesData.d.ts +12 -4
- package/dist/types/HumanIntelligence/hooks/useHumanChangesData.d.ts.map +1 -1
- package/dist/types/HumanIntelligence/utils/inlineMarkup.d.ts +2 -0
- package/dist/types/HumanIntelligence/utils/inlineMarkup.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as n,__spreadArray as r}from"../../_virtual/_tslib.js";import{useState as
|
|
1
|
+
import{__awaiter as e,__generator as n,__spreadArray as r,__assign as t}from"../../_virtual/_tslib.js";import{useState as o,useRef as i,useCallback as a,useEffect as s}from"react";import{useAccessToken as c,authHeader as u}from"./accessToken.js";function l(e,n){var r,t,o;return{id:null!==(r=e.humanChangeId)&&void 0!==r?r:"row_".concat(n),humanChangeId:e.humanChangeId,humanChangeScopeId:e.humanChangeScopeId,intentId:e.intentId,scopeId:e.scopeId,scopeName:e.scopeName,level:e.level,title:null!==(o=null!==(t=e.title)&&void 0!==t?t:e.summary)&&void 0!==o?o:"—",summary:e.summary,frequency:e.occurrenceFrequency,reviewStatus:e.reviewStatus,impactLabel:e.impactLabel,kpi:e.kpi,blastRadius:e.blastRadius,hasChildren:e.hasChildren,childrenCount:e.childrenCount,cognitiveDecisioning:e.cognitiveDecisioning,raw:e}}function d(d){var h=this,f=d.baseUrl,g=d.endpoint,v=d.accessToken,p=d.humanChangeConfigId,m=d.eventId,y=d.filters,b=d.pageSize,w=void 0===b?12:b,I=c(v),C=o([]),S=C[0],x=C[1],N=o(!1),T=N[0],A=N[1],j=o(!1),O=j[0],k=j[1],E=o(null),P=E[0],_=E[1],J=o(!0),F=J[0],M=J[1],z=i(void 0),L=i(0),U=i(null),q=f&&g?"".concat(f).concat(g):void 0,R=a(function(o){return e(h,void 0,void 0,function(){var e,i,a,s,c,d,h,f,g,v,b,C,S;return n(this,function(n){switch(n.label){case 0:if(!q||!p)return[2];null===(S=U.current)||void 0===S||S.abort(),e=new AbortController,U.current=e,i=++L.current,o.append?k(!0):A(!0),_(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),a={humanIntelligentConfigId:p,filters:y,pageSize:w},m&&(a.event_id=m),o.append&&z.current&&(a.cursor=z.current),[4,fetch(q,{method:"POST",headers:t({accept:"application/json","Content-Type":"application/json"},u(I)),body:JSON.stringify(a),signal:e.signal})];case 2:if(!(s=n.sent()).ok)throw new Error("Request failed: ".concat(s.status," ").concat(s.statusText));return[4,s.json()];case 3:if(c=n.sent(),i!==L.current)return[2];if(!1===(null==c?void 0:c.success))throw new Error("string"==typeof c.error?c.error:"Fetching human changes failed.");return d=function(e){var n,r;return null!==(r=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.humanChanges)&&void 0!==r?r:[]}(c),h=d.map(l),f=function(e,n){var r,t,o,i=null!==(t=null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.nextCursor)&&void 0!==t?t:null,a=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.pageSize;return{nextCursor:i,hasMore:!!i&&n>0&&("number"==typeof a?n>=a:n>0)}}(c,d.length),g=f.nextCursor,v=f.hasMore,b=!g||g!==z.current,z.current=null!=g?g:void 0,x(function(e){return o.append?r(r([],e,!0),h,!0):h}),M(v&&b),[3,6];case 4:return C=n.sent(),e.signal.aborted||i!==L.current?[2]:(_(C),o.append||x([]),M(!1),[3,6]);case 5:return e.signal.aborted||i!==L.current||(A(!1),k(!1)),U.current===e&&(U.current=null),[7];case 6:return[2]}})})},[q,I,p,m,JSON.stringify(y),w]);s(function(){z.current=void 0,M(!0),R({append:!1})},[q,I,p,m,JSON.stringify(y),w]),s(function(){return function(){var e;return null===(e=U.current)||void 0===e?void 0:e.abort()}},[]);var B=a(function(){T||O||!F||R({append:!0})},[T,O,F,R]),D=a(function(){z.current=void 0,M(!0),R({append:!1})},[R]);return{rows:S,loading:T,loadingMore:O,hasMore:F,fetchMore:B,refetch:D,error:P}}var h=new Map;function f(r){var i=this,l=r.baseUrl,d=r.accessToken,f=r.humanIntelligentConfigId,g=r.segmentIds,v=r.skip,p=void 0!==v&&v,m=c(d),y=o([]),b=y[0],w=y[1],I=o(!1),C=I[0],S=I[1],x=o(null),N=x[0],T=x[1],A=o(0),j=A[0],O=A[1],k=a(function(){return O(function(e){return e+1})},[]);return s(function(){var r=!0;if(p||!l||!f||0===(null==g?void 0:g.length))return w([]),S(!1),void T(null);return e(i,void 0,void 0,function(){var o,i,a,s,c,d=this;return n(this,function(v){switch(v.label){case 0:S(!0),T(null),o={humanIntelligentConfigId:f,segment_ids:g},i="segment-details:".concat(l,":").concat(JSON.stringify(o)),v.label=1;case 1:return v.trys.push([1,3,4,5]),h.has(i)||(a=fetch("".concat(l,"/federated/human_change_config_filters/segment-details"),{method:"POST",headers:t({"Content-Type":"application/json",accept:"application/json"},u(m)),body:JSON.stringify(o)}).then(function(r){return e(d,void 0,void 0,function(){var e,t;return n(this,function(n){switch(n.label){case 0:if(!r.ok)throw new Error("Failed to fetch segment details: ".concat(r.statusText));return[4,r.json()];case 1:if((e=n.sent()).success&&e.data&&Array.isArray(e.data.segments))return[2,e.data.segments];throw new Error((null===(t=e.error)||void 0===t?void 0:t.errorMessage)||"Invalid API response format")}})})}).catch(function(e){throw h.delete(i),e}),h.set(i,a)),[4,h.get(i)];case 2:return s=v.sent(),r?(w(s),[3,5]):[2];case 3:return c=v.sent(),r&&(console.error("Error fetching citation segments:",c),T(c.message||"An error occurred while fetching citation data."),w([])),[3,5];case 4:return r&&S(!1),[7];case 5:return[2]}})}),function(){r=!1}},[l,m,f,JSON.stringify(g),p,j]),{data:b,loading:C,error:N,refetch:k}}function g(l){var d=this,h=l.baseUrl,f=l.accessToken,g=l.configId,v=l.changeLogIds,p=l.skip,m=void 0!==p&&p,y=c(f),b=o([]),w=b[0],I=b[1],C=o(!1),S=C[0],x=C[1],N=o(null),T=N[0],A=N[1],j=o(0),O=j[0],k=j[1],E=a(function(){return k(function(e){return e+1})},[]),P=o(null),_=P[0],J=P[1],F=o(!0),M=F[0],z=F[1],L=o(!1),U=L[0],q=L[1],R=o(null),B=R[0],D=R[1],G=i(!1);s(function(){if(I([]),J(null),z(!0),A(null),D(null),!m&&h&&g&&0!==v.length){var r=!0;return e(d,void 0,void 0,function(){var e,o,i,a,s,c,l;return n(this,function(n){switch(n.label){case 0:x(!0),G.current=!0,n.label=1;case 1:return n.trys.push([1,4,5,6]),e={configId:g,changeLogIds:v,orderBy:"latestFirst",pageSize:15},[4,fetch("".concat(h,"/changelog/audit-log/fetch-by-ids"),{method:"POST",headers:t({"Content-Type":"application/json",accept:"application/json"},u(y)),body:JSON.stringify(e)})];case 2:if(!(o=n.sent()).ok)throw new Error("Failed to fetch changelogs: ".concat(o.statusText));return[4,o.json()];case 3:if(i=n.sent(),!r)return[2];if(!1===i.success)throw new Error((null===(l=i.error)||void 0===l?void 0:l.errorMessage)||i.error||"Invalid API response format");return a=i.data||i,s=Array.isArray(a.items)?a.items:Array.isArray(a)?a:[],I(s),J(a.nextCursor||null),z(!!a.hasNext),[3,6];case 4:return c=n.sent(),r&&(console.error("Error fetching changelogs:",c),A(c.message||"An error occurred while fetching changelogs.")),[3,6];case 5:return r&&(x(!1),G.current=!1),[7];case 6:return[2]}})}),function(){r=!1}}x(!1)},[h,y,g,JSON.stringify(v),m,O]);var H=a(function(){return e(d,void 0,void 0,function(){var e,o,i,a,s,c,l;return n(this,function(n){switch(n.label){case 0:if(m||!h||!g||0===v.length||!M||G.current)return[2];G.current=!0,q(!0),D(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),e={configId:g,changeLogIds:v,orderBy:"latestFirst",pageSize:15},_&&(e.cursor=_),[4,fetch("".concat(h,"/changelog/audit-log/fetch-by-ids"),{method:"POST",headers:t({"Content-Type":"application/json",accept:"application/json"},u(y)),body:JSON.stringify(e)})];case 2:if(!(o=n.sent()).ok)throw new Error("Failed to fetch changelogs: ".concat(o.statusText));return[4,o.json()];case 3:if(!1===(i=n.sent()).success)throw new Error((null===(l=i.error)||void 0===l?void 0:l.errorMessage)||i.error||"Invalid API response format");return a=i.data||i,s=Array.isArray(a.items)?a.items:Array.isArray(a)?a:[],I(function(e){return r(r([],e,!0),s,!0)}),J(a.nextCursor||null),z(!!a.hasNext),[3,6];case 4:return c=n.sent(),console.error("Error fetching next changelogs page:",c),D(c.message||"Failed to fetch more logs."),[3,6];case 5:return q(!1),G.current=!1,[7];case 6:return[2]}})})},[h,y,g,JSON.stringify(v),m,M,_]);return{data:w,loading:S,error:T,fetchNextPage:H,hasNextPage:M,isFetchingNextPage:U,fetchNextPageError:B,refetch:E}}function v(r){var i=this,l=r.baseUrl,d=r.accessToken,f=r.humanIntelligentConfigId,g=r.agentConfig,v=r.skip,p=void 0!==v&&v,m=c(d),y=o(""),b=y[0],w=y[1],I=o(!1),C=I[0],S=I[1],x=o(null),N=x[0],T=x[1],A=o(0),j=A[0],O=A[1],k=a(function(){return O(function(e){return e+1})},[]);return s(function(){var r=!0;if(p||!l||!f||!g)return w(""),S(!1),void T(null);return e(i,void 0,void 0,function(){var o,i,a,s,c,d=this;return n(this,function(v){switch(v.label){case 0:S(!0),T(null),o={humanIntelligentConfigId:f,agentConfig:g},i="business-context:".concat(l,":").concat(JSON.stringify(o)),v.label=1;case 1:return v.trys.push([1,3,4,5]),h.has(i)||(a=fetch("".concat(l,"/federated/human_change_config_filters/business-context"),{method:"POST",headers:t({"Content-Type":"application/json",accept:"application/json"},u(m)),body:JSON.stringify(o)}).then(function(r){return e(d,void 0,void 0,function(){var e,t;return n(this,function(n){switch(n.label){case 0:if(!r.ok)throw new Error("Failed to fetch business context: ".concat(r.statusText));return[4,r.json()];case 1:if((e=n.sent()).success&&e.data&&e.data.business_context)return[2,e.data.business_context];throw new Error((null===(t=e.error)||void 0===t?void 0:t.errorMessage)||"Invalid API response format")}})})}).catch(function(e){throw h.delete(i),e}),h.set(i,a)),[4,h.get(i)];case 2:return s=v.sent(),r?(w(s),[3,5]):[2];case 3:return c=v.sent(),r&&(console.error("Error fetching business context:",c),T(c.message||"An error occurred while fetching business context."),w("")),[3,5];case 4:return r&&S(!1),[7];case 5:return[2]}})}),function(){r=!1}},[l,m,f,g,p,j]),{data:b,loading:C,error:N,refetch:k}}export{v as useBusinessContextData,g as useCitationChangelogs,f as useCitationSegments,d as useHumanChangesData};
|
|
2
2
|
//# sourceMappingURL=useHumanChangesData.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__spreadArray as e,__assign as
|
|
1
|
+
import{__spreadArray as e,__assign as t}from"../../_virtual/_tslib.js";import n from"react";var a=new Set(["b","strong","i","em","u","s","del","ins","mark","code","small","sub","sup","span","br","p","ul","ol","li"]),r={condition:"span",option:"span"},i=new Set(["id","type","total","rank","count","pct","label"]),l=new Set(["br"]),o=new Set(["summary_payload","summary_context","what_happened","impact","where_it_applies","exemptions","tier","caution","rule_recommendation","rule_action","suggested_rule"]),s=new Set(["ul","ol"]),c={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function u(e){return e.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g,function(e,t){if("#"===t[0]){var n="x"===t[1]||"X"===t[1]?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return Number.isFinite(n)&&n>0?String.fromCodePoint(n):e}var a=c[t.toLowerCase()];return void 0===a?e:a})}var p=/<(\/?)([a-zA-Z][a-zA-Z0-9]*)([^>]*)>/g,d=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function f(e){var t,n,a,r,l={};for(d.lastIndex=0;r=d.exec(e);){var o=null===(t=r[1])||void 0===t?void 0:t.toLowerCase();o&&i.has(o)&&(l["data-".concat(o)]=u(null!==(a=null!==(n=r[2])&&void 0!==n?n:r[3])&&void 0!==a?a:""))}return l}function h(i,c){if(void 0===c&&(c={}),"string"!=typeof i)return i;if(!/[<&]/.test(i))return i;var d,h=c.classNames,g=void 0===h?{}:h,m=c.stripUnknownTags,v=void 0!==m&&m,x={tag:null,attrs:{},children:[]},_=[x],w=function(){return _[_.length-1]},y=0,b=0,k=function(e){var t;e&&(s.has(null!==(t=w().tag)&&void 0!==t?t:"")&&!e.trim()||w().children.push(u(e)))},A=function(){var a=_.pop(),i=a.tag,l=r[i],o=g[i],s=t(t(t({key:"".concat(i,"-").concat(b++)},o?{className:o}:{}),l?{"data-tag":i}:{}),a.attrs);w().children.push(n.createElement.apply(n,e([null!=l?l:i,s],a.children,!1)))};for(p.lastIndex=0;d=p.exec(i);){var S=d[0],z=d[1],Z=d[2],C=d[3],I=void 0===C?"":C,E=Z.toLowerCase(),F=a.has(E)||E in r;if(F||!o.has(E)&&!v){if(F)if(k(i.slice(y,d.index)),y=d.index+S.length,l.has(E))w().children.push(n.createElement(E,{key:"".concat(E,"-").concat(b++)}));else if(z){for(var L=-1,N=_.length-1;N>0;N--)if(_[N].tag===E){L=N;break}if(L>0)for(;_.length>L;)A()}else _.push({tag:E,attrs:E in r?f(I):{},children:[]}),/\/\s*$/.test(I)&&A()}else k(i.slice(y,d.index)),y=d.index+S.length}for(k(i.slice(y));_.length>1;)A();var j=x.children;return j.length?1===j.length&&"string"==typeof j[0]?j[0]:n.createElement.apply(n,e([n.Fragment,null],j,!1)):""}export{h as renderInlineMarkup};
|
|
2
2
|
//# sourceMappingURL=inlineMarkup.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=function(t){function n(e,n,r,o){var i=t.call(this,e,n)||this;return i.name="InsightsApiError",i.errorType=r,i.data=o,i}return e.__extends(n,t),n}(require("./dashboardApi.js").DashboardApiError),n=function(e){return e.replace(/\/+$/,"")},r=function(e){var t=function(e){return String(e).padStart(2,"0")};return"".concat(e.getFullYear(),"-").concat(t(e.getMonth()+1),"-").concat(t(e.getDate()))},o=function(e){var t=e.baseUrl,r=void 0===t?"":t,o=e.configId;return"".concat(n(r),"/federated/insights/").concat(encodeURIComponent(o))},i=function(e){var t=new URLSearchParams;Object.entries(e).forEach(function(e){var n=e[0],r=e[1];null!=r&&""!==r&&t.set(n,String(r))});var n=t.toString();return n?"?".concat(n):""},s=function(e){var t=e.startDate,n=e.endDate,o=e.workingDaysOnly;return{startDate:r(t),endDate:r(n),workingDaysOnly:!!o||void 0}},a=function(e){return e&&Object.keys(e).length?JSON.stringify(e):void 0};function c(n,r,o,i,s){var a,c;return e.__awaiter(this,void 0,void 0,function(){var u,d,l;return e.__generator(this,function(v){switch(v.label){case 0:return[4,fetch(r,{method:n,headers:e.__assign(e.__assign({accept:"application/json"},void 0!==i?{"Content-Type":"application/json"}:{}),o?{Authorization:"Bearer ".concat(o)}:{}),body:void 0!==i?JSON.stringify(i):void 0,signal:s})];case 1:u=v.sent(),d=null,v.label=2;case 2:return v.trys.push([2,4,,5]),[4,u.json()];case 3:return d=v.sent(),[3,5];case 4:if(l=v.sent(),null==s?void 0:s.aborted)throw new DOMException("The request was aborted.","AbortError");if("AbortError"===(null==l?void 0:l.name))throw l;return d=null,[3,5];case 5:if(!u.ok||!(null==d?void 0:d.success))throw new t((null===(a=null==d?void 0:d.error)||void 0===a?void 0:a.errorMessage)||"Request failed with status ".concat(u.status),u.status,null===(c=null==d?void 0:d.error)||void 0===c?void 0:c.errorType,null==d?void 0:d.data);return[2,{status:u.status,data:d.data}]}})})}var u=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,c("GET",t,n.accessToken,void 0,r)];case 1:return[2,e.sent().data]}})})};var d=function(t){var n,r,o,i=t;return e.__assign(e.__assign({},t),{rows:(null===(n=t.rows)||void 0===n?void 0:n.length)?t.rows:null!==(o=null!==(r=i.drivers)&&void 0!==r?r:i.items)&&void 0!==o?o:[]})},l=function(t){var n,r,o=t;return e.__assign(e.__assign({},t),{drivers:(null!==(n=o.drivers)&&void 0!==n?n:[]).map(function(t){var n,r,o,i,s,a,c,u,d,l,v,f,p;return e.__assign(e.__assign({},t),{r:null!==(o=null!==(n=t.r)&&void 0!==n?n:null===(r=t.correlation)||void 0===r?void 0:r.r)&&void 0!==o?o:null,nObs:null!==(c=null!==(s=null!==(i=t.nObs)&&void 0!==i?i:t.daysUsed)&&void 0!==s?s:null===(a=t.correlation)||void 0===a?void 0:a.nObs)&&void 0!==c?c:0,strength:null!==(v=null!==(d=null!==(u=t.strength)&&void 0!==u?u:t.correlationStrength)&&void 0!==d?d:null===(l=t.correlation)||void 0===l?void 0:l.strength)&&void 0!==v?v:null,lowHistory:null!==(f=t.lowHistory)&&void 0!==f?f:null===(p=t.correlation)||void 0===p?void 0:p.lowHistory})}),series:(null!==(r=o.series)&&void 0!==r?r:[]).flatMap(function(e){var n,r,o,i,s=null!==(r=null!==(n=e.x)&&void 0!==n?n:e.date)&&void 0!==r?r:e.dataDay;if("string"!=typeof s||!s)return[];var a=null!==(o=e.values)&&void 0!==o?o:e.metrics,c=a&&"object"==typeof a&&!Array.isArray(a)?a:Object.entries(e).reduce(function(e,t){var n=t[0],r=t[1];return["x","date","dataDay","disregarded","isDisregarded","value"].includes(n)||"number"!=typeof r&&null!==r||(e[n]=r),e},{});return"number"!=typeof e.value&&null!==e.value||(c[t.kpiId]=e.value),e.drivers&&"object"==typeof e.drivers&&!Array.isArray(e.drivers)&&Object.entries(e.drivers).forEach(function(e){var t=e[0],n=e[1];"number"!=typeof n&&null!==n||(c[t]=n)}),[{x:s,values:c,disregarded:Boolean(null!==(i=e.disregarded)&&void 0!==i?i:e.isDisregarded)}]})})};function v(t,n,r){var i;return e.__awaiter(this,void 0,void 0,function(){var s,a;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c("POST","".concat(o(t)).concat(n),t.accessToken,r)];case 1:return[2,e.sent().data];case 2:if(s=e.sent(),a="InsightsBusy"===(null==s?void 0:s.errorType)?null===(i=s.data)||void 0===i?void 0:i.jobId:void 0)return[2,{jobId:a}];throw s;case 3:return[2]}})})}exports.InsightsApiError=t,exports.decideObservation=function(t,n,r,i){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(s){switch(s.label){case 0:return[4,c("POST","".concat(o(t),"/observations/").concat(encodeURIComponent(n),"/decision"),t.accessToken,e.__assign(e.__assign({decision:r},i?{reason:i}:{}),{regenerate:"dashboard"}))];case 1:return[2,s.sent().data]}})})},exports.deleteReportComment=function(t,n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,c("DELETE","".concat(o(t),"/comments/").concat(encodeURIComponent(n)),t.accessToken)];case 1:return[2,e.sent().data]}})})},exports.fetchDrillTableRows=function(t,r,o){return e.__awaiter(void 0,void 0,void 0,function(){var i,s,a,u,d,l,v;return e.__generator(this,function(f){switch(f.label){case 0:return[4,c("POST","".concat(n(null!==(s=t.baseUrl)&&void 0!==s?s:""),"/federated/filters/table-data"),t.accessToken,e.__assign({config_id:t.configId,tableKey:r.tableKey,dateFilters:{startDate:r.startDay,endDate:r.endDay},sidebarFilters:r.filters,pageSize:null!==(a=r.pageSize)&&void 0!==a?a:20},r.cursor?{cursor:r.cursor}:{}),o)];case 1:return i=f.sent().data,[2,{rows:null!==(d=null===(u=null==i?void 0:i.table)||void 0===u?void 0:u[r.tableKey])&&void 0!==d?d:[],count:null!==(l=null==i?void 0:i.count)&&void 0!==l?l:0,hasNext:Boolean(null==i?void 0:i.hasNext),nextCursor:null!==(v=null==i?void 0:i.nextCursor)&&void 0!==v?v:null}]}})})},exports.fetchGraphGroups=function(t,n){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,u("".concat(o(t),"/graph-groups"),t,n)];case 1:return r=e.sent(),[2,Array.isArray(r)?{groups:r}:r]}})})},exports.fetchHierarchy=function(e,t){return u("".concat(o(e),"/hierarchy"),e,t)},exports.fetchInsightsCorrelation=function(t,n,r,s){var c;return u("".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation").concat(i(e.__assign(e.__assign({},r),{disregardDates:null===(c=r.disregardDates)||void 0===c?void 0:c.join(","),filters:a(r.filters)}))),t,s).then(l)},exports.fetchInsightsCorrelationTrend=function(t,n,r,s){var c;return u("".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation-trend").concat(i(e.__assign(e.__assign({},r),{disregardDates:null===(c=r.disregardDates)||void 0===c?void 0:c.join(","),filters:a(r.filters)}))),t,s)},exports.fetchInsightsDrivers=function(t,n,r){var s,c;return u("".concat(o(t),"/top-drivers").concat(i(e.__assign(e.__assign({},n),{parts:(null===(s=n.parts)||void 0===s?void 0:s.length)?n.parts.join(","):void 0,filters:a(n.filters),limit:Math.min(10,Math.max(1,null!==(c=n.limit)&&void 0!==c?c:10))}))),t,r).then(function(e){return console.log("[TopDrivers API response]",JSON.stringify({configId:t.configId,params:n,response:e},null,2)),d(e)})},exports.fetchInsightsJob=function(e,t,n){return u("".concat(o(e),"/jobs/").concat(encodeURIComponent(t)),e,n)},exports.fetchInsightsReport=function(e,t,n){return u("".concat(o(e),"/reports/").concat(encodeURIComponent(t)),e,n)},exports.fetchInsightsReports=function(t,n,r){return u("".concat(o(t),"/reports").concat(i(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchInsightsSeries=function(t,n,r,c){var d;return u("".concat(o(t),"/series").concat(i(e.__assign(e.__assign({},s(n)),{workingDaysOnly:n.group?void 0:!!n.workingDaysOnly||void 0,group:n.group,kpiIds:r.kpiIds.join(","),nodeKeys:(null===(d=r.nodeKeys)||void 0===d?void 0:d.length)?r.nodeKeys.join(","):void 0,entityKey:r.entityKey,topN:r.topN,filters:a(n.filters)}))),t,c)},exports.fetchInsightsSummary=function(t,n,r){return u("".concat(o(t),"/summary").concat(i(e.__assign(e.__assign({},s(n)),{filters:a(n.filters)}))),t,r)},exports.fetchLevelRows=function(t,n,r,c,d){return void 0===c&&(c={}),u("".concat(o(t),"/levels/").concat(encodeURIComponent(n),"/rows").concat(i(e.__assign(e.__assign(e.__assign({},s(r)),c),{filters:a(r.filters)}))),t,d)},exports.fetchLevelSummary=function(t,n,r,c){return u("".concat(o(t),"/levels/").concat(encodeURIComponent(n),"/summary").concat(i(e.__assign(e.__assign({},s(r)),{filters:a(r.filters)}))),t,c)},exports.fetchNeedsAttention=function(t,n,r){return void 0===n&&(n={}),u("".concat(o(t),"/needs-attention").concat(i(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchObservation=function(e,t,n){return u("".concat(o(e),"/observations/").concat(encodeURIComponent(t)),e,n)},exports.fetchObservations=function(t,n,r){return void 0===n&&(n={}),u("".concat(o(t),"/observations").concat(i(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchReportComments=function(e,t,n){return u("".concat(o(e),"/reports/").concat(encodeURIComponent(t),"/comments"),e,n)},exports.fetchRowDetail=function(e,t,n,r){return u("".concat(o(e),"/rows/").concat(encodeURIComponent(t)).concat(i(n)),e,r)},exports.fetchRowReport=function(e,t,n,r){return u("".concat(o(e),"/rows/").concat(encodeURIComponent(t),"/report").concat(i(n)),e,r)},exports.filtersParam=a,exports.generateInsightsReport=function(n,r,i){var s;return e.__awaiter(this,void 0,void 0,function(){var a,u,d;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c("POST","".concat(o(n),"/reports/generate"),n.accessToken,r,i)];case 1:if(null==(a=e.sent().data)?void 0:a.report)return[2,{kind:"report",report:a.report}];if(null==a?void 0:a.jobId)return[2,{kind:"job",jobId:a.jobId}];throw new t("The report couldn't be started.");case 2:if(u=e.sent(),d="InsightsBusy"===(null==u?void 0:u.errorType)?null===(s=u.data)||void 0===s?void 0:s.jobId:void 0)return[2,{kind:"job",jobId:d}];throw u;case 3:return[2]}})})},exports.generateInsightsSummary=function(e,t){return v(e,"/summary/generate",t)},exports.generateLevelSummary=function(e,t,n){return v(e,"/levels/".concat(encodeURIComponent(t),"/generate"),n)},exports.postReportComment=function(t,n,r,i){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(s){switch(s.label){case 0:return[4,c("POST","".concat(o(t),"/reports/").concat(encodeURIComponent(n),"/comments"),t.accessToken,e.__assign({commentText:r},i?{parentCommentId:i}:{}))];case 1:return[2,s.sent().data]}})})},exports.saveCorrelationWindow=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,c("PUT","".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation-window"),t.accessToken,r)];case 1:return[2,e.sent().data]}})})},exports.saveInsightsAction=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,c("PUT","".concat(o(t),"/actions/").concat(encodeURIComponent(n)),t.accessToken,r)];case 1:return[2,e.sent().data]}})})},exports.toIsoDay=r,exports.updateReportComment=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,c("PATCH","".concat(o(t),"/comments/").concat(encodeURIComponent(n)),t.accessToken,{commentText:r})];case 1:return[2,e.sent().data]}})})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=function(t){function n(e,n,r,o){var s=t.call(this,e,n)||this;return s.name="InsightsApiError",s.errorType=r,s.data=o,s}return e.__extends(n,t),n}(require("./dashboardApi.js").DashboardApiError),n=function(e){return e.replace(/\/+$/,"")},r=function(e){var t=function(e){return String(e).padStart(2,"0")};return"".concat(e.getFullYear(),"-").concat(t(e.getMonth()+1),"-").concat(t(e.getDate()))},o=function(e){var t=e.baseUrl,r=void 0===t?"":t,o=e.configId;return"".concat(n(r),"/federated/insights/").concat(encodeURIComponent(o))},s=function(e){var t=new URLSearchParams;Object.entries(e).forEach(function(e){var n=e[0],r=e[1];null!=r&&""!==r&&t.set(n,String(r))});var n=t.toString();return n?"?".concat(n):""},i=function(e){var t=e.startDate,n=e.endDate,o=e.workingDaysOnly;return{startDate:r(t),endDate:r(n),workingDaysOnly:!!o||void 0}},a=function(e){return e&&Object.keys(e).length?JSON.stringify(e):void 0},c={statuses:[502,503,504],delaysMs:[400,1200]},u=function(e,t){return new Promise(function(n,r){if(null==t?void 0:t.aborted)return r(new DOMException("The request was aborted.","AbortError"));var o=setTimeout(function(){null==t||t.removeEventListener("abort",s),n()},e);function s(){clearTimeout(o),r(new DOMException("The request was aborted.","AbortError"))}null==t||t.addEventListener("abort",s,{once:!0})})};function l(n,r,o,s,i){var a,l,d;return e.__awaiter(this,void 0,void 0,function(){var v,f,p,_,g,h,m,b,y;return e.__generator(this,function(w){switch(w.label){case 0:v=function(){return fetch(r,{method:n,headers:e.__assign(e.__assign({accept:"application/json"},void 0!==s?{"Content-Type":"application/json"}:{}),o?{Authorization:"Bearer ".concat(o)}:{}),body:void 0!==s?JSON.stringify(s):void 0,signal:i})},f="GET"===n?c.delaysMs:[],_=0,w.label=1;case 1:if(p)return[3,9];w.label=2;case 2:return w.trys.push([2,6,,8]),[4,v()];case 3:return g=w.sent(),_<f.length&&c.statuses.includes(g.status)?[4,u(f[_],i)]:[3,5];case 4:return w.sent(),[3,8];case 5:return p=g,[3,8];case 6:if(h=w.sent(),(null==i?void 0:i.aborted)||"AbortError"===(null==h?void 0:h.name)||_>=f.length)throw h;return[4,u(f[_],i)];case 7:return w.sent(),[3,8];case 8:return _++,[3,1];case 9:m=null,w.label=10;case 10:return w.trys.push([10,12,,13]),[4,p.json()];case 11:return m=w.sent(),[3,13];case 12:if(b=w.sent(),null==i?void 0:i.aborted)throw new DOMException("The request was aborted.","AbortError");if("AbortError"===(null==b?void 0:b.name))throw b;return m=null,[3,13];case 13:if(!p.ok||!(null==m?void 0:m.success))throw y=c.statuses.includes(p.status)&&!(null===(a=null==m?void 0:m.error)||void 0===a?void 0:a.errorMessage),new t((null===(l=null==m?void 0:m.error)||void 0===l?void 0:l.errorMessage)||(y?"The insights service didn't answer (".concat(p.status,"). Try again in a moment."):"Request failed with status ".concat(p.status)),p.status,null===(d=null==m?void 0:m.error)||void 0===d?void 0:d.errorType,null==m?void 0:m.data);return[2,{status:p.status,data:m.data}]}})})}var d=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,l("GET",t,n.accessToken,void 0,r)];case 1:return[2,e.sent().data]}})})};var v=function(t){var n,r,o,s=t;return e.__assign(e.__assign({},t),{rows:(null===(n=t.rows)||void 0===n?void 0:n.length)?t.rows:null!==(o=null!==(r=s.drivers)&&void 0!==r?r:s.items)&&void 0!==o?o:[]})},f=function(t){var n,r,o=t;return e.__assign(e.__assign({},t),{drivers:(null!==(n=o.drivers)&&void 0!==n?n:[]).map(function(t){var n,r,o,s,i,a,c,u,l,d,v,f,p;return e.__assign(e.__assign({},t),{r:null!==(o=null!==(n=t.r)&&void 0!==n?n:null===(r=t.correlation)||void 0===r?void 0:r.r)&&void 0!==o?o:null,nObs:null!==(c=null!==(i=null!==(s=t.nObs)&&void 0!==s?s:t.daysUsed)&&void 0!==i?i:null===(a=t.correlation)||void 0===a?void 0:a.nObs)&&void 0!==c?c:0,strength:null!==(v=null!==(l=null!==(u=t.strength)&&void 0!==u?u:t.correlationStrength)&&void 0!==l?l:null===(d=t.correlation)||void 0===d?void 0:d.strength)&&void 0!==v?v:null,lowHistory:null!==(f=t.lowHistory)&&void 0!==f?f:null===(p=t.correlation)||void 0===p?void 0:p.lowHistory})}),series:(null!==(r=o.series)&&void 0!==r?r:[]).flatMap(function(e){var n,r,o,s,i=null!==(r=null!==(n=e.x)&&void 0!==n?n:e.date)&&void 0!==r?r:e.dataDay;if("string"!=typeof i||!i)return[];var a=null!==(o=e.values)&&void 0!==o?o:e.metrics,c=a&&"object"==typeof a&&!Array.isArray(a)?a:Object.entries(e).reduce(function(e,t){var n=t[0],r=t[1];return["x","date","dataDay","disregarded","isDisregarded","value"].includes(n)||"number"!=typeof r&&null!==r||(e[n]=r),e},{});return"number"!=typeof e.value&&null!==e.value||(c[t.kpiId]=e.value),e.drivers&&"object"==typeof e.drivers&&!Array.isArray(e.drivers)&&Object.entries(e.drivers).forEach(function(e){var t=e[0],n=e[1];"number"!=typeof n&&null!==n||(c[t]=n)}),[{x:i,values:c,disregarded:Boolean(null!==(s=e.disregarded)&&void 0!==s?s:e.isDisregarded)}]})})};function p(t,n,r){var s;return e.__awaiter(this,void 0,void 0,function(){var i,a;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,l("POST","".concat(o(t)).concat(n),t.accessToken,r)];case 1:return[2,e.sent().data];case 2:if(i=e.sent(),a="InsightsBusy"===(null==i?void 0:i.errorType)?null===(s=i.data)||void 0===s?void 0:s.jobId:void 0)return[2,{jobId:a}];throw i;case 3:return[2]}})})}exports.InsightsApiError=t,exports.READ_RETRY=c,exports.decideObservation=function(t,n,r,s){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(i){switch(i.label){case 0:return[4,l("POST","".concat(o(t),"/observations/").concat(encodeURIComponent(n),"/decision"),t.accessToken,e.__assign(e.__assign({decision:r},s?{reason:s}:{}),{regenerate:"dashboard"}))];case 1:return[2,i.sent().data]}})})},exports.deleteReportComment=function(t,n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,l("DELETE","".concat(o(t),"/comments/").concat(encodeURIComponent(n)),t.accessToken)];case 1:return[2,e.sent().data]}})})},exports.fetchDrillTableRows=function(t,r,o){return e.__awaiter(void 0,void 0,void 0,function(){var s,i,a,c,u,d,v;return e.__generator(this,function(f){switch(f.label){case 0:return[4,l("POST","".concat(n(null!==(i=t.baseUrl)&&void 0!==i?i:""),"/federated/filters/table-data"),t.accessToken,e.__assign({config_id:t.configId,tableKey:r.tableKey,dateFilters:{startDate:r.startDay,endDate:r.endDay},sidebarFilters:r.filters,pageSize:null!==(a=r.pageSize)&&void 0!==a?a:20},r.cursor?{cursor:r.cursor}:{}),o)];case 1:return s=f.sent().data,[2,{rows:null!==(u=null===(c=null==s?void 0:s.table)||void 0===c?void 0:c[r.tableKey])&&void 0!==u?u:[],count:null!==(d=null==s?void 0:s.count)&&void 0!==d?d:0,hasNext:Boolean(null==s?void 0:s.hasNext),nextCursor:null!==(v=null==s?void 0:s.nextCursor)&&void 0!==v?v:null}]}})})},exports.fetchGraphGroups=function(t,n){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,d("".concat(o(t),"/graph-groups"),t,n)];case 1:return r=e.sent(),[2,Array.isArray(r)?{groups:r}:r]}})})},exports.fetchHierarchy=function(e,t){return d("".concat(o(e),"/hierarchy"),e,t)},exports.fetchInsightsCorrelation=function(t,n,r,i){var c;return d("".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation").concat(s(e.__assign(e.__assign({},r),{disregardDates:null===(c=r.disregardDates)||void 0===c?void 0:c.join(","),filters:a(r.filters)}))),t,i).then(f)},exports.fetchInsightsCorrelationTrend=function(t,n,r,i){var c;return d("".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation-trend").concat(s(e.__assign(e.__assign({},r),{disregardDates:null===(c=r.disregardDates)||void 0===c?void 0:c.join(","),filters:a(r.filters)}))),t,i)},exports.fetchInsightsDrivers=function(t,n,r){var i,c;return d("".concat(o(t),"/top-drivers").concat(s(e.__assign(e.__assign({},n),{parts:(null===(i=n.parts)||void 0===i?void 0:i.length)?n.parts.join(","):void 0,filters:a(n.filters),limit:Math.min(10,Math.max(1,null!==(c=n.limit)&&void 0!==c?c:10))}))),t,r).then(function(e){return console.log("[TopDrivers API response]",JSON.stringify({configId:t.configId,params:n,response:e},null,2)),v(e)})},exports.fetchInsightsJob=function(e,t,n){return d("".concat(o(e),"/jobs/").concat(encodeURIComponent(t)),e,n)},exports.fetchInsightsReport=function(e,t,n){return d("".concat(o(e),"/reports/").concat(encodeURIComponent(t)),e,n)},exports.fetchInsightsReports=function(t,n,r){return d("".concat(o(t),"/reports").concat(s(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchInsightsSeries=function(t,n,r,c){var u;return d("".concat(o(t),"/series").concat(s(e.__assign(e.__assign({},i(n)),{workingDaysOnly:n.group?void 0:!!n.workingDaysOnly||void 0,group:n.group,kpiIds:r.kpiIds.join(","),nodeKeys:(null===(u=r.nodeKeys)||void 0===u?void 0:u.length)?r.nodeKeys.join(","):void 0,entityKey:r.entityKey,topN:r.topN,filters:a(n.filters)}))),t,c)},exports.fetchInsightsSummary=function(t,n,r){return d("".concat(o(t),"/summary").concat(s(e.__assign(e.__assign({},i(n)),{filters:a(n.filters)}))),t,r)},exports.fetchLevelRows=function(t,n,r,c,u){return void 0===c&&(c={}),d("".concat(o(t),"/levels/").concat(encodeURIComponent(n),"/rows").concat(s(e.__assign(e.__assign(e.__assign({},i(r)),c),{filters:a(r.filters)}))),t,u)},exports.fetchLevelSummary=function(t,n,r,c){return d("".concat(o(t),"/levels/").concat(encodeURIComponent(n),"/summary").concat(s(e.__assign(e.__assign({},i(r)),{filters:a(r.filters)}))),t,c)},exports.fetchNeedsAttention=function(t,n,r){return void 0===n&&(n={}),d("".concat(o(t),"/needs-attention").concat(s(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchObservation=function(e,t,n){return d("".concat(o(e),"/observations/").concat(encodeURIComponent(t)),e,n)},exports.fetchObservations=function(t,n,r){return void 0===n&&(n={}),d("".concat(o(t),"/observations").concat(s(e.__assign(e.__assign({},n),{filters:a(n.filters)}))),t,r)},exports.fetchReportComments=function(e,t,n){return d("".concat(o(e),"/reports/").concat(encodeURIComponent(t),"/comments"),e,n)},exports.fetchRowDetail=function(e,t,n,r){return d("".concat(o(e),"/rows/").concat(encodeURIComponent(t)).concat(s(n)),e,r)},exports.fetchRowReport=function(e,t,n,r){return d("".concat(o(e),"/rows/").concat(encodeURIComponent(t),"/report").concat(s(n)),e,r)},exports.filtersParam=a,exports.generateInsightsReport=function(n,r,s){var i;return e.__awaiter(this,void 0,void 0,function(){var a,c,u;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,l("POST","".concat(o(n),"/reports/generate"),n.accessToken,r,s)];case 1:if(null==(a=e.sent().data)?void 0:a.report)return[2,{kind:"report",report:a.report}];if(null==a?void 0:a.jobId)return[2,{kind:"job",jobId:a.jobId}];throw new t("The report couldn't be started.");case 2:if(c=e.sent(),u="InsightsBusy"===(null==c?void 0:c.errorType)?null===(i=c.data)||void 0===i?void 0:i.jobId:void 0)return[2,{kind:"job",jobId:u}];throw c;case 3:return[2]}})})},exports.generateInsightsSummary=function(e,t){return p(e,"/summary/generate",t)},exports.generateLevelSummary=function(e,t,n){return p(e,"/levels/".concat(encodeURIComponent(t),"/generate"),n)},exports.postReportComment=function(t,n,r,s){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(i){switch(i.label){case 0:return[4,l("POST","".concat(o(t),"/reports/").concat(encodeURIComponent(n),"/comments"),t.accessToken,e.__assign({commentText:r},s?{parentCommentId:s}:{}))];case 1:return[2,i.sent().data]}})})},exports.saveCorrelationWindow=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,l("PUT","".concat(o(t),"/rows/").concat(encodeURIComponent(n),"/correlation-window"),t.accessToken,r)];case 1:return[2,e.sent().data]}})})},exports.saveInsightsAction=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,l("PUT","".concat(o(t),"/actions/").concat(encodeURIComponent(n)),t.accessToken,r)];case 1:return[2,e.sent().data]}})})},exports.toIsoDay=r,exports.updateReportComment=function(t,n,r){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,l("PATCH","".concat(o(t),"/comments/").concat(encodeURIComponent(n)),t.accessToken,{commentText:r})];case 1:return[2,e.sent().data]}})})};
|
|
2
2
|
//# sourceMappingURL=insightsApi.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("../../../_virtual/_tslib.js"),i=require("react"),l=require("react/jsx-runtime"),t=require("recharts"),o=require("../ui/chart.js"),r=require("./types.js"),a=require("../../utils/index.js"),u=require("./axisDomain.js"),s=require("./inlineLabels.js"),d=require("./Seperator.js"),c=function(e){var i=e.render,t=n.__rest(e,["render"]);return l.jsx(l.Fragment,{children:i(t)})},v=function(e){return"number"==typeof e&&!Number.isNaN(e)},f=function(n,i,l,t){return void 0===e&&(e="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):null),e?(e.font="".concat(l," ").concat(i,"px ").concat(t),e.measureText(n).width):n.length*i*.58},h=function(e){switch(e){case"linear":return"linear";case"step":return"stepAfter";default:return"monotone"}};exports.default=function(e){var g,y,x,p,m,k,_,b,j,A,L,w,C,S,M,T,N,W,O,R,z,F,P,E,D,I,H,q,K,B=e.tier,Z=e.series,V=e.hiddenKeys,G=e.onToggleSeries,Y=e.xAxis,U=e.yAxis,X=e.tooltip,J=e.legend,Q=e.style,$=e.syncId,ee=e.syncMethod,ne=e.reference;e.scrollable;var ie=e.onPointClick,le=e.activeThreshold,te=e.onThresholdViewChange,oe=null!==(g=null==Q?void 0:Q.chartHeight)&&void 0!==g?g:300,re=null!==(y=null==Q?void 0:Q.gridColor)&&void 0!==y?y:"#eef0f4",ae=null!==(x=null==Q?void 0:Q.axisColor)&&void 0!==x?x:"#d7dbe3",ue=null!==(p=null==Q?void 0:Q.axisLabelColor)&&void 0!==p?p:"#6b7280",se=null!==(m=null==Q?void 0:Q.tickColor)&&void 0!==m?m:"#9ca3af",de=null!==(k=null==Q?void 0:Q.fontFamily)&&void 0!==k?k:"Inter, system-ui, -apple-system, sans-serif",ce=Boolean(null==Q?void 0:Q.modern),ve=null!==(b=null===(_=null==Q?void 0:Q.text)||void 0===_?void 0:_.tickSize)&&void 0!==b?b:11,fe=null===(j=null==Q?void 0:Q.text)||void 0===j?void 0:j.axisTitleSize,he=null===(A=null==Q?void 0:Q.text)||void 0===A?void 0:A.axisTitleWeight,ge=null!==(w=null===(L=null==Q?void 0:Q.text)||void 0===L?void 0:L.valueLabelSize)&&void 0!==w?w:11,ye=null!==(S=null===(C=null==Q?void 0:Q.text)||void 0===C?void 0:C.valueLabelWeight)&&void 0!==S?S:600,xe=null!==(T=null===(M=null==Q?void 0:Q.text)||void 0===M?void 0:M.seriesLabelSize)&&void 0!==T?T:11,pe=null!==(W=null===(N=null==Q?void 0:Q.text)||void 0===N?void 0:N.seriesLabelWeight)&&void 0!==W?W:500,me="ellm-grad-".concat(i.useId().replace(/[^a-zA-Z0-9_-]/g,"")),ke=function(e){return"".concat(me,"-").concat(e.replace(/[^a-zA-Z0-9_-]/g,"_"))},_e=i.useState(null),be=_e[0],je=_e[1],Ae=i.useState(null),Le=Ae[0],we=Ae[1],Ce=i.useState(null),Se=Ce[0],Me=Ce[1],Te=i.useMemo(function(){var e,i,l;if(null===(e=null==Y?void 0:Y.categories)||void 0===e?void 0:e.length)return{categories:Y.categories,xType:null!==(i=Y.type)&&void 0!==i?i:"category"};var t=new Set,o=[];Z.forEach(function(e){return e.data.forEach(function(e){t.has(e.x)||(t.add(e.x),o.push(e.x))})});var r=o.every(v),a=null!==(l=null==Y?void 0:Y.type)&&void 0!==l?l:r?"number":"category";return{categories:"number"===a?n.__spreadArray([],o,!0).sort(function(e,n){return Number(e)-Number(n)}):o,xType:a}},[Z,null==Y?void 0:Y.categories,null==Y?void 0:Y.type]),Ne=Te.categories,We=Te.xType,Oe=i.useMemo(function(){var e=new Map;return Z.forEach(function(n){var i=new Map;n.data.forEach(function(e){return i.set(e.x,e.y)}),e.set(n.key,i)}),Ne.map(function(n){var i={x:n};return Z.forEach(function(l){var t,o=null===(t=e.get(l.key))||void 0===t?void 0:t.get(n);i[l.key]=null==o?null:o}),i})},[Z,Ne]),Re=i.useMemo(function(){var e={},n=Z.map(function(n,i){var l,t=null!==(l=n.color)&&void 0!==l?l:r.colorForIndex(null==Q?void 0:Q.colors,i);return e[n.key]={label:n.label,color:t,threshold:n.threshold,thresholdUnit:n.thresholdUnit},{series:n,color:t,index:i}});return{chartConfig:e,resolved:n}},[Z,null==Q?void 0:Q.colors]),ze=Re.chartConfig,Fe=Re.resolved,Pe=i.useMemo(function(){var e={};return Z.forEach(function(n){n.valueFormatter&&(e[n.key]=function(e,i){var l;return n.valueFormatter(e,null!==(l=null==i?void 0:i.payload)&&void 0!==l?l:{x:null==i?void 0:i.x,y:e})})}),e},[Z]),Ee=!1!==(null==X?void 0:X.enabled),De=(null==X?void 0:X.seriesKeys)?new Set(X.seriesKeys):null,Ie=!1!==(null==J?void 0:J.show),He="top"===(null==J?void 0:J.position)?"top":"bottom",qe="start"===(null==J?void 0:J.align)?"left":"end"===(null==J?void 0:J.align)?"right":"center",Ke=!1!==(null==Y?void 0:Y.show),Be=!1!==(null==U?void 0:U.show),Ze=!1!==(null==Q?void 0:Q.showGrid),Ve=!!(null==Q?void 0:Q.showVerticalGrid),Ge=i.useMemo(function(){var e,i=Z.filter(function(e){return!V.has(e.key)}),l=Math.max.apply(Math,n.__spreadArray([0],Oe.flatMap(function(e){return i.map(function(n){return Number(e[n.key])||0})}),!1)),t=null==le?void 0:le[B],o=t?null===(e=ze[t])||void 0===e?void 0:e.threshold:void 0;return void 0!==o&&o>l&&(l=o),l},[Oe,Z,V,le,B,ze]),Ye=i.useMemo(function(){return Math.ceil(1.1*Ge)},[Ge]),Ue=[null!=(null==U?void 0:U.min)?U.min:!1!==(null==U?void 0:U.beginAtZero)?0:"auto",null!=(null==U?void 0:U.max)?U.max:Ye],Xe=Z.some(function(e){return"right"===e.yAxis&&!V.has(e.key)}),Je=i.useMemo(function(){if(!Xe)return null;var e=function(e){var n,i=Z.filter(function(n){var i;return(null!==(i=n.yAxis)&&void 0!==i?i:"left")===e&&!V.has(n.key)}).map(function(e){return e.key}),l=Oe.flatMap(function(e){return i.map(function(n){return e[n]})}).filter(function(e){return"number"==typeof e&&Number.isFinite(e)});return u.axisDomain(l,{fromZero:"left"===e?!0===(null==U?void 0:U.beginAtZero):!0===(null===(n=null==U?void 0:U.right)||void 0===n?void 0:n.beginAtZero)})};return{left:e("left"),right:e("right")}},[Xe,Z,V,Oe,null==U?void 0:U.beginAtZero,null===(O=null==U?void 0:U.right)||void 0===O?void 0:O.beginAtZero]),Qe=function(e){return void 0===e&&(e="left"),Xe?{yAxisId:e}:{}},$e=!Xe||Z.some(function(e){var n;return"left"===(null!==(n=e.yAxis)&&void 0!==n?n:"left")&&!V.has(e.key)}),en=Xe&&(null==U?void 0:U.highlightOnHover)?Se:null;i.useEffect(function(){var e;null!==Se&&null===en&&(Me(null),null===(e=null==U?void 0:U.onHoverSide)||void 0===e||e.call(U,null))},[en,Se]);var nn=function(e){var n;return null!==en&&(null!==(n=e.yAxis)&&void 0!==n?n:"left")!==en},ln=.15,tn=function(e){var n;Me(e),null===(n=null==U?void 0:U.onHoverSide)||void 0===n||n.call(U,e)},on=function(e){return null===en?{}:en===e?{fontWeight:600}:{opacity:.35}},rn=function(e){return e?{style:{fill:e}}:{}},an=function(e,n,i,l,t){var o,r=e.valueFormatter?e.valueFormatter(n,{x:i,y:n}):a.compactNumber(n),u=null!==(o=e.pointRadius)&&void 0!==o?o:3;return{text:r,y:("below"===e.valueLabelPosition?t+u+16<oe-40:t-u-7<14)?t+u+14:t-u-7}},un=function(e,i,l){var t=e.filter(Number.isFinite).map(function(e,n){return String(i?i(e,n):a.compactNumber(e))}),o=Math.max.apply(Math,n.__spreadArray([0],t.map(function(e){return f(e,ve,400,de)}),!1));return Math.ceil(o+12+(l?(null!=fe?fe:ce?11:12)+12:0))},sn="number"==typeof Ue[1]?Ue[1]:Ge,dn="number"==typeof Ue[0]?Ue[0]:0,cn=(null==U?void 0:U.fitWidth)?Xe&&Je?{left:un(null!==(z=null===(R=Je.left)||void 0===R?void 0:R.ticks)&&void 0!==z?z:[],U.formatTick,U.label),right:un(null!==(P=null===(F=Je.right)||void 0===F?void 0:F.ticks)&&void 0!==P?P:[],null===(E=U.right)||void 0===E?void 0:E.formatTick,null===(D=U.right)||void 0===D?void 0:D.label)}:{left:un(Array.from({length:9},function(e,n){return dn+(sn-dn)*n/8}),U.formatTick,U.label),right:0}:{left:0,right:0},vn=null!==(I=null==Q?void 0:Q.yAxisWidth)&&void 0!==I?I:(null==U?void 0:U.label)?64:48,fn=Math.max(vn,cn.left),hn=Math.max(vn,cn.right),gn={top:12,right:Xe&&(null===(H=null==U?void 0:U.right)||void 0===H?void 0:H.label)?8:16,bottom:8,left:null!=(null==Q?void 0:Q.yAxisWidth)?0:(null==U?void 0:U.label)?16:0},yn=null!==(q=null==Y?void 0:Y.enableScroll)&&void 0!==q&&q,xn=null!==(K=null==Y?void 0:Y.minTickGap)&&void 0!==K?K:2;i.useMemo(function(){if(!yn||!be||Ne.length<=1)return"100%";var e=(Ne.length-1)*xn+200;return e>be-fn-gn.left-gn.right?"".concat(e,"px"):"100%"},[yn,be,Ne.length,xn,fn,gn]);var pn=function(e,n,i){if(ie){var l=Z.find(function(n){return n.key===e});l&&ie({series:l,point:{x:null==n?void 0:n.x,y:null==n?void 0:n[e]},index:i})}},mn=i.useRef(null),kn=function(e){var n;return mn.current=null!==(n=null==e?void 0:e.offset)&&void 0!==n?n:null,null},_n=Xe&&(null==U?void 0:U.highlightOnHover)?{onMouseMove:function(e){var n=function(e){var n=mn.current,i=e.currentTarget.querySelector("svg.recharts-surface");if(!n||!i)return null;var l=i.getBoundingClientRect(),t=l.width/(Number(i.getAttribute("width"))||l.width||1)||1,o=(e.clientX-l.left)/t,r=(e.clientY-l.top)/t;return o<0||r<n.top-8||r>n.top+n.height+8?null:o<n.left?"left":o>n.left+n.width?"right":null}(e);n!==Se&&tn(n)},onMouseLeave:function(){null!==Se&&tn(null)}}:{},bn=i.useRef({signature:"",placed:[]}),jn=Z.some(function(e){return e.inlineLabel&&!V.has(e.key)}),An=function(e){var i,t=null==e?void 0:e.offset,o=null!==(i=null==e?void 0:e.formattedGraphicalItems)&&void 0!==i?i:[];if(!t||!o.length)return null;var r=Fe.filter(function(e){var n=e.series;return!V.has(n.key)}),a=function(e){var n,i,l;return null!==(l=null===(i=null===(n=o.find(function(n){var i,l;return(null===(l=null===(i=null==n?void 0:n.item)||void 0===i?void 0:i.props)||void 0===l?void 0:l.dataKey)===e}))||void 0===n?void 0:n.props)||void 0===i?void 0:i.points)&&void 0!==l?l:[]},u=[];r.forEach(function(e){var n=e.series;a(n.key).forEach(function(e){var i,l,t=Array.isArray(null==e?void 0:e.value)?e.value[1]:null==e?void 0:e.value;if(e&&v(e.x)&&v(e.y)&&null!=t){if(!1!==n.showPoints){var o=(null!==(i=n.pointRadius)&&void 0!==i?i:3)+2;u.push({x:e.x-o,y:e.y-o,w:2*o,h:2*o,kind:"point"})}if(n.showValueLabels){var r=an(n,Number(t),null===(l=e.payload)||void 0===l?void 0:l.x,e.x,e.y);if("string"!=typeof r.text)return;var a=f(r.text,ge,ye,de);u.push({x:e.x-a/2,y:r.y-.85*ge,w:a,h:1.1*ge,kind:"number"})}}})});var d=r.map(function(e){var n,i=e.series,l="string"==typeof i.inlineLabel?i.inlineLabel:i.label;return{key:i.key,text:i.inlineLabel?l:"",points:(n=i.key,a(n).map(function(e){return e&&v(e.x)&&v(e.y)?{x:e.x,y:e.y}:null})),width:i.inlineLabel?f(l,xe,pe,de):0,height:xe,curve:"linear"===i.curve?"linear":"step"===i.curve?"step":"monotone"}}),c=function(e){return Math.round(e)},h=JSON.stringify([[t.left,t.top,t.width,t.height].map(c),d.map(function(e){return[e.key,e.text,e.curve,e.points.map(function(e){return e?[c(e.x),c(e.y)]:0})]}),u.map(function(e){return[e.x,e.y,e.w].map(c)})]);return bn.current.signature!==h&&(bn.current={signature:h,placed:s.placeLineLabels(d,u,{x:t.left,y:t.top,w:t.width,h:t.height})}),l.jsx("g",n.__assign({className:"ellm-graph__series-names",pointerEvents:"none"},{children:bn.current.placed.map(function(e){var i=Fe.find(function(n){return n.series.key===e.key});return i?l.jsx("text",n.__assign({x:e.x,y:e.y,transform:"rotate(".concat(e.angle.toFixed(2)," ").concat(e.x," ").concat(e.y,")"),textAnchor:"middle",dominantBaseline:"central",fill:i.color,fontSize:xe,fontWeight:pe,opacity:nn(i.series)?ln:1,stroke:"#fff",strokeWidth:4,strokeLinejoin:"round",paintOrder:"stroke"},{children:e.text}),e.key):null})}))};return l.jsx("div",n.__assign({style:{display:"flex",flexDirection:"column",width:"100%"}},_n,{children:l.jsx(o.ChartContainer,n.__assign({config:ze,style:{height:oe,fontFamily:de},ref:function(e){e&&null===be&&je(e.clientWidth)}},{children:function(){var e,r,u,s,v,f,g,y,x,p,m,k,_;return l.jsxs(t.ComposedChart,n.__assign({data:Oe,margin:gn,syncId:$},ee?{syncMethod:ee}:{},{onMouseMove:function(e){var n;return we(null!==(n=null==e?void 0:e.activeLabel)&&void 0!==n?n:null)},onMouseLeave:function(){return we(null)}},{children:[l.jsx(t.CartesianGrid,n.__assign({vertical:Ve,horizontal:Ze,stroke:re},ce?{strokeDasharray:"4 4"}:{})),Fe.some(function(e){var n=e.series;return n.area&&n.gradient})?l.jsx("defs",{children:Fe.filter(function(e){var n=e.series;return n.area&&n.gradient}).map(function(e){var i,t=e.series,o=e.color;return l.jsxs("linearGradient",n.__assign({id:ke(t.key),x1:"0",y1:"0",x2:"0",y2:"1"},{children:[l.jsx("stop",{offset:"0%",stopColor:o,stopOpacity:null!==(i=t.areaOpacity)&&void 0!==i?i:.18}),l.jsx("stop",{offset:"100%",stopColor:o,stopOpacity:0})]}),t.key)})}):null,l.jsx(t.XAxis,n.__assign({dataKey:"x",type:"number"===We?"number":"category",hide:!Ke,height:(null==Y?void 0:Y.label)?52:void 0,tickLine:!1,axisLine:!(null==Y?void 0:Y.hideLine)&&{stroke:ce?re:ae},tickMargin:8},(null==Y?void 0:Y.padding)?{padding:{left:null!==(e=Y.padding.left)&&void 0!==e?e:0,right:null!==(r=Y.padding.right)&&void 0!==r?r:0}}:{},{interval:"preserveStartEnd",tick:{fill:se,fontSize:ve},tickFormatter:(null==Y?void 0:Y.formatTick)?function(e,n){return Y.formatTick(e,n)}:void 0,label:(null==ne?void 0:ne.showReferenceAreaLabel)?function(e){return function(e){var i=e.viewBox;e.startTick,e.endTick;var t=i.x,o=i.y,r=i.width,a=1;if((null==ne?void 0:ne.showReferenceArea)&&null!=(null==ne?void 0:ne.referencePoint)&&Ne.length>1){var u=Ne.indexOf(ne.referencePoint);-1!==u&&(a=u/(Ne.length-1))}var s=100*a,c=100-s;return l.jsx("foreignObject",n.__assign({x:t,y:o+24,width:r,height:40},{children:l.jsxs("div",n.__assign({className:"ellm-graph__liveLabelContainer"},{children:[(null==ne?void 0:ne.referenceAreaLabel)&&l.jsxs("div",n.__assign({style:{flex:s,display:"flex",alignItems:"center"}},{children:[l.jsx(d.default,{}),l.jsx("span",n.__assign({style:{padding:"0 12px",color:"#6b7280",fontSize:"12px"}},{children:null==ne?void 0:ne.referenceAreaLabel})),l.jsx(d.default,{})]})),c>0&&l.jsxs("div",n.__assign({style:{flex:c,display:"flex",alignItems:"center"}},{children:[l.jsx(d.default,{style:{backgroundColor:"#DC2626"}}),l.jsxs("div",n.__assign({className:"ellm-graph__liveLabel"},{children:[l.jsx(d.default,{style:{width:"8px",height:"8px",borderRadius:"100%",backgroundColor:"#DC2626",flex:"auto"},pulse:!0}),"LIVE - ",null==ne?void 0:ne.referenceAreaLiveLabel]})),l.jsx(d.default,{style:{backgroundColor:"#DC2626"}})]}))]}))}))}(n.__assign(n.__assign({},e),{startTick:Ne[0],endTick:Ne[Ne.length-1]}))}:(null==Y?void 0:Y.label)?{value:Y.label,position:"insideBottom",offset:4,fill:ue,fontSize:null!=fe?fe:12,fontWeight:500}:void 0})),l.jsx(t.YAxis,n.__assign({},Qe("left"),{hide:!Be||!$e,domain:Xe&&(null==Je?void 0:Je.left)?[Je.left.lo,Je.left.hi]:Ue},Xe&&(null==Je?void 0:Je.left)?{ticks:Je.left.ticks,interval:0}:{},{tickLine:!1,axisLine:!1===(null==U?void 0:U.hideLine)&&{stroke:ae},tickCount:null==U?void 0:U.tickCount,width:fn,tick:n.__assign(n.__assign({fill:null!==(u=null==U?void 0:U.color)&&void 0!==u?u:se,fontSize:ve},rn(null==U?void 0:U.color)),on("left")),tickFormatter:(null==U?void 0:U.formatTick)?function(e,n){return U.formatTick(e,n)}:function(e){return"number"==typeof e?a.compactNumber(e):String(e)},label:(null==U?void 0:U.label)?n.__assign(n.__assign({value:U.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:null!==(s=null==U?void 0:U.color)&&void 0!==s?s:ue,fontSize:null!=fe?fe:ce?11:12,fontWeight:null!=he?he:ce?600:500},ce?{letterSpacing:"0.02em"}:{}),on("left")):void 0})),Xe?l.jsx(t.YAxis,n.__assign({yAxisId:"right",orientation:"right",hide:!1===(null===(v=null==U?void 0:U.right)||void 0===v?void 0:v.show),width:hn,domain:(null==Je?void 0:Je.right)?[Je.right.lo,Je.right.hi]:["auto","auto"]},(null==Je?void 0:Je.right)?{ticks:Je.right.ticks,interval:0}:{},{tickLine:!1,axisLine:!1,tick:n.__assign(n.__assign({fill:null!==(g=null===(f=null==U?void 0:U.right)||void 0===f?void 0:f.color)&&void 0!==g?g:se,fontSize:ve},rn(null===(y=null==U?void 0:U.right)||void 0===y?void 0:y.color)),on("right")),tickFormatter:(null===(x=null==U?void 0:U.right)||void 0===x?void 0:x.formatTick)?function(e,n){return U.right.formatTick(e,n)}:function(e){return"number"==typeof e?a.compactNumber(e):String(e)},label:(null===(p=null==U?void 0:U.right)||void 0===p?void 0:p.label)?n.__assign(n.__assign({value:U.right.label,angle:90,position:"insideRight",style:{textAnchor:"middle"},fill:null!==(m=U.right.color)&&void 0!==m?m:ue,fontSize:null!=fe?fe:ce?11:12,fontWeight:null!=he?he:ce?600:500},ce?{letterSpacing:"0.02em"}:{}),on("right")):void 0})):null,Ee&&l.jsx(o.ChartTooltip,{cursor:ce?{stroke:"#94a3b8",strokeOpacity:.55,strokeWidth:1}:{stroke:ae,strokeDasharray:"4 4"},content:function(e){var i,t=(null!==(i=e.payload)&&void 0!==i?i:[]).filter(function(e){var n=Z.find(function(n){return n.key===e.dataKey});return!1!==(null==n?void 0:n.showInTooltip)&&!(De&&!De.has(String(e.dataKey)))});return(null==X?void 0:X.render)?X.render({x:e.label,points:t.map(function(n){var i;return{series:Z.find(function(e){return e.key===n.dataKey}),value:null!==(i=n.value)&&void 0!==i?i:null,point:{x:e.label,y:n.value},color:n.color}})}):l.jsx(o.ChartTooltipContent,n.__assign({},e,{payload:t,hideLabel:!1===(null==X?void 0:X.showHeading),valueFormatters:Pe,labelFormatter:(null==X?void 0:X.formatHeading)?function(e){return X.formatHeading(e)}:void 0}))}}),Ie&&l.jsx(o.ChartLegend,{verticalAlign:He,content:function(e){var i;return l.jsx(o.ChartLegendContent,n.__assign({},e,{payload:null===(i=e.payload)||void 0===i?void 0:i.filter(function(e){var n;return!1!==(null===(n=Z.find(function(n){return n.key===e.dataKey}))||void 0===n?void 0:n.showInLegend)}),tier:B,verticalAlign:He,align:qe,hiddenKeys:V,activeThreshold:le,onThresholdViewChange:te,onItemClick:!1!==(null==J?void 0:J.toggle)&&G?G:void 0}))}}),(null==ne?void 0:ne.showReferenceArea)&&null!=(null==ne?void 0:ne.referencePoint)&&l.jsx(t.ReferenceArea,n.__assign({},Qe("left"),{x1:ne.referencePoint,fill:null!==(k=ne.referenceAreaFill)&&void 0!==k?k:"#2563EB1A"})),(null==ne?void 0:ne.showReferenceArea)&&null!=ne.referencePoint&&l.jsx(t.ReferenceLine,n.__assign({},Qe("left"),{x:ne.referencePoint,stroke:null!==(_=ne.referenceLineStroke)&&void 0!==_?_:"#3B82F6",strokeDasharray:"4 4"})),(null==le?void 0:le[B])&&void 0!==ze[null==le?void 0:le[B]].threshold&&l.jsx(t.ReferenceLine,n.__assign({},Qe("left"),{y:ze[null==le?void 0:le[B]].threshold,stroke:"red",strokeWidth:1.5,strokeDasharray:"4 4",label:function(e){var i=e.viewBox;return l.jsx("text",n.__assign({x:i.x-8,y:i.y,textAnchor:"end",dominantBaseline:"middle",fill:"red",fontSize:11},{children:ze[null==le?void 0:le[B]].threshold}))}})),Fe.map(function(e){var i,o,r,a,u,s=e.series,d=V.has(s.key),c="var(--color-".concat(s.key,")"),v=nn(s)?ln:1,f=!0===s.dashed?"6 5":"string"==typeof s.dashed?s.dashed:void 0,g=!1!==s.showPoints&&(s.fillPointsOnHover||ie||s.showValueLabels||s.pointColor?function(e){var i,t,o,r,a,u,d,f=null===(i=e.payload)||void 0===i?void 0:i[s.key];if(null==f||!Number.isFinite(Number(f)))return l.jsx("g",{});var h=an(s,Number(f),null===(t=e.payload)||void 0===t?void 0:t.x,e.cx,e.cy),g=h.text,y=s.pointColor?s.pointColor({x:null===(o=e.payload)||void 0===o?void 0:o.x,y:Number(f)},null!==(r=e.index)&&void 0!==r?r:0):c;return l.jsxs("g",n.__assign({style:{cursor:ie?"pointer":"default"},opacity:v,onClick:ie?function(){var n;return pn(s.key,e.payload,null!==(n=e.index)&&void 0!==n?n:0)}:void 0},{children:[s.showValueLabels&&"string"==typeof g?l.jsx("text",n.__assign({x:e.cx,y:h.y,textAnchor:"middle",fill:null!==(a=s.valueLabelColor)&&void 0!==a?a:y,fontSize:ge,fontWeight:ye},ce?{stroke:"#fff",strokeWidth:3,strokeLinejoin:"round",paintOrder:"stroke"}:{},{children:g})):null,l.jsx("circle",{cx:e.cx,cy:e.cy,r:null!==(u=s.pointRadius)&&void 0!==u?u:3,fill:s.fillPointsOnHover&&Le===(null===(d=e.payload)||void 0===d?void 0:d.x)?y:"#fff",stroke:y,strokeWidth:2})]}))}:{r:null!==(i=s.pointRadius)&&void 0!==i?i:3,fill:"#fff",stroke:c,strokeWidth:2,opacity:v}),y=!s.fillPointsOnHover&&n.__assign(n.__assign({r:null!==(o=s.activePointRadius)&&void 0!==o?o:(null!==(r=s.pointRadius)&&void 0!==r?r:3)+2},ce?{fill:c,stroke:"#fff",strokeWidth:2.5}:{}),ie&&{onClick:function(e,n){var i,l;return pn(s.key,null!==(i=null==n?void 0:n.payload)&&void 0!==i?i:n,null!==(l=null==n?void 0:n.index)&&void 0!==l?l:0)}}),x=n.__assign(n.__assign(n.__assign(n.__assign({},Qe(s.yAxis)),{key:s.key,dataKey:s.key,name:s.key,type:h(s.curve),stroke:c,strokeWidth:null!==(a=s.strokeWidth)&&void 0!==a?a:2,strokeDasharray:f,strokeOpacity:v}),ce?{strokeLinecap:"round",strokeLinejoin:"round"}:{}),{connectNulls:!1,isAnimationActive:!1,hide:d,dot:g,activeDot:y});return s.area?l.jsx(t.Area,n.__assign({},x,{fill:s.gradient?"url(#".concat(ke(s.key),")"):c,fillOpacity:(s.gradient?1:null!==(u=s.areaOpacity)&&void 0!==u?u:.12)*v})):l.jsx(t.Line,n.__assign({},x))}),Fe.flatMap(function(e){var o,r=e.series,a=e.color;if(V.has(r.key)||!(null===(o=r.markers)||void 0===o?void 0:o.length))return[];var u=new Map(r.data.map(function(e){return[e.x,e.y]}));return r.markers.map(function(e){var o,s=u.get(e.x);if(null==s)return null;var d=null!==(o=e.color)&&void 0!==o?o:a;return i.createElement(t.ReferenceDot,n.__assign({},Qe(r.yAxis),{key:"marker-".concat(r.key,"-").concat(e.x),x:e.x,y:s,ifOverflow:"extendDomain",shape:function(i){var t,o;return l.jsxs("g",n.__assign({style:{cursor:e.onClick?"pointer":"default"},opacity:nn(r)?ln:1,onClick:e.onClick,role:e.onClick?"button":void 0,"aria-label":e.label},{children:[e.label?l.jsx("title",{children:e.label}):null,l.jsx("circle",{cx:i.cx,cy:i.cy,r:null!==(t=e.haloRadius)&&void 0!==t?t:9,fill:d,fillOpacity:.16}),l.jsx("circle",{cx:i.cx,cy:i.cy,r:null!==(o=e.radius)&&void 0!==o?o:5,fill:r.fillPointsOnHover&&Le===e.x?d:"#fff",stroke:d,strokeWidth:2.5})]}))}}))})}),jn?l.jsx(t.Customized,{component:l.jsx(c,{render:An})}):null,Xe&&(null==U?void 0:U.highlightOnHover)?l.jsx(t.Customized,{component:l.jsx(c,{render:kn})}):null]}))}()}))}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("../../../_virtual/_tslib.js"),i=require("react"),l=require("react/jsx-runtime"),t=require("recharts"),r=require("../ui/chart.js"),o=require("./types.js"),u=require("../../utils/index.js"),a=require("./axisDomain.js"),d=require("./inlineLabels.js"),s=require("./Seperator.js"),c={K:1e3,M:1e6,B:1e9,T:1e12},v=function(e){if(null==e||"string"==typeof e&&""===e.trim())return null;var n=Number(e);return Number.isFinite(n)?n:null},f=function(e,n,i){return e.valueFormatter?e.valueFormatter(n,{x:i,y:n}):u.compactNumber(n)},h=function(e,n,i){var l;return null!==(l=function(e){var n,i,l;if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"!=typeof e||e.includes("%"))return null;var t=e.replace(/\s/g,"").match(/[-+]?(?:\d[\d,]*(?:\.\d*)?|\.\d+)([KMBT])?/i);if(!t)return null;var r=Number(t[0].replace(/[KMBT,]/gi,"")),o=null!==(l=c[null!==(i=null===(n=t[1])||void 0===n?void 0:n.toUpperCase())&&void 0!==i?i:""])&&void 0!==l?l:1;return Number.isFinite(r)?r*o:null}(f(e,n,i)))&&void 0!==l?l:n},g=function(e){var i=e.render,t=n.__rest(e,["render"]);return l.jsx(l.Fragment,{children:i(t)})},y=function(e){return"number"==typeof e&&!Number.isNaN(e)},x=function(n,i,l,t){return void 0===e&&(e="undefined"!=typeof document?document.createElement("canvas").getContext("2d"):null),e?(e.font="".concat(l," ").concat(i,"px ").concat(t),e.measureText(n).width):n.length*i*.58},p=function(e){switch(e){case"linear":return"linear";case"step":return"stepAfter";default:return"monotone"}};exports.default=function(e){var c,m,k,_,b,j,C,L,A,w,M,S,T,N,W,F,O,R,P,z,E,D,I,K,H,B,q,V,Z,G=e.tier,U=e.series,Y=e.hiddenKeys,X=e.onToggleSeries,J=e.xAxis,Q=e.yAxis,$=e.tooltip,ee=e.legend,ne=e.style,ie=e.syncId,le=e.syncMethod,te=e.reference;e.scrollable;var re=e.onPointClick,oe=e.activeThreshold,ue=e.onThresholdViewChange,ae=null!==(c=null==ne?void 0:ne.chartHeight)&&void 0!==c?c:300,de=null!==(m=null==ne?void 0:ne.gridColor)&&void 0!==m?m:"#eef0f4",se=null!==(k=null==ne?void 0:ne.axisColor)&&void 0!==k?k:"#d7dbe3",ce=null!==(_=null==ne?void 0:ne.axisLabelColor)&&void 0!==_?_:"#6b7280",ve=null!==(b=null==ne?void 0:ne.tickColor)&&void 0!==b?b:"#9ca3af",fe=null!==(j=null==ne?void 0:ne.fontFamily)&&void 0!==j?j:"Inter, system-ui, -apple-system, sans-serif",he=Boolean(null==ne?void 0:ne.modern),ge=null!==(L=null===(C=null==ne?void 0:ne.text)||void 0===C?void 0:C.tickSize)&&void 0!==L?L:11,ye=null===(A=null==ne?void 0:ne.text)||void 0===A?void 0:A.axisTitleSize,xe=null===(w=null==ne?void 0:ne.text)||void 0===w?void 0:w.axisTitleWeight,pe=null!==(S=null===(M=null==ne?void 0:ne.text)||void 0===M?void 0:M.valueLabelSize)&&void 0!==S?S:11,me=null!==(N=null===(T=null==ne?void 0:ne.text)||void 0===T?void 0:T.valueLabelWeight)&&void 0!==N?N:600,ke=null!==(F=null===(W=null==ne?void 0:ne.text)||void 0===W?void 0:W.seriesLabelSize)&&void 0!==F?F:11,_e=null!==(R=null===(O=null==ne?void 0:ne.text)||void 0===O?void 0:O.seriesLabelWeight)&&void 0!==R?R:500,be="ellm-grad-".concat(i.useId().replace(/[^a-zA-Z0-9_-]/g,"")),je=function(e){return"".concat(be,"-").concat(e.replace(/[^a-zA-Z0-9_-]/g,"_"))},Ce=i.useState(null),Le=Ce[0],Ae=Ce[1],we=i.useState(null),Me=we[0],Se=we[1],Te=i.useMemo(function(){var e,i,l;if(null===(e=null==J?void 0:J.categories)||void 0===e?void 0:e.length)return{categories:J.categories,xType:null!==(i=J.type)&&void 0!==i?i:"category"};var t=new Set,r=[];U.forEach(function(e){return e.data.forEach(function(e){t.has(e.x)||(t.add(e.x),r.push(e.x))})});var o=r.every(y),u=null!==(l=null==J?void 0:J.type)&&void 0!==l?l:o?"number":"category";return{categories:"number"===u?n.__spreadArray([],r,!0).sort(function(e,n){return Number(e)-Number(n)}):r,xType:u}},[U,null==J?void 0:J.categories,null==J?void 0:J.type]),Ne=Te.categories,We=Te.xType,Fe=i.useMemo(function(){var e=new Map;return U.forEach(function(n){var i=new Map;n.data.forEach(function(e){var l=v(e.y);i.set(e.x,null==l?null:h(n,l,e.x))}),e.set(n.key,i)}),Ne.map(function(n){var i={x:n};return U.forEach(function(l){var t,r=null===(t=e.get(l.key))||void 0===t?void 0:t.get(n);i[l.key]=null==r?null:r}),i})},[U,Ne]),Oe=i.useMemo(function(){var e={},n=U.map(function(n,i){var l,t=null!==(l=n.color)&&void 0!==l?l:o.colorForIndex(null==ne?void 0:ne.colors,i);return e[n.key]={label:n.label,color:t,threshold:n.threshold,thresholdUnit:n.thresholdUnit},{series:n,color:t,index:i}});return{chartConfig:e,resolved:n}},[U,null==ne?void 0:ne.colors]),Re=Oe.chartConfig,Pe=Oe.resolved,ze=i.useMemo(function(){var e={};return U.forEach(function(n){n.valueFormatter&&(e[n.key]=function(e,i){var l;return n.valueFormatter(e,null!==(l=null==i?void 0:i.payload)&&void 0!==l?l:{x:null==i?void 0:i.x,y:e})})}),e},[U]),Ee=!1!==(null==$?void 0:$.enabled),De=(null==$?void 0:$.seriesKeys)?new Set($.seriesKeys):null,Ie=!1!==(null==ee?void 0:ee.show),Ke="top"===(null==ee?void 0:ee.position)?"top":"bottom",He="start"===(null==ee?void 0:ee.align)?"left":"end"===(null==ee?void 0:ee.align)?"right":"center",Be=!1!==(null==J?void 0:J.show),qe=!1!==(null==Q?void 0:Q.show),Ve=!1!==(null==ne?void 0:ne.showGrid),Ze=!!(null==ne?void 0:ne.showVerticalGrid),Ge=i.useMemo(function(){var e,i=U.filter(function(e){return!Y.has(e.key)}),l=Math.max.apply(Math,n.__spreadArray([0],Fe.flatMap(function(e){return i.map(function(n){return Number(e[n.key])||0})}),!1)),t=null==oe?void 0:oe[G],r=t?null===(e=Re[t])||void 0===e?void 0:e.threshold:void 0;return void 0!==r&&r>l&&(l=r),l},[Fe,U,Y,oe,G,Re]),Ue=i.useMemo(function(){return Math.ceil(1.1*Ge)},[Ge]),Ye=[null!=(null==Q?void 0:Q.min)?Q.min:!1!==(null==Q?void 0:Q.beginAtZero)?0:"auto",null!=(null==Q?void 0:Q.max)?Q.max:Ue],Xe=U.some(function(e){return"right"===e.yAxis&&!Y.has(e.key)}),Je=i.useMemo(function(){if(!Xe&&!(null==Q?void 0:Q.tickCount))return null;var e=function(e){var i=U.filter(function(n){var i;return(null!==(i=n.yAxis)&&void 0!==i?i:"left")===e&&!Y.has(n.key)}).map(function(e){return e.key}),l=Fe.flatMap(function(e){return i.map(function(n){return e[n]})}).filter(function(e){return"number"==typeof e&&Number.isFinite(e)}),t="left"===e?Q:null==Q?void 0:Q.right,r=(null==t?void 0:t.tickCount)?Math.max(1,t.tickCount-1):void 0;return a.axisDomain(l,n.__assign(n.__assign({fromZero:!0===(null==t?void 0:t.beginAtZero)},r?{steps:r}:{}),void 0!==(null==t?void 0:t.domainPadding)?{paddingRatio:t.domainPadding}:{}))};return{left:e("left"),right:Xe?e("right"):null}},[Xe,U,Y,Fe,null==Q?void 0:Q.beginAtZero,null===(P=null==Q?void 0:Q.right)||void 0===P?void 0:P.beginAtZero,null==Q?void 0:Q.tickCount,null===(z=null==Q?void 0:Q.right)||void 0===z?void 0:z.tickCount,null==Q?void 0:Q.domainPadding,null===(E=null==Q?void 0:Q.right)||void 0===E?void 0:E.domainPadding]),Qe=function(e){return void 0===e&&(e="left"),Xe?{yAxisId:e}:{}},$e=!Xe||U.some(function(e){var n;return"left"===(null!==(n=e.yAxis)&&void 0!==n?n:"left")&&!Y.has(e.key)}),en=Xe&&(null==Q?void 0:Q.highlightOnHover)?Me:null;i.useEffect(function(){var e;null!==Me&&null===en&&(Se(null),null===(e=null==Q?void 0:Q.onHoverSide)||void 0===e||e.call(Q,null))},[en,Me]);var nn=function(e){var n;return null!==en&&(null!==(n=e.yAxis)&&void 0!==n?n:"left")!==en},ln=.15,tn=function(e){var n;Se(e),null===(n=null==Q?void 0:Q.onHoverSide)||void 0===n||n.call(Q,e)},rn=function(e){return null===en?{}:en===e?{fontWeight:600}:{opacity:.35}},on=function(e){return e?{style:{fill:e}}:{}},un=function(e,n,i,l,t){var r,o=f(e,n,i),u=null!==(r=e.pointRadius)&&void 0!==r?r:3;return{text:o,y:("below"===e.valueLabelPosition?t+u+16<ae-40:t-u-7<14)?t+u+14:t-u-7}},an=function(e,i,l){var t=e.filter(Number.isFinite).map(function(e,n){return String(i?i(e,n):u.compactNumber(e))}),r=Math.max.apply(Math,n.__spreadArray([0],t.map(function(e){return x(e,ge,400,fe)}),!1));return Math.ceil(r+12+(l?(null!=ye?ye:he?11:12)+12:0))},dn="number"==typeof Ye[1]?Ye[1]:Ge,sn="number"==typeof Ye[0]?Ye[0]:0,cn=(null==Q?void 0:Q.fitWidth)?Xe&&Je?{left:an(null!==(I=null===(D=Je.left)||void 0===D?void 0:D.ticks)&&void 0!==I?I:[],Q.formatTick,Q.label),right:an(null!==(H=null===(K=Je.right)||void 0===K?void 0:K.ticks)&&void 0!==H?H:[],null===(B=Q.right)||void 0===B?void 0:B.formatTick,null===(q=Q.right)||void 0===q?void 0:q.label)}:{left:an(Array.from({length:9},function(e,n){return sn+(dn-sn)*n/8}),Q.formatTick,Q.label),right:0}:{left:0,right:0},vn=null!==(V=null==ne?void 0:ne.yAxisWidth)&&void 0!==V?V:(null==Q?void 0:Q.label)?64:48,fn=Math.max(vn,cn.left),hn=Math.max(vn,cn.right),gn={top:12,right:Xe&&(null===(Z=null==Q?void 0:Q.right)||void 0===Z?void 0:Z.label)?8:16,bottom:8,left:null!=(null==ne?void 0:ne.yAxisWidth)?0:(null==Q?void 0:Q.label)?16:0},yn=function(e,n,i){if(re){var l=U.find(function(n){return n.key===e});l&&re({series:l,point:{x:null==n?void 0:n.x,y:null==n?void 0:n[e]},index:i})}},xn=i.useRef(null),pn=function(e){var n;return xn.current=null!==(n=null==e?void 0:e.offset)&&void 0!==n?n:null,null},mn=Xe&&(null==Q?void 0:Q.highlightOnHover)?{onMouseMove:function(e){var n=function(e){var n=xn.current,i=e.currentTarget.querySelector("svg.recharts-surface");if(!n||!i)return null;var l=i.getBoundingClientRect(),t=l.width/(Number(i.getAttribute("width"))||l.width||1)||1,r=(e.clientX-l.left)/t,o=(e.clientY-l.top)/t;return r<0||o<n.top-8||o>n.top+n.height+8?null:r<n.left?"left":r>n.left+n.width?"right":null}(e);n!==Me&&tn(n)},onMouseLeave:function(){null!==Me&&tn(null)}}:{},kn=i.useRef({signature:"",placed:[]}),_n=U.some(function(e){return e.inlineLabel&&!Y.has(e.key)}),bn=function(e){var i,t=null==e?void 0:e.offset,r=null!==(i=null==e?void 0:e.formattedGraphicalItems)&&void 0!==i?i:[];if(!t||!r.length)return null;var o=Pe.filter(function(e){var n=e.series;return!Y.has(n.key)}),u=function(e){var n,i,l;return null!==(l=null===(i=null===(n=r.find(function(n){var i,l;return(null===(l=null===(i=null==n?void 0:n.item)||void 0===i?void 0:i.props)||void 0===l?void 0:l.dataKey)===e}))||void 0===n?void 0:n.props)||void 0===i?void 0:i.points)&&void 0!==l?l:[]},a=[];o.forEach(function(e){var n=e.series;u(n.key).forEach(function(e){var i,l,t=Array.isArray(null==e?void 0:e.value)?e.value[1]:null==e?void 0:e.value;if(e&&y(e.x)&&y(e.y)&&null!=t){if(!1!==n.showPoints){var r=(null!==(i=n.pointRadius)&&void 0!==i?i:3)+2;a.push({x:e.x-r,y:e.y-r,w:2*r,h:2*r,kind:"point"})}if(n.showValueLabels){var o=un(n,Number(t),null===(l=e.payload)||void 0===l?void 0:l.x,e.x,e.y);if("string"!=typeof o.text)return;var u=x(o.text,pe,me,fe);a.push({x:e.x-u/2,y:o.y-.85*pe,w:u,h:1.1*pe,kind:"number"})}}})});var s=o.map(function(e){var n,i=e.series,l="string"==typeof i.inlineLabel?i.inlineLabel:i.label;return{key:i.key,text:i.inlineLabel?l:"",points:(n=i.key,u(n).map(function(e){return e&&y(e.x)&&y(e.y)?{x:e.x,y:e.y}:null})),width:i.inlineLabel?x(l,ke,_e,fe):0,height:ke,curve:"linear"===i.curve?"linear":"step"===i.curve?"step":"monotone"}}),c=function(e){return Math.round(e)},v=JSON.stringify([[t.left,t.top,t.width,t.height].map(c),s.map(function(e){return[e.key,e.text,e.curve,e.points.map(function(e){return e?[c(e.x),c(e.y)]:0})]}),a.map(function(e){return[e.x,e.y,e.w].map(c)})]);return kn.current.signature!==v&&(kn.current={signature:v,placed:d.placeLineLabels(s,a,{x:t.left,y:t.top,w:t.width,h:t.height})}),l.jsx("g",n.__assign({className:"ellm-graph__series-names",pointerEvents:"none"},{children:kn.current.placed.map(function(e){var i=Pe.find(function(n){return n.series.key===e.key});return i?l.jsx("text",n.__assign({x:e.x,y:e.y,transform:"rotate(".concat(e.angle.toFixed(2)," ").concat(e.x," ").concat(e.y,")"),textAnchor:"middle",dominantBaseline:"central",fill:i.color,fontSize:ke,fontWeight:_e,opacity:nn(i.series)?ln:1,stroke:"#fff",strokeWidth:4,strokeLinejoin:"round",paintOrder:"stroke"},{children:e.text}),e.key):null})}))};return l.jsx("div",n.__assign({style:{display:"flex",flexDirection:"column",width:"100%"}},mn,{children:l.jsx(r.ChartContainer,n.__assign({config:Re,style:{height:ae,fontFamily:fe}},{children:function(){var e,o,a,d,c,f,x,m,k,_,b,j,C,L;return l.jsxs(t.ComposedChart,n.__assign({data:Fe,margin:gn,syncId:ie},le?{syncMethod:le}:{},{onMouseMove:function(e){var n;return Ae(null!==(n=null==e?void 0:e.activeLabel)&&void 0!==n?n:null)},onMouseLeave:function(){return Ae(null)}},{children:[l.jsx(t.CartesianGrid,n.__assign({vertical:Ze,horizontal:Ve,stroke:de},he?{strokeDasharray:"4 4"}:{})),Pe.some(function(e){var n=e.series;return n.area&&n.gradient})?l.jsx("defs",{children:Pe.filter(function(e){var n=e.series;return n.area&&n.gradient}).map(function(e){var i,t=e.series,r=e.color;return l.jsxs("linearGradient",n.__assign({id:je(t.key),x1:"0",y1:"0",x2:"0",y2:"1"},{children:[l.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:null!==(i=t.areaOpacity)&&void 0!==i?i:.18}),l.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:0})]}),t.key)})}):null,l.jsx(t.XAxis,n.__assign({dataKey:"x",type:"number"===We?"number":"category",hide:!Be,height:(null==J?void 0:J.label)?52:void 0,tickLine:!1,axisLine:!(null==J?void 0:J.hideLine)&&{stroke:he?de:se},tickMargin:8},(null==J?void 0:J.padding)?{padding:{left:null!==(e=J.padding.left)&&void 0!==e?e:0,right:null!==(o=J.padding.right)&&void 0!==o?o:0}}:{},{interval:"preserveStartEnd",tick:{fill:ve,fontSize:ge},tickFormatter:(null==J?void 0:J.formatTick)?function(e,n){return J.formatTick(e,n)}:void 0,label:(null==te?void 0:te.showReferenceAreaLabel)?function(e){return function(e){var i=e.viewBox;e.startTick,e.endTick;var t=i.x,r=i.y,o=i.width,u=1;if((null==te?void 0:te.showReferenceArea)&&null!=(null==te?void 0:te.referencePoint)&&Ne.length>1){var a=Ne.indexOf(te.referencePoint);-1!==a&&(u=a/(Ne.length-1))}var d=100*u,c=100-d;return l.jsx("foreignObject",n.__assign({x:t,y:r+24,width:o,height:40},{children:l.jsxs("div",n.__assign({className:"ellm-graph__liveLabelContainer"},{children:[(null==te?void 0:te.referenceAreaLabel)&&l.jsxs("div",n.__assign({style:{flex:d,display:"flex",alignItems:"center"}},{children:[l.jsx(s.default,{}),l.jsx("span",n.__assign({style:{padding:"0 12px",color:"#6b7280",fontSize:"12px"}},{children:null==te?void 0:te.referenceAreaLabel})),l.jsx(s.default,{})]})),c>0&&l.jsxs("div",n.__assign({style:{flex:c,display:"flex",alignItems:"center"}},{children:[l.jsx(s.default,{style:{backgroundColor:"#DC2626"}}),l.jsxs("div",n.__assign({className:"ellm-graph__liveLabel"},{children:[l.jsx(s.default,{style:{width:"8px",height:"8px",borderRadius:"100%",backgroundColor:"#DC2626",flex:"auto"},pulse:!0}),"LIVE - ",null==te?void 0:te.referenceAreaLiveLabel]})),l.jsx(s.default,{style:{backgroundColor:"#DC2626"}})]}))]}))}))}(n.__assign(n.__assign({},e),{startTick:Ne[0],endTick:Ne[Ne.length-1]}))}:(null==J?void 0:J.label)?{value:J.label,position:"insideBottom",offset:4,fill:ce,fontSize:null!=ye?ye:12,fontWeight:500}:void 0})),l.jsx(t.YAxis,n.__assign({},Qe("left"),{hide:!qe||!$e,domain:(null==Je?void 0:Je.left)?[Je.left.lo,Je.left.hi]:Ye},(null==Je?void 0:Je.left)?{ticks:Je.left.ticks,interval:0}:{},{tickLine:!1,axisLine:!1===(null==Q?void 0:Q.hideLine)&&{stroke:se},tickCount:null==Q?void 0:Q.tickCount,width:fn,tick:n.__assign(n.__assign({fill:null!==(a=null==Q?void 0:Q.color)&&void 0!==a?a:ve,fontSize:ge},on(null==Q?void 0:Q.color)),rn("left")),tickFormatter:(null==Q?void 0:Q.formatTick)?function(e,n){return Q.formatTick(e,n)}:function(e){return"number"==typeof e?u.compactNumber(e):String(e)},label:(null==Q?void 0:Q.label)?n.__assign(n.__assign({value:Q.label,angle:-90,position:"insideLeft",style:{textAnchor:"middle"},fill:null!==(d=null==Q?void 0:Q.color)&&void 0!==d?d:ce,fontSize:null!=ye?ye:he?11:12,fontWeight:null!=xe?xe:he?600:500},he?{letterSpacing:"0.02em"}:{}),rn("left")):void 0})),Xe?l.jsx(t.YAxis,n.__assign({yAxisId:"right",orientation:"right",hide:!1===(null===(c=null==Q?void 0:Q.right)||void 0===c?void 0:c.show),width:hn,domain:(null==Je?void 0:Je.right)?[Je.right.lo,Je.right.hi]:["auto","auto"]},(null==Je?void 0:Je.right)?{ticks:Je.right.ticks,interval:0}:{},{tickLine:!1,axisLine:!1,tickCount:null===(f=null==Q?void 0:Q.right)||void 0===f?void 0:f.tickCount,tick:n.__assign(n.__assign({fill:null!==(m=null===(x=null==Q?void 0:Q.right)||void 0===x?void 0:x.color)&&void 0!==m?m:ve,fontSize:ge},on(null===(k=null==Q?void 0:Q.right)||void 0===k?void 0:k.color)),rn("right")),tickFormatter:(null===(_=null==Q?void 0:Q.right)||void 0===_?void 0:_.formatTick)?function(e,n){return Q.right.formatTick(e,n)}:function(e){return"number"==typeof e?u.compactNumber(e):String(e)},label:(null===(b=null==Q?void 0:Q.right)||void 0===b?void 0:b.label)?n.__assign(n.__assign({value:Q.right.label,angle:90,position:"insideRight",style:{textAnchor:"middle"},fill:null!==(j=Q.right.color)&&void 0!==j?j:ce,fontSize:null!=ye?ye:he?11:12,fontWeight:null!=xe?xe:he?600:500},he?{letterSpacing:"0.02em"}:{}),rn("right")):void 0})):null,Ee&&l.jsx(r.ChartTooltip,{cursor:he?{stroke:"#94a3b8",strokeOpacity:.55,strokeWidth:1}:{stroke:se,strokeDasharray:"4 4"},content:function(e){var i,t=(null!==(i=e.payload)&&void 0!==i?i:[]).filter(function(e){var n=U.find(function(n){return n.key===e.dataKey});return!1!==(null==n?void 0:n.showInTooltip)&&!(De&&!De.has(String(e.dataKey)))});return(null==$?void 0:$.render)?$.render({x:e.label,points:t.map(function(n){var i;return{series:U.find(function(e){return e.key===n.dataKey}),value:null!==(i=n.value)&&void 0!==i?i:null,point:{x:e.label,y:n.value},color:n.color}})}):l.jsx(r.ChartTooltipContent,n.__assign({},e,{payload:t,hideLabel:!1===(null==$?void 0:$.showHeading),valueFormatters:ze,labelFormatter:(null==$?void 0:$.formatHeading)?function(e){return $.formatHeading(e)}:void 0}))}}),Ie&&l.jsx(r.ChartLegend,{verticalAlign:Ke,content:function(e){var i;return l.jsx(r.ChartLegendContent,n.__assign({},e,{payload:null===(i=e.payload)||void 0===i?void 0:i.filter(function(e){var n;return!1!==(null===(n=U.find(function(n){return n.key===e.dataKey}))||void 0===n?void 0:n.showInLegend)}),tier:G,verticalAlign:Ke,align:He,hiddenKeys:Y,activeThreshold:oe,onThresholdViewChange:ue,onItemClick:!1!==(null==ee?void 0:ee.toggle)&&X?X:void 0}))}}),(null==te?void 0:te.showReferenceArea)&&null!=(null==te?void 0:te.referencePoint)&&l.jsx(t.ReferenceArea,n.__assign({},Qe("left"),{x1:te.referencePoint,fill:null!==(C=te.referenceAreaFill)&&void 0!==C?C:"#2563EB1A"})),(null==te?void 0:te.showReferenceArea)&&null!=te.referencePoint&&l.jsx(t.ReferenceLine,n.__assign({},Qe("left"),{x:te.referencePoint,stroke:null!==(L=te.referenceLineStroke)&&void 0!==L?L:"#3B82F6",strokeDasharray:"4 4"})),(null==oe?void 0:oe[G])&&void 0!==Re[null==oe?void 0:oe[G]].threshold&&l.jsx(t.ReferenceLine,n.__assign({},Qe("left"),{y:Re[null==oe?void 0:oe[G]].threshold,stroke:"red",strokeWidth:1.5,strokeDasharray:"4 4",label:function(e){var i=e.viewBox;return l.jsx("text",n.__assign({x:i.x-8,y:i.y,textAnchor:"end",dominantBaseline:"middle",fill:"red",fontSize:11},{children:Re[null==oe?void 0:oe[G]].threshold}))}})),Pe.map(function(e){var i,r,o,u,a,d=e.series,s=Y.has(d.key),c="var(--color-".concat(d.key,")"),v=nn(d)?ln:1,f=!0===d.dashed?"6 5":"string"==typeof d.dashed?d.dashed:void 0,h=!1!==d.showPoints&&(d.fillPointsOnHover||re||d.showValueLabels||d.pointColor?function(e){var i,t,r,o,u,a,s,f=null===(i=e.payload)||void 0===i?void 0:i[d.key];if(null==f||!Number.isFinite(Number(f)))return l.jsx("g",{});var h=un(d,Number(f),null===(t=e.payload)||void 0===t?void 0:t.x,e.cx,e.cy),g=h.text,y=d.pointColor?d.pointColor({x:null===(r=e.payload)||void 0===r?void 0:r.x,y:Number(f)},null!==(o=e.index)&&void 0!==o?o:0):c;return l.jsxs("g",n.__assign({style:{cursor:re?"pointer":"default"},opacity:v,onClick:re?function(){var n;return yn(d.key,e.payload,null!==(n=e.index)&&void 0!==n?n:0)}:void 0},{children:[d.showValueLabels&&"string"==typeof g?l.jsx("text",n.__assign({x:e.cx,y:h.y,textAnchor:"middle",fill:null!==(u=d.valueLabelColor)&&void 0!==u?u:y,fontSize:pe,fontWeight:me},he?{stroke:"#fff",strokeWidth:3,strokeLinejoin:"round",paintOrder:"stroke"}:{},{children:g})):null,l.jsx("circle",{cx:e.cx,cy:e.cy,r:null!==(a=d.pointRadius)&&void 0!==a?a:3,fill:d.fillPointsOnHover&&Le===(null===(s=e.payload)||void 0===s?void 0:s.x)?y:"#fff",stroke:y,strokeWidth:2})]}))}:{r:null!==(i=d.pointRadius)&&void 0!==i?i:3,fill:"#fff",stroke:c,strokeWidth:2,opacity:v}),g=null!==(r=d.activePointRadius)&&void 0!==r?r:(null!==(o=d.pointRadius)&&void 0!==o?o:3)+2,x=!d.fillPointsOnHover&&(re?function(e){return y(e.cx)&&y(e.cy)?l.jsx("circle",{cx:e.cx,cy:e.cy,r:g,fill:he?c:e.fill,stroke:"#fff",strokeWidth:he?2.5:2,className:"recharts-dot",style:{cursor:"pointer"},onClick:function(){var n;return yn(d.key,e.payload,null!==(n=e.index)&&void 0!==n?n:0)}}):l.jsx("g",{})}:n.__assign({r:g},he?{fill:c,stroke:"#fff",strokeWidth:2.5}:{})),m=n.__assign(n.__assign(n.__assign(n.__assign({},Qe(d.yAxis)),{key:d.key,dataKey:d.key,name:d.key,type:p(d.curve),stroke:c,strokeWidth:null!==(u=d.strokeWidth)&&void 0!==u?u:2,strokeDasharray:f,strokeOpacity:v}),he?{strokeLinecap:"round",strokeLinejoin:"round"}:{}),{connectNulls:!1,isAnimationActive:!1,hide:s,dot:h,activeDot:x});return d.area?l.jsx(t.Area,n.__assign({},m,{fill:d.gradient?"url(#".concat(je(d.key),")"):c,fillOpacity:(d.gradient?1:null!==(a=d.areaOpacity)&&void 0!==a?a:.12)*v})):l.jsx(t.Line,n.__assign({},m))}),Pe.flatMap(function(e){var r,o=e.series,u=e.color;if(Y.has(o.key)||!(null===(r=o.markers)||void 0===r?void 0:r.length))return[];var a=new Map(o.data.map(function(e){var n=v(e.y);return[e.x,null==n?null:h(o,n,e.x)]}));return o.markers.map(function(e){var r,d=a.get(e.x);if(null==d)return null;var s=null!==(r=e.color)&&void 0!==r?r:u;return i.createElement(t.ReferenceDot,n.__assign({},Qe(o.yAxis),{key:"marker-".concat(o.key,"-").concat(e.x),x:e.x,y:d,ifOverflow:"extendDomain",shape:function(i){var t,r;return l.jsxs("g",n.__assign({style:{cursor:e.onClick?"pointer":"default"},opacity:nn(o)?ln:1,onClick:e.onClick,role:e.onClick?"button":void 0,"aria-label":e.label},{children:[e.label?l.jsx("title",{children:e.label}):null,l.jsx("circle",{cx:i.cx,cy:i.cy,r:null!==(t=e.haloRadius)&&void 0!==t?t:9,fill:s,fillOpacity:.16}),l.jsx("circle",{cx:i.cx,cy:i.cy,r:null!==(r=e.radius)&&void 0!==r?r:5,fill:o.fillPointsOnHover&&Le===e.x?s:"#fff",stroke:s,strokeWidth:2.5})]}))}}))})}),_n?l.jsx(t.Customized,{component:l.jsx(g,{render:bn})}):null,Xe&&(null==Q?void 0:Q.highlightOnHover)?l.jsx(t.Customized,{component:l.jsx(g,{render:pn})}):null]}))}()}))}))};
|
|
2
2
|
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=[1,2,2.5,5,10],t=[1,2,2.5,4,5,10];function e(t,e){if(void 0===e&&(e=r),!(t>0&&Number.isFinite(t)))return 1;for(var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=[1,2,2.5,5,10],t=[1,2,2.5,4,5,10];function e(t,e){if(void 0===e&&(e=r),!(t>0&&Number.isFinite(t)))return 1;for(var a=Math.pow(10,Math.floor(Math.log10(t))),i=0,n=e;i<n.length;i++){var o=n[i];if(o*a>=t-1e-12)return o*a}return 10*a}var a=function(r,t){var e=Math.max(0,2-Math.floor(Math.log10(t)));return Number(r.toFixed(Math.min(e,10)))};exports.AXIS_STEPS=5,exports.axisDomain=function(r,i){var n=void 0===i?{}:i,o=n.fromZero,u=void 0!==o&&o,f=n.steps,h=void 0===f?5:f,l=n.paddingRatio,s=void 0===l?.25:l,M=r.filter(function(r){return Number.isFinite(r)});if(!M.length)return null;var v=Math.min.apply(Math,M),p=Math.max.apply(Math,M),m=function(r,t){return{lo:r,step:t,hi:r+t*h,ticks:Array.from({length:h+1},function(e,i){return a(r+t*i,t)})}};if(u&&v>=0)return m(0,e(1.08*p/h||1,t));p===v&&(p+=.1*Math.abs(p)||1,v-=.1*Math.abs(v)||1);for(var c=(p-v)*Math.max(0,s),d=e((p-v+2*c)/h),x=0;x<20;x++){var b=Math.floor((v-.5*c)/d)*d;if(v>=0&&b<0&&(b=0),b+d*h>=p+.5*c)return m(b,d);d=e(1.01*d)}return m(v,(p-v)/h)},exports.niceStep=e;
|
|
2
2
|
//# sourceMappingURL=axisDomain.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),i=require("react"),a=require("lucide-react"),t=require("../RcaDecisionComponent/RcaDecisionComponent.js"),r=require("../Graph/LineChart.js"),s=require("../Graph/PlotBySelector.js"),o=require("../../api/insightsApi.js"),l=require("./insightsContextCore.js"),d=require("./insightsUtils.js"),u=require("./DrillTable.js"),c=require("./DriverActivity.js"),g=require("./drillDay.js"),v=require("./FilterNotice.js"),p=require("./agPrimitives.js"),h=require("./KpiChart.js"),_=require("./NeedsAttention.js"),m=require("./insightsFormat.js"),f=10;function y(a){var t,r=this,s=a.entityKey,u=a.dataDay,c=l.useInsights(),g=i.useState(null),v=g[0],p=g[1],h=i.useState(null),_=h[0],m=h[1];if(d.useJob(v,null!==(t=null==c?void 0:c.api)&&void 0!==t?t:null,function(){p(null),null==c||c.refresh()}),!(null==c?void 0:c.viewer.isAdmin))return null;return n.jsxs("span",{children:[n.jsx("button",e.__assign({type:"button",className:"ins-link",disabled:Boolean(v),onClick:function(){return e.__awaiter(r,void 0,void 0,function(){var n,i,a,t;return e.__generator(this,function(e){switch(e.label){case 0:m(null),e.label=1;case 1:return e.trys.push([1,6,,7]),n={dataDay:u||o.toIsoDay(c.range.endDate),window:"both"},s?[4,o.generateLevelSummary(c.api,s,n)]:[3,3];case 2:return a=e.sent(),[3,5];case 3:return[4,o.generateInsightsSummary(c.api,n)];case 4:a=e.sent(),e.label=5;case 5:return(i=a).jobId?p(i.jobId):c.refresh(),[3,7];case 6:return t=e.sent(),m(t.message||"The summary couldn't be regenerated."),[3,7];case 7:return[2]}})})}},{children:v?"Regenerating…":"Regenerate summary"})),_?n.jsx("span",e.__assign({className:"ins-error"},{children:_})):null]})}var x=function(e){return e.replace(/\b\w/g,function(e){return e.toUpperCase()})};function b(e,n){return n?"Decision Advantage is unavailable right now: ".concat(n.message):e?"waiting"===e.status?"The first morning run hasn't finished yet. This fills in after it.":"running"===e.status?"The AI is writing this report. It usually takes a minute or two.":"generated"!==e.status?"No report generated for this day.":null:null}function j(e,n,i){return i?null:b(e,n)}function k(e){return e.replace(/\{\{([^|}]*)\|[^}]*\}\}/g,"$1")}function w(a){var r,s,o=a.report,l=a.movementType,u=a.direction,c=a.good,g=a.loading,v=a.error,h=i.useState(!1),_=h[0],m=h[1],f=i.useMemo(function(){return d.reportDecisioning(o)},[o]);if(i.useEffect(function(){return m(!1)},[null==o?void 0:o.reportId]),g)return n.jsx("div",e.__assign({className:"ag-summary"},{children:n.jsx(p.SkeletonLines,{widths:[28,96,72],label:"Loading summary"})}));var y=null==o?void 0:o.summary,x=null!==(r=null==y?void 0:y.headline)&&void 0!==r?r:"",j=Boolean(x),k=p.splitVerdict(x).prefix,w=Boolean(null==y?void 0:y.eyebrow)&&"Movement unavailable"!==(null==y?void 0:y.eyebrow),N=void 0!==l,D=w?y.eyebrow:N?p.movementVerdictLabel(l,u):k||"Summary",I=w?"good"===y.tone||"bad"===y.tone?p.verdictToneHex(y.tone):p.movementColorHex(y.movementType,y.movementDirection,c):N?p.movementColorHex(l,u,c):"Good news"===k?"#15803D":"Bad news"===k?"#E11D48":"#5928ED";return n.jsxs("div",e.__assign({className:"ag-summary"},{children:[n.jsx("p",e.__assign({className:"ag-summary__title",style:{color:j?I:"#64748b"}},{children:j?D:"No summary yet"})),n.jsxs("div",e.__assign({className:"ag-summary__text"},{children:[j?n.jsx(p.VerdictSentence,{text:x,good:c}):null!==(s=b(o,v))&&void 0!==s?s:"Reports are written after each morning run.",j&&f?n.jsx("span",e.__assign({className:"ag-summary__brain"},{children:n.jsx(t.ReasoningTrigger,{open:_,onToggle:function(){return m(function(e){return!e})},label:"how the AI reached this summary"})})):null]})),_&&f?n.jsx("div",e.__assign({className:"ag-summary__reasoning"},{children:n.jsx(t.ReasoningPanel,{decisioning:f})})):null]}))}function N(e){var a,r,s,o,u,c=e.report,g=e.error,v=e.loading,h=l.useInsights(),_=!v&&"generated"===(null==c?void 0:c.status),m=i.useMemo(function(){return _?d.reportDecisioning(c,null==c?void 0:c.footer):null},[_,c]),f=d.useOpenRow();return n.jsx(t.RcaDecisionComponent,{className:"ag-decision",title:null!==(a=null==h?void 0:h.labels.decisionAdvantageTitle)&&void 0!==a?a:"Decision Advantage",score:_?null==c?void 0:c.score:null,decisioning:m,notice:j(c,g,v),afterSections:v?n.jsx(p.SkeletonLines,{widths:[22,92,84,66,22,88,74],label:"Loading Decision Advantage"}):null,rootCause:_?d.toRcaItems(null==c?void 0:c.rootCause,f,null===(r=null==h?void 0:h.decisionAdvantage)||void 0===r?void 0:r.rootCauseTags):[],rootCauseLayout:null===(s=null==h?void 0:h.decisionAdvantage)||void 0===s?void 0:s.rootCauseLayout,nextSteps:_?d.toRcaItems(null==c?void 0:c.nextSteps,f):[],width:"100%",maxWidth:"none"},"".concat(null!==(o=null==c?void 0:c.reportId)&&void 0!==o?o:"pending",":").concat(null!==(u=null==c?void 0:c.generatedAt)&&void 0!==u?u:""))}var D=[{key:"drivers",label:"driversTab",info:"What moved the day's number the same way."},{key:"headwinds",label:"headwindsTab",info:"What moved against the day's number."},{key:"attention",label:"attentionTab",info:"The number moved, but activity doesn't explain it."}],I={drivers:"Nothing moved the day's way.",headwinds:"Nothing ran against the day.",attention:"No drivers for this day."},C={high:"High correlation",medium:"Medium correlation",low:"Low correlation",none:"No correlation"};function K(i){var t=i.on,r=i.onClick,s=i.disabled,o=void 0!==s&&s;return n.jsxs("button",e.__assign({type:"button",className:"ag-graph-pill".concat(t?" is-on":""),disabled:o,title:o?"A graph can show up to ".concat(f," rows"):void 0,onClick:function(e){e.stopPropagation(),r()}},{children:[n.jsx(a.TrendingUp,{"aria-hidden":"true"}),t?"In graph":o?"Graph full":"Add to graph"]}))}function S(i){var t=i.rank,r=i.category,s=i.name,o=i.chips,l=i.alignActivity,d=void 0!==l&&l,u=i.action,c=i.lines,g=i.cell,v=i.onOpen;return n.jsx("li",{children:n.jsxs("div",e.__assign({className:"ag-driver".concat(d?" ag-driver--aligned":"").concat(v?" is-clickable":""),role:v?"button":void 0,tabIndex:v?0:void 0,onClick:v,onKeyDown:v?function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),v())}:void 0},{children:[n.jsxs("div",e.__assign({className:"ag-driver__main"},{children:[n.jsxs("span",e.__assign({className:"ag-driver__rank"},{children:[t,"."]})),n.jsxs("div",e.__assign({className:"ag-driver__body"},{children:[n.jsxs("div",e.__assign({className:"ag-driver__heading"},{children:[r?n.jsxs("span",e.__assign({className:"ag-driver__category"},{children:[r," >"]})):null,n.jsxs("div",e.__assign({className:"ag-driver__identity"},{children:[n.jsx("span",e.__assign({className:"ag-driver__name"},{children:s})),n.jsxs("div",e.__assign({className:"ag-driver__chips"},{children:[o,u]}))]}))]})),c]}))]})),n.jsxs("div",e.__assign({className:"ag-driver__cell"},{children:[g,v?n.jsx("span",e.__assign({className:"ag-driver__open","aria-hidden":"true"},{children:n.jsx(a.ArrowUpRight,{})})):null]}))]}))})}function A(i){var a,t=i.label,r=i.rightLabel,s=i.children,o=l.useInsights();return n.jsxs("div",e.__assign({className:"ag-drivers"},{children:[n.jsxs("div",e.__assign({className:"ag-drivers__head"},{children:[n.jsx("span",{children:t}),n.jsx("span",{children:null!==(a=null!=r?r:null==o?void 0:o.labels.activityColumn)&&void 0!==a?a:"User Activity"})]})),n.jsx("ol",{children:s})]}))}var T=["#4F46E5","#64748B","#0F766E","#7C3AED","#475569","#818CF8","#94A3B8"],L=function(e,n){void 0===n&&(n="en-GB");var i=e.slice(0,10).split("-").map(Number),a=i[0],t=i[1],r=i[2];return Number.isFinite(a)&&Number.isFinite(t)&&Number.isFinite(r)?new Intl.DateTimeFormat(n,{day:"numeric",month:"short"}).format(new Date(a,t-1,r)):e};function P(t){var s,u,c,g,v,_,f,y,x,b,j,k,w=this,N=t.dataDay,D=t.nodeKey,I=void 0===D?"root":D,K=t.kpiId,S=t.dayGroup,A=l.useInsights(),P=null!==(s=null!=K?K:null==A?void 0:A.headlineKpi)&&void 0!==s?s:void 0,R=i.useState(""),F=R[0],M=R[1],B=i.useState([]),O=B[0],E=B[1],q=i.useState({}),G=q[0],W=q[1],H=i.useState(""),z=H[0],U=H[1],V=i.useState(null),Z=V[0],$=V[1],J=i.useState(null),X=J[0],Q=J[1],Y=i.useState(!1),ee=Y[0],ne=Y[1],ie=i.useState(!1),ae=ie[0],te=ie[1],re=i.useRef(null),se=d.useInsightsFetch(A&&P&&N?function(n){return o.fetchInsightsCorrelation(A.api,I,e.__assign({kpiId:P,dataDay:N,startDate:o.toIsoDay(A.range.startDate),endDate:o.toIsoDay(A.range.endDate),filters:A.range.filters},G),n)}:null,[null==A?void 0:A.api.configId,null==A?void 0:A.rangeKey,N,P,I,G.disregardBefore,null===(u=G.disregardDates)||void 0===u?void 0:u.join(","),null==A?void 0:A.revision]),oe=se.data,le=se.error,de=se.loading,ue=d.useInsightsFetch(A&&P&&N?function(n){return o.fetchInsightsCorrelationTrend(A.api,I,e.__assign({kpiId:P,startDate:o.toIsoDay(A.range.startDate),endDate:o.toIsoDay(A.range.endDate),filters:A.range.filters},G),n)}:null,[null==A?void 0:A.api.configId,null==A?void 0:A.rangeKey,N,P,I,G.disregardBefore,null===(c=G.disregardDates)||void 0===c?void 0:c.join(","),null==A?void 0:A.revision]);d.useJob(X,null!==(g=null==A?void 0:A.api)&&void 0!==g?g:null,function(){Q(null),U(""),null==A||A.refresh()}),i.useEffect(function(){if(ee){var e=function(e){re.current&&!re.current.contains(e.target)&&ne(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[ee]);var ce=i.useState(new Set),ge=ce[0],ve=ce[1],pe=i.useMemo(function(){if(!oe)return[];return oe.series.filter(function(e){return!(null==S?void 0:S.length)||S.map(Number).includes((n=e.x,new Date("".concat(n.slice(0,10),"T00:00:00")).getDay()||7));var n})},[oe,S]),he=i.useMemo(function(){return oe?e.__spreadArray([oe.kpiId],oe.drivers.map(function(e){return e.kpiId}).filter(function(e){return e!==oe.kpiId}),!0):[]},[oe]),_e=i.useMemo(function(){return oe&&A?he.map(function(e,n){var i=pe.map(function(n){var i,a;return n.disregarded?null:null!==(a=null===(i=n.values)||void 0===i?void 0:i[e])&&void 0!==a?a:null}),a=i.find(function(e){return"number"==typeof e&&0!==e});return{key:"corr_".concat(e.replace(/[^a-zA-Z0-9_]/g,"_")),label:A.kpiLabel(e),color:T[n%T.length],curve:"smooth",strokeWidth:2,pointRadius:2,data:pe.map(function(e,n){return{x:e.x,y:null==i[n]||null==a?null:Math.round((i[n]-a)/Math.abs(a)*1e3)/10}}),valueFormatter:function(e){return"".concat(e,"%")}}}):[]},[oe,A,pe,he]),me=Boolean(null===(_=null===(v=null==A?void 0:A.decisionAdvantage)||void 0===v?void 0:v.trendChart)||void 0===_?void 0:_.dualAxis),fe=null===(y=null===(f=null==A?void 0:A.decisionAdvantage)||void 0===f?void 0:f.trendChart)||void 0===y?void 0:y.correlation,ye=Math.max(1,Math.min(8,Number(null==fe?void 0:fe.maxKpis)||5)),xe=i.useState(null),be=xe[0],je=xe[1],ke=i.useState(new Set),we=ke[0],Ne=ke[1],De=i.useMemo(function(){var n,i;if(be)return be.filter(function(e){return he.includes(e)});var a=(null!==(n=null==fe?void 0:fe.defaultKpis)&&void 0!==n?n:[]).filter(function(e){return he.includes(e)});return(a.length?e.__spreadArray([null!==(i=null==oe?void 0:oe.kpiId)&&void 0!==i?i:""],a.filter(function(e){return e!==(null==oe?void 0:oe.kpiId)}),!0):he.slice(0,2)).filter(Boolean).slice(0,ye)},[be,he,null==fe?void 0:fe.defaultKpis,null==oe?void 0:oe.kpiId,ye]);i.useEffect(function(){return ve(new Set(_e.slice(2).map(function(e){return e.key})))},[_e]);if(!A||!N||"no_drivers"===(null==oe?void 0:oe.state)||oe&&!oe.verdictText)return null;if(le)return n.jsxs("div",e.__assign({className:"ag-empty"},{children:["Correlation is unavailable right now: ",le.message]}));if(de&&!oe)return n.jsx(p.ChartSkeleton,{height:220,label:"Loading correlation"});if(!oe)return null;var Ie=null!==(x=oe.strength)&&void 0!==x?x:"none",Ce="day"===A.period.grain?"today":"this ".concat(A.period.unit),Ke=A.kpiLabel(oe.kpiId);return n.jsx(p.CollapsibleVisualSection,e.__assign({title:"Correlation",meta:A.labels.correlationTitle.replace("{kpi}",Ke),className:"ag-visual--card",defaultExpanded:!1,action:A.viewer.isAdmin&&!me?n.jsxs("div",e.__assign({ref:re,className:"ag-corr__settings"},{children:[n.jsx("button",e.__assign({type:"button",className:"ag-icon-button","aria-label":"Correlation settings","aria-expanded":ee,onClick:function(){return ne(function(e){return!e})}},{children:n.jsx(a.Settings2,{"aria-hidden":"true"})})),ee?n.jsx("div",e.__assign({className:"ag-corr__settings-menu",role:"menu"},{children:n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:ae,onChange:function(e){return te(e.target.checked)}}),"Show date controls"]})})):null]})):null},{children:n.jsxs("div",e.__assign({className:"ag-corr"},{children:[n.jsx("p",e.__assign({className:"ag-corr__banner ag-corr__banner--".concat(Ie)},{children:oe.verdictText})),n.jsx("span",e.__assign({className:"ag-driver__badge ag-driver__badge--".concat(Ie)},{children:C[Ie]})),n.jsx("p",e.__assign({className:"ag-corr__caption"},{children:A.labels.correlationSubtitle.replace("{kpi}",Ke)})),(null===(b=oe.window)||void 0===b?void 0:b.source)?n.jsx("p",e.__assign({className:"ag-muted"},{children:"default"===oe.window.source?oe.window.startDate?"Using all ".concat(A.period.unit,"s since ").concat("day"===A.period.grain?L(oe.window.startDate,"en-US"):m.longPeriod(oe.window.startDate,A.period.grain)):"Using all available ".concat(A.period.unit,"s"):"row"===oe.window.source?"Saved window".concat(oe.window.startDate?" since ".concat(L(oe.window.startDate,"en-US")):"").concat((null===(j=oe.window.excludedDates)||void 0===j?void 0:j.length)?" · ".concat(oe.window.excludedDates.length," left out"):""):"Preview window".concat((null===(k=oe.window.excludedDates)||void 0===k?void 0:k.length)?" · ".concat(oe.window.excludedDates.length," left out"):"")})):null,n.jsxs("div",e.__assign({className:"ag-chart"},{children:[n.jsx("div",e.__assign({className:"ellm-graph"},{children:n.jsx(r.default,{tier:"decision-advantage-correlation",series:me?_e.filter(function(e){return De.some(function(n){return e.key==="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_"))})}):_e,hiddenKeys:me?we:ge,onToggleSeries:function(e){return ve(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},onPointClick:function(){},xAxis:{label:"day"===A.period.grain?"Date":m.longPeriod.axisTitle(A.period.grain),categories:pe.map(function(e){return e.x}),formatTick:function(e){return m.shortPeriod(e,A.period.grain)}},yAxis:{label:"% change",beginAtZero:!1,formatTick:function(e){return"".concat(Math.round(Number(e)).toLocaleString("en-US"),"%")}},tooltip:{render:function(i){var a,t=i.x,r=i.points,s=String(t),o=null===(a=ue.data)||void 0===a?void 0:a.series.find(function(e){return e.x===s});return n.jsxs("div",e.__assign({className:"ag-tip ag-tip--wide"},{children:[n.jsx("div",e.__assign({className:"ag-tip__head"},{children:"day"===A.period.grain?L(s):m.longPeriod(s,A.period.grain)})),r.filter(function(e){return null!=e.value}).map(function(i){return n.jsxs("div",e.__assign({className:"ag-tip__line"},{children:[n.jsxs("span",{children:[n.jsx("i",{style:{background:i.color}}),i.series.label]}),n.jsxs("strong",{children:[i.value,"%"]})]}),i.series.key)}),o?Object.keys(o.r).map(function(i){var a,t;return n.jsxs("div",e.__assign({className:"ag-tip__sub"},{children:[n.jsx("span",{children:A.kpiLabel(i)}),n.jsx("span",{children:null==o.r[i]?"No correlation":"r ".concat(o.r[i]," · ").concat(null!==(a=o.strength[i])&&void 0!==a?a:"none"," · ").concat(null!==(t=o.nObs[i])&&void 0!==t?t:0," ").concat(A.period.unit,"s")})]}),i)}):null]}))}},legend:me?{show:!1}:{position:"bottom",toggle:!0},style:{chartHeight:220,yAxisWidth:me?84:60,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}})})),me?n.jsxs("div",e.__assign({className:"kc__foot"},{children:[n.jsx("div",e.__assign({className:"kc__legend"},{children:De.map(function(i){var a="corr_".concat(i.replace(/[^a-zA-Z0-9_]/g,"_")),t=we.has(a);return n.jsxs("label",e.__assign({className:"kc__legend-item".concat(t?" is-off":""),style:{"--kc-color":T[he.indexOf(i)%T.length]}},{children:[n.jsx("input",{type:"checkbox",checked:!t,onChange:function(){return Ne(function(e){var n=new Set(e);return n.has(a)?n.delete(a):n.add(a),n})}}),A.kpiLabel(i)]}),i)})})),n.jsx(h.KpiPicker,{oneAxis:!0,selected:De,onChange:function(e){return je(e.slice(0,ye))},groups:[{label:"Correlated KPIs",kpis:he}],averageKpis:[],max:ye,insights:A,colorOf:function(e){return T[Math.max(0,he.indexOf(e))%T.length]}})]})):null]})),n.jsx("div",e.__assign({className:"ag-corr__metrics"},{children:oe.drivers.map(function(i){var a,t=null!==(a=i.strength)&&void 0!==a?a:"none";return n.jsxs("div",e.__assign({className:"ag-corr__metric"},{children:[n.jsx("span",e.__assign({className:"ag-corr__name"},{children:i.label||A.kpiLabel(i.kpiId)})),i.kpiId!==oe.kpiId?n.jsx("span",e.__assign({className:"ag-driver__badge ag-driver__badge--".concat(t)},{children:C[t]})):null,n.jsx("strong",{children:A.formatKpi(i.kpiId,i.value)}),n.jsx("span",e.__assign({className:"ag-corr__delta"},{children:null!=i.deltaPct?n.jsxs(n.Fragment,{children:[n.jsxs("span",e.__assign({className:"ag-dod__value ag-dod__value--".concat(i.tone||"flat")},{children:["up"===i.direction?"↑":"down"===i.direction?"↓":"→"," ",Math.abs(i.deltaPct),"%"]}))," vs. ",A.formatKpi(i.kpiId,i.previous)]}):"—"})),i.kpiId!==oe.kpiId?n.jsxs("span",e.__assign({className:"ag-corr__r"},{children:[i.nObs," ",A.period.unit,"s used",i.lowHistory?" · Low history":"",n.jsx("br",{}),null==i.movedWithToday?"No comparison for ".concat(Ce):i.movedWithToday?"Moved together with the headline ".concat(Ce):"Moved opposite the headline ".concat(Ce)]})):null]}),i.kpiId)})})),A.viewer.isAdmin&&ae?n.jsxs("div",e.__assign({className:"ag-corr__window"},{children:[n.jsxs("label",e.__assign({className:"ag-corr__start"},{children:["Ignore data before ",n.jsx("input",{type:"date",value:F,onChange:function(e){return M(e.target.value)}})]})),n.jsxs("div",e.__assign({className:"ag-corr__days-label"},{children:["Or leave out individual dates (",O.length," selected)"]})),n.jsx("div",e.__assign({className:"ag-corr__days","aria-label":"Days to leave out"},{children:oe.series.map(function(i){return n.jsx("button",e.__assign({type:"button","aria-pressed":O.includes(i.x),className:O.includes(i.x)?"is-selected":void 0,onClick:function(){return n=i.x,E(function(i){return i.includes(n)?i.filter(function(e){return e!==n}):e.__spreadArray(e.__spreadArray([],i,!0),[n],!1)});var n}},{children:L(i.x)}),i.x)})})),n.jsx("input",{className:"ag-corr__reason",value:z,onChange:function(e){return U(e.target.value)},placeholder:"Reason required to apply"}),Z?n.jsx("p",e.__assign({className:"ins-error"},{children:Z})):null,n.jsxs("div",e.__assign({className:"ag-corr__actions"},{children:[n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:function(){return W({disregardBefore:F||void 0,disregardDates:O})}},{children:"Preview"})),n.jsx("button",e.__assign({type:"button",className:"ins-button",disabled:Boolean(X),onClick:function(){return e.__awaiter(w,void 0,void 0,function(){var n,i;return e.__generator(this,function(e){switch(e.label){case 0:if(!A||!P||!z.trim())return $("A reason is required."),[2];$(null),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o.saveCorrelationWindow(A.api,I,{kpiId:P,startDate:F||null,excludedDates:O,dataDay:N,changeReason:z.trim(),regenerate:!0})];case 2:return n=e.sent(),Q(n.jobId),[3,4];case 3:return i=e.sent(),$(i.message||"The correlation window couldn't be saved."),[3,4];case 4:return[2]}})})}},{children:"Apply"})),n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:function(){M(""),E([]),W({})}},{children:"Clear"}))]}))]})):null]}))}))}var R=function(e){var n;return(null===(n=null==e?void 0:e.period)||void 0===n?void 0:n.end)||null};function F(i){var a=i.kpis,t=i.value,r=i.onChange,o=l.useInsights();return o&&a.length?n.jsx("div",e.__assign({className:"ag-plotby"},{children:n.jsx(s.default,{config:{options:a.map(function(e){return{label:o.kpiLabel(e),value:e}}),label:"Plot By",hideWhenSingle:!1,triggerIcon:null},value:t,onChange:r})})):null}function M(a){var t,s=a.entityKey,u=a.kpis,c=a.nodeKeys,g=a.workingDays,v=a.group,h=a.onOpenPoint,_=a.syncId,y=a.kpi,x=l.useInsights(),b=i.useState(null!==(t=u[0])&&void 0!==t?t:""),j=b[0],k=b[1];i.useEffect(function(){var e;u.includes(j)||k(null!==(e=u[0])&&void 0!==e?e:"")},[u,j]);var w=void 0!==y&&u.includes(y)?y:j,N=d.useInsightsFetch(x&&w&&null!==v&&0!==(null==c?void 0:c.length)?function(n){return o.fetchInsightsSeries(x.api,e.__assign(e.__assign({},x.range),{workingDaysOnly:g,group:v||void 0}),c?{kpiIds:[w],nodeKeys:c.slice(0,f)}:{kpiIds:[w],entityKey:s,topN:3},n)}:null,[null==x?void 0:x.api.configId,null==x?void 0:x.rangeKey,s,w,null==c?void 0:c.join(","),g,v,null==x?void 0:x.revision]),D=N.data,I=N.loading,C=N.error,K=i.useMemo(function(){var e;return 0===(null==c?void 0:c.length)?[]:(null!==(e=null==D?void 0:D.series)&&void 0!==e?e:[]).filter(function(e){return e.kpiId===w&&e.points.some(function(e){return Number.isFinite(e.y)})})},[D,c,w]),S=i.useState(new Set),A=S[0],T=S[1];i.useEffect(function(){return T(new Set)},[K]);var L=i.useMemo(function(){return Array.from(new Set(K.flatMap(function(e){return e.points.map(function(e){return e.x})}))).sort()},[K]),P=i.useMemo(function(){return K.map(function(e,n){var i,a=new Map(e.points.map(function(e){return[e.x,e.y]})),t=null!==(i=null==x?void 0:x.goodDirection(e.kpiId))&&void 0!==i?i:"up";return{key:"row_".concat(n,"_").concat(e.nodeKey.replace(/[^a-zA-Z0-9_]/g,"_")),label:e.label||e.nodeKey,color:["#06B6D4","#10A66A","#8650FF","#F59E0B","#E94BBD","#4285FF","#64748B","#F04444","#14B8A6","#84CC16"][n%10],curve:"smooth",pointRadius:3,activePointRadius:3,fillPointsOnHover:!0,data:L.map(function(e){var n;return{x:e,y:null!==(n=a.get(e))&&void 0!==n?n:null}}),valueFormatter:function(n){return x?x.formatKpi(e.kpiId,n):String(n)},markers:e.points.filter(function(e){var n;return null===(n=e.meta)||void 0===n?void 0:n.marker}).map(function(n){return{x:n.x,color:p.movementColorHex(n.meta.marker.movementType,n.meta.marker.direction,t),label:[n.meta.marker.criticality,n.meta.marker.headline].filter(Boolean).join(" · "),radius:3,haloRadius:3,onClick:function(){var i,a=null!==(i=e.label)&&void 0!==i?i:e.nodeKey;h?h({nodeKey:e.nodeKey,label:a,kpiId:e.kpiId,dataDay:n.x,reportId:n.meta.marker.reportId}):null==x||x.openReport(n.meta.marker.reportId?{reportId:n.meta.marker.reportId,title:"".concat(a," · ").concat(m.shortPeriod(n.x,null==x?void 0:x.period.grain))}:{nodeKey:e.nodeKey,kpiId:e.kpiId,dataDay:n.x,title:"".concat(a," · ").concat(m.shortPeriod(n.x,null==x?void 0:x.period.grain))})}}})}})},[K,L,x,h]);if(!x)return null;var R=x.kpiLabel(w);return n.jsxs("div",e.__assign({className:"ag-row-trend"},{children:[u.length>1&&void 0===y?n.jsx("div",e.__assign({className:"ag-chart__switch",role:"group","aria-label":"Number"},{children:u.map(function(i){return n.jsx("button",e.__assign({type:"button","aria-pressed":i===w,className:i===w?"is-active":void 0,onClick:function(){return k(i)}},{children:x.kpiLabel(i)}),i)})})):null,C?n.jsx("div",e.__assign({className:"ag-empty"},{children:"This chart is unavailable right now."})):I?n.jsx(p.ChartSkeleton,{height:240,label:"Loading trend"}):L.length?n.jsx("div",e.__assign({className:"ag-chart"},{children:n.jsxs("div",e.__assign({className:"ellm-graph"},{children:[n.jsx(r.default,{tier:"decision-advantage-".concat(s),syncId:_,syncMethod:"value",series:P,hiddenKeys:A,onToggleSeries:function(e){return T(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.size<P.length-1&&i.add(e),i})},onPointClick:function(e){var n,i,a,t,r,s,o=e.series,l=e.point,d=e.index,u=P.findIndex(function(e){return e.key===o.key}),c=K[u],g=null!==(n=l.x)&&void 0!==n?n:null===(i=o.data[d])||void 0===i?void 0:i.x,v=null==c?void 0:c.points.find(function(e){return e.x===String(g)});if(c&&v){var p=null!==(a=c.label)&&void 0!==a?a:c.nodeKey,_=null!==(s=null===(r=null===(t=v.meta)||void 0===t?void 0:t.marker)||void 0===r?void 0:r.reportId)&&void 0!==s?s:null;h?h({nodeKey:c.nodeKey,label:p,kpiId:c.kpiId,dataDay:v.x,reportId:_}):x.openReport(_?{reportId:_,title:"".concat(p," · ").concat(m.shortPeriod(v.x,x.period.grain))}:{nodeKey:c.nodeKey,kpiId:c.kpiId,dataDay:v.x,title:"".concat(p," · ").concat(m.shortPeriod(v.x,x.period.grain))})}},xAxis:{label:"day"===x.period.grain?"Date":m.longPeriod.axisTitle(x.period.grain),categories:L,tickCount:8,minTickGap:24,formatTick:function(e){return m.shortPeriod(e,x.period.grain)}},yAxis:{label:R,beginAtZero:!0,fitWidth:!0,formatTick:function(e){var n;return x.formatKpiAxis(null===(n=K[0])||void 0===n?void 0:n.kpiId,Number(e))}},tooltip:{formatHeading:function(e){return m.longPeriod(e,x.period.grain)}},legend:{show:!1},style:{chartHeight:240,yAxisWidth:70,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}}),n.jsx("div",e.__assign({className:"ellm-graph__legend ellm-chart__legend--bottom ellm-chart__legend--center"},{children:P.map(function(i){var a=A.has(i.key);return n.jsxs("label",e.__assign({title:i.label,className:"ellm-graph__legend-item ag-legend-item".concat(a?" ellm-graph__legend-item--off":""),style:{cursor:"pointer","--checkbox-color":i.color,color:i.color}},{children:[n.jsx("input",{type:"checkbox",className:"ellm-graph__legend-checkbox",checked:!a,onChange:function(){return T(function(e){var n=new Set(e);return n.has(i.key)?n.delete(i.key):n.size<P.length-1&&n.add(i.key),n})},style:{borderColor:i.color,accentColor:i.color}}),n.jsx("span",{children:i.label})]}),i.key)})}))]}))})):n.jsx("div",e.__assign({className:"ag-empty"},{children:"Not enough history yet for a trend chart."}))]}))}function B(a){var t,r=this,s=a.tab,d=a.partName,u=a.kpiIds,c=a.rankBy,g=a.search,h=a.graphed,_=a.onToggleGraph,m=a.onOpenRow,y=a.onFirstRow,b=a.onInitialGraph,j=a.fallbackDay,k=l.useInsights(),w=Math.min(200,Math.max(1,Number(s.pageSize)||5)),N=i.useState([]),D=N[0],I=N[1],C=i.useState(null),T=C[0],L=C[1],P=i.useState(!1),R=P[0],F=P[1],M=i.useState({loading:!0,error:null}),B=M[0],O=M[1],E=i.useState(),q=E[0],G=E[1],W=function(n,i){return e.__awaiter(r,void 0,void 0,function(){var a,t;return e.__generator(this,function(r){switch(r.label){case 0:if(!k)return[2];O({loading:!0,error:null}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,o.fetchLevelRows(k.api,s.entityKey,k.range,{sort:c,order:"desc",search:g||void 0,pageSize:w,cursor:null!=n?n:void 0,includeChildren:3},i)];case 2:return a=r.sent(),(null==i?void 0:i.aborted)?[2]:(G(a.context),I(function(i){return n?e.__spreadArray(e.__spreadArray([],i,!0),a.rows,!0):a.rows}),L(a.nextCursor),F(a.hasNext),O({loading:!1,error:null}),[3,4]);case 3:return t=r.sent(),(null==i?void 0:i.aborted)||"AbortError"===(null==t?void 0:t.name)?[2]:(O({loading:!1,error:t.message||"Couldn't load the rows."}),[3,4]);case 4:return[2]}})})},H=null===(t=D[0])||void 0===t?void 0:t.nodeKey;i.useEffect(function(){return null==y?void 0:y(H)},[H]);var z=D.slice(0,3).map(function(e){return e.nodeKey}),U=z.join("\0");if(i.useEffect(function(){B.loading||null==b||b(z)},[B.loading,U]),i.useEffect(function(){var e=new AbortController;return W(null,e.signal),function(){return e.abort()}},[null==k?void 0:k.api.configId,null==k?void 0:k.rangeKey,s.entityKey,c,g,w,null==k?void 0:k.revision]),!k)return null;var V,Z=k.goodDirection(c),$=u.filter(function(e){return e!==c}).slice(0,2),J=(V=d.trim().toLowerCase())?/(s|x|ch|sh)$/.test(V)?"".concat(V,"es"):/[^aeiou]y$/.test(V)?"".concat(V.slice(0,-1),"ies"):"".concat(V,"s"):"rows";return n.jsx(p.ReportAccordion,e.__assign({title:"Top Drivers for ".concat(x(J))},{children:B.error?n.jsx("p",e.__assign({className:"ag-muted"},{children:"Top drivers are unavailable right now."})):B.loading&&!D.length?n.jsx(p.SkeletonLines,{widths:[80,60,85,55,75],label:"Loading drivers"}):D.length?n.jsxs(n.Fragment,{children:[n.jsx(v.default,{context:q}),n.jsx(A,e.__assign({label:x(d),rightLabel:"User Activity · selected dates"},{children:D.map(function(i){var a,t,r,s,l=null===(a=i.metrics)||void 0===a?void 0:a[c],d=i.label||i.nodeKey,u=h.includes(i.nodeKey);return n.jsx(S,{rank:i.rank,name:d,chips:n.jsxs(n.Fragment,{children:[n.jsx(p.CriticalityChip,{criticality:null===(t=i.chip)||void 0===t?void 0:t.criticality}),n.jsx(p.MovementChip,{movementType:null===(r=i.chip)||void 0===r?void 0:r.movementType,direction:null===(s=i.chip)||void 0===s?void 0:s.direction,good:Z})]}),action:n.jsx(K,{on:u,disabled:!u&&h.length>=f,onClick:function(){return _(i.nodeKey)}}),lines:n.jsxs("span",e.__assign({className:"ag-driver__cost"},{children:[n.jsxs("span",e.__assign({className:"ag-driver__total"},{children:[k.formatKpi(c,null==l?void 0:l.value)," ",k.kpiLabel(c).toLowerCase()]})),null!=(null==l?void 0:l.deltaPct)?n.jsx("span",e.__assign({className:"ag-driver__sep"},{children:"|"})):null,n.jsx(p.DayOverDayChange,{deltaPct:null==l?void 0:l.deltaPct,good:Z,direction:null==l?void 0:l.direction,tone:null==l?void 0:l.tone,suffix:"vs previous period"})]})),cell:$.map(function(a){var t,r,s=null===(t=i.metrics)||void 0===t?void 0:t[a],o=null!==(r=null==s?void 0:s.tone)&&void 0!==r?r:p.toneOf(null==s?void 0:s.deltaPct,k.goodDirection(a)),l="up"===(null==s?void 0:s.direction)?"↑":"down"===(null==s?void 0:s.direction)?"↓":"flat"===(null==s?void 0:s.direction)?"→":null!=(null==s?void 0:s.deltaPct)&&s.deltaPct>0?"↑":null!=(null==s?void 0:s.deltaPct)&&s.deltaPct<0?"↓":"→";return n.jsxs("span",e.__assign({className:"ag-driver__activity"},{children:[n.jsx("strong",e.__assign({className:"good"===o?"ag-text--good":"bad"===o?"ag-text--bad":void 0},{children:null==(null==s?void 0:s.deltaPct)?k.formatKpi(a,null==s?void 0:s.value):"".concat(l).concat(Math.abs(s.deltaPct),"%")})),n.jsx("span",{children:k.kpiLabel(a)})]}),a)}),onOpen:function(){var e;return m(i,c,j||(null===(e=i.chip)||void 0===e?void 0:e.dataDay)||o.toIsoDay(k.range.endDate))}},i.nodeKey)})})),R?n.jsx("div",e.__assign({className:"ag-more"},{children:n.jsx("button",e.__assign({type:"button",disabled:B.loading,onClick:function(){return W(T)}},{children:B.loading?"Loading...":"Show more"}))})):null]}):n.jsx("p",e.__assign({className:"ag-muted"},{children:g?"No ".concat(J," match “").concat(g,"”."):"No ".concat(J," for this period yet.")}))}))}exports.AddToGraph=K,exports.CorrelationSection=P,exports.DecisionCard=N,exports.DriverList=A,exports.DriverRow=S,exports.L2Report=function(t){var r,s,c,h,_,m,x,b,j,k,D,I,C,K,S,A,T,L,O=t.tab,E=t.title,q=t.partName,G=t.partKpis,W=t.search,H=t.dataDay,z=t.onOpenRow,U=t.headerAction,V=l.useInsights(),Z="decision-advantage-l2-".concat(i.useId()),$=i.useState(null),J=$[0],X=$[1],Q=i.useState(null),Y=Q[0],ee=Q[1],ne=i.useState(Boolean(null==V?void 0:V.defaultWorkingDays)),ie=ne[0],ae=ne[1],te=d.useInsightsFetch(V?function(e){return o.fetchGraphGroups(V.api,e)}:null,[null==V?void 0:V.api.configId,null==V?void 0:V.revision]),re=i.useState(null),se=re[0],oe=re[1];i.useEffect(function(){var e,n;null===se&&((null===(e=te.data)||void 0===e?void 0:e.groups.length)?oe((null!==(n=te.data.groups.find(function(e){return e.isDefault}))&&void 0!==n?n:te.data.groups[0]).groupKey):te.loading||oe(""))},[se,te.data,te.loading]);var le=i.useState(null),de=le[0],ue=le[1],ce=i.useState(),ge=ce[0],ve=ce[1],pe=!1!==O.showSummary,he=null===(s=null===(r=te.data)||void 0===r?void 0:r.groups.find(function(e){return e.groupKey===se}))||void 0===s?void 0:s.days.map(Number),_e=(null==he?void 0:he.length)?he.every(function(e){return e>=1&&e<=5}):ie||Boolean(null==V?void 0:V.range.workingDaysOnly),me=V?g.resolveL2SummaryRange(V.range,_e,H):null,fe="".concat(null==V?void 0:V.api.configId,":").concat(null==V?void 0:V.rangeKey,":").concat(O.entityKey,":").concat(se,":").concat(null==me?void 0:me.startDate.getTime(),":").concat(null==me?void 0:me.endDate.getTime(),":").concat(null==me?void 0:me.workingDaysOnly),ye=d.useInsightsFetch(V&&me&&pe&&null!==se?function(e){return o.fetchLevelSummary(V.api,O.entityKey,me,e)}:null,[fe,pe,null==V?void 0:V.revision],fe);if(!V)return null;var xe=(null===(c=O.listKpis)||void 0===c?void 0:c.length)?O.listKpis:G,be=O.rankBy&&xe.includes(O.rankBy)?O.rankBy:null!==(h=xe[0])&&void 0!==h?h:"",je=null===(_=ye.data)||void 0===_?void 0:_.report,ke=R(null===(m=ye.data)||void 0===m?void 0:m.context),we=g.resolveDrillDay({endDate:V.range.endDate,workingDays:_e,selectedDay:H,reportDay:ke}),Ne=function(n){return H||_e?e.__assign(e.__assign({},n),{report:e.__assign(e.__assign({},n.report),{reportId:null})}):n},De=V.goodDirection(be),Ie=null!==(x=O.tier1Kpis)&&void 0!==x?x:V.tierKpis[1],Ce=null!==(b=O.tier2Kpis)&&void 0!==b?b:V.tierKpis[2],Ke=J&&Ie.includes(J)?J:null!==(j=Ie[0])&&void 0!==j?j:"",Se=Y&&Ce.includes(Y)?Y:null!==(k=Ce[0])&&void 0!==k?k:"",Ae=V.headlineKpi||be||Ie[0]||"",Te=function(e){var n=e.nodeKey,i=e.label,a=e.dataDay;return z({rank:0,nodeKey:n,label:i,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:Ae},action:null,children:[]},Ae,a)},Le=V.drill.tabTables[O.entityKey],Pe=Le?n.jsx(u.default,{table:e.__assign(e.__assign({},Le),{pageSize:null!==(I=null!==(D=Le.pageSize)&&void 0!==D?D:O.pageSize)&&void 0!==I?I:void 0}),tabEntityKey:O.entityKey,context:{trail:[],day:we},onRowClick:function(e,n){var i;return"report"===n?V.openReport({reportId:Ne(e).report.reportId,nodeKey:e.nodeKey,kpiId:be,dataDay:we,title:null!==(i=e.label)&&void 0!==i?i:e.nodeKey}):"drill"===n?z(Ne(e),be,we):void 0}}):null;return n.jsxs("section",e.__assign({className:"ag-report","aria-label":"L2 Report · ".concat(E)},{children:[n.jsxs("div",e.__assign({className:"ag-report__header"},{children:[n.jsxs("h2",e.__assign({className:"ag-report__title"},{children:[n.jsx(a.Sparkles,{"aria-hidden":"true"}),"L2 Report"]})),n.jsx("span",e.__assign({className:"ag-report__scope"},{children:E})),ke?n.jsx("span",e.__assign({className:"ag-report__date"},{children:p.formatHeaderDate(ke)})):null,U?n.jsx("div",e.__assign({className:"ag-report__header-action"},{children:U})):null]})),n.jsxs("div",e.__assign({className:"ag-report__grid ag-report__grid--l2"},{children:[n.jsx("div",e.__assign({className:"ag-report__analysis-scroll",role:"region","aria-label":"".concat(E," analysis"),tabIndex:0},{children:n.jsxs("div",e.__assign({className:"ag-stack"},{children:[pe?n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx(p.SectionHeader,{title:"Summary",action:n.jsx(y,{entityKey:O.entityKey,dataDay:ke})}),n.jsx(w,{report:je,loading:ye.loading,error:ye.error,good:De})]}),n.jsx(N,{report:je,error:ye.error,loading:ye.loading}),n.jsx(v.default,{context:null===(C=ye.data)||void 0===C?void 0:C.context})]}):null,xe.length?n.jsx(B,{tab:O,partName:q,kpiIds:xe,rankBy:be,search:W,graphed:null!=de?de:[],onToggleGraph:function(n){return ue(function(i){var a=null!=i?i:[];return a.includes(n)?a.filter(function(e){return e!==n}):a.length<f?e.__spreadArray(e.__spreadArray([],a,!0),[n],!1):a})},onOpenRow:function(e,n,i){return z(Ne(e),n,i)},onFirstRow:ve,onInitialGraph:function(e){return ue(function(n){return null!=n?n:e})},fallbackDay:we}):null]}))})),n.jsxs("div",e.__assign({className:"ag-stack"},{children:[Ie.length?n.jsx(p.CollapsibleVisualSection,e.__assign({title:"Trend",action:n.jsxs("div",e.__assign({className:"ag-visual__actions"},{children:[n.jsx(F,{kpis:Ie,value:Ke,onChange:X}),n.jsx(p.DaysDropdown,{value:ie,onChange:ae,groups:te.error||null===(K=te.data)||void 0===K?void 0:K.groups,group:se,onGroupChange:oe})]}))},{children:n.jsx(M,{entityKey:O.entityKey,kpis:Ie,kpi:Ke,nodeKeys:de,workingDays:ie,group:se,onOpenPoint:Te,syncId:Z})})):null,Ce.length?n.jsx(p.CollapsibleVisualSection,e.__assign({title:V.labels.activityTitle,action:n.jsx("div",e.__assign({className:"ag-visual__actions"},{children:n.jsx(F,{kpis:Ce,value:Se,onChange:ee})}))},{children:n.jsx(M,{entityKey:O.entityKey,kpis:Ce,kpi:Se,nodeKeys:de,workingDays:ie,group:se,onOpenPoint:Te,syncId:Z})})):null,n.jsx(P,{dataDay:ke,nodeKey:null!==(S=null==de?void 0:de[0])&&void 0!==S?S:ge,dayGroup:null===(T=null===(A=te.data)||void 0===A?void 0:A.groups.find(function(e){return e.groupKey===se}))||void 0===T?void 0:T.days}),"column"===(null==Le?void 0:Le.width)?Pe:null]}))]})),Le&&"full"===(null!==(L=Le.width)&&void 0!==L?L:"full")?Pe:null]}))},exports.MAX_SERIES=f,exports.PlotByKpi=F,exports.RegenerateSummary=y,exports.RowDrivers=B,exports.RowTrend=M,exports.SummaryCard=w,exports.TopDriversSection=function(t){var r,s,u,g,v,h,m,y,x,b,j,w,N,C=t.dataDay,T=t.entityKey,L=t.parentNodeKey,P=t.kpiId,R=t.title,F=t.graphed,M=t.onToggleGraph,B=t.onOpenDriver,O=t.onDecisionSettled,E=t.initialTab,q=void 0===E?"drivers":E,G=l.useInsights(),W=i.useState(q),H=W[0],z=W[1],U=i.useState({drivers:1,headwinds:1,attention:1}),V=U[0],Z=U[1],$=null!==(r=null!=P?P:null==G?void 0:G.headlineKpi)&&void 0!==r?r:void 0,J=T||L||null===(g=null===(u=null===(s=null==G?void 0:G.decisionAdvantage)||void 0===s?void 0:s.topDrivers)||void 0===u?void 0:u.parts)||void 0===g?void 0:g.filter(Boolean),X=null!==(v=null==J?void 0:J.join(","))&&void 0!==v?v:"",Q=function(e){return G&&$&&e===H?function(n){return o.fetchInsightsDrivers(G.api,{dataDay:C,kpiId:$,entityKey:T,parentNodeKey:L,tab:e,limit:Math.min(10,(L?10:3)*V[e]),offset:0,filters:G.range.filters,parts:(null==J?void 0:J.length)?J:void 0},n)}:null},Y=function(e){return[null==G?void 0:G.api.configId,null==G?void 0:G.rangeKey,C,$,T,L,e,H,V[e],null==G?void 0:G.revision,X]},ee={drivers:d.useInsightsFetch(Q("drivers"),Y("drivers")),headwinds:d.useInsightsFetch(Q("headwinds"),Y("headwinds")),attention:d.useInsightsFetch(Q("attention"),Y("attention"))},ne=ee[H],ie=ne.data,ae=ne.error,te=ne.loading,re=null!==(x=null!==(m=null===(h=ee.drivers.data)||void 0===h?void 0:h.tabs)&&void 0!==m?m:null===(y=ee.headwinds.data)||void 0===y?void 0:y.tabs)&&void 0!==x?x:null===(b=ee.attention.data)||void 0===b?void 0:b.tabs,se=_.useNeedsAttention(C,L,$),oe=null!==(w=null===(j=se.data)||void 0===j?void 0:j.counts.pending)&&void 0!==w?w:0;if(i.useEffect(function(){return Z({drivers:1,headwinds:1,attention:1})},[C]),i.useEffect(function(){return z(q)},[q]),!G)return null;var le=G.goodDirection(null!=$?$:""),de=null!==(N=null==ie?void 0:ie.rows)&&void 0!==N?N:[];return n.jsxs(p.ReportAccordion,e.__assign({title:R},{children:[n.jsx("div",e.__assign({className:"ag-driver-tabs",role:"tablist","aria-label":"Driver views"},{children:D.map(function(i){return n.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":H===i.key,className:H===i.key?"is-active":void 0,onClick:function(){return z(i.key)},title:i.info},{children:n.jsxs(n.Fragment,{children:[G.labels[i.label],(null==re?void 0:re[i.key])?" (".concat(re[i.key].total,")"):"","attention"===i.key&&oe?n.jsxs("span",e.__assign({className:"ag-na__tab-badge",title:"".concat(oe," data points need a decision")},{children:[oe,n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:" data points need a decision"}))]})):null,n.jsx(a.Info,{"aria-hidden":"true"})]})}),i.key)})})),"attention"===H?n.jsx(_.default,{dataDay:C,nodeKey:L,kpiId:$,attention:se,onDecisionSettled:O}):null,"attention"===H&&de.length?n.jsx("h4",e.__assign({className:"ag-na__subhead"},{children:"Rows that moved without a clear cause"})):null,ae?n.jsxs("p",e.__assign({className:"ag-muted"},{children:["Top drivers are unavailable right now: ",ae.message]})):te&&!ie?n.jsx("p",e.__assign({className:"ag-muted"},{children:"Loading drivers..."})):de.length?n.jsxs(n.Fragment,{children:[n.jsx(A,e.__assign({label:"Driver",rightLabel:G.labels.activityColumn},{children:de.map(function(i){var a,t,r,s,o=i.deltaContributionPct,l=F.includes(i.nodeKey),u=(null===(a=i.decisionAdvantage)||void 0===a?void 0:a.correlationSentence)||(null===(t=i.decisionAdvantage)||void 0===t?void 0:t.firstCause)||(null===(r=i.decisionAdvantage)||void 0===r?void 0:r.headline);return n.jsx(S,{alignActivity:!0,rank:i.rank,category:G.labels.driverCategory.replace("{plural}",i.entityKey?G.entityPluralName(i.entityKey):"").replace("{name}",i.entityKey?G.entityName(i.entityKey):""),name:i.label,chips:n.jsxs(n.Fragment,{children:[n.jsx(p.CriticalityChip,{criticality:i.criticality}),n.jsx(p.MovementChip,{movementType:i.movementType,direction:i.changeDirection,good:le})]}),action:M?n.jsx(K,{on:l,disabled:!l&&F.length>=f,onClick:function(){return M(i)}}):void 0,lines:n.jsxs(n.Fragment,{children:[null!=o?n.jsxs("span",e.__assign({className:"ag-driver__share"},{children:[G.labels.shareLine.replace("{share}",String(Math.abs(o))).replace("{period}",d.periodName(C,G.period.grain))," · ","opposite"===i.direction?G.labels.movedOpposite:G.labels.movedWith]})):null,n.jsxs("span",e.__assign({className:"ag-driver__cost"},{children:[n.jsx("span",e.__assign({className:"ag-driver__total"},{children:G.formatKpi($,i.value)})),null!=i.deltaPct?n.jsx("span",e.__assign({className:"ag-driver__sep"},{children:"|"})):null,n.jsx(p.DayOverDayChange,{deltaPct:i.deltaPct,good:le,direction:i.changeDirection,tone:i.tone,suffix:d.previousPeriodLabel(C,G.period.grain)})]})),u?n.jsx("p",e.__assign({className:"ag-driver__brief"},{children:n.jsx(p.VerdictSentence,{text:k(u),good:le,arrowsFollowVerdict:!0})})):null,(null===(s=i.decisionAdvantage)||void 0===s?void 0:s.nextStep)?n.jsxs("p",e.__assign({className:"ag-driver__brief"},{children:[n.jsx("strong",{children:"Next:"})," ",k(i.decisionAdvantage.nextStep)]})):null]}),cell:n.jsx(c.default,{driver:i,kpiId:null!=$?$:"",kpiLabel:G.kpiLabel,formatKpi:G.formatKpi}),onOpen:function(){var e;return B?B(i):G.openReport({reportId:null===(e=i.report)||void 0===e?void 0:e.reportId,nodeKey:i.nodeKey,kpiId:$,dataDay:C,title:i.label})}},i.nodeKey)})})),(null==ie?void 0:ie.hasMore)?n.jsx("div",e.__assign({className:"ag-more"},{children:n.jsx("button",e.__assign({type:"button",disabled:te,onClick:function(){return Z(function(n){var i;return e.__assign(e.__assign({},n),((i={})[H]=n[H]+1,i))})}},{children:te?"Loading...":"Show more"}))})):null]}):n.jsx("p",e.__assign({className:"ag-muted"},{children:I[H]}))]}))},exports.decisionCardNotice=j,exports.reportDayOf=R,exports.stripRowTags=k,exports.titleCase=x;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),i=require("react"),a=require("lucide-react"),t=require("../RcaDecisionComponent/RcaDecisionComponent.js"),r=require("../Graph/LineChart.js"),o=require("../Graph/PlotBySelector.js"),l=require("../../api/insightsApi.js"),s=require("./insightsContextCore.js"),d=require("./insightsErrors.js"),u=require("./insightsUtils.js"),c=require("./insightsFormat.js"),g=require("./DrillTable.js"),v=require("./DriverActivity.js"),p=require("./drillDay.js"),h=require("./FilterNotice.js"),_=require("./agPrimitives.js"),m=require("./KpiChart.js"),f=require("./NeedsAttention.js"),y=10;function x(a){var t,r=this,o=a.entityKey,g=a.dataDay,v=s.useInsights(),p=i.useState(null),h=p[0],_=p[1],m=i.useState(null),f=m[0],y=m[1];if(u.useJob(h,null!==(t=null==v?void 0:v.api)&&void 0!==t?t:null,function(){_(null),null==v||v.refresh()}),!(null==v?void 0:v.viewer.isAdmin))return null;return n.jsxs("span",{children:[n.jsx("button",e.__assign({type:"button",className:"ins-link",disabled:Boolean(h),onClick:function(){return e.__awaiter(r,void 0,void 0,function(){var n,i,a,t;return e.__generator(this,function(e){switch(e.label){case 0:y(null),e.label=1;case 1:return e.trys.push([1,6,,7]),n={dataDay:g||c.periodStart(l.toIsoDay(v.range.endDate),v.period.grain),window:"both"},o?[4,l.generateLevelSummary(v.api,o,n)]:[3,3];case 2:return a=e.sent(),[3,5];case 3:return[4,l.generateInsightsSummary(v.api,n)];case 4:a=e.sent(),e.label=5;case 5:return(i=a).jobId?_(i.jobId):v.refresh(),[3,7];case 6:return t=e.sent(),y(d.insightsErrorText(t,"The summary couldn't be regenerated.")),[3,7];case 7:return[2]}})})}},{children:h?"Regenerating…":"Regenerate summary"})),f?n.jsx("span",e.__assign({className:"ins-error"},{children:f})):null]})}var b=function(e){return e.replace(/\b\w/g,function(e){return e.toUpperCase()})};function j(e,n){return n?"Decision Advantage is unavailable right now: ".concat(n.message):e?"waiting"===e.status?"The first morning run hasn't finished yet. This fills in after it.":"running"===e.status?"The AI is writing this report. It usually takes a minute or two.":"generated"!==e.status?"No report generated for this day.":null:null}function k(e,n,i){return i?null:j(e,n)}function w(e){return e.replace(/\{\{([^|}]*)\|[^}]*\}\}/g,"$1")}function N(a){var r,o,l=a.report,s=a.movementType,d=a.direction,c=a.good,g=a.loading,v=a.error,p=a.emptyText,h=i.useState(!1),m=h[0],f=h[1],y=i.useMemo(function(){return u.reportDecisioning(l)},[l]);if(i.useEffect(function(){return f(!1)},[null==l?void 0:l.reportId]),g)return n.jsx("div",e.__assign({className:"ag-summary"},{children:n.jsx(_.SkeletonLines,{widths:[28,96,72],label:"Loading summary"})}));var x=null==l?void 0:l.summary,b=null!==(r=null==x?void 0:x.headline)&&void 0!==r?r:"",k=Boolean(b),w=_.splitVerdict(b).prefix,N=Boolean(null==x?void 0:x.eyebrow)&&"Movement unavailable"!==(null==x?void 0:x.eyebrow),D=void 0!==s,I=N?x.eyebrow:D?_.movementVerdictLabel(s,d):w||"Summary",C=N?"good"===x.tone||"bad"===x.tone?_.verdictToneHex(x.tone):_.movementColorHex(x.movementType,x.movementDirection,c):D?_.movementColorHex(s,d,c):"Good news"===w?"#15803D":"Bad news"===w?"#E11D48":"#5928ED";return n.jsxs("div",e.__assign({className:"ag-summary"},{children:[n.jsx("p",e.__assign({className:"ag-summary__title",style:{color:k?C:"#64748b"}},{children:k?I:"No summary yet"})),n.jsxs("div",e.__assign({className:"ag-summary__text"},{children:[k?n.jsx(_.VerdictSentence,{text:b,good:c}):null!==(o=null!=p?p:j(l,v))&&void 0!==o?o:"Reports are written after each morning run.",k&&y?n.jsx("span",e.__assign({className:"ag-summary__brain"},{children:n.jsx(t.ReasoningTrigger,{open:m,onToggle:function(){return f(function(e){return!e})},label:"how the AI reached this summary"})})):null]})),m&&y?n.jsx("div",e.__assign({className:"ag-summary__reasoning"},{children:n.jsx(t.ReasoningPanel,{decisioning:y})})):null]}))}function D(e){var a,r,o,l,d,c=e.report,g=e.error,v=e.loading,p=e.emptyText,h=s.useInsights(),m=!v&&"generated"===(null==c?void 0:c.status),f=i.useMemo(function(){return m?u.reportDecisioning(c,null==c?void 0:c.footer):null},[m,c]),y=u.useOpenRow();return n.jsx(t.RcaDecisionComponent,{className:"ag-decision",title:null!==(a=null==h?void 0:h.labels.decisionAdvantageTitle)&&void 0!==a?a:"Decision Advantage",score:m?null==c?void 0:c.score:null,decisioning:f,notice:v||c||!p?k(c,g,v):p,afterSections:v?n.jsx(_.SkeletonLines,{widths:[22,92,84,66,22,88,74],label:"Loading Decision Advantage"}):null,rootCause:m?u.toRcaItems(null==c?void 0:c.rootCause,y,null===(r=null==h?void 0:h.decisionAdvantage)||void 0===r?void 0:r.rootCauseTags):[],rootCauseLayout:null===(o=null==h?void 0:h.decisionAdvantage)||void 0===o?void 0:o.rootCauseLayout,nextSteps:m?u.toRcaItems(null==c?void 0:c.nextSteps,y):[],width:"100%",maxWidth:"none"},"".concat(null!==(l=null==c?void 0:c.reportId)&&void 0!==l?l:"pending",":").concat(null!==(d=null==c?void 0:c.generatedAt)&&void 0!==d?d:""))}var I=[{key:"drivers",label:"driversTab",info:"What moved the day's number the same way."},{key:"headwinds",label:"headwindsTab",info:"What moved against the day's number."},{key:"attention",label:"attentionTab",info:"The number moved, but activity doesn't explain it."}],C={drivers:"Nothing moved the day's way.",headwinds:"Nothing ran against the day.",attention:"No drivers for this day."},S={high:"High correlation",medium:"Medium correlation",low:"Low correlation",none:"No correlation"};function K(i){var t=i.on,r=i.onClick,o=i.disabled,l=void 0!==o&&o;return n.jsxs("button",e.__assign({type:"button",className:"ag-graph-pill".concat(t?" is-on":""),disabled:l,title:l?"A graph can show up to ".concat(y," rows"):void 0,onClick:function(e){e.stopPropagation(),r()}},{children:[n.jsx(a.TrendingUp,{"aria-hidden":"true"}),t?"In graph":l?"Graph full":"Add to graph"]}))}function A(i){var t=i.rank,r=i.category,o=i.name,l=i.chips,s=i.alignActivity,d=void 0!==s&&s,u=i.action,c=i.lines,g=i.cell,v=i.onOpen;return n.jsx("li",{children:n.jsxs("div",e.__assign({className:"ag-driver".concat(d?" ag-driver--aligned":"").concat(v?" is-clickable":""),role:v?"button":void 0,tabIndex:v?0:void 0,onClick:v,onKeyDown:v?function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),v())}:void 0},{children:[n.jsxs("div",e.__assign({className:"ag-driver__main"},{children:[n.jsxs("span",e.__assign({className:"ag-driver__rank"},{children:[t,"."]})),n.jsxs("div",e.__assign({className:"ag-driver__body"},{children:[n.jsxs("div",e.__assign({className:"ag-driver__heading"},{children:[r?n.jsxs("span",e.__assign({className:"ag-driver__category"},{children:[r," >"]})):null,n.jsxs("div",e.__assign({className:"ag-driver__identity"},{children:[n.jsx("span",e.__assign({className:"ag-driver__name"},{children:o})),n.jsxs("div",e.__assign({className:"ag-driver__chips"},{children:[l,u]}))]}))]})),c]}))]})),n.jsxs("div",e.__assign({className:"ag-driver__cell"},{children:[g,v?n.jsx("span",e.__assign({className:"ag-driver__open","aria-hidden":"true"},{children:n.jsx(a.ArrowUpRight,{})})):null]}))]}))})}function T(i){var a,t=i.label,r=i.rightLabel,o=i.children,l=s.useInsights();return n.jsxs("div",e.__assign({className:"ag-drivers"},{children:[n.jsxs("div",e.__assign({className:"ag-drivers__head"},{children:[n.jsx("span",{children:t}),n.jsx("span",{children:null!==(a=null!=r?r:null==l?void 0:l.labels.activityColumn)&&void 0!==a?a:"User Activity"})]})),n.jsx("ol",{children:o})]}))}var L=["#4F46E5","#64748B","#0F766E","#7C3AED","#475569","#818CF8","#94A3B8"],P=function(e,n){void 0===n&&(n="en-GB");var i=e.slice(0,10).split("-").map(Number),a=i[0],t=i[1],r=i[2];return Number.isFinite(a)&&Number.isFinite(t)&&Number.isFinite(r)?new Intl.DateTimeFormat(n,{day:"numeric",month:"short"}).format(new Date(a,t-1,r)):e};function R(t){var o,g,v,p,h,f,y,x,b,j,k,w,N,D,I,C=this,K=t.dataDay,A=t.nodeKey,T=void 0===A?"root":A,R=t.kpiId,F=t.dayGroup,M=s.useInsights(),B=null!==(o=null!=R?R:null==M?void 0:M.headlineKpi)&&void 0!==o?o:void 0,O=i.useMemo(function(){var e,n;return m.chartColors(null===(e=null==M?void 0:M.decisionAdvantage)||void 0===e?void 0:e.trendChart,Object.keys(null!==(n=null==M?void 0:M.kpis)&&void 0!==n?n:{}))},[null===(g=null==M?void 0:M.decisionAdvantage)||void 0===g?void 0:g.trendChart,null==M?void 0:M.kpis]),E=O.configured||Boolean(null===(p=null===(v=null==M?void 0:M.decisionAdvantage)||void 0===v?void 0:v.trendChart)||void 0===p?void 0:p.dualAxis),q=i.useCallback(function(e,n){return E?O.kpi(e):L[Math.max(0,n)%L.length]},[E,O]),G=i.useState(""),H=G[0],W=G[1],U=i.useState([]),z=U[0],V=U[1],Z=i.useState({}),$=Z[0],J=Z[1],X=i.useState(""),Q=X[0],Y=X[1],ee=i.useState(null),ne=ee[0],ie=ee[1],ae=i.useState(null),te=ae[0],re=ae[1],oe=i.useState(!1),le=oe[0],se=oe[1],de=i.useState(!1),ue=de[0],ce=de[1],ge=i.useRef(null),ve=M?l.toIsoDay(M.range.startDate):"",pe=K&&ve>K?K:ve,he=u.useInsightsFetch(M&&B&&K?function(n){return l.fetchInsightsCorrelation(M.api,T,e.__assign({kpiId:B,dataDay:K,startDate:pe,endDate:l.toIsoDay(M.range.endDate),filters:M.range.filters},$),n)}:null,[null==M?void 0:M.api.configId,null==M?void 0:M.rangeKey,K,B,T,$.disregardBefore,null===(h=$.disregardDates)||void 0===h?void 0:h.join(","),null==M?void 0:M.revision]),_e=he.data,me=he.error,fe=he.loading,ye=u.useInsightsFetch(M&&B&&K?function(n){return l.fetchInsightsCorrelationTrend(M.api,T,e.__assign({kpiId:B,startDate:l.toIsoDay(M.range.startDate),endDate:l.toIsoDay(M.range.endDate),filters:M.range.filters},$),n)}:null,[null==M?void 0:M.api.configId,null==M?void 0:M.rangeKey,K,B,T,$.disregardBefore,null===(f=$.disregardDates)||void 0===f?void 0:f.join(","),null==M?void 0:M.revision]);u.useJob(te,null!==(y=null==M?void 0:M.api)&&void 0!==y?y:null,function(){re(null),Y(""),null==M||M.refresh()}),i.useEffect(function(){if(le){var e=function(e){ge.current&&!ge.current.contains(e.target)&&se(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[le]);var xe=i.useState(new Set),be=xe[0],je=xe[1],ke=i.useMemo(function(){if(!_e)return[];return _e.series.filter(function(e){return!(null==F?void 0:F.length)||F.map(Number).includes((n=e.x,new Date("".concat(n.slice(0,10),"T00:00:00")).getDay()||7));var n})},[_e,F]),we=i.useMemo(function(){return _e?e.__spreadArray([_e.kpiId],_e.drivers.map(function(e){return e.kpiId}).filter(function(e){return e!==_e.kpiId}),!0):[]},[_e]),Ne=i.useMemo(function(){return _e&&M?we.map(function(e,n){var i=ke.map(function(n){var i,a;return n.disregarded?null:null!==(a=null===(i=n.values)||void 0===i?void 0:i[e])&&void 0!==a?a:null}),a=i.find(function(e){return"number"==typeof e&&0!==e});return{key:"corr_".concat(e.replace(/[^a-zA-Z0-9_]/g,"_")),label:M.kpiLabel(e),color:q(e,n),curve:"smooth",strokeWidth:2,pointRadius:2,data:ke.map(function(e,n){return{x:e.x,y:null==i[n]||null==a?null:Math.round((i[n]-a)/Math.abs(a)*1e3)/10}}),valueFormatter:function(e){return"".concat(e,"%")}}}):[]},[_e,M,ke,we,q]),De=Boolean(null===(b=null===(x=null==M?void 0:M.decisionAdvantage)||void 0===x?void 0:x.trendChart)||void 0===b?void 0:b.dualAxis),Ie=null===(k=null===(j=null==M?void 0:M.decisionAdvantage)||void 0===j?void 0:j.trendChart)||void 0===k?void 0:k.correlation,Ce=Math.max(1,Math.min(8,Number(null==Ie?void 0:Ie.maxKpis)||5)),Se=i.useState(null),Ke=Se[0],Ae=Se[1],Te=i.useState(new Set),Le=Te[0],Pe=Te[1],Re=i.useMemo(function(){var n,i;if(Ke)return Ke.filter(function(e){return we.includes(e)});var a=(null!==(n=null==Ie?void 0:Ie.defaultKpis)&&void 0!==n?n:[]).filter(function(e){return we.includes(e)});return(a.length?e.__spreadArray([null!==(i=null==_e?void 0:_e.kpiId)&&void 0!==i?i:""],a.filter(function(e){return e!==(null==_e?void 0:_e.kpiId)}),!0):we.slice(0,2)).filter(Boolean).slice(0,Ce)},[Ke,we,null==Ie?void 0:Ie.defaultKpis,null==_e?void 0:_e.kpiId,Ce]);i.useEffect(function(){return je(new Set(Ne.slice(2).map(function(e){return e.key})))},[Ne]);if(!M||!K||"no_drivers"===(null==_e?void 0:_e.state)||_e&&!_e.verdictText)return null;if(me)return n.jsxs("div",e.__assign({className:"ag-empty"},{children:["Correlation is unavailable right now: ",me.message]}));if(fe&&!_e)return n.jsx(_.ChartSkeleton,{height:220,label:"Loading correlation"});if(!_e)return null;var Fe=null!==(w=_e.strength)&&void 0!==w?w:"none",Me="day"===M.period.grain?"today":"this ".concat(M.period.unit),Be=M.kpiLabel(_e.kpiId);return n.jsx(_.CollapsibleVisualSection,e.__assign({title:"Correlation",meta:M.labels.correlationTitle.replace("{kpi}",Be),className:"ag-visual--card",defaultExpanded:!1,action:M.viewer.isAdmin&&!De?n.jsxs("div",e.__assign({ref:ge,className:"ag-corr__settings"},{children:[n.jsx("button",e.__assign({type:"button",className:"ag-icon-button","aria-label":"Correlation settings","aria-expanded":le,onClick:function(){return se(function(e){return!e})}},{children:n.jsx(a.Settings2,{"aria-hidden":"true"})})),le?n.jsx("div",e.__assign({className:"ag-corr__settings-menu",role:"menu"},{children:n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:ue,onChange:function(e){return ce(e.target.checked)}}),"Show date controls"]})})):null]})):null},{children:n.jsxs("div",e.__assign({className:"ag-corr"},{children:[n.jsx("p",e.__assign({className:"ag-corr__banner ag-corr__banner--".concat(Fe)},{children:_e.verdictText})),n.jsx("span",e.__assign({className:"ag-driver__badge ag-driver__badge--".concat(Fe)},{children:S[Fe]})),n.jsx("p",e.__assign({className:"ag-corr__caption"},{children:M.labels.correlationSubtitle.replace("{kpi}",Be)})),(null===(N=_e.window)||void 0===N?void 0:N.source)?n.jsx("p",e.__assign({className:"ag-muted"},{children:"default"===_e.window.source?_e.window.startDate?"Using all ".concat(M.period.unit,"s since ").concat("day"===M.period.grain?P(_e.window.startDate,"en-US"):c.longPeriod(_e.window.startDate,M.period.grain)):"Using all available ".concat(M.period.unit,"s"):"row"===_e.window.source?"Saved window".concat(_e.window.startDate?" since ".concat(P(_e.window.startDate,"en-US")):"").concat((null===(D=_e.window.excludedDates)||void 0===D?void 0:D.length)?" · ".concat(_e.window.excludedDates.length," left out"):""):"Preview window".concat((null===(I=_e.window.excludedDates)||void 0===I?void 0:I.length)?" · ".concat(_e.window.excludedDates.length," left out"):"")})):null,n.jsxs("div",e.__assign({className:"ag-chart"},{children:[n.jsx("div",e.__assign({className:"ellm-graph"},{children:n.jsx(r.default,{tier:"decision-advantage-correlation",series:De?Ne.filter(function(e){return Re.some(function(n){return e.key==="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_"))})}):Ne,hiddenKeys:De?Le:be,onToggleSeries:function(e){return je(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},onPointClick:function(){},xAxis:{label:"day"===M.period.grain?"Date":c.longPeriod.axisTitle(M.period.grain),categories:ke.map(function(e){return e.x}),formatTick:function(e){return c.shortPeriod(e,M.period.grain)}},yAxis:{label:"% change",beginAtZero:!1,formatTick:function(e){return"".concat(Math.round(Number(e)).toLocaleString("en-US"),"%")}},tooltip:{render:function(i){var a,t=i.x,r=i.points,o=String(t),l=null===(a=ye.data)||void 0===a?void 0:a.series.find(function(e){return e.x===o});return n.jsxs("div",e.__assign({className:"ag-tip ag-tip--wide"},{children:[n.jsx("div",e.__assign({className:"ag-tip__head"},{children:"day"===M.period.grain?P(o):c.longPeriod(o,M.period.grain)})),r.filter(function(e){return null!=e.value}).map(function(i){return n.jsxs("div",e.__assign({className:"ag-tip__line"},{children:[n.jsxs("span",{children:[n.jsx("i",{style:{background:i.color}}),i.series.label]}),n.jsxs("strong",{children:[i.value,"%"]})]}),i.series.key)}),l?Object.keys(l.r).map(function(i){var a,t;return n.jsxs("div",e.__assign({className:"ag-tip__sub"},{children:[n.jsx("span",{children:M.kpiLabel(i)}),n.jsx("span",{children:null==l.r[i]?"No correlation":"r ".concat(l.r[i]," · ").concat(null!==(a=l.strength[i])&&void 0!==a?a:"none"," · ").concat(null!==(t=l.nObs[i])&&void 0!==t?t:0," ").concat(M.period.unit,"s")})]}),i)}):null]}))}},legend:De?{show:!1}:{position:"bottom",toggle:!0},style:{chartHeight:220,yAxisWidth:De?84:60,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}})})),De?n.jsxs("div",e.__assign({className:"kc__foot"},{children:[n.jsx("div",e.__assign({className:"kc__legend"},{children:Re.map(function(i){var a="corr_".concat(i.replace(/[^a-zA-Z0-9_]/g,"_")),t=Le.has(a);return n.jsxs("label",e.__assign({className:"kc__legend-item".concat(t?" is-off":""),style:{"--kc-color":q(i,we.indexOf(i))}},{children:[n.jsx("input",{type:"checkbox",checked:!t,onChange:function(){return Pe(function(e){var n=new Set(e);return n.has(a)?n.delete(a):n.add(a),n})}}),M.kpiLabel(i)]}),i)})})),n.jsx(m.KpiPicker,{oneAxis:!0,selected:Re,onChange:function(e){return Ae(e.slice(0,Ce))},groups:[{label:"Correlated KPIs",kpis:we}],averageKpis:[],max:Ce,insights:M,colorOf:function(e){return q(e,we.indexOf(e))}})]})):null]})),n.jsx("div",e.__assign({className:"ag-corr__metrics"},{children:_e.drivers.map(function(i){var a,t=null!==(a=i.strength)&&void 0!==a?a:"none";return n.jsxs("div",e.__assign({className:"ag-corr__metric"},{children:[n.jsx("span",e.__assign({className:"ag-corr__name"},{children:i.label||M.kpiLabel(i.kpiId)})),i.kpiId!==_e.kpiId?n.jsx("span",e.__assign({className:"ag-driver__badge ag-driver__badge--".concat(t)},{children:S[t]})):null,n.jsx("strong",{children:M.formatKpi(i.kpiId,i.value)}),n.jsx("span",e.__assign({className:"ag-corr__delta"},{children:null!=i.deltaPct?n.jsxs(n.Fragment,{children:[n.jsxs("span",e.__assign({className:"ag-dod__value ag-dod__value--".concat(i.tone||"flat")},{children:["up"===i.direction?"↑":"down"===i.direction?"↓":"→"," ",Math.abs(i.deltaPct),"%"]}))," vs. ",M.formatKpi(i.kpiId,i.previous)]}):"—"})),i.kpiId!==_e.kpiId?n.jsxs("span",e.__assign({className:"ag-corr__r"},{children:[i.nObs," ",M.period.unit,"s used",i.lowHistory?" · Low history":"",n.jsx("br",{}),null==i.movedWithToday?"No comparison for ".concat(Me):i.movedWithToday?"Moved together with the headline ".concat(Me):"Moved opposite the headline ".concat(Me)]})):null]}),i.kpiId)})})),M.viewer.isAdmin&&ue?n.jsxs("div",e.__assign({className:"ag-corr__window"},{children:[n.jsxs("label",e.__assign({className:"ag-corr__start"},{children:["Ignore data before ",n.jsx("input",{type:"date",value:H,onChange:function(e){return W(e.target.value)}})]})),n.jsxs("div",e.__assign({className:"ag-corr__days-label"},{children:["Or leave out individual dates (",z.length," selected)"]})),n.jsx("div",e.__assign({className:"ag-corr__days","aria-label":"Days to leave out"},{children:_e.series.map(function(i){return n.jsx("button",e.__assign({type:"button","aria-pressed":z.includes(i.x),className:z.includes(i.x)?"is-selected":void 0,onClick:function(){return n=i.x,V(function(i){return i.includes(n)?i.filter(function(e){return e!==n}):e.__spreadArray(e.__spreadArray([],i,!0),[n],!1)});var n}},{children:P(i.x)}),i.x)})})),n.jsx("input",{className:"ag-corr__reason",value:Q,onChange:function(e){return Y(e.target.value)},placeholder:"Reason required to apply"}),ne?n.jsx("p",e.__assign({className:"ins-error"},{children:ne})):null,n.jsxs("div",e.__assign({className:"ag-corr__actions"},{children:[n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:function(){return J({disregardBefore:H||void 0,disregardDates:z})}},{children:"Preview"})),n.jsx("button",e.__assign({type:"button",className:"ins-button",disabled:Boolean(te),onClick:function(){return e.__awaiter(C,void 0,void 0,function(){var n,i;return e.__generator(this,function(e){switch(e.label){case 0:if(!M||!B||!Q.trim())return ie("A reason is required."),[2];ie(null),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,l.saveCorrelationWindow(M.api,T,{kpiId:B,startDate:H||null,excludedDates:z,dataDay:K,changeReason:Q.trim(),regenerate:!0})];case 2:return n=e.sent(),re(n.jobId),[3,4];case 3:return i=e.sent(),ie(d.insightsErrorText(i,"The correlation window couldn't be saved.")),[3,4];case 4:return[2]}})})}},{children:"Apply"})),n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:function(){W(""),V([]),J({})}},{children:"Clear"}))]}))]})):null]}))}))}var F=function(e){var n;return(null===(n=null==e?void 0:e.period)||void 0===n?void 0:n.end)||null};function M(e,n){var i,a;return"day"!==n.period.grain&&(!("generated"!==(null===(i=null==e?void 0:e.report)||void 0===i?void 0:i.status)||!(null===(a=e.context)||void 0===a?void 0:a.period))&&!c.periodInRange(e.context.period,l.toIsoDay(n.range.startDate),l.toIsoDay(n.range.endDate),n.period.grain))}function B(e,n){var i,a,t=(null===(i=null==e?void 0:e.period)||void 0===i?void 0:i.label)||_.periodHeading(null===(a=null==e?void 0:e.period)||void 0===a?void 0:a.end,n);return t?"No report in the selected dates. The latest one is for ".concat(t,"."):"No report in the selected dates."}function O(i){var a=i.kpis,t=i.value,r=i.onChange,l=s.useInsights();return l&&a.length?n.jsx("div",e.__assign({className:"ag-plotby"},{children:n.jsx(o.default,{config:{options:a.map(function(e){return{label:l.kpiLabel(e),value:e}}),label:"Plot By",hideWhenSingle:!1,triggerIcon:null},value:t,onChange:r})})):null}var E=["#06B6D4","#10A66A","#8650FF","#F59E0B","#E94BBD","#4285FF","#64748B","#F04444","#14B8A6","#84CC16"];function q(a){var t,o,d=a.entityKey,g=a.kpis,v=a.nodeKeys,p=a.workingDays,h=a.group,f=a.onOpenPoint,x=a.syncId,b=a.kpi,j=s.useInsights(),k=i.useState(null!==(t=g[0])&&void 0!==t?t:""),w=k[0],N=k[1];i.useEffect(function(){var e;g.includes(w)||N(null!==(e=g[0])&&void 0!==e?e:"")},[g,w]);var D=void 0!==b&&g.includes(b)?b:w,I=u.useInsightsFetch(j&&D&&null!==h&&0!==(null==v?void 0:v.length)?function(n){return l.fetchInsightsSeries(j.api,e.__assign(e.__assign({},j.range),{workingDaysOnly:p,group:h||void 0}),v?{kpiIds:[D],nodeKeys:v.slice(0,y)}:{kpiIds:[D],entityKey:d,topN:3},n)}:null,[null==j?void 0:j.api.configId,null==j?void 0:j.rangeKey,d,D,null==v?void 0:v.join(","),p,h,null==j?void 0:j.revision]),C=I.data,S=I.loading,K=I.error,A=i.useMemo(function(){var e;return 0===(null==v?void 0:v.length)?[]:(null!==(e=null==C?void 0:C.series)&&void 0!==e?e:[]).filter(function(e){return e.kpiId===D&&e.points.some(function(e){return Number.isFinite(e.y)})})},[C,v,D]),T=i.useState(new Set),L=T[0],P=T[1];i.useEffect(function(){return P(new Set)},[A]);var R=i.useMemo(function(){return Array.from(new Set(A.flatMap(function(e){return e.points.map(function(e){return e.x})}))).sort()},[A]),F=i.useMemo(function(){var e,n;return m.chartColors(null===(e=null==j?void 0:j.decisionAdvantage)||void 0===e?void 0:e.trendChart,Object.keys(null!==(n=null==j?void 0:j.kpis)&&void 0!==n?n:{}))},[null===(o=null==j?void 0:j.decisionAdvantage)||void 0===o?void 0:o.trendChart,null==j?void 0:j.kpis]),M=F.configured?F.rows:E,B=i.useMemo(function(){return A.map(function(e,n){var i,a=new Map(e.points.map(function(e){return[e.x,e.y]})),t=null!==(i=null==j?void 0:j.goodDirection(e.kpiId))&&void 0!==i?i:"up";return{key:"row_".concat(n,"_").concat(e.nodeKey.replace(/[^a-zA-Z0-9_]/g,"_")),label:e.label||e.nodeKey,color:M[n%M.length],curve:"smooth",pointRadius:3,activePointRadius:3,fillPointsOnHover:!0,data:R.map(function(e){var n;return{x:e,y:null!==(n=a.get(e))&&void 0!==n?n:null}}),valueFormatter:function(n){return j?j.formatKpi(e.kpiId,n):String(n)},markers:e.points.filter(function(e){var n;return null===(n=e.meta)||void 0===n?void 0:n.marker}).map(function(n){return{x:n.x,color:_.movementColorHex(n.meta.marker.movementType,n.meta.marker.direction,t),label:[n.meta.marker.criticality,n.meta.marker.headline].filter(Boolean).join(" · "),radius:3,haloRadius:3,onClick:function(){var i,a=null!==(i=e.label)&&void 0!==i?i:e.nodeKey;f?f({nodeKey:e.nodeKey,label:a,kpiId:e.kpiId,dataDay:n.x,reportId:n.meta.marker.reportId}):null==j||j.openReport(n.meta.marker.reportId?{reportId:n.meta.marker.reportId,title:"".concat(a," · ").concat(c.shortPeriod(n.x,null==j?void 0:j.period.grain))}:{nodeKey:e.nodeKey,kpiId:e.kpiId,dataDay:n.x,title:"".concat(a," · ").concat(c.shortPeriod(n.x,null==j?void 0:j.period.grain))})}}})}})},[A,R,j,f,M]);if(!j)return null;var O=j.kpiLabel(D);return n.jsxs("div",e.__assign({className:"ag-row-trend"},{children:[g.length>1&&void 0===b?n.jsx("div",e.__assign({className:"ag-chart__switch",role:"group","aria-label":"Number"},{children:g.map(function(i){return n.jsx("button",e.__assign({type:"button","aria-pressed":i===D,className:i===D?"is-active":void 0,onClick:function(){return N(i)}},{children:j.kpiLabel(i)}),i)})})):null,K?n.jsx("div",e.__assign({className:"ag-empty"},{children:"This chart is unavailable right now."})):S||null===h&&0!==(null==v?void 0:v.length)?n.jsx(_.ChartSkeleton,{height:240,label:"Loading trend"}):0===(null==v?void 0:v.length)?n.jsx("div",e.__assign({className:"ag-empty"},{children:"Use “Add to graph” on a row to draw it here."})):R.length?n.jsx("div",e.__assign({className:"ag-chart"},{children:n.jsxs("div",e.__assign({className:"ellm-graph"},{children:[n.jsx(r.default,{tier:"decision-advantage-".concat(d),syncId:x,syncMethod:"value",series:B,hiddenKeys:L,onToggleSeries:function(e){return P(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.size<B.length-1&&i.add(e),i})},onPointClick:function(e){var n,i,a,t,r,o,l=e.series,s=e.point,d=e.index,u=B.findIndex(function(e){return e.key===l.key}),g=A[u],v=null!==(n=s.x)&&void 0!==n?n:null===(i=l.data[d])||void 0===i?void 0:i.x,p=null==g?void 0:g.points.find(function(e){return e.x===String(v)});if(g&&p){var h=null!==(a=g.label)&&void 0!==a?a:g.nodeKey,_=null!==(o=null===(r=null===(t=p.meta)||void 0===t?void 0:t.marker)||void 0===r?void 0:r.reportId)&&void 0!==o?o:null;f?f({nodeKey:g.nodeKey,label:h,kpiId:g.kpiId,dataDay:p.x,reportId:_}):j.openReport(_?{reportId:_,title:"".concat(h," · ").concat(c.shortPeriod(p.x,j.period.grain))}:{nodeKey:g.nodeKey,kpiId:g.kpiId,dataDay:p.x,title:"".concat(h," · ").concat(c.shortPeriod(p.x,j.period.grain))})}},xAxis:{label:"day"===j.period.grain?"Date":c.longPeriod.axisTitle(j.period.grain),categories:R,tickCount:8,minTickGap:24,formatTick:function(e){return c.shortPeriod(e,j.period.grain)}},yAxis:{label:O,beginAtZero:!0,fitWidth:!0,formatTick:function(e){var n;return j.formatKpiAxis(null===(n=A[0])||void 0===n?void 0:n.kpiId,Number(e))}},tooltip:{formatHeading:function(e){return c.longPeriod(e,j.period.grain)}},legend:{show:!1},style:{chartHeight:240,yAxisWidth:70,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}}),n.jsx("div",e.__assign({className:"ellm-graph__legend ellm-chart__legend--bottom ellm-chart__legend--center"},{children:B.map(function(i){var a=L.has(i.key);return n.jsxs("label",e.__assign({title:i.label,className:"ellm-graph__legend-item ag-legend-item".concat(a?" ellm-graph__legend-item--off":""),style:{cursor:"pointer","--checkbox-color":i.color,color:i.color}},{children:[n.jsx("input",{type:"checkbox",className:"ellm-graph__legend-checkbox",checked:!a,onChange:function(){return P(function(e){var n=new Set(e);return n.has(i.key)?n.delete(i.key):n.size<B.length-1&&n.add(i.key),n})},style:{borderColor:i.color,accentColor:i.color}}),n.jsx("span",{children:i.label})]}),i.key)})}))]}))})):n.jsx("div",e.__assign({className:"ag-empty"},{children:"No data in the selected dates."}))]}))}function G(a){var t,r=this,o=a.tab,d=a.partName,u=a.kpiIds,g=a.rankBy,v=a.search,p=a.graphed,m=a.onToggleGraph,f=a.onOpenRow,x=a.onFirstRow,j=a.onInitialGraph,k=a.fallbackDay,w=s.useInsights(),N=Math.min(200,Math.max(1,Number(o.pageSize)||5)),D=i.useState([]),I=D[0],C=D[1],S=i.useState(null),L=S[0],P=S[1],R=i.useState(!1),F=R[0],M=R[1],B=i.useState({loading:!0,error:null}),O=B[0],E=B[1],q=i.useState(),G=q[0],H=q[1],W=function(n,i){return e.__awaiter(r,void 0,void 0,function(){var a,t;return e.__generator(this,function(r){switch(r.label){case 0:if(!w)return[2];E({loading:!0,error:null}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,l.fetchLevelRows(w.api,o.entityKey,w.range,{sort:g,order:"desc",search:v||void 0,pageSize:N,cursor:null!=n?n:void 0,includeChildren:3},i)];case 2:return a=r.sent(),(null==i?void 0:i.aborted)?[2]:(H(a.context),C(function(i){return n?e.__spreadArray(e.__spreadArray([],i,!0),a.rows,!0):a.rows}),P(a.nextCursor),M(a.hasNext),E({loading:!1,error:null}),[3,4]);case 3:return t=r.sent(),(null==i?void 0:i.aborted)||"AbortError"===(null==t?void 0:t.name)?[2]:(E({loading:!1,error:t.message||"Couldn't load the rows."}),[3,4]);case 4:return[2]}})})},U=null===(t=I[0])||void 0===t?void 0:t.nodeKey;i.useEffect(function(){return null==x?void 0:x(U)},[U]);var z=I.slice(0,3).map(function(e){return e.nodeKey}),V=z.join("\0");if(i.useEffect(function(){O.loading||O.error||!z.length||null==j||j(z)},[O.loading,O.error,V]),i.useEffect(function(){var e=new AbortController;return W(null,e.signal),function(){return e.abort()}},[null==w?void 0:w.api.configId,null==w?void 0:w.rangeKey,o.entityKey,g,v,N,null==w?void 0:w.revision]),!w)return null;var Z,$=w.goodDirection(g),J=u.filter(function(e){return e!==g}).slice(0,2),X=(Z=d.trim().toLowerCase())?/(s|x|ch|sh)$/.test(Z)?"".concat(Z,"es"):/[^aeiou]y$/.test(Z)?"".concat(Z.slice(0,-1),"ies"):"".concat(Z,"s"):"rows";return n.jsx(_.ReportAccordion,e.__assign({title:"Top Drivers for ".concat(b(X))},{children:O.error?n.jsx("p",e.__assign({className:"ag-muted"},{children:"Top drivers are unavailable right now."})):O.loading&&!I.length?n.jsx(_.SkeletonLines,{widths:[80,60,85,55,75],label:"Loading drivers"}):I.length?n.jsxs(n.Fragment,{children:[n.jsx(h.default,{context:G}),n.jsx(T,e.__assign({label:b(d),rightLabel:"User Activity · selected dates"},{children:I.map(function(i){var a,t,r,o,s=null===(a=i.metrics)||void 0===a?void 0:a[g],d=i.label||i.nodeKey,u=p.includes(i.nodeKey);return n.jsx(A,{rank:i.rank,name:d,chips:n.jsxs(n.Fragment,{children:[n.jsx(_.CriticalityChip,{criticality:null===(t=i.chip)||void 0===t?void 0:t.criticality}),n.jsx(_.MovementChip,{movementType:null===(r=i.chip)||void 0===r?void 0:r.movementType,direction:null===(o=i.chip)||void 0===o?void 0:o.direction,good:$})]}),action:n.jsx(K,{on:u,disabled:!u&&p.length>=y,onClick:function(){return m(i.nodeKey)}}),lines:n.jsxs("span",e.__assign({className:"ag-driver__cost"},{children:[n.jsxs("span",e.__assign({className:"ag-driver__total"},{children:[w.formatKpi(g,null==s?void 0:s.value)," ",w.kpiLabel(g).toLowerCase()]})),null!=(null==s?void 0:s.deltaPct)?n.jsx("span",e.__assign({className:"ag-driver__sep"},{children:"|"})):null,n.jsx(_.DayOverDayChange,{deltaPct:null==s?void 0:s.deltaPct,good:$,direction:null==s?void 0:s.direction,tone:null==s?void 0:s.tone,suffix:"vs previous period"})]})),cell:J.map(function(a){var t,r,o=null===(t=i.metrics)||void 0===t?void 0:t[a],l=null!==(r=null==o?void 0:o.tone)&&void 0!==r?r:_.toneOf(null==o?void 0:o.deltaPct,w.goodDirection(a)),s="up"===(null==o?void 0:o.direction)?"↑":"down"===(null==o?void 0:o.direction)?"↓":"flat"===(null==o?void 0:o.direction)?"→":null!=(null==o?void 0:o.deltaPct)&&o.deltaPct>0?"↑":null!=(null==o?void 0:o.deltaPct)&&o.deltaPct<0?"↓":"→";return n.jsxs("span",e.__assign({className:"ag-driver__activity"},{children:[n.jsx("strong",e.__assign({className:"good"===l?"ag-text--good":"bad"===l?"ag-text--bad":void 0},{children:null==(null==o?void 0:o.deltaPct)?w.formatKpi(a,null==o?void 0:o.value):"".concat(s).concat(Math.abs(o.deltaPct),"%")})),n.jsx("span",{children:w.kpiLabel(a)})]}),a)}),onOpen:function(){var e;return f(i,g,k||(null===(e=i.chip)||void 0===e?void 0:e.dataDay)||c.periodStart(l.toIsoDay(w.range.endDate),w.period.grain))}},i.nodeKey)})})),F?n.jsx("div",e.__assign({className:"ag-more"},{children:n.jsx("button",e.__assign({type:"button",disabled:O.loading,onClick:function(){return W(L)}},{children:O.loading?"Loading...":"Show more"}))})):null]}):n.jsx("p",e.__assign({className:"ag-muted"},{children:v?"No ".concat(X," match “").concat(v,"”."):"No ".concat(X," for this period yet.")}))}))}exports.AddToGraph=K,exports.CorrelationSection=R,exports.DecisionCard=D,exports.DriverList=T,exports.DriverRow=A,exports.L2Report=function(t){var r,o,d,c,v,m,f,b,j,k,w,I,C,S,K,A,T,L,P,E,H=t.tab,W=t.title,U=t.partName,z=t.partKpis,V=t.search,Z=t.dataDay,$=t.onOpenRow,J=t.headerAction,X=s.useInsights(),Q="decision-advantage-l2-".concat(i.useId()),Y=i.useState(null),ee=Y[0],ne=Y[1],ie=i.useState(null),ae=ie[0],te=ie[1],re=i.useState(Boolean(null==X?void 0:X.defaultWorkingDays)),oe=re[0],le=re[1],se=u.useInsightsFetch(X?function(e){return l.fetchGraphGroups(X.api,e)}:null,[null==X?void 0:X.api.configId,null==X?void 0:X.revision]),de=i.useState(null),ue=de[0],ce=de[1];i.useEffect(function(){var e,n;null===ue&&((null===(e=se.data)||void 0===e?void 0:e.groups.length)?ce((null!==(n=se.data.groups.find(function(e){return e.isDefault}))&&void 0!==n?n:se.data.groups[0]).groupKey):se.loading||ce(""))},[ue,se.data,se.loading]);var ge=i.useState(null),ve=ge[0],pe=ge[1],he=i.useState(),_e=he[0],me=he[1],fe=!1!==H.showSummary,ye=null===(o=null===(r=se.data)||void 0===r?void 0:r.groups.find(function(e){return e.groupKey===ue}))||void 0===o?void 0:o.days.map(Number),xe=null!==(d=null==X?void 0:X.period.grain)&&void 0!==d?d:"day",be="day"===xe&&((null==ye?void 0:ye.length)?ye.every(function(e){return e>=1&&e<=5}):oe||Boolean(null==X?void 0:X.range.workingDaysOnly)),je=X?p.resolveL2SummaryRange(X.range,be,Z,void 0,xe):null,ke="".concat(null==X?void 0:X.api.configId,":").concat(null==X?void 0:X.rangeKey,":").concat(H.entityKey,":").concat(ue,":").concat(null==je?void 0:je.startDate.getTime(),":").concat(null==je?void 0:je.endDate.getTime(),":").concat(null==je?void 0:je.workingDaysOnly),we=u.useInsightsFetch(X&&je&&fe&&null!==ue?function(e){return l.fetchLevelSummary(X.api,H.entityKey,je,e)}:null,[ke,fe,null==X?void 0:X.revision],ke);if(!X)return null;var Ne=(null===(c=H.listKpis)||void 0===c?void 0:c.length)?H.listKpis:z,De=H.rankBy&&Ne.includes(H.rankBy)?H.rankBy:null!==(v=Ne[0])&&void 0!==v?v:"",Ie=!Z&&M(we.data,X),Ce=Ie||null===(m=we.data)||void 0===m?void 0:m.report,Se=Ie?null:F(null===(f=we.data)||void 0===f?void 0:f.context),Ke=Ie?B(null===(b=we.data)||void 0===b?void 0:b.context,xe):null,Ae=p.resolveDrillDay({endDate:X.range.endDate,workingDays:be,selectedDay:Z,reportDay:Se,grain:xe}),Te=function(n){return Z||be?e.__assign(e.__assign({},n),{report:e.__assign(e.__assign({},n.report),{reportId:null})}):n},Le=X.goodDirection(De),Pe=null!==(j=H.tier1Kpis)&&void 0!==j?j:X.tierKpis[1],Re=null!==(k=H.tier2Kpis)&&void 0!==k?k:X.tierKpis[2],Fe=ee&&Pe.includes(ee)?ee:null!==(w=Pe[0])&&void 0!==w?w:"",Me=ae&&Re.includes(ae)?ae:null!==(I=Re[0])&&void 0!==I?I:"",Be=X.headlineKpi||De||Pe[0]||"",Oe=function(e){var n=e.nodeKey,i=e.label,a=e.dataDay;return $({rank:0,nodeKey:n,label:i,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:Be},action:null,children:[]},Be,a)},Ee=X.drill.tabTables[H.entityKey],qe=Ee?n.jsx(g.default,{table:e.__assign(e.__assign({},Ee),{pageSize:null!==(S=null!==(C=Ee.pageSize)&&void 0!==C?C:H.pageSize)&&void 0!==S?S:void 0}),tabEntityKey:H.entityKey,context:{trail:[],day:Ae},onRowClick:function(e,n){var i;return"report"===n?X.openReport({reportId:Te(e).report.reportId,nodeKey:e.nodeKey,kpiId:De,dataDay:Ae,title:null!==(i=e.label)&&void 0!==i?i:e.nodeKey}):"drill"===n?$(Te(e),De,Ae):void 0}}):null;return n.jsxs("section",e.__assign({className:"ag-report","aria-label":"L2 Report · ".concat(W)},{children:[n.jsxs("div",e.__assign({className:"ag-report__header"},{children:[n.jsxs("h2",e.__assign({className:"ag-report__title"},{children:[n.jsx(a.Sparkles,{"aria-hidden":"true"}),"L2 Report"]})),n.jsx("span",e.__assign({className:"ag-report__scope"},{children:W})),Se?n.jsx("span",e.__assign({className:"ag-report__date"},{children:_.periodHeading(Se,xe)})):null,J?n.jsx("div",e.__assign({className:"ag-report__header-action"},{children:J})):null]})),n.jsxs("div",e.__assign({className:"ag-report__grid ag-report__grid--l2"},{children:[n.jsx("div",e.__assign({className:"ag-report__analysis-scroll",role:"region","aria-label":"".concat(W," analysis"),tabIndex:0},{children:n.jsxs("div",e.__assign({className:"ag-stack"},{children:[fe?n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx(_.SectionHeader,{title:"Summary",action:n.jsx(x,{entityKey:H.entityKey,dataDay:Se})}),n.jsx(N,{report:Ce,loading:we.loading,error:we.error,good:Le,emptyText:Ke})]}),n.jsx(D,{report:Ce,error:we.error,loading:we.loading,emptyText:Ke}),n.jsx(h.default,{context:null===(K=we.data)||void 0===K?void 0:K.context})]}):null,Ne.length?n.jsx(G,{tab:H,partName:U,kpiIds:Ne,rankBy:De,search:V,graphed:null!=ve?ve:[],onToggleGraph:function(n){return pe(function(i){var a=null!=i?i:[];return a.includes(n)?a.filter(function(e){return e!==n}):a.length<y?e.__spreadArray(e.__spreadArray([],a,!0),[n],!1):a})},onOpenRow:function(e,n,i){return $(Te(e),n,i)},onFirstRow:me,onInitialGraph:function(e){return pe(function(n){return null!=n?n:e})},fallbackDay:Ae}):null]}))})),n.jsxs("div",e.__assign({className:"ag-stack"},{children:[Pe.length?n.jsx(_.CollapsibleVisualSection,e.__assign({title:"Trend",action:n.jsxs("div",e.__assign({className:"ag-visual__actions"},{children:[n.jsx(O,{kpis:Pe,value:Fe,onChange:ne}),n.jsx(_.DaysDropdown,{value:oe,onChange:le,groups:se.error||null===(A=se.data)||void 0===A?void 0:A.groups,group:ue,onGroupChange:ce})]}))},{children:n.jsx(q,{entityKey:H.entityKey,kpis:Pe,kpi:Fe,nodeKeys:ve,workingDays:oe,group:ue,onOpenPoint:Oe,syncId:Q})})):null,Re.length?n.jsx(_.CollapsibleVisualSection,e.__assign({title:X.labels.activityTitle,action:n.jsx("div",e.__assign({className:"ag-visual__actions"},{children:n.jsx(O,{kpis:Re,value:Me,onChange:te})}))},{children:n.jsx(q,{entityKey:H.entityKey,kpis:Re,kpi:Me,nodeKeys:ve,workingDays:oe,group:ue,onOpenPoint:Oe,syncId:Q})})):null,n.jsx(R,{dataDay:Se,nodeKey:null!==(T=null==ve?void 0:ve[0])&&void 0!==T?T:_e,dayGroup:null===(P=null===(L=se.data)||void 0===L?void 0:L.groups.find(function(e){return e.groupKey===ue}))||void 0===P?void 0:P.days}),"column"===(null==Ee?void 0:Ee.width)?qe:null]}))]})),Ee&&"full"===(null!==(E=Ee.width)&&void 0!==E?E:"full")?qe:null]}))},exports.MAX_SERIES=y,exports.PlotByKpi=O,exports.RegenerateSummary=x,exports.RowDrivers=G,exports.RowTrend=q,exports.SummaryCard=N,exports.TopDriversSection=function(t){var r,o,d,c,g,p,h,m,x,b,j,k,N,D=t.dataDay,S=t.entityKey,L=t.parentNodeKey,P=t.kpiId,R=t.title,F=t.graphed,M=t.onToggleGraph,B=t.onOpenDriver,O=t.onDecisionSettled,E=t.initialTab,q=void 0===E?"drivers":E,G=s.useInsights(),H=i.useState(q),W=H[0],U=H[1],z=i.useState({drivers:1,headwinds:1,attention:1}),V=z[0],Z=z[1],$=null!==(r=null!=P?P:null==G?void 0:G.headlineKpi)&&void 0!==r?r:void 0,J=S||L||null===(c=null===(d=null===(o=null==G?void 0:G.decisionAdvantage)||void 0===o?void 0:o.topDrivers)||void 0===d?void 0:d.parts)||void 0===c?void 0:c.filter(Boolean),X=null!==(g=null==J?void 0:J.join(","))&&void 0!==g?g:"",Q=function(e){return G&&$&&e===W?function(n){return l.fetchInsightsDrivers(G.api,{dataDay:D,kpiId:$,entityKey:S,parentNodeKey:L,tab:e,limit:Math.min(10,(L?10:3)*V[e]),offset:0,filters:G.range.filters,parts:(null==J?void 0:J.length)?J:void 0},n)}:null},Y=function(e){return[null==G?void 0:G.api.configId,null==G?void 0:G.rangeKey,D,$,S,L,e,W,V[e],null==G?void 0:G.revision,X]},ee={drivers:u.useInsightsFetch(Q("drivers"),Y("drivers")),headwinds:u.useInsightsFetch(Q("headwinds"),Y("headwinds")),attention:u.useInsightsFetch(Q("attention"),Y("attention"))},ne=ee[W],ie=ne.data,ae=ne.error,te=ne.loading,re=null!==(x=null!==(h=null===(p=ee.drivers.data)||void 0===p?void 0:p.tabs)&&void 0!==h?h:null===(m=ee.headwinds.data)||void 0===m?void 0:m.tabs)&&void 0!==x?x:null===(b=ee.attention.data)||void 0===b?void 0:b.tabs,oe=f.useNeedsAttention(D,L,$),le=null!==(k=null===(j=oe.data)||void 0===j?void 0:j.counts.pending)&&void 0!==k?k:0;if(i.useEffect(function(){return Z({drivers:1,headwinds:1,attention:1})},[D]),i.useEffect(function(){return U(q)},[q]),!G)return null;var se=G.goodDirection(null!=$?$:""),de=null!==(N=null==ie?void 0:ie.rows)&&void 0!==N?N:[];return n.jsxs(_.ReportAccordion,e.__assign({title:R},{children:[n.jsx("div",e.__assign({className:"ag-driver-tabs",role:"tablist","aria-label":"Driver views"},{children:I.map(function(i){return n.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":W===i.key,className:W===i.key?"is-active":void 0,onClick:function(){return U(i.key)},title:i.info},{children:n.jsxs(n.Fragment,{children:[G.labels[i.label],(null==re?void 0:re[i.key])?" (".concat(re[i.key].total,")"):"","attention"===i.key&&le?n.jsxs("span",e.__assign({className:"ag-na__tab-badge",title:"".concat(le," data points need a decision")},{children:[le,n.jsx("span",e.__assign({className:"ins-visually-hidden"},{children:" data points need a decision"}))]})):null,n.jsx(a.Info,{"aria-hidden":"true"})]})}),i.key)})})),"attention"===W?n.jsx(f.default,{dataDay:D,nodeKey:L,kpiId:$,attention:oe,onDecisionSettled:O}):null,"attention"===W&&de.length?n.jsx("h4",e.__assign({className:"ag-na__subhead"},{children:"Rows that moved without a clear cause"})):null,ae?n.jsxs("p",e.__assign({className:"ag-muted"},{children:["Top drivers are unavailable right now: ",ae.message]})):te&&!ie?n.jsx("p",e.__assign({className:"ag-muted"},{children:"Loading drivers..."})):de.length?n.jsxs(n.Fragment,{children:[n.jsx(T,e.__assign({label:"Driver",rightLabel:G.labels.activityColumn},{children:de.map(function(i){var a,t,r,o,l=i.deltaContributionPct,s=F.includes(i.nodeKey),d=(null===(a=i.decisionAdvantage)||void 0===a?void 0:a.correlationSentence)||(null===(t=i.decisionAdvantage)||void 0===t?void 0:t.firstCause)||(null===(r=i.decisionAdvantage)||void 0===r?void 0:r.headline);return n.jsx(A,{alignActivity:!0,rank:i.rank,category:G.labels.driverCategory.replace("{plural}",i.entityKey?G.entityPluralName(i.entityKey):"").replace("{name}",i.entityKey?G.entityName(i.entityKey):""),name:i.label,chips:n.jsxs(n.Fragment,{children:[n.jsx(_.CriticalityChip,{criticality:i.criticality}),n.jsx(_.MovementChip,{movementType:i.movementType,direction:i.changeDirection,good:se})]}),action:M?n.jsx(K,{on:s,disabled:!s&&F.length>=y,onClick:function(){return M(i)}}):void 0,lines:n.jsxs(n.Fragment,{children:[null!=l?n.jsxs("span",e.__assign({className:"ag-driver__share"},{children:[G.labels.shareLine.replace("{share}",String(Math.abs(l))).replace("{period}",u.periodName(D,G.period.grain))," · ","opposite"===i.direction?G.labels.movedOpposite:G.labels.movedWith]})):null,n.jsxs("span",e.__assign({className:"ag-driver__cost"},{children:[n.jsx("span",e.__assign({className:"ag-driver__total"},{children:G.formatKpi($,i.value)})),null!=i.deltaPct?n.jsx("span",e.__assign({className:"ag-driver__sep"},{children:"|"})):null,n.jsx(_.DayOverDayChange,{deltaPct:i.deltaPct,good:se,direction:i.changeDirection,tone:i.tone,suffix:u.previousPeriodLabel(D,G.period.grain)})]})),d?n.jsx("p",e.__assign({className:"ag-driver__brief"},{children:n.jsx(_.VerdictSentence,{text:w(d),good:se,arrowsFollowVerdict:!0})})):null,(null===(o=i.decisionAdvantage)||void 0===o?void 0:o.nextStep)?n.jsxs("p",e.__assign({className:"ag-driver__brief"},{children:[n.jsx("strong",{children:"Next:"})," ",w(i.decisionAdvantage.nextStep)]})):null]}),cell:n.jsx(v.default,{driver:i,kpiId:null!=$?$:"",kpiLabel:G.kpiLabel,formatKpi:G.formatKpi}),onOpen:function(){var e;return B?B(i):G.openReport({reportId:null===(e=i.report)||void 0===e?void 0:e.reportId,nodeKey:i.nodeKey,kpiId:$,dataDay:D,title:i.label})}},i.nodeKey)})})),(null==ie?void 0:ie.hasMore)?n.jsx("div",e.__assign({className:"ag-more"},{children:n.jsx("button",e.__assign({type:"button",disabled:te,onClick:function(){return Z(function(n){var i;return e.__assign(e.__assign({},n),((i={})[W]=n[W]+1,i))})}},{children:te?"Loading...":"Show more"}))})):null]}):n.jsx("p",e.__assign({className:"ag-muted"},{children:C[W]}))]}))},exports.decisionCardNotice=k,exports.outsideRangeText=B,exports.reportDayOf=F,exports.reportOutsideRange=M,exports.stripRowTags=w,exports.titleCase=b;
|
|
2
2
|
//# sourceMappingURL=AgReport.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("react"),s=require("lucide-react"),i=require("../../api/insightsApi.js"),r=require("./insightsContextCore.js"),a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),n=require("react/jsx-runtime"),t=require("react"),s=require("lucide-react"),i=require("../../api/insightsApi.js"),r=require("./insightsContextCore.js"),a=require("./insightsErrors.js"),l=require("./insightsUtils.js"),o=function(e){if(!e)return"";var n=new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})};function u(s){var i=this,r=s.placeholder,l=s.submitLabel,o=s.onSubmit,u=s.onCancel,c=s.initialValue,m=void 0===c?"":c,d=t.useState(m),_=d[0],h=d[1],g=t.useState(!1),p=g[0],x=g[1],v=t.useState(null),b=v[0],j=v[1];return n.jsxs("div",e.__assign({className:"ins-comment-box"},{children:[n.jsx("textarea",{value:_,maxLength:4e3,placeholder:r,"aria-label":r,onChange:function(e){return h(e.target.value)},rows:2}),b?n.jsx("p",e.__assign({className:"ins-error"},{children:b})):null,n.jsxs("div",e.__assign({className:"ins-comment-box__actions"},{children:[u?n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:u},{children:"Cancel"})):null,n.jsx("button",e.__assign({type:"button",className:"ins-button",disabled:p||!_.trim(),onClick:function(){return e.__awaiter(i,void 0,void 0,function(){var n;return e.__generator(this,function(e){switch(e.label){case 0:if(!_.trim())return[2];x(!0),j(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,o(_.trim())];case 2:return e.sent(),h(""),[3,5];case 3:return n=e.sent(),j(a.insightsErrorText(n,"Couldn't post the comment.")),[3,5];case 4:return x(!1),[7];case 5:return[2]}})})}},{children:p?"Posting…":l}))]}))]}))}exports.default=function(c){var m=this,d=c.reportId,_=r.useInsights(),h=t.useState(null),g=h[0],p=h[1],x=t.useState(null),v=x[0],b=x[1],j=t.useState(null),f=j[0],C=j[1],N=l.useInsightsFetch(_?function(e){return i.fetchReportComments(_.api,d,e)}:null,[d,null==_?void 0:_.api.configId,null==_?void 0:_.revision]),y=N.data,w=N.loading,S=N.error,k=N.reload;if(!_)return null;var L=_.viewer,q=function(t){var r,l,c=Boolean(L.email&&t.createdByEmail&&L.email.toLowerCase()===t.createdByEmail.toLowerCase());return n.jsxs("li",e.__assign({className:"ins-comment"},{children:[t.isDeleted?n.jsx("p",e.__assign({className:"ins-comment__deleted"},{children:"Comment deleted"})):n.jsxs(n.Fragment,{children:[n.jsxs("div",e.__assign({className:"ins-comment__meta"},{children:[n.jsx("strong",{children:t.createdByName||t.createdByEmail||"Someone"}),n.jsxs("span",{children:[o(t.createdAt),t.edited?" · edited":""]})]})),v===t.id?n.jsx(u,{placeholder:"Edit comment",submitLabel:"Save",initialValue:null!==(r=t.commentText)&&void 0!==r?r:"",onCancel:function(){return b(null)},onSubmit:function(n){return e.__awaiter(m,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,i.updateReportComment(_.api,t.id,n)];case 1:return e.sent(),b(null),k(),[2]}})})}}):n.jsx("p",e.__assign({className:"ins-comment__text"},{children:t.commentText})),n.jsxs("div",e.__assign({className:"ins-comment__actions"},{children:[n.jsx("button",e.__assign({type:"button",className:"ins-link",onClick:function(){return p(g===t.id?null:t.id)}},{children:"Reply"})),c?n.jsxs("button",e.__assign({type:"button",className:"ins-link",onClick:function(){return b(t.id)}},{children:[n.jsx(s.PenLine,{"aria-hidden":"true"})," Edit"]})):null,c||L.isAdmin?n.jsxs("button",e.__assign({type:"button",className:"ins-link ins-link--danger",onClick:function(){return n=t.id,e.__awaiter(m,void 0,void 0,function(){var t;return e.__generator(this,function(e){switch(e.label){case 0:C(null),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i.deleteReportComment(_.api,n)];case 2:return e.sent(),k(),[3,4];case 3:return t=e.sent(),C(a.insightsErrorText(t,"Couldn't delete the comment.")),[3,4];case 4:return[2]}})});var n}},{children:[n.jsx(s.Trash2,{"aria-hidden":"true"})," Delete"]})):null]}))]}),g===t.id?n.jsx(u,{placeholder:"Write a reply",submitLabel:"Reply",onCancel:function(){return p(null)},onSubmit:function(n){return e.__awaiter(m,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,i.postReportComment(_.api,d,n,t.id)];case 1:return e.sent(),p(null),k(),[2]}})})}}):null,(null===(l=t.replies)||void 0===l?void 0:l.length)?n.jsx("ul",e.__assign({className:"ins-comments ins-comments--replies"},{children:t.replies.map(q)})):null]}),t.id)};return n.jsxs("section",e.__assign({className:"ins-thread","aria-label":"Comments"},{children:[n.jsxs("h3",{children:[n.jsx(s.MessageSquare,{"aria-hidden":"true"})," Comments",(null==y?void 0:y.count)?" (".concat(y.count,")"):""]}),S?n.jsx("p",e.__assign({className:"ins-error"},{children:S.message})):null,f?n.jsx("p",e.__assign({className:"ins-error"},{children:f})):null,w&&!y?n.jsx("p",e.__assign({className:"ins-muted"},{children:"Loading comments…"})):null,y&&!y.comments.length?n.jsx("p",e.__assign({className:"ins-muted"},{children:"No comments yet."})):null,(null==y?void 0:y.comments.length)?n.jsx("ul",e.__assign({className:"ins-comments"},{children:y.comments.map(q)})):null,n.jsx(u,{placeholder:"Add a comment",submitLabel:"Comment",onSubmit:function(n){return e.__awaiter(m,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:return[4,i.postReportComment(_.api,d,n)];case 1:return e.sent(),k(),[2]}})})}})]}))};
|
|
2
2
|
//# sourceMappingURL=CommentsThread.js.map
|