@e-llm-studio/federated-dashboard-components 2.2.9-rca-test-16 → 2.2.9-rca-test-18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/ExecutiveDashboard/ExecutiveDashboardWrapper.js +1 -1
  2. package/dist/ExecutiveDashboard/api/insightsApi.js +1 -1
  3. package/dist/ExecutiveDashboard/components/ExecutiveDashboard.js +1 -1
  4. package/dist/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
  5. package/dist/ExecutiveDashboard/components/Graph/axisDomain.js +1 -1
  6. package/dist/ExecutiveDashboard/components/Insights/AgCharts.js +1 -1
  7. package/dist/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
  8. package/dist/ExecutiveDashboard/components/Insights/CommentsThread.js +1 -1
  9. package/dist/ExecutiveDashboard/components/Insights/DecisionAdvantageCard.js +1 -1
  10. package/dist/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
  11. package/dist/ExecutiveDashboard/components/Insights/InsightTabs.js +1 -1
  12. package/dist/ExecutiveDashboard/components/Insights/InsightsContext.js +1 -1
  13. package/dist/ExecutiveDashboard/components/Insights/KpiChart.js +1 -1
  14. package/dist/ExecutiveDashboard/components/Insights/L1Report.js +1 -1
  15. package/dist/ExecutiveDashboard/components/Insights/NeedsAttention.js +1 -1
  16. package/dist/ExecutiveDashboard/components/Insights/ReportDrawer.js +1 -1
  17. package/dist/ExecutiveDashboard/components/Insights/agPrimitives.js +1 -1
  18. package/dist/ExecutiveDashboard/components/Insights/drillDay.js +1 -1
  19. package/dist/ExecutiveDashboard/components/Insights/insightsErrors.js +2 -0
  20. package/dist/ExecutiveDashboard/components/Insights/insightsErrors.js.map +1 -0
  21. package/dist/ExecutiveDashboard/components/Insights/insightsFormat.js +1 -1
  22. package/dist/ExecutiveDashboard/components/Insights/insightsUtils.js +1 -1
  23. package/dist/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.js +2 -0
  24. package/dist/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.js.map +1 -0
  25. package/dist/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.js +1 -1
  26. package/dist/ExecutiveDashboard/components/Table/TableCard.js +1 -1
  27. package/dist/HumanIntelligence/HumanChangesTableWrapper.js +1 -1
  28. package/dist/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.js +1 -1
  29. package/dist/HumanIntelligence/components/HumanChangesSummary/HumanChangesSummary.js +1 -1
  30. package/dist/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.js +1 -1
  31. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js +2 -0
  32. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js.map +1 -0
  33. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js +2 -0
  34. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js.map +1 -0
  35. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js +2 -0
  36. package/dist/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js.map +1 -0
  37. package/dist/HumanIntelligence/hooks/accessToken.js +2 -0
  38. package/dist/HumanIntelligence/hooks/accessToken.js.map +1 -0
  39. package/dist/HumanIntelligence/hooks/useHumanChangesData.js +1 -1
  40. package/dist/HumanIntelligence/utils/inlineMarkup.js +1 -1
  41. package/dist/cjs/ExecutiveDashboard/ExecutiveDashboardWrapper.js +1 -1
  42. package/dist/cjs/ExecutiveDashboard/api/insightsApi.js +1 -1
  43. package/dist/cjs/ExecutiveDashboard/components/ExecutiveDashboard.js +1 -1
  44. package/dist/cjs/ExecutiveDashboard/components/Graph/LineChart.js +1 -1
  45. package/dist/cjs/ExecutiveDashboard/components/Graph/axisDomain.js +1 -1
  46. package/dist/cjs/ExecutiveDashboard/components/Insights/AgCharts.js +1 -1
  47. package/dist/cjs/ExecutiveDashboard/components/Insights/AgReport.js +1 -1
  48. package/dist/cjs/ExecutiveDashboard/components/Insights/CommentsThread.js +1 -1
  49. package/dist/cjs/ExecutiveDashboard/components/Insights/DecisionAdvantageCard.js +1 -1
  50. package/dist/cjs/ExecutiveDashboard/components/Insights/DrillTable.js +1 -1
  51. package/dist/cjs/ExecutiveDashboard/components/Insights/InsightTabs.js +1 -1
  52. package/dist/cjs/ExecutiveDashboard/components/Insights/InsightsContext.js +1 -1
  53. package/dist/cjs/ExecutiveDashboard/components/Insights/KpiChart.js +1 -1
  54. package/dist/cjs/ExecutiveDashboard/components/Insights/L1Report.js +1 -1
  55. package/dist/cjs/ExecutiveDashboard/components/Insights/NeedsAttention.js +1 -1
  56. package/dist/cjs/ExecutiveDashboard/components/Insights/ReportDrawer.js +1 -1
  57. package/dist/cjs/ExecutiveDashboard/components/Insights/agPrimitives.js +1 -1
  58. package/dist/cjs/ExecutiveDashboard/components/Insights/drillDay.js +1 -1
  59. package/dist/cjs/ExecutiveDashboard/components/Insights/insightsErrors.js +2 -0
  60. package/dist/cjs/ExecutiveDashboard/components/Insights/insightsErrors.js.map +1 -0
  61. package/dist/cjs/ExecutiveDashboard/components/Insights/insightsFormat.js +1 -1
  62. package/dist/cjs/ExecutiveDashboard/components/Insights/insightsUtils.js +1 -1
  63. package/dist/cjs/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.js +2 -0
  64. package/dist/cjs/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.js.map +1 -0
  65. package/dist/cjs/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.js +1 -1
  66. package/dist/cjs/ExecutiveDashboard/components/Table/TableCard.js +1 -1
  67. package/dist/cjs/HumanIntelligence/HumanChangesTableWrapper.js +1 -1
  68. package/dist/cjs/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.js +1 -1
  69. package/dist/cjs/HumanIntelligence/components/HumanChangesSummary/HumanChangesSummary.js +1 -1
  70. package/dist/cjs/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.js +1 -1
  71. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js +2 -0
  72. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.js.map +1 -0
  73. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js +2 -0
  74. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.module.css.js.map +1 -0
  75. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js +2 -0
  76. package/dist/cjs/HumanIntelligence/components/ReviewLearningConditionsModal/parser.js.map +1 -0
  77. package/dist/cjs/HumanIntelligence/hooks/accessToken.js +2 -0
  78. package/dist/cjs/HumanIntelligence/hooks/accessToken.js.map +1 -0
  79. package/dist/cjs/HumanIntelligence/hooks/useHumanChangesData.js +1 -1
  80. package/dist/cjs/HumanIntelligence/utils/inlineMarkup.js +1 -1
  81. package/dist/cjs/styles.css +1 -1
  82. package/dist/styles.css +1 -1
  83. package/dist/types/ExecutiveDashboard/ExecutiveDashboardWrapper.d.ts +1 -1
  84. package/dist/types/ExecutiveDashboard/ExecutiveDashboardWrapper.d.ts.map +1 -1
  85. package/dist/types/ExecutiveDashboard/TestExecutiveDashboard.d.ts.map +1 -1
  86. package/dist/types/ExecutiveDashboard/api/insightsApi.d.ts +9 -0
  87. package/dist/types/ExecutiveDashboard/api/insightsApi.d.ts.map +1 -1
  88. package/dist/types/ExecutiveDashboard/components/ExecutiveDashboard.d.ts +3 -1
  89. package/dist/types/ExecutiveDashboard/components/ExecutiveDashboard.d.ts.map +1 -1
  90. package/dist/types/ExecutiveDashboard/components/Graph/LineChart.d.ts.map +1 -1
  91. package/dist/types/ExecutiveDashboard/components/Graph/axisDomain.d.ts +4 -4
  92. package/dist/types/ExecutiveDashboard/components/Graph/axisDomain.d.ts.map +1 -1
  93. package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts +2 -0
  94. package/dist/types/ExecutiveDashboard/components/Graph/types.d.ts.map +1 -1
  95. package/dist/types/ExecutiveDashboard/components/Insights/AgCharts.d.ts.map +1 -1
  96. package/dist/types/ExecutiveDashboard/components/Insights/AgReport.d.ts +18 -3
  97. package/dist/types/ExecutiveDashboard/components/Insights/AgReport.d.ts.map +1 -1
  98. package/dist/types/ExecutiveDashboard/components/Insights/CommentsThread.d.ts.map +1 -1
  99. package/dist/types/ExecutiveDashboard/components/Insights/DecisionAdvantageCard.d.ts.map +1 -1
  100. package/dist/types/ExecutiveDashboard/components/Insights/DrillTable.d.ts.map +1 -1
  101. package/dist/types/ExecutiveDashboard/components/Insights/InsightTabs.d.ts.map +1 -1
  102. package/dist/types/ExecutiveDashboard/components/Insights/InsightsContext.d.ts +3 -1
  103. package/dist/types/ExecutiveDashboard/components/Insights/InsightsContext.d.ts.map +1 -1
  104. package/dist/types/ExecutiveDashboard/components/Insights/KpiChart.d.ts +28 -2
  105. package/dist/types/ExecutiveDashboard/components/Insights/KpiChart.d.ts.map +1 -1
  106. package/dist/types/ExecutiveDashboard/components/Insights/L1Report.d.ts.map +1 -1
  107. package/dist/types/ExecutiveDashboard/components/Insights/NeedsAttention.d.ts.map +1 -1
  108. package/dist/types/ExecutiveDashboard/components/Insights/ReportDrawer.d.ts.map +1 -1
  109. package/dist/types/ExecutiveDashboard/components/Insights/agPrimitives.d.ts +16 -3
  110. package/dist/types/ExecutiveDashboard/components/Insights/agPrimitives.d.ts.map +1 -1
  111. package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts +9 -4
  112. package/dist/types/ExecutiveDashboard/components/Insights/drillDay.d.ts.map +1 -1
  113. package/dist/types/ExecutiveDashboard/components/Insights/insightsErrors.d.ts +11 -0
  114. package/dist/types/ExecutiveDashboard/components/Insights/insightsErrors.d.ts.map +1 -0
  115. package/dist/types/ExecutiveDashboard/components/Insights/insightsFormat.d.ts +38 -0
  116. package/dist/types/ExecutiveDashboard/components/Insights/insightsFormat.d.ts.map +1 -1
  117. package/dist/types/ExecutiveDashboard/components/Insights/insightsUtils.d.ts +17 -1
  118. package/dist/types/ExecutiveDashboard/components/Insights/insightsUtils.d.ts.map +1 -1
  119. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.d.ts +54 -0
  120. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/CitationMarkdown.d.ts.map +1 -0
  121. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.d.ts +3 -2
  122. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/RcaDecisionComponent.d.ts.map +1 -1
  123. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/types.d.ts +15 -0
  124. package/dist/types/ExecutiveDashboard/components/RcaDecisionComponent/types.d.ts.map +1 -1
  125. package/dist/types/ExecutiveDashboard/components/Table/TableCard.d.ts +6 -1
  126. package/dist/types/ExecutiveDashboard/components/Table/TableCard.d.ts.map +1 -1
  127. package/dist/types/ExecutiveDashboard/types/index.d.ts +6 -0
  128. package/dist/types/ExecutiveDashboard/types/index.d.ts.map +1 -1
  129. package/dist/types/ExecutiveDashboard/types/insights.d.ts +20 -0
  130. package/dist/types/ExecutiveDashboard/types/insights.d.ts.map +1 -1
  131. package/dist/types/HumanIntelligence/HumanChangesTableWrapper.d.ts.map +1 -1
  132. package/dist/types/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.d.ts +2 -0
  133. package/dist/types/HumanIntelligence/components/CognitiveDecisioning/CognitiveDecisioning.d.ts.map +1 -1
  134. package/dist/types/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.d.ts +2 -0
  135. package/dist/types/HumanIntelligence/components/HumanIntelligenceCard/HumanIntelligenceCard.d.ts.map +1 -1
  136. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.d.ts +5 -0
  137. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/ReviewLearningConditionsModal.d.ts.map +1 -0
  138. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/parser.d.ts +20 -0
  139. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/parser.d.ts.map +1 -0
  140. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/types.d.ts +45 -0
  141. package/dist/types/HumanIntelligence/components/ReviewLearningConditionsModal/types.d.ts.map +1 -0
  142. package/dist/types/HumanIntelligence/hooks/accessToken.d.ts +13 -0
  143. package/dist/types/HumanIntelligence/hooks/accessToken.d.ts.map +1 -0
  144. package/dist/types/HumanIntelligence/hooks/useHumanChangesData.d.ts +12 -4
  145. package/dist/types/HumanIntelligence/hooks/useHumanChangesData.d.ts.map +1 -1
  146. package/dist/types/HumanIntelligence/utils/inlineMarkup.d.ts +2 -0
  147. package/dist/types/HumanIntelligence/utils/inlineMarkup.d.ts.map +1 -1
  148. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- import{__assign as e,__spreadArray as n,__awaiter as i,__generator as r}from"../../../_virtual/_tslib.js";import{jsx as a,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useState as o,useMemo as d,useEffect as c,useRef as u,useId as s}from"react";import{Info as v,Settings2 as p,Sparkles as g,TrendingUp as h,ArrowUpRight as m}from"lucide-react";import{ReasoningTrigger as f,ReasoningPanel as y,RcaDecisionComponent as b}from"../RcaDecisionComponent/RcaDecisionComponent.js";import k from"../Graph/LineChart.js";import _ from"../Graph/PlotBySelector.js";import{fetchInsightsCorrelation as N,toIsoDay as w,fetchInsightsCorrelationTrend as D,fetchGraphGroups as x,fetchLevelSummary as K,fetchInsightsDrivers as I,saveCorrelationWindow as C,fetchInsightsSeries as A,generateInsightsSummary as T,generateLevelSummary as S,fetchLevelRows as L}from"../../api/insightsApi.js";import{useInsights as P}from"./insightsContextCore.js";import{reportDecisioning as B,useOpenRow as j,toRcaItems as R,useInsightsFetch as O,periodName as F,previousPeriodLabel as M,useJob as G}from"./insightsUtils.js";import E from"./DrillTable.js";import W from"./DriverActivity.js";import{resolveL2SummaryRange as z,resolveDrillDay as U}from"./drillDay.js";import H from"./FilterNotice.js";import{SkeletonLines as Z,splitVerdict as $,movementVerdictLabel as q,verdictToneHex as V,movementColorHex as J,VerdictSentence as Q,ReportAccordion as X,CriticalityChip as Y,MovementChip as ee,DayOverDayChange as ne,ChartSkeleton as ie,CollapsibleVisualSection as re,formatHeaderDate as ae,SectionHeader as te,DaysDropdown as le,toneOf as oe}from"./agPrimitives.js";import{KpiPicker as de}from"./KpiChart.js";import ce,{useNeedsAttention as ue}from"./NeedsAttention.js";import{longPeriod as se,shortPeriod as ve}from"./insightsFormat.js";var pe=10;function ge(n){var l,d=this,c=n.entityKey,u=n.dataDay,s=P(),v=o(null),p=v[0],g=v[1],h=o(null),m=h[0],f=h[1];if(G(p,null!==(l=null==s?void 0:s.api)&&void 0!==l?l:null,function(){g(null),null==s||s.refresh()}),!(null==s?void 0:s.viewer.isAdmin))return null;return t("span",{children:[a("button",e({type:"button",className:"ins-link",disabled:Boolean(p),onClick:function(){return i(d,void 0,void 0,function(){var e,n,i,a;return r(this,function(r){switch(r.label){case 0:f(null),r.label=1;case 1:return r.trys.push([1,6,,7]),e={dataDay:u||w(s.range.endDate),window:"both"},c?[4,S(s.api,c,e)]:[3,3];case 2:return i=r.sent(),[3,5];case 3:return[4,T(s.api,e)];case 4:i=r.sent(),r.label=5;case 5:return(n=i).jobId?g(n.jobId):s.refresh(),[3,7];case 6:return a=r.sent(),f(a.message||"The summary couldn't be regenerated."),[3,7];case 7:return[2]}})})}},{children:p?"Regenerating…":"Regenerate summary"})),m?a("span",e({className:"ins-error"},{children:m})):null]})}var he=function(e){return e.replace(/\b\w/g,function(e){return e.toUpperCase()})};function me(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 fe(e,n,i){return i?null:me(e,n)}function ye(e){return e.replace(/\{\{([^|}]*)\|[^}]*\}\}/g,"$1")}function be(n){var i,r,l=n.report,u=n.movementType,s=n.direction,v=n.good,p=n.loading,g=n.error,h=o(!1),m=h[0],b=h[1],k=d(function(){return B(l)},[l]);if(c(function(){return b(!1)},[null==l?void 0:l.reportId]),p)return a("div",e({className:"ag-summary"},{children:a(Z,{widths:[28,96,72],label:"Loading summary"})}));var _=null==l?void 0:l.summary,N=null!==(i=null==_?void 0:_.headline)&&void 0!==i?i:"",w=Boolean(N),D=$(N).prefix,x=Boolean(null==_?void 0:_.eyebrow)&&"Movement unavailable"!==(null==_?void 0:_.eyebrow),K=void 0!==u,I=x?_.eyebrow:K?q(u,s):D||"Summary",C=x?"good"===_.tone||"bad"===_.tone?V(_.tone):J(_.movementType,_.movementDirection,v):K?J(u,s,v):"Good news"===D?"#15803D":"Bad news"===D?"#E11D48":"#5928ED";return t("div",e({className:"ag-summary"},{children:[a("p",e({className:"ag-summary__title",style:{color:w?C:"#64748b"}},{children:w?I:"No summary yet"})),t("div",e({className:"ag-summary__text"},{children:[w?a(Q,{text:N,good:v}):null!==(r=me(l,g))&&void 0!==r?r:"Reports are written after each morning run.",w&&k?a("span",e({className:"ag-summary__brain"},{children:a(f,{open:m,onToggle:function(){return b(function(e){return!e})},label:"how the AI reached this summary"})})):null]})),m&&k?a("div",e({className:"ag-summary__reasoning"},{children:a(y,{decisioning:k})})):null]}))}function ke(e){var n,i,r,t,l,o=e.report,c=e.error,u=e.loading,s=P(),v=!u&&"generated"===(null==o?void 0:o.status),p=d(function(){return v?B(o,null==o?void 0:o.footer):null},[v,o]),g=j();return a(b,{className:"ag-decision",title:null!==(n=null==s?void 0:s.labels.decisionAdvantageTitle)&&void 0!==n?n:"Decision Advantage",score:v?null==o?void 0:o.score:null,decisioning:p,notice:fe(o,c,u),afterSections:u?a(Z,{widths:[22,92,84,66,22,88,74],label:"Loading Decision Advantage"}):null,rootCause:v?R(null==o?void 0:o.rootCause,g,null===(i=null==s?void 0:s.decisionAdvantage)||void 0===i?void 0:i.rootCauseTags):[],rootCauseLayout:null===(r=null==s?void 0:s.decisionAdvantage)||void 0===r?void 0:r.rootCauseLayout,nextSteps:v?R(null==o?void 0:o.nextSteps,g):[],width:"100%",maxWidth:"none"},"".concat(null!==(t=null==o?void 0:o.reportId)&&void 0!==t?t:"pending",":").concat(null!==(l=null==o?void 0:o.generatedAt)&&void 0!==l?l:""))}var _e=[{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."}],Ne={drivers:"Nothing moved the day's way.",headwinds:"Nothing ran against the day.",attention:"No drivers for this day."},we={high:"High correlation",medium:"Medium correlation",low:"Low correlation",none:"No correlation"};function De(n){var i=n.on,r=n.onClick,l=n.disabled,o=void 0!==l&&l;return t("button",e({type:"button",className:"ag-graph-pill".concat(i?" is-on":""),disabled:o,title:o?"A graph can show up to ".concat(pe," rows"):void 0,onClick:function(e){e.stopPropagation(),r()}},{children:[a(h,{"aria-hidden":"true"}),i?"In graph":o?"Graph full":"Add to graph"]}))}function xe(n){var i=n.rank,r=n.category,l=n.name,o=n.chips,d=n.alignActivity,c=void 0!==d&&d,u=n.action,s=n.lines,v=n.cell,p=n.onOpen;return a("li",{children:t("div",e({className:"ag-driver".concat(c?" ag-driver--aligned":"").concat(p?" is-clickable":""),role:p?"button":void 0,tabIndex:p?0:void 0,onClick:p,onKeyDown:p?function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())}:void 0},{children:[t("div",e({className:"ag-driver__main"},{children:[t("span",e({className:"ag-driver__rank"},{children:[i,"."]})),t("div",e({className:"ag-driver__body"},{children:[t("div",e({className:"ag-driver__heading"},{children:[r?t("span",e({className:"ag-driver__category"},{children:[r," >"]})):null,t("div",e({className:"ag-driver__identity"},{children:[a("span",e({className:"ag-driver__name"},{children:l})),t("div",e({className:"ag-driver__chips"},{children:[o,u]}))]}))]})),s]}))]})),t("div",e({className:"ag-driver__cell"},{children:[v,p?a("span",e({className:"ag-driver__open","aria-hidden":"true"},{children:a(m,{})})):null]}))]}))})}function Ke(n){var i,r=n.label,l=n.rightLabel,o=n.children,d=P();return t("div",e({className:"ag-drivers"},{children:[t("div",e({className:"ag-drivers__head"},{children:[a("span",{children:r}),a("span",{children:null!==(i=null!=l?l:null==d?void 0:d.labels.activityColumn)&&void 0!==i?i:"User Activity"})]})),a("ol",{children:o})]}))}function Ie(n){var i,r,d,u,s,p,g,h,m,f,y,b,k,_=n.dataDay,N=n.entityKey,w=n.parentNodeKey,D=n.kpiId,x=n.title,K=n.graphed,C=n.onToggleGraph,A=n.onOpenDriver,T=n.onDecisionSettled,S=n.initialTab,L=void 0===S?"drivers":S,B=P(),j=o(L),R=j[0],G=j[1],E=o({drivers:1,headwinds:1,attention:1}),z=E[0],U=E[1],H=null!==(i=null!=D?D:null==B?void 0:B.headlineKpi)&&void 0!==i?i:void 0,Z=N||w||null===(u=null===(d=null===(r=null==B?void 0:B.decisionAdvantage)||void 0===r?void 0:r.topDrivers)||void 0===d?void 0:d.parts)||void 0===u?void 0:u.filter(Boolean),$=null!==(s=null==Z?void 0:Z.join(","))&&void 0!==s?s:"",q=function(e){return B&&H&&e===R?function(n){return I(B.api,{dataDay:_,kpiId:H,entityKey:N,parentNodeKey:w,tab:e,limit:Math.min(10,(w?10:3)*z[e]),offset:0,filters:B.range.filters,parts:(null==Z?void 0:Z.length)?Z:void 0},n)}:null},V=function(e){return[null==B?void 0:B.api.configId,null==B?void 0:B.rangeKey,_,H,N,w,e,R,z[e],null==B?void 0:B.revision,$]},J={drivers:O(q("drivers"),V("drivers")),headwinds:O(q("headwinds"),V("headwinds")),attention:O(q("attention"),V("attention"))},ie=J[R],re=ie.data,ae=ie.error,te=ie.loading,le=null!==(m=null!==(g=null===(p=J.drivers.data)||void 0===p?void 0:p.tabs)&&void 0!==g?g:null===(h=J.headwinds.data)||void 0===h?void 0:h.tabs)&&void 0!==m?m:null===(f=J.attention.data)||void 0===f?void 0:f.tabs,oe=ue(_,w,H),de=null!==(b=null===(y=oe.data)||void 0===y?void 0:y.counts.pending)&&void 0!==b?b:0;if(c(function(){return U({drivers:1,headwinds:1,attention:1})},[_]),c(function(){return G(L)},[L]),!B)return null;var se=B.goodDirection(null!=H?H:""),ve=null!==(k=null==re?void 0:re.rows)&&void 0!==k?k:[];return t(X,e({title:x},{children:[a("div",e({className:"ag-driver-tabs",role:"tablist","aria-label":"Driver views"},{children:_e.map(function(n){return a("button",e({type:"button",role:"tab","aria-selected":R===n.key,className:R===n.key?"is-active":void 0,onClick:function(){return G(n.key)},title:n.info},{children:t(l,{children:[B.labels[n.label],(null==le?void 0:le[n.key])?" (".concat(le[n.key].total,")"):"","attention"===n.key&&de?t("span",e({className:"ag-na__tab-badge",title:"".concat(de," data points need a decision")},{children:[de,a("span",e({className:"ins-visually-hidden"},{children:" data points need a decision"}))]})):null,a(v,{"aria-hidden":"true"})]})}),n.key)})})),"attention"===R?a(ce,{dataDay:_,nodeKey:w,kpiId:H,attention:oe,onDecisionSettled:T}):null,"attention"===R&&ve.length?a("h4",e({className:"ag-na__subhead"},{children:"Rows that moved without a clear cause"})):null,ae?t("p",e({className:"ag-muted"},{children:["Top drivers are unavailable right now: ",ae.message]})):te&&!re?a("p",e({className:"ag-muted"},{children:"Loading drivers..."})):ve.length?t(l,{children:[a(Ke,e({label:"Driver",rightLabel:B.labels.activityColumn},{children:ve.map(function(n){var i,r,o,d,c=n.deltaContributionPct,u=K.includes(n.nodeKey),s=(null===(i=n.decisionAdvantage)||void 0===i?void 0:i.correlationSentence)||(null===(r=n.decisionAdvantage)||void 0===r?void 0:r.firstCause)||(null===(o=n.decisionAdvantage)||void 0===o?void 0:o.headline);return a(xe,{alignActivity:!0,rank:n.rank,category:B.labels.driverCategory.replace("{plural}",n.entityKey?B.entityPluralName(n.entityKey):"").replace("{name}",n.entityKey?B.entityName(n.entityKey):""),name:n.label,chips:t(l,{children:[a(Y,{criticality:n.criticality}),a(ee,{movementType:n.movementType,direction:n.changeDirection,good:se})]}),action:C?a(De,{on:u,disabled:!u&&K.length>=pe,onClick:function(){return C(n)}}):void 0,lines:t(l,{children:[null!=c?t("span",e({className:"ag-driver__share"},{children:[B.labels.shareLine.replace("{share}",String(Math.abs(c))).replace("{period}",F(_,B.period.grain))," · ","opposite"===n.direction?B.labels.movedOpposite:B.labels.movedWith]})):null,t("span",e({className:"ag-driver__cost"},{children:[a("span",e({className:"ag-driver__total"},{children:B.formatKpi(H,n.value)})),null!=n.deltaPct?a("span",e({className:"ag-driver__sep"},{children:"|"})):null,a(ne,{deltaPct:n.deltaPct,good:se,direction:n.changeDirection,tone:n.tone,suffix:M(_,B.period.grain)})]})),s?a("p",e({className:"ag-driver__brief"},{children:a(Q,{text:ye(s),good:se,arrowsFollowVerdict:!0})})):null,(null===(d=n.decisionAdvantage)||void 0===d?void 0:d.nextStep)?t("p",e({className:"ag-driver__brief"},{children:[a("strong",{children:"Next:"})," ",ye(n.decisionAdvantage.nextStep)]})):null]}),cell:a(W,{driver:n,kpiId:null!=H?H:"",kpiLabel:B.kpiLabel,formatKpi:B.formatKpi}),onOpen:function(){var e;return A?A(n):B.openReport({reportId:null===(e=n.report)||void 0===e?void 0:e.reportId,nodeKey:n.nodeKey,kpiId:H,dataDay:_,title:n.label})}},n.nodeKey)})})),(null==re?void 0:re.hasMore)?a("div",e({className:"ag-more"},{children:a("button",e({type:"button",disabled:te,onClick:function(){return U(function(n){var i;return e(e({},n),((i={})[R]=n[R]+1,i))})}},{children:te?"Loading...":"Show more"}))})):null]}):a("p",e({className:"ag-muted"},{children:Ne[R]}))]}))}var Ce=["#4F46E5","#64748B","#0F766E","#7C3AED","#475569","#818CF8","#94A3B8"],Ae=function(e,n){void 0===n&&(n="en-GB");var i=e.slice(0,10).split("-").map(Number),r=i[0],a=i[1],t=i[2];return Number.isFinite(r)&&Number.isFinite(a)&&Number.isFinite(t)?new Intl.DateTimeFormat(n,{day:"numeric",month:"short"}).format(new Date(r,a-1,t)):e};function Te(s){var v,g,h,m,f,y,b,_,x,K,I,A,T=this,S=s.dataDay,L=s.nodeKey,B=void 0===L?"root":L,j=s.kpiId,R=s.dayGroup,F=P(),M=null!==(v=null!=j?j:null==F?void 0:F.headlineKpi)&&void 0!==v?v:void 0,E=o(""),W=E[0],z=E[1],U=o([]),H=U[0],Z=U[1],$=o({}),q=$[0],V=$[1],J=o(""),Q=J[0],X=J[1],Y=o(null),ee=Y[0],ne=Y[1],ae=o(null),te=ae[0],le=ae[1],oe=o(!1),ce=oe[0],ue=oe[1],pe=o(!1),ge=pe[0],he=pe[1],me=u(null),fe=O(F&&M&&S?function(n){return N(F.api,B,e({kpiId:M,dataDay:S,startDate:w(F.range.startDate),endDate:w(F.range.endDate),filters:F.range.filters},q),n)}:null,[null==F?void 0:F.api.configId,null==F?void 0:F.rangeKey,S,M,B,q.disregardBefore,null===(g=q.disregardDates)||void 0===g?void 0:g.join(","),null==F?void 0:F.revision]),ye=fe.data,be=fe.error,ke=fe.loading,_e=O(F&&M&&S?function(n){return D(F.api,B,e({kpiId:M,startDate:w(F.range.startDate),endDate:w(F.range.endDate),filters:F.range.filters},q),n)}:null,[null==F?void 0:F.api.configId,null==F?void 0:F.rangeKey,S,M,B,q.disregardBefore,null===(h=q.disregardDates)||void 0===h?void 0:h.join(","),null==F?void 0:F.revision]);G(te,null!==(m=null==F?void 0:F.api)&&void 0!==m?m:null,function(){le(null),X(""),null==F||F.refresh()}),c(function(){if(ce){var e=function(e){me.current&&!me.current.contains(e.target)&&ue(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[ce]);var Ne=o(new Set),De=Ne[0],xe=Ne[1],Ke=d(function(){if(!ye)return[];return ye.series.filter(function(e){return!(null==R?void 0:R.length)||R.map(Number).includes((n=e.x,new Date("".concat(n.slice(0,10),"T00:00:00")).getDay()||7));var n})},[ye,R]),Ie=d(function(){return ye?n([ye.kpiId],ye.drivers.map(function(e){return e.kpiId}).filter(function(e){return e!==ye.kpiId}),!0):[]},[ye]),Te=d(function(){return ye&&F?Ie.map(function(e,n){var i=Ke.map(function(n){var i,r;return n.disregarded?null:null!==(r=null===(i=n.values)||void 0===i?void 0:i[e])&&void 0!==r?r:null}),r=i.find(function(e){return"number"==typeof e&&0!==e});return{key:"corr_".concat(e.replace(/[^a-zA-Z0-9_]/g,"_")),label:F.kpiLabel(e),color:Ce[n%Ce.length],curve:"smooth",strokeWidth:2,pointRadius:2,data:Ke.map(function(e,n){return{x:e.x,y:null==i[n]||null==r?null:Math.round((i[n]-r)/Math.abs(r)*1e3)/10}}),valueFormatter:function(e){return"".concat(e,"%")}}}):[]},[ye,F,Ke,Ie]),Se=Boolean(null===(y=null===(f=null==F?void 0:F.decisionAdvantage)||void 0===f?void 0:f.trendChart)||void 0===y?void 0:y.dualAxis),Le=null===(_=null===(b=null==F?void 0:F.decisionAdvantage)||void 0===b?void 0:b.trendChart)||void 0===_?void 0:_.correlation,Pe=Math.max(1,Math.min(8,Number(null==Le?void 0:Le.maxKpis)||5)),Be=o(null),je=Be[0],Re=Be[1],Oe=o(new Set),Fe=Oe[0],Me=Oe[1],Ge=d(function(){var e,i;if(je)return je.filter(function(e){return Ie.includes(e)});var r=(null!==(e=null==Le?void 0:Le.defaultKpis)&&void 0!==e?e:[]).filter(function(e){return Ie.includes(e)});return(r.length?n([null!==(i=null==ye?void 0:ye.kpiId)&&void 0!==i?i:""],r.filter(function(e){return e!==(null==ye?void 0:ye.kpiId)}),!0):Ie.slice(0,2)).filter(Boolean).slice(0,Pe)},[je,Ie,null==Le?void 0:Le.defaultKpis,null==ye?void 0:ye.kpiId,Pe]);c(function(){return xe(new Set(Te.slice(2).map(function(e){return e.key})))},[Te]);if(!F||!S||"no_drivers"===(null==ye?void 0:ye.state)||ye&&!ye.verdictText)return null;if(be)return t("div",e({className:"ag-empty"},{children:["Correlation is unavailable right now: ",be.message]}));if(ke&&!ye)return a(ie,{height:220,label:"Loading correlation"});if(!ye)return null;var Ee=null!==(x=ye.strength)&&void 0!==x?x:"none",We="day"===F.period.grain?"today":"this ".concat(F.period.unit),ze=F.kpiLabel(ye.kpiId);return a(re,e({title:"Correlation",meta:F.labels.correlationTitle.replace("{kpi}",ze),className:"ag-visual--card",defaultExpanded:!1,action:F.viewer.isAdmin&&!Se?t("div",e({ref:me,className:"ag-corr__settings"},{children:[a("button",e({type:"button",className:"ag-icon-button","aria-label":"Correlation settings","aria-expanded":ce,onClick:function(){return ue(function(e){return!e})}},{children:a(p,{"aria-hidden":"true"})})),ce?a("div",e({className:"ag-corr__settings-menu",role:"menu"},{children:t("label",{children:[a("input",{type:"checkbox",checked:ge,onChange:function(e){return he(e.target.checked)}}),"Show date controls"]})})):null]})):null},{children:t("div",e({className:"ag-corr"},{children:[a("p",e({className:"ag-corr__banner ag-corr__banner--".concat(Ee)},{children:ye.verdictText})),a("span",e({className:"ag-driver__badge ag-driver__badge--".concat(Ee)},{children:we[Ee]})),a("p",e({className:"ag-corr__caption"},{children:F.labels.correlationSubtitle.replace("{kpi}",ze)})),(null===(K=ye.window)||void 0===K?void 0:K.source)?a("p",e({className:"ag-muted"},{children:"default"===ye.window.source?ye.window.startDate?"Using all ".concat(F.period.unit,"s since ").concat("day"===F.period.grain?Ae(ye.window.startDate,"en-US"):se(ye.window.startDate,F.period.grain)):"Using all available ".concat(F.period.unit,"s"):"row"===ye.window.source?"Saved window".concat(ye.window.startDate?" since ".concat(Ae(ye.window.startDate,"en-US")):"").concat((null===(I=ye.window.excludedDates)||void 0===I?void 0:I.length)?" · ".concat(ye.window.excludedDates.length," left out"):""):"Preview window".concat((null===(A=ye.window.excludedDates)||void 0===A?void 0:A.length)?" · ".concat(ye.window.excludedDates.length," left out"):"")})):null,t("div",e({className:"ag-chart"},{children:[a("div",e({className:"ellm-graph"},{children:a(k,{tier:"decision-advantage-correlation",series:Se?Te.filter(function(e){return Ge.some(function(n){return e.key==="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_"))})}):Te,hiddenKeys:Se?Fe:De,onToggleSeries:function(e){return xe(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},onPointClick:function(){},xAxis:{label:"day"===F.period.grain?"Date":se.axisTitle(F.period.grain),categories:Ke.map(function(e){return e.x}),formatTick:function(e){return ve(e,F.period.grain)}},yAxis:{label:"% change",beginAtZero:!1,formatTick:function(e){return"".concat(Math.round(Number(e)).toLocaleString("en-US"),"%")}},tooltip:{render:function(n){var i,r=n.x,l=n.points,o=String(r),d=null===(i=_e.data)||void 0===i?void 0:i.series.find(function(e){return e.x===o});return t("div",e({className:"ag-tip ag-tip--wide"},{children:[a("div",e({className:"ag-tip__head"},{children:"day"===F.period.grain?Ae(o):se(o,F.period.grain)})),l.filter(function(e){return null!=e.value}).map(function(n){return t("div",e({className:"ag-tip__line"},{children:[t("span",{children:[a("i",{style:{background:n.color}}),n.series.label]}),t("strong",{children:[n.value,"%"]})]}),n.series.key)}),d?Object.keys(d.r).map(function(n){var i,r;return t("div",e({className:"ag-tip__sub"},{children:[a("span",{children:F.kpiLabel(n)}),a("span",{children:null==d.r[n]?"No correlation":"r ".concat(d.r[n]," · ").concat(null!==(i=d.strength[n])&&void 0!==i?i:"none"," · ").concat(null!==(r=d.nObs[n])&&void 0!==r?r:0," ").concat(F.period.unit,"s")})]}),n)}):null]}))}},legend:Se?{show:!1}:{position:"bottom",toggle:!0},style:{chartHeight:220,yAxisWidth:Se?84:60,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}})})),Se?t("div",e({className:"kc__foot"},{children:[a("div",e({className:"kc__legend"},{children:Ge.map(function(n){var i="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_")),r=Fe.has(i);return t("label",e({className:"kc__legend-item".concat(r?" is-off":""),style:{"--kc-color":Ce[Ie.indexOf(n)%Ce.length]}},{children:[a("input",{type:"checkbox",checked:!r,onChange:function(){return Me(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n})}}),F.kpiLabel(n)]}),n)})})),a(de,{oneAxis:!0,selected:Ge,onChange:function(e){return Re(e.slice(0,Pe))},groups:[{label:"Correlated KPIs",kpis:Ie}],averageKpis:[],max:Pe,insights:F,colorOf:function(e){return Ce[Math.max(0,Ie.indexOf(e))%Ce.length]}})]})):null]})),a("div",e({className:"ag-corr__metrics"},{children:ye.drivers.map(function(n){var i,r=null!==(i=n.strength)&&void 0!==i?i:"none";return t("div",e({className:"ag-corr__metric"},{children:[a("span",e({className:"ag-corr__name"},{children:n.label||F.kpiLabel(n.kpiId)})),n.kpiId!==ye.kpiId?a("span",e({className:"ag-driver__badge ag-driver__badge--".concat(r)},{children:we[r]})):null,a("strong",{children:F.formatKpi(n.kpiId,n.value)}),a("span",e({className:"ag-corr__delta"},{children:null!=n.deltaPct?t(l,{children:[t("span",e({className:"ag-dod__value ag-dod__value--".concat(n.tone||"flat")},{children:["up"===n.direction?"↑":"down"===n.direction?"↓":"→"," ",Math.abs(n.deltaPct),"%"]}))," vs. ",F.formatKpi(n.kpiId,n.previous)]}):"—"})),n.kpiId!==ye.kpiId?t("span",e({className:"ag-corr__r"},{children:[n.nObs," ",F.period.unit,"s used",n.lowHistory?" · Low history":"",a("br",{}),null==n.movedWithToday?"No comparison for ".concat(We):n.movedWithToday?"Moved together with the headline ".concat(We):"Moved opposite the headline ".concat(We)]})):null]}),n.kpiId)})})),F.viewer.isAdmin&&ge?t("div",e({className:"ag-corr__window"},{children:[t("label",e({className:"ag-corr__start"},{children:["Ignore data before ",a("input",{type:"date",value:W,onChange:function(e){return z(e.target.value)}})]})),t("div",e({className:"ag-corr__days-label"},{children:["Or leave out individual dates (",H.length," selected)"]})),a("div",e({className:"ag-corr__days","aria-label":"Days to leave out"},{children:ye.series.map(function(i){return a("button",e({type:"button","aria-pressed":H.includes(i.x),className:H.includes(i.x)?"is-selected":void 0,onClick:function(){return e=i.x,Z(function(i){return i.includes(e)?i.filter(function(n){return n!==e}):n(n([],i,!0),[e],!1)});var e}},{children:Ae(i.x)}),i.x)})})),a("input",{className:"ag-corr__reason",value:Q,onChange:function(e){return X(e.target.value)},placeholder:"Reason required to apply"}),ee?a("p",e({className:"ins-error"},{children:ee})):null,t("div",e({className:"ag-corr__actions"},{children:[a("button",e({type:"button",className:"ins-link",onClick:function(){return V({disregardBefore:W||void 0,disregardDates:H})}},{children:"Preview"})),a("button",e({type:"button",className:"ins-button",disabled:Boolean(te),onClick:function(){return i(T,void 0,void 0,function(){var e,n;return r(this,function(i){switch(i.label){case 0:if(!F||!M||!Q.trim())return ne("A reason is required."),[2];ne(null),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,C(F.api,B,{kpiId:M,startDate:W||null,excludedDates:H,dataDay:S,changeReason:Q.trim(),regenerate:!0})];case 2:return e=i.sent(),le(e.jobId),[3,4];case 3:return n=i.sent(),ne(n.message||"The correlation window couldn't be saved."),[3,4];case 4:return[2]}})})}},{children:"Apply"})),a("button",e({type:"button",className:"ins-link",onClick:function(){z(""),Z([]),V({})}},{children:"Clear"}))]}))]})):null]}))}))}var Se=function(e){var n;return(null===(n=null==e?void 0:e.period)||void 0===n?void 0:n.end)||null};function Le(n){var i=n.kpis,r=n.value,t=n.onChange,l=P();return l&&i.length?a("div",e({className:"ag-plotby"},{children:a(_,{config:{options:i.map(function(e){return{label:l.kpiLabel(e),value:e}}),label:"Plot By",hideWhenSingle:!1,triggerIcon:null},value:r,onChange:t})})):null}function Pe(n){var i,r=n.entityKey,l=n.kpis,u=n.nodeKeys,s=n.workingDays,v=n.group,p=n.onOpenPoint,g=n.syncId,h=n.kpi,m=P(),f=o(null!==(i=l[0])&&void 0!==i?i:""),y=f[0],b=f[1];c(function(){var e;l.includes(y)||b(null!==(e=l[0])&&void 0!==e?e:"")},[l,y]);var _=void 0!==h&&l.includes(h)?h:y,N=O(m&&_&&null!==v&&0!==(null==u?void 0:u.length)?function(n){return A(m.api,e(e({},m.range),{workingDaysOnly:s,group:v||void 0}),u?{kpiIds:[_],nodeKeys:u.slice(0,pe)}:{kpiIds:[_],entityKey:r,topN:3},n)}:null,[null==m?void 0:m.api.configId,null==m?void 0:m.rangeKey,r,_,null==u?void 0:u.join(","),s,v,null==m?void 0:m.revision]),w=N.data,D=N.loading,x=N.error,K=d(function(){var e;return 0===(null==u?void 0:u.length)?[]:(null!==(e=null==w?void 0:w.series)&&void 0!==e?e:[]).filter(function(e){return e.kpiId===_&&e.points.some(function(e){return Number.isFinite(e.y)})})},[w,u,_]),I=o(new Set),C=I[0],T=I[1];c(function(){return T(new Set)},[K]);var S=d(function(){return Array.from(new Set(K.flatMap(function(e){return e.points.map(function(e){return e.x})}))).sort()},[K]),L=d(function(){return K.map(function(e,n){var i,r=new Map(e.points.map(function(e){return[e.x,e.y]})),a=null!==(i=null==m?void 0:m.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:S.map(function(e){var n;return{x:e,y:null!==(n=r.get(e))&&void 0!==n?n:null}}),valueFormatter:function(n){return m?m.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:J(n.meta.marker.movementType,n.meta.marker.direction,a),label:[n.meta.marker.criticality,n.meta.marker.headline].filter(Boolean).join(" · "),radius:3,haloRadius:3,onClick:function(){var i,r=null!==(i=e.label)&&void 0!==i?i:e.nodeKey;p?p({nodeKey:e.nodeKey,label:r,kpiId:e.kpiId,dataDay:n.x,reportId:n.meta.marker.reportId}):null==m||m.openReport(n.meta.marker.reportId?{reportId:n.meta.marker.reportId,title:"".concat(r," · ").concat(ve(n.x,null==m?void 0:m.period.grain))}:{nodeKey:e.nodeKey,kpiId:e.kpiId,dataDay:n.x,title:"".concat(r," · ").concat(ve(n.x,null==m?void 0:m.period.grain))})}}})}})},[K,S,m,p]);if(!m)return null;var B=m.kpiLabel(_);return t("div",e({className:"ag-row-trend"},{children:[l.length>1&&void 0===h?a("div",e({className:"ag-chart__switch",role:"group","aria-label":"Number"},{children:l.map(function(n){return a("button",e({type:"button","aria-pressed":n===_,className:n===_?"is-active":void 0,onClick:function(){return b(n)}},{children:m.kpiLabel(n)}),n)})})):null,x?a("div",e({className:"ag-empty"},{children:"This chart is unavailable right now."})):D?a(ie,{height:240,label:"Loading trend"}):S.length?a("div",e({className:"ag-chart"},{children:t("div",e({className:"ellm-graph"},{children:[a(k,{tier:"decision-advantage-".concat(r),syncId:g,syncMethod:"value",series:L,hiddenKeys:C,onToggleSeries:function(e){return T(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.size<L.length-1&&i.add(e),i})},onPointClick:function(e){var n,i,r,a,t,l,o=e.series,d=e.point,c=e.index,u=L.findIndex(function(e){return e.key===o.key}),s=K[u],v=null!==(n=d.x)&&void 0!==n?n:null===(i=o.data[c])||void 0===i?void 0:i.x,g=null==s?void 0:s.points.find(function(e){return e.x===String(v)});if(s&&g){var h=null!==(r=s.label)&&void 0!==r?r:s.nodeKey,f=null!==(l=null===(t=null===(a=g.meta)||void 0===a?void 0:a.marker)||void 0===t?void 0:t.reportId)&&void 0!==l?l:null;p?p({nodeKey:s.nodeKey,label:h,kpiId:s.kpiId,dataDay:g.x,reportId:f}):m.openReport(f?{reportId:f,title:"".concat(h," · ").concat(ve(g.x,m.period.grain))}:{nodeKey:s.nodeKey,kpiId:s.kpiId,dataDay:g.x,title:"".concat(h," · ").concat(ve(g.x,m.period.grain))})}},xAxis:{label:"day"===m.period.grain?"Date":se.axisTitle(m.period.grain),categories:S,tickCount:8,minTickGap:24,formatTick:function(e){return ve(e,m.period.grain)}},yAxis:{label:B,beginAtZero:!0,fitWidth:!0,formatTick:function(e){var n;return m.formatKpiAxis(null===(n=K[0])||void 0===n?void 0:n.kpiId,Number(e))}},tooltip:{formatHeading:function(e){return se(e,m.period.grain)}},legend:{show:!1},style:{chartHeight:240,yAxisWidth:70,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}}),a("div",e({className:"ellm-graph__legend ellm-chart__legend--bottom ellm-chart__legend--center"},{children:L.map(function(n){var i=C.has(n.key);return t("label",e({title:n.label,className:"ellm-graph__legend-item ag-legend-item".concat(i?" ellm-graph__legend-item--off":""),style:{cursor:"pointer","--checkbox-color":n.color,color:n.color}},{children:[a("input",{type:"checkbox",className:"ellm-graph__legend-checkbox",checked:!i,onChange:function(){return T(function(e){var i=new Set(e);return i.has(n.key)?i.delete(n.key):i.size<L.length-1&&i.add(n.key),i})},style:{borderColor:n.color,accentColor:n.color}}),a("span",{children:n.label})]}),n.key)})}))]}))})):a("div",e({className:"ag-empty"},{children:"Not enough history yet for a trend chart."}))]}))}function Be(d){var u,s=this,v=d.tab,p=d.partName,g=d.kpiIds,h=d.rankBy,m=d.search,f=d.graphed,y=d.onToggleGraph,b=d.onOpenRow,k=d.onFirstRow,_=d.onInitialGraph,N=d.fallbackDay,D=P(),x=Math.min(200,Math.max(1,Number(v.pageSize)||5)),K=o([]),I=K[0],C=K[1],A=o(null),T=A[0],S=A[1],B=o(!1),j=B[0],R=B[1],O=o({loading:!0,error:null}),F=O[0],M=O[1],G=o(),E=G[0],W=G[1],z=function(e,a){return i(s,void 0,void 0,function(){var i,t;return r(this,function(r){switch(r.label){case 0:if(!D)return[2];M({loading:!0,error:null}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,L(D.api,v.entityKey,D.range,{sort:h,order:"desc",search:m||void 0,pageSize:x,cursor:null!=e?e:void 0,includeChildren:3},a)];case 2:return i=r.sent(),(null==a?void 0:a.aborted)?[2]:(W(i.context),C(function(r){return e?n(n([],r,!0),i.rows,!0):i.rows}),S(i.nextCursor),R(i.hasNext),M({loading:!1,error:null}),[3,4]);case 3:return t=r.sent(),(null==a?void 0:a.aborted)||"AbortError"===(null==t?void 0:t.name)?[2]:(M({loading:!1,error:t.message||"Couldn't load the rows."}),[3,4]);case 4:return[2]}})})},U=null===(u=I[0])||void 0===u?void 0:u.nodeKey;c(function(){return null==k?void 0:k(U)},[U]);var $=I.slice(0,3).map(function(e){return e.nodeKey}),q=$.join("\0");if(c(function(){F.loading||null==_||_($)},[F.loading,q]),c(function(){var e=new AbortController;return z(null,e.signal),function(){return e.abort()}},[null==D?void 0:D.api.configId,null==D?void 0:D.rangeKey,v.entityKey,h,m,x,null==D?void 0:D.revision]),!D)return null;var V,J=D.goodDirection(h),Q=g.filter(function(e){return e!==h}).slice(0,2),ie=(V=p.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 a(X,e({title:"Top Drivers for ".concat(he(ie))},{children:F.error?a("p",e({className:"ag-muted"},{children:"Top drivers are unavailable right now."})):F.loading&&!I.length?a(Z,{widths:[80,60,85,55,75],label:"Loading drivers"}):I.length?t(l,{children:[a(H,{context:E}),a(Ke,e({label:he(p),rightLabel:"User Activity · selected dates"},{children:I.map(function(n){var i,r,o,d,c=null===(i=n.metrics)||void 0===i?void 0:i[h],u=n.label||n.nodeKey,s=f.includes(n.nodeKey);return a(xe,{rank:n.rank,name:u,chips:t(l,{children:[a(Y,{criticality:null===(r=n.chip)||void 0===r?void 0:r.criticality}),a(ee,{movementType:null===(o=n.chip)||void 0===o?void 0:o.movementType,direction:null===(d=n.chip)||void 0===d?void 0:d.direction,good:J})]}),action:a(De,{on:s,disabled:!s&&f.length>=pe,onClick:function(){return y(n.nodeKey)}}),lines:t("span",e({className:"ag-driver__cost"},{children:[t("span",e({className:"ag-driver__total"},{children:[D.formatKpi(h,null==c?void 0:c.value)," ",D.kpiLabel(h).toLowerCase()]})),null!=(null==c?void 0:c.deltaPct)?a("span",e({className:"ag-driver__sep"},{children:"|"})):null,a(ne,{deltaPct:null==c?void 0:c.deltaPct,good:J,direction:null==c?void 0:c.direction,tone:null==c?void 0:c.tone,suffix:"vs previous period"})]})),cell:Q.map(function(i){var r,l,o=null===(r=n.metrics)||void 0===r?void 0:r[i],d=null!==(l=null==o?void 0:o.tone)&&void 0!==l?l:oe(null==o?void 0:o.deltaPct,D.goodDirection(i)),c="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 t("span",e({className:"ag-driver__activity"},{children:[a("strong",e({className:"good"===d?"ag-text--good":"bad"===d?"ag-text--bad":void 0},{children:null==(null==o?void 0:o.deltaPct)?D.formatKpi(i,null==o?void 0:o.value):"".concat(c).concat(Math.abs(o.deltaPct),"%")})),a("span",{children:D.kpiLabel(i)})]}),i)}),onOpen:function(){var e;return b(n,h,N||(null===(e=n.chip)||void 0===e?void 0:e.dataDay)||w(D.range.endDate))}},n.nodeKey)})})),j?a("div",e({className:"ag-more"},{children:a("button",e({type:"button",disabled:F.loading,onClick:function(){return z(T)}},{children:F.loading?"Loading...":"Show more"}))})):null]}):a("p",e({className:"ag-muted"},{children:m?"No ".concat(ie," match “").concat(m,"”."):"No ".concat(ie," for this period yet.")}))}))}function je(i){var r,d,u,v,p,h,m,f,y,b,k,_,N,w,D,I,C,A,T=i.tab,S=i.title,L=i.partName,B=i.partKpis,j=i.search,R=i.dataDay,F=i.onOpenRow,M=i.headerAction,G=P(),W="decision-advantage-l2-".concat(s()),Z=o(null),$=Z[0],q=Z[1],V=o(null),J=V[0],Q=V[1],X=o(Boolean(null==G?void 0:G.defaultWorkingDays)),Y=X[0],ee=X[1],ne=O(G?function(e){return x(G.api,e)}:null,[null==G?void 0:G.api.configId,null==G?void 0:G.revision]),ie=o(null),oe=ie[0],de=ie[1];c(function(){var e,n;null===oe&&((null===(e=ne.data)||void 0===e?void 0:e.groups.length)?de((null!==(n=ne.data.groups.find(function(e){return e.isDefault}))&&void 0!==n?n:ne.data.groups[0]).groupKey):ne.loading||de(""))},[oe,ne.data,ne.loading]);var ce=o(null),ue=ce[0],se=ce[1],ve=o(),he=ve[0],me=ve[1],fe=!1!==T.showSummary,ye=null===(d=null===(r=ne.data)||void 0===r?void 0:r.groups.find(function(e){return e.groupKey===oe}))||void 0===d?void 0:d.days.map(Number),_e=(null==ye?void 0:ye.length)?ye.every(function(e){return e>=1&&e<=5}):Y||Boolean(null==G?void 0:G.range.workingDaysOnly),Ne=G?z(G.range,_e,R):null,we="".concat(null==G?void 0:G.api.configId,":").concat(null==G?void 0:G.rangeKey,":").concat(T.entityKey,":").concat(oe,":").concat(null==Ne?void 0:Ne.startDate.getTime(),":").concat(null==Ne?void 0:Ne.endDate.getTime(),":").concat(null==Ne?void 0:Ne.workingDaysOnly),De=O(G&&Ne&&fe&&null!==oe?function(e){return K(G.api,T.entityKey,Ne,e)}:null,[we,fe,null==G?void 0:G.revision],we);if(!G)return null;var xe=(null===(u=T.listKpis)||void 0===u?void 0:u.length)?T.listKpis:B,Ke=T.rankBy&&xe.includes(T.rankBy)?T.rankBy:null!==(v=xe[0])&&void 0!==v?v:"",Ie=null===(p=De.data)||void 0===p?void 0:p.report,Ce=Se(null===(h=De.data)||void 0===h?void 0:h.context),Ae=U({endDate:G.range.endDate,workingDays:_e,selectedDay:R,reportDay:Ce}),je=function(n){return R||_e?e(e({},n),{report:e(e({},n.report),{reportId:null})}):n},Re=G.goodDirection(Ke),Oe=null!==(m=T.tier1Kpis)&&void 0!==m?m:G.tierKpis[1],Fe=null!==(f=T.tier2Kpis)&&void 0!==f?f:G.tierKpis[2],Me=$&&Oe.includes($)?$:null!==(y=Oe[0])&&void 0!==y?y:"",Ge=J&&Fe.includes(J)?J:null!==(b=Fe[0])&&void 0!==b?b:"",Ee=G.headlineKpi||Ke||Oe[0]||"",We=function(e){var n=e.nodeKey,i=e.label,r=e.dataDay;return F({rank:0,nodeKey:n,label:i,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:Ee},action:null,children:[]},Ee,r)},ze=G.drill.tabTables[T.entityKey],Ue=ze?a(E,{table:e(e({},ze),{pageSize:null!==(_=null!==(k=ze.pageSize)&&void 0!==k?k:T.pageSize)&&void 0!==_?_:void 0}),tabEntityKey:T.entityKey,context:{trail:[],day:Ae},onRowClick:function(e,n){var i;return"report"===n?G.openReport({reportId:je(e).report.reportId,nodeKey:e.nodeKey,kpiId:Ke,dataDay:Ae,title:null!==(i=e.label)&&void 0!==i?i:e.nodeKey}):"drill"===n?F(je(e),Ke,Ae):void 0}}):null;return t("section",e({className:"ag-report","aria-label":"L2 Report · ".concat(S)},{children:[t("div",e({className:"ag-report__header"},{children:[t("h2",e({className:"ag-report__title"},{children:[a(g,{"aria-hidden":"true"}),"L2 Report"]})),a("span",e({className:"ag-report__scope"},{children:S})),Ce?a("span",e({className:"ag-report__date"},{children:ae(Ce)})):null,M?a("div",e({className:"ag-report__header-action"},{children:M})):null]})),t("div",e({className:"ag-report__grid ag-report__grid--l2"},{children:[a("div",e({className:"ag-report__analysis-scroll",role:"region","aria-label":"".concat(S," analysis"),tabIndex:0},{children:t("div",e({className:"ag-stack"},{children:[fe?t(l,{children:[t("div",{children:[a(te,{title:"Summary",action:a(ge,{entityKey:T.entityKey,dataDay:Ce})}),a(be,{report:Ie,loading:De.loading,error:De.error,good:Re})]}),a(ke,{report:Ie,error:De.error,loading:De.loading}),a(H,{context:null===(N=De.data)||void 0===N?void 0:N.context})]}):null,xe.length?a(Be,{tab:T,partName:L,kpiIds:xe,rankBy:Ke,search:j,graphed:null!=ue?ue:[],onToggleGraph:function(e){return se(function(i){var r=null!=i?i:[];return r.includes(e)?r.filter(function(n){return n!==e}):r.length<pe?n(n([],r,!0),[e],!1):r})},onOpenRow:function(e,n,i){return F(je(e),n,i)},onFirstRow:me,onInitialGraph:function(e){return se(function(n){return null!=n?n:e})},fallbackDay:Ae}):null]}))})),t("div",e({className:"ag-stack"},{children:[Oe.length?a(re,e({title:"Trend",action:t("div",e({className:"ag-visual__actions"},{children:[a(Le,{kpis:Oe,value:Me,onChange:q}),a(le,{value:Y,onChange:ee,groups:ne.error||null===(w=ne.data)||void 0===w?void 0:w.groups,group:oe,onGroupChange:de})]}))},{children:a(Pe,{entityKey:T.entityKey,kpis:Oe,kpi:Me,nodeKeys:ue,workingDays:Y,group:oe,onOpenPoint:We,syncId:W})})):null,Fe.length?a(re,e({title:G.labels.activityTitle,action:a("div",e({className:"ag-visual__actions"},{children:a(Le,{kpis:Fe,value:Ge,onChange:Q})}))},{children:a(Pe,{entityKey:T.entityKey,kpis:Fe,kpi:Ge,nodeKeys:ue,workingDays:Y,group:oe,onOpenPoint:We,syncId:W})})):null,a(Te,{dataDay:Ce,nodeKey:null!==(D=null==ue?void 0:ue[0])&&void 0!==D?D:he,dayGroup:null===(C=null===(I=ne.data)||void 0===I?void 0:I.groups.find(function(e){return e.groupKey===oe}))||void 0===C?void 0:C.days}),"column"===(null==ze?void 0:ze.width)?Ue:null]}))]})),ze&&"full"===(null!==(A=ze.width)&&void 0!==A?A:"full")?Ue:null]}))}export{De as AddToGraph,Te as CorrelationSection,ke as DecisionCard,Ke as DriverList,xe as DriverRow,je as L2Report,pe as MAX_SERIES,Le as PlotByKpi,ge as RegenerateSummary,Be as RowDrivers,Pe as RowTrend,be as SummaryCard,Ie as TopDriversSection,fe as decisionCardNotice,Se as reportDayOf,ye as stripRowTags,he as titleCase};
1
+ import{__assign as e,__spreadArray as n,__awaiter as i,__generator as r}from"../../../_virtual/_tslib.js";import{jsx as t,jsxs as a,Fragment as l}from"react/jsx-runtime";import{useState as o,useMemo as d,useEffect as c,useCallback as u,useRef as s,useId as v}from"react";import{Info as p,Settings2 as g,Sparkles as h,TrendingUp as m,ArrowUpRight as f}from"lucide-react";import{ReasoningTrigger as y,ReasoningPanel as b,RcaDecisionComponent as k}from"../RcaDecisionComponent/RcaDecisionComponent.js";import _ from"../Graph/LineChart.js";import N from"../Graph/PlotBySelector.js";import{toIsoDay as w,fetchInsightsCorrelation as x,fetchInsightsCorrelationTrend as D,fetchGraphGroups as K,fetchLevelSummary as I,fetchInsightsDrivers as C,saveCorrelationWindow as A,fetchInsightsSeries as T,generateInsightsSummary as S,generateLevelSummary as L,fetchLevelRows as B}from"../../api/insightsApi.js";import{useInsights as P}from"./insightsContextCore.js";import{insightsErrorText as j}from"./insightsErrors.js";import{reportDecisioning as O,useOpenRow as R,toRcaItems as F,useInsightsFetch as M,periodName as E,previousPeriodLabel as G,useJob as W}from"./insightsUtils.js";import{longPeriod as z,shortPeriod as H,periodInRange as U,periodStart as Z}from"./insightsFormat.js";import V from"./DrillTable.js";import $ from"./DriverActivity.js";import{resolveL2SummaryRange as q,resolveDrillDay as J}from"./drillDay.js";import Q from"./FilterNotice.js";import{SkeletonLines as X,splitVerdict as Y,movementVerdictLabel as ee,verdictToneHex as ne,movementColorHex as ie,VerdictSentence as re,ReportAccordion as te,CriticalityChip as ae,MovementChip as le,DayOverDayChange as oe,ChartSkeleton as de,CollapsibleVisualSection as ce,periodHeading as ue,SectionHeader as se,DaysDropdown as ve,toneOf as pe}from"./agPrimitives.js";import{chartColors as ge,KpiPicker as he}from"./KpiChart.js";import me,{useNeedsAttention as fe}from"./NeedsAttention.js";var ye=10;function be(n){var l,d=this,c=n.entityKey,u=n.dataDay,s=P(),v=o(null),p=v[0],g=v[1],h=o(null),m=h[0],f=h[1];if(W(p,null!==(l=null==s?void 0:s.api)&&void 0!==l?l:null,function(){g(null),null==s||s.refresh()}),!(null==s?void 0:s.viewer.isAdmin))return null;return a("span",{children:[t("button",e({type:"button",className:"ins-link",disabled:Boolean(p),onClick:function(){return i(d,void 0,void 0,function(){var e,n,i,t;return r(this,function(r){switch(r.label){case 0:f(null),r.label=1;case 1:return r.trys.push([1,6,,7]),e={dataDay:u||Z(w(s.range.endDate),s.period.grain),window:"both"},c?[4,L(s.api,c,e)]:[3,3];case 2:return i=r.sent(),[3,5];case 3:return[4,S(s.api,e)];case 4:i=r.sent(),r.label=5;case 5:return(n=i).jobId?g(n.jobId):s.refresh(),[3,7];case 6:return t=r.sent(),f(j(t,"The summary couldn't be regenerated.")),[3,7];case 7:return[2]}})})}},{children:p?"Regenerating…":"Regenerate summary"})),m?t("span",e({className:"ins-error"},{children:m})):null]})}var ke=function(e){return e.replace(/\b\w/g,function(e){return e.toUpperCase()})};function _e(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 Ne(e,n,i){return i?null:_e(e,n)}function we(e){return e.replace(/\{\{([^|}]*)\|[^}]*\}\}/g,"$1")}function xe(n){var i,r,l,u=n.report,s=n.movementType,v=n.direction,p=n.good,g=n.loading,h=n.error,m=n.emptyText,f=o(!1),k=f[0],_=f[1],N=d(function(){return O(u)},[u]);if(c(function(){return _(!1)},[null==u?void 0:u.reportId]),g)return t("div",e({className:"ag-summary"},{children:t(X,{widths:[28,96,72],label:"Loading summary"})}));var w=null==u?void 0:u.summary,x=null!==(i=null==w?void 0:w.headline)&&void 0!==i?i:"",D=Boolean(x),K=Y(x).prefix,I=Boolean(null==w?void 0:w.eyebrow)&&"Movement unavailable"!==(null==w?void 0:w.eyebrow),C=void 0!==s,A=I?w.eyebrow:C?ee(s,v):K||"Summary",T=I?"good"===w.tone||"bad"===w.tone?ne(w.tone):ie(w.movementType,w.movementDirection,p):C?ie(s,v,p):"Good news"===K?"#15803D":"Bad news"===K?"#E11D48":"#5928ED";return a("div",e({className:"ag-summary"},{children:[t("p",e({className:"ag-summary__title",style:{color:D?T:"#64748b"}},{children:D?A:"No summary yet"})),a("div",e({className:"ag-summary__text"},{children:[D?t(re,{text:x,good:p,citations:null===(r=null==w?void 0:w.cited)||void 0===r?void 0:r.citation,excelDisplay:"popup",excelHover:!0}):null!==(l=null!=m?m:_e(u,h))&&void 0!==l?l:"Reports are written after each morning run.",D&&N?t("span",e({className:"ag-summary__brain"},{children:t(y,{open:k,onToggle:function(){return _(function(e){return!e})},label:"how the AI reached this summary"})})):null]})),k&&N?t("div",e({className:"ag-summary__reasoning"},{children:t(b,{decisioning:N})})):null]}))}function De(e){var n,i,r,a,l,o=e.report,c=e.error,u=e.loading,s=e.emptyText,v=P(),p=!u&&"generated"===(null==o?void 0:o.status),g=d(function(){return p?O(o,null==o?void 0:o.footer):null},[p,o]),h=R();return t(k,{className:"ag-decision",title:null!==(n=null==v?void 0:v.labels.decisionAdvantageTitle)&&void 0!==n?n:"Decision Advantage",score:p?null==o?void 0:o.score:null,decisioning:g,notice:u||o||!s?Ne(o,c,u):s,afterSections:u?t(X,{widths:[22,92,84,66,22,88,74],label:"Loading Decision Advantage"}):null,rootCause:p?F(null==o?void 0:o.rootCause,h,null===(i=null==v?void 0:v.decisionAdvantage)||void 0===i?void 0:i.rootCauseTags):[],rootCauseLayout:null===(r=null==v?void 0:v.decisionAdvantage)||void 0===r?void 0:r.rootCauseLayout,nextSteps:p?F(null==o?void 0:o.nextSteps,h):[],excelHover:!0,autoScrollToCitedCell:!0,width:"100%",maxWidth:"none"},"".concat(null!==(a=null==o?void 0:o.reportId)&&void 0!==a?a:"pending",":").concat(null!==(l=null==o?void 0:o.generatedAt)&&void 0!==l?l:""))}var Ke=[{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."}],Ie={drivers:"Nothing moved the day's way.",headwinds:"Nothing ran against the day.",attention:"No drivers for this day."},Ce={high:"High correlation",medium:"Medium correlation",low:"Low correlation",none:"No correlation"};function Ae(n){var i=n.on,r=n.onClick,l=n.disabled,o=void 0!==l&&l;return a("button",e({type:"button",className:"ag-graph-pill".concat(i?" is-on":""),disabled:o,title:o?"A graph can show up to ".concat(ye," rows"):void 0,onClick:function(e){e.stopPropagation(),r()}},{children:[t(m,{"aria-hidden":"true"}),i?"In graph":o?"Graph full":"Add to graph"]}))}function Te(n){var i=n.rank,r=n.category,l=n.name,o=n.chips,d=n.alignActivity,c=void 0!==d&&d,u=n.action,s=n.lines,v=n.cell,p=n.onOpen;return t("li",{children:a("div",e({className:"ag-driver".concat(c?" ag-driver--aligned":"").concat(p?" is-clickable":""),role:p?"button":void 0,tabIndex:p?0:void 0,onClick:p,onKeyDown:p?function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())}:void 0},{children:[a("div",e({className:"ag-driver__main"},{children:[a("span",e({className:"ag-driver__rank"},{children:[i,"."]})),a("div",e({className:"ag-driver__body"},{children:[a("div",e({className:"ag-driver__heading"},{children:[r?a("span",e({className:"ag-driver__category"},{children:[r," >"]})):null,a("div",e({className:"ag-driver__identity"},{children:[t("span",e({className:"ag-driver__name"},{children:l})),a("div",e({className:"ag-driver__chips"},{children:[o,u]}))]}))]})),s]}))]})),a("div",e({className:"ag-driver__cell"},{children:[v,p?t("span",e({className:"ag-driver__open","aria-hidden":"true"},{children:t(f,{})})):null]}))]}))})}function Se(n){var i,r=n.label,l=n.rightLabel,o=n.children,d=P();return a("div",e({className:"ag-drivers"},{children:[a("div",e({className:"ag-drivers__head"},{children:[t("span",{children:r}),t("span",{children:null!==(i=null!=l?l:null==d?void 0:d.labels.activityColumn)&&void 0!==i?i:"User Activity"})]})),t("ol",{children:o})]}))}function Le(n){var i,r,d,u,s,v,g,h,m,f,y,b,k,_=n.dataDay,N=n.entityKey,w=n.parentNodeKey,x=n.kpiId,D=n.title,K=n.graphed,I=n.onToggleGraph,A=n.onOpenDriver,T=n.onDecisionSettled,S=n.initialTab,L=void 0===S?"drivers":S,B=P(),j=o(L),O=j[0],R=j[1],F=o({drivers:1,headwinds:1,attention:1}),W=F[0],z=F[1],H=null!==(i=null!=x?x:null==B?void 0:B.headlineKpi)&&void 0!==i?i:void 0,U=N||w||null===(u=null===(d=null===(r=null==B?void 0:B.decisionAdvantage)||void 0===r?void 0:r.topDrivers)||void 0===d?void 0:d.parts)||void 0===u?void 0:u.filter(Boolean),Z=null!==(s=null==U?void 0:U.join(","))&&void 0!==s?s:"",V=function(e){return B&&H&&e===O?function(n){return C(B.api,{dataDay:_,kpiId:H,entityKey:N,parentNodeKey:w,tab:e,limit:Math.min(10,(w?10:3)*W[e]),offset:0,filters:B.range.filters,parts:(null==U?void 0:U.length)?U:void 0},n)}:null},q=function(e){return[null==B?void 0:B.api.configId,null==B?void 0:B.rangeKey,_,H,N,w,e,O,W[e],null==B?void 0:B.revision,Z]},J={drivers:M(V("drivers"),q("drivers")),headwinds:M(V("headwinds"),q("headwinds")),attention:M(V("attention"),q("attention"))},Q=J[O],X=Q.data,Y=Q.error,ee=Q.loading,ne=null!==(m=null!==(g=null===(v=J.drivers.data)||void 0===v?void 0:v.tabs)&&void 0!==g?g:null===(h=J.headwinds.data)||void 0===h?void 0:h.tabs)&&void 0!==m?m:null===(f=J.attention.data)||void 0===f?void 0:f.tabs,ie=fe(_,w,H),de=null!==(b=null===(y=ie.data)||void 0===y?void 0:y.counts.pending)&&void 0!==b?b:0;if(c(function(){return z({drivers:1,headwinds:1,attention:1})},[_]),c(function(){return R(L)},[L]),!B)return null;var ce=B.goodDirection(null!=H?H:""),ue=null!==(k=null==X?void 0:X.rows)&&void 0!==k?k:[];return a(te,e({title:D},{children:[t("div",e({className:"ag-driver-tabs",role:"tablist","aria-label":"Driver views"},{children:Ke.map(function(n){return t("button",e({type:"button",role:"tab","aria-selected":O===n.key,className:O===n.key?"is-active":void 0,onClick:function(){return R(n.key)},title:n.info},{children:a(l,{children:[B.labels[n.label],(null==ne?void 0:ne[n.key])?" (".concat(ne[n.key].total,")"):"","attention"===n.key&&de?a("span",e({className:"ag-na__tab-badge",title:"".concat(de," data points need a decision")},{children:[de,t("span",e({className:"ins-visually-hidden"},{children:" data points need a decision"}))]})):null,t(p,{"aria-hidden":"true"})]})}),n.key)})})),"attention"===O?t(me,{dataDay:_,nodeKey:w,kpiId:H,attention:ie,onDecisionSettled:T}):null,"attention"===O&&ue.length?t("h4",e({className:"ag-na__subhead"},{children:"Rows that moved without a clear cause"})):null,Y?a("p",e({className:"ag-muted"},{children:["Top drivers are unavailable right now: ",Y.message]})):ee&&!X?t("p",e({className:"ag-muted"},{children:"Loading drivers..."})):ue.length?a(l,{children:[t(Se,e({label:"Driver",rightLabel:B.labels.activityColumn},{children:ue.map(function(n){var i,r,o,d,c=n.deltaContributionPct,u=K.includes(n.nodeKey),s=(null===(i=n.decisionAdvantage)||void 0===i?void 0:i.correlationSentence)||(null===(r=n.decisionAdvantage)||void 0===r?void 0:r.firstCause)||(null===(o=n.decisionAdvantage)||void 0===o?void 0:o.headline);return t(Te,{alignActivity:!0,rank:n.rank,category:B.labels.driverCategory.replace("{plural}",n.entityKey?B.entityPluralName(n.entityKey):"").replace("{name}",n.entityKey?B.entityName(n.entityKey):""),name:n.label,chips:a(l,{children:[t(ae,{criticality:n.criticality}),t(le,{movementType:n.movementType,direction:n.changeDirection,good:ce})]}),action:I?t(Ae,{on:u,disabled:!u&&K.length>=ye,onClick:function(){return I(n)}}):void 0,lines:a(l,{children:[null!=c?a("span",e({className:"ag-driver__share"},{children:[B.labels.shareLine.replace("{share}",String(Math.abs(c))).replace("{period}",E(_,B.period.grain))," · ","opposite"===n.direction?B.labels.movedOpposite:B.labels.movedWith]})):null,a("span",e({className:"ag-driver__cost"},{children:[t("span",e({className:"ag-driver__total"},{children:B.formatKpi(H,n.value)})),null!=n.deltaPct?t("span",e({className:"ag-driver__sep"},{children:"|"})):null,t(oe,{deltaPct:n.deltaPct,good:ce,direction:n.changeDirection,tone:n.tone,suffix:G(_,B.period.grain)})]})),s?t("p",e({className:"ag-driver__brief"},{children:t(re,{text:we(s),good:ce,arrowsFollowVerdict:!0})})):null,(null===(d=n.decisionAdvantage)||void 0===d?void 0:d.nextStep)?a("p",e({className:"ag-driver__brief"},{children:[t("strong",{children:"Next:"})," ",we(n.decisionAdvantage.nextStep)]})):null]}),cell:t($,{driver:n,kpiId:null!=H?H:"",kpiLabel:B.kpiLabel,formatKpi:B.formatKpi}),onOpen:function(){var e;return A?A(n):B.openReport({reportId:null===(e=n.report)||void 0===e?void 0:e.reportId,nodeKey:n.nodeKey,kpiId:H,dataDay:_,title:n.label})}},n.nodeKey)})})),(null==X?void 0:X.hasMore)?t("div",e({className:"ag-more"},{children:t("button",e({type:"button",disabled:ee,onClick:function(){return z(function(n){var i;return e(e({},n),((i={})[O]=n[O]+1,i))})}},{children:ee?"Loading...":"Show more"}))})):null]}):t("p",e({className:"ag-muted"},{children:Ie[O]}))]}))}var Be=["#4F46E5","#64748B","#0F766E","#7C3AED","#475569","#818CF8","#94A3B8"],Pe=function(e,n){void 0===n&&(n="en-GB");var i=e.slice(0,10).split("-").map(Number),r=i[0],t=i[1],a=i[2];return Number.isFinite(r)&&Number.isFinite(t)&&Number.isFinite(a)?new Intl.DateTimeFormat(n,{day:"numeric",month:"short"}).format(new Date(r,t-1,a)):e};function je(v){var p,h,m,f,y,b,k,N,K,I,C,T,S,L,B,O=this,R=v.dataDay,F=v.nodeKey,E=void 0===F?"root":F,G=v.kpiId,U=v.dayGroup,Z=P(),V=null!==(p=null!=G?G:null==Z?void 0:Z.headlineKpi)&&void 0!==p?p:void 0,$=d(function(){var e,n;return ge(null===(e=null==Z?void 0:Z.decisionAdvantage)||void 0===e?void 0:e.trendChart,Object.keys(null!==(n=null==Z?void 0:Z.kpis)&&void 0!==n?n:{}))},[null===(h=null==Z?void 0:Z.decisionAdvantage)||void 0===h?void 0:h.trendChart,null==Z?void 0:Z.kpis]),q=$.configured||Boolean(null===(f=null===(m=null==Z?void 0:Z.decisionAdvantage)||void 0===m?void 0:m.trendChart)||void 0===f?void 0:f.dualAxis),J=u(function(e,n){return q?$.kpi(e):Be[Math.max(0,n)%Be.length]},[q,$]),Q=o(""),X=Q[0],Y=Q[1],ee=o([]),ne=ee[0],ie=ee[1],re=o({}),te=re[0],ae=re[1],le=o(""),oe=le[0],ue=le[1],se=o(null),ve=se[0],pe=se[1],me=o(null),fe=me[0],ye=me[1],be=o(!1),ke=be[0],_e=be[1],Ne=o(!1),we=Ne[0],xe=Ne[1],De=s(null),Ke=Z?w(Z.range.startDate):"",Ie=R&&Ke>R?R:Ke,Ae=M(Z&&V&&R?function(n){return x(Z.api,E,e({kpiId:V,dataDay:R,startDate:Ie,endDate:w(Z.range.endDate),filters:Z.range.filters},te),n)}:null,[null==Z?void 0:Z.api.configId,null==Z?void 0:Z.rangeKey,R,V,E,te.disregardBefore,null===(y=te.disregardDates)||void 0===y?void 0:y.join(","),null==Z?void 0:Z.revision]),Te=Ae.data,Se=Ae.error,Le=Ae.loading,je=M(Z&&V&&R?function(n){return D(Z.api,E,e({kpiId:V,startDate:w(Z.range.startDate),endDate:w(Z.range.endDate),filters:Z.range.filters},te),n)}:null,[null==Z?void 0:Z.api.configId,null==Z?void 0:Z.rangeKey,R,V,E,te.disregardBefore,null===(b=te.disregardDates)||void 0===b?void 0:b.join(","),null==Z?void 0:Z.revision]);W(fe,null!==(k=null==Z?void 0:Z.api)&&void 0!==k?k:null,function(){ye(null),ue(""),null==Z||Z.refresh()}),c(function(){if(ke){var e=function(e){De.current&&!De.current.contains(e.target)&&_e(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}},[ke]);var Oe=o(new Set),Re=Oe[0],Fe=Oe[1],Me=d(function(){if(!Te)return[];return Te.series.filter(function(e){return!(null==U?void 0:U.length)||U.map(Number).includes((n=e.x,new Date("".concat(n.slice(0,10),"T00:00:00")).getDay()||7));var n})},[Te,U]),Ee=d(function(){return Te?n([Te.kpiId],Te.drivers.map(function(e){return e.kpiId}).filter(function(e){return e!==Te.kpiId}),!0):[]},[Te]),Ge=d(function(){return Te&&Z?Ee.map(function(e,n){var i=Me.map(function(n){var i,r;return n.disregarded?null:null!==(r=null===(i=n.values)||void 0===i?void 0:i[e])&&void 0!==r?r:null}),r=i.find(function(e){return"number"==typeof e&&0!==e});return{key:"corr_".concat(e.replace(/[^a-zA-Z0-9_]/g,"_")),label:Z.kpiLabel(e),color:J(e,n),curve:"smooth",strokeWidth:2,pointRadius:2,data:Me.map(function(e,n){return{x:e.x,y:null==i[n]||null==r?null:Math.round((i[n]-r)/Math.abs(r)*1e3)/10}}),valueFormatter:function(e){return"".concat(e,"%")}}}):[]},[Te,Z,Me,Ee,J]),We=Boolean(null===(K=null===(N=null==Z?void 0:Z.decisionAdvantage)||void 0===N?void 0:N.trendChart)||void 0===K?void 0:K.dualAxis),ze=null===(C=null===(I=null==Z?void 0:Z.decisionAdvantage)||void 0===I?void 0:I.trendChart)||void 0===C?void 0:C.correlation,He=Math.max(1,Math.min(8,Number(null==ze?void 0:ze.maxKpis)||5)),Ue=o(null),Ze=Ue[0],Ve=Ue[1],$e=o(new Set),qe=$e[0],Je=$e[1],Qe=d(function(){var e,i;if(Ze)return Ze.filter(function(e){return Ee.includes(e)});var r=(null!==(e=null==ze?void 0:ze.defaultKpis)&&void 0!==e?e:[]).filter(function(e){return Ee.includes(e)});return(r.length?n([null!==(i=null==Te?void 0:Te.kpiId)&&void 0!==i?i:""],r.filter(function(e){return e!==(null==Te?void 0:Te.kpiId)}),!0):Ee.slice(0,2)).filter(Boolean).slice(0,He)},[Ze,Ee,null==ze?void 0:ze.defaultKpis,null==Te?void 0:Te.kpiId,He]);c(function(){return Fe(new Set(Ge.slice(2).map(function(e){return e.key})))},[Ge]);if(!Z||!R||"no_drivers"===(null==Te?void 0:Te.state)||Te&&!Te.verdictText)return null;if(Se)return a("div",e({className:"ag-empty"},{children:["Correlation is unavailable right now: ",Se.message]}));if(Le&&!Te)return t(de,{height:220,label:"Loading correlation"});if(!Te)return null;var Xe=null!==(T=Te.strength)&&void 0!==T?T:"none",Ye="day"===Z.period.grain?"today":"this ".concat(Z.period.unit),en=Z.kpiLabel(Te.kpiId);return t(ce,e({title:"Correlation",meta:Z.labels.correlationTitle.replace("{kpi}",en),className:"ag-visual--card",defaultExpanded:!1,action:Z.viewer.isAdmin&&!We?a("div",e({ref:De,className:"ag-corr__settings"},{children:[t("button",e({type:"button",className:"ag-icon-button","aria-label":"Correlation settings","aria-expanded":ke,onClick:function(){return _e(function(e){return!e})}},{children:t(g,{"aria-hidden":"true"})})),ke?t("div",e({className:"ag-corr__settings-menu",role:"menu"},{children:a("label",{children:[t("input",{type:"checkbox",checked:we,onChange:function(e){return xe(e.target.checked)}}),"Show date controls"]})})):null]})):null},{children:a("div",e({className:"ag-corr"},{children:[t("p",e({className:"ag-corr__banner ag-corr__banner--".concat(Xe)},{children:Te.verdictText})),t("span",e({className:"ag-driver__badge ag-driver__badge--".concat(Xe)},{children:Ce[Xe]})),t("p",e({className:"ag-corr__caption"},{children:Z.labels.correlationSubtitle.replace("{kpi}",en)})),(null===(S=Te.window)||void 0===S?void 0:S.source)?t("p",e({className:"ag-muted"},{children:"default"===Te.window.source?Te.window.startDate?"Using all ".concat(Z.period.unit,"s since ").concat("day"===Z.period.grain?Pe(Te.window.startDate,"en-US"):z(Te.window.startDate,Z.period.grain)):"Using all available ".concat(Z.period.unit,"s"):"row"===Te.window.source?"Saved window".concat(Te.window.startDate?" since ".concat(Pe(Te.window.startDate,"en-US")):"").concat((null===(L=Te.window.excludedDates)||void 0===L?void 0:L.length)?" · ".concat(Te.window.excludedDates.length," left out"):""):"Preview window".concat((null===(B=Te.window.excludedDates)||void 0===B?void 0:B.length)?" · ".concat(Te.window.excludedDates.length," left out"):"")})):null,a("div",e({className:"ag-chart"},{children:[t("div",e({className:"ellm-graph"},{children:t(_,{tier:"decision-advantage-correlation",series:We?Ge.filter(function(e){return Qe.some(function(n){return e.key==="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_"))})}):Ge,hiddenKeys:We?qe:Re,onToggleSeries:function(e){return Fe(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.add(e),i})},onPointClick:function(){},xAxis:{label:"day"===Z.period.grain?"Date":z.axisTitle(Z.period.grain),categories:Me.map(function(e){return e.x}),formatTick:function(e){return H(e,Z.period.grain)}},yAxis:{label:"% change",beginAtZero:!1,formatTick:function(e){return"".concat(Math.round(Number(e)).toLocaleString("en-US"),"%")}},tooltip:{render:function(n){var i,r=n.x,l=n.points,o=String(r),d=null===(i=je.data)||void 0===i?void 0:i.series.find(function(e){return e.x===o});return a("div",e({className:"ag-tip ag-tip--wide"},{children:[t("div",e({className:"ag-tip__head"},{children:"day"===Z.period.grain?Pe(o):z(o,Z.period.grain)})),l.filter(function(e){return null!=e.value}).map(function(n){return a("div",e({className:"ag-tip__line"},{children:[a("span",{children:[t("i",{style:{background:n.color}}),n.series.label]}),a("strong",{children:[n.value,"%"]})]}),n.series.key)}),d?Object.keys(d.r).map(function(n){var i,r;return a("div",e({className:"ag-tip__sub"},{children:[t("span",{children:Z.kpiLabel(n)}),t("span",{children:null==d.r[n]?"No correlation":"r ".concat(d.r[n]," · ").concat(null!==(i=d.strength[n])&&void 0!==i?i:"none"," · ").concat(null!==(r=d.nObs[n])&&void 0!==r?r:0," ").concat(Z.period.unit,"s")})]}),n)}):null]}))}},legend:We?{show:!1}:{position:"bottom",toggle:!0},style:{chartHeight:220,yAxisWidth:We?84:60,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}})})),We?a("div",e({className:"kc__foot"},{children:[t("div",e({className:"kc__legend"},{children:Qe.map(function(n){var i="corr_".concat(n.replace(/[^a-zA-Z0-9_]/g,"_")),r=qe.has(i);return a("label",e({className:"kc__legend-item".concat(r?" is-off":""),style:{"--kc-color":J(n,Ee.indexOf(n))}},{children:[t("input",{type:"checkbox",checked:!r,onChange:function(){return Je(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n})}}),Z.kpiLabel(n)]}),n)})})),t(he,{oneAxis:!0,selected:Qe,onChange:function(e){return Ve(e.slice(0,He))},groups:[{label:"Correlated KPIs",kpis:Ee}],averageKpis:[],max:He,insights:Z,colorOf:function(e){return J(e,Ee.indexOf(e))}})]})):null]})),t("div",e({className:"ag-corr__metrics"},{children:Te.drivers.map(function(n){var i,r=null!==(i=n.strength)&&void 0!==i?i:"none";return a("div",e({className:"ag-corr__metric"},{children:[t("span",e({className:"ag-corr__name"},{children:n.label||Z.kpiLabel(n.kpiId)})),n.kpiId!==Te.kpiId?t("span",e({className:"ag-driver__badge ag-driver__badge--".concat(r)},{children:Ce[r]})):null,t("strong",{children:Z.formatKpi(n.kpiId,n.value)}),t("span",e({className:"ag-corr__delta"},{children:null!=n.deltaPct?a(l,{children:[a("span",e({className:"ag-dod__value ag-dod__value--".concat(n.tone||"flat")},{children:["up"===n.direction?"↑":"down"===n.direction?"↓":"→"," ",Math.abs(n.deltaPct),"%"]}))," vs. ",Z.formatKpi(n.kpiId,n.previous)]}):"—"})),n.kpiId!==Te.kpiId?a("span",e({className:"ag-corr__r"},{children:[n.nObs," ",Z.period.unit,"s used",n.lowHistory?" · Low history":"",t("br",{}),null==n.movedWithToday?"No comparison for ".concat(Ye):n.movedWithToday?"Moved together with the headline ".concat(Ye):"Moved opposite the headline ".concat(Ye)]})):null]}),n.kpiId)})})),Z.viewer.isAdmin&&we?a("div",e({className:"ag-corr__window"},{children:[a("label",e({className:"ag-corr__start"},{children:["Ignore data before ",t("input",{type:"date",value:X,onChange:function(e){return Y(e.target.value)}})]})),a("div",e({className:"ag-corr__days-label"},{children:["Or leave out individual dates (",ne.length," selected)"]})),t("div",e({className:"ag-corr__days","aria-label":"Days to leave out"},{children:Te.series.map(function(i){return t("button",e({type:"button","aria-pressed":ne.includes(i.x),className:ne.includes(i.x)?"is-selected":void 0,onClick:function(){return e=i.x,ie(function(i){return i.includes(e)?i.filter(function(n){return n!==e}):n(n([],i,!0),[e],!1)});var e}},{children:Pe(i.x)}),i.x)})})),t("input",{className:"ag-corr__reason",value:oe,onChange:function(e){return ue(e.target.value)},placeholder:"Reason required to apply"}),ve?t("p",e({className:"ins-error"},{children:ve})):null,a("div",e({className:"ag-corr__actions"},{children:[t("button",e({type:"button",className:"ins-link",onClick:function(){return ae({disregardBefore:X||void 0,disregardDates:ne})}},{children:"Preview"})),t("button",e({type:"button",className:"ins-button",disabled:Boolean(fe),onClick:function(){return i(O,void 0,void 0,function(){var e,n;return r(this,function(i){switch(i.label){case 0:if(!Z||!V||!oe.trim())return pe("A reason is required."),[2];pe(null),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,A(Z.api,E,{kpiId:V,startDate:X||null,excludedDates:ne,dataDay:R,changeReason:oe.trim(),regenerate:!0})];case 2:return e=i.sent(),ye(e.jobId),[3,4];case 3:return n=i.sent(),pe(j(n,"The correlation window couldn't be saved.")),[3,4];case 4:return[2]}})})}},{children:"Apply"})),t("button",e({type:"button",className:"ins-link",onClick:function(){Y(""),ie([]),ae({})}},{children:"Clear"}))]}))]})):null]}))}))}var Oe=function(e){var n;return(null===(n=null==e?void 0:e.period)||void 0===n?void 0:n.end)||null};function Re(e,n){var i,r;return"day"!==n.period.grain&&(!("generated"!==(null===(i=null==e?void 0:e.report)||void 0===i?void 0:i.status)||!(null===(r=e.context)||void 0===r?void 0:r.period))&&!U(e.context.period,w(n.range.startDate),w(n.range.endDate),n.period.grain))}function Fe(e,n){var i,r,t=(null===(i=null==e?void 0:e.period)||void 0===i?void 0:i.label)||ue(null===(r=null==e?void 0:e.period)||void 0===r?void 0:r.end,n);return t?"No report in the selected dates. The latest one is for ".concat(t,"."):"No report in the selected dates."}function Me(n){var i=n.kpis,r=n.value,a=n.onChange,l=P();return l&&i.length?t("div",e({className:"ag-plotby"},{children:t(N,{config:{options:i.map(function(e){return{label:l.kpiLabel(e),value:e}}),label:"Plot By",hideWhenSingle:!1,triggerIcon:null},value:r,onChange:a})})):null}var Ee=["#06B6D4","#10A66A","#8650FF","#F59E0B","#E94BBD","#4285FF","#64748B","#F04444","#14B8A6","#84CC16"];function Ge(n){var i,r,l=n.entityKey,u=n.kpis,s=n.nodeKeys,v=n.workingDays,p=n.group,g=n.onOpenPoint,h=n.syncId,m=n.kpi,f=P(),y=o(null!==(i=u[0])&&void 0!==i?i:""),b=y[0],k=y[1];c(function(){var e;u.includes(b)||k(null!==(e=u[0])&&void 0!==e?e:"")},[u,b]);var N=void 0!==m&&u.includes(m)?m:b,w=M(f&&N&&null!==p&&0!==(null==s?void 0:s.length)?function(n){return T(f.api,e(e({},f.range),{workingDaysOnly:v,group:p||void 0}),s?{kpiIds:[N],nodeKeys:s.slice(0,ye)}:{kpiIds:[N],entityKey:l,topN:3},n)}:null,[null==f?void 0:f.api.configId,null==f?void 0:f.rangeKey,l,N,null==s?void 0:s.join(","),v,p,null==f?void 0:f.revision]),x=w.data,D=w.loading,K=w.error,I=d(function(){var e;return 0===(null==s?void 0:s.length)?[]:(null!==(e=null==x?void 0:x.series)&&void 0!==e?e:[]).filter(function(e){return e.kpiId===N&&e.points.some(function(e){return Number.isFinite(e.y)})})},[x,s,N]),C=o(new Set),A=C[0],S=C[1],L=o({}),B=L[0],j=L[1];c(function(){S(new Set),j({})},[I]);var O=function(e){return S(function(n){var i=new Set(n);return i.has(e)?i.delete(e):i.size<I.length-1&&i.add(e),i})},R=d(function(){return Array.from(new Set(I.flatMap(function(e){return e.points.map(function(e){return e.x})}))).sort()},[I]),F=d(function(){var e,n;return ge(null===(e=null==f?void 0:f.decisionAdvantage)||void 0===e?void 0:e.trendChart,Object.keys(null!==(n=null==f?void 0:f.kpis)&&void 0!==n?n:{}))},[null===(r=null==f?void 0:f.decisionAdvantage)||void 0===r?void 0:r.trendChart,null==f?void 0:f.kpis]),E=F.configured?F.rows:Ee,G=d(function(){return I.map(function(e,n){var i,r,t=new Map(e.points.map(function(e){return[e.x,e.y]})),a=null!==(i=null==f?void 0:f.goodDirection(e.kpiId))&&void 0!==i?i:"up",l="row_".concat(n,"_").concat(e.nodeKey.replace(/[^a-zA-Z0-9_]/g,"_")),o=E[n%E.length];return{key:l,label:e.label||e.nodeKey,color:o,curve:"smooth",pointRadius:3,activePointRadius:3,fillPointsOnHover:!0,showValueLabels:null!==(r=B[l])&&void 0!==r&&r,valueLabelColor:o,data:R.map(function(e){var n;return{x:e,y:null!==(n=t.get(e))&&void 0!==n?n:null}}),valueFormatter:function(n){return f?f.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:ie(n.meta.marker.movementType,n.meta.marker.direction,a),label:[n.meta.marker.criticality,n.meta.marker.headline].filter(Boolean).join(" · "),radius:3,haloRadius:3,onClick:function(){var i,r=null!==(i=e.label)&&void 0!==i?i:e.nodeKey;g?g({nodeKey:e.nodeKey,label:r,kpiId:e.kpiId,dataDay:n.x,reportId:n.meta.marker.reportId}):null==f||f.openReport(n.meta.marker.reportId?{reportId:n.meta.marker.reportId,title:"".concat(r," · ").concat(H(n.x,null==f?void 0:f.period.grain))}:{nodeKey:e.nodeKey,kpiId:e.kpiId,dataDay:n.x,title:"".concat(r," · ").concat(H(n.x,null==f?void 0:f.period.grain))})}}})}})},[I,R,f,g,E,B]);if(!f)return null;var W=f.kpiLabel(N);return a("div",e({className:"ag-row-trend"},{children:[u.length>1&&void 0===m?t("div",e({className:"ag-chart__switch",role:"group","aria-label":"Number"},{children:u.map(function(n){return t("button",e({type:"button","aria-pressed":n===N,className:n===N?"is-active":void 0,onClick:function(){return k(n)}},{children:f.kpiLabel(n)}),n)})})):null,K?t("div",e({className:"ag-empty"},{children:"This chart is unavailable right now."})):D||null===p&&0!==(null==s?void 0:s.length)?t(de,{height:240,label:"Loading trend"}):0===(null==s?void 0:s.length)?t("div",e({className:"ag-empty"},{children:"Use “Add to graph” on a row to draw it here."})):R.length?t("div",e({className:"ag-chart"},{children:a("div",e({className:"ellm-graph"},{children:[t(_,{tier:"decision-advantage-".concat(l),syncId:h,syncMethod:"value",series:G,hiddenKeys:A,onToggleSeries:O,onPointClick:function(e){var n,i,r,t,a,l,o=e.series,d=e.point,c=e.index,u=G.findIndex(function(e){return e.key===o.key}),s=I[u],v=null!==(n=d.x)&&void 0!==n?n:null===(i=o.data[c])||void 0===i?void 0:i.x,p=null==s?void 0:s.points.find(function(e){return e.x===String(v)});if(s&&p){var h=null!==(r=s.label)&&void 0!==r?r:s.nodeKey,m=null!==(l=null===(a=null===(t=p.meta)||void 0===t?void 0:t.marker)||void 0===a?void 0:a.reportId)&&void 0!==l?l:null;g?g({nodeKey:s.nodeKey,label:h,kpiId:s.kpiId,dataDay:p.x,reportId:m}):f.openReport(m?{reportId:m,title:"".concat(h," · ").concat(H(p.x,f.period.grain))}:{nodeKey:s.nodeKey,kpiId:s.kpiId,dataDay:p.x,title:"".concat(h," · ").concat(H(p.x,f.period.grain))})}},xAxis:{label:"day"===f.period.grain?"Date":z.axisTitle(f.period.grain),categories:R,tickCount:8,minTickGap:24,formatTick:function(e){return H(e,f.period.grain)}},yAxis:{label:W,beginAtZero:!0,fitWidth:!0,formatTick:function(e){var n;return f.formatKpiAxis(null===(n=I[0])||void 0===n?void 0:n.kpiId,Number(e))}},tooltip:{formatHeading:function(e){return z(e,f.period.grain)}},legend:{show:!1},style:{chartHeight:240,yAxisWidth:70,gridColor:"#e2e8f0",axisColor:"#cbd5e1",axisLabelColor:"#64748b",tickColor:"#64748b"}}),t("div",e({className:"kc__foot"},{children:t("div",e({className:"kc__legend"},{children:G.map(function(n){var i=A.has(n.key),r=Boolean(n.showValueLabels);return a("div",e({className:"kc__legend-item ag-legend-item".concat(i?" is-off":""),style:{"--kc-color":n.color}},{children:[t("input",{type:"checkbox",checked:r&&!i,disabled:i,onChange:function(){return j(function(i){var t;return e(e({},i),((t={})[n.key]=!r,t))})},"aria-label":"Numbers on ".concat(n.label),title:r?"Hide the numbers on this line":"Show the numbers on this line"}),a("button",e({type:"button",className:"kc__legend-series","aria-pressed":!i,onClick:function(){return O(n.key)},title:i?"Show ".concat(n.label):"Hide ".concat(n.label)},{children:[t("i",{className:"kc__legend-line","aria-hidden":"true"}),t("span",{children:n.label})]}))]}),n.key)})}))}))]}))})):t("div",e({className:"ag-empty"},{children:"No data in the selected dates."}))]}))}function We(d){var u,s=this,v=d.tab,p=d.partName,g=d.kpiIds,h=d.rankBy,m=d.search,f=d.graphed,y=d.onToggleGraph,b=d.onOpenRow,k=d.onFirstRow,_=d.onInitialGraph,N=d.fallbackDay,x=P(),D=Math.min(200,Math.max(1,Number(v.pageSize)||5)),K=o([]),I=K[0],C=K[1],A=o(null),T=A[0],S=A[1],L=o(!1),j=L[0],O=L[1],R=o({loading:!0,error:null}),F=R[0],M=R[1],E=o(),G=E[0],W=E[1],z=function(e,t){return i(s,void 0,void 0,function(){var i,a;return r(this,function(r){switch(r.label){case 0:if(!x)return[2];M({loading:!0,error:null}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,B(x.api,v.entityKey,x.range,{sort:h,order:"desc",search:m||void 0,pageSize:D,cursor:null!=e?e:void 0,includeChildren:3},t)];case 2:return i=r.sent(),(null==t?void 0:t.aborted)?[2]:(W(i.context),C(function(r){return e?n(n([],r,!0),i.rows,!0):i.rows}),S(i.nextCursor),O(i.hasNext),M({loading:!1,error:null}),[3,4]);case 3:return a=r.sent(),(null==t?void 0:t.aborted)||"AbortError"===(null==a?void 0:a.name)?[2]:(M({loading:!1,error:a.message||"Couldn't load the rows."}),[3,4]);case 4:return[2]}})})},H=null===(u=I[0])||void 0===u?void 0:u.nodeKey;c(function(){return null==k?void 0:k(H)},[H]);var U=I.slice(0,3).map(function(e){return e.nodeKey}),V=U.join("\0");if(c(function(){F.loading||F.error||!U.length||null==_||_(U)},[F.loading,F.error,V]),c(function(){var e=new AbortController;return z(null,e.signal),function(){return e.abort()}},[null==x?void 0:x.api.configId,null==x?void 0:x.rangeKey,v.entityKey,h,m,D,null==x?void 0:x.revision]),!x)return null;var $,q=x.goodDirection(h),J=g.filter(function(e){return e!==h}).slice(0,2),Y=($=p.trim().toLowerCase())?/(s|x|ch|sh)$/.test($)?"".concat($,"es"):/[^aeiou]y$/.test($)?"".concat($.slice(0,-1),"ies"):"".concat($,"s"):"rows";return t(te,e({title:"Top Drivers for ".concat(ke(Y))},{children:F.error?t("p",e({className:"ag-muted"},{children:"Top drivers are unavailable right now."})):F.loading&&!I.length?t(X,{widths:[80,60,85,55,75],label:"Loading drivers"}):I.length?a(l,{children:[t(Q,{context:G}),t(Se,e({label:ke(p),rightLabel:"User Activity · selected dates"},{children:I.map(function(n){var i,r,o,d,c=null===(i=n.metrics)||void 0===i?void 0:i[h],u=n.label||n.nodeKey,s=f.includes(n.nodeKey);return t(Te,{rank:n.rank,name:u,chips:a(l,{children:[t(ae,{criticality:null===(r=n.chip)||void 0===r?void 0:r.criticality}),t(le,{movementType:null===(o=n.chip)||void 0===o?void 0:o.movementType,direction:null===(d=n.chip)||void 0===d?void 0:d.direction,good:q})]}),action:t(Ae,{on:s,disabled:!s&&f.length>=ye,onClick:function(){return y(n.nodeKey)}}),lines:a("span",e({className:"ag-driver__cost"},{children:[a("span",e({className:"ag-driver__total"},{children:[x.formatKpi(h,null==c?void 0:c.value)," ",x.kpiLabel(h).toLowerCase()]})),null!=(null==c?void 0:c.deltaPct)?t("span",e({className:"ag-driver__sep"},{children:"|"})):null,t(oe,{deltaPct:null==c?void 0:c.deltaPct,good:q,direction:null==c?void 0:c.direction,tone:null==c?void 0:c.tone,suffix:"vs previous period"})]})),cell:J.map(function(i){var r,l,o=null===(r=n.metrics)||void 0===r?void 0:r[i],d=null!==(l=null==o?void 0:o.tone)&&void 0!==l?l:pe(null==o?void 0:o.deltaPct,x.goodDirection(i)),c="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 a("span",e({className:"ag-driver__activity"},{children:[t("strong",e({className:"good"===d?"ag-text--good":"bad"===d?"ag-text--bad":void 0},{children:null==(null==o?void 0:o.deltaPct)?x.formatKpi(i,null==o?void 0:o.value):"".concat(c).concat(Math.abs(o.deltaPct),"%")})),t("span",{children:x.kpiLabel(i)})]}),i)}),onOpen:function(){var e;return b(n,h,N||(null===(e=n.chip)||void 0===e?void 0:e.dataDay)||Z(w(x.range.endDate),x.period.grain))}},n.nodeKey)})})),j?t("div",e({className:"ag-more"},{children:t("button",e({type:"button",disabled:F.loading,onClick:function(){return z(T)}},{children:F.loading?"Loading...":"Show more"}))})):null]}):t("p",e({className:"ag-muted"},{children:m?"No ".concat(Y," match “").concat(m,"”."):"No ".concat(Y," for this period yet.")}))}))}function ze(i){var r,d,u,s,p,g,m,f,y,b,k,_,N,w,x,D,C,A,T,S,L=i.tab,B=i.title,j=i.partName,O=i.partKpis,R=i.search,F=i.dataDay,E=i.onOpenRow,G=i.headerAction,W=P(),z="decision-advantage-l2-".concat(v()),H=o(null),U=H[0],Z=H[1],$=o(null),X=$[0],Y=$[1],ee=o(Boolean(null==W?void 0:W.defaultWorkingDays)),ne=ee[0],ie=ee[1],re=M(W?function(e){return K(W.api,e)}:null,[null==W?void 0:W.api.configId,null==W?void 0:W.revision]),te=o(null),ae=te[0],le=te[1];c(function(){var e,n;null===ae&&((null===(e=re.data)||void 0===e?void 0:e.groups.length)?le((null!==(n=re.data.groups.find(function(e){return e.isDefault}))&&void 0!==n?n:re.data.groups[0]).groupKey):re.loading||le(""))},[ae,re.data,re.loading]);var oe=o(null),de=oe[0],pe=oe[1],ge=o(),he=ge[0],me=ge[1],fe=!1!==L.showSummary,ke=null===(d=null===(r=re.data)||void 0===r?void 0:r.groups.find(function(e){return e.groupKey===ae}))||void 0===d?void 0:d.days.map(Number),_e=null!==(u=null==W?void 0:W.period.grain)&&void 0!==u?u:"day",Ne="day"===_e&&((null==ke?void 0:ke.length)?ke.every(function(e){return e>=1&&e<=5}):ne||Boolean(null==W?void 0:W.range.workingDaysOnly)),we=W?q(W.range,Ne,F,void 0,_e):null,Ke="".concat(null==W?void 0:W.api.configId,":").concat(null==W?void 0:W.rangeKey,":").concat(L.entityKey,":").concat(ae,":").concat(null==we?void 0:we.startDate.getTime(),":").concat(null==we?void 0:we.endDate.getTime(),":").concat(null==we?void 0:we.workingDaysOnly),Ie=M(W&&we&&fe&&null!==ae?function(e){return I(W.api,L.entityKey,we,e)}:null,[Ke,fe,null==W?void 0:W.revision],Ke);if(!W)return null;var Ce=(null===(s=L.listKpis)||void 0===s?void 0:s.length)?L.listKpis:O,Ae=L.rankBy&&Ce.includes(L.rankBy)?L.rankBy:null!==(p=Ce[0])&&void 0!==p?p:"",Te=!F&&Re(Ie.data,W),Se=Te||null===(g=Ie.data)||void 0===g?void 0:g.report,Le=Te?null:Oe(null===(m=Ie.data)||void 0===m?void 0:m.context),Be=Te?Fe(null===(f=Ie.data)||void 0===f?void 0:f.context,_e):null,Pe=J({endDate:W.range.endDate,workingDays:Ne,selectedDay:F,reportDay:Le,grain:_e}),Ee=function(n){return F||Ne?e(e({},n),{report:e(e({},n.report),{reportId:null})}):n},ze=W.goodDirection(Ae),He=null!==(y=L.tier1Kpis)&&void 0!==y?y:W.tierKpis[1],Ue=null!==(b=L.tier2Kpis)&&void 0!==b?b:W.tierKpis[2],Ze=U&&He.includes(U)?U:null!==(k=He[0])&&void 0!==k?k:"",Ve=X&&Ue.includes(X)?X:null!==(_=Ue[0])&&void 0!==_?_:"",$e=W.headlineKpi||Ae||He[0]||"",qe=function(e){var n=e.nodeKey,i=e.label,r=e.dataDay;return E({rank:0,nodeKey:n,label:i,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:$e},action:null,children:[]},$e,r)},Je=W.drill.tabTables[L.entityKey],Qe=Je?t(V,{table:e(e({},Je),{pageSize:null!==(w=null!==(N=Je.pageSize)&&void 0!==N?N:L.pageSize)&&void 0!==w?w:void 0}),tabEntityKey:L.entityKey,context:{trail:[],day:Pe},onRowClick:function(e,n){var i;return"report"===n?W.openReport({reportId:Ee(e).report.reportId,nodeKey:e.nodeKey,kpiId:Ae,dataDay:Pe,title:null!==(i=e.label)&&void 0!==i?i:e.nodeKey}):"drill"===n?E(Ee(e),Ae,Pe):void 0}}):null;return a("section",e({className:"ag-report","aria-label":"L2 Report · ".concat(B)},{children:[a("div",e({className:"ag-report__header"},{children:[a("h2",e({className:"ag-report__title"},{children:[t(h,{"aria-hidden":"true"}),"L2 Report"]})),t("span",e({className:"ag-report__scope"},{children:B})),Le?t("span",e({className:"ag-report__date"},{children:ue(Le,_e)})):null,G?t("div",e({className:"ag-report__header-action"},{children:G})):null]})),a("div",e({className:"ag-report__grid ag-report__grid--l2"},{children:[t("div",e({className:"ag-report__analysis-scroll",role:"region","aria-label":"".concat(B," analysis"),tabIndex:0},{children:a("div",e({className:"ag-stack"},{children:[fe?a(l,{children:[a("div",{children:[t(se,{title:"Summary",action:t(be,{entityKey:L.entityKey,dataDay:Le})}),t(xe,{report:Se,loading:Ie.loading,error:Ie.error,good:ze,emptyText:Be})]}),t(De,{report:Se,error:Ie.error,loading:Ie.loading,emptyText:Be}),t(Q,{context:null===(x=Ie.data)||void 0===x?void 0:x.context})]}):null,Ce.length?t(We,{tab:L,partName:j,kpiIds:Ce,rankBy:Ae,search:R,graphed:null!=de?de:[],onToggleGraph:function(e){return pe(function(i){var r=null!=i?i:[];return r.includes(e)?r.filter(function(n){return n!==e}):r.length<ye?n(n([],r,!0),[e],!1):r})},onOpenRow:function(e,n,i){return E(Ee(e),n,i)},onFirstRow:me,onInitialGraph:function(e){return pe(function(n){return null!=n?n:e})},fallbackDay:Pe}):null]}))})),a("div",e({className:"ag-stack"},{children:[He.length?t(ce,e({title:"Trend",action:a("div",e({className:"ag-visual__actions"},{children:[t(Me,{kpis:He,value:Ze,onChange:Z}),t(ve,{value:ne,onChange:ie,groups:re.error||null===(D=re.data)||void 0===D?void 0:D.groups,group:ae,onGroupChange:le})]}))},{children:t(Ge,{entityKey:L.entityKey,kpis:He,kpi:Ze,nodeKeys:de,workingDays:ne,group:ae,onOpenPoint:qe,syncId:z})})):null,Ue.length?t(ce,e({title:W.labels.activityTitle,action:t("div",e({className:"ag-visual__actions"},{children:t(Me,{kpis:Ue,value:Ve,onChange:Y})}))},{children:t(Ge,{entityKey:L.entityKey,kpis:Ue,kpi:Ve,nodeKeys:de,workingDays:ne,group:ae,onOpenPoint:qe,syncId:z})})):null,t(je,{dataDay:Le,nodeKey:null!==(C=null==de?void 0:de[0])&&void 0!==C?C:he,dayGroup:null===(T=null===(A=re.data)||void 0===A?void 0:A.groups.find(function(e){return e.groupKey===ae}))||void 0===T?void 0:T.days}),"column"===(null==Je?void 0:Je.width)?Qe:null]}))]})),Je&&"full"===(null!==(S=Je.width)&&void 0!==S?S:"full")?Qe:null]}))}export{Ae as AddToGraph,je as CorrelationSection,De as DecisionCard,Se as DriverList,Te as DriverRow,ze as L2Report,ye as MAX_SERIES,Me as PlotByKpi,be as RegenerateSummary,We as RowDrivers,Ge as RowTrend,xe as SummaryCard,Le as TopDriversSection,Ne as decisionCardNotice,Fe as outsideRangeText,Oe as reportDayOf,Re as reportOutsideRange,we as stripRowTags,ke as titleCase};
2
2
  //# sourceMappingURL=AgReport.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as n,__generator as t}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as l,Fragment as r}from"react/jsx-runtime";import{useState as a}from"react";import{MessageSquare as s,PenLine as o,Trash2 as c}from"lucide-react";import{fetchReportComments as u,deleteReportComment as m,updateReportComment as d,postReportComment as h}from"../../api/insightsApi.js";import{useInsights as p}from"./insightsContextCore.js";import{useInsightsFetch as v}from"./insightsUtils.js";var b=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 f(r){var s=this,o=r.placeholder,c=r.submitLabel,u=r.onSubmit,m=r.onCancel,d=r.initialValue,h=a(void 0===d?"":d),p=h[0],v=h[1],b=a(!1),f=b[0],N=b[1],g=a(null),C=g[0],y=g[1];return i("div",e({className:"ins-comment-box"},{children:[l("textarea",{value:p,maxLength:4e3,placeholder:o,"aria-label":o,onChange:function(e){return v(e.target.value)},rows:2}),C?l("p",e({className:"ins-error"},{children:C})):null,i("div",e({className:"ins-comment-box__actions"},{children:[m?l("button",e({type:"button",className:"ins-link",onClick:m},{children:"Cancel"})):null,l("button",e({type:"button",className:"ins-button",disabled:f||!p.trim(),onClick:function(){return n(s,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:if(!p.trim())return[2];N(!0),y(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,u(p.trim())];case 2:return n.sent(),v(""),[3,5];case 3:return e=n.sent(),y(e.message||"Couldn't post the comment."),[3,5];case 4:return N(!1),[7];case 5:return[2]}})})}},{children:f?"Posting…":c}))]}))]}))}function N(N){var g=this,C=N.reportId,y=p(),_=a(null),k=_[0],w=_[1],x=a(null),L=x[0],S=x[1],j=a(null),B=j[0],E=j[1],A=v(y?function(e){return u(y.api,C,e)}:null,[C,null==y?void 0:y.api.configId,null==y?void 0:y.revision]),D=A.data,T=A.loading,I=A.error,R=A.reload;if(!y)return null;var V=y.viewer,P=function(a){var s,u,p=Boolean(V.email&&a.createdByEmail&&V.email.toLowerCase()===a.createdByEmail.toLowerCase());return i("li",e({className:"ins-comment"},{children:[a.isDeleted?l("p",e({className:"ins-comment__deleted"},{children:"Comment deleted"})):i(r,{children:[i("div",e({className:"ins-comment__meta"},{children:[l("strong",{children:a.createdByName||a.createdByEmail||"Someone"}),i("span",{children:[b(a.createdAt),a.edited?" · edited":""]})]})),L===a.id?l(f,{placeholder:"Edit comment",submitLabel:"Save",initialValue:null!==(s=a.commentText)&&void 0!==s?s:"",onCancel:function(){return S(null)},onSubmit:function(e){return n(g,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,d(y.api,a.id,e)];case 1:return n.sent(),S(null),R(),[2]}})})}}):l("p",e({className:"ins-comment__text"},{children:a.commentText})),i("div",e({className:"ins-comment__actions"},{children:[l("button",e({type:"button",className:"ins-link",onClick:function(){return w(k===a.id?null:a.id)}},{children:"Reply"})),p?i("button",e({type:"button",className:"ins-link",onClick:function(){return S(a.id)}},{children:[l(o,{"aria-hidden":"true"})," Edit"]})):null,p||V.isAdmin?i("button",e({type:"button",className:"ins-link ins-link--danger",onClick:function(){return e=a.id,n(g,void 0,void 0,function(){var n;return t(this,function(t){switch(t.label){case 0:E(null),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,m(y.api,e)];case 2:return t.sent(),R(),[3,4];case 3:return n=t.sent(),E(n.message||"Couldn't delete the comment."),[3,4];case 4:return[2]}})});var e}},{children:[l(c,{"aria-hidden":"true"})," Delete"]})):null]}))]}),k===a.id?l(f,{placeholder:"Write a reply",submitLabel:"Reply",onCancel:function(){return w(null)},onSubmit:function(e){return n(g,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,h(y.api,C,e,a.id)];case 1:return n.sent(),w(null),R(),[2]}})})}}):null,(null===(u=a.replies)||void 0===u?void 0:u.length)?l("ul",e({className:"ins-comments ins-comments--replies"},{children:a.replies.map(P)})):null]}),a.id)};return i("section",e({className:"ins-thread","aria-label":"Comments"},{children:[i("h3",{children:[l(s,{"aria-hidden":"true"})," Comments",(null==D?void 0:D.count)?" (".concat(D.count,")"):""]}),I?l("p",e({className:"ins-error"},{children:I.message})):null,B?l("p",e({className:"ins-error"},{children:B})):null,T&&!D?l("p",e({className:"ins-muted"},{children:"Loading comments…"})):null,D&&!D.comments.length?l("p",e({className:"ins-muted"},{children:"No comments yet."})):null,(null==D?void 0:D.comments.length)?l("ul",e({className:"ins-comments"},{children:D.comments.map(P)})):null,l(f,{placeholder:"Add a comment",submitLabel:"Comment",onSubmit:function(e){return n(g,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,h(y.api,C,e)];case 1:return n.sent(),R(),[2]}})})}})]}))}export{N as default};
1
+ import{__assign as e,__awaiter as n,__generator as t}from"../../../_virtual/_tslib.js";import{jsxs as i,jsx as r,Fragment as l}from"react/jsx-runtime";import{useState as a}from"react";import{MessageSquare as o,PenLine as s,Trash2 as c}from"lucide-react";import{fetchReportComments as u,deleteReportComment as m,updateReportComment as d,postReportComment as h}from"../../api/insightsApi.js";import{useInsights as p}from"./insightsContextCore.js";import{insightsErrorText as f}from"./insightsErrors.js";import{useInsightsFetch as v}from"./insightsUtils.js";var b=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 N(l){var o=this,s=l.placeholder,c=l.submitLabel,u=l.onSubmit,m=l.onCancel,d=l.initialValue,h=a(void 0===d?"":d),p=h[0],v=h[1],b=a(!1),N=b[0],g=b[1],C=a(null),y=C[0],_=C[1];return i("div",e({className:"ins-comment-box"},{children:[r("textarea",{value:p,maxLength:4e3,placeholder:s,"aria-label":s,onChange:function(e){return v(e.target.value)},rows:2}),y?r("p",e({className:"ins-error"},{children:y})):null,i("div",e({className:"ins-comment-box__actions"},{children:[m?r("button",e({type:"button",className:"ins-link",onClick:m},{children:"Cancel"})):null,r("button",e({type:"button",className:"ins-button",disabled:N||!p.trim(),onClick:function(){return n(o,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:if(!p.trim())return[2];g(!0),_(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,u(p.trim())];case 2:return n.sent(),v(""),[3,5];case 3:return e=n.sent(),_(f(e,"Couldn't post the comment.")),[3,5];case 4:return g(!1),[7];case 5:return[2]}})})}},{children:N?"Posting…":c}))]}))]}))}function g(g){var C=this,y=g.reportId,_=p(),k=a(null),w=k[0],x=k[1],L=a(null),S=L[0],j=L[1],E=a(null),B=E[0],A=E[1],D=v(_?function(e){return u(_.api,y,e)}:null,[y,null==_?void 0:_.api.configId,null==_?void 0:_.revision]),T=D.data,I=D.loading,R=D.error,V=D.reload;if(!_)return null;var P=_.viewer,U=function(a){var o,u,p=Boolean(P.email&&a.createdByEmail&&P.email.toLowerCase()===a.createdByEmail.toLowerCase());return i("li",e({className:"ins-comment"},{children:[a.isDeleted?r("p",e({className:"ins-comment__deleted"},{children:"Comment deleted"})):i(l,{children:[i("div",e({className:"ins-comment__meta"},{children:[r("strong",{children:a.createdByName||a.createdByEmail||"Someone"}),i("span",{children:[b(a.createdAt),a.edited?" · edited":""]})]})),S===a.id?r(N,{placeholder:"Edit comment",submitLabel:"Save",initialValue:null!==(o=a.commentText)&&void 0!==o?o:"",onCancel:function(){return j(null)},onSubmit:function(e){return n(C,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,d(_.api,a.id,e)];case 1:return n.sent(),j(null),V(),[2]}})})}}):r("p",e({className:"ins-comment__text"},{children:a.commentText})),i("div",e({className:"ins-comment__actions"},{children:[r("button",e({type:"button",className:"ins-link",onClick:function(){return x(w===a.id?null:a.id)}},{children:"Reply"})),p?i("button",e({type:"button",className:"ins-link",onClick:function(){return j(a.id)}},{children:[r(s,{"aria-hidden":"true"})," Edit"]})):null,p||P.isAdmin?i("button",e({type:"button",className:"ins-link ins-link--danger",onClick:function(){return e=a.id,n(C,void 0,void 0,function(){var n;return t(this,function(t){switch(t.label){case 0:A(null),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,m(_.api,e)];case 2:return t.sent(),V(),[3,4];case 3:return n=t.sent(),A(f(n,"Couldn't delete the comment.")),[3,4];case 4:return[2]}})});var e}},{children:[r(c,{"aria-hidden":"true"})," Delete"]})):null]}))]}),w===a.id?r(N,{placeholder:"Write a reply",submitLabel:"Reply",onCancel:function(){return x(null)},onSubmit:function(e){return n(C,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,h(_.api,y,e,a.id)];case 1:return n.sent(),x(null),V(),[2]}})})}}):null,(null===(u=a.replies)||void 0===u?void 0:u.length)?r("ul",e({className:"ins-comments ins-comments--replies"},{children:a.replies.map(U)})):null]}),a.id)};return i("section",e({className:"ins-thread","aria-label":"Comments"},{children:[i("h3",{children:[r(o,{"aria-hidden":"true"})," Comments",(null==T?void 0:T.count)?" (".concat(T.count,")"):""]}),R?r("p",e({className:"ins-error"},{children:R.message})):null,B?r("p",e({className:"ins-error"},{children:B})):null,I&&!T?r("p",e({className:"ins-muted"},{children:"Loading comments…"})):null,T&&!T.comments.length?r("p",e({className:"ins-muted"},{children:"No comments yet."})):null,(null==T?void 0:T.comments.length)?r("ul",e({className:"ins-comments"},{children:T.comments.map(U)})):null,r(N,{placeholder:"Add a comment",submitLabel:"Comment",onSubmit:function(e){return n(C,void 0,void 0,function(){return t(this,function(n){switch(n.label){case 0:return[4,h(_.api,y,e)];case 1:return n.sent(),V(),[2]}})})}})]}))}export{g as default};
2
2
  //# sourceMappingURL=CommentsThread.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as n}from"../../../_virtual/_tslib.js";import{jsxs as e,jsx as i,Fragment as t}from"react/jsx-runtime";import{RefreshCw as o,MessageSquare as a,Sparkles as r,Clock3 as l}from"lucide-react";import{RcaDecisionComponent as s}from"../RcaDecisionComponent/RcaDecisionComponent.js";import{fetchLevelSummary as d,fetchInsightsSummary as u}from"../../api/insightsApi.js";import{useInsights as c}from"./insightsContextCore.js";import{useInsightsFetch as h,useOpenRow as m,toRcaItems as v,formatReportDate as p,formatPeriod as g}from"./insightsUtils.js";import y from"./FilterNotice.js";function f(n){var e,i=[];return n&&!n.matchesRange&&(null===(e=n.period)||void 0===e?void 0:e.end)&&i.push("Latest report: ".concat(p(n.period),".")),"preliminary"===(null==n?void 0:n.runType)&&i.push("Preliminary: late data can still change it."),i.length?i.join(" "):null}function N(t){var o=t.title,a=t.icon,l=t.heading,s=t.text,d=t.action;return e("article",n({className:"ins-state"},{children:[i("header",n({className:"ins-state__header"},{children:i("span",{children:o})})),e("div",n({className:"ins-state__body"},{children:[i("span",n({className:"ins-state__icon"},{children:null!=a?a:i(r,{"aria-hidden":"true"})})),e("div",{children:[i("p",n({className:"ins-state__heading"},{children:l})),s?i("p",n({className:"ins-state__text"},{children:s})):null,d]})]}))]}))}function _(t){var o=t.title;return e("article",n({className:"ins-state","aria-busy":"true","aria-label":"Loading ".concat(o)},{children:[i("header",n({className:"ins-state__header"},{children:i("span",{children:o})})),e("div",n({className:"ins-skeleton"},{children:[i("span",{style:{width:"40%"}}),i("span",{style:{width:"85%"}}),i("span",{style:{width:"70%"}}),i("span",{style:{width:"78%"}})]}))]}))}function b(t){var r,d,u,h,p,y,_,b=t.report,C=t.title,w=t.context,x=t.onComments,k=t.onRetry,A=c(),I=m(),T=b.title||C;return"waiting"===b.status?i(N,{title:T,icon:i(l,{"aria-hidden":"true"}),heading:"The first run hasn't finished yet",text:"The AI checks yesterday's numbers every morning. This card fills in after its first run."}):"running"===b.status?i(N,{title:T,icon:i(l,{"aria-hidden":"true"}),heading:"Being written",text:"The AI is writing this report. It usually takes a minute or two.",action:k?e("button",n({type:"button",className:"ins-link",onClick:k},{children:[i(o,{"aria-hidden":"true"})," Check again"]})):null}):"generated"!==b.status?i(N,{title:T,heading:"No report for this period",text:(null===(r=null==w?void 0:w.period)||void 0===r?void 0:r.start)?"Nothing was written for ".concat(g(w.period),". Reports are written after each morning run."):"Reports are written after each morning run."}):i(s,{title:T,score:b.score,summary:b.summary,notice:f(w),headerActions:x&&b.reportId?e("button",n({type:"button",className:"ins-chip-button",onClick:x,"aria-label":"Open report and comments"},{children:[i(a,{"aria-hidden":"true"}),b.commentCount||""]})):null,rootCause:v(b.rootCause,I,null===(d=null==A?void 0:A.decisionAdvantage)||void 0===d?void 0:d.rootCauseTags),rootCauseLayout:null===(u=null==A?void 0:A.decisionAdvantage)||void 0===u?void 0:u.rootCauseLayout,nextSteps:v(b.nextSteps,I),width:"100%",maxWidth:"none"},"".concat(null!==(h=b.reportId)&&void 0!==h?h:T,":").concat(null!==(_=null!==(p=b.generatedAt)&&void 0!==p?p:null===(y=null==w?void 0:w.period)||void 0===y?void 0:y.end)&&void 0!==_?_:""))}function C(t){var o=t.summary,r=t.onOpen,l="good"===o.tone?"#15803D":"bad"===o.tone?"#E11D48":void 0;return e("div",n({className:"ins-summary","aria-label":"Significant change summary"},{children:[i("div",n({className:"ins-summary__title",style:{color:l}},{children:o.eyebrow||"Significant change"})),i("div",n({className:"ins-summary__text"},{children:o.headline?i("span",n({className:"ins-summary__lead",style:{color:l}},{children:o.headline})):"No summary yet"})),r?i("button",n({type:"button",className:"ins-summary__open",onClick:r,"aria-label":"Open the full report and comments"},{children:i(a,{"aria-hidden":"true"})})):null]}))}function w(r){var l,d,u,h,p,y,N,_,b=r.title,w=void 0===b?"Decision Advantage":b,x=r.report,k=r.context,A=r.loading,I=r.error,T=r.onRetry,R=r.children,j=c(),D=m(),S="generated"===(null==x?void 0:x.status),L=(null==x?void 0:x.reportId)&&j?function(){return j.openReport({reportId:x.reportId,title:w})}:void 0,O=null;return O=I?e(t,{children:["Couldn't load Decision Advantage: ",I.message," ",T?e("button",n({type:"button",className:"ins-link ins-link--inline",onClick:T},{children:[i(o,{"aria-hidden":"true"})," Try again"]})):null]}):A&&!x?"Loading…":null!==(l=function(n,e){var i;return n?"waiting"===n.status?"The first morning run hasn't finished yet. This fills in after it.":"running"===n.status?"The AI is writing this report. It usually takes a minute or two.":"generated"!==n.status?(null===(i=null==e?void 0:e.period)||void 0===i?void 0:i.start)?"No report was written for ".concat(g(e.period),". Reports are written after each morning run."):"No report yet. Reports are written after each morning run.":null:null}(x,k))&&void 0!==l?l:f(k),e("div",n({className:"ins-dcol"},{children:[(null===(d=null==x?void 0:x.summary)||void 0===d?void 0:d.headline)?e(t,{children:[i("div",n({className:"ins-dcol__heading"},{children:"Summary"})),i(C,{summary:x.summary,onOpen:L})]}):null,i(s,{className:"ins-dcol__card",title:w,score:S?null==x?void 0:x.score:null,notice:O,headerActions:S&&L?e("button",n({type:"button",className:"ins-chip-button",onClick:L,"aria-label":"Open the full report and comments"},{children:[i(a,{"aria-hidden":"true"}),(null==x?void 0:x.commentCount)||""]})):null,rootCause:S?v(null==x?void 0:x.rootCause,D,null===(u=null==j?void 0:j.decisionAdvantage)||void 0===u?void 0:u.rootCauseTags):[],rootCauseLayout:null===(h=null==j?void 0:j.decisionAdvantage)||void 0===h?void 0:h.rootCauseLayout,nextSteps:S?v(null==x?void 0:x.nextSteps,D):[],afterSections:R,width:"100%",maxWidth:"none"},"".concat(null!==(p=null==x?void 0:x.reportId)&&void 0!==p?p:w,":").concat(null!==(_=null!==(y=null==x?void 0:x.generatedAt)&&void 0!==y?y:null===(N=null==k?void 0:k.period)||void 0===N?void 0:N.end)&&void 0!==_?_:""))]}))}function x(e){var t=e.children,o=e.minHeight;return i("div",n({className:"ins-fill",style:{minHeight:void 0===o?520:o}},{children:i("div",n({className:"ins-fill__inner"},{children:t}))}))}function k(n){var t,o,a,r,l=n.entityKey,s=n.title,m=void 0===s?"Decision Advantage":s,v=c(),p=h(v?function(n){return l?d(v.api,l,v.range,n):u(v.api,v.range,n)}:null,[null==v?void 0:v.api.configId,null==v?void 0:v.api.baseUrl,null==v?void 0:v.api.accessToken,null==v?void 0:v.rangeKey,l,null==v?void 0:v.revision],"".concat(null!==(t=null==v?void 0:v.api.configId)&&void 0!==t?t:"",":").concat(null!==(o=null==v?void 0:v.api.baseUrl)&&void 0!==o?o:"",":").concat(null!==(a=null==v?void 0:v.api.accessToken)&&void 0!==a?a:"",":").concat(null!==(r=null==v?void 0:v.rangeKey)&&void 0!==r?r:"",":").concat(null!=l?l:"root")),g=p.data,f=p.error,N=p.loading,_=p.reload;return v?f&&"InsightsDisabled"===f.errorType?null:e(x,{children:[i(y,{context:null==g?void 0:g.context}),i(w,{title:m,report:null==g?void 0:g.report,context:null==g?void 0:g.context,loading:N,error:f,onRetry:_})]}):null}export{w as DecisionColumn,x as FillHeight,_ as InsightsSkeleton,N as InsightsStateCard,b as ReportView,C as SummaryBox,k as default,f as reportNotice};
1
+ import{__assign as e}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as i,Fragment as t}from"react/jsx-runtime";import{RefreshCw as o,MessageSquare as l,Sparkles as a,Clock3 as r}from"lucide-react";import{RcaDecisionComponent as s}from"../RcaDecisionComponent/RcaDecisionComponent.js";import{hasCitationLink as d,CitationMarkdown as u}from"../RcaDecisionComponent/CitationMarkdown.js";import{fetchLevelSummary as c,fetchInsightsSummary as m}from"../../api/insightsApi.js";import{useInsights as v}from"./insightsContextCore.js";import{useInsightsFetch as h,useOpenRow as p,toRcaItems as g,formatReportDate as y,formatPeriod as f}from"./insightsUtils.js";import C from"./FilterNotice.js";function N(e){var n,i=[];return e&&!e.matchesRange&&(null===(n=e.period)||void 0===n?void 0:n.end)&&i.push("Latest report: ".concat(y(e.period),".")),"preliminary"===(null==e?void 0:e.runType)&&i.push("Preliminary: late data can still change it."),i.length?i.join(" "):null}function _(t){var o=t.title,l=t.icon,r=t.heading,s=t.text,d=t.action;return n("article",e({className:"ins-state"},{children:[i("header",e({className:"ins-state__header"},{children:i("span",{children:o})})),n("div",e({className:"ins-state__body"},{children:[i("span",e({className:"ins-state__icon"},{children:null!=l?l:i(a,{"aria-hidden":"true"})})),n("div",{children:[i("p",e({className:"ins-state__heading"},{children:r})),s?i("p",e({className:"ins-state__text"},{children:s})):null,d]})]}))]}))}function b(t){var o=t.title;return n("article",e({className:"ins-state","aria-busy":"true","aria-label":"Loading ".concat(o)},{children:[i("header",e({className:"ins-state__header"},{children:i("span",{children:o})})),n("div",e({className:"ins-skeleton"},{children:[i("span",{style:{width:"40%"}}),i("span",{style:{width:"85%"}}),i("span",{style:{width:"70%"}}),i("span",{style:{width:"78%"}})]}))]}))}function x(t){var a,d,u,c,m,h,y,C,b,x=t.report,w=t.title,T=t.context,k=t.onComments,A=t.onRetry,I=v(),R=p(),S=x.title||w;return"waiting"===x.status?i(_,{title:S,icon:i(r,{"aria-hidden":"true"}),heading:"The first run hasn't finished yet",text:"The AI checks yesterday's numbers every morning. This card fills in after its first run."}):"running"===x.status?i(_,{title:S,icon:i(r,{"aria-hidden":"true"}),heading:"Being written",text:"The AI is writing this report. It usually takes a minute or two.",action:A?n("button",e({type:"button",className:"ins-link",onClick:A},{children:[i(o,{"aria-hidden":"true"})," Check again"]})):null}):"generated"!==x.status?i(_,{title:S,heading:"No report for this period",text:(null===(a=null==T?void 0:T.period)||void 0===a?void 0:a.start)?"Nothing was written for ".concat(f(T.period),". Reports are written after each morning run."):"Reports are written after each morning run."}):i(s,{title:S,score:x.score,summary:x.summary?e(e({},x.summary),{citations:null!==(u=null===(d=x.summary.cited)||void 0===d?void 0:d.citation)&&void 0!==u?u:void 0}):null,notice:N(T),headerActions:k&&x.reportId?n("button",e({type:"button",className:"ins-chip-button",onClick:k,"aria-label":"Open report and comments"},{children:[i(l,{"aria-hidden":"true"}),x.commentCount||""]})):null,rootCause:g(x.rootCause,R,null===(c=null==I?void 0:I.decisionAdvantage)||void 0===c?void 0:c.rootCauseTags),rootCauseLayout:null===(m=null==I?void 0:I.decisionAdvantage)||void 0===m?void 0:m.rootCauseLayout,nextSteps:g(x.nextSteps,R),autoScrollToCitedCell:!0,excelHover:!0,width:"100%",maxWidth:"none"},"".concat(null!==(h=x.reportId)&&void 0!==h?h:S,":").concat(null!==(b=null!==(y=x.generatedAt)&&void 0!==y?y:null===(C=null==T?void 0:T.period)||void 0===C?void 0:C.end)&&void 0!==b?b:""))}function w(t){var o,a=t.summary,r=t.onOpen,s="good"===a.tone?"#15803D":"bad"===a.tone?"#E11D48":void 0;return n("div",e({className:"ins-summary","aria-label":"Significant change summary"},{children:[i("div",e({className:"ins-summary__title",style:{color:s}},{children:a.eyebrow||"Significant change"})),i("div",e({className:"ins-summary__text"},{children:a.headline?i("span",e({className:"ins-summary__lead",style:{color:s}},{children:d(a.headline)?i(u,{text:a.headline,citations:null===(o=a.cited)||void 0===o?void 0:o.citation,excelDisplay:"popup",excelHover:!0,autoScrollToCitedCell:!0}):a.headline})):"No summary yet"})),r?i("button",e({type:"button",className:"ins-summary__open",onClick:r,"aria-label":"Open the full report and comments"},{children:i(l,{"aria-hidden":"true"})})):null]}))}function T(a){var r,d,u,c,m,h,y,C,_=a.title,b=void 0===_?"Decision Advantage":_,x=a.report,T=a.context,k=a.loading,A=a.error,I=a.onRetry,R=a.children,S=v(),D=p(),j="generated"===(null==x?void 0:x.status),L=(null==x?void 0:x.reportId)&&S?function(){return S.openReport({reportId:x.reportId,title:b})}:void 0,H=null;return H=A?n(t,{children:["Couldn't load Decision Advantage: ",A.message," ",I?n("button",e({type:"button",className:"ins-link ins-link--inline",onClick:I},{children:[i(o,{"aria-hidden":"true"})," Try again"]})):null]}):k&&!x?"Loading…":null!==(r=function(e,n){var i;return 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?(null===(i=null==n?void 0:n.period)||void 0===i?void 0:i.start)?"No report was written for ".concat(f(n.period),". Reports are written after each morning run."):"No report yet. Reports are written after each morning run.":null:null}(x,T))&&void 0!==r?r:N(T),n("div",e({className:"ins-dcol"},{children:[(null===(d=null==x?void 0:x.summary)||void 0===d?void 0:d.headline)?n(t,{children:[i("div",e({className:"ins-dcol__heading"},{children:"Summary"})),i(w,{summary:x.summary,onOpen:L})]}):null,i(s,{className:"ins-dcol__card",title:b,score:j?null==x?void 0:x.score:null,notice:H,headerActions:j&&L?n("button",e({type:"button",className:"ins-chip-button",onClick:L,"aria-label":"Open the full report and comments"},{children:[i(l,{"aria-hidden":"true"}),(null==x?void 0:x.commentCount)||""]})):null,rootCause:j?g(null==x?void 0:x.rootCause,D,null===(u=null==S?void 0:S.decisionAdvantage)||void 0===u?void 0:u.rootCauseTags):[],rootCauseLayout:null===(c=null==S?void 0:S.decisionAdvantage)||void 0===c?void 0:c.rootCauseLayout,nextSteps:j?g(null==x?void 0:x.nextSteps,D):[],afterSections:R,autoScrollToCitedCell:!0,excelHover:!0,width:"100%",maxWidth:"none"},"".concat(null!==(m=null==x?void 0:x.reportId)&&void 0!==m?m:b,":").concat(null!==(C=null!==(h=null==x?void 0:x.generatedAt)&&void 0!==h?h:null===(y=null==T?void 0:T.period)||void 0===y?void 0:y.end)&&void 0!==C?C:""))]}))}function k(n){var t=n.children,o=n.minHeight;return i("div",e({className:"ins-fill",style:{minHeight:void 0===o?520:o}},{children:i("div",e({className:"ins-fill__inner"},{children:t}))}))}function A(e){var t,o,l,a,r=e.entityKey,s=e.title,d=void 0===s?"Decision Advantage":s,u=v(),p=h(u?function(e){return r?c(u.api,r,u.range,e):m(u.api,u.range,e)}:null,[null==u?void 0:u.api.configId,null==u?void 0:u.api.baseUrl,null==u?void 0:u.api.accessToken,null==u?void 0:u.rangeKey,r,null==u?void 0:u.revision],"".concat(null!==(t=null==u?void 0:u.api.configId)&&void 0!==t?t:"",":").concat(null!==(o=null==u?void 0:u.api.baseUrl)&&void 0!==o?o:"",":").concat(null!==(l=null==u?void 0:u.api.accessToken)&&void 0!==l?l:"",":").concat(null!==(a=null==u?void 0:u.rangeKey)&&void 0!==a?a:"",":").concat(null!=r?r:"root")),g=p.data,y=p.error,f=p.loading,N=p.reload;return u?y&&"InsightsDisabled"===y.errorType?null:n(k,{children:[i(C,{context:null==g?void 0:g.context}),i(T,{title:d,report:null==g?void 0:g.report,context:null==g?void 0:g.context,loading:f,error:y,onRetry:N})]}):null}export{T as DecisionColumn,k as FillHeight,b as InsightsSkeleton,_ as InsightsStateCard,x as ReportView,w as SummaryBox,A as default,N as reportNotice};
2
2
  //# sourceMappingURL=DecisionAdvantageCard.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as n,__awaiter as t,__generator as l}from"../../../_virtual/_tslib.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Search as o,X as a,ChevronRight as u}from"lucide-react";import{useMemo as c,useState as d,useRef as s,useEffect as v}from"react";import{toIsoDay as f,fetchLevelRows as y,fetchInsightsDrivers as h,fetchDrillTableRows as p}from"../../api/insightsApi.js";import{formatHeaderDate as b}from"./agPrimitives.js";import{useInsights as m}from"./insightsContextCore.js";import{formatFigure as g}from"./insightsFormat.js";var k=/\{([^{}]+)\}/g;function w(e){var t=e.range,l=e.dashboardRange,o=e.onApply,a=d(t),u=a[0],c=a[1],s=!u.start||!u.end||u.start>u.end;return r("form",n({className:"ag-drill__dates","aria-label":"Table date range",onSubmit:function(e){e.preventDefault(),s||o(u)}},{children:[r("label",{children:["From",i("input",{type:"date",required:!0,value:u.start,max:u.end||void 0,onChange:function(e){var t=e.target.value;c(function(e){return n(n({},e),{start:t})})}})]}),r("label",{children:["To",i("input",{type:"date",required:!0,value:u.end,min:u.start||void 0,onChange:function(e){var t=e.target.value;c(function(e){return n(n({},e),{end:t})})}})]}),i("button",n({type:"submit",disabled:s},{children:"Apply"})),i("button",n({type:"button",onClick:function(){c(l),o(l)}},{children:"Use dashboard range"})),u.start&&u.end&&u.start>u.end?i("span",n({role:"alert"},{children:"From must be on or before To."})):null]}))}var K=function(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},N=function(e,n){return n.split(".").reduce(function(e,n){return e&&"object"==typeof e?e[n]:void 0},e)};function _(e,n){if(null==e||""===e)return"—";if("date"===n&&"string"==typeof e){var t=new Date("".concat(e.slice(0,10),"T00:00:00"));return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}var l="number"==typeof e?e:"string"==typeof e&&""!==e.trim()&&!Number.isNaN(Number(e))&&n&&"text"!==n&&"chip"!==n?Number(e):null;return null!==l?"percent"===n?"".concat(new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(l),"%"):new Intl.NumberFormat(void 0,{maximumFractionDigits:"rating"===n?2:1}).format(l):"object"==typeof e?JSON.stringify(e):String(e)}function C(e,n,t){var l,r,i,o,a,u=n.trail;return{record:t.record,context:{row:null!==(r=null===(l=u[u.length-1])||void 0===l?void 0:l.label)&&void 0!==r?r:"",parent:null!==(o=null===(i=u[u.length-2])||void 0===i?void 0:i.label)&&void 0!==o?o:"",day:null!==(a=n.day)&&void 0!==a?a:"",startDate:f(e.range.startDate),endDate:f(e.range.endDate),trail:Object.fromEntries(u.map(function(e){return[e.entityKey,e.label]}))}}}var S=function(e,n,t,l){return e.replace(k,function(e,r){var i=function(e,n,t){var l=t.trim();return l.startsWith("context.")?N(e.context,l.slice(8)):l.startsWith("input.")?n[l.slice(6)]:N(e.record,l)}(n,t,r),o=null==i?"":"object"==typeof i?JSON.stringify(i):String(i);return l?encodeURIComponent(o):o})},x=function(e,n,t){return"string"==typeof e?S(e,n,t,!1):Array.isArray(e)?e.map(function(e){return x(e,n,t)}):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(function(e){var l=e[0],r=e[1];return[l,x(r,n,t)]})):e},T=new Set,j=["good","warning","bad","info","neutral"],D=function(e){return String(null!=e?e:"").trim().toLowerCase().replace(/[\s_-]+/g," ")};function E(e){var t,l=e.text,r=e.value,o=e.colors,a=o?null===(t=Object.entries(o).find(function(e){var n=e[0];return D(n)===D(r)}))||void 0===t?void 0:t[1]:void 0;if(a&&"object"==typeof a)return i("span",n({className:"ag-drill__chip",style:n({background:a.background,color:a.color},a.border?{boxShadow:"inset 0 0 0 1px ".concat(a.border)}:{})},{children:l}));var u="string"==typeof a&&j.includes(a)?a:"neutral";return i("span",n({className:"ag-drill__chip ag-drill__chip--".concat(u)},{children:l}))}function B(e){var t,l=e.button,o=e.question,u=e.onCancel,c=e.onSubmit,f=d({}),y=f[0],h=f[1],p=s(null);v(function(){var e;return null===(e=p.current)||void 0===e?void 0:e.focus()},[]);var b=null!==(t=l.ask)&&void 0!==t?t:[],m=b.some(function(e){var n;return!(null===(n=y[e.key])||void 0===n?void 0:n.trim())});return i("div",n({className:"ag-drill__dialog",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&u()}},{children:r("form",n({className:"ag-drill__dialog-box",role:"dialog","aria-modal":"true","aria-label":l.label,onSubmit:function(e){e.preventDefault(),m||c(y)},onKeyDown:function(e){"Escape"===e.key&&(e.stopPropagation(),u())}},{children:[r("header",{children:[i("strong",{children:l.label}),i("button",n({type:"button","aria-label":"Cancel",onClick:u},{children:i(a,{"aria-hidden":"true"})}))]}),o?i("p",{children:o}):null,b.map(function(e,t){var l;return r("label",{children:[i("span",{children:e.label}),i("input",{ref:0===t?function(e){p.current=e}:void 0,value:null!==(l=y[e.key])&&void 0!==l?l:"",onChange:function(t){return h(function(l){var r;return n(n({},l),((r={})[e.key]=t.target.value,r))})},required:!0})]},e.key)}),r("footer",{children:[i("button",n({type:"button",onClick:u},{children:"Cancel"})),i("button",n({ref:b.length?void 0:function(e){p.current=e},type:"submit",disabled:m},{children:l.label}))]})]}))}))}function O(k){var j,D,O,A,P,I,R,M,L,F,q,z,J,U,H,W,G,Q=this,V=k.table,X=k.tabEntityKey,Y=k.context,Z=k.onRowClick,$=k.className,ee=m(),ne=Y.trail.length>0,te=c(function(){return function(e,t,l){var r,i,o,a,u,c={filterBy:l?"trail":"none",period:l?"day":"range"};return(null===(r=e.views)||void 0===r?void 0:r.length)?e.views.map(function(t){var l,r,i,o,a,u;return n(n({},t),{source:null!==(l=t.source)&&void 0!==l?l:"insights",filterBy:null!==(r=t.filterBy)&&void 0!==r?r:"row"===t.scope?"row":c.filterBy,period:null!==(i=t.period)&&void 0!==i?i:c.period,onRowClick:null!==(o=t.onRowClick)&&void 0!==o?o:e.onRowClick,buttons:null!==(u=null!==(a=t.buttons)&&void 0!==a?a:e.buttons)&&void 0!==u?u:[]})}):[{source:null!==(i=e.source)&&void 0!==i?i:"insights",entityKey:t,tableKey:e.tableKey,columns:e.columns,onRowClick:e.onRowClick,filterBy:l?null!==(o=e.filterBy)&&void 0!==o?o:c.filterBy:"none",period:l?null!==(a=e.period)&&void 0!==a?a:c.period:"range",buttons:null!==(u=e.buttons)&&void 0!==u?u:[]}]}(V,X,ne)},[V,X,ne]),le=te.map(function(e){var n;return"".concat(e.source,":").concat(null!==(n=e.entityKey)&&void 0!==n?n:e.tableKey)}).join("|"),re=d(0),ie=re[0],oe=re[1],ae=d(""),ue=ae[0],ce=ae[1],de=d(""),se=de[0],ve=de[1],fe=d(V.defaultSort),ye=fe[0],he=fe[1],pe=d([]),be=pe[0],me=pe[1],ge=d(null),ke=ge[0],we=ge[1],Ke=d(0),Ne=Ke[0],_e=Ke[1],Ce=d(!1),Se=Ce[0],xe=Ce[1],Te=d(0),je=Te[0],De=Te[1],Ee=d(!1),Be=Ee[0],Oe=Ee[1],Ae=d(null),Pe=Ae[0],Ie=Ae[1],Re=d(null),Me=Re[0],Le=Re[1],Fe=d(null),qe=Fe[0],ze=Fe[1],Je=d(null),Ue=Je[0],He=Je[1],We=d(null),Ge=We[0],Qe=We[1],Ve=s(null);v(function(){return oe(0)},[le]),v(function(){var e=setTimeout(function(){return ve(ue.trim())},300);return function(){return clearTimeout(e)}},[ue]);var Xe=te[Math.min(ie,te.length-1)],Ye=Y.trail,Ze=Ye[Ye.length-1],$e=null!==(j=V.pageSize)&&void 0!==j?j:10,en=Xe&&"table"!==Xe.source?Ze&&Xe.entityKey&&!(null==ee?void 0:ee.isChildOf(Xe.entityKey,Ze.entityKey))?"movers":"rows":"table",nn="rows"===en&&Ze?Ze.nodeKey:void 0,tn=c(function(){var n,t,l;if(!ee||!Xe||"table"===Xe.source)return[];if(null===(n=Xe.columns)||void 0===n?void 0:n.length)return Xe.columns;var r=ee.entityKpis(null!==(t=Xe.entityKey)&&void 0!==t?t:"").slice(0,4);return e([{key:"label",source:"field",label:ee.entityName(null!==(l=Xe.entityKey)&&void 0!==l?l:"")}],r.map(function(e){return{key:e,source:"kpi",show:"both"}}),!0)},[ee,Xe]),ln=tn.find(function(e){return"children"===e.source}),rn=null!==(D=null==ee?void 0:ee.headlineKpi)&&void 0!==D?D:"",on=Ye.map(function(e){return"".concat(e.entityKey,":").concat(e.nodeKey)}).join("|"),an=JSON.stringify([null==ee?void 0:ee.rangeKey,null==ee?void 0:ee.api.configId,le,on,Y.day]),un=ne&&"table"===en,cn=c(function(){return ee?"day"===(null==Xe?void 0:Xe.period)&&Y.day?{start:Y.day,end:Y.day}:{start:f(ee.range.startDate),end:f(ee.range.endDate)}:{start:"",end:""}},[ee,null==Xe?void 0:Xe.period,Y.day]),dn=un&&(null==Ge?void 0:Ge.scope)===an?Ge.range:cn,sn=c(function(){if(!ee||!Xe)return{};var e=n({},ee.sidebarFilters);return("trail"===Xe.filterBy?Ye:"row"===Xe.filterBy?Ye.slice(-1):[]).forEach(function(n){var t=ee.labelColumnOf(n.entityKey);t&&n.label&&(e[t]=[n.label])}),e},[ee,Xe,on]),vn=JSON.stringify(sn),fn="table"===en?void 0:"chip.criticality"===(null==ye?void 0:ye.key)?"criticality":null==ye?void 0:ye.key,yn="table"===en||null==ye?void 0:ye.order,hn="table"===en?"":se,pn=function(e,r){return t(Q,void 0,void 0,function(){var t,i,o,a,u,c,d,s,v,f,b;return l(this,function(l){switch(l.label){case 0:if(!ee||!Xe)return[2,void 0];if("table"!==en)return[3,2];if(!Xe.tableKey)throw new Error("Pick a Table Builder table for this list.");return[4,p(ee.api,{tableKey:Xe.tableKey,startDay:dn.start,endDay:dn.end,filters:sn,pageSize:$e,cursor:e?ke:null},r)];case 1:return t=l.sent(),i=e?be.length:0,[2,{rows:t.rows.map(function(e,n){return{id:"t".concat(i+n),record:e}}),count:t.count,hasMore:t.hasNext,cursor:t.nextCursor,offset:0}];case 2:return"movers"!==en?[3,4]:(o=e?Ne:0,[4,h(ee.api,{dataDay:null!==(s=Y.day)&&void 0!==s?s:void 0,kpiId:rn,parentNodeKey:null==Ze?void 0:Ze.nodeKey,entityKey:Xe.entityKey,tab:"drivers",limit:$e,offset:o,filters:ee.range.filters},r)]);case 3:return a=l.sent(),u=a.rows.map(function(e){return function(e,n){var t,l,r,i,o;return{rank:e.rank,nodeKey:e.nodeKey,label:e.label,parent:null,metrics:(t={},t[n]={value:e.value,previous:e.previous,deltaPct:e.deltaPct,direction:e.changeDirection,tone:e.tone},t),barPct:null,chip:{criticality:e.criticality,movementType:e.movementType},report:{reportId:null!==(r=null===(l=e.report)||void 0===l?void 0:l.reportId)&&void 0!==r?r:null,status:(null===(i=e.report)||void 0===i?void 0:i.reportId)?"generated":"none",kpiId:n},action:null,children:[],entityKey:null!==(o=e.entityKey)&&void 0!==o?o:null}}(e,rn)}),c=a,[2,{rows:u.map(function(e){return{id:e.nodeKey,record:e,insights:e}}),count:null!==(v=c.total)&&void 0!==v?v:o+u.length,hasMore:Boolean(c.hasMore),cursor:null,offset:o+u.length}];case 4:return[4,y(ee.api,null!==(f=Xe.entityKey)&&void 0!==f?f:"",n({},ee.range),{sort:fn,order:yn,search:hn||void 0,pageSize:$e,parentNodeKey:nn,includeChildren:ln?null!==(b=ln.max)&&void 0!==b?b:3:void 0,childEntityKey:null==ln?void 0:ln.childEntityKey,cursor:e&&null!=ke?ke:void 0},r)];case 5:return[2,{rows:(d=l.sent()).rows.map(function(e){var t,l;return{id:e.nodeKey,record:e,insights:n(n({},e),{entityKey:null!==(l=null!==(t=e.entityKey)&&void 0!==t?t:Xe.entityKey)&&void 0!==l?l:null})}}),count:d.count,hasMore:d.hasNext,cursor:d.nextCursor,offset:0}]}})})};if(v(function(){if(ee&&Xe){var e=new AbortController;return Ve.current=e,Oe(!0),Ie(null),me([]),we(null),_e(0),Le(null),pn(!1,e.signal).then(function(n){var t;n&&!e.signal.aborted&&(me(n.rows),De(n.count),xe(n.hasMore),we(null!==(t=n.cursor)&&void 0!==t?t:null),_e(n.offset))}).catch(function(n){e.signal.aborted||"AbortError"===(null==n?void 0:n.name)||Ie(n instanceof Error?n.message:"The rows couldn't be loaded.")}).finally(function(){e.signal.aborted||Oe(!1)}),function(){return e.abort()}}},[null==ee?void 0:ee.api,null==ee?void 0:ee.revision,null==ee?void 0:ee.rangeKey,le,ie,en,nn,on,Y.day,dn.start,dn.end,vn,hn,fn,yn,$e,null==ln?void 0:ln.childEntityKey]),!ee||!Xe)return null;var bn="table"===en?function(t,l,r){var i,o,a=l.tableKey?t.tableSource(l.tableKey):void 0,u=(null===(i=null==a?void 0:a.columns)||void 0===i?void 0:i.length)?a.columns:Object.keys(null!=r?r:{}).map(function(e){return{key:e,label:K(e)}}),c=null!==(o=l.columns)&&void 0!==o?o:[];return e(e([],c.filter(function(e){return e.key&&u.some(function(n){return n.key===e.key})}),!0),u.filter(function(e){return!c.some(function(n){return n.key===e.key})}).map(function(e){return n(n({},e),{source:"field"})}),!0).filter(function(e){return!e.hidden}).map(function(e){var t,l,r,i,o,a;return n(n({},e),{source:"field",sortable:null!==(t=e.sortable)&&void 0!==t?t:null===(l=u.find(function(n){return n.key===e.key}))||void 0===l?void 0:l.sortable,label:null!==(o=null!==(r=e.label)&&void 0!==r?r:null===(i=u.find(function(n){return n.key===e.key}))||void 0===i?void 0:i.label)&&void 0!==o?o:K(null!==(a=e.key)&&void 0!==a?a:"")})})}(ee,Xe,null===(O=be[0])||void 0===O?void 0:O.record):tn,mn=ee.hostTables["table"===Xe.source?null!==(A=Xe.tableKey)&&void 0!==A?A:"":"insights.".concat(null!==(P=Xe.entityKey)&&void 0!==P?P:"")],gn=(null===(I=null==mn?void 0:mn.columns)||void 0===I?void 0:I.length)?mn.columns:null,kn=function(e){return e.insights?function(e){var n,t,l,r,i,o,a,u,c,d,s,v,f,y,h,p,b,m={id:e.nodeKey,nodeKey:e.nodeKey,label:null!==(n=e.label)&&void 0!==n?n:e.nodeKey,entityKey:null!==(t=e.entityKey)&&void 0!==t?t:null,parent:null!==(r=null===(l=e.parent)||void 0===l?void 0:l.label)&&void 0!==r?r:null,criticality:null!==(o=null===(i=e.chip)||void 0===i?void 0:i.criticality)&&void 0!==o?o:null,movementType:null!==(u=null===(a=e.chip)||void 0===a?void 0:a.movementType)&&void 0!==u?u:null,reportId:null!==(d=null===(c=e.report)||void 0===c?void 0:c.reportId)&&void 0!==d?d:null,reportStatus:null!==(v=null===(s=e.report)||void 0===s?void 0:s.status)&&void 0!==v?v:null,actionStatus:null!==(y=null===(f=e.action)||void 0===f?void 0:f.status)&&void 0!==y?y:null,assignee:null!==(p=null===(h=e.action)||void 0===h?void 0:h.assigneeName)&&void 0!==p?p:null,children:e.children.map(function(e){return e.label}).filter(Boolean),__row:e};return Object.entries(null!==(b=e.metrics)&&void 0!==b?b:{}).forEach(function(e){var n,t,l,r=e[0],i=e[1];m[r]=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:null,m["".concat(r,"_delta")]=null!==(t=null==i?void 0:i.deltaPct)&&void 0!==t?t:null,m["".concat(r,"_previous")]=null!==(l=null==i?void 0:i.previous)&&void 0!==l?l:null}),m}(e.insights):n({id:e.id},e.record)},wn="table"===en?"none":null!==(R=Xe.onRowClick)&&void 0!==R?R:"none",Kn="none"!==wn,Nn="table"===en?e([],be,!0).filter(function(e){return!se||(gn?gn.map(function(e){return e.key}):bn.map(function(e){var n;return null!==(n=e.key)&&void 0!==n?n:""})).some(function(n){var t;return String(null!==(t=e.record[n])&&void 0!==t?t:"").toLowerCase().includes(se.toLowerCase())})}).sort(function(e,n){if(!(null==ye?void 0:ye.key))return 0;var t=e.record[ye.key],l=n.record[ye.key],r=Number(t),i=Number(l),o=null==t||null==l||""===t||""===l||Number.isNaN(r)||Number.isNaN(i)?String(null!=t?t:"").localeCompare(String(null!=l?l:"")):r-i;return"asc"===ye.order?o:-o}):be,_n=function(e){return"movers"!==en&&!0===e.sortable},Cn=function(e){var n;if(_n(e)){var t=null!==(n=e.key)&&void 0!==n?n:"";he(function(e){return{key:t,order:(null==e?void 0:e.key)===t&&"desc"===e.order?"asc":"desc"}})}},Sn=function(e){var n;return(null===(n=ee.tableSource(null!=e?e:""))||void 0===n?void 0:n.title)||K(null!=e?e:"")},xn="table"===Xe.source?Sn(Xe.tableKey):ee.entityName(null!==(M=Xe.entityKey)&&void 0!==M?M:""),Tn="table"===Xe.source?xn:ee.entityPluralName(null!==(L=Xe.entityKey)&&void 0!==L?L:""),jn=function(e){var n;return e.title||("table"===e.source?Sn(e.tableKey):ee.entityPluralName(null!==(n=e.entityKey)&&void 0!==n?n:""))},Dn=te.length>1?"Drill down in {row}":ne?"table"===Xe.source?"{part}":ee.labels.drillTableTitle:"{parts}",En=(null!==(F=V.title)&&void 0!==F?F:Dn).replace(/\{row\}/g,null!==(q=null==Ze?void 0:Ze.label)&&void 0!==q?q:"").replace(/\{parent\}/g,null!==(J=null===(z=Ye[Ye.length-2])||void 0===z?void 0:z.label)&&void 0!==J?J:"").replace(/\{day\}/g,Y.day?b(Y.day):"").replace(/\{parts\}|\{plural\}/g,Tn).replace(/\{part\}/g,xn).replace(/\s+/g," ").trim(),Bn=function(e){return Xe.buttons.filter(function(n){var t,l,r;if(n.adminOnly&&!ee.viewer.isAdmin)return!1;if(!("host"!==n.type||n.handler&&ee.actionHandlers[n.handler]))return T.has(null!==(t=n.handler)&&void 0!==t?t:"")||(T.add(null!==(l=n.handler)&&void 0!==l?l:""),console.warn('Decision Advantage: no host handler named "'.concat(null!==(r=n.handler)&&void 0!==r?r:"",'" is registered, so its button is hidden.'))),!1;if(n.when){var i=N(e.record,n.when);if(null==i||""===i)return!1}return!0})},On=function(e,n,r){return t(Q,void 0,void 0,function(){var t,i,o,a,u,c,d,s,v,f,y,h,p,b,m,g,k,w,K,N,_,T;return l(this,function(l){switch(l.label){case 0:t=C(ee,Y,n),i="".concat(n.id,":").concat(null!==(b=e.id)&&void 0!==b?b:e.label),Le(null),l.label=1;case 1:if(l.trys.push([1,9,10,11]),"open"===e.type){if(o=S(null!==(m=e.url)&&void 0!==m?m:"",t,r,!0),/^https:\/\//i.test(o))window.open(o,"_blank","noopener,noreferrer");else{if(!/^mailto:/i.test(o))throw new Error("This link isn't allowed: only https and mailto links open.");window.location.href=o}return[2]}return He(i),"host"!==e.type?[3,3]:[4,(0,ee.actionHandlers[null!==(g=e.handler)&&void 0!==g?g:""])({button:e,row:n.record,context:t.context,inputs:r})];case 2:return a=l.sent(),Le({tone:"ok",text:a&&a.message||"".concat(e.label,": done.")}),[2];case 3:if("https:"!==(u=new URL(S(null!==(k=e.url)&&void 0!==k?k:"",t,r,!0))).protocol)throw new Error("Only https APIs can be called.");return c=null!==(w=e.method)&&void 0!==w?w:"POST",d={Accept:"application/json"},Object.entries(null!==(K=e.headers)&&void 0!==K?K:{}).forEach(function(e){var n=e[0],l=e[1];d[n]=S(String(l),t,r,!1)}),ee.api.accessToken&&ee.approvedApiHosts.includes(u.host.toLowerCase())&&(d.Authorization="Bearer ".concat(ee.api.accessToken)),(s="GET"!==c&&void 0!==e.body&&null!==e.body)&&(d["Content-Type"]="application/json"),[4,fetch(u.toString(),{method:c,headers:d,body:s?JSON.stringify(x(e.body,t,r)):void 0})];case 4:v=l.sent(),f="",l.label=5;case 5:return l.trys.push([5,7,,8]),[4,v.json()];case 6:return y=l.sent(),h=null==y?void 0:y.error,f=String(null!==(T=null!==(_=null!==(N=null==y?void 0:y.message)&&void 0!==N?N:null==h?void 0:h.errorMessage)&&void 0!==_?_:null==y?void 0:y.detail)&&void 0!==T?T:""),[3,8];case 7:return l.sent(),f="",[3,8];case 8:if(!v.ok)throw new Error(f||"".concat(e.label," failed (status ").concat(v.status,")."));return Le({tone:"ok",text:f||"".concat(e.label,": done.")}),[3,11];case 9:return p=l.sent(),Le({tone:"error",text:p instanceof Error?p.message:"".concat(e.label," failed.")}),[3,11];case 10:return He(null),[7];case 11:return[2]}})})},An=function(e){var n,t,l,r=null!==(t=null!==(n=e.key)&&void 0!==n?n:e.id)&&void 0!==t?t:"",i="table"===Xe.source?Xe.tableKey:Xe.entityKey;return null!==(l=i?ee.cellRenderers["".concat(i,".").concat(r)]:void 0)&&void 0!==l?l:ee.cellRenderers[r]},Pn=function(e,t){var l,o,a,u,c,d,s,v,f,y=null!==(l=t.key)&&void 0!==l?l:"",h=An(t),p="kpi"===t.source&&e.insights?null===(o=e.insights.metrics[y])||void 0===o?void 0:o.value:"children"===t.source&&e.insights?e.insights.children.map(function(e){return e.label}).filter(Boolean):"label"===y&&e.insights?e.insights.label||e.insights.nodeKey:N(e.record,y);if(null==h?void 0:h.render){var b=h.render({column:t,value:p,record:e.record,row:e.insights,entityKey:Xe.entityKey,tableKey:Xe.tableKey});if(void 0!==b)return b}if(e.insights){var m=null===(a=ee.renderInsightsCell)||void 0===a?void 0:a.call(ee,{column:t,row:e.insights,entityKey:null!==(u=Xe.entityKey)&&void 0!==u?u:""});if(void 0!==m)return m}if("custom"===t.source)return null!==(c=t.emptyText)&&void 0!==c?c:"—";if("kpi"===t.source&&e.insights&&!(null==h?void 0:h.as)){var k=e.insights.metrics[y],w=t.format&&"number"!==t.format?null:g(null==k?void 0:k.value,null===(d=ee.kpis[y])||void 0===d?void 0:d.format),K=null!=w?w:_(null==k?void 0:k.value,t.format),C=null==(null==k?void 0:k.deltaPct)?"—":"".concat(k.deltaPct>0?"↑":k.deltaPct<0?"↓":""," ").concat(Math.abs(k.deltaPct),"%");return"delta"===t.show?i("span",n({className:(null==k?void 0:k.tone)?"ag-drill__change--".concat(k.tone):void 0},{children:C})):"value"===t.show?K:r("span",n({className:"ag-drill__metric"},{children:[i("strong",{children:K}),i("small",n({className:(null==k?void 0:k.tone)?"ag-drill__change--".concat(k.tone):void 0},{children:C}))]}))}if("children"===t.source&&e.insights&&!(null==h?void 0:h.as)){var S=Array.from(new Set(p)),x=null!==(s=t.max)&&void 0!==s?s:3,T=S.length?"".concat(S.slice(0,x).join(", ")).concat(S.length>x?" +".concat(S.length-x):""):null!==(v=t.emptyText)&&void 0!==v?v:"—";return i("span",n({className:"ag-drill__contributors",title:S.join(", ")||void 0},{children:T}))}var j=null!==(f=null==h?void 0:h.as)&&void 0!==f?f:t.format;if("link"===j){var D="string"==typeof p?p:"";return/^https:\/\//i.test(D)?i("a",n({href:D,target:"_blank",rel:"noopener noreferrer"},{children:D})):_(p,"text")}var B=_(p,"chip"===j?"text":j);return"—"===B&&t.emptyText?t.emptyText:"chip"!==j&&!(null==h?void 0:h.colors)||"—"===B?B:i(E,{text:B.replace(/_/g," "),value:p,colors:null==h?void 0:h.colors})},In=function(e){e.insights&&(null==Z||Z(e.insights,wn))},Rn=Xe.buttons.length>0,Mn=function(e){var n;return null!==(n=e.align)&&void 0!==n?n:"kpi"===e.source?"right":"left"},Ln="ag-drill-".concat(String(null!==(U=V.id)&&void 0!==U?U:En).replace(/[^a-z0-9]+/gi,"-")),Fn=!1!==V.search&&"movers"!==en;return r("section",n({className:"ag-drill".concat($?" ".concat($):""),"aria-labelledby":Ln,style:null===(H=null==mn?void 0:mn.card)||void 0===H?void 0:H.root},{children:[r("header",n({className:"ag-drill__header",style:null===(W=null==mn?void 0:mn.card)||void 0===W?void 0:W.header},{children:[r("div",{children:[i("h3",n({id:Ln,style:null===(G=null==mn?void 0:mn.card)||void 0===G?void 0:G.title},{children:En})),"movers"===en?r("span",{children:["Rows that moved",Y.day?" on ".concat(b(Y.day)):""]}):null]}),Fn?r("label",n({className:"ag-drill__search"},{children:[i(o,{"aria-hidden":"true"}),i("input",{type:"search",value:ue,onChange:function(e){return ce(e.target.value)},placeholder:"Search ".concat(Tn.toLowerCase(),"…"),"aria-label":"Search ".concat(Tn)})]})):null]})),un?i(w,{range:dn,dashboardRange:{start:f(ee.range.startDate),end:f(ee.range.endDate)},onApply:function(e){return Qe({scope:an,range:e})}},"".concat(an,":").concat(dn.start,":").concat(dn.end)):null,te.length>1?i("div",n({className:"ag-drill__tabs",role:"tablist","aria-label":"What this table lists"},{children:te.map(function(e,t){var l;return i("button",n({type:"button",role:"tab","aria-selected":t===ie,className:t===ie?"is-active":void 0,onClick:function(){oe(t),ce(""),ve(""),he(V.defaultSort)}},{children:jn(e)}),"".concat(e.source,":").concat(null!==(l=e.entityKey)&&void 0!==l?l:e.tableKey,":").concat(t))})})):null,Me?r("p",n({className:"ag-drill__notice ag-drill__notice--".concat(Me.tone),role:"status"},{children:[Me.text,i("button",n({type:"button","aria-label":"Dismiss",onClick:function(){return Le(null)}},{children:i(a,{"aria-hidden":"true"})}))]})):null,r("div",n({className:"ag-drill__table-wrap","aria-live":"polite"},{children:[r("table",n({className:"ag-drill__table"},{children:[i("thead",{children:r("tr",{children:[gn?gn.map(function(e){var t,l,o=bn.find(function(n){return n.key===e.key}),a=n(n({},o),{key:e.key,source:null!==(t=null==o?void 0:o.source)&&void 0!==t?t:"field",sortable:null!==(l=e.sortable)&&void 0!==l?l:null==o?void 0:o.sortable});return i("th",n({className:e.headerClassName,style:n(n({},e.style),e.headerStyle),"aria-sort":(null==ye?void 0:ye.key)===e.key?"asc"===ye.order?"ascending":"descending":void 0},{children:_n(a)?r("button",n({type:"button",onClick:function(){return Cn(a)}},{children:[e.header,i("span",n({"aria-hidden":"true"},{children:(null==ye?void 0:ye.key)===e.key?"asc"===ye.order?"↑":"↓":"↕"}))]})):e.header}),e.key)}):bn.map(function(e){var t,l,o,a,u,c=null!==(l=null!==(t=e.key)&&void 0!==t?t:e.id)&&void 0!==l?l:"",d=null!==(o=e.label)&&void 0!==o?o:"kpi"===e.source?ee.kpiLabel(c):"children"===e.source?ee.entityPluralName(null!==(a=e.childEntityKey)&&void 0!==a?a:""):K(null!==(u=c.split(".").pop())&&void 0!==u?u:c);return i("th",n({className:"ag-drill__col--".concat(Mn(e)," ").concat(e.hideBelow?"ag-drill__hide--".concat(e.hideBelow):""),style:{width:e.width},"aria-sort":(null==ye?void 0:ye.key)===c?"asc"===ye.order?"ascending":"descending":void 0},{children:_n(e)?r("button",n({type:"button",onClick:function(){return Cn(e)}},{children:[d,i("span",n({"aria-hidden":"true"},{children:(null==ye?void 0:ye.key)===c?"asc"===ye.order?"↑":"↓":"↕"}))]})):d}),"".concat(e.source,":").concat(c))}),Rn?i("th",{children:i("span",n({className:"ins-visually-hidden"},{children:"Actions"}))}):null,Kn?i("th",{children:i("span",n({className:"ins-visually-hidden"},{children:"Open"}))}):null]})}),i("tbody",{children:Nn.map(function(e){return r("tr",n({className:Kn?void 0:"is-static",tabIndex:Kn?0:void 0,onClick:Kn?function(n){n.target.closest("a,button,input,select,textarea")||In(e)}:void 0,onKeyDown:Kn?function(n){return function(e,n){Kn&&e.target===e.currentTarget&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),In(n)))}(n,e)}:void 0},{children:[gn?(t=kn(e),gn.map(function(e){return i("td",n({className:e.bodyClassName,style:n(n({},e.style),e.bodyStyle)},{children:e.body(t)}),e.key)})):bn.map(function(t,l){var r,o,a=0===l?"th":"td",u=null===(r=An(t))||void 0===r?void 0:r.className;return i(a,n({scope:0===l?"row":void 0,className:"ag-drill__col--".concat(Mn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):"").concat(u?" ".concat(u):"")},{children:Pn(e,t)}),"".concat(t.source,":").concat(null!==(o=t.key)&&void 0!==o?o:t.id))}),Rn?i("td",n({className:"ag-drill__buttons"},{children:Bn(e).map(function(t){var l,r,o=Ue==="".concat(e.id,":").concat(null!==(l=t.id)&&void 0!==l?l:t.label);return i("button",n({type:"button",disabled:o,"aria-busy":o||void 0,onClick:function(){return function(e,n){var t,l=e.confirm?S(e.confirm,C(ee,Y,n),{},!1):"";"call"!==e.type||!(null!==(t=e.ask)&&void 0!==t?t:[]).length&&!l?l&&!window.confirm(l)||On(e,n,{}):ze({button:e,row:n,question:l})}(t,e)}},{children:o?"…":t.label}),null!==(r=t.id)&&void 0!==r?r:t.label)})})):null,Kn?i("td",{children:i(u,{className:"ag-drill__open","aria-hidden":"true"})}):null]}),e.id);var t})})]})),Be&&!be.length?i("p",n({className:"ag-drill__state"},{children:"Loading rows…"})):null,Be||Nn.length||Pe?null:i("p",n({className:"ag-drill__state"},{children:"No rows found."})),Pe?i("p",n({className:"ag-drill__state ag-drill__state--error"},{children:Pe})):null]})),r("footer",n({className:"ag-drill__footer"},{children:[i("span",{children:"rows"===en&&je?"".concat(be.length," of ").concat(je):""}),Se?i("button",n({type:"button",onClick:function(){return t(Q,void 0,void 0,function(){var n,t,r,i;return l(this,function(l){switch(l.label){case 0:if(Be||!Se)return[2];n=Ve.current,Oe(!0),Ie(null),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,pn(!0,null==n?void 0:n.signal)];case 2:return!(t=l.sent())||(null==n?void 0:n.signal.aborted)?[2]:(me(function(n){return e(e([],n,!0),t.rows,!0)}),xe(t.hasMore),we(null!==(i=t.cursor)&&void 0!==i?i:null),_e(t.offset),[3,5]);case 3:return r=l.sent(),(null==n?void 0:n.signal.aborted)||Ie(r instanceof Error?r.message:"More rows couldn't be loaded."),[3,5];case 4:return(null==n?void 0:n.signal.aborted)||Oe(!1),[7];case 5:return[2]}})})},disabled:Be},{children:Be?"Loading…":"Show more"})):null]})),qe?i(B,{button:qe.button,question:qe.question,onCancel:function(){return ze(null)},onSubmit:function(e){var n=qe.button,t=qe.row;ze(null),On(n,t,e)}}):null]}))}export{O as default};
1
+ import{__spreadArray as e,__assign as n,__awaiter as t,__generator as l}from"../../../_virtual/_tslib.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Search as o,X as a,ChevronRight as u}from"lucide-react";import{useMemo as c,useState as d,useRef as s,useEffect as v}from"react";import{toIsoDay as y,fetchLevelRows as f,fetchInsightsDrivers as h,fetchDrillTableRows as p}from"../../api/insightsApi.js";import{formatHeaderDate as b,CriticalityChip as m,MovementChip as g}from"./agPrimitives.js";import{useInsights as k}from"./insightsContextCore.js";import{formatFigure as w}from"./insightsFormat.js";var K=/\{([^{}]+)\}/g;function N(e){var t=e.range,l=e.dashboardRange,o=e.onApply,a=d(t),u=a[0],c=a[1],s=!u.start||!u.end||u.start>u.end;return r("form",n({className:"ag-drill__dates","aria-label":"Table date range",onSubmit:function(e){e.preventDefault(),s||o(u)}},{children:[r("label",{children:["From",i("input",{type:"date",required:!0,value:u.start,max:u.end||void 0,onChange:function(e){var t=e.target.value;c(function(e){return n(n({},e),{start:t})})}})]}),r("label",{children:["To",i("input",{type:"date",required:!0,value:u.end,min:u.start||void 0,onChange:function(e){var t=e.target.value;c(function(e){return n(n({},e),{end:t})})}})]}),i("button",n({type:"submit",disabled:s},{children:"Apply"})),i("button",n({type:"button",onClick:function(){c(l),o(l)}},{children:"Use dashboard range"})),u.start&&u.end&&u.start>u.end?i("span",n({role:"alert"},{children:"From must be on or before To."})):null]}))}var _=function(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},C=function(e,n){return n.split(".").reduce(function(e,n){return e&&"object"==typeof e?e[n]:void 0},e)};function S(e,n){if(null==e||""===e)return"—";if("date"===n&&"string"==typeof e){var t=new Date("".concat(e.slice(0,10),"T00:00:00"));return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}var l="number"==typeof e?e:"string"==typeof e&&""!==e.trim()&&!Number.isNaN(Number(e))&&n&&"text"!==n&&"chip"!==n?Number(e):null;return null!==l?"percent"===n?"".concat(new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(l),"%"):new Intl.NumberFormat(void 0,{maximumFractionDigits:"rating"===n?2:1}).format(l):"object"==typeof e?JSON.stringify(e):String(e)}function x(e,n,t){var l,r,i,o,a,u=n.trail;return{record:t.record,context:{row:null!==(r=null===(l=u[u.length-1])||void 0===l?void 0:l.label)&&void 0!==r?r:"",parent:null!==(o=null===(i=u[u.length-2])||void 0===i?void 0:i.label)&&void 0!==o?o:"",day:null!==(a=n.day)&&void 0!==a?a:"",startDate:y(e.range.startDate),endDate:y(e.range.endDate),trail:Object.fromEntries(u.map(function(e){return[e.entityKey,e.label]}))}}}var T=function(e,n,t,l){return e.replace(K,function(e,r){var i=function(e,n,t){var l=t.trim();return l.startsWith("context.")?C(e.context,l.slice(8)):l.startsWith("input.")?n[l.slice(6)]:C(e.record,l)}(n,t,r),o=null==i?"":"object"==typeof i?JSON.stringify(i):String(i);return l?encodeURIComponent(o):o})},D=function(e,n,t){return"string"==typeof e?T(e,n,t,!1):Array.isArray(e)?e.map(function(e){return D(e,n,t)}):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(function(e){var l=e[0],r=e[1];return[l,D(r,n,t)]})):e},j=new Set,E=["good","warning","bad","info","neutral"],B=function(e){return String(null!=e?e:"").trim().toLowerCase().replace(/[\s_-]+/g," ")};function O(e){var t,l=e.text,r=e.value,o=e.colors,a=o?null===(t=Object.entries(o).find(function(e){var n=e[0];return B(n)===B(r)}))||void 0===t?void 0:t[1]:void 0;if(a&&"object"==typeof a)return i("span",n({className:"ag-drill__chip",style:n({background:a.background,color:a.color},a.border?{boxShadow:"inset 0 0 0 1px ".concat(a.border)}:{})},{children:l}));var u="string"==typeof a&&E.includes(a)?a:"neutral";return i("span",n({className:"ag-drill__chip ag-drill__chip--".concat(u)},{children:l}))}function A(e){var t,l=e.button,o=e.question,u=e.onCancel,c=e.onSubmit,y=d({}),f=y[0],h=y[1],p=s(null);v(function(){var e;return null===(e=p.current)||void 0===e?void 0:e.focus()},[]);var b=null!==(t=l.ask)&&void 0!==t?t:[],m=b.some(function(e){var n;return!(null===(n=f[e.key])||void 0===n?void 0:n.trim())});return i("div",n({className:"ag-drill__dialog",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&u()}},{children:r("form",n({className:"ag-drill__dialog-box",role:"dialog","aria-modal":"true","aria-label":l.label,onSubmit:function(e){e.preventDefault(),m||c(f)},onKeyDown:function(e){"Escape"===e.key&&(e.stopPropagation(),u())}},{children:[r("header",{children:[i("strong",{children:l.label}),i("button",n({type:"button","aria-label":"Cancel",onClick:u},{children:i(a,{"aria-hidden":"true"})}))]}),o?i("p",{children:o}):null,b.map(function(e,t){var l;return r("label",{children:[i("span",{children:e.label}),i("input",{ref:0===t?function(e){p.current=e}:void 0,value:null!==(l=f[e.key])&&void 0!==l?l:"",onChange:function(t){return h(function(l){var r;return n(n({},l),((r={})[e.key]=t.target.value,r))})},required:!0})]},e.key)}),r("footer",{children:[i("button",n({type:"button",onClick:u},{children:"Cancel"})),i("button",n({ref:b.length?void 0:function(e){p.current=e},type:"submit",disabled:m},{children:l.label}))]})]}))}))}function P(K){var E,B,P,I,R,M,L,F,q,z,J,U,H,W,G,Q,V,X=this,Y=K.table,Z=K.tabEntityKey,$=K.context,ee=K.onRowClick,ne=K.className,te=k(),le=$.trail.length>0,re=c(function(){return function(e,t,l){var r,i,o,a,u,c={filterBy:l?"trail":"none",period:l?"day":"range"};return(null===(r=e.views)||void 0===r?void 0:r.length)?e.views.map(function(t){var l,r,i,o,a,u;return n(n({},t),{source:null!==(l=t.source)&&void 0!==l?l:"insights",filterBy:null!==(r=t.filterBy)&&void 0!==r?r:"row"===t.scope?"row":c.filterBy,period:null!==(i=t.period)&&void 0!==i?i:c.period,onRowClick:null!==(o=t.onRowClick)&&void 0!==o?o:e.onRowClick,buttons:null!==(u=null!==(a=t.buttons)&&void 0!==a?a:e.buttons)&&void 0!==u?u:[]})}):[{source:null!==(i=e.source)&&void 0!==i?i:"insights",entityKey:t,tableKey:e.tableKey,columns:e.columns,onRowClick:e.onRowClick,filterBy:l?null!==(o=e.filterBy)&&void 0!==o?o:c.filterBy:"none",period:l?null!==(a=e.period)&&void 0!==a?a:c.period:"range",buttons:null!==(u=e.buttons)&&void 0!==u?u:[]}]}(Y,Z,le)},[Y,Z,le]),ie=re.map(function(e){var n;return"".concat(e.source,":").concat(null!==(n=e.entityKey)&&void 0!==n?n:e.tableKey)}).join("|"),oe=d(0),ae=oe[0],ue=oe[1],ce=d(""),de=ce[0],se=ce[1],ve=d(""),ye=ve[0],fe=ve[1],he=d(Y.defaultSort),pe=he[0],be=he[1],me=d([]),ge=me[0],ke=me[1],we=d(null),Ke=we[0],Ne=we[1],_e=d(0),Ce=_e[0],Se=_e[1],xe=d(!1),Te=xe[0],De=xe[1],je=d(0),Ee=je[0],Be=je[1],Oe=d(!1),Ae=Oe[0],Pe=Oe[1],Ie=d(null),Re=Ie[0],Me=Ie[1],Le=d(null),Fe=Le[0],qe=Le[1],ze=d(null),Je=ze[0],Ue=ze[1],He=d(null),We=He[0],Ge=He[1],Qe=d(null),Ve=Qe[0],Xe=Qe[1],Ye=s(null);v(function(){return ue(0)},[ie]),v(function(){var e=setTimeout(function(){return fe(de.trim())},300);return function(){return clearTimeout(e)}},[de]);var Ze=re[Math.min(ae,re.length-1)],$e=$.trail,en=$e[$e.length-1],nn=null!==(E=Y.pageSize)&&void 0!==E?E:10,tn=Ze&&"table"!==Ze.source?en&&Ze.entityKey&&!(null==te?void 0:te.isChildOf(Ze.entityKey,en.entityKey))?"movers":"rows":"table",ln="rows"===tn&&en?en.nodeKey:void 0,rn=c(function(){var n,t,l;if(!te||!Ze||"table"===Ze.source)return[];if(null===(n=Ze.columns)||void 0===n?void 0:n.length)return Ze.columns;var r=te.entityKpis(null!==(t=Ze.entityKey)&&void 0!==t?t:"").slice(0,4);return e([{key:"label",source:"field",label:te.entityName(null!==(l=Ze.entityKey)&&void 0!==l?l:"")}],r.map(function(e){return{key:e,source:"kpi",show:"both"}}),!0)},[te,Ze]),on=rn.find(function(e){return"children"===e.source}),an=null!==(B=null==te?void 0:te.headlineKpi)&&void 0!==B?B:"",un=$e.map(function(e){return"".concat(e.entityKey,":").concat(e.nodeKey)}).join("|"),cn=JSON.stringify([null==te?void 0:te.rangeKey,null==te?void 0:te.api.configId,ie,un,$.day]),dn=le&&"table"===tn,sn=c(function(){return te?"day"===(null==Ze?void 0:Ze.period)&&$.day?{start:$.day,end:$.day}:{start:y(te.range.startDate),end:y(te.range.endDate)}:{start:"",end:""}},[te,null==Ze?void 0:Ze.period,$.day]),vn=dn&&(null==Ve?void 0:Ve.scope)===cn?Ve.range:sn,yn=c(function(){if(!te||!Ze)return{};var e=n({},te.sidebarFilters);return("trail"===Ze.filterBy?$e:"row"===Ze.filterBy?$e.slice(-1):[]).forEach(function(n){var t=te.labelColumnOf(n.entityKey);t&&n.label&&(e[t]=[n.label])}),e},[te,Ze,un]),fn=JSON.stringify(yn),hn="table"===tn?void 0:"chip.criticality"===(null==pe?void 0:pe.key)?"criticality":null==pe?void 0:pe.key,pn="table"===tn||null==pe?void 0:pe.order,bn="table"===tn?"":ye,mn=function(e,r){return t(X,void 0,void 0,function(){var t,i,o,a,u,c,d,s,v,y,b;return l(this,function(l){switch(l.label){case 0:if(!te||!Ze)return[2,void 0];if("table"!==tn)return[3,2];if(!Ze.tableKey)throw new Error("Pick a Table Builder table for this list.");return[4,p(te.api,{tableKey:Ze.tableKey,startDay:vn.start,endDay:vn.end,filters:yn,pageSize:nn,cursor:e?Ke:null},r)];case 1:return t=l.sent(),i=e?ge.length:0,[2,{rows:t.rows.map(function(e,n){return{id:"t".concat(i+n),record:e}}),count:t.count,hasMore:t.hasNext,cursor:t.nextCursor,offset:0}];case 2:return"movers"!==tn?[3,4]:(o=e?Ce:0,[4,h(te.api,{dataDay:null!==(s=$.day)&&void 0!==s?s:void 0,kpiId:an,parentNodeKey:null==en?void 0:en.nodeKey,entityKey:Ze.entityKey,tab:"drivers",limit:nn,offset:o,filters:te.range.filters},r)]);case 3:return a=l.sent(),u=a.rows.map(function(e){return function(e,n){var t,l,r,i,o;return{rank:e.rank,nodeKey:e.nodeKey,label:e.label,parent:null,metrics:(t={},t[n]={value:e.value,previous:e.previous,deltaPct:e.deltaPct,direction:e.changeDirection,tone:e.tone},t),barPct:null,chip:{criticality:e.criticality,movementType:e.movementType},report:{reportId:null!==(r=null===(l=e.report)||void 0===l?void 0:l.reportId)&&void 0!==r?r:null,status:(null===(i=e.report)||void 0===i?void 0:i.reportId)?"generated":"none",kpiId:n},action:null,children:[],entityKey:null!==(o=e.entityKey)&&void 0!==o?o:null}}(e,an)}),c=a,[2,{rows:u.map(function(e){return{id:e.nodeKey,record:e,insights:e}}),count:null!==(v=c.total)&&void 0!==v?v:o+u.length,hasMore:Boolean(c.hasMore),cursor:null,offset:o+u.length}];case 4:return[4,f(te.api,null!==(y=Ze.entityKey)&&void 0!==y?y:"",n({},te.range),{sort:hn,order:pn,search:bn||void 0,pageSize:nn,parentNodeKey:ln,includeChildren:on?null!==(b=on.max)&&void 0!==b?b:3:void 0,childEntityKey:null==on?void 0:on.childEntityKey,cursor:e&&null!=Ke?Ke:void 0},r)];case 5:return[2,{rows:(d=l.sent()).rows.map(function(e){var t,l;return{id:e.nodeKey,record:e,insights:n(n({},e),{entityKey:null!==(l=null!==(t=e.entityKey)&&void 0!==t?t:Ze.entityKey)&&void 0!==l?l:null})}}),count:d.count,hasMore:d.hasNext,cursor:d.nextCursor,offset:0}]}})})};if(v(function(){if(te&&Ze){var e=new AbortController;return Ye.current=e,Pe(!0),Me(null),ke([]),Ne(null),Se(0),qe(null),mn(!1,e.signal).then(function(n){var t;n&&!e.signal.aborted&&(ke(n.rows),Be(n.count),De(n.hasMore),Ne(null!==(t=n.cursor)&&void 0!==t?t:null),Se(n.offset))}).catch(function(n){e.signal.aborted||"AbortError"===(null==n?void 0:n.name)||Me(n instanceof Error?n.message:"The rows couldn't be loaded.")}).finally(function(){e.signal.aborted||Pe(!1)}),function(){return e.abort()}}},[null==te?void 0:te.api,null==te?void 0:te.revision,null==te?void 0:te.rangeKey,ie,ae,tn,ln,un,$.day,vn.start,vn.end,fn,bn,hn,pn,nn,null==on?void 0:on.childEntityKey]),!te||!Ze)return null;var gn="table"===tn?function(t,l,r){var i,o,a=l.tableKey?t.tableSource(l.tableKey):void 0,u=(null===(i=null==a?void 0:a.columns)||void 0===i?void 0:i.length)?a.columns:Object.keys(null!=r?r:{}).map(function(e){return{key:e,label:_(e)}}),c=null!==(o=l.columns)&&void 0!==o?o:[];return e(e([],c.filter(function(e){return e.key&&u.some(function(n){return n.key===e.key})}),!0),u.filter(function(e){return!c.some(function(n){return n.key===e.key})}).map(function(e){return n(n({},e),{source:"field"})}),!0).filter(function(e){return!e.hidden}).map(function(e){var t,l,r,i,o,a;return n(n({},e),{source:"field",sortable:null!==(t=e.sortable)&&void 0!==t?t:null===(l=u.find(function(n){return n.key===e.key}))||void 0===l?void 0:l.sortable,label:null!==(o=null!==(r=e.label)&&void 0!==r?r:null===(i=u.find(function(n){return n.key===e.key}))||void 0===i?void 0:i.label)&&void 0!==o?o:_(null!==(a=e.key)&&void 0!==a?a:"")})})}(te,Ze,null===(P=ge[0])||void 0===P?void 0:P.record):rn,kn=te.hostTables["table"===Ze.source?null!==(I=Ze.tableKey)&&void 0!==I?I:"":"insights.".concat(null!==(R=Ze.entityKey)&&void 0!==R?R:"")],wn=(null===(M=null==kn?void 0:kn.columns)||void 0===M?void 0:M.length)?kn.columns:null,Kn=function(e){return e.insights?function(e){var n,t,l,r,i,o,a,u,c,d,s,v,y,f,h,p,b,m={id:e.nodeKey,nodeKey:e.nodeKey,label:null!==(n=e.label)&&void 0!==n?n:e.nodeKey,entityKey:null!==(t=e.entityKey)&&void 0!==t?t:null,parent:null!==(r=null===(l=e.parent)||void 0===l?void 0:l.label)&&void 0!==r?r:null,criticality:null!==(o=null===(i=e.chip)||void 0===i?void 0:i.criticality)&&void 0!==o?o:null,movementType:null!==(u=null===(a=e.chip)||void 0===a?void 0:a.movementType)&&void 0!==u?u:null,reportId:null!==(d=null===(c=e.report)||void 0===c?void 0:c.reportId)&&void 0!==d?d:null,reportStatus:null!==(v=null===(s=e.report)||void 0===s?void 0:s.status)&&void 0!==v?v:null,actionStatus:null!==(f=null===(y=e.action)||void 0===y?void 0:y.status)&&void 0!==f?f:null,assignee:null!==(p=null===(h=e.action)||void 0===h?void 0:h.assigneeName)&&void 0!==p?p:null,children:e.children.map(function(e){return e.label}).filter(Boolean),__row:e};return Object.entries(null!==(b=e.metrics)&&void 0!==b?b:{}).forEach(function(e){var n,t,l,r=e[0],i=e[1];m[r]=null!==(n=null==i?void 0:i.value)&&void 0!==n?n:null,m["".concat(r,"_delta")]=null!==(t=null==i?void 0:i.deltaPct)&&void 0!==t?t:null,m["".concat(r,"_previous")]=null!==(l=null==i?void 0:i.previous)&&void 0!==l?l:null}),m}(e.insights):n({id:e.id},e.record)},Nn="table"===tn?"none":null!==(L=Ze.onRowClick)&&void 0!==L?L:"none",_n="none"!==Nn,Cn="table"===tn?e([],ge,!0).filter(function(e){return!ye||(wn?wn.map(function(e){return e.key}):gn.map(function(e){var n;return null!==(n=e.key)&&void 0!==n?n:""})).some(function(n){var t;return String(null!==(t=e.record[n])&&void 0!==t?t:"").toLowerCase().includes(ye.toLowerCase())})}).sort(function(e,n){if(!(null==pe?void 0:pe.key))return 0;var t=e.record[pe.key],l=n.record[pe.key],r=Number(t),i=Number(l),o=null==t||null==l||""===t||""===l||Number.isNaN(r)||Number.isNaN(i)?String(null!=t?t:"").localeCompare(String(null!=l?l:"")):r-i;return"asc"===pe.order?o:-o}):ge,Sn=function(e){return"movers"!==tn&&!0===e.sortable},xn=function(e){var n;if(Sn(e)){var t=null!==(n=e.key)&&void 0!==n?n:"";be(function(e){return{key:t,order:(null==e?void 0:e.key)===t&&"desc"===e.order?"asc":"desc"}})}},Tn=function(e){var n;return(null===(n=te.tableSource(null!=e?e:""))||void 0===n?void 0:n.title)||_(null!=e?e:"")},Dn="table"===Ze.source?Tn(Ze.tableKey):te.entityName(null!==(F=Ze.entityKey)&&void 0!==F?F:""),jn="table"===Ze.source?Dn:te.entityPluralName(null!==(q=Ze.entityKey)&&void 0!==q?q:""),En=function(e){var n;return e.title||("table"===e.source?Tn(e.tableKey):te.entityPluralName(null!==(n=e.entityKey)&&void 0!==n?n:""))},Bn=re.length>1?"Drill down in {row}":le?"table"===Ze.source?"{part}":te.labels.drillTableTitle:"{parts}",On=(null!==(z=Y.title)&&void 0!==z?z:Bn).replace(/\{row\}/g,null!==(J=null==en?void 0:en.label)&&void 0!==J?J:"").replace(/\{parent\}/g,null!==(H=null===(U=$e[$e.length-2])||void 0===U?void 0:U.label)&&void 0!==H?H:"").replace(/\{day\}/g,$.day?b($.day):"").replace(/\{parts\}|\{plural\}/g,jn).replace(/\{part\}/g,Dn).replace(/\s+/g," ").trim(),An=function(e){return Ze.buttons.filter(function(n){var t,l,r;if(n.adminOnly&&!te.viewer.isAdmin)return!1;if(!("host"!==n.type||n.handler&&te.actionHandlers[n.handler]))return j.has(null!==(t=n.handler)&&void 0!==t?t:"")||(j.add(null!==(l=n.handler)&&void 0!==l?l:""),console.warn('Decision Advantage: no host handler named "'.concat(null!==(r=n.handler)&&void 0!==r?r:"",'" is registered, so its button is hidden.'))),!1;if(n.when){var i=C(e.record,n.when);if(null==i||""===i)return!1}return!0})},Pn=function(e,n,r){return t(X,void 0,void 0,function(){var t,i,o,a,u,c,d,s,v,y,f,h,p,b,m,g,k,w,K,N,_,C;return l(this,function(l){switch(l.label){case 0:t=x(te,$,n),i="".concat(n.id,":").concat(null!==(b=e.id)&&void 0!==b?b:e.label),qe(null),l.label=1;case 1:if(l.trys.push([1,9,10,11]),"open"===e.type){if(o=T(null!==(m=e.url)&&void 0!==m?m:"",t,r,!0),/^https:\/\//i.test(o))window.open(o,"_blank","noopener,noreferrer");else{if(!/^mailto:/i.test(o))throw new Error("This link isn't allowed: only https and mailto links open.");window.location.href=o}return[2]}return Ge(i),"host"!==e.type?[3,3]:[4,(0,te.actionHandlers[null!==(g=e.handler)&&void 0!==g?g:""])({button:e,row:n.record,context:t.context,inputs:r})];case 2:return a=l.sent(),qe({tone:"ok",text:a&&a.message||"".concat(e.label,": done.")}),[2];case 3:if("https:"!==(u=new URL(T(null!==(k=e.url)&&void 0!==k?k:"",t,r,!0))).protocol)throw new Error("Only https APIs can be called.");return c=null!==(w=e.method)&&void 0!==w?w:"POST",d={Accept:"application/json"},Object.entries(null!==(K=e.headers)&&void 0!==K?K:{}).forEach(function(e){var n=e[0],l=e[1];d[n]=T(String(l),t,r,!1)}),te.api.accessToken&&te.approvedApiHosts.includes(u.host.toLowerCase())&&(d.Authorization="Bearer ".concat(te.api.accessToken)),(s="GET"!==c&&void 0!==e.body&&null!==e.body)&&(d["Content-Type"]="application/json"),[4,fetch(u.toString(),{method:c,headers:d,body:s?JSON.stringify(D(e.body,t,r)):void 0})];case 4:v=l.sent(),y="",l.label=5;case 5:return l.trys.push([5,7,,8]),[4,v.json()];case 6:return f=l.sent(),h=null==f?void 0:f.error,y=String(null!==(C=null!==(_=null!==(N=null==f?void 0:f.message)&&void 0!==N?N:null==h?void 0:h.errorMessage)&&void 0!==_?_:null==f?void 0:f.detail)&&void 0!==C?C:""),[3,8];case 7:return l.sent(),y="",[3,8];case 8:if(!v.ok)throw new Error(y||"".concat(e.label," failed (status ").concat(v.status,")."));return qe({tone:"ok",text:y||"".concat(e.label,": done.")}),[3,11];case 9:return p=l.sent(),qe({tone:"error",text:p instanceof Error?p.message:"".concat(e.label," failed.")}),[3,11];case 10:return Ge(null),[7];case 11:return[2]}})})},In=function(e){var n,t,l,r=null!==(t=null!==(n=e.key)&&void 0!==n?n:e.id)&&void 0!==t?t:"",i="table"===Ze.source?Ze.tableKey:Ze.entityKey;return null!==(l=i?te.cellRenderers["".concat(i,".").concat(r)]:void 0)&&void 0!==l?l:te.cellRenderers[r]},Rn=function(e,t){var l,o,a,u,c,d,s,v,y,f,h=null!==(l=t.key)&&void 0!==l?l:"",p=In(t),b="kpi"===t.source&&e.insights?null===(o=e.insights.metrics[h])||void 0===o?void 0:o.value:"children"===t.source&&e.insights?e.insights.children.map(function(e){return e.label}).filter(Boolean):"label"===h&&e.insights?e.insights.label||e.insights.nodeKey:C(e.record,h);if(null==p?void 0:p.render){var k=p.render({column:t,value:b,record:e.record,row:e.insights,entityKey:Ze.entityKey,tableKey:Ze.tableKey});if(void 0!==k)return k}if(e.insights){var K=null===(a=te.renderInsightsCell)||void 0===a?void 0:a.call(te,{column:t,row:e.insights,entityKey:null!==(u=Ze.entityKey)&&void 0!==u?u:""});if(void 0!==K)return K}if("custom"===t.source)return null!==(c=t.emptyText)&&void 0!==c?c:"—";var N=null===(d=e.insights)||void 0===d?void 0:d.chip;if("label"===h&&e.insights&&!(null==p?void 0:p.as)&&((null==N?void 0:N.criticality)||(null==N?void 0:N.movementType))){var _=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return gn.some(function(n){var t;return e.includes(null!==(t=n.key)&&void 0!==t?t:"")})};return r("span",n({className:"ag-drill__name"},{children:[i("span",{children:S(b,t.format)}),_("criticality","chip.criticality")?null:i(m,{criticality:N.criticality}),_("movementType","chip.movementType")?null:i(g,{movementType:N.movementType,direction:N.direction,good:te.goodDirection(N.kpiId||an)})]}))}if("kpi"===t.source&&e.insights&&!(null==p?void 0:p.as)){var x=e.insights.metrics[h],T=t.format&&"number"!==t.format?null:w(null==x?void 0:x.value,null===(s=te.kpis[h])||void 0===s?void 0:s.format),D=null!=T?T:S(null==x?void 0:x.value,t.format),j=null==(null==x?void 0:x.deltaPct)?"—":"".concat(x.deltaPct>0?"↑":x.deltaPct<0?"↓":""," ").concat(Math.abs(x.deltaPct),"%");return"delta"===t.show?i("span",n({className:(null==x?void 0:x.tone)?"ag-drill__change--".concat(x.tone):void 0},{children:j})):"value"===t.show?D:r("span",n({className:"ag-drill__metric"},{children:[i("strong",{children:D}),i("small",n({className:(null==x?void 0:x.tone)?"ag-drill__change--".concat(x.tone):void 0},{children:j}))]}))}if("children"===t.source&&e.insights&&!(null==p?void 0:p.as)){var E=Array.from(new Set(b)),B=null!==(v=t.max)&&void 0!==v?v:3,A=E.length?"".concat(E.slice(0,B).join(", ")).concat(E.length>B?" +".concat(E.length-B):""):null!==(y=t.emptyText)&&void 0!==y?y:"—";return i("span",n({className:"ag-drill__contributors",title:E.join(", ")||void 0},{children:A}))}var P=null!==(f=null==p?void 0:p.as)&&void 0!==f?f:t.format;if("link"===P){var I="string"==typeof b?b:"";return/^https:\/\//i.test(I)?i("a",n({href:I,target:"_blank",rel:"noopener noreferrer"},{children:I})):S(b,"text")}var R=S(b,"chip"===P?"text":P);return"—"===R&&t.emptyText?t.emptyText:"chip"!==P&&!(null==p?void 0:p.colors)||"—"===R?R:i(O,{text:R.replace(/_/g," "),value:b,colors:null==p?void 0:p.colors})},Mn=function(e){e.insights&&(null==ee||ee(e.insights,Nn))},Ln=Ze.buttons.length>0,Fn=function(e){var n;return null!==(n=e.align)&&void 0!==n?n:"kpi"===e.source?"right":"left"},qn="ag-drill-".concat(String(null!==(W=Y.id)&&void 0!==W?W:On).replace(/[^a-z0-9]+/gi,"-")),zn=!1!==Y.search&&"movers"!==tn;return r("section",n({className:"ag-drill".concat(ne?" ".concat(ne):""),"aria-labelledby":qn,style:null===(G=null==kn?void 0:kn.card)||void 0===G?void 0:G.root},{children:[r("header",n({className:"ag-drill__header",style:null===(Q=null==kn?void 0:kn.card)||void 0===Q?void 0:Q.header},{children:[r("div",{children:[i("h3",n({id:qn,style:null===(V=null==kn?void 0:kn.card)||void 0===V?void 0:V.title},{children:On})),"movers"===tn?r("span",{children:["Rows that moved",$.day?" on ".concat(b($.day)):""]}):null]}),zn?r("label",n({className:"ag-drill__search"},{children:[i(o,{"aria-hidden":"true"}),i("input",{type:"search",value:de,onChange:function(e){return se(e.target.value)},placeholder:"Search ".concat(jn.toLowerCase(),"…"),"aria-label":"Search ".concat(jn)})]})):null]})),dn?i(N,{range:vn,dashboardRange:{start:y(te.range.startDate),end:y(te.range.endDate)},onApply:function(e){return Xe({scope:cn,range:e})}},"".concat(cn,":").concat(vn.start,":").concat(vn.end)):null,re.length>1?i("div",n({className:"ag-drill__tabs",role:"tablist","aria-label":"What this table lists"},{children:re.map(function(e,t){var l;return i("button",n({type:"button",role:"tab","aria-selected":t===ae,className:t===ae?"is-active":void 0,onClick:function(){ue(t),se(""),fe(""),be(Y.defaultSort)}},{children:En(e)}),"".concat(e.source,":").concat(null!==(l=e.entityKey)&&void 0!==l?l:e.tableKey,":").concat(t))})})):null,Fe?r("p",n({className:"ag-drill__notice ag-drill__notice--".concat(Fe.tone),role:"status"},{children:[Fe.text,i("button",n({type:"button","aria-label":"Dismiss",onClick:function(){return qe(null)}},{children:i(a,{"aria-hidden":"true"})}))]})):null,r("div",n({className:"ag-drill__table-wrap","aria-live":"polite"},{children:[r("table",n({className:"ag-drill__table"},{children:[i("thead",{children:r("tr",{children:[wn?wn.map(function(e){var t,l,o=gn.find(function(n){return n.key===e.key}),a=n(n({},o),{key:e.key,source:null!==(t=null==o?void 0:o.source)&&void 0!==t?t:"field",sortable:null!==(l=e.sortable)&&void 0!==l?l:null==o?void 0:o.sortable});return i("th",n({className:e.headerClassName,style:n(n({},e.style),e.headerStyle),"aria-sort":(null==pe?void 0:pe.key)===e.key?"asc"===pe.order?"ascending":"descending":void 0},{children:Sn(a)?r("button",n({type:"button",onClick:function(){return xn(a)}},{children:[e.header,i("span",n({"aria-hidden":"true"},{children:(null==pe?void 0:pe.key)===e.key?"asc"===pe.order?"↑":"↓":"↕"}))]})):e.header}),e.key)}):gn.map(function(e){var t,l,o,a,u,c=null!==(l=null!==(t=e.key)&&void 0!==t?t:e.id)&&void 0!==l?l:"",d=null!==(o=e.label)&&void 0!==o?o:"kpi"===e.source?te.kpiLabel(c):"children"===e.source?te.entityPluralName(null!==(a=e.childEntityKey)&&void 0!==a?a:""):_(null!==(u=c.split(".").pop())&&void 0!==u?u:c);return i("th",n({className:"ag-drill__col--".concat(Fn(e)," ").concat(e.hideBelow?"ag-drill__hide--".concat(e.hideBelow):""),style:{width:e.width},"aria-sort":(null==pe?void 0:pe.key)===c?"asc"===pe.order?"ascending":"descending":void 0},{children:Sn(e)?r("button",n({type:"button",onClick:function(){return xn(e)}},{children:[d,i("span",n({"aria-hidden":"true"},{children:(null==pe?void 0:pe.key)===c?"asc"===pe.order?"↑":"↓":"↕"}))]})):d}),"".concat(e.source,":").concat(c))}),Ln?i("th",{children:i("span",n({className:"ins-visually-hidden"},{children:"Actions"}))}):null,_n?i("th",{children:i("span",n({className:"ins-visually-hidden"},{children:"Open"}))}):null]})}),i("tbody",{children:Cn.map(function(e){return r("tr",n({className:_n?void 0:"is-static",tabIndex:_n?0:void 0,onClick:_n?function(n){n.target.closest("a,button,input,select,textarea")||Mn(e)}:void 0,onKeyDown:_n?function(n){return function(e,n){_n&&e.target===e.currentTarget&&("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),Mn(n)))}(n,e)}:void 0},{children:[wn?(t=Kn(e),wn.map(function(e){return i("td",n({className:e.bodyClassName,style:n(n({},e.style),e.bodyStyle)},{children:e.body(t)}),e.key)})):gn.map(function(t,l){var r,o,a=0===l?"th":"td",u=null===(r=In(t))||void 0===r?void 0:r.className;return i(a,n({scope:0===l?"row":void 0,className:"ag-drill__col--".concat(Fn(t)," ").concat(t.hideBelow?"ag-drill__hide--".concat(t.hideBelow):"").concat(u?" ".concat(u):"")},{children:Rn(e,t)}),"".concat(t.source,":").concat(null!==(o=t.key)&&void 0!==o?o:t.id))}),Ln?i("td",n({className:"ag-drill__buttons"},{children:An(e).map(function(t){var l,r,o=We==="".concat(e.id,":").concat(null!==(l=t.id)&&void 0!==l?l:t.label);return i("button",n({type:"button",disabled:o,"aria-busy":o||void 0,onClick:function(){return function(e,n){var t,l=e.confirm?T(e.confirm,x(te,$,n),{},!1):"";"call"!==e.type||!(null!==(t=e.ask)&&void 0!==t?t:[]).length&&!l?l&&!window.confirm(l)||Pn(e,n,{}):Ue({button:e,row:n,question:l})}(t,e)}},{children:o?"…":t.label}),null!==(r=t.id)&&void 0!==r?r:t.label)})})):null,_n?i("td",{children:i(u,{className:"ag-drill__open","aria-hidden":"true"})}):null]}),e.id);var t})})]})),Ae&&!ge.length?i("p",n({className:"ag-drill__state"},{children:"Loading rows…"})):null,Ae||Cn.length||Re?null:i("p",n({className:"ag-drill__state"},{children:"No rows found."})),Re?i("p",n({className:"ag-drill__state ag-drill__state--error"},{children:Re})):null]})),r("footer",n({className:"ag-drill__footer"},{children:[i("span",{children:"rows"===tn&&Ee?"".concat(ge.length," of ").concat(Ee):""}),Te?i("button",n({type:"button",onClick:function(){return t(X,void 0,void 0,function(){var n,t,r,i;return l(this,function(l){switch(l.label){case 0:if(Ae||!Te)return[2];n=Ye.current,Pe(!0),Me(null),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,mn(!0,null==n?void 0:n.signal)];case 2:return!(t=l.sent())||(null==n?void 0:n.signal.aborted)?[2]:(ke(function(n){return e(e([],n,!0),t.rows,!0)}),De(t.hasMore),Ne(null!==(i=t.cursor)&&void 0!==i?i:null),Se(t.offset),[3,5]);case 3:return r=l.sent(),(null==n?void 0:n.signal.aborted)||Me(r instanceof Error?r.message:"More rows couldn't be loaded."),[3,5];case 4:return(null==n?void 0:n.signal.aborted)||Pe(!1),[7];case 5:return[2]}})})},disabled:Ae},{children:Ae?"Loading…":"Show more"})):null]})),Je?i(A,{button:Je.button,question:Je.question,onCancel:function(){return Ue(null)},onSubmit:function(e){var n=Je.button,t=Je.row;Ue(null),Pn(n,t,e)}}):null]}))}export{P as default};
2
2
  //# sourceMappingURL=DrillTable.js.map
@@ -1,2 +1,2 @@
1
- import{__spreadArray as e,__assign as t}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as a,Fragment as i}from"react/jsx-runtime";import{useState as l,useEffect as r,useMemo as o,useRef as d}from"react";import{ChevronDown as u,Search as c,ChevronRight as s,X as y}from"lucide-react";import{L2Report as m}from"./AgReport.js";import{L1ReportModal as p}from"./L1Report.js";import v,{popupRowFromTable as h,DEFAULT_LEVEL as f}from"./DrillLevel.js";import{formatHeaderDate as b}from"./agPrimitives.js";import{useInsights as g}from"./insightsContextCore.js";import{OPEN_INSIGHTS_ENTITY_REPORT as K}from"./insightsUtils.js";function N(i){var o,u,c,m=i.target,p=i.onClose,K=i.onOpenL1,N=i.onOpenL2,_=d(null),w=g(),k=m.kpiId,D=l([]),E=D[0],C=D[1];r(function(){return C([])},[m.row.nodeKey]);var I=t(t({},h(w,t(t({},m.row),{entityKey:null!==(o=m.row.entityKey)&&void 0!==o?o:m.l2.tab.entityKey}))),{reportId:m.row.report.kpiId===k?m.row.report.reportId:null}),O=e([I],E,!0),L=O[O.length-1],R=l(m.dataDay),x=R[0],A=R[1],T=l(L.reportId?null:m.dataDay),j=T[0],S=T[1];r(function(){return A(m.dataDay)},[m.dataDay,m.row.nodeKey]),r(function(){return S(I.reportId?null:m.dataDay)},[I.reportId,m.dataDay,m.row.nodeKey]),r(function(){var e,t=document.activeElement,n=document.body.style.overflow;document.body.style.overflow="hidden",null===(e=_.current)||void 0===e||e.focus();var a=function(e){return"Escape"===e.key&&p()};return document.addEventListener("keydown",a),function(){var e;document.removeEventListener("keydown",a),document.body.style.overflow=n,null===(e=null==t?void 0:t.focus)||void 0===e||e.call(t)}},[p]);var M=I.label,P=null!==(u=null==w?void 0:w.matchDrillLevel(L.entityKey,O.slice(0,-1).map(function(e){return e.entityKey})))&&void 0!==u?u:f;return a("div",t({className:"ag-modal",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&p()}},{children:n("div",t({className:"ag-modal__dialog",role:"dialog","aria-modal":"true","aria-labelledby":"ag-l2-row-modal-title"},{children:[n("header",t({className:"ag-modal__head"},{children:[n("div",t({className:"ag-modal__detail-title"},{children:[n("div",t({className:"ag-modal__breadcrumb"},{children:[a("button",t({type:"button",onClick:K},{children:"L1"})),a(s,{"aria-hidden":"true"}),n("button",t({type:"button",onClick:N},{children:["Top ",null!==(c=null==w?void 0:w.entityPluralName(m.l2.tab.entityKey))&&void 0!==c?c:m.partName]})),a(s,{"aria-hidden":"true"}),E.length?a("button",t({type:"button",onClick:function(){return C([])}},{children:M})):a("strong",t({id:"ag-l2-row-modal-title"},{children:M})),E.map(function(e,i){return n("span",t({className:"ag-modal__crumb"},{children:[a(s,{"aria-hidden":"true"}),i===E.length-1?n("strong",t({id:"ag-l2-row-modal-title",title:e.partName},{children:[e.partName?"".concat(e.partName,": "):"",e.label]})):n("button",t({type:"button",title:e.partName,onClick:function(){return C(function(e){return e.slice(0,i+1)})}},{children:[e.partName?"".concat(e.partName,": "):"",e.label]}))]}),"".concat(e.nodeKey,"-").concat(i))})]})),a("span",t({className:"ag-modal__date"},{children:b(j||x)}))]})),a("button",t({ref:_,type:"button",className:"ag-modal__close","aria-label":"Close",onClick:p},{children:a(y,{"aria-hidden":"true"})}))]})),a("div",t({className:"ag-modal__body"},{children:a(v,{trail:O,level:P,kpiId:k,dataDay:x,reportDay:j,onReportDay:function(e){A(e),S(e)},tier2Kpis:m.tier2Kpis,onOpen:function(t){return C(function(n){return e(e([],n,!0),[t],!1)})}})}))]}))}))}function _(e){var i=e.target,l=e.onClose,o=e.onOpenL1,u=e.onOpenRow,c=d(null),p=g();return r(function(){var e,t=document.activeElement,n=document.body.style.overflow;document.body.style.overflow="hidden",null===(e=c.current)||void 0===e||e.focus();var a=function(e){return"Escape"===e.key&&l()};return document.addEventListener("keydown",a),function(){var e;document.removeEventListener("keydown",a),document.body.style.overflow=n,null===(e=null==t?void 0:t.focus)||void 0===e||e.call(t)}},[l]),p?a("div",t({className:"ag-modal",role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&l()}},{children:n("div",t({className:"ag-modal__dialog",role:"dialog","aria-modal":"true","aria-labelledby":"ag-l2-overview-modal-title"},{children:[n("header",t({className:"ag-modal__head"},{children:[n("div",t({className:"ag-modal__detail-title"},{children:[n("div",t({className:"ag-modal__breadcrumb"},{children:[a("button",t({type:"button",onClick:o},{children:"L1"})),a(s,{"aria-hidden":"true"}),n("strong",t({id:"ag-l2-overview-modal-title"},{children:["Top ",p.entityPluralName(i.tab.entityKey)]}))]})),a("span",t({className:"ag-modal__date"},{children:b(i.dataDay)}))]})),a("button",t({ref:c,type:"button",className:"ag-modal__close","aria-label":"Close",onClick:l},{children:a(y,{"aria-hidden":"true"})}))]})),a("div",t({className:"ag-modal__body"},{children:a(m,{tab:i.tab,title:i.title,partName:i.partName,partKpis:i.partKpis,search:"",dataDay:i.dataDay,onOpenRow:function(e,t,n){var a;return u({row:e,partName:i.partName,kpiId:p.headlineKpi||t,dataDay:n,tier2Kpis:null!==(a=i.tab.tier2Kpis)&&void 0!==a?a:p.tierKpis[2],l2:i})}})}))]}))})):null}function w(d){var s,y,v,h,f,b=d.tabs,w=d.insightsConfig,k=g(),D=l(0),E=D[0],C=D[1],I=l(!1),O=I[0],L=I[1],R=l(""),x=R[0],A=R[1],T=l(""),j=T[0],S=T[1],M=l(null),P=M[0],F=M[1],G=l(null),X=G[0],B=G[1],U=l(null),W=U[0],q=U[1];r(function(){var e=setTimeout(function(){return S(x.trim())},300);return function(){return clearTimeout(e)}},[x]),r(function(){A(""),S("")},[E]);var z=o(function(){var e,t={};return(null!==(e=null==w?void 0:w.hierarchy)&&void 0!==e?e:[]).forEach(function(e){var n;return(null!==(n=e.entities)&&void 0!==n?n:[]).forEach(function(e){var n,a;(null==e?void 0:e.entityKey)&&(t[e.entityKey]={name:null!==(n=e.name)&&void 0!==n?n:"",kpis:null!==(a=e.kpis)&&void 0!==a?a:[]})})}),t},[w]);if(r(function(){if(k){var t=k.entityOrder.length?e([],b,!0).sort(function(e,t){var n=k.entityOrder.indexOf(e.entityKey),a=k.entityOrder.indexOf(t.entityKey);return(n<0?Number.MAX_SAFE_INTEGER:n)-(a<0?Number.MAX_SAFE_INTEGER:a)}):b,n=function(e){var n,a,i,l,r,o,d=e,u=d.detail,c=(null==u?void 0:u.entityKey)?t.findIndex(function(e){return e.entityKey===u.entityKey}):-1;if(u&&!(c<0)){var s=t[c],y=(null===(n=z[s.entityKey])||void 0===n?void 0:n.name)||s.title||k.entityName(s.entityKey)||s.entityKey,m=k.headlineKpi||s.rankBy||(null===(a=s.listKpis)||void 0===a?void 0:a[0])||(null===(i=z[s.entityKey])||void 0===i?void 0:i.kpis[0])||"",p=u.dataDay||k.range.endDate.toISOString().slice(0,10),v={tab:s,title:s.title||y,partName:y,partKpis:null!==(r=null===(l=z[s.entityKey])||void 0===l?void 0:l.kpis)&&void 0!==r?r:[],dataDay:p};d.preventDefault(),q(null),B(null),C(c),F({row:{rank:0,nodeKey:u.nodeKey,label:u.label,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:m},action:null,children:[]},partName:y,kpiId:m,dataDay:p,tier2Kpis:null!==(o=s.tier2Kpis)&&void 0!==o?o:k.tierKpis[2],l2:v})}};return window.addEventListener(K,n),function(){return window.removeEventListener(K,n)}}},[k,b,z]),!k||!b.length)return null;var H=k.entityOrder.length?e([],b,!0).sort(function(e,t){var n=k.entityOrder.indexOf(e.entityKey),a=k.entityOrder.indexOf(t.entityKey);return(n<0?Number.MAX_SAFE_INTEGER:n)-(a<0?Number.MAX_SAFE_INTEGER:a)}):b,J=Math.min(E,H.length-1),Q=H[J],V=function(e){var t;return e.title||k.entityName(e.entityKey)||(null===(t=z[e.entityKey])||void 0===t?void 0:t.name)||e.entityKey},Y=(null===(s=z[Q.entityKey])||void 0===s?void 0:s.name)||V(Q),Z=Q.rankBy||(null===(y=Q.listKpis)||void 0===y?void 0:y[0])||(null===(v=z[Q.entityKey])||void 0===v?void 0:v.kpis[0])||"",$=Z?k.kpiLabel(Z).toLowerCase():"activity";return n("div",t({className:"ag-tabs"},{children:[n("div",t({className:"ag-tabs__head"},{children:[n("div",t({className:"ag-tabs__bar"},{children:[a("div",t({className:"ag-tabs__list",role:"tablist","aria-label":"Insights"},{children:H.map(function(e,n){return a("button",t({id:"ag-tab-".concat(n),type:"button",role:"tab","aria-selected":n===J,"aria-controls":"ag-tabpanel",className:n===J?"is-active":void 0,onClick:function(){F(null),C(n)}},{children:V(e)}),"".concat(e.entityKey,"-").concat(n))})})),a("button",t({type:"button",className:"ag-icon-button","aria-label":O?"Expand insights":"Collapse insights","aria-expanded":!O,onClick:function(){return L(function(e){return!e})}},{children:a(u,{"aria-hidden":"true",className:O?"is-closed":"is-open"})}))]})),O?null:a(i,{children:a("p",t({className:"ag-tabs__desc"},{children:Y?"".concat(k.entityPluralName(Q.entityKey)," with the highest ").concat($,"."):null}))})]})),O?null:n("div",t({className:"ag-tabs__body",role:"tabpanel",id:"ag-tabpanel","aria-labelledby":"ag-tab-".concat(J)},{children:[a(m,{tab:Q,title:V(Q),partName:Y,partKpis:null!==(f=null===(h=z[Q.entityKey])||void 0===h?void 0:h.kpis)&&void 0!==f?f:[],search:j,headerAction:n("label",t({className:"ag-search"},{children:[a(c,{"aria-hidden":"true"}),a("input",{type:"search",value:x,onChange:function(e){return A(e.target.value)},placeholder:"Search ".concat(Y.toLowerCase(),"..."),"aria-label":"Search ".concat(k.entityPluralName(Q.entityKey))})]})),onOpenRow:function(e,n,a){var i,l,r,o,d,u,c=null!==(i=e.entityKey)&&void 0!==i?i:Q.entityKey;k.matchDrillLevel(c,[])?F({row:t(t({},e),{entityKey:c}),partName:Y,kpiId:k.headlineKpi||n,dataDay:a,tier2Kpis:null!==(o=Q.tier2Kpis)&&void 0!==o?o:k.tierKpis[2],l2:{tab:Q,title:V(Q),partName:Y,partKpis:null!==(u=null===(d=z[Q.entityKey])||void 0===d?void 0:d.kpis)&&void 0!==u?u:[],dataDay:a}}):k.openReport({reportId:null===(l=e.report)||void 0===l?void 0:l.reportId,nodeKey:e.nodeKey,kpiId:k.headlineKpi||n,dataDay:a,title:null!==(r=e.label)&&void 0!==r?r:e.nodeKey})}},J),P?a(N,{target:P,onClose:function(){return F(null)},onOpenL1:function(){q(P.dataDay),F(null)},onOpenL2:function(){B(P.l2),F(null)}}):null,X?a(_,{target:X,onClose:function(){return B(null)},onOpenL1:function(){q(X.dataDay),B(null)},onOpenRow:function(e){F(e),B(null)}}):null,W?a(p,{day:W,workingDays:Boolean(k.defaultWorkingDays),onClose:function(){return q(null)}}):null]}))]}))}export{w as default};
1
+ import{__spreadArray as e,__assign as t}from"../../../_virtual/_tslib.js";import{jsxs as n,jsx as a}from"react/jsx-runtime";import{useState as i,useEffect as r,useMemo as l,useRef as o}from"react";import{ChevronDown as d,Search as u,ChevronRight as c,X as s}from"lucide-react";import{L2Report as p}from"./AgReport.js";import{L1ReportModal as y}from"./L1Report.js";import m,{popupRowFromTable as v,DEFAULT_LEVEL as h}from"./DrillLevel.js";import{periodHeading as b}from"./agPrimitives.js";import{periodStart as f}from"./insightsFormat.js";import{toIsoDay as g}from"../../api/insightsApi.js";import{useInsights as K}from"./insightsContextCore.js";import{OPEN_INSIGHTS_ENTITY_REPORT as N,useScrollToTopOnStep as _,useInsightsModal as D}from"./insightsUtils.js";function k(l){var d,u,p,y=l.target,f=l.onClose,g=l.onOpenL1,N=l.onOpenL2,k=o(null),w=o(null),C=K(),I=y.kpiId,O=i([]),E=O[0],L=O[1];r(function(){return L([])},[y.row.nodeKey]);var R=t(t({},v(C,t(t({},y.row),{entityKey:null!==(d=y.row.entityKey)&&void 0!==d?d:y.l2.tab.entityKey}))),{reportId:y.row.report.kpiId===I?y.row.report.reportId:null}),j=e([R],E,!0),A=j[j.length-1];_(w,j.map(function(e){return e.nodeKey}).join(">"));var x=i(y.dataDay),T=x[0],M=x[1],S=i(A.reportId?null:y.dataDay),F=S[0],P=S[1];r(function(){return M(y.dataDay)},[y.dataDay,y.row.nodeKey]),r(function(){return P(R.reportId?null:y.dataDay)},[R.reportId,y.dataDay,y.row.nodeKey]);var G=D(f,k),X=R.label,B=null!==(u=null==C?void 0:C.matchDrillLevel(A.entityKey,j.slice(0,-1).map(function(e){return e.entityKey})))&&void 0!==u?u:h;return a("div",t({className:G,role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&f()}},{children:n("div",t({ref:w,className:"ag-modal__dialog",role:"dialog","aria-modal":"true","aria-labelledby":"ag-l2-row-modal-title"},{children:[n("header",t({className:"ag-modal__head"},{children:[n("div",t({className:"ag-modal__detail-title"},{children:[n("div",t({className:"ag-modal__breadcrumb"},{children:[a("button",t({type:"button",onClick:g},{children:"L1"})),a(c,{"aria-hidden":"true"}),n("button",t({type:"button",onClick:N},{children:["Top ",null!==(p=null==C?void 0:C.entityPluralName(y.l2.tab.entityKey))&&void 0!==p?p:y.partName]})),a(c,{"aria-hidden":"true"}),E.length?a("button",t({type:"button",onClick:function(){return L([])}},{children:X})):a("strong",t({id:"ag-l2-row-modal-title"},{children:X})),E.map(function(e,i){return n("span",t({className:"ag-modal__crumb"},{children:[a(c,{"aria-hidden":"true"}),i===E.length-1?n("strong",t({id:"ag-l2-row-modal-title",title:e.partName},{children:[e.partName?"".concat(e.partName,": "):"",e.label]})):n("button",t({type:"button",title:e.partName,onClick:function(){return L(function(e){return e.slice(0,i+1)})}},{children:[e.partName?"".concat(e.partName,": "):"",e.label]}))]}),"".concat(e.nodeKey,"-").concat(i))})]})),a("span",t({className:"ag-modal__date"},{children:b(F||T,null==C?void 0:C.period.grain)}))]})),a("button",t({ref:k,type:"button",className:"ag-modal__close","aria-label":"Close",onClick:f},{children:a(s,{"aria-hidden":"true"})}))]})),a("div",t({className:"ag-modal__body"},{children:a(m,{trail:j,level:B,kpiId:I,dataDay:T,reportDay:F,onReportDay:function(e){M(e),P(e)},tier2Kpis:y.tier2Kpis,onOpen:function(t){return L(function(n){return e(e([],n,!0),[t],!1)})}})}))]}))}))}function w(e){var i=e.target,r=e.onClose,l=e.onOpenL1,d=e.onOpenRow,u=o(null),y=K(),m=D(r,u);return y?a("div",t({className:m,role:"presentation",onMouseDown:function(e){return e.target===e.currentTarget&&r()}},{children:n("div",t({className:"ag-modal__dialog",role:"dialog","aria-modal":"true","aria-labelledby":"ag-l2-overview-modal-title"},{children:[n("header",t({className:"ag-modal__head"},{children:[n("div",t({className:"ag-modal__detail-title"},{children:[n("div",t({className:"ag-modal__breadcrumb"},{children:[a("button",t({type:"button",onClick:l},{children:"L1"})),a(c,{"aria-hidden":"true"}),n("strong",t({id:"ag-l2-overview-modal-title"},{children:["Top ",y.entityPluralName(i.tab.entityKey)]}))]})),a("span",t({className:"ag-modal__date"},{children:b(i.dataDay,y.period.grain)}))]})),a("button",t({ref:u,type:"button",className:"ag-modal__close","aria-label":"Close",onClick:r},{children:a(s,{"aria-hidden":"true"})}))]})),a("div",t({className:"ag-modal__body"},{children:a(p,{tab:i.tab,title:i.title,partName:i.partName,partKpis:i.partKpis,search:"",dataDay:i.dataDay,onOpenRow:function(e,t,n){var a;return d({row:e,partName:i.partName,kpiId:y.headlineKpi||t,dataDay:n,tier2Kpis:null!==(a=i.tab.tier2Kpis)&&void 0!==a?a:y.tierKpis[2],l2:i})}})}))]}))})):null}function C(o){var c,s,m,v=o.tabs,h=o.insightsConfig,b=K(),_=i(0),D=_[0],C=_[1],I=i(!1),O=I[0],E=I[1],L=i(""),R=L[0],j=L[1],A=i(""),x=A[0],T=A[1],M=i(null),S=M[0],F=M[1],P=i(null),G=P[0],X=P[1],B=i(null),U=B[0],W=B[1];r(function(){var e=setTimeout(function(){return T(R.trim())},300);return function(){return clearTimeout(e)}},[R]),r(function(){j(""),T("")},[D]);var q=l(function(){var e,t={};return(null!==(e=null==h?void 0:h.hierarchy)&&void 0!==e?e:[]).forEach(function(e){var n;return(null!==(n=e.entities)&&void 0!==n?n:[]).forEach(function(e){var n,a;(null==e?void 0:e.entityKey)&&(t[e.entityKey]={name:null!==(n=e.name)&&void 0!==n?n:"",kpis:null!==(a=e.kpis)&&void 0!==a?a:[]})})}),t},[h]);if(r(function(){if(b){var t=b.entityOrder.length?e([],v,!0).sort(function(e,t){var n=b.entityOrder.indexOf(e.entityKey),a=b.entityOrder.indexOf(t.entityKey);return(n<0?Number.MAX_SAFE_INTEGER:n)-(a<0?Number.MAX_SAFE_INTEGER:a)}):v,n=function(e){var n,a,i,r,l,o,d=e,u=d.detail,c=(null==u?void 0:u.entityKey)?t.findIndex(function(e){return e.entityKey===u.entityKey}):-1;if(u&&!(c<0)){var s=t[c],p=(null===(n=q[s.entityKey])||void 0===n?void 0:n.name)||s.title||b.entityName(s.entityKey)||s.entityKey,y=b.headlineKpi||s.rankBy||(null===(a=s.listKpis)||void 0===a?void 0:a[0])||(null===(i=q[s.entityKey])||void 0===i?void 0:i.kpis[0])||"",m=u.dataDay||f(g(b.range.endDate),b.period.grain),v={tab:s,title:s.title||p,partName:p,partKpis:null!==(l=null===(r=q[s.entityKey])||void 0===r?void 0:r.kpis)&&void 0!==l?l:[],dataDay:m};d.preventDefault(),W(null),X(null),C(c),F({row:{rank:0,nodeKey:u.nodeKey,label:u.label,parent:null,metrics:{},barPct:null,chip:null,report:{reportId:null,status:"none",kpiId:y},action:null,children:[]},partName:p,kpiId:y,dataDay:m,tier2Kpis:null!==(o=s.tier2Kpis)&&void 0!==o?o:b.tierKpis[2],l2:v})}};return window.addEventListener(N,n),function(){return window.removeEventListener(N,n)}}},[b,v,q]),!b||!v.length)return null;var z=b.entityOrder.length?e([],v,!0).sort(function(e,t){var n=b.entityOrder.indexOf(e.entityKey),a=b.entityOrder.indexOf(t.entityKey);return(n<0?Number.MAX_SAFE_INTEGER:n)-(a<0?Number.MAX_SAFE_INTEGER:a)}):v,H=Math.min(D,z.length-1),J=z[H],Q=function(e){var t;return e.title||b.entityName(e.entityKey)||(null===(t=q[e.entityKey])||void 0===t?void 0:t.name)||e.entityKey},V=(null===(c=q[J.entityKey])||void 0===c?void 0:c.name)||Q(J);return n("div",t({className:"ag-tabs"},{children:[a("div",t({className:"ag-tabs__head"},{children:n("div",t({className:"ag-tabs__bar"},{children:[a("div",t({className:"ag-tabs__list",role:"tablist","aria-label":"Insights"},{children:z.map(function(e,n){return a("button",t({id:"ag-tab-".concat(n),type:"button",role:"tab","aria-selected":n===H,"aria-controls":"ag-tabpanel",className:n===H?"is-active":void 0,onClick:function(){F(null),C(n)}},{children:Q(e)}),"".concat(e.entityKey,"-").concat(n))})})),a("button",t({type:"button",className:"ag-icon-button","aria-label":O?"Expand insights":"Collapse insights","aria-expanded":!O,onClick:function(){return E(function(e){return!e})}},{children:a(d,{"aria-hidden":"true",className:O?"is-closed":"is-open"})}))]}))})),O?null:n("div",t({className:"ag-tabs__body",role:"tabpanel",id:"ag-tabpanel","aria-labelledby":"ag-tab-".concat(H)},{children:[a(p,{tab:J,title:Q(J),partName:V,partKpis:null!==(m=null===(s=q[J.entityKey])||void 0===s?void 0:s.kpis)&&void 0!==m?m:[],search:x,headerAction:n("label",t({className:"ag-search"},{children:[a(u,{"aria-hidden":"true"}),a("input",{type:"search",value:R,onChange:function(e){return j(e.target.value)},placeholder:"Search ".concat(V.toLowerCase(),"..."),"aria-label":"Search ".concat(b.entityPluralName(J.entityKey))})]})),onOpenRow:function(e,n,a){var i,r,l,o,d,u,c=null!==(i=e.entityKey)&&void 0!==i?i:J.entityKey;b.matchDrillLevel(c,[])?F({row:t(t({},e),{entityKey:c}),partName:V,kpiId:b.headlineKpi||n,dataDay:a,tier2Kpis:null!==(o=J.tier2Kpis)&&void 0!==o?o:b.tierKpis[2],l2:{tab:J,title:Q(J),partName:V,partKpis:null!==(u=null===(d=q[J.entityKey])||void 0===d?void 0:d.kpis)&&void 0!==u?u:[],dataDay:a}}):b.openReport({reportId:null===(r=e.report)||void 0===r?void 0:r.reportId,nodeKey:e.nodeKey,kpiId:b.headlineKpi||n,dataDay:a,title:null!==(l=e.label)&&void 0!==l?l:e.nodeKey})}},H),S?a(k,{target:S,onClose:function(){return F(null)},onOpenL1:function(){W(S.dataDay),F(null)},onOpenL2:function(){X(S.l2),F(null)}}):null,G?a(w,{target:G,onClose:function(){return X(null)},onOpenL1:function(){W(G.dataDay),X(null)},onOpenRow:function(e){F(e),X(null)}}):null,U?a(y,{day:U,workingDays:Boolean(b.defaultWorkingDays),onClose:function(){return W(null)}}):null]}))]}))}export{C as default};
2
2
  //# sourceMappingURL=InsightTabs.js.map