react-semaphor 0.1.498 → 0.1.499

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 (119) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +22 -22
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +5 -5
  7. package/dist/chunks/{calculated-field-identity-BGIPbwBx.js → calculated-field-identity-BC2NViZZ.js} +73 -63
  8. package/dist/chunks/{calculated-field-identity-CEzmY7Bi.cjs → calculated-field-identity-CtYhhZoG.cjs} +1 -1
  9. package/dist/chunks/{constants-CKoIADZx.js → constants-CTRduy1g.js} +9 -9
  10. package/dist/chunks/{constants-CpBVuEea.cjs → constants-DNgpRMaX.cjs} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-C8eAX-JN.js → dashboard-briefing-launcher-Bp6SBVb6.js} +9 -9
  12. package/dist/chunks/{dashboard-briefing-launcher-BEmyxEd8.cjs → dashboard-briefing-launcher-Dtzn9Tqg.cjs} +1 -1
  13. package/dist/chunks/{dashboard-controls-YvJe7cPL.cjs → dashboard-controls-CLw5VQ2x.cjs} +1 -1
  14. package/dist/chunks/{dashboard-controls-C_v7sbq4.js → dashboard-controls-DDI3atQf.js} +11 -11
  15. package/dist/chunks/{dashboard-date-comparison-definition-aANgeL-E.js → dashboard-date-comparison-definition-C1vJshiP.js} +6 -6
  16. package/dist/chunks/{dashboard-date-comparison-definition-Er8D33iq.cjs → dashboard-date-comparison-definition-CWz_Yte8.cjs} +1 -1
  17. package/dist/chunks/{dashboard-json-CSp5bXIV.cjs → dashboard-json-BnT6W7Lt.cjs} +1 -1
  18. package/dist/chunks/{dashboard-json-BaT3Yy8x.js → dashboard-json-rHLrTBbN.js} +7 -7
  19. package/dist/chunks/{edit-dashboard-visual-GWiW0jjy.js → edit-dashboard-visual-BH2LkjHV.js} +6858 -6893
  20. package/dist/chunks/edit-dashboard-visual-DqAMe8XW.cjs +172 -0
  21. package/dist/chunks/{editor-action-buttons-BSC0nwgV.cjs → editor-action-buttons-Boq8MLya.cjs} +1 -1
  22. package/dist/chunks/{editor-action-buttons-CfZITZwQ.js → editor-action-buttons-DUEK2-kM.js} +6 -6
  23. package/dist/chunks/{field-aggregations-DLWbqnBW.cjs → field-aggregations-mlkON_QA.cjs} +1 -1
  24. package/dist/chunks/{field-aggregations-CxJWY4Ny.js → field-aggregations-tLaXZ2VJ.js} +13 -13
  25. package/dist/chunks/{field-dependencies-BiyQuGxZ.cjs → field-dependencies-R7MrlW6D.cjs} +1 -1
  26. package/dist/chunks/{field-dependencies-CNOgt39w.js → field-dependencies-ZE2klbHO.js} +1 -1
  27. package/dist/chunks/{index-BJfUMDHc.js → index-BVIet238.js} +42 -42
  28. package/dist/chunks/{index-C3RHKD3d.cjs → index-Bh3SlWJS.cjs} +1 -1
  29. package/dist/chunks/{index-DjbQVfS6.js → index-CEm8bwwd.js} +26924 -26927
  30. package/dist/chunks/{index-DhBGtRkR.cjs → index-Gos2ij10.cjs} +219 -219
  31. package/dist/chunks/{matrix-analytical-definition-s10yOPft.js → matrix-analytical-definition-CIVFNNnF.js} +1 -1
  32. package/dist/chunks/{matrix-analytical-definition-DbaMwlWM.cjs → matrix-analytical-definition-wIEDXvV5.cjs} +1 -1
  33. package/dist/chunks/{matrix-card-DGpXdK_Y.js → matrix-card-BVvKHL7s.js} +2 -2
  34. package/dist/chunks/{matrix-card-BitrcBVw.cjs → matrix-card-Dh0J0_Of.cjs} +1 -1
  35. package/dist/chunks/matrix-control-sources-CjnsBREg.js +605 -0
  36. package/dist/chunks/matrix-control-sources-a67fwoOO.cjs +1 -0
  37. package/dist/chunks/{matrix-definition-AP5W3wGc.js → matrix-definition-BEXCfZAe.js} +3 -3
  38. package/dist/chunks/{matrix-definition-C33isJ3k.cjs → matrix-definition-CKVi4VVg.cjs} +1 -1
  39. package/dist/chunks/{matrix-formatter-CZYFhdZ0.js → matrix-formatter-BTPfthsa.js} +41 -41
  40. package/dist/chunks/{matrix-formatter-UCXQxvV3.cjs → matrix-formatter-CWtdnbfv.cjs} +1 -1
  41. package/dist/chunks/{matrix-member-presentation-5-M0obIa.js → matrix-member-presentation-DiDUvZts.js} +1 -1
  42. package/dist/chunks/{matrix-member-presentation-DgIq9UG9.cjs → matrix-member-presentation-e_KZoZOx.cjs} +1 -1
  43. package/dist/chunks/{matrix-operation-contract-BFumahBa.js → matrix-operation-contract-CPgckXxm.js} +144 -144
  44. package/dist/chunks/{matrix-operation-contract-C0-V685e.cjs → matrix-operation-contract-thtFuUYf.cjs} +1 -1
  45. package/dist/chunks/{metric-comparison-ClKUI7Tu.cjs → metric-comparison-CAqV6VnZ.cjs} +1 -1
  46. package/dist/chunks/{metric-comparison-Df3HmmUE.js → metric-comparison-Dgyq1I3d.js} +1 -1
  47. package/dist/chunks/{pivot-header-presentation-CGWDx1V_.cjs → pivot-header-presentation-DUXM-VOP.cjs} +1 -1
  48. package/dist/chunks/{pivot-header-presentation-CAmKYLgn.js → pivot-header-presentation-DcCO8-Ij.js} +3 -3
  49. package/dist/chunks/{pivot-result-identity-DBeK76wx.js → pivot-result-identity-Be1zm0AV.js} +1 -1
  50. package/dist/chunks/{pivot-result-identity-0grcK7bY.cjs → pivot-result-identity-DJyF4I2K.cjs} +1 -1
  51. package/dist/chunks/{pivot-result-lifecycle-DVPJg7Gg.js → pivot-result-lifecycle-DpSZOMOZ.js} +7 -7
  52. package/dist/chunks/{pivot-result-lifecycle-CC0jWMFT.cjs → pivot-result-lifecycle-E_huAPev.cjs} +1 -1
  53. package/dist/chunks/{raw-temporal-Kc3mdzH7.cjs → raw-temporal-DYoPBY6B.cjs} +1 -1
  54. package/dist/chunks/{raw-temporal-T3PEaGmJ.js → raw-temporal-DfnRBxQn.js} +2 -2
  55. package/dist/chunks/{raw-temporal-contract-Ck5vJoQ6.js → raw-temporal-contract-CNwYygW2.js} +1 -1
  56. package/dist/chunks/{raw-temporal-contract-SwtP1jSh.cjs → raw-temporal-contract-D1_n2pBj.cjs} +1 -1
  57. package/dist/chunks/{report-preferences-dialog-B8DdDM7q.js → report-preferences-dialog-8nfXNWvl.js} +6 -6
  58. package/dist/chunks/{report-preferences-dialog-BcaEOgn2.cjs → report-preferences-dialog-CW59SyVZ.cjs} +1 -1
  59. package/dist/chunks/{report-runtime-context-D3t8vyl9.cjs → report-runtime-context-CqFbgZq9.cjs} +1 -1
  60. package/dist/chunks/{report-runtime-context-BziN1eg9.js → report-runtime-context-Dln1qvGS.js} +5 -5
  61. package/dist/chunks/{semantic-format-Ca-sdETk.cjs → semantic-format-C7Goni6h.cjs} +1 -1
  62. package/dist/chunks/{semantic-format-A3k--fpE.js → semantic-format-PKQt2EAz.js} +2 -2
  63. package/dist/chunks/{source-entity-resolution-CTUzMH2S.cjs → source-entity-resolution-BMKxwdKN.cjs} +1 -1
  64. package/dist/chunks/{source-entity-resolution-DX9C1ebK.js → source-entity-resolution-BSZ07Sl6.js} +19 -19
  65. package/dist/chunks/{switch-DV8zX7rV.js → switch-B4wVqV4L.js} +51 -50
  66. package/dist/chunks/{switch-CgycqpWv.cjs → switch-DVjKkt22.cjs} +12 -12
  67. package/dist/chunks/{temporal-bucket-contract-BBdvWsY0.cjs → temporal-bucket-contract-CSdspcYj.cjs} +1 -1
  68. package/dist/chunks/{temporal-bucket-contract-lq7Jrif0.js → temporal-bucket-contract-_WCvDnvn.js} +1 -1
  69. package/dist/chunks/{update-policy-DIw_H9RT.cjs → update-policy-BESKAspa.cjs} +1 -1
  70. package/dist/chunks/{update-policy-EgZ1nRbd.js → update-policy-BWbXhkk-.js} +2 -2
  71. package/dist/chunks/{validators-CvLOGzT3.js → validators-CHlnnHuS.js} +1102 -1043
  72. package/dist/chunks/validators-D2F_uxxP.cjs +1 -0
  73. package/dist/dashboard/index.cjs +1 -1
  74. package/dist/dashboard/index.js +1 -1
  75. package/dist/dashboard-authoring/index.cjs +3 -3
  76. package/dist/dashboard-authoring/index.js +112 -107
  77. package/dist/data-app-builder/index.cjs +1 -1
  78. package/dist/data-app-builder/index.js +2 -2
  79. package/dist/data-app-codegen/index.cjs +1 -1
  80. package/dist/data-app-codegen/index.js +2 -2
  81. package/dist/data-app-codegen-node/index.cjs +1 -1
  82. package/dist/data-app-codegen-node/index.js +3 -3
  83. package/dist/data-app-sdk/index.cjs +1 -1
  84. package/dist/data-app-sdk/index.js +4 -4
  85. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  86. package/dist/data-app-sdk-adapters/index.js +2 -2
  87. package/dist/data-app-sdk-validation/index.cjs +1 -1
  88. package/dist/data-app-sdk-validation/index.js +5 -5
  89. package/dist/format-utils/index.cjs +1 -1
  90. package/dist/format-utils/index.js +16 -16
  91. package/dist/index.cjs +1 -1
  92. package/dist/index.js +81 -78
  93. package/dist/report-runtime-context/index.cjs +1 -1
  94. package/dist/report-runtime-context/index.js +2 -2
  95. package/dist/surfboard/index.cjs +1 -1
  96. package/dist/surfboard/index.js +2 -2
  97. package/dist/types/analytics-protocol.d.ts +15 -0
  98. package/dist/types/briefings.d.ts +16 -1
  99. package/dist/types/dashboard-assistant.d.ts +15 -0
  100. package/dist/types/dashboard-authoring.d.ts +49 -1
  101. package/dist/types/dashboard.d.ts +23 -1
  102. package/dist/types/data-app-builder.d.ts +15 -0
  103. package/dist/types/data-app-codegen-node.d.ts +15 -0
  104. package/dist/types/data-app-codegen.d.ts +15 -0
  105. package/dist/types/data-app-sdk-adapters.d.ts +15 -0
  106. package/dist/types/data-app-sdk-validation.d.ts +15 -0
  107. package/dist/types/data-app-sdk.d.ts +15 -0
  108. package/dist/types/format-utils.d.ts +15 -0
  109. package/dist/types/index.cjs +1 -1
  110. package/dist/types/index.js +30 -27
  111. package/dist/types/main.d.ts +67 -8
  112. package/dist/types/shared.d.ts +16 -1
  113. package/dist/types/surfboard.d.ts +23 -1
  114. package/dist/types/types.d.ts +67 -8
  115. package/package.json +1 -1
  116. package/dist/chunks/edit-dashboard-visual-_Wap0YGu.cjs +0 -172
  117. package/dist/chunks/matrix-control-sources-DdfST7Fo.cjs +0 -1
  118. package/dist/chunks/matrix-control-sources-Dxh6hOU9.js +0 -523
  119. package/dist/chunks/validators-mhiJSia7.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";var ce=Object.defineProperty;var le=(t,e,n)=>e in t?ce(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var M=(t,e,n)=>le(t,typeof e!="symbol"?e+"":e,n);const S=require("./common-types-nBuCd3u2.cjs"),R=require("./validators-mhiJSia7.cjs");require("./matrix-operation-contract-C0-V685e.cjs");const Y=require("./calculated-field-identity-CEzmY7Bi.cjs"),de=require("./field-aggregations-DLWbqnBW.cjs"),ue=require("zod"),Z=require("./matrix-card-BitrcBVw.cjs"),V=require("./constants-B00YUv89.cjs");function X(t,e){const r=Ie(t);let i;if(r.date){const d=Oe(r.date,2);i=Ne(d.restDateString,d.year)}if(!i||isNaN(i.getTime()))return new Date(NaN);const s=i.getTime();let f=0,_;if(r.time&&(f=Re(r.time),isNaN(f)))return new Date(NaN);if(r.timezone){if(_=De(r.timezone),isNaN(_))return new Date(NaN)}else{const d=new Date(s+f),m=new Date(0);return m.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),m.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),m}return new Date(s+f+_)}const w={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ge=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,fe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,_e=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ie(t){const e={},n=t.split(w.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],w.timeZoneDelimiter.test(e.date)&&(e.date=t.split(w.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const i=w.timezone.exec(r);i?(e.time=r.replace(i[1],""),e.timezone=i[1]):e.time=r}return e}function Oe(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?i:s*100,restDateString:t.slice((r[1]||r[2]).length)}}function Ne(t,e){if(e===null)return new Date(NaN);const n=t.match(ge);if(!n)return new Date(NaN);const r=!!n[4],i=L(n[1]),s=L(n[2])-1,f=L(n[3]),_=L(n[4]),d=L(n[5])-1;if(r)return pe(e,_,d)?me(e,_,d):new Date(NaN);{const m=new Date(0);return!Te(e,s,f)||!Ce(e,i)?new Date(NaN):(m.setUTCFullYear(e,s,Math.max(i,f)),m)}}function L(t){return t?parseInt(t):1}function Re(t){const e=t.match(fe);if(!e)return NaN;const n=v(e[1]),r=v(e[2]),i=v(e[3]);return he(n,r,i)?n*V.millisecondsInHour+r*V.millisecondsInMinute+i*1e3:NaN}function v(t){return t&&parseFloat(t.replace(",","."))||0}function De(t){if(t==="Z")return 0;const e=t.match(_e);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),i=e[3]&&parseInt(e[3])||0;return Ae(r,i)?n*(r*V.millisecondsInHour+i*V.millisecondsInMinute):NaN}function me(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const i=r.getUTCDay()||7,s=(e-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+s),r}const Ee=[31,null,31,30,31,30,31,31,30,31,30,31];function W(t){return t%400===0||t%4===0&&t%100!==0}function Te(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(Ee[e]||(W(t)?29:28))}function Ce(t,e){return e>=1&&e<=(W(t)?366:365)}function pe(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function he(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function Ae(t,e){return e>=0&&e<=59}const ye=["lg","md","sm","xs","xxs"],Le=15;function we(t,e){return`${t}-${e}`}const Se="CONTROL_PLACEHOLDER_QUOTED",Q="CONTROL_REFERENCE_MISSING",K="CONTROL_VALUE_MISSING",Ve="CONTROL_VALUE_INVALID",xe="CONTROL_CONTEXT_UNSUPPORTED",J="CONTROL_DEFINITION_DUPLICATE",ee="CONTROL_DEFINITION_INVALID",x="CONTROL_BINDING_MAPPING_MISSING",te="CONTROL_BINDING_TARGET_INVALID",U="CONTROL_BINDING_VALUE_INVALID";class I extends Error{constructor(n,r){super(n);M(this,"status",400);M(this,"details");Object.setPrototypeOf(this,I.prototype),this.name="ControlResolutionError",this.details=r}}function G(t,e){const n=new Map;for(const r of[...t,...e]){if(!r||typeof r!="object"||typeof r.id!="string"||r.id.trim().length===0)throw new I("Malformed control definition was provided for query execution.",{code:ee});if(n.get(r.id))throw new I(`Duplicate control definition '${r.id}' was provided for query execution.`,{code:J,controlId:r.id});n.set(r.id,r)}return n}const be=/^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;function Me(t){switch(t.source.kind){case"manual":return t.source.options.map(e=>e.value);case"field_allowlist":return t.source.fieldIds;case"metric_allowlist":return t.source.metricIds;case"dataset_values":return null;default:return null}}function E(t){return`${t.label||t.id} (${t.id})`}function ve(t){return t.type==="field_selector"||t.type==="metric_selector"||t.type==="aggregation_selector"||t.type==="grain_selector"}function j(t,e){const n=Me(t);if(!(!n||n.length===0)&&!n.includes(e))throw new Error(`Control ${E(t)} received unsupported value '${e}'.`)}function re(t,e){switch(t.type){case"enum":case"field_selector":case"metric_selector":case"aggregation_selector":case"grain_selector":{if(typeof e!="string"||e.trim().length===0)throw new Error(`Control ${E(t)} requires a non-empty string value.`);return ve(t)&&e===S.CONTROL_CARD_DEFAULT_VALUE||j(t,e),e}case"multi_enum":{if(!Array.isArray(e))throw new Error(`Control ${E(t)} requires a non-empty array value.`);if(e.length===0){if(!t.requiredAtExecution)return;throw new Error(`Control ${E(t)} requires a non-empty array value.`)}for(const n of e){if(typeof n!="string"||n.trim().length===0)throw new Error(`Control ${E(t)} requires string array values.`);j(t,n)}return e}case"text":{if(typeof e!="string")throw new Error(`Control ${E(t)} requires a string value.`);return e}case"number":{if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&be.test(e.trim()))return Number(e);throw new Error(`Control ${E(t)} requires a numeric value.`)}case"boolean":{if(typeof e!="boolean")throw new Error(`Control ${E(t)} requires a boolean value.`);return e}case"date":{if(e instanceof Date&&!Number.isNaN(e.getTime()))return e;if(typeof e=="string"&&e.trim().length>0){const n=e.trim(),r=X(n);if(!Number.isNaN(r.getTime()))return n}throw new Error(`Control ${E(t)} requires a date-compatible value.`)}default:return e}}function $(t){var i;const e=t.definitions.get(t.binding.controlId);if(!e)throw new I(`Binding references unknown control '${t.binding.controlId}'.`,{code:Q,controlId:t.binding.controlId});if(!Object.prototype.hasOwnProperty.call(t.controlValues||{},t.binding.controlId)){if(!e.requiredAtExecution)return;throw new I(`Control '${t.binding.controlId}' must resolve to a concrete value before query execution.`,{code:K,controlId:t.binding.controlId})}let r;try{r=re(e,(i=t.controlValues)==null?void 0:i[t.binding.controlId])}catch(s){const f=s instanceof Error?s.message:String(s);throw new I(f,{code:U,controlId:t.binding.controlId})}if(typeof r=="string"&&r.trim().length>0)return r;if(typeof r=="number"||typeof r=="boolean")return String(r);if(r instanceof Date&&!Number.isNaN(r.getTime()))return r.toISOString();throw new I(`Binding control '${t.binding.controlId}' must resolve to a single scalar value.`,{code:U,controlId:t.binding.controlId})}function F(t){const e=t.binding.mapping[t.selectedValue];if(typeof e=="string"&&e.trim().length>0)return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}'.`,{code:x,controlId:t.binding.controlId})}function ne(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="groupby")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid group-by field.`,{code:x,controlId:t.binding.controlId})}function oe(t){const e=t.binding.mapping[t.selectedValue];if(e&&typeof e=="object"&&"role"in e&&e.role==="metric")return e;throw new I(`Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid metric field.`,{code:x,controlId:t.binding.controlId})}const Ue=new Set(["day","week","month","quarter","year","hour","minute","second"]);function Fe(t){let e=t.spec;const n=G(t.controlDefinitions||[],t.cardControlDefinitions||[]),r=(t.controlBindings||[]).filter(o=>o.target!=="sql_param"),i=r.filter(o=>o.target==="config_metric_selector"||o.target==="config_field_selector"),s=r.filter(o=>o.target==="config_grain"||o.target==="config_aggregation"),f=new Set,_=new Map;let d;const m=()=>{if(d)return d;const o=t.catalog,c=new Map;for(const l of o){const u=c.get(l.id)??[];c.set(l.id,[...u,l])}return d={refs:o,byId:c},d},h=(o,c)=>{throw new I(o,{code:te,...c?{controlId:c}:{}})},b=(o,c)=>{var u;if(o.derivedField)return o.derivedField.dataType;const l=m().refs.filter(C=>C.field.name===o.name&&R.semaphorSourcesReferToSameDataset(C.field.source??t.spec.source,o.source??t.spec.source));return l.length>1?h("The selected field is ambiguous in the authorized Matrix field catalog.",c):R.normalizeAnalyticsCatalogDataType(((u=l[0])==null?void 0:u.field.dataType)??o.dataType)},B=(o,c)=>Y.getMatrixBindingTargets(o,c.target,l=>b(l,c.controlId)),T=R.matrixSpecSchema.safeParse(e);if(!T.success)return h(T.error.message);e=T.data;const se=[...i,...s].map(o=>{const c=$({binding:o,definitions:n,controlValues:t.controlValues}),l=!o.matrixTargetId&&c!==void 0&&c!==S.CONTROL_CARD_DEFAULT_VALUE?B(T.data,o):[];return{binding:o,selectedValue:c,targetId:o.matrixTargetId??(l.length===1?l[0].id:void 0)}});for(const{binding:o,targetId:c,selectedValue:l}of se){if(l===void 0||l===S.CONTROL_CARD_DEFAULT_VALUE)continue;const u=a=>h(a,o.controlId),C=o.target==="config_metric_selector"||o.target==="config_aggregation",ae=B(e,o);(!c||!ae.some(a=>a.id===c))&&u("Choose a valid Matrix level or measure target for this control.");const P=`${o.target}:${c}`;f.has(P)&&u("Multiple controls cannot replace the same Matrix target."),f.add(P);const q=a=>{const g=(m().byId.get(a.id)??[]).filter(N=>!a.source||R.semaphorSourcesReferToSameDataset(a.source,N.field.source??t.spec.source));if(g.length!==1)return u(g.length?"The selected field is ambiguous in the authorized Matrix field catalog.":"The selected field is not in the authorized Matrix field catalog.");const D=R.matrixFieldSchema.safeParse(g[0].field);return D.success?D.data:u(D.error.message)},A=o.target==="config_metric_selector"||o.target==="config_field_selector"?o.mapping[l]:void 0,p=A&&typeof A=="object"&&"kind"in A&&A.kind==="matrix_instance"?A.id:void 0;if(C){_.set(c,o.controlId);const a=p===void 0?void 0:T.data.measures.find(O=>O.id===p&&O.kind==="aggregate");p!==void 0&&!a&&u("The selected Matrix aggregate measure is no longer available.");const g=o.target==="config_metric_selector"&&!a?oe({binding:o,selectedValue:l}):void 0,D=((a==null?void 0:a.kind)==="aggregate"?a.aggregate:g==null?void 0:g.aggregate)??(o.target==="config_aggregation"?F({binding:o,selectedValue:l}):void 0),N=D===void 0?void 0:R.matrixAggregateSchema.safeParse(D);N&&!N.success&&u("This aggregation is not supported by Matrix."),e={...e,measures:e.measures.map(O=>O.id!==c||O.kind!=="aggregate"?O:{...O,...g?{field:q(g)}:{},...(a==null?void 0:a.kind)==="aggregate"?{field:a.field}:{},aggregate:N!=null&&N.success?N.data:O.aggregate})}}else{const a=p===void 0?void 0:[...T.data.rows,...T.data.columns].find(O=>O.id===p);p!==void 0&&!a&&u("The selected Matrix level is no longer available.");const g=o.target==="config_field_selector"&&!a?ne({binding:o,selectedValue:l}):void 0,D=o.target==="config_grain"?F({binding:o,selectedValue:l}):a?a.grain:g==null?void 0:g.granularity;D!==void 0&&!Ue.has(D)&&u("This time grain is not supported by Matrix.");const N=O=>O.map(y=>{if(y.id!==c)return y;const k=(a==null?void 0:a.field)??(g?q(g):y.field),H=b(k,o.controlId),z=D??(g&&R.isAnalyticsDateLikeDataType(H)?y.grain:void 0);return z&&!R.isAnalyticsDateLikeDataType(H)&&u("A time grain requires a temporal Matrix level."),{...y,field:k,grain:z}});e={...e,rows:N(e.rows),columns:N(e.columns)}}}for(const[o,c]of Array.from(_)){const l=e.measures.find(C=>C.id===o);if(!l||l.kind!=="aggregate")continue;const u=b(l.field,c);de.getFieldAggregationOptions(u).some(C=>C.value===l.aggregate)||h(`Aggregation '${l.aggregate}' is not eligible for this Matrix field datatype.`,c)}try{return Y.reconcileMatrixSpecStructure(T.data,e)}catch(o){if(o instanceof ue.ZodError)return h(o.message);throw o}}function ie(t,e){const n=[],r=i=>{if(i.source){const s=R.configSourceRefSchema.safeParse(i.source);if(s.success)n.push(s.data);else if(e)throw s.error}i.derivedField&&Object.values(i.derivedField.inputs).forEach(s=>r(s.field))};for(const i of t){if(i.target!=="config_field_selector"&&i.target!=="config_metric_selector")continue;const s=e==null?void 0:e.get(i),f=e?s&&s!==S.CONTROL_CARD_DEFAULT_VALUE?[i.mapping[s]]:[]:Object.values(i.mapping);for(const _ of f)_&&"role"in _&&r(_)}return n}function Ge(t,e=[],n=[]){return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(e),...n])}function $e(t,e={}){const n=e.controlBindings??[],r=G(e.controlDefinitions??[],e.cardControlDefinitions??[]),i=new Map(n.filter(s=>s.target==="config_field_selector"||s.target==="config_metric_selector").map(s=>[s,$({binding:s,definitions:r,controlValues:e.controlValues})]));return R.mergeSemaphorSourcesByIdentity([...Z.matrixDefinitionSources(t),...ie(n,i)])}exports.CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE=x;exports.CONTROL_BINDING_TARGET_INVALID_ERROR_CODE=te;exports.CONTROL_BINDING_VALUE_INVALID_ERROR_CODE=U;exports.CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE=xe;exports.CONTROL_DEFINITION_DUPLICATE_ERROR_CODE=J;exports.CONTROL_DEFINITION_INVALID_ERROR_CODE=ee;exports.CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE=Se;exports.CONTROL_REFERENCE_MISSING_ERROR_CODE=Q;exports.CONTROL_VALUE_INVALID_ERROR_CODE=Ve;exports.CONTROL_VALUE_MISSING_ERROR_CODE=K;exports.ControlResolutionError=I;exports.DASHBOARD_AUTHORING_BREAKPOINTS=ye;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=Le;exports.buildControlDefinitionIndex=G;exports.getColumnCatalogFieldId=we;exports.matrixCatalogSources=Ge;exports.matrixExecutionSources=$e;exports.parseISO=X;exports.resolveBindingControlValue=$;exports.resolveGroupByFieldTarget=ne;exports.resolveMatrixControlBindings=Fe;exports.resolveMetricFieldTarget=oe;exports.resolveScalarMappedValue=F;exports.validateControlValue=re;
@@ -1,523 +0,0 @@
1
- var te = Object.defineProperty;
2
- var re = (t, e, n) => e in t ? te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var x = (t, e, n) => re(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { C as A } from "./common-types-C6cAQgyh.js";
5
- import { O as ne, A as oe, aX as B, B as ie, aj as P, ah as se, q as j, Y as ae } from "./validators-CvLOGzT3.js";
6
- import "./matrix-operation-contract-BFumahBa.js";
7
- import { g as ce, r as le } from "./calculated-field-identity-BGIPbwBx.js";
8
- import { g as de } from "./field-aggregations-CxJWY4Ny.js";
9
- import { ZodError as ue } from "zod";
10
- import { a as Y } from "./matrix-card-DGpXdK_Y.js";
11
- import { m as H, a as Z } from "./constants-DeLIHVAW.js";
12
- function ge(t, e) {
13
- const r = Ie(t);
14
- let i;
15
- if (r.date) {
16
- const d = pe(r.date, 2);
17
- i = Ne(d.restDateString, d.year);
18
- }
19
- if (!i || isNaN(i.getTime()))
20
- return /* @__PURE__ */ new Date(NaN);
21
- const s = i.getTime();
22
- let f = 0, m;
23
- if (r.time && (f = De(r.time), isNaN(f)))
24
- return /* @__PURE__ */ new Date(NaN);
25
- if (r.timezone) {
26
- if (m = Oe(r.timezone), isNaN(m))
27
- return /* @__PURE__ */ new Date(NaN);
28
- } else {
29
- const d = new Date(s + f), D = /* @__PURE__ */ new Date(0);
30
- return D.setFullYear(
31
- d.getUTCFullYear(),
32
- d.getUTCMonth(),
33
- d.getUTCDate()
34
- ), D.setHours(
35
- d.getUTCHours(),
36
- d.getUTCMinutes(),
37
- d.getUTCSeconds(),
38
- d.getUTCMilliseconds()
39
- ), D;
40
- }
41
- return new Date(s + f + m);
42
- }
43
- const b = {
44
- dateTimeDelimiter: /[T ]/,
45
- timeZoneDelimiter: /[Z ]/i,
46
- timezone: /([Z+-].*)$/
47
- }, fe = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, me = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, _e = /^([+-])(\d{2})(?::?(\d{2}))?$/;
48
- function Ie(t) {
49
- const e = {}, n = t.split(b.dateTimeDelimiter);
50
- let r;
51
- if (n.length > 2)
52
- return e;
53
- if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], b.timeZoneDelimiter.test(e.date) && (e.date = t.split(b.timeZoneDelimiter)[0], r = t.substr(
54
- e.date.length,
55
- t.length
56
- ))), r) {
57
- const i = b.timezone.exec(r);
58
- i ? (e.time = r.replace(i[1], ""), e.timezone = i[1]) : e.time = r;
59
- }
60
- return e;
61
- }
62
- function pe(t, e) {
63
- const n = new RegExp(
64
- "^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
65
- ), r = t.match(n);
66
- if (!r) return { year: NaN, restDateString: "" };
67
- const i = r[1] ? parseInt(r[1]) : null, s = r[2] ? parseInt(r[2]) : null;
68
- return {
69
- year: s === null ? i : s * 100,
70
- restDateString: t.slice((r[1] || r[2]).length)
71
- };
72
- }
73
- function Ne(t, e) {
74
- if (e === null) return /* @__PURE__ */ new Date(NaN);
75
- const n = t.match(fe);
76
- if (!n) return /* @__PURE__ */ new Date(NaN);
77
- const r = !!n[4], i = y(n[1]), s = y(n[2]) - 1, f = y(n[3]), m = y(n[4]), d = y(n[5]) - 1;
78
- if (r)
79
- return Re(e, m, d) ? Te(e, m, d) : /* @__PURE__ */ new Date(NaN);
80
- {
81
- const D = /* @__PURE__ */ new Date(0);
82
- return !Ce(e, s, f) || !Ee(e, i) ? /* @__PURE__ */ new Date(NaN) : (D.setUTCFullYear(e, s, Math.max(i, f)), D);
83
- }
84
- }
85
- function y(t) {
86
- return t ? parseInt(t) : 1;
87
- }
88
- function De(t) {
89
- const e = t.match(me);
90
- if (!e) return NaN;
91
- const n = L(e[1]), r = L(e[2]), i = L(e[3]);
92
- return we(n, r, i) ? n * H + r * Z + i * 1e3 : NaN;
93
- }
94
- function L(t) {
95
- return t && parseFloat(t.replace(",", ".")) || 0;
96
- }
97
- function Oe(t) {
98
- if (t === "Z") return 0;
99
- const e = t.match(_e);
100
- if (!e) return 0;
101
- const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
102
- return ye(r, i) ? n * (r * H + i * Z) : NaN;
103
- }
104
- function Te(t, e, n) {
105
- const r = /* @__PURE__ */ new Date(0);
106
- r.setUTCFullYear(t, 0, 4);
107
- const i = r.getUTCDay() || 7, s = (e - 1) * 7 + n + 1 - i;
108
- return r.setUTCDate(r.getUTCDate() + s), r;
109
- }
110
- const he = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
111
- function W(t) {
112
- return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
113
- }
114
- function Ce(t, e, n) {
115
- return e >= 0 && e <= 11 && n >= 1 && n <= (he[e] || (W(t) ? 29 : 28));
116
- }
117
- function Ee(t, e) {
118
- return e >= 1 && e <= (W(t) ? 366 : 365);
119
- }
120
- function Re(t, e, n) {
121
- return e >= 1 && e <= 53 && n >= 0 && n <= 6;
122
- }
123
- function we(t, e, n) {
124
- return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
125
- }
126
- function ye(t, e) {
127
- return e >= 0 && e <= 59;
128
- }
129
- const We = [
130
- "lg",
131
- "md",
132
- "sm",
133
- "xs",
134
- "xxs"
135
- ], Xe = 15;
136
- function Qe(t, e) {
137
- return `${t}-${e}`;
138
- }
139
- const Je = "CONTROL_PLACEHOLDER_QUOTED", be = "CONTROL_REFERENCE_MISSING", Ae = "CONTROL_VALUE_MISSING", Ke = "CONTROL_VALUE_INVALID", et = "CONTROL_CONTEXT_UNSUPPORTED", Se = "CONTROL_DEFINITION_DUPLICATE", xe = "CONTROL_DEFINITION_INVALID", V = "CONTROL_BINDING_MAPPING_MISSING", Le = "CONTROL_BINDING_TARGET_INVALID", k = "CONTROL_BINDING_VALUE_INVALID";
140
- class I extends Error {
141
- constructor(n, r) {
142
- super(n);
143
- x(this, "status", 400);
144
- x(this, "details");
145
- Object.setPrototypeOf(this, I.prototype), this.name = "ControlResolutionError", this.details = r;
146
- }
147
- }
148
- function X(t, e) {
149
- const n = /* @__PURE__ */ new Map();
150
- for (const r of [...t, ...e]) {
151
- if (!r || typeof r != "object" || typeof r.id != "string" || r.id.trim().length === 0)
152
- throw new I(
153
- "Malformed control definition was provided for query execution.",
154
- {
155
- code: xe
156
- }
157
- );
158
- if (n.get(r.id))
159
- throw new I(
160
- `Duplicate control definition '${r.id}' was provided for query execution.`,
161
- {
162
- code: Se,
163
- controlId: r.id
164
- }
165
- );
166
- n.set(r.id, r);
167
- }
168
- return n;
169
- }
170
- const Ve = /^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
171
- function ve(t) {
172
- switch (t.source.kind) {
173
- case "manual":
174
- return t.source.options.map((e) => e.value);
175
- case "field_allowlist":
176
- return t.source.fieldIds;
177
- case "metric_allowlist":
178
- return t.source.metricIds;
179
- case "dataset_values":
180
- return null;
181
- default:
182
- return null;
183
- }
184
- }
185
- function O(t) {
186
- return `${t.label || t.id} (${t.id})`;
187
- }
188
- function Me(t) {
189
- return t.type === "field_selector" || t.type === "metric_selector" || t.type === "aggregation_selector" || t.type === "grain_selector";
190
- }
191
- function q(t, e) {
192
- const n = ve(t);
193
- if (!(!n || n.length === 0) && !n.includes(e))
194
- throw new Error(
195
- `Control ${O(t)} received unsupported value '${e}'.`
196
- );
197
- }
198
- function Ue(t, e) {
199
- switch (t.type) {
200
- case "enum":
201
- case "field_selector":
202
- case "metric_selector":
203
- case "aggregation_selector":
204
- case "grain_selector": {
205
- if (typeof e != "string" || e.trim().length === 0)
206
- throw new Error(
207
- `Control ${O(t)} requires a non-empty string value.`
208
- );
209
- return Me(t) && e === A || q(t, e), e;
210
- }
211
- case "multi_enum": {
212
- if (!Array.isArray(e))
213
- throw new Error(
214
- `Control ${O(t)} requires a non-empty array value.`
215
- );
216
- if (e.length === 0) {
217
- if (!t.requiredAtExecution)
218
- return;
219
- throw new Error(
220
- `Control ${O(t)} requires a non-empty array value.`
221
- );
222
- }
223
- for (const n of e) {
224
- if (typeof n != "string" || n.trim().length === 0)
225
- throw new Error(
226
- `Control ${O(t)} requires string array values.`
227
- );
228
- q(t, n);
229
- }
230
- return e;
231
- }
232
- case "text": {
233
- if (typeof e != "string")
234
- throw new Error(
235
- `Control ${O(t)} requires a string value.`
236
- );
237
- return e;
238
- }
239
- case "number": {
240
- if (typeof e == "number" && Number.isFinite(e))
241
- return e;
242
- if (typeof e == "string" && Ve.test(e.trim()))
243
- return Number(e);
244
- throw new Error(
245
- `Control ${O(t)} requires a numeric value.`
246
- );
247
- }
248
- case "boolean": {
249
- if (typeof e != "boolean")
250
- throw new Error(
251
- `Control ${O(t)} requires a boolean value.`
252
- );
253
- return e;
254
- }
255
- case "date": {
256
- if (e instanceof Date && !Number.isNaN(e.getTime()))
257
- return e;
258
- if (typeof e == "string" && e.trim().length > 0) {
259
- const n = e.trim(), r = ge(n);
260
- if (!Number.isNaN(r.getTime()))
261
- return n;
262
- }
263
- throw new Error(
264
- `Control ${O(t)} requires a date-compatible value.`
265
- );
266
- }
267
- default:
268
- return e;
269
- }
270
- }
271
- function Q(t) {
272
- var i;
273
- const e = t.definitions.get(t.binding.controlId);
274
- if (!e)
275
- throw new I(
276
- `Binding references unknown control '${t.binding.controlId}'.`,
277
- {
278
- code: be,
279
- controlId: t.binding.controlId
280
- }
281
- );
282
- if (!Object.prototype.hasOwnProperty.call(
283
- t.controlValues || {},
284
- t.binding.controlId
285
- )) {
286
- if (!e.requiredAtExecution)
287
- return;
288
- throw new I(
289
- `Control '${t.binding.controlId}' must resolve to a concrete value before query execution.`,
290
- {
291
- code: Ae,
292
- controlId: t.binding.controlId
293
- }
294
- );
295
- }
296
- let r;
297
- try {
298
- r = Ue(
299
- e,
300
- (i = t.controlValues) == null ? void 0 : i[t.binding.controlId]
301
- );
302
- } catch (s) {
303
- const f = s instanceof Error ? s.message : String(s);
304
- throw new I(f, {
305
- code: k,
306
- controlId: t.binding.controlId
307
- });
308
- }
309
- if (typeof r == "string" && r.trim().length > 0)
310
- return r;
311
- if (typeof r == "number" || typeof r == "boolean")
312
- return String(r);
313
- if (r instanceof Date && !Number.isNaN(r.getTime()))
314
- return r.toISOString();
315
- throw new I(
316
- `Binding control '${t.binding.controlId}' must resolve to a single scalar value.`,
317
- {
318
- code: k,
319
- controlId: t.binding.controlId
320
- }
321
- );
322
- }
323
- function z(t) {
324
- const e = t.binding.mapping[t.selectedValue];
325
- if (typeof e == "string" && e.trim().length > 0)
326
- return e;
327
- throw new I(
328
- `Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}'.`,
329
- {
330
- code: V,
331
- controlId: t.binding.controlId
332
- }
333
- );
334
- }
335
- function $e(t) {
336
- const e = t.binding.mapping[t.selectedValue];
337
- if (e && typeof e == "object" && "role" in e && e.role === "groupby")
338
- return e;
339
- throw new I(
340
- `Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid group-by field.`,
341
- {
342
- code: V,
343
- controlId: t.binding.controlId
344
- }
345
- );
346
- }
347
- function Fe(t) {
348
- const e = t.binding.mapping[t.selectedValue];
349
- if (e && typeof e == "object" && "role" in e && e.role === "metric")
350
- return e;
351
- throw new I(
352
- `Binding for control '${t.binding.controlId}' does not map value '${t.selectedValue}' to a valid metric field.`,
353
- {
354
- code: V,
355
- controlId: t.binding.controlId
356
- }
357
- );
358
- }
359
- const Ge = /* @__PURE__ */ new Set([
360
- "day",
361
- "week",
362
- "month",
363
- "quarter",
364
- "year",
365
- "hour",
366
- "minute",
367
- "second"
368
- ]);
369
- function tt(t) {
370
- let e = t.spec;
371
- const n = X(
372
- t.controlDefinitions || [],
373
- t.cardControlDefinitions || []
374
- ), r = (t.controlBindings || []).filter(
375
- (o) => o.target !== "sql_param"
376
- ), i = r.filter(
377
- (o) => o.target === "config_metric_selector" || o.target === "config_field_selector"
378
- ), s = r.filter(
379
- (o) => o.target === "config_grain" || o.target === "config_aggregation"
380
- ), f = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Map();
381
- let d;
382
- const D = () => {
383
- if (d) return d;
384
- const o = t.catalog, c = /* @__PURE__ */ new Map();
385
- for (const l of o) {
386
- const u = c.get(l.id) ?? [];
387
- c.set(l.id, [...u, l]);
388
- }
389
- return d = { refs: o, byId: c }, d;
390
- }, E = (o, c) => {
391
- throw new I(o, {
392
- code: Le,
393
- ...c ? { controlId: c } : {}
394
- });
395
- }, S = (o, c) => {
396
- var u;
397
- if (o.derivedField) return o.derivedField.dataType;
398
- const l = D().refs.filter((h) => h.field.name === o.name && B(h.field.source ?? t.spec.source, o.source ?? t.spec.source));
399
- return l.length > 1 ? E("The selected field is ambiguous in the authorized Matrix field catalog.", c) : se(((u = l[0]) == null ? void 0 : u.field.dataType) ?? o.dataType);
400
- }, v = (o, c) => ce(o, c.target, (l) => S(l, c.controlId)), T = ne.safeParse(e);
401
- if (!T.success) return E(T.error.message);
402
- e = T.data;
403
- const K = [...i, ...s].map((o) => {
404
- const c = Q({ binding: o, definitions: n, controlValues: t.controlValues }), l = !o.matrixTargetId && c !== void 0 && c !== A ? v(T.data, o) : [];
405
- return {
406
- binding: o,
407
- selectedValue: c,
408
- targetId: o.matrixTargetId ?? (l.length === 1 ? l[0].id : void 0)
409
- };
410
- });
411
- for (const { binding: o, targetId: c, selectedValue: l } of K) {
412
- if (l === void 0 || l === A)
413
- continue;
414
- const u = (a) => E(a, o.controlId), h = o.target === "config_metric_selector" || o.target === "config_aggregation", ee = v(e, o);
415
- (!c || !ee.some((a) => a.id === c)) && u("Choose a valid Matrix level or measure target for this control.");
416
- const M = `${o.target}:${c}`;
417
- f.has(M) && u("Multiple controls cannot replace the same Matrix target."), f.add(M);
418
- const U = (a) => {
419
- const g = (D().byId.get(a.id) ?? []).filter((p) => !a.source || B(a.source, p.field.source ?? t.spec.source));
420
- if (g.length !== 1) return u(g.length ? "The selected field is ambiguous in the authorized Matrix field catalog." : "The selected field is not in the authorized Matrix field catalog.");
421
- const N = ie.safeParse(g[0].field);
422
- return N.success ? N.data : u(N.error.message);
423
- }, R = o.target === "config_metric_selector" || o.target === "config_field_selector" ? o.mapping[l] : void 0, C = R && typeof R == "object" && "kind" in R && R.kind === "matrix_instance" ? R.id : void 0;
424
- if (h) {
425
- m.set(c, o.controlId);
426
- const a = C === void 0 ? void 0 : T.data.measures.find(
427
- (_) => _.id === C && _.kind === "aggregate"
428
- );
429
- C !== void 0 && !a && u("The selected Matrix aggregate measure is no longer available.");
430
- const g = o.target === "config_metric_selector" && !a ? Fe({ binding: o, selectedValue: l }) : void 0, N = ((a == null ? void 0 : a.kind) === "aggregate" ? a.aggregate : g == null ? void 0 : g.aggregate) ?? (o.target === "config_aggregation" ? z({ binding: o, selectedValue: l }) : void 0), p = N === void 0 ? void 0 : oe.safeParse(N);
431
- p && !p.success && u("This aggregation is not supported by Matrix."), e = {
432
- ...e,
433
- measures: e.measures.map(
434
- (_) => _.id !== c || _.kind !== "aggregate" ? _ : {
435
- ..._,
436
- ...g ? { field: U(g) } : {},
437
- ...(a == null ? void 0 : a.kind) === "aggregate" ? { field: a.field } : {},
438
- aggregate: p != null && p.success ? p.data : _.aggregate
439
- }
440
- )
441
- };
442
- } else {
443
- const a = C === void 0 ? void 0 : [...T.data.rows, ...T.data.columns].find(
444
- (_) => _.id === C
445
- );
446
- C !== void 0 && !a && u("The selected Matrix level is no longer available.");
447
- const g = o.target === "config_field_selector" && !a ? $e({ binding: o, selectedValue: l }) : void 0, N = o.target === "config_grain" ? z({ binding: o, selectedValue: l }) : a ? a.grain : g == null ? void 0 : g.granularity;
448
- N !== void 0 && !Ge.has(N) && u("This time grain is not supported by Matrix.");
449
- const p = (_) => _.map((w) => {
450
- if (w.id !== c) return w;
451
- const $ = (a == null ? void 0 : a.field) ?? (g ? U(g) : w.field), F = S($, o.controlId), G = N ?? (g && P(F) ? w.grain : void 0);
452
- return G && !P(F) && u("A time grain requires a temporal Matrix level."), { ...w, field: $, grain: G };
453
- });
454
- e = {
455
- ...e,
456
- rows: p(e.rows),
457
- columns: p(e.columns)
458
- };
459
- }
460
- }
461
- for (const [o, c] of Array.from(m)) {
462
- const l = e.measures.find((h) => h.id === o);
463
- if (!l || l.kind !== "aggregate") continue;
464
- const u = S(l.field, c);
465
- de(u).some((h) => h.value === l.aggregate) || E(`Aggregation '${l.aggregate}' is not eligible for this Matrix field datatype.`, c);
466
- }
467
- try {
468
- return le(T.data, e);
469
- } catch (o) {
470
- if (o instanceof ue) return E(o.message);
471
- throw o;
472
- }
473
- }
474
- function J(t, e) {
475
- const n = [], r = (i) => {
476
- if (i.source) {
477
- const s = ae.safeParse(i.source);
478
- if (s.success) n.push(s.data);
479
- else if (e) throw s.error;
480
- }
481
- i.derivedField && Object.values(i.derivedField.inputs).forEach((s) => r(s.field));
482
- };
483
- for (const i of t) {
484
- if (i.target !== "config_field_selector" && i.target !== "config_metric_selector") continue;
485
- const s = e == null ? void 0 : e.get(i), f = e ? s && s !== A ? [i.mapping[s]] : [] : Object.values(i.mapping);
486
- for (const m of f)
487
- m && "role" in m && r(m);
488
- }
489
- return n;
490
- }
491
- function rt(t, e = [], n = []) {
492
- return j([...Y(t), ...J(e), ...n]);
493
- }
494
- function nt(t, e = {}) {
495
- const n = e.controlBindings ?? [], r = X(e.controlDefinitions ?? [], e.cardControlDefinitions ?? []), i = new Map(n.filter((s) => s.target === "config_field_selector" || s.target === "config_metric_selector").map((s) => [s, Q({ binding: s, definitions: r, controlValues: e.controlValues })]));
496
- return j([...Y(t), ...J(n, i)]);
497
- }
498
- export {
499
- Je as C,
500
- Xe as D,
501
- We as a,
502
- nt as b,
503
- be as c,
504
- Ae as d,
505
- Ke as e,
506
- et as f,
507
- Qe as g,
508
- Se as h,
509
- xe as i,
510
- V as j,
511
- Le as k,
512
- k as l,
513
- rt as m,
514
- I as n,
515
- X as o,
516
- z as p,
517
- $e as q,
518
- Q as r,
519
- Fe as s,
520
- tt as t,
521
- ge as u,
522
- Ue as v
523
- };