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 +0,0 @@
1
- "use strict";var Y=Object.defineProperty;var z=(e,t,r)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var w=(e,t,r)=>z(e,typeof t!="symbol"?t+"":t,r);const l=require("./format-types-CSv0V7mm.cjs"),h=require("./presentation-execution-BTV-Q43g.cjs"),W=require("./temporal-bucket-pMnV-4Nj.cjs"),J=require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");const Q=require("./metric-comparison-CUAJ8n4y.cjs"),ee=require("./temporal-bucket-contract-ChDBWX8I.cjs"),T=require("./pivot-result-identity-CDLRT-YG.cjs");function v(e,t){const r=l.toDate(e),n=l.toDate(t),o=r.getTime()-n.getTime();return o<0?-1:o>0?1:o}function te(e){return l.constructFrom(e,Date.now())}function re(e,t){const r=l.toDate(e),n=l.toDate(t),o=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return o*12+i}function oe(e){return t=>{const n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function ne(e,t){return+l.toDate(e)-+l.toDate(t)}function ie(e){const t=l.toDate(e);return t.setHours(23,59,59,999),t}function ae(e){const t=l.toDate(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function se(e){const t=l.toDate(e);return+ie(t)==+ae(t)}function ce(e,t){const r=l.toDate(e),n=l.toDate(t),o=v(r,n),i=Math.abs(re(r,n));let s;if(i<1)s=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-o*i);let a=v(r,n)===-o;se(l.toDate(e))&&i===1&&v(e,n)===1&&(a=!1),s=o*(i-Number(a))}return s===0?0:s}function le(e,t,r){const n=ne(e,t)/1e3;return oe(r==null?void 0:r.roundingMethod)(n)}function ue(e,t,r){const n=l.getDefaultOptions(),o=(r==null?void 0:r.locale)??n.locale??l.enUS,i=2520,s=v(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:s});let c,d;s>0?(c=l.toDate(t),d=l.toDate(e)):(c=l.toDate(e),d=l.toDate(t));const y=le(d,c),m=(l.getTimezoneOffsetInMilliseconds(d)-l.getTimezoneOffsetInMilliseconds(c))/1e3,f=Math.round((y-m)/60);let p;if(f<2)return r!=null&&r.includeSeconds?y<5?o.formatDistance("lessThanXSeconds",5,a):y<10?o.formatDistance("lessThanXSeconds",10,a):y<20?o.formatDistance("lessThanXSeconds",20,a):y<40?o.formatDistance("halfAMinute",0,a):y<60?o.formatDistance("lessThanXMinutes",1,a):o.formatDistance("xMinutes",1,a):f===0?o.formatDistance("lessThanXMinutes",1,a):o.formatDistance("xMinutes",f,a);if(f<45)return o.formatDistance("xMinutes",f,a);if(f<90)return o.formatDistance("aboutXHours",1,a);if(f<l.minutesInDay){const g=Math.round(f/60);return o.formatDistance("aboutXHours",g,a)}else{if(f<i)return o.formatDistance("xDays",1,a);if(f<l.minutesInMonth){const g=Math.round(f/l.minutesInDay);return o.formatDistance("xDays",g,a)}else if(f<l.minutesInMonth*2)return p=Math.round(f/l.minutesInMonth),o.formatDistance("aboutXMonths",p,a)}if(p=ce(d,c),p<12){const g=Math.round(f/l.minutesInMonth);return o.formatDistance("xMonths",g,a)}else{const g=p%12,C=Math.trunc(p/12);return g<3?o.formatDistance("aboutXYears",C,a):g<9?o.formatDistance("overXYears",C,a):o.formatDistance("almostXYears",C+1,a)}}function j(e,t){return ue(e,te(e),t)}const F=["day","hour","minute","second","millisecond"],R={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},fe={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},de={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function me(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function K(e,t){return me(e)?e:t}function I(e,t){return F.indexOf(K(e,t))}function ye(e,t){const r=I(e,"day"),n=I(t,"second"),o=Math.min(r,n),i=Math.max(r,n);return F.slice(o,i+1)}function ge(e,t){return e*R[K(t,"second")]}function pe(e,t){const r=ye(t.largestUnit,t.smallestUnit),n=r[r.length-1],o=R[n];let i=Math.round(e/o)*o;return r.map(s=>{const a=R[s],c=Math.floor(i/a);return i-=c*a,{unit:s,value:c}})}function he(e,t){const r=e.filter(i=>i.value!==0),n=r.length>0?r:[e[e.length-1]],o=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):n.length;return n.slice(0,o).map(i=>`${i.value}${fe[i.unit]}`).join(" ")}function we(e,t){const r=e.filter(i=>i.value!==0),n=r.length>0?r:[e[e.length-1]],o=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):n.length;return n.slice(0,o).map(i=>{const[s,a]=de[i.unit];return`${i.value} ${i.value===1?s:a}`}).join(" ")}function be(e){const t=e.some(c=>c.unit==="day"&&c.value!==0),r=e.some(c=>c.unit==="millisecond"),n=e.findIndex(c=>c.value!==0),o=Math.max(0,e.length-2),i=t?0:n===-1?o:Math.min(n,o),s=n===-1?e.slice(o):e.slice(i);if(s.length===0)return"0";const a=s.map((c,d)=>c.unit==="millisecond"?String(c.value).padStart(3,"0"):d===0?String(c.value):String(c.value).padStart(2,"0")).join(":");return r?a.replace(/:(\d{3})$/,".$1"):a}function ve(e,t,r){const n=`${r.prefix||""}${e}${r.suffix||""}`;return t?r.negativeInParentheses?`(${n})`:`-${n}`:n}function N(e,t={}){if(e==null)return"";const r=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(r))return"";const n=t.inputUnit||"second",o=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",i=r<0,s=Math.abs(ge(r,n)),a=pe(s,t),c=o==="digital"?be(a):o==="long"?we(a,t.maxUnits):he(a,t.maxUnits);return ve(c,i,t)}function Me(e,t,r){const n={...t,locale:t.locale??r};if(n.type==="number")return h.formatNumericCanonical(e,n);const{prefix:o,suffix:i,...s}=n;return`${o??""}${h.formatNumericCanonical(e,{...s,negativeStyle:n.type==="currency"?n.negativeStyle:"minus"})}${i??""}`}function D(e,t,r){return e===null?{value:e,text:null}:!t||!l.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:h.formatNumericCanonical(e,{type:"number",locale:r})}:t.type==="duration"?{value:e,text:N(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:Me(e,t,r)}}function L(e,t,r,n){return e===null?{value:e,text:null}:n==="percent"?{value:e,text:h.formatNumericCanonical(e,{type:"percent",locale:r,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:h.formatNumericCanonical(e,{type:"number",locale:r,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function _(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 Ae(e,t){const r={mode:t.displayMode,current:D(e.currentValue,t.metricFormat,t.locale),comparison:D(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(r.difference=D(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(r.percentChange=L(e.percentChange,_(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(r.ratio=L(e.ratio,_(t.precision,2),t.locale,"ratio")),r}function Ce(e,t){return e&&e!=="auto"?e:t}function De(e,t=new Date){try{const r={timeZone:e,timeZoneName:"short"},o=new Intl.DateTimeFormat("en-US",r).formatToParts(t).find(i=>i.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function Re(e){try{const t={timeZone:e,timeZoneName:"long"},n=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(o=>o.type==="timeZoneName");return(n==null?void 0:n.value)||e}catch{return e}}function x(e,t="auto"){if(!e)return new Date(NaN);const r=e.endsWith("Z"),n=/[+-]\d{2}:?\d{2}$/.test(e),o=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return r||n||o?new Date(e):new Date(e+"Z");if(t==="local"){if(r||n){const i=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(i)}return new Date(e)}else return t==="UTC"?r?new Date(e):n?new Date(e):new Date(e+"Z"):r||n||o?new Date(e):l.fromZonedTime(e,t)}const xe="MM/dd/yyyy",Se=(e,t,r,n="auto")=>{if(!e)return"";try{const o=x(e,n);if(isNaN(o.getTime()))return e;const s=(t&&t.trim()?t:xe).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return r&&r!=="auto"?l.formatInTimeZone(o,r,s):l.format(o,s)}catch(o){return console.error("Date formatting error:",o),e}},Te=(e,t="auto")=>{if(!e)return"";try{const r=x(e,t);return isNaN(r.getTime())?e:j(r,{addSuffix:!0})}catch(r){return console.error("Relative time formatting error:",r),e}};function O(e,t=","){if(e==null)return"";const r=String(e);return r.includes(t)||r.includes('"')||r.includes(`
2
- `)||r.includes("\r")?`"${r.replace(/"/g,'""')}"`:r}function V(e,t=","){return e.map(r=>O(r,t)).join(t)}function U(e,t={}){const{delimiter:r=",",lineEnding:n=`
3
- `}=t;return e.map(o=>V(o,r)).join(n)}function Ie(e,t={}){if(e.length===0)return"";const{delimiter:r=",",lineEnding:n=`
4
- `,includeHeaders:o=!0,columns:i}=t,s=i||Object.keys(e[0]),a=[];o&&a.push(s);for(const c of e){const d=s.map(y=>{const m=c[y];return m==null?"":String(m)});a.push(d)}return U(a,{delimiter:r,lineEnding:n})}const B="__TOTAL__";function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function A(e){return e===B}function Le(e){const t=new Map,r=(e.groupByColumns??[]).map((o,i)=>{var d,y,m;if(!M(o))throw new Error(`Aggregate groupByColumns[${i}] is invalid`);const s=typeof o.id=="string"&&o.id.length>0?o.id:void 0,a=s?(m=(y=(d=e.columnKeyMap)==null?void 0:d.byRole)==null?void 0:y.groupby)==null?void 0:m[s]:void 0,c=(a==null?void 0:a.outputKey)||(a==null?void 0:a.rawKey)||(typeof o.alias=="string"&&o.alias.length>0?o.alias:typeof o.name=="string"&&o.name.length>0?o.name:void 0);if(!c)throw new Error(`Aggregate groupByColumns[${i}] has no output key`);return[s,o.alias,o.name,c].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,c)}),c}),n=(e.rowAggregates??[]).flatMap(o=>!M(o)||typeof o.function!="string"||typeof o.groupLevel!="string"?[]:[{function:o.function,groupLevel:o.groupLevel==="ALL"?"ALL":t.get(o.groupLevel)||o.groupLevel,...typeof o.label=="string"?{label:o.label}:{}}]);return{groupColumnKeys:r,rowAggregates:n}}function q(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function G(e){var r;if(e.customLabel)return e.customLabel;const t=q(e.aggregateFunction);if(e.levelValue!==void 0&&!A(e.levelValue)){if(e.levelValue===null){const o=(r=e.formatValue)==null?void 0:r.call(e,null);return o?`Subtotal ${o}`:`Subtotal ${t}`}const n=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(n)return`Subtotal (${n})`}return`Subtotal ${t}`}function Z(e,t){return t||`Grand ${q(e)}`}function S(e){var n,o;const t=e.context.groupColumnKeys,r=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const i=(n=e.context.rowAggregates.find(s=>s.groupLevel==="ALL"))==null?void 0:n.label;return{kind:"grand-total",cells:t.map((s,a)=>({columnKey:s,text:a===0?Z(r,i):"",placement:a===0?"label":"empty",colSpan:a===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 i=t.indexOf(e.row.subtotalLevel);if(i<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const s=M(e.row.subtotalContext)?e.row.subtotalContext:void 0,a=M(s==null?void 0:s.groupByValues)?s.groupByValues:{},c=(o=e.context.rowAggregates.find(d=>d.groupLevel===e.row.subtotalLevel&&d.function===r))==null?void 0:o.label;return{kind:"subtotal",cells:t.map((d,y)=>{if(y>i)return{columnKey:d,text:"",placement:"empty",colSpan:1};if(y<i){const m=e.row[d];return{columnKey:d,text:m===void 0||A(m)?"":e.formatValue(m,d),placement:"value",colSpan:1}}return{columnKey:d,text:G({aggregateFunction:r,customLabel:c,levelValue:a[d],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,d):String(e.formatValue(m,d)??"")}),placement:"label",colSpan:t.length-i}})}}return{kind:"data",cells:t.map(i=>{const s=e.row[i];return{columnKey:i,text:s===void 0||A(s)?"":e.formatValue(s,i),placement:"value",colSpan:1}})}}function _e(e){const t=S(e).cells.find(r=>r.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Ee(e){return S(e).cells.map(t=>t.text)}class H extends Error{constructor(r,n){super(`${r}: ${n}`);w(this,"deliveryBlocking",!0);this.code=r,this.name="PivotHeaderPresentationError"}}function Pe(e){var o;const t=e.mode??"formatted",r=e.members.map(i=>{var a;if(t==="canonical"||!i.temporalBucket)return i.value===null?"":String(i.value);const s=(a=e.resolveTemporalFormat)==null?void 0:a.call(e,i.fieldId);if(!s)throw new H("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${i.fieldId}"`);return W.formatTemporalBucket({value:i.value,metadata:i.temporalBucket,format:s})}),n=((o=e.metricLabel)==null?void 0:o.trim())||void 0;return{memberLabels:r,...n?{metricLabel:n}:{},flattenedLabel:[...r,...n?[n]:[]].join(" / ")}}function b(e){return Array.from(new Set((e??[]).flatMap(t=>typeof t.id=="string"&&t.id?[t.id]:[])))}function $e(e){const t=e.metricFields??[],r=b(t),n=new Map;return r.forEach(o=>{n.set(o,t.filter(i=>i.id===o).length)}),{expectedRoleFieldIds:{groupby:b(e.groupByFields),metric:r.length>0?r:[J.SEMAPHOR_GENERATED_COUNT_METRIC_ID],pivotby:b(e.pivotByFields),detail:b(e.detailFields)},expectedMetricAliases:t.flatMap(o=>o.id&&(n.get(o.id)??0)>1?[Q.resolveMetricResultAlias(o)]:[])}}class u extends Error{constructor(r,n){super(`invalid_pivot_result_lifecycle: ${r}`);w(this,"code","invalid_pivot_result_lifecycle");w(this,"deliveryBlocking",!0);this.cause=n,this.name="PivotResultLifecycleError"}}function ke(e){if(!Array.isArray(e)||e.some(r=>!r||typeof r!="object"||Array.isArray(r)||typeof r.key!="string"||!r.key||typeof r.name!="string"||typeof r.label!="string"))throw new u("Canonical pivot columns must be an array of keyed, named result descriptors.");const t=e;if(new Set(t.map(r=>r.key)).size!==t.length)throw new u("Canonical pivot column keys must be unique.");for(const r of t){const n=ee.validateTemporalBucketResultColumn(r,{metadataRequired:!1});if(!n.ok)throw new u(`Canonical pivot column "${r.key}" has invalid temporal metadata: ${n.error.message}`)}return t}function E(e){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1||e.source!=="explorer"||!e.byRole||typeof e.byRole!="object"||Array.isArray(e.byRole))throw new u("A loaded canonical pivot result requires its role-scoped column key map.");const t=e,r=new Set(["groupby","metric","pivotby","detail"]);for(const[n,o]of Object.entries(t.byRole)){if(!r.has(n)||!o||typeof o!="object"||Array.isArray(o))throw new u(`Canonical pivot role map contains invalid "${n}" bindings.`);for(const[i,s]of Object.entries(o))if(!i||!s||typeof s!="object"||Array.isArray(s)||s.role!==n||typeof s.rawKey!="string"||!s.rawKey||s.outputKey!==void 0&&(typeof s.outputKey!="string"||!s.outputKey))throw new u(`Canonical pivot role map contains an invalid "${n}:${i}" binding.`)}if(t.byMetricAlias!==void 0){if(!t.byMetricAlias||typeof t.byMetricAlias!="object"||Array.isArray(t.byMetricAlias))throw new u("Canonical pivot metric-alias bindings must be an object.");for(const[n,o]of Object.entries(t.byMetricAlias))if(!n||!o||typeof o!="object"||Array.isArray(o)||o.role!=="metric"||typeof o.rawKey!="string"||!o.rawKey||o.outputKey!==void 0&&(typeof o.outputKey!="string"||!o.outputKey))throw new u(`Canonical pivot metric-alias map contains an invalid "${n}" binding.`)}return t}function je(e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new u("Canonical pivot column metadata must be an object.");for(const[t,r]of Object.entries(e)){if(!t||!r||typeof r!="object"||Array.isArray(r))throw new u(`Canonical pivot column metadata contains an invalid "${t}" classification.`);const{isSubtotal:n,subtotalScope:o}=r;if(n!==void 0&&typeof n!="boolean"||o!==void 0&&o!=="base"&&o!=="pivot-value"&&o!=="grand-total"||n===!0&&o!=="pivot-value"&&o!=="grand-total"||(o==="pivot-value"||o==="grand-total")&&n!==!0||o==="base"&&n===!0)throw new u(`Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`)}return e}function P(e,t){if(!Array.isArray(e)||e.some(r=>typeof r!="string"||!r)||new Set(e).size!==e.length)throw new u(`Canonical pivot contract ${t} must be an array of unique field identities.`);return e}function Fe(e,t){if(!e||typeof e!="object"||Array.isArray(e)||e.version!==1)throw new u("A canonical pivot result requires its versioned result contract.");const r=e,n=r.expectedRoleFieldIds;if(!n||typeof n!="object"||Array.isArray(n))throw new u("Canonical pivot contract role identities must be an object.");const i=Object.fromEntries(["groupby","metric","pivotby","detail"].map(f=>[f,P(n[f],`expectedRoleFieldIds.${f}`)])),s=P(r.expectedMetricAliases,"expectedMetricAliases"),a=r.columnKinds;if(!a||typeof a!="object"||Array.isArray(a))throw new u("Canonical pivot contract column kinds must be an object.");const c=new Set(["row","pivot_metric","value"]),d=t.map(f=>f.key),y=Object.keys(a);if(y.length!==d.length||y.some(f=>!d.includes(f)||!c.has(a[f])))throw new u("Canonical pivot contract must classify every authoritative result column exactly once.");const m=je(r.columnClassifications);if(Object.keys(m).some(f=>!d.includes(f)))throw new u("Canonical pivot contract contains a classification for an unknown result column.");return{version:1,expectedRoleFieldIds:i,expectedMetricAliases:s,columnKinds:a,columnClassifications:m}}function $(e,t){const r=["groupby","metric","pivotby","detail"];for(const i of r){const s=new Set(t.expectedRoleFieldIds[i]??[]),a=Object.keys(e.byRole[i]??{});if(a.length!==s.size||a.some(c=>!s.has(c)))throw new u(`The role-scoped ${i} bindings do not match the authored result fields.`)}const n=new Set(t.expectedMetricAliases),o=Object.keys(e.byMetricAlias??{});if(o.length!==n.size||o.some(i=>!n.has(i)))throw new u("The metric-alias bindings do not match the authored metric instances.")}function Ke(e){if(!Array.isArray(e)||e.some(t=>!t||typeof t!="object"||Array.isArray(t)))throw new u("Canonical pivot records must be an array of row objects.");return e}function Ne(e,t){e.forEach((r,n)=>{t.forEach(o=>{if(!Object.prototype.hasOwnProperty.call(r,o.key)||r[o.key]===void 0)throw new u(`Canonical pivot column "${o.key}" is absent from row ${n}.`)})})}function Oe(e,t,r){const n=new Set(t.map(o=>o.key));["groupby","detail"].forEach(o=>{Object.entries(e.byRole[o]??{}).forEach(([i,s])=>{const a=s.outputKey||s.rawKey;if(!n.has(a)||r.columnKinds[a]!=="row")throw new u(`The role-scoped ${o} binding for "${i}" does not name an authoritative result column.`)})})}function k(e,t){t.forEach(r=>{const n=e.columnKinds[r.key];if(n==="pivot_metric"&&r.pivotIdentity===void 0)throw new u(`Physical pivot result column "${r.key}" is missing its identity.`);if(n!=="pivot_metric"&&r.pivotIdentity!==void 0)throw new u(`Canonical pivot result column "${r.key}" carries pivot identity outside the physical pivot projection.`)})}function X(e){const t=Ke(e.records),r=ke(e.columns),n=Fe(e.pivotResultContract,r),o=n.expectedRoleFieldIds.pivotby??[];if(e.pivotResultState==="loaded_empty"){if(t.length!==0)throw new u("A loaded_empty pivot result cannot carry records.");if(r.some(c=>n.columnKinds[c.key]==="pivot_metric"))throw new u("A loaded_empty pivot result cannot carry physical pivot columns.");k(n,r);const a=E(e.columnKeyMap);return $(a,n),{pivotResultState:"loaded_empty",records:[],columns:r,columnKeyMap:a,pivotResultContract:n}}if(e.pivotResultState!=="loaded_valid")throw new u("A canonical pivot result must declare loaded_empty or loaded_valid.");if(t.length===0)throw new u("A loaded_valid pivot result must carry at least one record.");const i=E(e.columnKeyMap);$(i,n),Oe(i,r,n),k(n,r);const s=r.filter(a=>n.columnKinds[a.key]==="pivot_metric");if(o.length>0&&s.length===0)throw new u("A loaded_valid pivot result is missing its physical pivot columns.");try{T.requirePivotResultColumnIdentities(s,{expectedPivotFieldIds:o,columnClassifications:n.columnClassifications})}catch(a){throw a instanceof T.PivotResultIdentityError?new u(a.message,a):a}return Ne(t,r),{pivotResultState:"loaded_valid",records:t,columns:r,columnKeyMap:i,pivotResultContract:n}}function Ve(e){const t=new Set;["groupby","detail"].forEach(i=>{Object.values(e.columnKeyMap.byRole[i]??{}).forEach(s=>{t.add(s.outputKey||s.rawKey)})});const r=new Set(e.physicalPivotColumnKeys),n=new Set(e.columns.map(i=>i.key)),o={version:1,expectedRoleFieldIds:{groupby:Array.from(new Set(e.expectedRoleFieldIds.groupby??[])),metric:Array.from(new Set(e.expectedRoleFieldIds.metric??[])),pivotby:Array.from(new Set(e.expectedRoleFieldIds.pivotby??[])),detail:Array.from(new Set(e.expectedRoleFieldIds.detail??[]))},expectedMetricAliases:[...e.expectedMetricAliases??[]],columnKinds:Object.fromEntries(e.columns.map(i=>[i.key,t.has(i.key)?"row":r.has(i.key)?"pivot_metric":"value"])),columnClassifications:Object.fromEntries(Object.entries(e.columnMetadata??{}).filter(([i])=>n.has(i)))};return X({pivotResultState:e.records.length===0?"loaded_empty":"loaded_valid",pivotResultContract:o,records:e.records,columns:e.columns,columnKeyMap:e.columnKeyMap})}exports.AGGREGATE_TOTAL_MEMBER_MARKER=B;exports.PivotHeaderPresentationError=H;exports.PivotResultLifecycleError=u;exports.arrayToCSV=U;exports.arrayToCSVRow=V;exports.createCanonicalPivotResultTransport=Ve;exports.derivePivotResultContractExpectations=$e;exports.escapeCSVValue=O;exports.formatAggregateGrandTotalLabel=Z;exports.formatAggregateGroupCell=_e;exports.formatAggregateGroupRow=Ee;exports.formatAggregateSubtotalLabel=G;exports.formatDate=Se;exports.formatDistanceToNow=j;exports.formatDuration=N;exports.formatMetricComparison=Ae;exports.formatRelativeTime=Te;exports.getTimezoneAbbreviation=De;exports.getTimezoneName=Re;exports.isAggregateTotalMemberMarker=A;exports.objectsToCSV=Ie;exports.parseCanonicalPivotResultTransport=X;exports.parseWithSourceTimezone=x;exports.presentAggregateGroupRow=S;exports.presentPivotHeader=Pe;exports.resolveAggregateTablePresentationContext=Le;exports.resolveTimezone=Ce;
@@ -1,637 +0,0 @@
1
- import { b as C } from "./report-runtime-context-bCy3CVzK.js";
2
- import { canonicalizeSupportedLocale as F, canonicalizeSupportedCurrencyCode as y } from "../value-format-preferences/index.js";
3
- import { p as M } from "./temporal-bucket-BnPxGrAi.js";
4
- function I(r) {
5
- if (!r) return !1;
6
- const e = r.toLowerCase().replace("_", "-");
7
- return e === "en-in" || e.startsWith("en-in-");
8
- }
9
- function $(r, e) {
10
- const i = Math.abs(r);
11
- return i >= 1e12 ? { divisor: 1e12, suffix: "T" } : i >= 1e9 ? { divisor: 1e9, suffix: "B" } : I(e) && i >= 1e7 ? { divisor: 1e7, suffix: "Cr" } : i >= 1e6 ? { divisor: 1e6, suffix: "M" } : I(e) && i >= 1e5 ? { divisor: 1e5, suffix: "L" } : i >= 1e3 ? { divisor: 1e3, suffix: "K" } : { divisor: 1, suffix: "" };
12
- }
13
- function h(r, e) {
14
- try {
15
- const i = d(e);
16
- return $(r, i);
17
- } catch {
18
- return $(r, "en-US");
19
- }
20
- }
21
- function P(r) {
22
- try {
23
- return new Intl.NumberFormat(r), !0;
24
- } catch {
25
- return !1;
26
- }
27
- }
28
- function d(r) {
29
- return r && P(r) ? r : "en-US";
30
- }
31
- function v(r, e) {
32
- if (r == null || isNaN(r))
33
- return "";
34
- const i = d(e == null ? void 0 : e.locale);
35
- let a = r;
36
- if (e != null && e.multiplyBy && (a *= e.multiplyBy), e != null && e.useSuffix) {
37
- const { divisor: t, suffix: s } = h(a, i);
38
- a = a / t;
39
- const n = new Intl.NumberFormat(i, {
40
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
41
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
42
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
43
- }).format(a);
44
- return `${(e == null ? void 0 : e.prefix) ?? ""}${n}${s}${(e == null ? void 0 : e.suffix) ?? ""}`;
45
- }
46
- const c = new Intl.NumberFormat(i, {
47
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
48
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
49
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
50
- }).format(a);
51
- if (e != null && e.negativeInParentheses && a < 0) {
52
- const t = c.replace("-", "");
53
- return `(${(e == null ? void 0 : e.prefix) ?? ""}${t}${(e == null ? void 0 : e.suffix) ?? ""})`;
54
- }
55
- return `${(e == null ? void 0 : e.prefix) ?? ""}${c}${(e == null ? void 0 : e.suffix) ?? ""}`;
56
- }
57
- function k(r, e) {
58
- if (r == null || isNaN(r))
59
- return "";
60
- const i = d(e == null ? void 0 : e.locale), a = (e == null ? void 0 : e.currency) || "USD", c = r < 0, t = !!(e != null && e.negativeInParentheses && c), s = t ? Math.abs(r) : r;
61
- try {
62
- if (e != null && e.useSuffix) {
63
- const { divisor: u, suffix: l } = h(s, i), m = s / u, D = `${new Intl.NumberFormat(i, {
64
- style: "currency",
65
- currency: a,
66
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
67
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
68
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
69
- }).format(m)}${l}`;
70
- return t ? `(${D})` : D;
71
- }
72
- const n = new Intl.NumberFormat(i, {
73
- style: "currency",
74
- currency: a,
75
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
76
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
77
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
78
- }).format(s);
79
- return t ? `(${n})` : n;
80
- } catch {
81
- const n = Math.abs(r), u = e != null && e.useSuffix ? h(n, i) : { divisor: 1, suffix: "" }, l = v(
82
- n / u.divisor,
83
- {
84
- locale: i,
85
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
86
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
87
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
88
- }
89
- ), m = `${a} ${l}${u.suffix}`;
90
- return c ? e != null && e.negativeInParentheses ? `(${m})` : `-${m}` : m;
91
- }
92
- }
93
- function S(r, e) {
94
- if (r == null || isNaN(r))
95
- return "";
96
- const i = d(e == null ? void 0 : e.locale), c = (e == null ? void 0 : e.alreadyPercent) ?? (e == null ? void 0 : e.percentValueMode) === "whole" ? r / 100 : r;
97
- return new Intl.NumberFormat(i, {
98
- style: "percent",
99
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
100
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
101
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
102
- }).format(c);
103
- }
104
- function E(r, e) {
105
- if (r == null || isNaN(r))
106
- return "";
107
- const i = d(e == null ? void 0 : e.locale);
108
- return new Intl.NumberFormat(i, {
109
- notation: "scientific",
110
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
111
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2
112
- }).format(r);
113
- }
114
- function G(r, e) {
115
- if (r == null || Number.isNaN(r))
116
- return "";
117
- const i = e.scale === void 0 ? r : r * e.scale, a = e.negativeStyle === "parentheses" && i < 0, c = a ? Math.abs(i) : i, t = {
118
- style: e.type === "number" ? "decimal" : e.type,
119
- locale: e.locale,
120
- currency: e.currency,
121
- minimumFractionDigits: e.minimumFractionDigits,
122
- maximumFractionDigits: e.maximumFractionDigits,
123
- useGrouping: e.useGrouping,
124
- percentValueMode: e.percentValueMode,
125
- useSuffix: e.compact
126
- };
127
- let s;
128
- switch (e.type) {
129
- case "currency":
130
- s = k(c, t);
131
- break;
132
- case "percent":
133
- s = S(c, t);
134
- break;
135
- case "scientific":
136
- s = E(c, t);
137
- break;
138
- default:
139
- s = v(c, t);
140
- break;
141
- }
142
- const n = `${e.prefix ?? ""}${s}${e.suffix ?? ""}`;
143
- return a ? `(${n})` : n;
144
- }
145
- function J(r, e, i = "en-US") {
146
- if (r == null || isNaN(r))
147
- return "";
148
- const a = d((e == null ? void 0 : e.locale) || i), c = (e == null ? void 0 : e.style) || "decimal", t = c === "decimal" ? "number" : c;
149
- return t === "currency" && new Intl.NumberFormat(a, {
150
- style: "currency",
151
- currency: (e == null ? void 0 : e.currency) || "USD"
152
- }), G(r, {
153
- type: t,
154
- locale: a,
155
- currency: t === "currency" ? (e == null ? void 0 : e.currency) || "USD" : void 0,
156
- minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
157
- maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
158
- useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0,
159
- percentValueMode: t === "percent" ? (e == null ? void 0 : e.percentValueMode) ?? "whole" : void 0,
160
- scale: e == null ? void 0 : e.scale,
161
- compact: e == null ? void 0 : e.compact,
162
- negativeStyle: e == null ? void 0 : e.negativeStyle,
163
- prefix: e == null ? void 0 : e.prefix,
164
- suffix: e == null ? void 0 : e.suffix
165
- });
166
- }
167
- function Y(r, e, i) {
168
- const a = {
169
- style: e === "currency" ? "currency" : e === "percent" ? "percent" : "decimal",
170
- locale: i == null ? void 0 : i.locale,
171
- currency: i == null ? void 0 : i.currency,
172
- minimumFractionDigits: i == null ? void 0 : i.decimalPlaces,
173
- maximumFractionDigits: i == null ? void 0 : i.decimalPlaces,
174
- useSuffix: i == null ? void 0 : i.useSuffix,
175
- prefix: i == null ? void 0 : i.prefix,
176
- suffix: i == null ? void 0 : i.suffix,
177
- negativeInParentheses: i == null ? void 0 : i.negativeInParentheses,
178
- multiplyBy: i == null ? void 0 : i.multiplyBy
179
- };
180
- switch (e) {
181
- case "currency":
182
- return k(r, a);
183
- case "percent":
184
- return S(r, a);
185
- case "scientific":
186
- return E(r, a);
187
- default:
188
- return v(r, a);
189
- }
190
- }
191
- const V = [
192
- "type",
193
- "locale",
194
- "minimumFractionDigits",
195
- "maximumFractionDigits",
196
- "useGrouping",
197
- "prefix",
198
- "suffix",
199
- "negativeStyle",
200
- "compact",
201
- "scale",
202
- "currency",
203
- "percentValueMode"
204
- ];
205
- function j(r) {
206
- if (r === null || typeof r != "object" || Array.isArray(r))
207
- return !1;
208
- const e = Object.getPrototypeOf(r);
209
- return e === null || e === Object.prototype;
210
- }
211
- function K(r) {
212
- if (!j(r))
213
- return {
214
- ok: !1,
215
- issues: [{ path: "$", message: "Numeric format must be an object." }]
216
- };
217
- const e = [], i = new Set(V);
218
- Object.keys(r).filter((t) => !i.has(t)).forEach(
219
- (t) => e.push({ path: t, message: `Unknown property "${t}".` })
220
- ), r.type !== "number" && r.type !== "currency" && r.type !== "percent" && r.type !== "scientific" && e.push({
221
- path: "type",
222
- message: "Expected number, currency, percent, or scientific."
223
- });
224
- const a = r.locale === void 0 ? void 0 : F(r.locale);
225
- r.locale !== void 0 && !a && e.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
226
- const c = r.currency === void 0 ? void 0 : y(r.currency);
227
- r.currency !== void 0 && !c && e.push({
228
- path: "currency",
229
- message: "Expected a supported ISO 4217 currency code."
230
- });
231
- for (const t of ["minimumFractionDigits", "maximumFractionDigits"]) {
232
- const s = r[t];
233
- s !== void 0 && (!Number.isInteger(s) || typeof s != "number" || s < 0 || s > 20) && e.push({
234
- path: t,
235
- message: "Expected an integer from 0 to 20."
236
- });
237
- }
238
- typeof r.minimumFractionDigits == "number" && typeof r.maximumFractionDigits == "number" && r.minimumFractionDigits > r.maximumFractionDigits && e.push({
239
- path: "maximumFractionDigits",
240
- message: "Must be greater than or equal to minimumFractionDigits."
241
- });
242
- for (const t of ["useGrouping", "compact"])
243
- r[t] !== void 0 && typeof r[t] != "boolean" && e.push({ path: t, message: "Expected a boolean." });
244
- for (const t of ["prefix", "suffix"])
245
- r[t] !== void 0 && typeof r[t] != "string" && e.push({ path: t, message: "Expected a string." });
246
- return r.negativeStyle !== void 0 && r.negativeStyle !== "minus" && r.negativeStyle !== "parentheses" && e.push({
247
- path: "negativeStyle",
248
- message: "Expected minus or parentheses."
249
- }), r.percentValueMode !== void 0 && r.percentValueMode !== "fraction" && r.percentValueMode !== "whole" && e.push({
250
- path: "percentValueMode",
251
- message: "Expected fraction or whole."
252
- }), r.scale !== void 0 && (typeof r.scale != "number" || !Number.isFinite(r.scale)) && e.push({ path: "scale", message: "Expected a finite number." }), e.length > 0 ? { ok: !1, issues: e } : {
253
- ok: !0,
254
- value: {
255
- type: r.type,
256
- ...a ? { locale: a } : {},
257
- ...r.minimumFractionDigits !== void 0 ? { minimumFractionDigits: r.minimumFractionDigits } : {},
258
- ...r.maximumFractionDigits !== void 0 ? { maximumFractionDigits: r.maximumFractionDigits } : {},
259
- ...r.useGrouping !== void 0 ? { useGrouping: r.useGrouping } : {},
260
- ...r.prefix !== void 0 ? { prefix: r.prefix } : {},
261
- ...r.suffix !== void 0 ? { suffix: r.suffix } : {},
262
- ...r.negativeStyle !== void 0 ? {
263
- negativeStyle: r.negativeStyle
264
- } : {},
265
- ...r.compact !== void 0 ? { compact: r.compact } : {},
266
- ...r.scale !== void 0 ? { scale: r.scale } : {},
267
- ...c ? { currency: c } : {},
268
- ...r.percentValueMode !== void 0 ? {
269
- percentValueMode: r.percentValueMode
270
- } : {}
271
- }
272
- };
273
- }
274
- function R(r) {
275
- const e = K(r);
276
- if (!e.ok)
277
- return e;
278
- const i = [];
279
- return e.value.locale || i.push({
280
- path: "locale",
281
- message: "Resolved numeric formats require an explicit locale."
282
- }), e.value.minimumFractionDigits === void 0 && i.push({
283
- path: "minimumFractionDigits",
284
- message: "Resolved numeric formats require minimumFractionDigits."
285
- }), e.value.maximumFractionDigits === void 0 && i.push({
286
- path: "maximumFractionDigits",
287
- message: "Resolved numeric formats require maximumFractionDigits."
288
- }), e.value.type === "currency" && !e.value.currency && i.push({
289
- path: "currency",
290
- message: "Resolved currency formats require an explicit currency."
291
- }), i.length > 0 ? { ok: !1, issues: i } : e;
292
- }
293
- function H(r) {
294
- var a;
295
- const e = /* @__PURE__ */ new Set();
296
- if (r.snapshot.resolvedFormats.forEach((c, t) => {
297
- if (c.format.type !== "temporal_bucket") {
298
- if (c.scope.attachmentIndex !== void 0)
299
- throw new Error(
300
- `resolvedFormats.${t}.scope.attachmentIndex is not valid for a card export`
301
- );
302
- if (c.scope.dashboardId !== r.expectedScope.dashboardId || c.scope.cardId !== r.expectedScope.cardId)
303
- throw new Error(
304
- `resolvedFormats.${t}.scope must match the executing dashboard/card`
305
- );
306
- if (c.target.kind !== "column")
307
- throw new Error(
308
- `resolvedFormats.${t}.target must identify an export column`
309
- );
310
- if (e.has(c.target.columnKey))
311
- throw new Error(
312
- `resolvedFormats.${t} duplicates export column "${c.target.columnKey}"`
313
- );
314
- e.add(c.target.columnKey);
315
- }
316
- }), !r.useFormattedValues)
317
- return;
318
- if (!((a = r.visibleColumns) != null && a.length))
319
- throw new Error(
320
- "visibleColumns must identify every formatted export column"
321
- );
322
- const i = r.visibleColumns.find(
323
- (c) => !e.has(c)
324
- );
325
- if (i)
326
- throw new Error(
327
- `resolvedFormats is missing visible export column "${i}"`
328
- );
329
- }
330
- function O(r, e) {
331
- const i = new Intl.NumberFormat(r, {
332
- style: "currency",
333
- currency: e
334
- }).resolvedOptions();
335
- return {
336
- minimumFractionDigits: i.minimumFractionDigits,
337
- maximumFractionDigits: i.maximumFractionDigits
338
- };
339
- }
340
- function _(r) {
341
- if (r.minimumFractionDigits !== void 0 || r.maximumFractionDigits !== void 0) {
342
- const i = r.minimumFractionDigits ?? 0;
343
- return {
344
- minimumFractionDigits: i,
345
- maximumFractionDigits: r.maximumFractionDigits ?? Math.max(i, 2)
346
- };
347
- }
348
- const e = r.type === "percent" ? 1 : r.type === "scientific" ? 2 : 0;
349
- return {
350
- minimumFractionDigits: e,
351
- maximumFractionDigits: e
352
- };
353
- }
354
- function Q(r, e, i) {
355
- const a = F(r.locale) ?? e.locale, c = r.type === "number" || r.type === "currency" ? y(i) : void 0;
356
- if (!(r.type === "currency" || c !== void 0))
357
- return {
358
- ...r,
359
- locale: a,
360
- ..._(r)
361
- };
362
- const s = c ?? y(r.currency) ?? e.defaultCurrency, n = O(
363
- a,
364
- s
365
- ), u = n.minimumFractionDigits ?? 0, l = n.maximumFractionDigits ?? u, m = r.minimumFractionDigits ?? Math.min(
366
- u,
367
- r.maximumFractionDigits ?? u
368
- ), w = r.maximumFractionDigits ?? Math.max(
369
- m,
370
- l
371
- );
372
- return {
373
- ...r,
374
- type: "currency",
375
- locale: a,
376
- currency: s,
377
- minimumFractionDigits: m,
378
- maximumFractionDigits: w
379
- };
380
- }
381
- function f(r) {
382
- if (r === null || typeof r != "object" || Array.isArray(r))
383
- return !1;
384
- const e = Object.getPrototypeOf(r);
385
- return e === null || e === Object.prototype;
386
- }
387
- function g(r, e, i) {
388
- const a = new Set(e), c = Object.keys(r).find((t) => !a.has(t));
389
- if (c)
390
- throw new Error(`${i} contains unknown property "${c}"`);
391
- }
392
- function T(r, e = "scope") {
393
- if (!f(r))
394
- throw new Error(`${e} must be an object`);
395
- g(
396
- r,
397
- ["dashboardId", "cardId", "attachmentIndex"],
398
- e
399
- );
400
- const i = typeof r.dashboardId == "string" ? r.dashboardId.trim() : "";
401
- if (!i)
402
- throw new Error(`${e}.dashboardId is required`);
403
- const a = typeof r.cardId == "string" ? r.cardId.trim() : void 0;
404
- if (r.cardId !== void 0 && !a)
405
- throw new Error(`${e}.cardId must be a non-empty string`);
406
- const c = r.attachmentIndex;
407
- if (c !== void 0 && (typeof c != "number" || !Number.isInteger(c) || c < 0))
408
- throw new Error(
409
- `${e}.attachmentIndex must be a non-negative integer`
410
- );
411
- return {
412
- dashboardId: i,
413
- ...a ? { cardId: a } : {},
414
- ...typeof c == "number" ? { attachmentIndex: c } : {}
415
- };
416
- }
417
- function o(r, e, i, a) {
418
- if (r.kind !== e) return;
419
- g(r, ["kind", i], a);
420
- const c = typeof r[i] == "string" ? r[i].trim() : "";
421
- if (!c)
422
- throw new Error(`${a}.${i} is required`);
423
- return c;
424
- }
425
- function B(r, e) {
426
- if (!f(r))
427
- throw new Error(`${e} must be an object`);
428
- const i = o(r, "metric", "metricId", e);
429
- if (i) return { kind: "metric", metricId: i };
430
- const a = o(r, "column", "columnKey", e);
431
- if (a) return { kind: "column", columnKey: a };
432
- const c = o(
433
- r,
434
- "matrix_measure",
435
- "measureId",
436
- e
437
- );
438
- if (c) return { kind: "matrix_measure", measureId: c };
439
- throw new Error(`${e} is not a valid numeric presentation target`);
440
- }
441
- function U(r, e) {
442
- if (!f(r))
443
- throw new Error(`${e} must be an object`);
444
- if (r.kind === "field") {
445
- g(r, ["kind", "fieldId", "role"], e);
446
- const c = typeof r.fieldId == "string" ? r.fieldId.trim() : "";
447
- if (!c)
448
- throw new Error(`${e}.fieldId is required`);
449
- const t = r.role;
450
- if (t !== void 0 && t !== "groupby" && t !== "pivotby")
451
- throw new Error(`${e}.role must be groupby or pivotby`);
452
- return {
453
- kind: "field",
454
- fieldId: c,
455
- ...t ? { role: t } : {}
456
- };
457
- }
458
- const i = o(r, "column", "columnKey", e);
459
- if (i) return { kind: "column", columnKey: i };
460
- const a = o(
461
- r,
462
- "matrix_axis",
463
- "axisInstanceId",
464
- e
465
- );
466
- if (a) return { kind: "matrix_axis", axisInstanceId: a };
467
- throw new Error(`${e} is not a valid temporal bucket presentation target`);
468
- }
469
- function q(r) {
470
- return [
471
- r.dashboardId,
472
- r.cardId ?? null,
473
- r.attachmentIndex ?? null
474
- ];
475
- }
476
- function x(r) {
477
- switch (r.kind) {
478
- case "metric":
479
- return [r.kind, r.metricId];
480
- case "column":
481
- return [r.kind, r.columnKey];
482
- case "matrix_measure":
483
- return [r.kind, r.measureId];
484
- case "field":
485
- return [r.kind, r.fieldId, r.role ?? ""];
486
- case "matrix_axis":
487
- return [r.kind, r.axisInstanceId];
488
- }
489
- }
490
- function N(r, e) {
491
- return r.dashboardId === e.dashboardId && r.cardId === e.cardId && r.attachmentIndex === e.attachmentIndex;
492
- }
493
- function b(r, e) {
494
- const i = x(r), a = x(e);
495
- return i.length === a.length && i.every((c, t) => c === a[t]);
496
- }
497
- function A(r) {
498
- if (!Array.isArray(r))
499
- throw new Error("resolvedFormats must be an array");
500
- const e = /* @__PURE__ */ new Set();
501
- return r.map((i, a) => {
502
- var u, l;
503
- const c = `resolvedFormats.${a}`;
504
- if (!f(i))
505
- throw new Error(`${c} must be an object`);
506
- g(i, ["scope", "target", "format"], c);
507
- const t = T(i.scope, `${c}.scope`);
508
- if (!f(i.format))
509
- throw new Error(`${c}.format must be an object`);
510
- let s;
511
- if (i.format.type === "temporal_bucket") {
512
- const m = M(i.format);
513
- if (!m.ok)
514
- throw new Error(
515
- `${c}.format is invalid: ${((u = m.issues[0]) == null ? void 0 : u.message) ?? "invalid value"}`
516
- );
517
- s = {
518
- scope: t,
519
- target: U(i.target, `${c}.target`),
520
- format: m.value
521
- };
522
- } else {
523
- const m = R(i.format);
524
- if (!m.ok)
525
- throw new Error(
526
- `${c}.format is invalid: ${((l = m.issues[0]) == null ? void 0 : l.message) ?? "invalid value"}`
527
- );
528
- s = {
529
- scope: t,
530
- target: B(i.target, `${c}.target`),
531
- format: m.value
532
- };
533
- }
534
- const n = JSON.stringify([
535
- ...q(s.scope),
536
- ...x(s.target)
537
- ]);
538
- if (e.has(n))
539
- throw new Error(
540
- `${c} duplicates a scoped presentation target`
541
- );
542
- return e.add(n), s;
543
- });
544
- }
545
- function X(r) {
546
- if (!f(r))
547
- throw new Error("presentation execution snapshot must be an object");
548
- g(
549
- r,
550
- ["reportContext", "resolvedFormats"],
551
- "presentation execution snapshot"
552
- );
553
- const e = C(r.reportContext);
554
- if (!e.ok) {
555
- const i = e.issues[0];
556
- throw new Error(
557
- `presentation execution snapshot reportContext is invalid: ${i != null && i.path && i.path !== "$" ? `${i.path}: ` : ""}${(i == null ? void 0 : i.message) ?? "invalid value"}`
558
- );
559
- }
560
- return {
561
- reportContext: e.value,
562
- resolvedFormats: A(r.resolvedFormats)
563
- };
564
- }
565
- function Z(r) {
566
- const e = r.snapshot.resolvedFormats.find(
567
- (i) => i.format.type !== "temporal_bucket" && N(i.scope, r.scope) && b(i.target, r.target)
568
- );
569
- return e == null ? void 0 : e.format;
570
- }
571
- function p(r) {
572
- const e = r.snapshot.resolvedFormats.find(
573
- (i) => i.format.type === "temporal_bucket" && N(i.scope, r.scope) && b(i.target, r.target)
574
- );
575
- return e == null ? void 0 : e.format;
576
- }
577
- function ee(r) {
578
- var c;
579
- const e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
580
- if (r.snapshot.resolvedFormats.forEach((t, s) => {
581
- if (t.scope.attachmentIndex !== void 0)
582
- throw new Error(
583
- `resolvedFormats.${s}.scope.attachmentIndex is not valid for a card export`
584
- );
585
- if (t.scope.dashboardId !== r.expectedScope.dashboardId || t.scope.cardId !== r.expectedScope.cardId)
586
- throw new Error(
587
- `resolvedFormats.${s}.scope must match the executing dashboard/card`
588
- );
589
- if (t.target.kind === "field" && t.format.type === "temporal_bucket") {
590
- const n = JSON.stringify(x(t.target));
591
- if (i.has(n))
592
- throw new Error(
593
- `resolvedFormats.${s} duplicates export field "${t.target.fieldId}"`
594
- );
595
- i.add(n);
596
- return;
597
- }
598
- if (t.target.kind !== "column")
599
- throw new Error(
600
- `resolvedFormats.${s}.target must identify an export column or temporal pivot field`
601
- );
602
- if (e.has(t.target.columnKey))
603
- throw new Error(
604
- `resolvedFormats.${s} duplicates export column "${t.target.columnKey}"`
605
- );
606
- e.add(t.target.columnKey);
607
- }), !r.useFormattedValues) return;
608
- if (!((c = r.visibleColumns) != null && c.length))
609
- throw new Error("visibleColumns must identify every formatted export column");
610
- const a = r.visibleColumns.find(
611
- (t) => !e.has(t)
612
- );
613
- if (a)
614
- throw new Error(
615
- `resolvedFormats is missing visible export column "${a}"`
616
- );
617
- }
618
- export {
619
- Z as a,
620
- G as b,
621
- v as c,
622
- k as d,
623
- S as e,
624
- J as f,
625
- E as g,
626
- Y as h,
627
- R as i,
628
- Q as j,
629
- T as k,
630
- A as l,
631
- X as m,
632
- p as n,
633
- ee as o,
634
- K as p,
635
- O as r,
636
- H as v
637
- };