react-semaphor 0.1.453 → 0.1.455
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +100 -99
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-GHKFwThg.js → analyze-result-contract-BbRJ-C06.js} +1 -1
- package/dist/chunks/{analyze-result-contract-Dxw66nUG.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
- package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
- package/dist/chunks/{canonical-result-keys-KLk__J_O.js → canonical-result-keys-D6avdjpA.js} +14 -13
- package/dist/chunks/{common-types-Ci66eflG.cjs → common-types-C57kJ59w.cjs} +1 -1
- package/dist/chunks/{common-types-F6qk6PPS.js → common-types-H51FLKB7.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CFpX0WX3.js → dashboard-briefing-launcher-BgBMjAVe.js} +10 -10
- package/dist/chunks/{dashboard-briefing-launcher-mUXWuiOZ.cjs → dashboard-briefing-launcher-BmEHYblf.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-SoNubIu1.cjs → dashboard-controls-BLNG_zHC.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BeYAmOJc.js → dashboard-controls-C-23EDdr.js} +10 -10
- package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
- package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
- package/dist/chunks/{dashboard-json-BublPnQ4.cjs → dashboard-json-BJ_Z9EaL.cjs} +1 -1
- package/dist/chunks/{dashboard-json-DeLUagVV.js → dashboard-json-BTF-1Iwa.js} +8 -8
- package/dist/chunks/{edit-dashboard-visual-CrvPcO7A.cjs → edit-dashboard-visual-CR832BJc.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-Go0h82DR.js → edit-dashboard-visual-Mw-ZE7P7.js} +12 -12
- package/dist/chunks/{editor-action-buttons-1Lo0fIh7.cjs → editor-action-buttons-BVigIMg0.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-BFNtjFzO.js → editor-action-buttons-BxbFCerU.js} +6 -6
- package/dist/chunks/{index-BsH32bn1.js → index-B5Oy1eLv.js} +35305 -34883
- package/dist/chunks/index-C99Ow35Y.cjs +4 -0
- package/dist/chunks/{index-q12_nNUS.cjs → index-DIWJALWL.cjs} +231 -231
- package/dist/chunks/{index-B3ZugihZ.js → index-DrYILnh0.js} +799 -808
- package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
- package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
- package/dist/chunks/{pivot-header-presentation-DcfPaCiy.cjs → pivot-header-presentation-DhyQXxKq.cjs} +1 -1
- package/dist/chunks/{pivot-header-presentation-nk604qc1.js → pivot-header-presentation-ckYOQ4aZ.js} +2 -2
- package/dist/chunks/{pivot-result-identity-CRUokNgm.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
- package/dist/chunks/{pivot-result-identity-C43Ai5Kr.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
- package/dist/chunks/{pivot-result-lifecycle-4kSe0Hk1.js → pivot-result-lifecycle-sjzIOpvp.js} +57 -58
- package/dist/chunks/{raw-temporal-contract-CxbRFwnd.cjs → raw-temporal-contract-BtjH_G-d.cjs} +1 -1
- package/dist/chunks/{raw-temporal-contract-BF7PjBY9.js → raw-temporal-contract-CxncLze5.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-BEVZAE3m.cjs → report-preferences-dialog-BgE3Gzsp.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-BNV7qXYH.js → report-preferences-dialog-CFenWkcH.js} +6 -6
- package/dist/chunks/{report-runtime-context-DjYqLV-c.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-BJQDu2fV.js → report-runtime-context-SM6YO61_.js} +5 -5
- package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
- package/dist/chunks/{saved-temporal-bucket-format-DiZdQXOL.js → saved-temporal-bucket-format-SGAV0ivR.js} +33 -35
- package/dist/chunks/{switch-DgLwr7O-.js → switch-BeZW-HnS.js} +367 -369
- package/dist/chunks/{switch-CjJ6FHYJ.cjs → switch-D-CCcfhc.cjs} +28 -28
- package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
- package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
- package/dist/chunks/{temporal-bucket-authoring-FIRnJz0e.js → temporal-bucket-authoring-K1kE6R_z.js} +28 -27
- package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-anl4h-vg.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
- package/dist/chunks/{temporal-bucket-contract-BQOj6Frl.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
- package/dist/chunks/{token-types-D0i0IUX3.cjs → token-types-D7CaaI80.cjs} +1 -1
- package/dist/chunks/{token-types-CRpQJ4kv.js → token-types-GbxRUozo.js} +1 -1
- package/dist/chunks/{update-policy-C1i9bgsy.cjs → update-policy-BmiOd0PB.cjs} +1 -1
- package/dist/chunks/{update-policy-CaJz9aPG.js → update-policy-hednMF-0.js} +1 -1
- package/dist/chunks/validators-BDYprKI9.cjs +1 -0
- package/dist/chunks/{validators-DeMXwRON.js → validators-DEmd8Sin.js} +1544 -1200
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +7 -7
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +78 -77
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +29 -30
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +21 -21
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +39 -40
- package/dist/index.cjs +1 -1
- package/dist/index.js +15 -15
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +44 -11
- package/dist/types/briefings.d.ts +9 -17
- package/dist/types/dashboard-assistant.d.ts +19 -22
- package/dist/types/dashboard-authoring.d.ts +9 -17
- package/dist/types/dashboard.d.ts +9 -17
- package/dist/types/data-app-builder.d.ts +28 -2
- package/dist/types/data-app-codegen-node.d.ts +29 -3
- package/dist/types/data-app-codegen.d.ts +29 -3
- package/dist/types/data-app-sdk-adapters.d.ts +28 -2
- package/dist/types/data-app-sdk-validation.d.ts +38 -7
- package/dist/types/data-app-sdk.d.ts +42 -10
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +25 -26
- package/dist/types/shared.d.ts +9 -17
- package/dist/types/surfboard.d.ts +9 -17
- package/dist/types/types.d.ts +19 -22
- package/package.json +1 -1
- package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
- package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
- package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
- package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
- package/dist/chunks/index-DjiIh_9n.cjs +0 -4
- package/dist/chunks/metric-comparison-D0T0MKRK.js +0 -387
- package/dist/chunks/metric-comparison-DYR3RXam.cjs +0 -1
- package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +0 -1
- package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +0 -1
- package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +0 -1
- package/dist/chunks/temporal-bucket-FBZGrDCe.js +0 -560
- package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +0 -1
- package/dist/chunks/validators-Dm7Kpz6p.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var le=Object.defineProperty;var me=(e,t,r)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var g=(e,t,r)=>me(e,typeof t!="symbol"?t+"":t,r);const w=require("./validators-BDYprKI9.cjs"),ue=require("./raw-temporal-contract-BtjH_G-d.cjs"),x=require("../value-format-preferences/index.cjs"),h=require("./temporal-bucket-DHY1y9lq.cjs"),de=require("./index-F25jnH0p.cjs"),fe=require("./report-runtime-context-DqxS4wbi.cjs");require("./analyze-result-contract-LPDNldic.cjs");const ye=require("./temporal-bucket-contract-D2-93DGr.cjs"),j=require("./pivot-result-identity-Bb4EixVN.cjs");function O(e){if(!e)return!1;const t=e.toLowerCase().replace("_","-");return t==="en-in"||t.startsWith("en-in-")}function q(e,t){const r=Math.abs(e);return r>=1e12?{divisor:1e12,suffix:"T"}:r>=1e9?{divisor:1e9,suffix:"B"}:O(t)&&r>=1e7?{divisor:1e7,suffix:"Cr"}:r>=1e6?{divisor:1e6,suffix:"M"}:O(t)&&r>=1e5?{divisor:1e5,suffix:"L"}:r>=1e3?{divisor:1e3,suffix:"K"}:{divisor:1,suffix:""}}function D(e,t){try{const r=b(t);return q(e,r)}catch{return q(e,"en-US")}}function he(e){try{return new Intl.NumberFormat(e),!0}catch{return!1}}function b(e){return e&&he(e)?e:"en-US"}function F(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale);let a=e;if(t!=null&&t.multiplyBy&&(a*=t.multiplyBy),t!=null&&t.useSuffix){const{divisor:i,suffix:o}=D(a,r);a=a/i;const s=new Intl.NumberFormat(r,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(a);return`${(t==null?void 0:t.prefix)??""}${s}${o}${(t==null?void 0:t.suffix)??""}`}const n=new Intl.NumberFormat(r,{minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(a);if(t!=null&&t.negativeInParentheses&&a<0){const i=n.replace("-","");return`(${(t==null?void 0:t.prefix)??""}${i}${(t==null?void 0:t.suffix)??""})`}return`${(t==null?void 0:t.prefix)??""}${n}${(t==null?void 0:t.suffix)??""}`}function N(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale),a=(t==null?void 0:t.currency)||"USD",n=e<0,i=!!(t!=null&&t.negativeInParentheses&&n),o=i?Math.abs(e):e;try{if(t!=null&&t.useSuffix){const{divisor:l,suffix:m}=D(o,r),c=o/l,f=`${new Intl.NumberFormat(r,{style:"currency",currency:a,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(c)}${m}`;return i?`(${f})`:f}const s=new Intl.NumberFormat(r,{style:"currency",currency:a,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(o);return i?`(${s})`:s}catch{const s=Math.abs(e),l=t!=null&&t.useSuffix?D(s,r):{divisor:1,suffix:""},m=F(s/l.divisor,{locale:r,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}),c=`${a} ${m}${l.suffix}`;return n?t!=null&&t.negativeInParentheses?`(${c})`:`-${c}`:c}}function M(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale),n=(t==null?void 0:t.alreadyPercent)??(t==null?void 0:t.percentValueMode)==="whole"?e/100:e;return new Intl.NumberFormat(r,{style:"percent",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0}).format(n)}function P(e,t){if(e==null||isNaN(e))return"";const r=b(t==null?void 0:t.locale);return new Intl.NumberFormat(r,{notation:"scientific",minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2}).format(e)}function U(e,t){if(e==null||Number.isNaN(e))return"";const r=t.scale===void 0?e:e*t.scale,a=t.negativeStyle==="parentheses"&&r<0,n=a?Math.abs(r):r,i={style:t.type==="number"?"decimal":t.type,locale:t.locale,currency:t.currency,minimumFractionDigits:t.minimumFractionDigits,maximumFractionDigits:t.maximumFractionDigits,useGrouping:t.useGrouping,percentValueMode:t.percentValueMode,useSuffix:t.compact};let o;switch(t.type){case"currency":o=N(n,i);break;case"percent":o=M(n,i);break;case"scientific":o=P(n,i);break;default:o=F(n,i);break}const s=`${t.prefix??""}${o}${t.suffix??""}`;return a?`(${s})`:s}function ge(e,t,r="en-US"){if(e==null||isNaN(e))return"";const a=b((t==null?void 0:t.locale)||r),n=(t==null?void 0:t.style)||"decimal",i=n==="decimal"?"number":n;return i==="currency"&&new Intl.NumberFormat(a,{style:"currency",currency:(t==null?void 0:t.currency)||"USD"}),U(e,{type:i,locale:a,currency:i==="currency"?(t==null?void 0:t.currency)||"USD":void 0,minimumFractionDigits:(t==null?void 0:t.minimumFractionDigits)??0,maximumFractionDigits:(t==null?void 0:t.maximumFractionDigits)??2,useGrouping:(t==null?void 0:t.useGrouping)??!0,percentValueMode:i==="percent"?(t==null?void 0:t.percentValueMode)??"whole":void 0,scale:t==null?void 0:t.scale,compact:t==null?void 0:t.compact,negativeStyle:t==null?void 0:t.negativeStyle,prefix:t==null?void 0:t.prefix,suffix:t==null?void 0:t.suffix})}function ve(e,t,r){const a={style:t==="currency"?"currency":t==="percent"?"percent":"decimal",locale:r==null?void 0:r.locale,currency:r==null?void 0:r.currency,minimumFractionDigits:r==null?void 0:r.decimalPlaces,maximumFractionDigits:r==null?void 0:r.decimalPlaces,useSuffix:r==null?void 0:r.useSuffix,prefix:r==null?void 0:r.prefix,suffix:r==null?void 0:r.suffix,negativeInParentheses:r==null?void 0:r.negativeInParentheses,multiplyBy:r==null?void 0:r.multiplyBy};switch(t){case"currency":return N(e,a);case"percent":return M(e,a);case"scientific":return P(e,a);default:return F(e,a)}}const we=["type","locale","minimumFractionDigits","maximumFractionDigits","useGrouping","prefix","suffix","negativeStyle","compact","scale","currency","percentValueMode"];function J(e){if(!h.isPlainJsonRecord(e))return{ok:!1,issues:[{path:"$",message:"Numeric format must be an object."}]};const t=[],r=new Set(we);Object.keys(e).filter(i=>!r.has(i)).forEach(i=>t.push({path:i,message:`Unknown property "${i}".`})),e.type!=="number"&&e.type!=="currency"&&e.type!=="percent"&&e.type!=="scientific"&&t.push({path:"type",message:"Expected number, currency, percent, or scientific."});const a=e.locale===void 0?void 0:x.canonicalizeSupportedLocale(e.locale);e.locale!==void 0&&!a&&t.push({path:"locale",message:"Expected a supported BCP 47 locale."});const n=e.currency===void 0?void 0:x.canonicalizeSupportedCurrencyCode(e.currency);e.currency!==void 0&&!n&&t.push({path:"currency",message:"Expected a supported ISO 4217 currency code."});for(const i of["minimumFractionDigits","maximumFractionDigits"]){const o=e[i];o!==void 0&&(!Number.isInteger(o)||typeof o!="number"||o<0||o>20)&&t.push({path:i,message:"Expected an integer from 0 to 20."})}typeof e.minimumFractionDigits=="number"&&typeof e.maximumFractionDigits=="number"&&e.minimumFractionDigits>e.maximumFractionDigits&&t.push({path:"maximumFractionDigits",message:"Must be greater than or equal to minimumFractionDigits."});for(const i of["useGrouping","compact"])e[i]!==void 0&&typeof e[i]!="boolean"&&t.push({path:i,message:"Expected a boolean."});for(const i of["prefix","suffix"])e[i]!==void 0&&typeof e[i]!="string"&&t.push({path:i,message:"Expected a string."});return e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&t.push({path:"negativeStyle",message:"Expected minus or parentheses."}),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&t.push({path:"percentValueMode",message:"Expected fraction or whole."}),e.scale!==void 0&&(typeof e.scale!="number"||!Number.isFinite(e.scale))&&t.push({path:"scale",message:"Expected a finite number."}),t.length>0?{ok:!1,issues:t}:{ok:!0,value:{type:e.type,...a?{locale:a}:{},...e.minimumFractionDigits!==void 0?{minimumFractionDigits:e.minimumFractionDigits}:{},...e.maximumFractionDigits!==void 0?{maximumFractionDigits:e.maximumFractionDigits}:{},...e.useGrouping!==void 0?{useGrouping:e.useGrouping}:{},...e.prefix!==void 0?{prefix:e.prefix}:{},...e.suffix!==void 0?{suffix:e.suffix}:{},...e.negativeStyle!==void 0?{negativeStyle:e.negativeStyle}:{},...e.compact!==void 0?{compact:e.compact}:{},...e.scale!==void 0?{scale:e.scale}:{},...n?{currency:n}:{},...e.percentValueMode!==void 0?{percentValueMode:e.percentValueMode}:{}}}}function H(e){const t=J(e);if(!t.ok)return t;const r=[];return t.value.locale||r.push({path:"locale",message:"Resolved numeric formats require an explicit locale."}),t.value.minimumFractionDigits===void 0&&r.push({path:"minimumFractionDigits",message:"Resolved numeric formats require minimumFractionDigits."}),t.value.maximumFractionDigits===void 0&&r.push({path:"maximumFractionDigits",message:"Resolved numeric formats require maximumFractionDigits."}),t.value.type==="currency"&&!t.value.currency&&r.push({path:"currency",message:"Resolved currency formats require an explicit currency."}),r.length>0?{ok:!1,issues:r}:t}function pe(e){var a;const t=new Set;if(e.snapshot.resolvedFormats.forEach((n,i)=>{if(n.format.type!=="temporal_bucket"){if(n.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`);if(n.scope.dashboardId!==e.expectedScope.dashboardId||n.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${i}.scope must match the executing dashboard/card`);if(n.target.kind!=="column")throw new Error(`resolvedFormats.${i}.target must identify an export column`);if(t.has(n.target.columnKey))throw new Error(`resolvedFormats.${i} duplicates export column "${n.target.columnKey}"`);t.add(n.target.columnKey)}}),!e.useFormattedValues)return;if(!((a=e.visibleColumns)!=null&&a.length))throw new Error("visibleColumns must identify every formatted export column");const r=e.visibleColumns.find(n=>!t.has(n));if(r)throw new Error(`resolvedFormats is missing visible export column "${r}"`)}function Y(e,t){const r=new Intl.NumberFormat(e,{style:"currency",currency:t}).resolvedOptions();return{minimumFractionDigits:r.minimumFractionDigits,maximumFractionDigits:r.maximumFractionDigits}}function xe(e){if(e.minimumFractionDigits!==void 0||e.maximumFractionDigits!==void 0){const r=e.minimumFractionDigits??0;return{minimumFractionDigits:r,maximumFractionDigits:e.maximumFractionDigits??Math.max(r,2)}}const t=e.type==="percent"?1:e.type==="scientific"?2:0;return{minimumFractionDigits:t,maximumFractionDigits:t}}function Se(e,t,r){const a=x.canonicalizeSupportedLocale(e.locale)??t.locale,n=e.type==="number"||e.type==="currency"?x.canonicalizeSupportedCurrencyCode(r):void 0;if(!(e.type==="currency"||n!==void 0))return{...e,locale:a,...xe(e)};const o=n??x.canonicalizeSupportedCurrencyCode(e.currency)??t.defaultCurrency,s=Y(a,o),l=s.minimumFractionDigits??0,m=s.maximumFractionDigits??l,c=e.minimumFractionDigits??Math.min(l,e.maximumFractionDigits??l),y=e.maximumFractionDigits??Math.max(c,m);return{...e,type:"currency",locale:a,currency:o,minimumFractionDigits:c,maximumFractionDigits:y}}class p extends Error{constructor(r,a){super(a);g(this,"code");this.name="RawTemporalFormatContractError",this.code=r}}const be=["SSSSSSSSS","SSSSSSSS","SSSSSSS","SSSSSS","SSSSS","SSSS","SSS","SS","S"],X=/^(\d{4})-(\d{2})-(\d{2})$/,W=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/,Q=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/,Te=["yyyy","MMMM","LLLL","zzz","XXX","MMM","LLL","yy","MM","dd","HH","hh","mm","ss","M","d","H","h","m","s","a"],ke=new Set(["HH","H","hh","h","mm","m","ss","s","a",...be]),_e=new Set(["zzz","XXX"]),E=new Set(["short","medium","long"]);function v(e,t){return Object.keys(e).length===t.length&&t.every(a=>a in e)}function d(e){throw new p("invalid_raw_temporal_format",e)}function ee(e){if(!e||e.trim()!==e||e.length>256)return d("date_fns patterns must be non-empty, trimmed, and at most 256 characters.");const t=[],r=n=>{const i=t[t.length-1];(i==null?void 0:i.kind)==="literal"?i.value+=n:t.push({kind:"literal",value:n})};let a=0;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){r("'"),a+=2;continue}let o="",s=!1;for(a+=1;a<e.length;){if(e[a]==="'"){if(e[a+1]==="'"){o+="'",a+=2;continue}s=!0,a+=1;break}o+=e[a],a+=1}if(!s)return d("date_fns pattern has an unclosed quote.");r(o);continue}if(e[a]==="S"){let o=a+1;for(;e[o]==="S";)o+=1;const s=e.slice(a,o);if(s.length>9)return d("date_fns fractional-second tokens support at most nine digits.");t.push({kind:"token",value:s}),a=o;continue}const n=Te.find(o=>e.startsWith(o,a));if(n){t.push({kind:"token",value:n}),a+=n.length;continue}const i=e[a];if(/[A-Za-z]/.test(i))return d(`Unsupported date_fns pattern token beginning at "${e.slice(a)}".`);r(i),a+=1}return t.some(n=>n.kind==="token")?t:d("date_fns patterns must contain at least one token.")}function te(e,t){if(e==="semaphor_tokens"){const r=w.tokenizeTemporalBucketPattern(t);r.ok||d(r.message);return}ee(t)}function Re(e){return!h.isPlainJsonRecord(e)||!v(e,["dateStyle","dateTime"])?d("Automatic raw temporal styles are incomplete."):E.has(e.dateStyle)?!h.isPlainJsonRecord(e.dateTime)||!v(e.dateTime,["dateStyle","timeStyle"])||!E.has(e.dateTime.dateStyle)||!E.has(e.dateTime.timeStyle)?d("Automatic dateTime styles are incomplete or invalid."):{dateStyle:e.dateStyle,dateTime:{dateStyle:e.dateTime.dateStyle,timeStyle:e.dateTime.timeStyle}}:d("Automatic dateStyle is invalid.")}function I(e){const t=["type","locale","calendarTimezone","presentation"],r=[...t,"sourceTimezone"];if(!h.isPlainJsonRecord(e)||!v(e,t)&&!v(e,r)||e.type!=="raw_temporal")return d("Resolved raw temporal format has an invalid shape.");const a=x.canonicalizeSupportedLocale(e.locale);return a?typeof e.calendarTimezone!="string"||!w.isValidIanaTimeZone(e.calendarTimezone)?d("Raw temporal calendarTimezone must be a valid IANA timezone."):e.sourceTimezone!==void 0&&(typeof e.sourceTimezone!="string"||!w.isValidIanaTimeZone(e.sourceTimezone))?d("Raw temporal sourceTimezone must be a valid IANA timezone."):h.isPlainJsonRecord(e.presentation)?e.presentation.mode==="auto"?v(e.presentation,["mode","styles"])?{type:"raw_temporal",locale:a,calendarTimezone:e.calendarTimezone,...e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{},presentation:{mode:"auto",styles:Re(e.presentation.styles)}}:d("Automatic raw temporal presentation has unknown fields."):e.presentation.mode!=="pattern"||!v(e.presentation,["mode","dialect","pattern"])||e.presentation.dialect!=="semaphor_tokens"&&e.presentation.dialect!=="date_fns"||typeof e.presentation.pattern!="string"?d("Pattern raw temporal presentation has an invalid shape."):(te(e.presentation.dialect,e.presentation.pattern),{type:"raw_temporal",locale:a,calendarTimezone:e.calendarTimezone,...e.sourceTimezone?{sourceTimezone:e.sourceTimezone}:{},presentation:{mode:"pattern",dialect:e.presentation.dialect,pattern:e.presentation.pattern}}):d("Raw temporal presentation must be an object."):d("Raw temporal locale is invalid or unsupported.")}function Ce(e){var s,l,m;if(e.format){if(!h.isPlainJsonRecord(e.format))return d("Authored raw temporal format has an invalid shape.");const c=Object.keys(e.format);if(!c.includes("type")||!c.includes("presentation")||c.some(f=>f!=="type"&&f!=="presentation"&&f!=="timezone"&&f!=="sourceTimezone")||e.format.type!=="raw_temporal"||!h.isPlainJsonRecord(e.format.presentation))return d("Authored raw temporal format has an invalid shape.");const y=e.format.presentation;if(y.mode==="auto"){if(!v(y,["mode"]))return d("Automatic authored raw temporal format has unknown fields.")}else{if(y.mode!=="pattern"||!v(y,["mode","dialect","pattern"])||y.dialect!=="semaphor_tokens"&&y.dialect!=="date_fns"||typeof y.pattern!="string")return d("Authored raw temporal pattern has an invalid shape.");te(y.dialect,y.pattern)}}const t=(s=e.format)==null?void 0:s.timezone,r=(l=e.format)==null?void 0:l.sourceTimezone,a=t&&t!=="auto"?t:e.calendar.tz,n=r&&r!=="auto"?r==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:r:void 0;if(t!==void 0&&t!=="auto"&&!w.isValidIanaTimeZone(a)||n!==void 0&&!w.isValidIanaTimeZone(n))return d("Authored raw temporal timezone is invalid.");const i=((m=e.format)==null?void 0:m.presentation)??{mode:"auto"},o={type:"raw_temporal",locale:e.preferences.locale,calendarTimezone:a,...n?{sourceTimezone:n}:{},presentation:i.mode==="pattern"?{...i}:{mode:"auto",styles:{dateStyle:e.preferences.dateStyle,dateTime:{...e.preferences.dateTime}}}};return I(o)}function Fe(e){if(X.test(e))return"date";if(Q.test(e))return"instant";if(W.test(e))return"wall_datetime"}function Ie(e){const t=new Set;let r=!1;for(const a of e.values){if(a===null)continue;r=!0;const n=Fe(a);n&&t.add(n)}if(!r)return{status:"empty"};if(t.size===0)return{status:"invalid_only"};if(t.size>1)throw new p("mixed_sql_temporal_semantics",`Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`);return{status:"classified",metadata:{kind:"raw_temporal",valueKind:[...t][0]}}}function Ee(e){return{version:1,columns:Object.fromEntries([...e].map(([t,r])=>[t,r.status==="classified"?r.metadata.valueKind:r.status]))}}function re(e){if(!h.isPlainJsonRecord(e)||e.version!==1||!h.isPlainJsonRecord(e.columns)||Object.keys(e).some(a=>a!=="version"&&a!=="columns"))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence is malformed.");const t={},r=new Set(["empty","invalid_only","date","wall_datetime","instant"]);for(const[a,n]of Object.entries(e.columns)){if(!a.trim()||!r.has(n))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence contains an invalid column or status.");t[a]=n}return{version:1,columns:t}}function De(e){if(e.length===0)return;const t=e.map(re),r=Object.keys(t[0].columns).sort();for(let a=1;a<t.length;a+=1){const n=Object.keys(t[a].columns).sort();if(n.length!==r.length||n.some((i,o)=>i!==r[o]))throw new p("invalid_raw_temporal_format","Raw temporal chunk classification evidence has inconsistent columns.")}for(const a of r)if(new Set(t.map(i=>i.columns[a]).filter(i=>i!=="empty"&&i!=="invalid_only")).size>1)throw new p("mixed_sql_temporal_semantics",`Declared SQL temporal column "${a}" has inconsistent semantics across export chunks. Normalize it to one kind.`)}function $e(e){return e%4===0&&(e%100!==0||e%400===0)}function Ae(e,t){return t===2?$e(e)?29:28:[4,6,9,11].includes(t)?30:31}function Ne(e){return e.year>=1&&e.year<=9999&&e.month>=1&&e.month<=12&&e.day>=1&&e.day<=Ae(e.year,e.month)&&e.hour>=0&&e.hour<=23&&e.minute>=0&&e.minute<=59&&e.second>=0&&e.second<=59}function Me(e){return{year:Number(e[1]),month:Number(e[2]),day:Number(e[3]),hour:Number(e[4]??0),minute:Number(e[5]??0),second:Number(e[6]??0),fraction:e[7]??""}}function Pe(e,t){const r=t==="date"?e.match(X):t==="wall_datetime"?e.match(W):e.match(Q);if(!r)return{status:"invalid_shape"};const a=Me(r);if(!Ne(a))return{status:"out_of_range"};if(t==="instant"){const n=r[8];if(n&&n!=="Z"){const[o,s]=n.slice(1).split(":").map(Number);if(o>23||s>59)return{status:"out_of_range"}}const i=new Date(e.replace(" ","T"));return Number.isNaN(i.getTime())?{status:"out_of_range"}:{status:"valid",fields:a,instant:i}}return{status:"valid",fields:a}}function $(e){const t=new Date(0);return t.setUTCFullYear(e.year,e.month-1,e.day),t.setUTCHours(e.hour,e.minute,e.second,0),t}function ae(e,t){const r=e.fraction?`.${e.fraction.padEnd(3,"0").slice(0,3)}`:"";return de.fromZonedTime(`${String(e.year).padStart(4,"0")}-${String(e.month).padStart(2,"0")}-${String(e.day).padStart(2,"0")}T${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${r}`,t)}function Ke(e,t){const r=new Map,a=new Map;let n,i,o,s;return{number(l,m=1){let c=r.get(m);return c||(c=new Intl.NumberFormat(e,{useGrouping:!1,minimumIntegerDigits:m,maximumFractionDigits:0}),r.set(m,c)),c.format(l)},month(l,m,c){var k;const y=`${m}:${c?"standalone":"contextual"}`;let f=a.get(y);if(!f){const _={calendar:"gregory",timeZone:"UTC",month:m};c||(_.day="numeric"),f=new Intl.DateTimeFormat(e,_),a.set(y,f)}return((k=f.formatToParts(l).find(_=>_.type==="month"))==null?void 0:k.value)??""},dayPeriod(l){var m;return n??(n=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:"UTC",hour:"numeric",hour12:!0})),((m=n.formatToParts(l).find(c=>c.type==="dayPeriod"))==null?void 0:m.value)??""},instantFields(l){i??(i=new Intl.DateTimeFormat("en-CA",{calendar:"gregory",numberingSystem:"latn",timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}));const m=i.formatToParts(l),c=y=>{var f;return Number((f=m.find(k=>k.type===y))==null?void 0:f.value)};return{year:c("year"),month:c("month"),day:c("day"),hour:c("hour"),minute:c("minute"),second:c("second"),fraction:""}},timezoneName(l){var m;return o??(o=new Intl.DateTimeFormat(e,{calendar:"gregory",timeZone:t,timeZoneName:"short"})),((m=o.formatToParts(l).find(c=>c.type==="timeZoneName"))==null?void 0:m.value)??""},timezoneOffset(l){var y;s??(s=new Intl.DateTimeFormat("en-US",{calendar:"gregory",timeZone:t,timeZoneName:"longOffset"}));const m=(y=s.formatToParts(l).find(f=>f.type==="timeZoneName"))==null?void 0:y.value;if(!m)return d("Unable to resolve the instant timezone offset.");const c=m.replace(/^GMT/,"");return c===""||/^[+-]00:00$/.test(c)?"Z":c}}}function ze(e,t,r,a,n){if(/^S{1,9}$/.test(e)){const i=t.fraction.padEnd(e.length,"0").slice(0,e.length);return a.number(Number(i),e.length)}switch(e){case"YYYY":case"yyyy":return a.number(t.year,4);case"YY":case"yy":return a.number(t.year%100,2);case"MMMM":return a.month(r,"long",!1);case"LLLL":return a.month(r,"long",!0);case"MMM":return a.month(r,"short",!1);case"LLL":return a.month(r,"short",!0);case"MM":return a.number(t.month,2);case"M":return a.number(t.month);case"DD":case"dd":return a.number(t.day,2);case"d":return a.number(t.day);case"HH":return a.number(t.hour,2);case"H":return a.number(t.hour);case"hh":return a.number(t.hour%12||12,2);case"h":return a.number(t.hour%12||12);case"mm":return a.number(t.minute,2);case"m":return a.number(t.minute);case"ss":return a.number(t.second,2);case"s":return a.number(t.second);case"a":return a.dayPeriod(r);case"zzz":return n?a.timezoneName(n):d("Timezone pattern tokens require an instant value.");case"XXX":return n?a.timezoneOffset(n):d("Timezone pattern tokens require an instant value.");default:return d(`Unsupported raw temporal pattern token "${e}".`)}}function je(e,t,r,a){const n=$(t);return e.map(i=>i.kind==="literal"?i.value:ze(i.value,t,n,r,a)).join("")}function Oe(e,t,r,a){const n=r==="date_fns"?ee(a):(()=>{const s=w.tokenizeTemporalBucketPattern(a);return s.ok?s.segments:d(s.message)})(),i=n.filter(s=>s.kind==="token").map(s=>s.value);if(e.valueKind==="date"&&i.some(s=>ke.has(s)))return d("Date patterns cannot contain time tokens.");if(e.valueKind!=="instant"&&i.some(s=>_e.has(s)))return d("Timezone pattern tokens require an instant value.");const o=Ke(t.locale,t.calendarTimezone);return s=>{const l=e.valueKind==="wall_datetime"&&t.sourceTimezone?ae(s.fields,t.sourceTimezone):void 0,m=e.valueKind==="instant"?{...o.instantFields(s.instant),fraction:s.fields.fraction}:l?{...o.instantFields(l),fraction:s.fields.fraction}:s.fields;return je(n,m,o,s.instant??l)}}function qe(e,t){const r=t.presentation.mode==="auto"?t.presentation.styles:d("Automatic raw temporal formatting requires styles.");if(e.valueKind==="date"){const o=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:"UTC",dateStyle:r.dateStyle});return s=>o.format($(s.fields))}const a=e.valueKind==="instant",n=!a&&r.dateTime.timeStyle==="long"?"medium":r.dateTime.timeStyle,i=new Intl.DateTimeFormat(t.locale,{calendar:"gregory",timeZone:a||e.valueKind==="wall_datetime"&&t.sourceTimezone?t.calendarTimezone:"UTC",dateStyle:r.dateTime.dateStyle,timeStyle:n});return o=>a?i.format(o.instant):e.valueKind==="wall_datetime"&&t.sourceTimezone?i.format(ae(o.fields,t.sourceTimezone)):i.format($(o.fields))}function L(e,t,r){return{ok:!1,text:e,diagnostic:{code:r,message:`Raw temporal ${t.valueKind} value is ${r==="invalid_raw_temporal_value"?"malformed":"out of range"}.`}}}function ne(e){const t=ue.parseRawTemporalValueMetadata(e.metadata),r=I(e.format),a=r.presentation.mode==="auto"?qe(t,r):Oe(t,r,r.presentation.dialect,r.presentation.pattern);return n=>{if(n===null)return{ok:!0,text:"",status:"empty"};const i=Pe(n,t.valueKind);return i.status==="invalid_shape"?L(n,t,"invalid_raw_temporal_value"):i.status==="out_of_range"?L(n,t,"out_of_range_raw_temporal_value"):{ok:!0,text:a(i),status:"formatted"}}}function Le(e){return ne({metadata:e.metadata,format:e.format})(e.value)}class A extends Error{constructor(r){super(`invalid_presentation_execution_snapshot: ${r} Resave this report before running it again.`);g(this,"code","invalid_presentation_execution_snapshot");g(this,"deliveryBlocking",!0);this.name="PresentationExecutionSnapshotError"}}class Ve extends Error{constructor(r){super(`missing_resolved_raw_temporal_format: Column "${r}" has no captured presentation. Resave this report before running it again.`);g(this,"code","missing_resolved_raw_temporal_format");g(this,"deliveryBlocking",!0);this.name="MissingResolvedRawTemporalFormatError"}}function T(e,t,r){const a=new Set(t),n=Object.keys(e).find(i=>!a.has(i));if(n)throw new Error(`${r} contains unknown property "${n}"`)}function ie(e,t="scope"){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);T(e,["dashboardId","cardId","attachmentIndex"],t);const r=typeof e.dashboardId=="string"?e.dashboardId.trim():"";if(!r)throw new Error(`${t}.dashboardId is required`);const a=typeof e.cardId=="string"?e.cardId.trim():void 0;if(e.cardId!==void 0&&!a)throw new Error(`${t}.cardId must be a non-empty string`);const n=e.attachmentIndex;if(n!==void 0&&(typeof n!="number"||!Number.isInteger(n)||n<0))throw new Error(`${t}.attachmentIndex must be a non-negative integer`);return{dashboardId:r,...a?{cardId:a}:{},...typeof n=="number"?{attachmentIndex:n}:{}}}function S(e,t,r,a){if(e.kind!==t)return;T(e,["kind",r],a);const n=typeof e[r]=="string"?e[r].trim():"";if(!n)throw new Error(`${a}.${r} is required`);return n}function Be(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);const r=S(e,"metric","metricId",t);if(r)return{kind:"metric",metricId:r};const a=S(e,"column","columnKey",t);if(a)return{kind:"column",columnKey:a};const n=S(e,"matrix_measure","measureId",t);if(n)return{kind:"matrix_measure",measureId:n};throw new Error(`${t} is not a valid numeric presentation target`)}function Ge(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);if(e.kind==="field"){T(e,["kind","fieldId","role"],t);const n=typeof e.fieldId=="string"?e.fieldId.trim():"";if(!n)throw new Error(`${t}.fieldId is required`);const i=e.role;if(i!==void 0&&i!=="groupby"&&i!=="pivotby")throw new Error(`${t}.role must be groupby or pivotby`);return{kind:"field",fieldId:n,...i?{role:i}:{}}}const r=S(e,"column","columnKey",t);if(r)return{kind:"column",columnKey:r};const a=S(e,"matrix_axis","axisInstanceId",t);if(a)return{kind:"matrix_axis",axisInstanceId:a};throw new Error(`${t} is not a valid temporal bucket presentation target`)}function Ze(e,t){if(!h.isPlainJsonRecord(e))throw new Error(`${t} must be an object`);const r=S(e,"column","columnKey",t);if(!r)throw new Error(`${t} must identify a column`);return{kind:"column",columnKey:r}}function Ue(e){return[e.dashboardId,e.cardId??null,e.attachmentIndex??null]}function C(e){switch(e.kind){case"metric":return[e.kind,e.metricId];case"column":return[e.kind,e.columnKey];case"matrix_measure":return[e.kind,e.measureId];case"field":return[e.kind,e.fieldId,e.role??""];case"matrix_axis":return[e.kind,e.axisInstanceId]}}function K(e,t){return e.dashboardId===t.dashboardId&&e.cardId===t.cardId&&e.attachmentIndex===t.attachmentIndex}function z(e,t){const r=C(e),a=C(t);return r.length===a.length&&r.every((n,i)=>n===a[i])}function oe(e){if(!Array.isArray(e))throw new Error("resolvedFormats must be an array");const t=new Set;return e.map((r,a)=>{var l,m;const n=`resolvedFormats.${a}`;if(!h.isPlainJsonRecord(r))throw new Error(`${n} must be an object`);T(r,["scope","target","format"],n);const i=ie(r.scope,`${n}.scope`);if(!h.isPlainJsonRecord(r.format))throw new Error(`${n}.format must be an object`);let o;switch(r.format.type){case"temporal_bucket":{const c=h.parseResolvedTemporalBucketFormat(r.format);if(!c.ok)throw new Error(`${n}.format is invalid: ${((l=c.issues[0])==null?void 0:l.message)??"invalid value"}`);o={scope:i,target:Ge(r.target,`${n}.target`),format:c.value};break}case"raw_temporal":o={scope:i,target:Ze(r.target,`${n}.target`),format:I(r.format)};break;case"number":case"currency":case"percent":case"scientific":{const c=H(r.format);if(!c.ok)throw new Error(`${n}.format is invalid: ${((m=c.issues[0])==null?void 0:m.message)??"invalid value"}`);o={scope:i,target:Be(r.target,`${n}.target`),format:c.value};break}default:throw new Error(`${n}.format.type is unsupported`)}const s=JSON.stringify([...Ue(o.scope),...C(o.target)]);if(t.has(s))throw new Error(`${n} duplicates a scoped presentation target`);return t.add(s),o})}function se(e){try{if(!h.isPlainJsonRecord(e))throw new Error("presentation execution snapshot must be an object");if(T(e,["version","reportContext","resolvedFormats"],"presentation execution snapshot"),e.version!==1)throw new Error("presentation execution snapshot version must be 1");const t=fe.parseReportRuntimeContext(e.reportContext);if(!t.ok){const r=t.issues[0];throw new Error(`presentation execution snapshot reportContext is invalid: ${r!=null&&r.path&&r.path!=="$"?`${r.path}: `:""}${(r==null?void 0:r.message)??"invalid value"}`)}return{version:1,reportContext:t.value,resolvedFormats:oe(e.resolvedFormats)}}catch(t){throw t instanceof A?t:new A(t instanceof Error?t.message:"Snapshot is invalid.")}}function Je(e){return se({version:1,reportContext:e.reportContext,resolvedFormats:[...e.resolvedFormats]})}function He(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type!=="temporal_bucket"&&r.format.type!=="raw_temporal"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function Ye(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type==="raw_temporal"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function Xe(e){const t=e.snapshot.resolvedFormats.find(r=>r.format.type==="temporal_bucket"&&K(r.scope,e.scope)&&z(r.target,e.target));return t==null?void 0:t.format}function We(e){var n;const t=new Set,r=new Set;if(e.snapshot.resolvedFormats.forEach((i,o)=>{if(i.scope.attachmentIndex!==void 0)throw new Error(`resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`);if(i.scope.dashboardId!==e.expectedScope.dashboardId||i.scope.cardId!==e.expectedScope.cardId)throw new Error(`resolvedFormats.${o}.scope must match the executing dashboard/card`);if(i.target.kind==="field"&&i.format.type==="temporal_bucket"){const s=JSON.stringify(C(i.target));if(r.has(s))throw new Error(`resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`);r.add(s);return}if(i.target.kind!=="column")throw new Error(`resolvedFormats.${o}.target must identify an export column or temporal pivot field`);if(t.has(i.target.columnKey))throw new Error(`resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`);t.add(i.target.columnKey)}),!e.useFormattedValues)return;if(!((n=e.visibleColumns)!=null&&n.length))throw new Error("visibleColumns must identify every formatted export column");const a=e.visibleColumns.find(i=>!t.has(i));if(a)throw new Error(`resolvedFormats is missing visible export column "${a}"`)}function R(e){return Array.from(new Set((e??[]).flatMap(t=>typeof t.id=="string"&&t.id?[t.id]:[])))}function Qe(e){const t=e.metricFields??[],r=R(t),a=new Map;return r.forEach(n=>{a.set(n,t.filter(i=>i.id===n).length)}),{expectedRoleFieldIds:{groupby:R(e.groupByFields),metric:r.length>0?r:[w.SEMAPHOR_GENERATED_COUNT_METRIC_ID],pivotby:R(e.pivotByFields),detail:R(e.detailFields)},expectedMetricAliases:t.flatMap(n=>n.id&&(a.get(n.id)??0)>1?[h.resolveMetricResultAlias(n)]:[])}}class u extends Error{constructor(r,a){super(`invalid_pivot_result_lifecycle: ${r}`);g(this,"code","invalid_pivot_result_lifecycle");g(this,"deliveryBlocking",!0);this.cause=a,this.name="PivotResultLifecycleError"}}function et(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 a=ye.validateTemporalBucketResultColumn(r,{metadataRequired:!1});if(!a.ok)throw new u(`Canonical pivot column "${r.key}" has invalid temporal metadata: ${a.error.message}`)}return t}function V(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[a,n]of Object.entries(t.byRole)){if(!r.has(a)||!n||typeof n!="object"||Array.isArray(n))throw new u(`Canonical pivot role map contains invalid "${a}" bindings.`);for(const[i,o]of Object.entries(n))if(!i||!o||typeof o!="object"||Array.isArray(o)||o.role!==a||typeof o.rawKey!="string"||!o.rawKey||o.outputKey!==void 0&&(typeof o.outputKey!="string"||!o.outputKey))throw new u(`Canonical pivot role map contains an invalid "${a}:${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[a,n]of Object.entries(t.byMetricAlias))if(!a||!n||typeof n!="object"||Array.isArray(n)||n.role!=="metric"||typeof n.rawKey!="string"||!n.rawKey||n.outputKey!==void 0&&(typeof n.outputKey!="string"||!n.outputKey))throw new u(`Canonical pivot metric-alias map contains an invalid "${a}" binding.`)}return t}function tt(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:a,subtotalScope:n}=r;if(a!==void 0&&typeof a!="boolean"||n!==void 0&&n!=="base"&&n!=="pivot-value"&&n!=="grand-total"||a===!0&&n!=="pivot-value"&&n!=="grand-total"||(n==="pivot-value"||n==="grand-total")&&a!==!0||n==="base"&&a===!0)throw new u(`Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`)}return e}function B(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 rt(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,a=r.expectedRoleFieldIds;if(!a||typeof a!="object"||Array.isArray(a))throw new u("Canonical pivot contract role identities must be an object.");const i=Object.fromEntries(["groupby","metric","pivotby","detail"].map(f=>[f,B(a[f],`expectedRoleFieldIds.${f}`)])),o=B(r.expectedMetricAliases,"expectedMetricAliases"),s=r.columnKinds;if(!s||typeof s!="object"||Array.isArray(s))throw new u("Canonical pivot contract column kinds must be an object.");const l=new Set(["row","pivot_metric","value"]),m=t.map(f=>f.key),c=Object.keys(s);if(c.length!==m.length||c.some(f=>!m.includes(f)||!l.has(s[f])))throw new u("Canonical pivot contract must classify every authoritative result column exactly once.");const y=tt(r.columnClassifications);if(Object.keys(y).some(f=>!m.includes(f)))throw new u("Canonical pivot contract contains a classification for an unknown result column.");return{version:1,expectedRoleFieldIds:i,expectedMetricAliases:o,columnKinds:s,columnClassifications:y}}function G(e,t){const r=["groupby","metric","pivotby","detail"];for(const i of r){const o=new Set(t.expectedRoleFieldIds[i]??[]),s=Object.keys(e.byRole[i]??{});if(s.length!==o.size||s.some(l=>!o.has(l)))throw new u(`The role-scoped ${i} bindings do not match the authored result fields.`)}const a=new Set(t.expectedMetricAliases),n=Object.keys(e.byMetricAlias??{});if(n.length!==a.size||n.some(i=>!a.has(i)))throw new u("The metric-alias bindings do not match the authored metric instances.")}function at(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 nt(e,t){e.forEach((r,a)=>{t.forEach(n=>{if(!Object.prototype.hasOwnProperty.call(r,n.key)||r[n.key]===void 0)throw new u(`Canonical pivot column "${n.key}" is absent from row ${a}.`)})})}function it(e,t,r){const a=new Set(t.map(n=>n.key));["groupby","detail"].forEach(n=>{Object.entries(e.byRole[n]??{}).forEach(([i,o])=>{const s=o.outputKey||o.rawKey;if(!a.has(s)||r.columnKinds[s]!=="row")throw new u(`The role-scoped ${n} binding for "${i}" does not name an authoritative result column.`)})})}function Z(e,t){t.forEach(r=>{const a=e.columnKinds[r.key];if(a==="pivot_metric"&&r.pivotIdentity===void 0)throw new u(`Physical pivot result column "${r.key}" is missing its identity.`);if(a!=="pivot_metric"&&r.pivotIdentity!==void 0)throw new u(`Canonical pivot result column "${r.key}" carries pivot identity outside the physical pivot projection.`)})}function ce(e){const t=at(e.records),r=et(e.columns),a=rt(e.pivotResultContract,r),n=a.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(l=>a.columnKinds[l.key]==="pivot_metric"))throw new u("A loaded_empty pivot result cannot carry physical pivot columns.");Z(a,r);const s=V(e.columnKeyMap);return G(s,a),{pivotResultState:"loaded_empty",records:[],columns:r,columnKeyMap:s,pivotResultContract:a}}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=V(e.columnKeyMap);G(i,a),it(i,r,a),Z(a,r);const o=r.filter(s=>a.columnKinds[s.key]==="pivot_metric");if(n.length>0&&o.length===0)throw new u("A loaded_valid pivot result is missing its physical pivot columns.");try{j.requirePivotResultColumnIdentities(o,{expectedPivotFieldIds:n,columnClassifications:a.columnClassifications})}catch(s){throw s instanceof j.PivotResultIdentityError?new u(s.message,s):s}return nt(t,r),{pivotResultState:"loaded_valid",records:t,columns:r,columnKeyMap:i,pivotResultContract:a}}function ot(e){const t=new Set;["groupby","detail"].forEach(i=>{Object.values(e.columnKeyMap.byRole[i]??{}).forEach(o=>{t.add(o.outputKey||o.rawKey)})});const r=new Set(e.physicalPivotColumnKeys),a=new Set(e.columns.map(i=>i.key)),n={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])=>a.has(i)))};return ce({pivotResultState:e.records.length===0?"loaded_empty":"loaded_valid",pivotResultContract:n,records:e.records,columns:e.columns,columnKeyMap:e.columnKeyMap})}exports.MissingResolvedRawTemporalFormatError=Ve;exports.PivotResultLifecycleError=u;exports.PresentationExecutionSnapshotError=A;exports.RawTemporalFormatContractError=p;exports.assertRawTemporalChunkClassificationAgreement=De;exports.classifyDeclaredSqlTemporalColumn=Ie;exports.createCanonicalPivotResultTransport=ot;exports.createPresentationExecutionSnapshot=Je;exports.createRawTemporalChunkClassificationEvidence=Ee;exports.derivePivotResultContractExpectations=Qe;exports.findResolvedNumericFormat=He;exports.findResolvedRawTemporalFormat=Ye;exports.findResolvedTemporalBucketFormat=Xe;exports.formatCurrency=N;exports.formatNumber=F;exports.formatNumberCustom=ve;exports.formatNumberWithColumnSettings=ge;exports.formatNumericCanonical=U;exports.formatPercent=M;exports.formatRawTemporalValue=Le;exports.formatScientific=P;exports.parseCanonicalPivotResultTransport=ce;exports.parseNumericCanonicalFormat=J;exports.parsePresentationExecutionSnapshot=se;exports.parsePresentationScope=ie;exports.parseRawTemporalChunkClassificationEvidence=re;exports.parseResolvedNumericCanonicalFormat=H;exports.parseResolvedPresentationEntries=oe;exports.parseResolvedRawTemporalFormat=I;exports.prepareRawTemporalFormatter=ne;exports.resolveCurrencyFractionDigits=Y;exports.resolveNumericPresentation=Se;exports.resolveRawTemporalFormat=Ce;exports.validateCardExportNumericPresentationSnapshot=pe;exports.validateCardExportPresentationSnapshot=We;
|
package/dist/chunks/{pivot-result-lifecycle-4kSe0Hk1.js → pivot-result-lifecycle-sjzIOpvp.js}
RENAMED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
var ee = Object.defineProperty;
|
|
2
2
|
var te = (e, t, r) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var g = (e, t, r) => te(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { b as k,
|
|
5
|
-
import { p as ae } from "./raw-temporal-contract-
|
|
4
|
+
import { b as k, al as G, x as re } from "./validators-DEmd8Sin.js";
|
|
5
|
+
import { p as ae } from "./raw-temporal-contract-CxncLze5.js";
|
|
6
6
|
import { canonicalizeSupportedLocale as E, canonicalizeSupportedCurrencyCode as $ } from "../value-format-preferences/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import { f as
|
|
9
|
-
import { b as
|
|
10
|
-
import "./analyze-result-contract-
|
|
11
|
-
import { a as
|
|
12
|
-
import {
|
|
13
|
-
import { d as me, P as le } from "./pivot-result-identity-C43Ai5Kr.js";
|
|
7
|
+
import { l as h, j as ne, a as ie } from "./temporal-bucket-5UYEotyQ.js";
|
|
8
|
+
import { f as oe } from "./index-CACdoqu3.js";
|
|
9
|
+
import { b as se } from "./report-runtime-context-SM6YO61_.js";
|
|
10
|
+
import "./analyze-result-contract-BbRJ-C06.js";
|
|
11
|
+
import { a as ce } from "./temporal-bucket-contract-D5d-xEl3.js";
|
|
12
|
+
import { d as me, P as le } from "./pivot-result-identity-DU1v-5Xk.js";
|
|
14
13
|
function N(e) {
|
|
15
14
|
if (!e) return !1;
|
|
16
15
|
const t = e.toLowerCase().replace("_", "-");
|
|
@@ -152,7 +151,7 @@ function de(e, t) {
|
|
|
152
151
|
const s = `${t.prefix ?? ""}${o}${t.suffix ?? ""}`;
|
|
153
152
|
return a ? `(${s})` : s;
|
|
154
153
|
}
|
|
155
|
-
function
|
|
154
|
+
function ot(e, t, r = "en-US") {
|
|
156
155
|
if (e == null || isNaN(e))
|
|
157
156
|
return "";
|
|
158
157
|
const a = x((t == null ? void 0 : t.locale) || r), n = (t == null ? void 0 : t.style) || "decimal", i = n === "decimal" ? "number" : n;
|
|
@@ -174,7 +173,7 @@ function st(e, t, r = "en-US") {
|
|
|
174
173
|
suffix: t == null ? void 0 : t.suffix
|
|
175
174
|
});
|
|
176
175
|
}
|
|
177
|
-
function
|
|
176
|
+
function st(e, t, r) {
|
|
178
177
|
const a = {
|
|
179
178
|
style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
|
|
180
179
|
locale: r == null ? void 0 : r.locale,
|
|
@@ -294,7 +293,7 @@ function he(e) {
|
|
|
294
293
|
message: "Resolved currency formats require an explicit currency."
|
|
295
294
|
}), r.length > 0 ? { ok: !1, issues: r } : t;
|
|
296
295
|
}
|
|
297
|
-
function
|
|
296
|
+
function ct(e) {
|
|
298
297
|
var a;
|
|
299
298
|
const t = /* @__PURE__ */ new Set();
|
|
300
299
|
if (e.snapshot.resolvedFormats.forEach((n, i) => {
|
|
@@ -355,7 +354,7 @@ function ve(e) {
|
|
|
355
354
|
maximumFractionDigits: t
|
|
356
355
|
};
|
|
357
356
|
}
|
|
358
|
-
function
|
|
357
|
+
function mt(e, t, r) {
|
|
359
358
|
const a = E(e.locale) ?? t.locale, n = e.type === "number" || e.type === "currency" ? $(r) : void 0;
|
|
360
359
|
if (!(e.type === "currency" || n !== void 0))
|
|
361
360
|
return {
|
|
@@ -558,7 +557,7 @@ function R(e) {
|
|
|
558
557
|
}
|
|
559
558
|
}) : d("Raw temporal presentation must be an object.") : d("Raw temporal locale is invalid or unsupported.");
|
|
560
559
|
}
|
|
561
|
-
function
|
|
560
|
+
function lt(e) {
|
|
562
561
|
var s, m, l;
|
|
563
562
|
if (e.format) {
|
|
564
563
|
if (!h(e.format))
|
|
@@ -609,7 +608,7 @@ function _e(e) {
|
|
|
609
608
|
if (X.test(e)) return "instant";
|
|
610
609
|
if (Y.test(e)) return "wall_datetime";
|
|
611
610
|
}
|
|
612
|
-
function
|
|
611
|
+
function ut(e) {
|
|
613
612
|
const t = /* @__PURE__ */ new Set();
|
|
614
613
|
let r = !1;
|
|
615
614
|
for (const a of e.values) {
|
|
@@ -633,7 +632,7 @@ function dt(e) {
|
|
|
633
632
|
}
|
|
634
633
|
};
|
|
635
634
|
}
|
|
636
|
-
function
|
|
635
|
+
function dt(e) {
|
|
637
636
|
return {
|
|
638
637
|
version: 1,
|
|
639
638
|
columns: Object.fromEntries(
|
|
@@ -667,7 +666,7 @@ function Te(e) {
|
|
|
667
666
|
}
|
|
668
667
|
return { version: 1, columns: t };
|
|
669
668
|
}
|
|
670
|
-
function
|
|
669
|
+
function ft(e) {
|
|
671
670
|
if (e.length === 0) return;
|
|
672
671
|
const t = e.map(Te), r = Object.keys(t[0].columns).sort();
|
|
673
672
|
for (let a = 1; a < t.length; a += 1) {
|
|
@@ -731,7 +730,7 @@ function C(e) {
|
|
|
731
730
|
}
|
|
732
731
|
function Q(e, t) {
|
|
733
732
|
const r = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
|
|
734
|
-
return
|
|
733
|
+
return oe(
|
|
735
734
|
`${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}T${String(e.hour).padStart(2, "0")}:${String(e.minute).padStart(2, "0")}:${String(e.second).padStart(2, "0")}${r}`,
|
|
736
735
|
t
|
|
737
736
|
);
|
|
@@ -951,7 +950,7 @@ function Ke(e) {
|
|
|
951
950
|
return i.status === "invalid_shape" ? P(n, t, "invalid_raw_temporal_value") : i.status === "out_of_range" ? P(n, t, "out_of_range_raw_temporal_value") : { ok: !0, text: a(i), status: "formatted" };
|
|
952
951
|
};
|
|
953
952
|
}
|
|
954
|
-
function
|
|
953
|
+
function yt(e) {
|
|
955
954
|
return Ke({
|
|
956
955
|
metadata: e.metadata,
|
|
957
956
|
format: e.format
|
|
@@ -967,7 +966,7 @@ class j extends Error {
|
|
|
967
966
|
this.name = "PresentationExecutionSnapshotError";
|
|
968
967
|
}
|
|
969
968
|
}
|
|
970
|
-
class
|
|
969
|
+
class ht extends Error {
|
|
971
970
|
constructor(r) {
|
|
972
971
|
super(
|
|
973
972
|
`missing_resolved_raw_temporal_format: Column "${r}" has no captured presentation. Resave this report before running it again.`
|
|
@@ -1095,7 +1094,7 @@ function K(e, t) {
|
|
|
1095
1094
|
const r = I(e), a = I(t);
|
|
1096
1095
|
return r.length === a.length && r.every((n, i) => n === a[i]);
|
|
1097
1096
|
}
|
|
1098
|
-
function
|
|
1097
|
+
function Le(e) {
|
|
1099
1098
|
if (!Array.isArray(e))
|
|
1100
1099
|
throw new Error("resolvedFormats must be an array");
|
|
1101
1100
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -1160,7 +1159,7 @@ function qe(e) {
|
|
|
1160
1159
|
return t.add(s), o;
|
|
1161
1160
|
});
|
|
1162
1161
|
}
|
|
1163
|
-
function
|
|
1162
|
+
function qe(e) {
|
|
1164
1163
|
try {
|
|
1165
1164
|
if (!h(e))
|
|
1166
1165
|
throw new Error("presentation execution snapshot must be an object");
|
|
@@ -1170,7 +1169,7 @@ function Le(e) {
|
|
|
1170
1169
|
"presentation execution snapshot"
|
|
1171
1170
|
), e.version !== 1)
|
|
1172
1171
|
throw new Error("presentation execution snapshot version must be 1");
|
|
1173
|
-
const t =
|
|
1172
|
+
const t = se(e.reportContext);
|
|
1174
1173
|
if (!t.ok) {
|
|
1175
1174
|
const r = t.issues[0];
|
|
1176
1175
|
throw new Error(
|
|
@@ -1180,7 +1179,7 @@ function Le(e) {
|
|
|
1180
1179
|
return {
|
|
1181
1180
|
version: 1,
|
|
1182
1181
|
reportContext: t.value,
|
|
1183
|
-
resolvedFormats:
|
|
1182
|
+
resolvedFormats: Le(e.resolvedFormats)
|
|
1184
1183
|
};
|
|
1185
1184
|
} catch (t) {
|
|
1186
1185
|
throw t instanceof j ? t : new j(
|
|
@@ -1188,32 +1187,32 @@ function Le(e) {
|
|
|
1188
1187
|
);
|
|
1189
1188
|
}
|
|
1190
1189
|
}
|
|
1191
|
-
function
|
|
1192
|
-
return
|
|
1190
|
+
function gt(e) {
|
|
1191
|
+
return qe({
|
|
1193
1192
|
version: 1,
|
|
1194
1193
|
reportContext: e.reportContext,
|
|
1195
1194
|
resolvedFormats: [...e.resolvedFormats]
|
|
1196
1195
|
});
|
|
1197
1196
|
}
|
|
1198
|
-
function
|
|
1197
|
+
function vt(e) {
|
|
1199
1198
|
const t = e.snapshot.resolvedFormats.find(
|
|
1200
1199
|
(r) => r.format.type !== "temporal_bucket" && r.format.type !== "raw_temporal" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1201
1200
|
);
|
|
1202
1201
|
return t == null ? void 0 : t.format;
|
|
1203
1202
|
}
|
|
1204
|
-
function
|
|
1203
|
+
function wt(e) {
|
|
1205
1204
|
const t = e.snapshot.resolvedFormats.find(
|
|
1206
1205
|
(r) => r.format.type === "raw_temporal" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1207
1206
|
);
|
|
1208
1207
|
return t == null ? void 0 : t.format;
|
|
1209
1208
|
}
|
|
1210
|
-
function
|
|
1209
|
+
function pt(e) {
|
|
1211
1210
|
const t = e.snapshot.resolvedFormats.find(
|
|
1212
1211
|
(r) => r.format.type === "temporal_bucket" && M(r.scope, e.scope) && K(r.target, e.target)
|
|
1213
1212
|
);
|
|
1214
1213
|
return t == null ? void 0 : t.format;
|
|
1215
1214
|
}
|
|
1216
|
-
function
|
|
1215
|
+
function xt(e) {
|
|
1217
1216
|
var n;
|
|
1218
1217
|
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1219
1218
|
if (e.snapshot.resolvedFormats.forEach((i, o) => {
|
|
@@ -1263,7 +1262,7 @@ function T(e) {
|
|
|
1263
1262
|
)
|
|
1264
1263
|
);
|
|
1265
1264
|
}
|
|
1266
|
-
function
|
|
1265
|
+
function St(e) {
|
|
1267
1266
|
const t = e.metricFields ?? [], r = T(t), a = /* @__PURE__ */ new Map();
|
|
1268
1267
|
return r.forEach((n) => {
|
|
1269
1268
|
a.set(
|
|
@@ -1278,7 +1277,7 @@ function bt(e) {
|
|
|
1278
1277
|
detail: T(e.detailFields)
|
|
1279
1278
|
},
|
|
1280
1279
|
expectedMetricAliases: t.flatMap(
|
|
1281
|
-
(n) => n.id && (a.get(n.id) ?? 0) > 1 ? [
|
|
1280
|
+
(n) => n.id && (a.get(n.id) ?? 0) > 1 ? [ie(n)] : []
|
|
1282
1281
|
)
|
|
1283
1282
|
};
|
|
1284
1283
|
}
|
|
@@ -1364,7 +1363,7 @@ function Ge(e) {
|
|
|
1364
1363
|
}
|
|
1365
1364
|
return e;
|
|
1366
1365
|
}
|
|
1367
|
-
function
|
|
1366
|
+
function L(e, t) {
|
|
1368
1367
|
if (!Array.isArray(e) || e.some((r) => typeof r != "string" || !r) || new Set(e).size !== e.length)
|
|
1369
1368
|
throw new u(
|
|
1370
1369
|
`Canonical pivot contract ${t} must be an array of unique field identities.`
|
|
@@ -1389,12 +1388,12 @@ function Be(e, t) {
|
|
|
1389
1388
|
"detail"
|
|
1390
1389
|
].map((f) => [
|
|
1391
1390
|
f,
|
|
1392
|
-
|
|
1391
|
+
L(
|
|
1393
1392
|
a[f],
|
|
1394
1393
|
`expectedRoleFieldIds.${f}`
|
|
1395
1394
|
)
|
|
1396
1395
|
])
|
|
1397
|
-
), o =
|
|
1396
|
+
), o = L(
|
|
1398
1397
|
r.expectedMetricAliases,
|
|
1399
1398
|
"expectedMetricAliases"
|
|
1400
1399
|
), s = r.columnKinds;
|
|
@@ -1432,7 +1431,7 @@ function Be(e, t) {
|
|
|
1432
1431
|
columnClassifications: y
|
|
1433
1432
|
};
|
|
1434
1433
|
}
|
|
1435
|
-
function
|
|
1434
|
+
function q(e, t) {
|
|
1436
1435
|
const r = [
|
|
1437
1436
|
"groupby",
|
|
1438
1437
|
"metric",
|
|
@@ -1516,7 +1515,7 @@ function Ye(e) {
|
|
|
1516
1515
|
);
|
|
1517
1516
|
V(a, r);
|
|
1518
1517
|
const s = O(e.columnKeyMap);
|
|
1519
|
-
return
|
|
1518
|
+
return q(s, a), {
|
|
1520
1519
|
pivotResultState: "loaded_empty",
|
|
1521
1520
|
records: [],
|
|
1522
1521
|
columns: r,
|
|
@@ -1533,7 +1532,7 @@ function Ye(e) {
|
|
|
1533
1532
|
"A loaded_valid pivot result must carry at least one record."
|
|
1534
1533
|
);
|
|
1535
1534
|
const i = O(e.columnKeyMap);
|
|
1536
|
-
|
|
1535
|
+
q(i, a), He(i, r, a), V(a, r);
|
|
1537
1536
|
const o = r.filter(
|
|
1538
1537
|
(s) => a.columnKinds[s.key] === "pivot_metric"
|
|
1539
1538
|
);
|
|
@@ -1557,7 +1556,7 @@ function Ye(e) {
|
|
|
1557
1556
|
pivotResultContract: a
|
|
1558
1557
|
};
|
|
1559
1558
|
}
|
|
1560
|
-
function
|
|
1559
|
+
function bt(e) {
|
|
1561
1560
|
const t = /* @__PURE__ */ new Set();
|
|
1562
1561
|
["groupby", "detail"].forEach((i) => {
|
|
1563
1562
|
Object.values(e.columnKeyMap.byRole[i] ?? {}).forEach((o) => {
|
|
@@ -1605,38 +1604,38 @@ function _t(e) {
|
|
|
1605
1604
|
}
|
|
1606
1605
|
export {
|
|
1607
1606
|
Ke as A,
|
|
1608
|
-
|
|
1609
|
-
|
|
1607
|
+
yt as B,
|
|
1608
|
+
St as C,
|
|
1610
1609
|
u as D,
|
|
1611
1610
|
Ye as E,
|
|
1612
|
-
|
|
1613
|
-
|
|
1611
|
+
bt as F,
|
|
1612
|
+
ht as M,
|
|
1614
1613
|
j as P,
|
|
1615
1614
|
p as R,
|
|
1616
|
-
|
|
1615
|
+
vt as a,
|
|
1617
1616
|
de as b,
|
|
1618
1617
|
A as c,
|
|
1619
1618
|
B as d,
|
|
1620
1619
|
U as e,
|
|
1621
|
-
|
|
1620
|
+
ot as f,
|
|
1622
1621
|
Z as g,
|
|
1623
|
-
|
|
1622
|
+
st as h,
|
|
1624
1623
|
he as i,
|
|
1625
|
-
|
|
1624
|
+
mt as j,
|
|
1626
1625
|
Ne as k,
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1626
|
+
Le as l,
|
|
1627
|
+
qe as m,
|
|
1628
|
+
gt as n,
|
|
1629
|
+
wt as o,
|
|
1631
1630
|
ye as p,
|
|
1632
|
-
|
|
1631
|
+
pt as q,
|
|
1633
1632
|
ge as r,
|
|
1634
|
-
|
|
1633
|
+
xt as s,
|
|
1635
1634
|
R as t,
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1635
|
+
lt as u,
|
|
1636
|
+
ct as v,
|
|
1637
|
+
ut as w,
|
|
1638
|
+
dt as x,
|
|
1640
1639
|
Te as y,
|
|
1641
|
-
|
|
1640
|
+
ft as z
|
|
1642
1641
|
};
|
package/dist/chunks/{raw-temporal-contract-CxbRFwnd.cjs → raw-temporal-contract-BtjH_G-d.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var i=(a,e,t)=>e in a?l(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var n=(a,e,t)=>i(a,typeof e!="symbol"?e+"":e,t);const s=require("./validators-
|
|
1
|
+
"use strict";var l=Object.defineProperty;var i=(a,e,t)=>e in a?l(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var n=(a,e,t)=>i(a,typeof e!="symbol"?e+"":e,t);const s=require("./validators-BDYprKI9.cjs");class r extends Error{constructor(t){super(t);n(this,"code");this.name="RawTemporalMetadataContractError",this.code=s.RAW_TEMPORAL_CONTRACT_ERROR_CODES.invalidMetadata}}function m(a){if(a===null||typeof a!="object"||Array.isArray(a))return!1;const e=Object.getPrototypeOf(a);return e===null||e===Object.prototype}function d(a){if(!m(a))throw new r("Raw temporal metadata must be an object.");const e=Object.keys(a);if(e.length!==2||!e.includes("kind")||!e.includes("valueKind"))throw new r("Raw temporal metadata must contain only kind and valueKind.");if(a.kind!=="raw_temporal")throw new r("Raw temporal metadata kind must be raw_temporal.");if(a.valueKind!=="date"&&a.valueKind!=="wall_datetime"&&a.valueKind!=="instant")throw new r("Raw temporal valueKind must be date, wall_datetime, or instant.");return{kind:"raw_temporal",valueKind:a.valueKind}}function w(a,e){if(!a.rawTemporal){if(e.metadataRequired)throw new r("Activated raw temporal result is missing metadata.");return}if(a.temporalBucket)throw new r("A result column cannot carry both raw and grouped temporal metadata.");const t=d(a.rawTemporal),o=t.valueKind==="date"?"date":"datetime";if(a.dataType!==o)throw new r(`${t.valueKind} raw temporal values require dataType ${o}.`);return t}exports.RawTemporalMetadataContractError=r;exports.parseRawTemporalValueMetadata=d;exports.validateRawTemporalResultColumn=w;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
2
|
var i = (a, e, t) => e in a ? d(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
3
|
var n = (a, e, t) => i(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { R as l } from "./validators-
|
|
4
|
+
import { R as l } from "./validators-DEmd8Sin.js";
|
|
5
5
|
class r extends Error {
|
|
6
6
|
constructor(t) {
|
|
7
7
|
super(t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),l=require("./index-q12_nNUS.cjs"),u=require("./switch-CjJ6FHYJ.cjs"),V=require("./report-runtime-context-DjYqLV-c.cjs");require("./x-B6ghREd2.cjs");require("./saved-temporal-bucket-format-Gfbh4IiP.cjs");require("./validators-Dm7Kpz6p.cjs");require("./analyze-result-contract-Dxw66nUG.cjs");const L=require("../value-format-preferences/index.cjs");function G(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(p=>p.actions.applyResolvedCalendarPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,[g,S]=o.useState(!1),[b,C]=o.useState(!1),[f,j]=o.useState(!1),[T,x]=o.useState(null),[w,P]=o.useState(null),v=o.useRef(i);v.current=i,o.useEffect(()=>{P(null),x(null),S(!1),C(!1),j(!1)},[i]);const N=o.useCallback(async p=>{const r=V.parseCalendarPreferencesResponse(await p.json());if(!r.ok)throw new Error("Calendar preferences response is invalid");return r.value},[]),k=o.useCallback(async()=>{if(!s||!i||!h)return;const p=i;S(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to fetch preferences")}const n=await N(r);v.current===p&&P(n)}catch(r){v.current===p&&x(r instanceof Error?r.message:"Unknown error")}finally{v.current===p&&S(!1)}},[i,h,s,N]);o.useEffect(()=>{s&&k()},[s,k]);const E=o.useCallback(async p=>{if(!i||!h)return x("Not authenticated"),!1;const r=i;C(!0),x(null);try{const n=await fetch(`${h}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(p)});if(!n.ok){const D=await n.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}const y=await N(n);return v.current!==r?!1:(P(y),m(y.resolved,y.sources),!0)}catch(n){return v.current===r&&x(n instanceof Error?n.message:"Unknown error"),!1}finally{v.current===r&&C(!1)}},[i,h,m,N]),A=o.useCallback(async()=>{if(!i||!h)return x("Not authenticated"),!1;const p=i;j(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to clear preferences")}const n=await N(r);return v.current!==p?!1:(P(n),m(n.resolved,n.sources),!0)}catch(r){return v.current===p&&x(r instanceof Error?r.message:"Unknown error"),!1}finally{v.current===p&&j(!1)}},[i,h,m,N]);return{preferences:w,isLoading:g,isSaving:b,isClearing:f,error:T,updatePreferences:E,clearPreferences:A,refetch:k}}const F=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],B=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],R="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const a=Intl;if(a.supportedValuesOf)return a.supportedValuesOf("timeZone")}catch{}return F.map(a=>a.value)}function H(a){if(!a)return"default";if(a.tz!==a.weekStart)return"inherited";switch(a.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default"}}function U(a){const c=F.find(t=>t.value===a);return c?c.label:a}function K(a){const c=B.find(t=>t.value===a);return c?c.label:String(a)}function J({active:a,onClose:c}){const{preferences:t,isLoading:m,isSaving:s,isClearing:i,updatePreferences:h,clearPreferences:g}=G({enabled:a}),S=l.useCalendarContext(),b=(t==null?void 0:t.resolved.tz)||(S==null?void 0:S.tz)||"UTC",C=(t==null?void 0:t.resolved.weekStart)??(S==null?void 0:S.weekStart)??1,[f,j]=o.useState((t==null?void 0:t.stored)===null),[T,x]=o.useState(!1),[w,P]=o.useState(b),[v,N]=o.useState(C),[k,E]=o.useState(!1),A=o.useMemo(()=>W(),[]),p=o.useMemo(()=>A.filter(d=>!F.some(M=>M.value===d)),[A]),r=o.useMemo(()=>U(w),[w]),n=t!=null&&t.inherited?U(t.inherited.tz):"UTC",y=t!=null&&t.inherited?K(t.inherited.weekStart):"Monday",D=H(t==null?void 0:t.inheritedSources);o.useEffect(()=>{if(!a){x(!1);return}T||(t&&j(t.stored===null),P(b),N(C))},[a,T,t,b,C]);const O=async()=>{if(m){l.ue.error("Preferences are still loading. Please try again.");return}f?await g()?(l.ue.success("Now using default settings."),c()):l.ue.error("Failed to save preferences. Please try again."):await h({tz:w,weekStart:v})?(l.ue.success("Preferences saved."),c()):l.ue.error("Failed to save preferences. Please try again.")},_=()=>{c()},z=s||i,$=z||m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(l.RadioGroup,{value:f?"defaults":"custom",onValueChange:d=>{x(!0),j(d==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",f&&"bg-muted/50"),onClick:()=>{x(!0),j(!0)},children:[e.jsx(l.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",D," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[n,", week starts ",y]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!f&&"bg-muted/50"),onClick:()=>{x(!0),j(!1)},children:[e.jsx(l.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:u.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",f&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Timezone"}),e.jsxs(u.Popover,{open:k,onOpenChange:E,modal:!0,children:[e.jsx(u.PopoverTrigger,{asChild:!0,children:e.jsxs(u.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":k,className:"w-full justify-between text-[12px] font-normal",disabled:f,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(l.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(u.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(l.Command,{className:"overflow-visible",children:[e.jsx(l.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(l.CommandList,{children:[e.jsx(l.CommandEmpty,{children:"No timezone found."}),e.jsx(l.CommandGroup,{heading:"Common",children:F.map(d=>e.jsxs(l.CommandItem,{value:`${d.value} ${d.label}`,onSelect:()=>{x(!0),P(d.value),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:d.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:d.value})]},d.value))}),e.jsx(l.CommandSeparator,{}),e.jsx(l.CommandGroup,{heading:"All timezones",children:p.map(d=>e.jsxs(l.CommandItem,{value:d,onSelect:()=>{x(!0),P(d),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d?"opacity-100":"opacity-0")}),d]},d))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Week starts on"}),e.jsx(l.RadioGroup,{value:String(v),onValueChange:d=>{x(!0),N(Number(d))},className:"flex gap-4",disabled:f,children:B.map(d=>e.jsxs("label",{htmlFor:`week-start-${d.value}`,className:u.cn("flex cursor-pointer items-center gap-2 text-[13px]",f&&"cursor-not-allowed"),children:[e.jsx(l.RadioGroupItem,{value:String(d.value),id:`week-start-${d.value}`,disabled:f}),d.label]},d.value))})]})]})]}),e.jsxs(l.DialogFooter,{children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:_,disabled:z,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:O,disabled:$,children:z?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})}function Y(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(r=>r.actions.applyResolvedValueFormatPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,g=o.useRef(i);g.current=i;const[S,b]=o.useState(null),[C,f]=o.useState(!1),[j,T]=o.useState(!1),[x,w]=o.useState(!1),[P,v]=o.useState(null);o.useEffect(()=>{b(null),v(null),f(!1),T(!1),w(!1)},[i]);const N=o.useCallback(async r=>{const n=L.parseValueFormatPreferencesResponse(await r.json());if(!n.ok)throw new Error("Value format preferences response is invalid");return n.value},[]),k=o.useCallback(async(r,n)=>{if(!i||!h)throw new Error("Not authenticated");const y=await fetch(`${h}/v1/user-preferences/value-format`,{method:r,headers:{Authorization:`Bearer ${i}`,...n?{"Content-Type":"application/json"}:{}},body:n?JSON.stringify(n):void 0});if(!y.ok){const D=await y.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}return N(y)},[i,h,N]),E=o.useCallback(async()=>{if(!s||!i||!h)return;const r=i;f(!0),v(null);try{const n=await k("GET");g.current===r&&b(n)}catch(n){g.current===r&&v(n instanceof Error?n.message:"Unknown error")}finally{g.current===r&&f(!1)}},[i,h,s,k]);o.useEffect(()=>{s&&E()},[s,E]);const A=o.useCallback(async r=>{const n=i;T(!0),v(null);try{const y=await k("PATCH",r);return g.current!==n?!1:(b(y),m(y.resolved,y.sources),!0)}catch(y){return g.current===n&&v(y instanceof Error?y.message:"Unknown error"),!1}finally{g.current===n&&T(!1)}},[i,m,k]),p=o.useCallback(async()=>{const r=i;w(!0),v(null);try{const n=await k("DELETE");return g.current!==r?!1:(b(n),m(n.resolved,n.sources),!0)}catch(n){return g.current===r&&v(n instanceof Error?n.message:"Unknown error"),!1}finally{g.current===r&&w(!1)}},[i,m,k]);return{preferences:S,isLoading:C,isSaving:j,isClearing:x,error:P,updatePreferences:A,clearPreferences:p,refetch:E}}const I=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function q(a,c){var t,m;switch(c){case"locale":return a==null?void 0:a.locale;case"dateStyle":return a==null?void 0:a.dateStyle;case"dateTime.dateStyle":return(t=a==null?void 0:a.dateTime)==null?void 0:t.dateStyle;case"dateTime.timeStyle":return(m=a==null?void 0:a.dateTime)==null?void 0:m.timeStyle;case"defaultCurrency":return a==null?void 0:a.defaultCurrency}}function Z(a){var m,s;const c=(m=a==null?void 0:a.dateTime)==null?void 0:m.dateStyle,t=(s=a==null?void 0:a.dateTime)==null?void 0:s.timeStyle;return{locale:a==null?void 0:a.locale,dateStyle:a==null?void 0:a.dateStyle,dateTime:c===void 0&&t===void 0?void 0:{dateStyle:c,timeStyle:t},defaultCurrency:a==null?void 0:a.defaultCurrency}}function Q({active:a,onClose:c}){var g,S,b,C,f,j,T;const{preferences:t,isLoading:m,isSaving:s,updatePreferences:i}=Y({enabled:a});if(!a)return null;if(!t)return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:m?"Loading preferences…":"Preferences unavailable."})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",disabled:!0,children:"Save"})]})]})]});const h=[((g=t.stored)==null?void 0:g.locale)??"",((S=t.stored)==null?void 0:S.dateStyle)??"",((C=(b=t.stored)==null?void 0:b.dateTime)==null?void 0:C.dateStyle)??"",((j=(f=t.stored)==null?void 0:f.dateTime)==null?void 0:j.timeStyle)??"",((T=t.stored)==null?void 0:T.defaultCurrency)??""].join(":");return e.jsx(X,{preferences:t,isSaving:s,updatePreferences:i,onClose:c},h)}function X({preferences:a,isSaving:c,updatePreferences:t,onClose:m}){var b,C;const[s,i]=o.useState(()=>Z(a.stored)),h=(s.locale===void 0||L.canonicalizeSupportedLocale(s.locale)!==void 0)&&(s.defaultCurrency===void 0||L.canonicalizeSupportedCurrencyCode(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((b=s.dateTime)==null?void 0:b.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((C=s.dateTime)==null?void 0:C.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),g=async()=>{const f={...s.locale!==void 0?{locale:s.locale}:{},...s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{},...s.dateTime?{dateTime:{...s.dateTime}}:{},...s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{}},j=I.filter(w=>q(s,w)===void 0&&q(a.stored,w)!==void 0),T={...Object.keys(f).length>0?{set:f}:{},...j.length>0?{clear:j}:{}};(Object.keys(T).length===0?!0:await t(T))?(l.ue.success("Display format preferences saved."),m()):l.ue.error("Failed to save preferences. Please try again.")},S=async()=>{await t({clear:[...I]})?(l.ue.success("Display format preferences reset."),m()):l.ue.error("Failed to reset display format preferences. Please try again.")};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.DisplayFormatPreferencesFields,{value:s,inherited:a.inherited,inheritedSources:a.inheritedSources,onChange:i,disabled:c})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",onClick:S,disabled:c||a.stored===null,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:m,disabled:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:g,disabled:c||!h,children:c?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]})}function ee({open:a,onOpenChange:c}){const[t,m]=o.useState("display"),s=()=>c(!1);return e.jsx(l.Dialog,{open:a,onOpenChange:c,children:e.jsxs(l.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{className:"text-[15px]",children:"Report preferences"}),e.jsx(l.DialogDescription,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),e.jsxs(u.Tabs,{value:t,onValueChange:m,children:[e.jsxs(u.TabsList,{variant:"underline",className:"w-full justify-start",children:[e.jsx(u.TabsTrigger,{value:"display",children:"Display formats"}),e.jsx(u.TabsTrigger,{value:"calendar",children:"Calendar"})]}),e.jsx(u.TabsContent,{value:"display",children:e.jsx(Q,{active:a&&t==="display",onClose:s})}),e.jsx(u.TabsContent,{value:"calendar",children:e.jsx(J,{active:a&&t==="calendar",onClose:s})})]})]})})}exports.ReportPreferencesDialog=ee;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),l=require("./index-DIWJALWL.cjs"),u=require("./switch-D-CCcfhc.cjs"),V=require("./report-runtime-context-DqxS4wbi.cjs");require("./x-B6ghREd2.cjs");require("./saved-temporal-bucket-format-CFfWXRl9.cjs");require("./validators-BDYprKI9.cjs");require("./analyze-result-contract-LPDNldic.cjs");const L=require("../value-format-preferences/index.cjs");function G(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(p=>p.actions.applyResolvedCalendarPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,[g,S]=o.useState(!1),[b,C]=o.useState(!1),[f,j]=o.useState(!1),[T,x]=o.useState(null),[w,P]=o.useState(null),v=o.useRef(i);v.current=i,o.useEffect(()=>{P(null),x(null),S(!1),C(!1),j(!1)},[i]);const N=o.useCallback(async p=>{const r=V.parseCalendarPreferencesResponse(await p.json());if(!r.ok)throw new Error("Calendar preferences response is invalid");return r.value},[]),k=o.useCallback(async()=>{if(!s||!i||!h)return;const p=i;S(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to fetch preferences")}const n=await N(r);v.current===p&&P(n)}catch(r){v.current===p&&x(r instanceof Error?r.message:"Unknown error")}finally{v.current===p&&S(!1)}},[i,h,s,N]);o.useEffect(()=>{s&&k()},[s,k]);const E=o.useCallback(async p=>{if(!i||!h)return x("Not authenticated"),!1;const r=i;C(!0),x(null);try{const n=await fetch(`${h}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(p)});if(!n.ok){const D=await n.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}const y=await N(n);return v.current!==r?!1:(P(y),m(y.resolved,y.sources),!0)}catch(n){return v.current===r&&x(n instanceof Error?n.message:"Unknown error"),!1}finally{v.current===r&&C(!1)}},[i,h,m,N]),A=o.useCallback(async()=>{if(!i||!h)return x("Not authenticated"),!1;const p=i;j(!0),x(null);try{const r=await fetch(`${h}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${i}`}});if(!r.ok){const y=await r.json().catch(()=>({}));throw new Error(y.error||"Failed to clear preferences")}const n=await N(r);return v.current!==p?!1:(P(n),m(n.resolved,n.sources),!0)}catch(r){return v.current===p&&x(r instanceof Error?r.message:"Unknown error"),!1}finally{v.current===p&&j(!1)}},[i,h,m,N]);return{preferences:w,isLoading:g,isSaving:b,isClearing:f,error:T,updatePreferences:E,clearPreferences:A,refetch:k}}const F=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],B=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],R="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function W(){try{const a=Intl;if(a.supportedValuesOf)return a.supportedValuesOf("timeZone")}catch{}return F.map(a=>a.value)}function H(a){if(!a)return"default";if(a.tz!==a.weekStart)return"inherited";switch(a.tz){case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"system_default":return"system";case"session_initial":return"embedded";default:return"default"}}function U(a){const c=F.find(t=>t.value===a);return c?c.label:a}function K(a){const c=B.find(t=>t.value===a);return c?c.label:String(a)}function J({active:a,onClose:c}){const{preferences:t,isLoading:m,isSaving:s,isClearing:i,updatePreferences:h,clearPreferences:g}=G({enabled:a}),S=l.useCalendarContext(),b=(t==null?void 0:t.resolved.tz)||(S==null?void 0:S.tz)||"UTC",C=(t==null?void 0:t.resolved.weekStart)??(S==null?void 0:S.weekStart)??1,[f,j]=o.useState((t==null?void 0:t.stored)===null),[T,x]=o.useState(!1),[w,P]=o.useState(b),[v,N]=o.useState(C),[k,E]=o.useState(!1),A=o.useMemo(()=>W(),[]),p=o.useMemo(()=>A.filter(d=>!F.some(M=>M.value===d)),[A]),r=o.useMemo(()=>U(w),[w]),n=t!=null&&t.inherited?U(t.inherited.tz):"UTC",y=t!=null&&t.inherited?K(t.inherited.weekStart):"Monday",D=H(t==null?void 0:t.inheritedSources);o.useEffect(()=>{if(!a){x(!1);return}T||(t&&j(t.stored===null),P(b),N(C))},[a,T,t,b,C]);const O=async()=>{if(m){l.ue.error("Preferences are still loading. Please try again.");return}f?await g()?(l.ue.success("Now using default settings."),c()):l.ue.error("Failed to save preferences. Please try again."):await h({tz:w,weekStart:v})?(l.ue.success("Preferences saved."),c()):l.ue.error("Failed to save preferences. Please try again.")},_=()=>{c()},z=s||i,$=z||m;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(l.RadioGroup,{value:f?"defaults":"custom",onValueChange:d=>{x(!0),j(d==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",f&&"bg-muted/50"),onClick:()=>{x(!0),j(!0)},children:[e.jsx(l.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",D," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[n,", week starts ",y]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:u.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!f&&"bg-muted/50"),onClick:()=>{x(!0),j(!1)},children:[e.jsx(l.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:u.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",f&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Timezone"}),e.jsxs(u.Popover,{open:k,onOpenChange:E,modal:!0,children:[e.jsx(u.PopoverTrigger,{asChild:!0,children:e.jsxs(u.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":k,className:"w-full justify-between text-[12px] font-normal",disabled:f,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(l.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(u.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(l.Command,{className:"overflow-visible",children:[e.jsx(l.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(l.CommandList,{children:[e.jsx(l.CommandEmpty,{children:"No timezone found."}),e.jsx(l.CommandGroup,{heading:"Common",children:F.map(d=>e.jsxs(l.CommandItem,{value:`${d.value} ${d.label}`,onSelect:()=>{x(!0),P(d.value),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:d.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:d.value})]},d.value))}),e.jsx(l.CommandSeparator,{}),e.jsx(l.CommandGroup,{heading:"All timezones",children:p.map(d=>e.jsxs(l.CommandItem,{value:d,onSelect:()=>{x(!0),P(d),E(!1)},children:[e.jsx(u.Check,{className:u.cn("h-3.5 w-3.5",w===d?"opacity-100":"opacity-0")}),d]},d))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u.Label,{className:R,children:"Week starts on"}),e.jsx(l.RadioGroup,{value:String(v),onValueChange:d=>{x(!0),N(Number(d))},className:"flex gap-4",disabled:f,children:B.map(d=>e.jsxs("label",{htmlFor:`week-start-${d.value}`,className:u.cn("flex cursor-pointer items-center gap-2 text-[13px]",f&&"cursor-not-allowed"),children:[e.jsx(l.RadioGroupItem,{value:String(d.value),id:`week-start-${d.value}`,disabled:f}),d.label]},d.value))})]})]})]}),e.jsxs(l.DialogFooter,{children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:_,disabled:z,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:O,disabled:$,children:z?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})}function Y(a={}){const{authToken:c,tokenProps:t}=l.useSemaphorContext(),m=u.useDashboardStore(r=>r.actions.applyResolvedValueFormatPreferences),s=a.enabled??!0,i=(c==null?void 0:c.accessToken)??null,h=(t==null?void 0:t.apiServiceUrl)??null,g=o.useRef(i);g.current=i;const[S,b]=o.useState(null),[C,f]=o.useState(!1),[j,T]=o.useState(!1),[x,w]=o.useState(!1),[P,v]=o.useState(null);o.useEffect(()=>{b(null),v(null),f(!1),T(!1),w(!1)},[i]);const N=o.useCallback(async r=>{const n=L.parseValueFormatPreferencesResponse(await r.json());if(!n.ok)throw new Error("Value format preferences response is invalid");return n.value},[]),k=o.useCallback(async(r,n)=>{if(!i||!h)throw new Error("Not authenticated");const y=await fetch(`${h}/v1/user-preferences/value-format`,{method:r,headers:{Authorization:`Bearer ${i}`,...n?{"Content-Type":"application/json"}:{}},body:n?JSON.stringify(n):void 0});if(!y.ok){const D=await y.json().catch(()=>({}));throw new Error(D.error||"Failed to update preferences")}return N(y)},[i,h,N]),E=o.useCallback(async()=>{if(!s||!i||!h)return;const r=i;f(!0),v(null);try{const n=await k("GET");g.current===r&&b(n)}catch(n){g.current===r&&v(n instanceof Error?n.message:"Unknown error")}finally{g.current===r&&f(!1)}},[i,h,s,k]);o.useEffect(()=>{s&&E()},[s,E]);const A=o.useCallback(async r=>{const n=i;T(!0),v(null);try{const y=await k("PATCH",r);return g.current!==n?!1:(b(y),m(y.resolved,y.sources),!0)}catch(y){return g.current===n&&v(y instanceof Error?y.message:"Unknown error"),!1}finally{g.current===n&&T(!1)}},[i,m,k]),p=o.useCallback(async()=>{const r=i;w(!0),v(null);try{const n=await k("DELETE");return g.current!==r?!1:(b(n),m(n.resolved,n.sources),!0)}catch(n){return g.current===r&&v(n instanceof Error?n.message:"Unknown error"),!1}finally{g.current===r&&w(!1)}},[i,m,k]);return{preferences:S,isLoading:C,isSaving:j,isClearing:x,error:P,updatePreferences:A,clearPreferences:p,refetch:E}}const I=["locale","dateStyle","dateTime.dateStyle","dateTime.timeStyle","defaultCurrency"];function q(a,c){var t,m;switch(c){case"locale":return a==null?void 0:a.locale;case"dateStyle":return a==null?void 0:a.dateStyle;case"dateTime.dateStyle":return(t=a==null?void 0:a.dateTime)==null?void 0:t.dateStyle;case"dateTime.timeStyle":return(m=a==null?void 0:a.dateTime)==null?void 0:m.timeStyle;case"defaultCurrency":return a==null?void 0:a.defaultCurrency}}function Z(a){var m,s;const c=(m=a==null?void 0:a.dateTime)==null?void 0:m.dateStyle,t=(s=a==null?void 0:a.dateTime)==null?void 0:s.timeStyle;return{locale:a==null?void 0:a.locale,dateStyle:a==null?void 0:a.dateStyle,dateTime:c===void 0&&t===void 0?void 0:{dateStyle:c,timeStyle:t},defaultCurrency:a==null?void 0:a.defaultCurrency}}function Q({active:a,onClose:c}){var g,S,b,C,f,j,T;const{preferences:t,isLoading:m,isSaving:s,updatePreferences:i}=Y({enabled:a});if(!a)return null;if(!t)return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx("div",{className:"flex min-h-36 items-center justify-center text-[12px] text-muted-foreground",children:m?"Loading preferences…":"Preferences unavailable."})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",disabled:!0,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",disabled:!0,children:"Save"})]})]})]});const h=[((g=t.stored)==null?void 0:g.locale)??"",((S=t.stored)==null?void 0:S.dateStyle)??"",((C=(b=t.stored)==null?void 0:b.dateTime)==null?void 0:C.dateStyle)??"",((j=(f=t.stored)==null?void 0:f.dateTime)==null?void 0:j.timeStyle)??"",((T=t.stored)==null?void 0:T.defaultCurrency)??""].join(":");return e.jsx(X,{preferences:t,isSaving:s,updatePreferences:i,onClose:c},h)}function X({preferences:a,isSaving:c,updatePreferences:t,onClose:m}){var b,C;const[s,i]=o.useState(()=>Z(a.stored)),h=(s.locale===void 0||L.canonicalizeSupportedLocale(s.locale)!==void 0)&&(s.defaultCurrency===void 0||L.canonicalizeSupportedCurrencyCode(s.defaultCurrency)!==void 0)&&(s.dateStyle===void 0||["short","medium","long"].includes(s.dateStyle))&&(((b=s.dateTime)==null?void 0:b.dateStyle)===void 0||["short","medium","long"].includes(s.dateTime.dateStyle))&&(((C=s.dateTime)==null?void 0:C.timeStyle)===void 0||["short","medium","long"].includes(s.dateTime.timeStyle)),g=async()=>{const f={...s.locale!==void 0?{locale:s.locale}:{},...s.dateStyle!==void 0?{dateStyle:s.dateStyle}:{},...s.dateTime?{dateTime:{...s.dateTime}}:{},...s.defaultCurrency!==void 0?{defaultCurrency:s.defaultCurrency}:{}},j=I.filter(w=>q(s,w)===void 0&&q(a.stored,w)!==void 0),T={...Object.keys(f).length>0?{set:f}:{},...j.length>0?{clear:j}:{}};(Object.keys(T).length===0?!0:await t(T))?(l.ue.success("Display format preferences saved."),m()):l.ue.error("Failed to save preferences. Please try again.")},S=async()=>{await t({clear:[...I]})?(l.ue.success("Display format preferences reset."),m()):l.ue.error("Failed to reset display format preferences. Please try again.")};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"py-2",children:e.jsx(l.DisplayFormatPreferencesFields,{value:s,inherited:a.inherited,inheritedSources:a.inheritedSources,onChange:i,disabled:c})}),e.jsxs(l.DialogFooter,{className:"justify-between sm:justify-between",children:[e.jsx(u.Button,{variant:"ghost",size:"xs",onClick:S,disabled:c||a.stored===null,children:"Reset display formats"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u.Button,{variant:"outline",size:"xs",onClick:m,disabled:c,children:"Cancel"}),e.jsx(u.Button,{size:"xs",onClick:g,disabled:c||!h,children:c?e.jsxs(e.Fragment,{children:[e.jsx(u.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})]})}function ee({open:a,onOpenChange:c}){const[t,m]=o.useState("display"),s=()=>c(!1);return e.jsx(l.Dialog,{open:a,onOpenChange:c,children:e.jsxs(l.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(l.DialogHeader,{children:[e.jsx(l.DialogTitle,{className:"text-[15px]",children:"Report preferences"}),e.jsx(l.DialogDescription,{className:"text-[13px] leading-5",children:"Set how values and Calendar periods appear for you."})]}),e.jsxs(u.Tabs,{value:t,onValueChange:m,children:[e.jsxs(u.TabsList,{variant:"underline",className:"w-full justify-start",children:[e.jsx(u.TabsTrigger,{value:"display",children:"Display formats"}),e.jsx(u.TabsTrigger,{value:"calendar",children:"Calendar"})]}),e.jsx(u.TabsContent,{value:"display",children:e.jsx(Q,{active:a&&t==="display",onClose:s})}),e.jsx(u.TabsContent,{value:"calendar",children:e.jsx(J,{active:a&&t==="calendar",onClose:s})})]})]})})}exports.ReportPreferencesDialog=ee;
|
package/dist/chunks/{report-preferences-dialog-BNV7qXYH.js → report-preferences-dialog-CFenWkcH.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as o, Fragment as j, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import oe, { useState as S, useRef as X, useEffect as U, useCallback as E, useMemo as _ } from "react";
|
|
3
|
-
import { az as ee, aA as ce, aB as B, aC as $, aD as de, h as ue, i as me, j as fe, k as he, l as M, m as H, aE as ve, aF as V, aG as z, b as ye, aH as pe, aI as ge, aJ as Se, aK as be, aL as Te } from "./index-
|
|
4
|
-
import { u as ae, c as F, O as W, P as we, a as Ce, B as L, b as ke, d as q, L as te, T as xe, F as Ne, G, I as K } from "./switch-
|
|
5
|
-
import { a as Pe } from "./report-runtime-context-
|
|
3
|
+
import { az as ee, aA as ce, aB as B, aC as $, aD as de, h as ue, i as me, j as fe, k as he, l as M, m as H, aE as ve, aF as V, aG as z, b as ye, aH as pe, aI as ge, aJ as Se, aK as be, aL as Te } from "./index-B5Oy1eLv.js";
|
|
4
|
+
import { u as ae, c as F, O as W, P as we, a as Ce, B as L, b as ke, d as q, L as te, T as xe, F as Ne, G, I as K } from "./switch-BeZW-HnS.js";
|
|
5
|
+
import { a as Pe } from "./report-runtime-context-SM6YO61_.js";
|
|
6
6
|
import "./x-CXDkqdur.js";
|
|
7
|
-
import "./saved-temporal-bucket-format-
|
|
8
|
-
import "./validators-
|
|
9
|
-
import "./analyze-result-contract-
|
|
7
|
+
import "./saved-temporal-bucket-format-SGAV0ivR.js";
|
|
8
|
+
import "./validators-DEmd8Sin.js";
|
|
9
|
+
import "./analyze-result-contract-BbRJ-C06.js";
|
|
10
10
|
import { parseValueFormatPreferencesResponse as Ae, canonicalizeSupportedLocale as Ee, canonicalizeSupportedCurrencyCode as ze } from "../value-format-preferences/index.js";
|
|
11
11
|
function Le(e = {}) {
|
|
12
12
|
const { authToken: i, tokenProps: a } = ee(), d = ae(
|
package/dist/chunks/{report-runtime-context-DjYqLV-c.cjs → report-runtime-context-DqxS4wbi.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const p=require("../value-format-preferences/index.cjs"),f=require("./validators-
|
|
1
|
+
"use strict";const p=require("../value-format-preferences/index.cjs"),f=require("./validators-BDYprKI9.cjs"),g={tz:"UTC",weekStart:1,anchor:"now"},b=["tz","weekStart","anchor","fiscalCalendar"],E=["kind","yearStartMonth"],w=["calendar","valueFormat","preferenceSources"],T=["calendar","valueFormat"],y=["tz","weekStart"],F=["stored","inherited","inheritedSources","resolved","sources"],z=["locale","dateStyle","dateTime","defaultCurrency"],R=["dateStyle","timeStyle"];function o(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const a=Object.getPrototypeOf(e);return a===null||Object.getPrototypeOf(a)===null}function n(e,a,r){const t=new Set(a);return Object.keys(e).filter(s=>!t.has(s)).map(s=>({path:r==="$"?s:`${r}.${s}`,code:"unknown_property",message:`Unknown property "${s}"`}))}function _(e){return Number.isInteger(e)&&typeof e=="number"&&e>=0&&e<=6}function d(e,a,r){if(!o(e))return{ok:!1,issues:[{path:a,code:"invalid_type",message:"Calendar preferences must be an object"}]};const t=n(e,["tz","weekStart"],a);return(!r||e.tz!==void 0)&&(typeof e.tz!="string"||!f.isValidIanaTimeZone(e.tz))&&t.push({path:`${a}.tz`,code:"invalid_timezone",message:"tz must be a valid IANA timezone"}),(!r||e.weekStart!==void 0)&&!_(e.weekStart)&&t.push({path:`${a}.weekStart`,code:"invalid_week_start",message:"weekStart must be an integer from 0 to 6"}),t.length?{ok:!1,issues:t}:{ok:!0,value:{...e.tz!==void 0?{tz:e.tz}:{},...e.weekStart!==void 0?{weekStart:e.weekStart}:{}}}}function A(e){if(e==="now")return{ok:!0,value:"now"};if(!o(e))return{ok:!1,issues:[{path:"anchor",code:"invalid_anchor",message:'anchor must be "now" or an object with an ISO timestamp'}]};const a=n(e,["iso"],"anchor"),r=e.iso;return f.parseSemaphorIsoInstant(r)===null&&a.push({path:"anchor.iso",code:"invalid_anchor",message:"anchor.iso must be an ISO timestamp with an explicit offset"}),a.length?{ok:!1,issues:a}:{ok:!0,value:{iso:r}}}function O(e){if(!o(e))return{ok:!1,issues:[{path:"fiscalCalendar",code:"invalid_fiscal_calendar",message:"fiscalCalendar must be an object"}]};const a=n(e,E,"fiscalCalendar");return e.kind!=="month_aligned"&&a.push({path:"fiscalCalendar.kind",code:"invalid_fiscal_calendar",message:'fiscalCalendar.kind must be "month_aligned"'}),(!Number.isInteger(e.yearStartMonth)||typeof e.yearStartMonth!="number"||e.yearStartMonth<1||e.yearStartMonth>12)&&a.push({path:"fiscalCalendar.yearStartMonth",code:"invalid_fiscal_calendar",message:"fiscalCalendar.yearStartMonth must be an integer from 1 to 12"}),a.length?{ok:!1,issues:a}:{ok:!0,value:{kind:"month_aligned",yearStartMonth:e.yearStartMonth}}}function C(e){if(!o(e))return{ok:!1,issues:[{path:"$",code:"invalid_type",message:"Calendar context must be an object"}]};const a=n(e,b,"$");(typeof e.tz!="string"||!f.isValidIanaTimeZone(e.tz))&&a.push({path:"tz",code:"invalid_timezone",message:"tz must be a valid IANA timezone"}),_(e.weekStart)||a.push({path:"weekStart",code:"invalid_week_start",message:"weekStart must be an integer from 0 to 6"});const r=A(e.anchor);r.ok||a.push(...r.issues);let t;if(e.fiscalCalendar!==void 0){const s=O(e.fiscalCalendar);s.ok?t=s.value:a.push(...s.issues)}return a.length||!r.ok?{ok:!1,issues:a}:{ok:!0,value:{tz:e.tz,weekStart:e.weekStart,anchor:r.value,...t?{fiscalCalendar:t}:{}}}}function l(e,a,r){if(!p.isReportPreferenceSource(e)){r.push({path:a,code:"invalid_preference_source",message:"Preference source is invalid"});return}return e}function k(e,a){if(!o(e))return{ok:!1,issues:[{path:a,code:"invalid_type",message:"Calendar preference sources must be an object"}]};const r=n(e,y,a),t=l(e.tz,`${a}.tz`,r),s=l(e.weekStart,`${a}.weekStart`,r);return r.length||!t||!s?{ok:!1,issues:r}:{ok:!0,value:{tz:t,weekStart:s}}}function $(e){if(!o(e))return{ok:!1,issues:[{path:"$",code:"invalid_type",message:"Calendar preference response must be an object"}]};const a=n(e,F,"$"),r=e.stored===null?{ok:!0,value:null}:d(e.stored,"stored",!0),t=d(e.inherited,"inherited",!1),s=k(e.inheritedSources,"inheritedSources"),c=d(e.resolved,"resolved",!1),i=k(e.sources,"sources");for(const u of[r,t,s,c,i])u.ok||a.push(...u.issues);return a.length||!r.ok||!t.ok||!s.ok||!c.ok||!i.ok?{ok:!1,issues:a}:{ok:!0,value:{stored:r.value,inherited:t.value,inheritedSources:s.value,resolved:c.value,sources:i.value}}}function P(e){if(!o(e))return{ok:!1,issues:[{path:"preferenceSources",code:"invalid_type",message:"preferenceSources must be an object"}]};const a=n(e,T,"preferenceSources"),r=e.calendar,t=e.valueFormat;if(o(r)||a.push({path:"preferenceSources.calendar",code:"invalid_type",message:"Calendar preference sources must be an object"}),o(t)||a.push({path:"preferenceSources.valueFormat",code:"invalid_type",message:"Value-format preference sources must be an object"}),!o(r)||!o(t))return{ok:!1,issues:a};a.push(...n(r,y,"preferenceSources.calendar"),...n(t,z,"preferenceSources.valueFormat"));const s=t.dateTime;o(s)?a.push(...n(s,R,"preferenceSources.valueFormat.dateTime")):a.push({path:"preferenceSources.valueFormat.dateTime",code:"invalid_type",message:"Datetime preference sources must be an object"});const c=l(r.tz,"preferenceSources.calendar.tz",a),i=l(r.weekStart,"preferenceSources.calendar.weekStart",a),u=l(t.locale,"preferenceSources.valueFormat.locale",a),m=l(t.dateStyle,"preferenceSources.valueFormat.dateStyle",a),S=o(s)?l(s.dateStyle,"preferenceSources.valueFormat.dateTime.dateStyle",a):void 0,v=o(s)?l(s.timeStyle,"preferenceSources.valueFormat.dateTime.timeStyle",a):void 0,h=l(t.defaultCurrency,"preferenceSources.valueFormat.defaultCurrency",a);return a.length||!c||!i||!u||!m||!S||!v||!h?{ok:!1,issues:a}:{ok:!0,value:{calendar:{tz:c,weekStart:i},valueFormat:{locale:u,dateStyle:m,dateTime:{dateStyle:S,timeStyle:v},defaultCurrency:h}}}}function j(e){var t;const a=p.parseValueFormatPreferences(e);if(!a.ok)return{ok:!1,issues:a.issues.map(s=>({path:`valueFormat.${s.path}`,code:"invalid_value_format",message:s.message}))};const r=a.value;return r.locale===void 0||r.dateStyle===void 0||((t=r.dateTime)==null?void 0:t.dateStyle)===void 0||r.dateTime.timeStyle===void 0||r.defaultCurrency===void 0?{ok:!1,issues:[{path:"valueFormat",code:"invalid_value_format",message:"Resolved value-format preferences must be complete"}]}:{ok:!0,value:{locale:r.locale,dateStyle:r.dateStyle,dateTime:{dateStyle:r.dateTime.dateStyle,timeStyle:r.dateTime.timeStyle},defaultCurrency:r.defaultCurrency}}}function N(e){if(!o(e))return{ok:!1,issues:[{path:"$",code:"invalid_type",message:"Report runtime context must be an object"}]};const a=n(e,w,"$"),r=C(e.calendar),t=j(e.valueFormat),s=P(e.preferenceSources);return r.ok||a.push(...r.issues.map(c=>({...c,path:c.path==="$"?"calendar":`calendar.${c.path}`}))),t.ok||a.push(...t.issues),s.ok||a.push(...s.issues),a.length||!r.ok||!t.ok||!s.ok?{ok:!1,issues:a}:{ok:!0,value:{calendar:r.value,valueFormat:t.value,preferenceSources:s.value}}}exports.DEFAULT_CALENDAR_CONTEXT=g;exports.parseCalendarContext=C;exports.parseCalendarPreferencesResponse=$;exports.parseReportRuntimeContext=N;
|