react-semaphor 0.1.449 → 0.1.453

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 (134) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +115 -109
  3. package/dist/appearance/index.cjs +1 -1
  4. package/dist/appearance/index.js +1 -1
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +15 -13
  7. package/dist/briefings/index.cjs +1 -1
  8. package/dist/briefings/index.js +39 -2131
  9. package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-Dxw66nUG.cjs} +1 -1
  10. package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-GHKFwThg.js} +1 -1
  11. package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +1 -0
  12. package/dist/chunks/canonical-result-keys-KLk__J_O.js +466 -0
  13. package/dist/chunks/color-CJvdlFM_.js +2162 -0
  14. package/dist/chunks/color-CyB5o13F.cjs +4 -0
  15. package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-Ci66eflG.cjs} +1 -1
  16. package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-F6qk6PPS.js} +1 -1
  17. package/dist/chunks/contracts-CoCOpd_i.js +11 -0
  18. package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
  19. package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-CFpX0WX3.js} +86 -84
  20. package/dist/chunks/dashboard-briefing-launcher-mUXWuiOZ.cjs +26 -0
  21. package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-BeYAmOJc.js} +15 -13
  22. package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-SoNubIu1.cjs} +1 -1
  23. package/dist/chunks/dashboard-json-BublPnQ4.cjs +1 -0
  24. package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-DeLUagVV.js} +25 -23
  25. package/dist/chunks/edit-dashboard-visual-CrvPcO7A.cjs +172 -0
  26. package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-Go0h82DR.js} +6925 -6947
  27. package/dist/chunks/editor-action-buttons-1Lo0fIh7.cjs +16 -0
  28. package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-BFNtjFzO.js} +41 -39
  29. package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
  30. package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
  31. package/dist/chunks/index-B3ZugihZ.js +3713 -0
  32. package/dist/chunks/{index-CPuawpXJ.js → index-BsH32bn1.js} +47472 -47845
  33. package/dist/chunks/index-ByFbacH7.cjs +1 -0
  34. package/dist/chunks/index-CACdoqu3.js +318 -0
  35. package/dist/chunks/index-DSKR3nKn.js +421 -0
  36. package/dist/chunks/index-DjiIh_9n.cjs +4 -0
  37. package/dist/chunks/index-F25jnH0p.cjs +1 -0
  38. package/dist/chunks/index-q12_nNUS.cjs +1392 -0
  39. package/dist/chunks/{metric-comparison-97zHGEx5.js → metric-comparison-D0T0MKRK.js} +1 -1
  40. package/dist/chunks/{metric-comparison-CUAJ8n4y.cjs → metric-comparison-DYR3RXam.cjs} +1 -1
  41. package/dist/chunks/pivot-header-presentation-DcfPaCiy.cjs +4 -0
  42. package/dist/chunks/pivot-header-presentation-nk604qc1.js +557 -0
  43. package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-C43Ai5Kr.js} +1 -1
  44. package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-CRUokNgm.cjs} +1 -1
  45. package/dist/chunks/pivot-result-lifecycle-4kSe0Hk1.js +1642 -0
  46. package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +1 -0
  47. package/dist/chunks/raw-temporal-contract-BF7PjBY9.js +64 -0
  48. package/dist/chunks/raw-temporal-contract-CxbRFwnd.cjs +1 -0
  49. package/dist/chunks/report-preferences-dialog-BEVZAE3m.cjs +1 -0
  50. package/dist/chunks/report-preferences-dialog-BNV7qXYH.js +723 -0
  51. package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-BJQDu2fV.js} +1 -1
  52. package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DjYqLV-c.cjs} +1 -1
  53. package/dist/chunks/saved-temporal-bucket-format-DiZdQXOL.js +924 -0
  54. package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +1 -0
  55. package/dist/chunks/switch-CjJ6FHYJ.cjs +138 -0
  56. package/dist/chunks/{switch-BXet-Sno.js → switch-DgLwr7O-.js} +4352 -5249
  57. package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +1 -0
  58. package/dist/chunks/temporal-bucket-FBZGrDCe.js +560 -0
  59. package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +1 -0
  60. package/dist/chunks/temporal-bucket-authoring-FIRnJz0e.js +221 -0
  61. package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-BQOj6Frl.js} +1 -1
  62. package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-anl4h-vg.cjs} +1 -1
  63. package/dist/chunks/{token-types-BHR58aTy.js → token-types-CRpQJ4kv.js} +1 -1
  64. package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D0i0IUX3.cjs} +1 -1
  65. package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-C1i9bgsy.cjs} +1 -1
  66. package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-CaJz9aPG.js} +1 -1
  67. package/dist/chunks/{validators-Cs74WVie.js → validators-DeMXwRON.js} +253 -233
  68. package/dist/chunks/validators-Dm7Kpz6p.cjs +1 -0
  69. package/dist/dashboard/index.cjs +1 -1
  70. package/dist/dashboard/index.js +2 -2
  71. package/dist/dashboard-authoring/index.cjs +3 -3
  72. package/dist/dashboard-authoring/index.js +32 -29
  73. package/dist/data-app-builder/index.cjs +1 -1
  74. package/dist/data-app-builder/index.js +2 -2
  75. package/dist/data-app-codegen/index.cjs +1 -1
  76. package/dist/data-app-codegen/index.js +2 -2
  77. package/dist/data-app-codegen-node/index.cjs +1 -1
  78. package/dist/data-app-codegen-node/index.js +3 -3
  79. package/dist/data-app-sdk/index.cjs +1 -1
  80. package/dist/data-app-sdk/index.js +3 -3
  81. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  82. package/dist/data-app-sdk-adapters/index.js +2 -2
  83. package/dist/data-app-sdk-validation/index.cjs +1 -1
  84. package/dist/data-app-sdk-validation/index.js +3 -3
  85. package/dist/format-utils/index.cjs +3 -3
  86. package/dist/format-utils/index.js +162 -145
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.js +157 -155
  89. package/dist/report-runtime-context/index.cjs +1 -1
  90. package/dist/report-runtime-context/index.js +2 -2
  91. package/dist/style.css +1 -1
  92. package/dist/surfboard/index.cjs +1 -1
  93. package/dist/surfboard/index.js +3 -3
  94. package/dist/types/analytics-protocol.d.ts +37 -0
  95. package/dist/types/briefings.d.ts +718 -7
  96. package/dist/types/dashboard-assistant.d.ts +18 -0
  97. package/dist/types/dashboard-authoring.d.ts +52 -2
  98. package/dist/types/dashboard.d.ts +128 -0
  99. package/dist/types/data-app-sdk-validation.d.ts +13 -0
  100. package/dist/types/data-app-sdk.d.ts +13 -0
  101. package/dist/types/format-utils.d.ts +190 -3
  102. package/dist/types/index.cjs +1 -1
  103. package/dist/types/index.js +4 -4
  104. package/dist/types/main.d.ts +103 -12
  105. package/dist/types/shared.d.ts +5 -0
  106. package/dist/types/surfboard.d.ts +129 -1
  107. package/dist/types/types.d.ts +98 -6
  108. package/dist/types/value-format-preferences.d.ts +3 -0
  109. package/package.json +2 -1
  110. package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
  111. package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
  112. package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
  113. package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
  114. package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
  115. package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
  116. package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
  117. package/dist/chunks/format-types-DZGgYj39.js +0 -1663
  118. package/dist/chunks/index-CJdxSyQq.js +0 -2578
  119. package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
  120. package/dist/chunks/index-DRlMUglg.cjs +0 -4
  121. package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
  122. package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
  123. package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
  124. package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
  125. package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
  126. package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
  127. package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
  128. package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
  129. package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
  130. package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
  131. package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
  132. package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
  133. package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
  134. package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
@@ -1,4 +1,4 @@
1
- import { e as _ } from "./validators-Cs74WVie.js";
1
+ import { e as _ } from "./validators-DeMXwRON.js";
2
2
  const g = "higher_is_better", D = {
3
3
  displayMode: "difference",
4
4
  showComparison: !0,
@@ -1 +1 @@
1
- "use strict";const g=require("./validators-9D4KBqKD.cjs"),b="higher_is_better",C={displayMode:"difference",showComparison:!0,indicatorStyle:"arrow_badge",showColor:!0,conditionalLabel:!1};function w(o){return g.parseSemaphorIsoInstant(o)!==null}function $(o){var i,e,s,t;if(((i=o.metricComparison)==null?void 0:i.mode)!=="off"){if(((e=o.metricComparison)==null?void 0:e.mode)==="explicit")return{source:"explicit",spec:o.metricComparison.spec};if(!((o.inheritGlobalComparison??((s=o.globalDateComparison)==null?void 0:s.inheritGlobalComparison))===!1||((t=o.globalDateComparison)==null?void 0:t.selection.mode)!=="period"))return{source:"inherited",spec:o.globalDateComparison.selection.spec,...o.globalDateComparison.owner?{owner:o.globalDateComparison.owner}:{}}}}function h(o){if(o.alias)return o.alias;const i=o.entityName&&o.entityName!=="SEMAPHOR_CALCULATED_FIELD"?o.entityName:void 0,e=i&&i!==o.name?`${i}_`:"";if(o.role!=="metric")return`${e}${o.name}`;let s=o.aggregate||"metric";if(o.expression){const t=o.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);s=t?t[1].toLowerCase():"expr"}else s=s.toLowerCase();return`${e}${o.name}_${s}`}function n(o,i,e){return e?{code:o,message:i,path:e}:{code:o,message:i}}function p(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}function a(o,i,e,s){Object.keys(o).forEach(t=>{i.includes(t)||s.push(n("invalid_comparison_spec",`Comparison kind does not accept field "${t}".`,`${e}.${t}`))})}function f(o,i,e){o.alignment!==void 0&&o.alignment!=="calendar"&&o.alignment!=="weekday"&&e.push(n("invalid_comparison_spec",'Comparison alignment must be "calendar" or "weekday".',`${i}.alignment`)),o.toDate!==void 0&&typeof o.toDate!="boolean"&&e.push(n("invalid_comparison_spec","Comparison toDate must be a boolean.",`${i}.toDate`))}function _(o,i,e){o!==void 0&&(typeof o!="number"||!Number.isSafeInteger(o)||o<=0)&&e.push(n("invalid_comparison_spec","Comparison offset must be a positive safe integer.",i))}function d(o,i="comparison"){const e=[];return p(o)?(o.kind==="previous_period"?(a(o,["kind","offsetPeriods","alignment","toDate"],i,e),_(o.offsetPeriods,`${i}.offsetPeriods`,e),f(o,i,e)):o.kind==="previous_year"?(a(o,["kind","offsetYears","alignment","toDate"],i,e),_(o.offsetYears,`${i}.offsetYears`,e),f(o,i,e)):o.kind==="target"?(a(o,["kind","targetValue"],i,e),(typeof o.targetValue!="number"||!Number.isFinite(o.targetValue))&&e.push(n("invalid_comparison_spec","Target comparison requires a finite targetValue.",`${i}.targetValue`))):e.push(n("invalid_comparison_spec","Comparison kind must be previous_period, previous_year, or target.",`${i}.kind`)),{ok:e.length===0,errors:e,warnings:[]}):{ok:!1,errors:[n("invalid_comparison_spec","Comparison spec must be an object.",i)],warnings:[]}}function D(o,i="comparison"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_config","Comparison config must be an object.",i)],warnings:[]};const e=[];return o.mode==="off"?a(o,["mode"],i,e):o.mode==="explicit"?(a(o,["mode","spec"],i,e),e.push(...d(o.spec,`${i}.spec`).errors)):e.push(n("invalid_comparison_config","Comparison mode must be off or explicit.",`${i}.mode`)),{ok:e.length===0,errors:e,warnings:[]}}function u(o,i="comparisonSelection"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison selection must be an object.",i)],warnings:[]};const e=[];if(o.mode==="off")a(o,["mode"],i,e);else if(o.mode==="period"){a(o,["mode","spec"],i,e);const s=d(o.spec,`${i}.spec`);e.push(...s.errors),p(o.spec)&&o.spec.kind==="target"&&e.push(n("invalid_global_date_comparison","Global Date comparison supports previous_period or previous_year, not target.",`${i}.spec.kind`))}else e.push(n("invalid_global_date_comparison","Global Date comparison mode must be off or period.",`${i}.mode`));return{ok:e.length===0,errors:e,warnings:[]}}function I(o,i="globalDateComparison"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison context must be an object.",i)],warnings:[]};const e=[];return a(o,["selection","inheritGlobalComparison","owner","referenceTime"],i,e),e.push(...u(o.selection,`${i}.selection`).errors),o.inheritGlobalComparison!==void 0&&o.inheritGlobalComparison!==!1&&e.push(n("invalid_global_date_comparison","inheritGlobalComparison may only be false when present.",`${i}.inheritGlobalComparison`)),o.owner!==void 0&&(p(o.owner)?o.owner.kind==="global_date"?a(o.owner,["kind"],`${i}.owner`,e):o.owner.kind==="field_date"?(a(o.owner,["kind","filterId","label"],`${i}.owner`,e),(typeof o.owner.filterId!="string"||!o.owner.filterId.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty filterId.",`${i}.owner.filterId`)),(typeof o.owner.label!="string"||!o.owner.label.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty label.",`${i}.owner.label`))):e.push(n("invalid_global_date_comparison","Comparison owner kind must be global_date or field_date.",`${i}.owner.kind`)):e.push(n("invalid_global_date_comparison","Comparison owner must be an object.",`${i}.owner`))),o.referenceTime!==void 0&&(typeof o.referenceTime!="string"||!w(o.referenceTime))&&e.push(n("invalid_global_date_comparison","referenceTime must be a valid ISO date-time string when present.",`${i}.referenceTime`)),{ok:e.length===0,errors:e,warnings:[]}}function M(o,i="comparisonPolarity"){return o==="higher_is_better"||o==="lower_is_better"||o==="neutral"?{ok:!0,errors:[],warnings:[]}:{ok:!1,errors:[n("invalid_comparison_polarity","Comparison polarity must be higher_is_better, lower_is_better, or neutral.",i)],warnings:[]}}function S(o,i="comparisonPresentation"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_presentation","Comparison presentation must be an object.",i)],warnings:[]};const e=[],s=["displayMode","showComparison","precision","indicatorStyle","showColor","position","conditionalLabel","labelName","conditionalLabels","colors"];return Object.keys(o).forEach(r=>{s.includes(r)||e.push(n("invalid_comparison_presentation",`Comparison presentation does not accept field "${r}".`,`${i}.${r}`))}),[["displayMode",["difference","percent_change","both","ratio"]],["indicatorStyle",["arrow_badge","arrow","badge","none"]],["position",["left","right","top"]]].forEach(([r,l])=>{o[r]!==void 0&&!l.includes(o[r])&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} is invalid.`,`${i}.${r}`))}),["showComparison","showColor","conditionalLabel"].forEach(r=>{o[r]!==void 0&&typeof o[r]!="boolean"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be a boolean.`,`${i}.${r}`))}),o.precision!==void 0&&(typeof o.precision!="number"||!Number.isInteger(o.precision)||o.precision<0||o.precision>6)&&e.push(n("invalid_comparison_presentation","Comparison presentation precision must be an integer from 0 through 6.",`${i}.precision`)),o.labelName!==void 0&&typeof o.labelName!="string"&&e.push(n("invalid_comparison_presentation","Comparison presentation labelName must be a string.",`${i}.labelName`)),["conditionalLabels","colors"].forEach(r=>{const l=o[r];if(l!==void 0){if(!p(l)){e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be an object.`,`${i}.${r}`));return}Object.keys(l).forEach(c=>{["increase","decrease","neutral"].includes(c)||e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} does not accept field "${c}".`,`${i}.${r}.${c}`))}),Object.entries(l).forEach(([c,m])=>{m!==void 0&&typeof m!="string"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r}.${c} must be a string.`,`${i}.${r}.${c}`))})}}),{ok:e.length===0,errors:e,warnings:[]}}function N(o){return o===null?"unknown":o>0?"increase":o<0?"decrease":"no_change"}function T(o,i){return o==="unknown"||o==="no_change"||i==="neutral"?"neutral":i==="higher_is_better"&&o==="increase"||i==="lower_is_better"&&o==="decrease"?"favorable":"unfavorable"}function y(o){const{currentValue:i,comparisonValue:e,polarity:s=b}=o,r=i!==null&&e!==null?i-e:null,l=r!==null&&e!==null&&e!==0?r/Math.abs(e):null,c=i!==null&&e!==null&&e!==0?i/e:null,m=N(r);return{status:e===null?"insufficient_history":"available",currentValue:i,comparisonValue:e,delta:r,percentChange:l,ratio:c,direction:m,sentiment:T(m,s)}}exports.COMPARISON_PRESENTATION_DEFAULTS=C;exports.DEFAULT_METRIC_COMPARISON_POLARITY=b;exports.evaluateMetricComparison=y;exports.resolveMetricComparisonRequest=$;exports.resolveMetricResultAlias=h;exports.validateComparisonPresentationSpec=S;exports.validateGlobalDateComparisonContext=I;exports.validateGlobalDateComparisonSelection=u;exports.validateMetricComparisonConfig=D;exports.validateMetricComparisonPolarity=M;exports.validateMetricComparisonSpec=d;
1
+ "use strict";const g=require("./validators-Dm7Kpz6p.cjs"),b="higher_is_better",C={displayMode:"difference",showComparison:!0,indicatorStyle:"arrow_badge",showColor:!0,conditionalLabel:!1};function w(o){return g.parseSemaphorIsoInstant(o)!==null}function $(o){var i,e,s,t;if(((i=o.metricComparison)==null?void 0:i.mode)!=="off"){if(((e=o.metricComparison)==null?void 0:e.mode)==="explicit")return{source:"explicit",spec:o.metricComparison.spec};if(!((o.inheritGlobalComparison??((s=o.globalDateComparison)==null?void 0:s.inheritGlobalComparison))===!1||((t=o.globalDateComparison)==null?void 0:t.selection.mode)!=="period"))return{source:"inherited",spec:o.globalDateComparison.selection.spec,...o.globalDateComparison.owner?{owner:o.globalDateComparison.owner}:{}}}}function h(o){if(o.alias)return o.alias;const i=o.entityName&&o.entityName!=="SEMAPHOR_CALCULATED_FIELD"?o.entityName:void 0,e=i&&i!==o.name?`${i}_`:"";if(o.role!=="metric")return`${e}${o.name}`;let s=o.aggregate||"metric";if(o.expression){const t=o.expression.match(/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i);s=t?t[1].toLowerCase():"expr"}else s=s.toLowerCase();return`${e}${o.name}_${s}`}function n(o,i,e){return e?{code:o,message:i,path:e}:{code:o,message:i}}function p(o){return!!o&&typeof o=="object"&&!Array.isArray(o)}function a(o,i,e,s){Object.keys(o).forEach(t=>{i.includes(t)||s.push(n("invalid_comparison_spec",`Comparison kind does not accept field "${t}".`,`${e}.${t}`))})}function f(o,i,e){o.alignment!==void 0&&o.alignment!=="calendar"&&o.alignment!=="weekday"&&e.push(n("invalid_comparison_spec",'Comparison alignment must be "calendar" or "weekday".',`${i}.alignment`)),o.toDate!==void 0&&typeof o.toDate!="boolean"&&e.push(n("invalid_comparison_spec","Comparison toDate must be a boolean.",`${i}.toDate`))}function _(o,i,e){o!==void 0&&(typeof o!="number"||!Number.isSafeInteger(o)||o<=0)&&e.push(n("invalid_comparison_spec","Comparison offset must be a positive safe integer.",i))}function d(o,i="comparison"){const e=[];return p(o)?(o.kind==="previous_period"?(a(o,["kind","offsetPeriods","alignment","toDate"],i,e),_(o.offsetPeriods,`${i}.offsetPeriods`,e),f(o,i,e)):o.kind==="previous_year"?(a(o,["kind","offsetYears","alignment","toDate"],i,e),_(o.offsetYears,`${i}.offsetYears`,e),f(o,i,e)):o.kind==="target"?(a(o,["kind","targetValue"],i,e),(typeof o.targetValue!="number"||!Number.isFinite(o.targetValue))&&e.push(n("invalid_comparison_spec","Target comparison requires a finite targetValue.",`${i}.targetValue`))):e.push(n("invalid_comparison_spec","Comparison kind must be previous_period, previous_year, or target.",`${i}.kind`)),{ok:e.length===0,errors:e,warnings:[]}):{ok:!1,errors:[n("invalid_comparison_spec","Comparison spec must be an object.",i)],warnings:[]}}function D(o,i="comparison"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_config","Comparison config must be an object.",i)],warnings:[]};const e=[];return o.mode==="off"?a(o,["mode"],i,e):o.mode==="explicit"?(a(o,["mode","spec"],i,e),e.push(...d(o.spec,`${i}.spec`).errors)):e.push(n("invalid_comparison_config","Comparison mode must be off or explicit.",`${i}.mode`)),{ok:e.length===0,errors:e,warnings:[]}}function u(o,i="comparisonSelection"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison selection must be an object.",i)],warnings:[]};const e=[];if(o.mode==="off")a(o,["mode"],i,e);else if(o.mode==="period"){a(o,["mode","spec"],i,e);const s=d(o.spec,`${i}.spec`);e.push(...s.errors),p(o.spec)&&o.spec.kind==="target"&&e.push(n("invalid_global_date_comparison","Global Date comparison supports previous_period or previous_year, not target.",`${i}.spec.kind`))}else e.push(n("invalid_global_date_comparison","Global Date comparison mode must be off or period.",`${i}.mode`));return{ok:e.length===0,errors:e,warnings:[]}}function I(o,i="globalDateComparison"){if(!p(o))return{ok:!1,errors:[n("invalid_global_date_comparison","Global Date comparison context must be an object.",i)],warnings:[]};const e=[];return a(o,["selection","inheritGlobalComparison","owner","referenceTime"],i,e),e.push(...u(o.selection,`${i}.selection`).errors),o.inheritGlobalComparison!==void 0&&o.inheritGlobalComparison!==!1&&e.push(n("invalid_global_date_comparison","inheritGlobalComparison may only be false when present.",`${i}.inheritGlobalComparison`)),o.owner!==void 0&&(p(o.owner)?o.owner.kind==="global_date"?a(o.owner,["kind"],`${i}.owner`,e):o.owner.kind==="field_date"?(a(o.owner,["kind","filterId","label"],`${i}.owner`,e),(typeof o.owner.filterId!="string"||!o.owner.filterId.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty filterId.",`${i}.owner.filterId`)),(typeof o.owner.label!="string"||!o.owner.label.trim())&&e.push(n("invalid_global_date_comparison","Field Date comparison owner requires a non-empty label.",`${i}.owner.label`))):e.push(n("invalid_global_date_comparison","Comparison owner kind must be global_date or field_date.",`${i}.owner.kind`)):e.push(n("invalid_global_date_comparison","Comparison owner must be an object.",`${i}.owner`))),o.referenceTime!==void 0&&(typeof o.referenceTime!="string"||!w(o.referenceTime))&&e.push(n("invalid_global_date_comparison","referenceTime must be a valid ISO date-time string when present.",`${i}.referenceTime`)),{ok:e.length===0,errors:e,warnings:[]}}function M(o,i="comparisonPolarity"){return o==="higher_is_better"||o==="lower_is_better"||o==="neutral"?{ok:!0,errors:[],warnings:[]}:{ok:!1,errors:[n("invalid_comparison_polarity","Comparison polarity must be higher_is_better, lower_is_better, or neutral.",i)],warnings:[]}}function S(o,i="comparisonPresentation"){if(!p(o))return{ok:!1,errors:[n("invalid_comparison_presentation","Comparison presentation must be an object.",i)],warnings:[]};const e=[],s=["displayMode","showComparison","precision","indicatorStyle","showColor","position","conditionalLabel","labelName","conditionalLabels","colors"];return Object.keys(o).forEach(r=>{s.includes(r)||e.push(n("invalid_comparison_presentation",`Comparison presentation does not accept field "${r}".`,`${i}.${r}`))}),[["displayMode",["difference","percent_change","both","ratio"]],["indicatorStyle",["arrow_badge","arrow","badge","none"]],["position",["left","right","top"]]].forEach(([r,l])=>{o[r]!==void 0&&!l.includes(o[r])&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} is invalid.`,`${i}.${r}`))}),["showComparison","showColor","conditionalLabel"].forEach(r=>{o[r]!==void 0&&typeof o[r]!="boolean"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be a boolean.`,`${i}.${r}`))}),o.precision!==void 0&&(typeof o.precision!="number"||!Number.isInteger(o.precision)||o.precision<0||o.precision>6)&&e.push(n("invalid_comparison_presentation","Comparison presentation precision must be an integer from 0 through 6.",`${i}.precision`)),o.labelName!==void 0&&typeof o.labelName!="string"&&e.push(n("invalid_comparison_presentation","Comparison presentation labelName must be a string.",`${i}.labelName`)),["conditionalLabels","colors"].forEach(r=>{const l=o[r];if(l!==void 0){if(!p(l)){e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} must be an object.`,`${i}.${r}`));return}Object.keys(l).forEach(c=>{["increase","decrease","neutral"].includes(c)||e.push(n("invalid_comparison_presentation",`Comparison presentation ${r} does not accept field "${c}".`,`${i}.${r}.${c}`))}),Object.entries(l).forEach(([c,m])=>{m!==void 0&&typeof m!="string"&&e.push(n("invalid_comparison_presentation",`Comparison presentation ${r}.${c} must be a string.`,`${i}.${r}.${c}`))})}}),{ok:e.length===0,errors:e,warnings:[]}}function N(o){return o===null?"unknown":o>0?"increase":o<0?"decrease":"no_change"}function T(o,i){return o==="unknown"||o==="no_change"||i==="neutral"?"neutral":i==="higher_is_better"&&o==="increase"||i==="lower_is_better"&&o==="decrease"?"favorable":"unfavorable"}function y(o){const{currentValue:i,comparisonValue:e,polarity:s=b}=o,r=i!==null&&e!==null?i-e:null,l=r!==null&&e!==null&&e!==0?r/Math.abs(e):null,c=i!==null&&e!==null&&e!==0?i/e:null,m=N(r);return{status:e===null?"insufficient_history":"available",currentValue:i,comparisonValue:e,delta:r,percentChange:l,ratio:c,direction:m,sentiment:T(m,s)}}exports.COMPARISON_PRESENTATION_DEFAULTS=C;exports.DEFAULT_METRIC_COMPARISON_POLARITY=b;exports.evaluateMetricComparison=y;exports.resolveMetricComparisonRequest=$;exports.resolveMetricResultAlias=h;exports.validateComparisonPresentationSpec=S;exports.validateGlobalDateComparisonContext=I;exports.validateGlobalDateComparisonSelection=u;exports.validateMetricComparisonConfig=D;exports.validateMetricComparisonPolarity=M;exports.validateMetricComparisonSpec=d;
@@ -0,0 +1,4 @@
1
+ "use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-BiJepH5S.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./temporal-bucket-Dnj8qT9l.cjs");function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function X(e){return c.constructFrom(e,Date.now())}function H(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function Y(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function q(e,t){return+c.toDate(e)-+c.toDate(t)}function W(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function J(e){const t=c.toDate(e);return+W(t)==+K(t)}function Q(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(H(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;J(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function z(e,t,n){const o=q(e,t)/1e3;return Y(n==null?void 0:n.roundingMethod)(o)}function ee(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=z(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=Q(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function C(e,t){return ee(e,X(e),t)}const I=["day","hour","minute","second","millisecond"],L={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},te={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},ne={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function re(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function V(e,t){return re(e)?e:t}function S(e,t){return I.indexOf(V(e,t))}function oe(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return I.slice(r,a+1)}function ae(e,t){return e*L[V(t,"second")]}function se(e,t){const n=oe(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=L[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=L[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function ie(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${te[a.unit]}`).join(" ")}function le(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=ne[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ce(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function ue(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(ae(n,o)),s=se(i,t),l=r==="digital"?ce(s):r==="long"?le(s,t.maxUnits):ie(s,t.maxUnits);return ue(l,a,t)}function fe(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function p(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:fe(e,t,n)}}function v(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function N(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function me(e,t){const n={mode:t.displayMode,current:p(e.currentValue,t.metricFormat,t.locale),comparison:p(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=p(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=v(e.percentChange,N(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=v(e.ratio,N(t.precision,2),t.locale,"ratio")),n}function ge(e,t){return e&&e!=="auto"?e:t}function de(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function he(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const Me="MM/dd/yyyy",ye=(e,t,n,o="auto")=>{if(!e)return"";try{const r=T(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:Me).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},De=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:C(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function R(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
2
+ `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function $(e,t=","){return e.map(n=>R(n,t)).join(t)}function _(e,t={}){const{delimiter:n=",",lineEnding:o=`
3
+ `}=t;return e.map(r=>$(r,n)).join(o)}function be(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:o=`
4
+ `,includeHeaders:r=!0,columns:a}=t,i=a||Object.keys(e[0]),s=[];r&&s.push(i);for(const l of e){const u=i.map(g=>{const m=l[g];return m==null?"":String(m)});s.push(u)}return _(s,{delimiter:n,lineEnding:o})}const F="__TOTAL__";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e){return e===F}function we(e){const t=new Map,n=(e.groupByColumns??[]).map((r,a)=>{var u,g,m;if(!D(r))throw new Error(`Aggregate groupByColumns[${a}] is invalid`);const i=typeof r.id=="string"&&r.id.length>0?r.id:void 0,s=i?(m=(g=(u=e.columnKeyMap)==null?void 0:u.byRole)==null?void 0:g.groupby)==null?void 0:m[i]:void 0,l=(s==null?void 0:s.outputKey)||(s==null?void 0:s.rawKey)||(typeof r.alias=="string"&&r.alias.length>0?r.alias:typeof r.name=="string"&&r.name.length>0?r.name:void 0);if(!l)throw new Error(`Aggregate groupByColumns[${a}] has no output key`);return[i,r.alias,r.name,l].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,l)}),l}),o=(e.rowAggregates??[]).flatMap(r=>!D(r)||typeof r.function!="string"||typeof r.groupLevel!="string"?[]:[{function:r.function,groupLevel:r.groupLevel==="ALL"?"ALL":t.get(r.groupLevel)||r.groupLevel,...typeof r.label=="string"?{label:r.label}:{}}]);return{groupColumnKeys:n,rowAggregates:o}}function P(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function U(e){var n;if(e.customLabel)return e.customLabel;const t=P(e.aggregateFunction);if(e.levelValue!==void 0&&!b(e.levelValue)){if(e.levelValue===null){const r=(n=e.formatValue)==null?void 0:n.call(e,null);return r?`Subtotal ${r}`:`Subtotal ${t}`}const o=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(o)return`Subtotal (${o})`}return`Subtotal ${t}`}function O(e,t){return t||`Grand ${P(e)}`}function x(e){var o,r;const t=e.context.groupColumnKeys,n=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const a=(o=e.context.rowAggregates.find(i=>i.groupLevel==="ALL"))==null?void 0:o.label;return{kind:"grand-total",cells:t.map((i,s)=>({columnKey:i,text:s===0?O(n,a):"",placement:s===0?"label":"empty",colSpan:s===0?t.length:1}))}}if(e.row.isSubtotal===!0){if(typeof e.row.subtotalLevel!="string")throw new Error("Aggregate subtotal row is missing subtotalLevel");const a=t.indexOf(e.row.subtotalLevel);if(a<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const i=D(e.row.subtotalContext)?e.row.subtotalContext:void 0,s=D(i==null?void 0:i.groupByValues)?i.groupByValues:{},l=(r=e.context.rowAggregates.find(u=>u.groupLevel===e.row.subtotalLevel&&u.function===n))==null?void 0:r.label;return{kind:"subtotal",cells:t.map((u,g)=>{if(g>a)return{columnKey:u,text:"",placement:"empty",colSpan:1};if(g<a){const m=e.row[u];return{columnKey:u,text:m===void 0||b(m)?"":e.formatValue(m,u),placement:"value",colSpan:1}}return{columnKey:u,text:U({aggregateFunction:n,customLabel:l,levelValue:s[u],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,u):String(e.formatValue(m,u)??"")}),placement:"label",colSpan:t.length-a}})}}return{kind:"data",cells:t.map(a=>{const i=e.row[a];return{columnKey:a,text:i===void 0||b(i)?"":e.formatValue(i,a),placement:"value",colSpan:1}})}}function pe(e){const t=x(e).cells.find(n=>n.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Le(e){return x(e).cells.map(t=>t.text)}class Z extends Error{constructor(n,o){super(`${n}: ${o}`);A(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError"}}function Te(e){var r;const t=e.mode??"formatted",n=e.members.map(a=>{var s;if(t==="canonical"||!a.temporalBucket)return a.value===null?"":String(a.value);const i=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,a.fieldId);if(!i)throw new Z("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${a.fieldId}"`);return j.formatTemporalBucket({value:a.value,metadata:a.temporalBucket,format:i})}),o=((r=e.metricLabel)==null?void 0:r.trim())||void 0;return{memberLabels:n,...o?{metricLabel:o}:{},flattenedLabel:[...n,...o?[o]:[]].join(" / ")}}exports.AGGREGATE_TOTAL_MEMBER_MARKER=F;exports.PivotHeaderPresentationError=Z;exports.arrayToCSV=_;exports.arrayToCSVRow=$;exports.escapeCSVValue=R;exports.formatAggregateGrandTotalLabel=O;exports.formatAggregateGroupCell=pe;exports.formatAggregateGroupRow=Le;exports.formatAggregateSubtotalLabel=U;exports.formatDate=ye;exports.formatDistanceToNow=C;exports.formatDuration=E;exports.formatMetricComparison=me;exports.formatRelativeTime=De;exports.getTimezoneAbbreviation=de;exports.getTimezoneName=he;exports.isAggregateTotalMemberMarker=b;exports.objectsToCSV=be;exports.parseWithSourceTimezone=T;exports.presentAggregateGroupRow=x;exports.presentPivotHeader=Te;exports.resolveAggregateTablePresentationContext=we;exports.resolveTimezone=ge;
@@ -0,0 +1,557 @@
1
+ var U = Object.defineProperty;
2
+ var E = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var A = (e, t, n) => E(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { t as f, c as P, g as R, e as O, a as T, m as S, b as M, i as Z, f as k, d as B } from "./format-types-CFHQoIuk.js";
5
+ import { b as y } from "./pivot-result-lifecycle-4kSe0Hk1.js";
6
+ import { f as j } from "./index-CACdoqu3.js";
7
+ import { f as X } from "./temporal-bucket-FBZGrDCe.js";
8
+ function b(e, t) {
9
+ const n = f(e), o = f(t), r = n.getTime() - o.getTime();
10
+ return r < 0 ? -1 : r > 0 ? 1 : r;
11
+ }
12
+ function G(e) {
13
+ return P(e, Date.now());
14
+ }
15
+ function H(e, t) {
16
+ const n = f(e), o = f(t), r = n.getFullYear() - o.getFullYear(), s = n.getMonth() - o.getMonth();
17
+ return r * 12 + s;
18
+ }
19
+ function Y(e) {
20
+ return (t) => {
21
+ const o = (e ? Math[e] : Math.trunc)(t);
22
+ return o === 0 ? 0 : o;
23
+ };
24
+ }
25
+ function W(e, t) {
26
+ return +f(e) - +f(t);
27
+ }
28
+ function q(e) {
29
+ const t = f(e);
30
+ return t.setHours(23, 59, 59, 999), t;
31
+ }
32
+ function K(e) {
33
+ const t = f(e), n = t.getMonth();
34
+ return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
35
+ }
36
+ function J(e) {
37
+ const t = f(e);
38
+ return +q(t) == +K(t);
39
+ }
40
+ function Q(e, t) {
41
+ const n = f(e), o = f(t), r = b(n, o), s = Math.abs(
42
+ H(n, o)
43
+ );
44
+ let i;
45
+ if (s < 1)
46
+ i = 0;
47
+ else {
48
+ n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * s);
49
+ let a = b(n, o) === -r;
50
+ J(f(e)) && s === 1 && b(e, o) === 1 && (a = !1), i = r * (s - Number(a));
51
+ }
52
+ return i === 0 ? 0 : i;
53
+ }
54
+ function z(e, t, n) {
55
+ const o = W(e, t) / 1e3;
56
+ return Y(n == null ? void 0 : n.roundingMethod)(o);
57
+ }
58
+ function ee(e, t, n) {
59
+ const o = R(), r = (n == null ? void 0 : n.locale) ?? o.locale ?? O, s = 2520, i = b(e, t);
60
+ if (isNaN(i))
61
+ throw new RangeError("Invalid time value");
62
+ const a = Object.assign({}, n, {
63
+ addSuffix: n == null ? void 0 : n.addSuffix,
64
+ comparison: i
65
+ });
66
+ let l, c;
67
+ i > 0 ? (l = f(t), c = f(e)) : (l = f(e), c = f(t));
68
+ const d = z(c, l), m = (T(c) - T(l)) / 1e3, u = Math.round((d - m) / 60);
69
+ let h;
70
+ if (u < 2)
71
+ return n != null && n.includeSeconds ? d < 5 ? r.formatDistance("lessThanXSeconds", 5, a) : d < 10 ? r.formatDistance("lessThanXSeconds", 10, a) : d < 20 ? r.formatDistance("lessThanXSeconds", 20, a) : d < 40 ? r.formatDistance("halfAMinute", 0, a) : d < 60 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", 1, a) : u === 0 ? r.formatDistance("lessThanXMinutes", 1, a) : r.formatDistance("xMinutes", u, a);
72
+ if (u < 45)
73
+ return r.formatDistance("xMinutes", u, a);
74
+ if (u < 90)
75
+ return r.formatDistance("aboutXHours", 1, a);
76
+ if (u < S) {
77
+ const g = Math.round(u / 60);
78
+ return r.formatDistance("aboutXHours", g, a);
79
+ } else {
80
+ if (u < s)
81
+ return r.formatDistance("xDays", 1, a);
82
+ if (u < M) {
83
+ const g = Math.round(u / S);
84
+ return r.formatDistance("xDays", g, a);
85
+ } else if (u < M * 2)
86
+ return h = Math.round(u / M), r.formatDistance("aboutXMonths", h, a);
87
+ }
88
+ if (h = Q(c, l), h < 12) {
89
+ const g = Math.round(u / M);
90
+ return r.formatDistance("xMonths", g, a);
91
+ } else {
92
+ const g = h % 12, w = Math.trunc(h / 12);
93
+ return g < 3 ? r.formatDistance("aboutXYears", w, a) : g < 9 ? r.formatDistance("overXYears", w, a) : r.formatDistance("almostXYears", w + 1, a);
94
+ }
95
+ }
96
+ function te(e, t) {
97
+ return ee(e, G(e), t);
98
+ }
99
+ const V = [
100
+ "day",
101
+ "hour",
102
+ "minute",
103
+ "second",
104
+ "millisecond"
105
+ ], L = {
106
+ day: 864e5,
107
+ hour: 36e5,
108
+ minute: 6e4,
109
+ second: 1e3,
110
+ millisecond: 1
111
+ }, ne = {
112
+ day: "d",
113
+ hour: "hr",
114
+ minute: "min",
115
+ second: "s",
116
+ millisecond: "ms"
117
+ }, re = {
118
+ day: ["day", "days"],
119
+ hour: ["hour", "hours"],
120
+ minute: ["minute", "minutes"],
121
+ second: ["second", "seconds"],
122
+ millisecond: ["millisecond", "milliseconds"]
123
+ };
124
+ function oe(e) {
125
+ return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
126
+ }
127
+ function $(e, t) {
128
+ return oe(e) ? e : t;
129
+ }
130
+ function N(e, t) {
131
+ return V.indexOf($(e, t));
132
+ }
133
+ function se(e, t) {
134
+ const n = N(e, "day"), o = N(t, "second"), r = Math.min(n, o), s = Math.max(n, o);
135
+ return V.slice(r, s + 1);
136
+ }
137
+ function ae(e, t) {
138
+ return e * L[$(t, "second")];
139
+ }
140
+ function ie(e, t) {
141
+ const n = se(t.largestUnit, t.smallestUnit), o = n[n.length - 1], r = L[o];
142
+ let s = Math.round(e / r) * r;
143
+ return n.map((i) => {
144
+ const a = L[i], l = Math.floor(s / a);
145
+ return s -= l * a, { unit: i, value: l };
146
+ });
147
+ }
148
+ function le(e, t) {
149
+ const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
150
+ return o.slice(0, r).map((s) => `${s.value}${ne[s.unit]}`).join(" ");
151
+ }
152
+ function ce(e, t) {
153
+ const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
154
+ return o.slice(0, r).map((s) => {
155
+ const [i, a] = re[s.unit];
156
+ return `${s.value} ${s.value === 1 ? i : a}`;
157
+ }).join(" ");
158
+ }
159
+ function ue(e) {
160
+ const t = e.some(
161
+ (l) => l.unit === "day" && l.value !== 0
162
+ ), n = e.some((l) => l.unit === "millisecond"), o = e.findIndex((l) => l.value !== 0), r = Math.max(0, e.length - 2), s = t ? 0 : o === -1 ? r : Math.min(o, r), i = o === -1 ? e.slice(r) : e.slice(s);
163
+ if (i.length === 0)
164
+ return "0";
165
+ const a = i.map((l, c) => l.unit === "millisecond" ? String(l.value).padStart(3, "0") : c === 0 ? String(l.value) : String(l.value).padStart(2, "0")).join(":");
166
+ return n ? a.replace(/:(\d{3})$/, ".$1") : a;
167
+ }
168
+ function fe(e, t, n) {
169
+ const o = `${n.prefix || ""}${e}${n.suffix || ""}`;
170
+ return t ? n.negativeInParentheses ? `(${o})` : `-${o}` : o;
171
+ }
172
+ function me(e, t = {}) {
173
+ if (e == null)
174
+ return "";
175
+ const n = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
176
+ if (!Number.isFinite(n))
177
+ return "";
178
+ const o = t.inputUnit || "second", r = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", s = n < 0, i = Math.abs(ae(n, o)), a = ie(i, t), l = r === "digital" ? ue(a) : r === "long" ? ce(a, t.maxUnits) : le(a, t.maxUnits);
179
+ return fe(l, s, t);
180
+ }
181
+ function de(e, t, n) {
182
+ const o = {
183
+ ...t,
184
+ locale: t.locale ?? n
185
+ };
186
+ if (o.type === "number")
187
+ return y(e, o);
188
+ const { prefix: r, suffix: s, ...i } = o;
189
+ return `${r ?? ""}${y(e, {
190
+ ...i,
191
+ negativeStyle: o.type === "currency" ? o.negativeStyle : "minus"
192
+ })}${s ?? ""}`;
193
+ }
194
+ function p(e, t, n) {
195
+ return e === null ? { value: e, text: null } : !t || !Z(t) && t.type !== "duration" ? {
196
+ value: e,
197
+ text: y(e, { type: "number", locale: n })
198
+ } : t.type === "duration" ? {
199
+ value: e,
200
+ text: me(e, {
201
+ inputUnit: t.inputUnit,
202
+ outputStyle: t.outputStyle,
203
+ largestUnit: t.largestUnit,
204
+ smallestUnit: t.smallestUnit,
205
+ maxUnits: t.maxUnits,
206
+ prefix: t.prefix,
207
+ suffix: t.suffix,
208
+ negativeInParentheses: t.negativeStyle === "parentheses"
209
+ })
210
+ } : { value: e, text: de(e, t, n) };
211
+ }
212
+ function v(e, t, n, o) {
213
+ return e === null ? { value: e, text: null } : o === "percent" ? {
214
+ value: e,
215
+ text: y(e, {
216
+ type: "percent",
217
+ locale: n,
218
+ minimumFractionDigits: t,
219
+ maximumFractionDigits: t,
220
+ percentValueMode: "fraction"
221
+ })
222
+ } : {
223
+ value: e,
224
+ text: y(e, {
225
+ type: "number",
226
+ locale: n,
227
+ minimumFractionDigits: t,
228
+ maximumFractionDigits: t,
229
+ suffix: "×"
230
+ })
231
+ };
232
+ }
233
+ function I(e, t) {
234
+ if (e === void 0) return t;
235
+ if (!Number.isInteger(e) || e < 0 || e > 6)
236
+ throw new RangeError("Comparison precision must be an integer from 0 to 6.");
237
+ return e;
238
+ }
239
+ function Ne(e, t) {
240
+ const n = {
241
+ mode: t.displayMode,
242
+ current: p(
243
+ e.currentValue,
244
+ t.metricFormat,
245
+ t.locale
246
+ ),
247
+ comparison: p(
248
+ e.comparisonValue,
249
+ t.metricFormat,
250
+ t.locale
251
+ )
252
+ };
253
+ return (t.displayMode === "difference" || t.displayMode === "both") && (n.difference = p(
254
+ e.delta,
255
+ t.metricFormat,
256
+ t.locale
257
+ )), (t.displayMode === "percent_change" || t.displayMode === "both") && (n.percentChange = v(
258
+ e.percentChange,
259
+ I(t.precision, 1),
260
+ t.locale,
261
+ "percent"
262
+ )), t.displayMode === "ratio" && (n.ratio = v(
263
+ e.ratio,
264
+ I(t.precision, 2),
265
+ t.locale,
266
+ "ratio"
267
+ )), n;
268
+ }
269
+ function ve(e, t) {
270
+ return e && e !== "auto" ? e : t;
271
+ }
272
+ function Ie(e, t = /* @__PURE__ */ new Date()) {
273
+ try {
274
+ const n = {
275
+ timeZone: e,
276
+ timeZoneName: "short"
277
+ }, r = new Intl.DateTimeFormat("en-US", n).formatToParts(t).find((s) => s.type === "timeZoneName");
278
+ return (r == null ? void 0 : r.value) || e;
279
+ } catch {
280
+ return e;
281
+ }
282
+ }
283
+ function Ve(e) {
284
+ try {
285
+ const t = {
286
+ timeZone: e,
287
+ timeZoneName: "long"
288
+ }, o = new Intl.DateTimeFormat("en-US", t).formatToParts(
289
+ /* @__PURE__ */ new Date()
290
+ ).find((r) => r.type === "timeZoneName");
291
+ return (o == null ? void 0 : o.value) || e;
292
+ } catch {
293
+ return e;
294
+ }
295
+ }
296
+ function C(e, t = "auto") {
297
+ if (!e)
298
+ return /* @__PURE__ */ new Date(NaN);
299
+ const n = e.endsWith("Z"), o = /[+-]\d{2}:?\d{2}$/.test(e), r = /\([A-Z]{3,4}\)$/.test(e);
300
+ if (t === "auto")
301
+ return n || o || r ? new Date(e) : /* @__PURE__ */ new Date(e + "Z");
302
+ if (t === "local") {
303
+ if (n || o) {
304
+ const s = e.replace(/Z$/, "").replace(/[+-]\d{2}:?\d{2}$/, "");
305
+ return new Date(s);
306
+ }
307
+ return new Date(e);
308
+ } else return t === "UTC" ? n ? new Date(e) : o ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || o || r ? new Date(e) : j(e, t);
309
+ }
310
+ const ge = "MM/dd/yyyy", $e = (e, t, n, o = "auto") => {
311
+ if (!e)
312
+ return "";
313
+ try {
314
+ const r = C(e, o);
315
+ if (isNaN(r.getTime()))
316
+ return e;
317
+ const i = (t && t.trim() ? t : ge).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
318
+ return n && n !== "auto" ? k(r, n, i) : B(r, i);
319
+ } catch (r) {
320
+ return console.error("Date formatting error:", r), e;
321
+ }
322
+ }, Ce = (e, t = "auto") => {
323
+ if (!e)
324
+ return "";
325
+ try {
326
+ const n = C(e, t);
327
+ return isNaN(n.getTime()) ? e : te(n, { addSuffix: !0 });
328
+ } catch (n) {
329
+ return console.error("Relative time formatting error:", n), e;
330
+ }
331
+ };
332
+ function he(e, t = ",") {
333
+ if (e == null)
334
+ return "";
335
+ const n = String(e);
336
+ return n.includes(t) || n.includes('"') || n.includes(`
337
+ `) || n.includes("\r") ? `"${n.replace(/"/g, '""')}"` : n;
338
+ }
339
+ function ye(e, t = ",") {
340
+ return e.map((n) => he(n, t)).join(t);
341
+ }
342
+ function Me(e, t = {}) {
343
+ const { delimiter: n = ",", lineEnding: o = `
344
+ ` } = t;
345
+ return e.map((r) => ye(r, n)).join(o);
346
+ }
347
+ function _e(e, t = {}) {
348
+ if (e.length === 0)
349
+ return "";
350
+ const {
351
+ delimiter: n = ",",
352
+ lineEnding: o = `
353
+ `,
354
+ includeHeaders: r = !0,
355
+ columns: s
356
+ } = t, i = s || Object.keys(e[0]), a = [];
357
+ r && a.push(i);
358
+ for (const l of e) {
359
+ const c = i.map((d) => {
360
+ const m = l[d];
361
+ return m == null ? "" : String(m);
362
+ });
363
+ a.push(c);
364
+ }
365
+ return Me(a, { delimiter: n, lineEnding: o });
366
+ }
367
+ const be = "__TOTAL__";
368
+ function D(e) {
369
+ return typeof e == "object" && e !== null && !Array.isArray(e);
370
+ }
371
+ function x(e) {
372
+ return e === be;
373
+ }
374
+ function Fe(e) {
375
+ const t = /* @__PURE__ */ new Map(), n = (e.groupByColumns ?? []).map((r, s) => {
376
+ var c, d, m;
377
+ if (!D(r))
378
+ throw new Error(`Aggregate groupByColumns[${s}] is invalid`);
379
+ const i = typeof r.id == "string" && r.id.length > 0 ? r.id : void 0, a = i ? (m = (d = (c = e.columnKeyMap) == null ? void 0 : c.byRole) == null ? void 0 : d.groupby) == null ? void 0 : m[i] : void 0, l = (a == null ? void 0 : a.outputKey) || (a == null ? void 0 : a.rawKey) || (typeof r.alias == "string" && r.alias.length > 0 ? r.alias : typeof r.name == "string" && r.name.length > 0 ? r.name : void 0);
380
+ if (!l)
381
+ throw new Error(`Aggregate groupByColumns[${s}] has no output key`);
382
+ return [i, r.alias, r.name, l].forEach((u) => {
383
+ typeof u == "string" && u.length > 0 && t.set(u, l);
384
+ }), l;
385
+ }), o = (e.rowAggregates ?? []).flatMap((r) => !D(r) || typeof r.function != "string" || typeof r.groupLevel != "string" ? [] : [
386
+ {
387
+ function: r.function,
388
+ groupLevel: r.groupLevel === "ALL" ? "ALL" : t.get(r.groupLevel) || r.groupLevel,
389
+ ...typeof r.label == "string" ? { label: r.label } : {}
390
+ }
391
+ ]);
392
+ return { groupColumnKeys: n, rowAggregates: o };
393
+ }
394
+ function _(e) {
395
+ return e === "SUM" ? "Total" : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
396
+ }
397
+ function De(e) {
398
+ var n;
399
+ if (e.customLabel) return e.customLabel;
400
+ const t = _(e.aggregateFunction);
401
+ if (e.levelValue !== void 0 && !x(e.levelValue)) {
402
+ if (e.levelValue === null) {
403
+ const r = (n = e.formatValue) == null ? void 0 : n.call(e, null);
404
+ return r ? `Subtotal ${r}` : `Subtotal ${t}`;
405
+ }
406
+ const o = e.formatValue ? e.formatValue(e.levelValue) : String(e.levelValue);
407
+ if (o) return `Subtotal (${o})`;
408
+ }
409
+ return `Subtotal ${t}`;
410
+ }
411
+ function we(e, t) {
412
+ return t || `Grand ${_(e)}`;
413
+ }
414
+ function F(e) {
415
+ var o, r;
416
+ const t = e.context.groupColumnKeys, n = typeof e.row.aggregate == "string" ? e.row.aggregate : "SUM";
417
+ if (e.row.isGrandTotal === !0) {
418
+ const s = (o = e.context.rowAggregates.find(
419
+ (i) => i.groupLevel === "ALL"
420
+ )) == null ? void 0 : o.label;
421
+ return {
422
+ kind: "grand-total",
423
+ cells: t.map((i, a) => ({
424
+ columnKey: i,
425
+ text: a === 0 ? we(n, s) : "",
426
+ placement: a === 0 ? "label" : "empty",
427
+ colSpan: a === 0 ? t.length : 1
428
+ }))
429
+ };
430
+ }
431
+ if (e.row.isSubtotal === !0) {
432
+ if (typeof e.row.subtotalLevel != "string")
433
+ throw new Error("Aggregate subtotal row is missing subtotalLevel");
434
+ const s = t.indexOf(e.row.subtotalLevel);
435
+ if (s < 0)
436
+ throw new Error(
437
+ `Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`
438
+ );
439
+ const i = D(e.row.subtotalContext) ? e.row.subtotalContext : void 0, a = D(i == null ? void 0 : i.groupByValues) ? i.groupByValues : {}, l = (r = e.context.rowAggregates.find(
440
+ (c) => c.groupLevel === e.row.subtotalLevel && c.function === n
441
+ )) == null ? void 0 : r.label;
442
+ return {
443
+ kind: "subtotal",
444
+ cells: t.map((c, d) => {
445
+ if (d > s)
446
+ return {
447
+ columnKey: c,
448
+ text: "",
449
+ placement: "empty",
450
+ colSpan: 1
451
+ };
452
+ if (d < s) {
453
+ const m = e.row[c];
454
+ return {
455
+ columnKey: c,
456
+ text: m === void 0 || x(m) ? "" : e.formatValue(m, c),
457
+ placement: "value",
458
+ colSpan: 1
459
+ };
460
+ }
461
+ return {
462
+ columnKey: c,
463
+ text: De({
464
+ aggregateFunction: n,
465
+ customLabel: l,
466
+ levelValue: a[c],
467
+ formatValue: (m) => e.formatLabelValue ? e.formatLabelValue(m, c) : String(e.formatValue(m, c) ?? "")
468
+ }),
469
+ placement: "label",
470
+ colSpan: t.length - s
471
+ };
472
+ })
473
+ };
474
+ }
475
+ return {
476
+ kind: "data",
477
+ cells: t.map((s) => {
478
+ const i = e.row[s];
479
+ return {
480
+ columnKey: s,
481
+ text: i === void 0 || x(i) ? "" : e.formatValue(i, s),
482
+ placement: "value",
483
+ colSpan: 1
484
+ };
485
+ })
486
+ };
487
+ }
488
+ function Ue(e) {
489
+ const t = F(e).cells.find(
490
+ (n) => n.columnKey === e.columnKey
491
+ );
492
+ if (!t)
493
+ throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);
494
+ return t.text;
495
+ }
496
+ function Ee(e) {
497
+ return F(e).cells.map((t) => t.text);
498
+ }
499
+ class pe extends Error {
500
+ constructor(n, o) {
501
+ super(`${n}: ${o}`);
502
+ A(this, "deliveryBlocking", !0);
503
+ this.code = n, this.name = "PivotHeaderPresentationError";
504
+ }
505
+ }
506
+ function Pe(e) {
507
+ var r;
508
+ const t = e.mode ?? "formatted", n = e.members.map((s) => {
509
+ var a;
510
+ if (t === "canonical" || !s.temporalBucket)
511
+ return s.value === null ? "" : String(s.value);
512
+ const i = (a = e.resolveTemporalFormat) == null ? void 0 : a.call(e, s.fieldId);
513
+ if (!i)
514
+ throw new pe(
515
+ "missing_resolved_temporal_format",
516
+ `Missing resolved temporal presentation for pivot field "${s.fieldId}"`
517
+ );
518
+ return X({
519
+ value: s.value,
520
+ metadata: s.temporalBucket,
521
+ format: i
522
+ });
523
+ }), o = ((r = e.metricLabel) == null ? void 0 : r.trim()) || void 0;
524
+ return {
525
+ memberLabels: n,
526
+ ...o ? { metricLabel: o } : {},
527
+ flattenedLabel: [
528
+ ...n,
529
+ ...o ? [o] : []
530
+ ].join(" / ")
531
+ };
532
+ }
533
+ export {
534
+ be as A,
535
+ pe as P,
536
+ $e as a,
537
+ ye as b,
538
+ me as c,
539
+ Ne as d,
540
+ he as e,
541
+ Ce as f,
542
+ Ie as g,
543
+ Ve as h,
544
+ Me as i,
545
+ x as j,
546
+ Fe as k,
547
+ De as l,
548
+ we as m,
549
+ F as n,
550
+ _e as o,
551
+ C as p,
552
+ Ue as q,
553
+ ve as r,
554
+ Ee as s,
555
+ Pe as t,
556
+ te as u
557
+ };
@@ -1,7 +1,7 @@
1
1
  var y = Object.defineProperty;
2
2
  var c = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var u = (t, e, r) => c(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { v as d } from "./temporal-bucket-contract-_F6vNhhH.js";
4
+ import { v as d } from "./temporal-bucket-contract-BQOj6Frl.js";
5
5
  function f(t) {
6
6
  return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
7
7
  }
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-ChDBWX8I.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
1
+ "use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-anl4h-vg.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;