react-semaphor 0.1.470 → 0.1.471
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/README.md +10 -0
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DEVbQCQE.js → dashboard-briefing-launcher-C2-b7rZU.js} +5 -5
- package/dist/chunks/dashboard-briefing-launcher-ChHmLu0F.cjs +26 -0
- package/dist/chunks/{dashboard-controls-DPK-CRWL.js → dashboard-controls-Db7VOHdj.js} +4 -4
- package/dist/chunks/{dashboard-controls-8D1m_ECN.cjs → dashboard-controls-kw4QQDSz.cjs} +1 -1
- package/dist/chunks/dashboard-filter-value-compatibility-Dmh-NaPK.cjs +1 -0
- package/dist/chunks/dashboard-filter-value-compatibility-ilbH2A31.js +836 -0
- package/dist/chunks/{dashboard-json-DhKOoHwK.cjs → dashboard-json-Cu37kF4Q.cjs} +1 -1
- package/dist/chunks/{dashboard-json-DVWLTmIJ.js → dashboard-json-Dp-38lll.js} +2 -2
- package/dist/chunks/{edit-dashboard-visual-B6zidwTu.cjs → edit-dashboard-visual-Cbtpwhlp.cjs} +33 -33
- package/dist/chunks/{edit-dashboard-visual-CxEC3bPx.js → edit-dashboard-visual-CffII05Z.js} +3609 -3711
- package/dist/chunks/{editor-action-buttons-B3S00DsB.cjs → editor-action-buttons-DcTGZa2C.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-HfJ-Bohl.js → editor-action-buttons-DqwDHxFv.js} +2 -2
- package/dist/chunks/{index-tsB3LfTQ.js → index-CUf0lwSP.js} +24201 -24259
- package/dist/chunks/{index-DVBYvkj0.cjs → index-DUYREWSl.cjs} +227 -227
- package/dist/chunks/{pivot-header-presentation-BW0Ay7WV.js → pivot-header-presentation-7XrwJYDm.js} +101 -94
- package/dist/chunks/pivot-header-presentation-Cr6pU5JL.cjs +4 -0
- package/dist/chunks/{report-preferences-dialog-DvNWNrlj.cjs → report-preferences-dialog-BEe2cTT-.cjs} +1 -1
- package/dist/chunks/{report-preferences-dialog-D-VpoQJz.js → report-preferences-dialog-C_FTOmOg.js} +2 -2
- package/dist/chunks/{switch-NAbuOQNg.cjs → switch-CQN9Hzho.cjs} +19 -19
- package/dist/chunks/{switch-DnbD-yCM.js → switch-n2yUNY8i.js} +383 -370
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +71 -68
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -6
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/format-utils.d.ts +9 -0
- package/package.json +1 -1
- package/dist/chunks/dashboard-briefing-launcher-exfJnSop.cjs +0 -26
- package/dist/chunks/dashboard-filter-value-compatibility-BAaqJGjt.js +0 -692
- package/dist/chunks/dashboard-filter-value-compatibility-CYrWe1U6.cjs +0 -1
- package/dist/chunks/pivot-header-presentation-DVBTHug2.cjs +0 -4
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var H=Object.defineProperty;var L=(e,n,t)=>n in e?H(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var N=(e,n,t)=>L(e,typeof n!="symbol"?n+"":n,t);const f=require("./validators-DcshgK7w.cjs");require("./analyze-result-contract-OgPk-zGu.cjs");require("../value-format-preferences/index.cjs");function p(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function k(e){return p(e)&&typeof e.name=="string"}function F(e){return!p(e)||e.kind!=="semantic"&&e.kind!=="physical"||(e.kind==="semantic"?[e.datasetId,e.datasetName,e.connectionId]:[e.databaseName,e.schemaName]).some(t=>t!==void 0&&typeof t!="string")?!1:f.hasCompleteSemaphorSourceIdentity(e)}function v(e,n){var c,o;if((n==null?void 0:n.mode)!=="database"&&e.type==="dataset"&&"domainId"in e&&e.domainId){const s=e,d={kind:"semantic",domainId:s.domainId,datasetId:f.getSemaphorDatasetEntityId(s),datasetName:s.name,connectionId:s.connectionId||(n==null?void 0:n.connectionId),label:s.label};return F(d)?f.canonicalizeSemaphorSourceIdentity(d):void 0}const t=e.connectionId||(n==null?void 0:n.connectionId),a=e.type==="dataset"&&"table"in e&&e.table?e.table:e.name;if(!t||!a)return;const i={kind:"physical",connectionId:t,connectionType:e.connectionType||(n==null?void 0:n.connectionType),tableName:a,databaseName:e.database||((c=n==null?void 0:n.dbSelection)==null?void 0:c.database),schemaName:e.schema||((o=n==null?void 0:n.dbSelection)==null?void 0:o.schema),dialect:e.dialect};return F(i)?i:void 0}function V(e,n){var s,d;const t=v(e,n);if(!t)return;const a=e.type==="dataset"&&"table"in e&&typeof e.table=="string"?e.table.trim():void 0,i=t.kind==="physical"?t.tableName:a,c=e.connectionId||(n==null?void 0:n.connectionId),o=i&&c?{connectionId:c,databaseName:e.database||((s=n==null?void 0:n.dbSelection)==null?void 0:s.database),schemaName:e.schema||((d=n==null?void 0:n.dbSelection)==null?void 0:d.schema),tableName:i}:void 0;return{source:t,...o?{executionTable:o}:{}}}function x(e){const n=p(e.dataSource)?e.dataSource:void 0;if(typeof e.sql=="string"&&e.sql.trim()){const o=[],s=Array.isArray(n==null?void 0:n.selectedEntities)?n.selectedEntities:[];for(const d of s){if(!k(d))continue;const r=V(d,n);r&&!o.some(T=>f.semaphorSourcesReferToSameDataset(T.source,r.source))&&o.push(r)}return{cardId:e.id,kind:"sql",pinnedCatalogSources:o}}if(!p(e.config))return{cardId:e.id,kind:"unconfigured"};const t=[],a=p(e.config.matrixIntent)?e.config.matrixIntent:void 0,i=e.type==="matrixTable"?(a==null?void 0:a.kind)==="matrix"?a.source:e.config.source:void 0;F(i)&&t.push(i);const c=p(e.config.joinPlan)?e.config.joinPlan:void 0;if(c){const o=Array.isArray(c.joins)?c.joins:[],s=[c.baseEntity];for(const d of o)p(d)&&s.push(d.source,d.target);for(const d of s){if(!k(d))continue;const r=v(d,n);r&&t.push(r)}}else if(e.type!=="matrixTable"){const o=Array.isArray(n==null?void 0:n.selectedEntities)?n.selectedEntities:[];if(o.length===1&&k(o[0])){const s=v(o[0],n);s&&t.push(s)}}if(!t.length&&!c&&e.type!=="matrixTable"){const o=e.config.queryBaseSource;F(o)&&t.push(o)}return{cardId:e.id,kind:"config",executableSources:f.mergeSemaphorSourcesByIdentity(t)}}function w(e,n){return(e.kind==="config"?e.executableSources:e.kind==="sql"?e.pinnedCatalogSources.map(a=>a.source):[]).some(a=>f.semaphorSourcesReferToSameDataset(a,n))}function U(e,n){if(e.kind==="config")return e.executableSources.find(t=>f.semaphorSourcesReferToSameDataset(t,n))}function W(e,n){var t;return(t=C(e,n))==null?void 0:t.source}function C(e,n){if(e.kind==="sql")return e.pinnedCatalogSources.find(t=>f.semaphorSourcesReferToSameDataset(t.source,n))}function R(e){const n=new Set;for(const t of[e.name,e.sourceField]){if(!t)continue;const a=f.normalizeAnalyticsCatalogName(t);if(!a)continue;n.add(a);const i=a.split("."),c=i[i.length-1];c&&n.add(c)}return n}function z(e,n){const t=f.normalizeAnalyticsCatalogDataType(e),a=f.normalizeAnalyticsCatalogDataType(n);return t==="unknown"||a==="unknown"?!1:(t==="date"||t==="datetime")&&(a==="date"||a==="datetime")?!0:t===a}function K(e,n){return f.semaphorSourcesReferToSameDataset(e.field.source,n.field.source)&&f.normalizeAnalyticsCatalogName(e.field.name)===f.normalizeAnalyticsCatalogName(n.field.name)&&f.normalizeAnalyticsCatalogName(e.field.sourceField||e.field.name)===f.normalizeAnalyticsCatalogName(n.field.sourceField||n.field.name)}function P(e,n){if(e.kind!=="field")return!1;const t=R(n),a=R(e.field);return z(n.dataType,e.field.dataType)&&[...a].some(i=>t.has(i))}function Y(e){const n=e.candidates.filter(t=>P(t,e.logicalValueField));return n.length===1?{status:"matched",target:n[0]}:n.length>1?{status:"ambiguous"}:{status:"notApplicable"}}function G(e){const n=[];for(const t of e.acceptedTargets)!z(e.logicalValueField.dataType,t.field.dataType)||n.some(a=>K(a,t))||n.push(t);return n.length===1?{status:"matched",target:n[0]}:n.length>1?{status:"ambiguous"}:{status:"notApplicable"}}const J=/\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i,Q=/\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i,X=/\bwhere\b/i;function B(e){return e!=null&&e.trim()?J.test(e)||Q.test(e):!1}function Z(e){return!(e!=null&&e.trim())||B(e)?null:X.test(e)?{helper:"{{ filters | and }}",description:"For queries with an existing WHERE clause."}:{helper:"{{ filters | where }}",description:"For queries without a WHERE clause."}}function ee(e){return(e.field.sourceField||e.field.name).trim()||void 0}function ne(e){if(e.inventory.kind!=="sql"||e.target.kind!=="field")return{status:"ineligible"};const n=C(e.inventory,e.target.field.source),t=ee(e.target);if(!n||!t)return{status:"ineligible"};if(n.executionTable){const o=[n.executionTable.databaseName,n.executionTable.schemaName,n.executionTable.tableName,t].filter(Boolean).join(".");return{status:"eligible",source:n.source,executionIdentifier:o}}if(e.inventory.pinnedCatalogSources.length!==1)return{status:"ineligible"};const a=f.normalizeAnalyticsCatalogName(t),i=(e.candidateTargets||[]).filter(o=>f.normalizeAnalyticsCatalogName(o.field.sourceField||o.field.name)===a),c=[];for(const o of i)c.some(s=>f.semaphorSourcesReferToSameDataset(s,o.field.source))||c.push(o.field.source);return c.length>1?{status:"ineligible"}:{status:"eligible",source:n.source,executionIdentifier:t}}class j extends Error{constructor(t){super(t.map(a=>a.message).join(" "));N(this,"issues");this.name="DashboardFilterMappingContractError",this.issues=t}}const te={string:!0,number:!0,boolean:!0,date:!0,datetime:!0};function b(e){return typeof e=="string"&&e.trim().length>0}function m(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){return Array.isArray(e)&&e.every(n=>typeof n=="string")}function ie(e){if(!m(e))return!1;switch(e.kind){case"allSheets":return e.sheetKinds===void 0||I(e.sheetKinds)&&e.sheetKinds.every(n=>n==="dashboard"||n==="document");case"sheets":return I(e.sheetIds);case"cards":return I(e.cardIds);case"documentSections":return b(e.sheetId)&&I(e.sectionIds);default:return!1}}function re(e){return e==="shared"||e==="perSheet"||e==="perCard"||e==="perDocumentSection"}function se(e){return m(e)?b(e.id)&&b(e.column)&&b(e.dataType):!1}function oe(e,n,t,a){var s;if(!m(n)){a.push({code:"invalid_option_source",path:t,message:`${t} must be a semantic or physical option source.`,inputId:e});return}const i=n.source,c=[["labelField",n.labelField],["valueField",n.valueField],["searchField",n.searchField]];if(!m(i)||i.kind!=="semantic"&&i.kind!=="physical"||!f.hasCompleteSemaphorSourceIdentity(i)||!m(n.labelField)||!m(n.valueField)||n.searchField!==void 0&&!m(n.searchField)||n.disambiguationFields!==void 0&&(!Array.isArray(n.disambiguationFields)||!n.disambiguationFields.every(m))){a.push({code:"invalid_option_source",path:t,message:`${t} must contain a valid semantic or physical source and field references.`,inputId:e});return}for(const[d,r]of c)r!==void 0&&m(r)&&(!b(r.name)||r.source!==void 0&&!f.semaphorSourcesReferToSameDataset(r.source,i))&&a.push({code:"invalid_option_source",path:`${t}.${d}`,message:`${t}.${d} must be a named field belonging to the declared option source.`,inputId:e});for(const[d,r]of((s=n.disambiguationFields)==null?void 0:s.entries())||[])(!m(r)||!b(r.name)||r.source!==void 0&&!f.semaphorSourcesReferToSameDataset(r.source,i))&&a.push({code:"invalid_option_source",path:`${t}.disambiguationFields[${d}]`,message:`${t}.disambiguationFields[${d}] must be a named field belonging to the declared option source.`,inputId:e});const o=n.valueField;["string","number","boolean","date","datetime"].includes(String(o.dataType))||a.push({code:"invalid_option_source",path:`${t}.valueField.dataType`,message:`${t}.valueField.dataType must be a known option-value datatype.`,inputId:e})}function ae(e,n,t,a,i,c){var r;if(b(n.bindingId)||i.push({code:"invalid_binding_id",path:`${t}.bindingId`,message:`${t}.bindingId must be an opaque non-empty id.`,inputId:e,cardId:n.cardId}),((r=n.target)==null?void 0:r.kind)!=="field"){i.push({code:"unsupported_target",path:`${t}.target`,message:`${t}.target must be one direct field target.`,inputId:e,cardId:n.cardId,bindingId:n.bindingId});return}const o=n.target.field;if(!b(o==null?void 0:o.name)||!o.source||o.source.kind!=="semantic"&&o.source.kind!=="physical"||!f.hasCompleteSemaphorSourceIdentity(o.source)){i.push({code:"invalid_target_field",path:`${t}.target.field`,message:`${t}.target.field must have a name and a source-qualified semantic or physical identity.`,inputId:e,cardId:n.cardId,bindingId:n.bindingId});return}if(Object.prototype.hasOwnProperty.call(te,o.dataType)||i.push({code:"unknown_target_data_type",path:`${t}.target.field.dataType`,message:`${t}.target.field.dataType must be known.`,inputId:e,cardId:n.cardId,bindingId:n.bindingId}),o.sourceField!==void 0&&!b(o.sourceField)&&i.push({code:"invalid_target_field",path:`${t}.target.field.sourceField`,message:`${t}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,inputId:e,cardId:n.cardId,bindingId:n.bindingId}),!c)return;const s=a.get(n.cardId);if(!s){i.push({code:"unknown_card",path:`${t}.cardId`,message:`${t}.cardId '${n.cardId}' does not exist.`,inputId:e,cardId:n.cardId,bindingId:n.bindingId});return}const d=x(s);(d.kind==="unconfigured"||!w(d,o.source))&&i.push({code:"unavailable_card_source",path:`${t}.target.field.source`,message:`${t}.target field source is not declared by card '${s.id}'.`,inputId:e,cardId:s.id,bindingId:n.bindingId})}function de(e,n,t,a,i,c){if(n===void 0)return;if(!m(n)||n.kind!=="cardMappings"||!Array.isArray(n.cards)){i.push({code:"invalid_application",path:t,message:`${t} must be a cardMappings application with a cards array.`,inputId:e});return}const o=new Set;n.cards.forEach((s,d)=>{const r=`${t}.cards[${d}]`;if(!b(s==null?void 0:s.cardId)){i.push({code:"unknown_card",path:`${r}.cardId`,message:`${r}.cardId is required.`,inputId:e});return}if(o.has(s.cardId)){i.push({code:"duplicate_card_application",path:`${r}.cardId`,message:`${t} contains more than one entry for card '${s.cardId}'.`,inputId:e,cardId:s.cardId});return}if(o.add(s.cardId),c&&!a.has(s.cardId)){i.push({code:"unknown_card",path:`${r}.cardId`,message:`${r}.cardId '${s.cardId}' does not exist.`,inputId:e,cardId:s.cardId});return}s.kind==="bound"?ae(e,s,r,a,i,c):s.kind!=="excluded"&&i.push({code:"invalid_application",path:r,message:`${r}.kind must be 'bound' or 'excluded'.`,inputId:e,cardId:s.cardId})})}function q({inputs:e,dashboardFilters:n,cards:t=[],validateCardTargets:a=!1}){const i=[],c=new Map((n||[]).map(r=>[r.id,r])),o=new Map(a?t.map(r=>[r.id,r]):[]),s=[],d=new Map;return e!=null&&!Array.isArray(e)?(i.push({code:"invalid_input",path:"dashboard.inputs",message:"dashboard.inputs must be an array when present."}),{ok:!1,inputs:s,issues:i}):((Array.isArray(e)?e:[]).forEach((r,T)=>{const u=`dashboard.inputs[${T}]`;if(!m(r)||r.kind!=="filter"&&r.kind!=="control"||!b(r.id)||!b(r.label)||!b(r.variableName)||!ie(r.scope)||!re(r.runtimeScope)){i.push({code:"invalid_input",path:u,message:`${u} must be a complete filter or control Dashboard Input envelope.`,inputId:m(r)&&typeof r.id=="string"?r.id:void 0});return}if(r.kind==="control"&&!m(r.control)){i.push({code:"invalid_input",path:`${u}.control`,message:`${u}.control must be a control definition.`,inputId:r.id});return}const l=r;if(l.kind==="control"){s.push(l);return}const $=l.filter,g=l.filterReference,y=$!==void 0,E=!!g;if(y&&E){i.push({code:"both_filter_definitions",path:u,message:`${u} must contain either filter or filterReference, not both.`,inputId:l.id});return}if(!y&&!E){i.push({code:"missing_filter_definition",path:u,message:`${u} must contain filter or filterReference.`,inputId:l.id});return}if(y&&!se($)){i.push({code:"invalid_input",path:`${u}.filter`,message:`${u}.filter must be a complete dashboard filter definition.`,inputId:l.id});return}let h,_;if(y)h=$,_="embedded";else{if((g==null?void 0:g.kind)!=="dashboardFilter"){i.push({code:"invalid_filter_reference",path:`${u}.filterReference.kind`,message:`${u}.filterReference.kind must be 'dashboardFilter'.`,inputId:l.id});return}const D=typeof(g==null?void 0:g.filterId)=="string"?g.filterId:void 0;if(h=D?c.get(D):void 0,_="dashboardFilter",!h){i.push({code:"orphaned_filter_reference",path:`${u}.filterReference.filterId`,message:`${u}.filterReference cannot resolve dashboard filter '${D||""}'.`,inputId:l.id});return}if(h.kind==="global-date"){i.push({code:"global_date_reference",path:`${u}.filterReference`,message:`${u}.filterReference cannot reference the Global Date filter.`,inputId:l.id});return}const A=d.get(h.id);if(A){i.push({code:"duplicate_filter_reference",path:`${u}.filterReference.filterId`,message:`${u}.filterReference duplicates dashboard filter '${h.id}' already owned by Dashboard Input '${A}'.`,inputId:l.id});return}d.set(h.id,l.id)}if(!h)return;if(l.optionSource!==void 0&&oe(l.id,l.optionSource,`${u}.optionSource`,i),l.application&&h.kind==="global-date"){i.push({code:"global_date_reference",path:`${u}.application`,message:`${u}.application cannot map the Global Date filter.`,inputId:l.id});return}l.application&&l.scope.kind!=="allSheets"&&l.scope.kind!=="sheets"&&i.push({code:"unsupported_mapped_scope",path:`${u}.scope`,message:`${u}.scope must be allSheets or sheets when cardMappings are present.`,inputId:l.id}),de(l.id,l.application,`${u}.application`,o,i,a);const{filter:me,filterReference:be,compatibility:S,...O}=l;s.push({...O,filter:h,...y&&S?{compatibility:S}:{},...l.optionSource?{optionSource:l.optionSource}:{},definitionOrigin:_})}),i.length?{ok:!1,inputs:s,issues:i}:{ok:!0,inputs:s})}function ce(e){const n=q(e);if(!n.ok)throw new j(n.issues);return n.inputs}function le(e=()=>globalThis.crypto.randomUUID()){return e()}const ue={date:new Set(["between","not between","=","!=",">",">=","<","<=","is null","is not null"]),number:new Set(["between","not between","=","!=",">",">=","<","<=","in","not in","is null","is not null"]),string:new Set(["=","!=","in","not in","like","not like","is null","is not null"]),boolean:new Set(["=","!=","in","not in","is null","is not null"])};function M(e){const n=f.normalizeAnalyticsCatalogDataType(e);return n==="number"||n==="boolean"?n:n==="date"||n==="datetime"?"date":"string"}function fe(e,n){return typeof n!="string"?!1:ue[M(e)].has(n)}exports.DashboardFilterMappingContractError=j;exports.buildDashboardCardSourceIndex=x;exports.createDashboardFilterBindingId=le;exports.dashboardCardFilterSourceInventoryContains=w;exports.dashboardFilterTargetMatchesLogicalValue=P;exports.dashboardFilterValueTypeForDataType=M;exports.findDashboardCardExecutableSource=U;exports.findDashboardCardPinnedCatalogSource=W;exports.findDashboardSqlPinnedCatalogSource=C;exports.getDashboardFilterSubscriptionHint=Z;exports.hasDashboardFilterSubscription=B;exports.isDashboardFilterOperationCompatible=fe;exports.normalizeDashboardInputs=q;exports.requireNormalizedDashboardInputs=ce;exports.resolveDashboardFilterAutomaticTarget=Y;exports.resolveDashboardFilterInheritedTarget=G;exports.resolveDashboardSqlFilterTarget=ne;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-DJgO2P0H.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./temporal-bucket-9Wz9Ds6H.cjs");function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function X(e){return c.constructFrom(e,Date.now())}function H(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function Y(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function q(e,t){return+c.toDate(e)-+c.toDate(t)}function W(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function J(e){const t=c.toDate(e);return+W(t)==+K(t)}function Q(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(H(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;J(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function z(e,t,n){const o=q(e,t)/1e3;return Y(n==null?void 0:n.roundingMethod)(o)}function ee(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=z(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=Q(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function C(e,t){return ee(e,X(e),t)}const I=["day","hour","minute","second","millisecond"],L={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},te={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},ne={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function re(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function V(e,t){return re(e)?e:t}function S(e,t){return I.indexOf(V(e,t))}function oe(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return I.slice(r,a+1)}function ae(e,t){return e*L[V(t,"second")]}function se(e,t){const n=oe(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=L[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=L[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function ie(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${te[a.unit]}`).join(" ")}function le(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=ne[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ce(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function ue(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(ae(n,o)),s=se(i,t),l=r==="digital"?ce(s):r==="long"?le(s,t.maxUnits):ie(s,t.maxUnits);return ue(l,a,t)}function fe(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function p(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:fe(e,t,n)}}function v(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function N(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function me(e,t){const n={mode:t.displayMode,current:p(e.currentValue,t.metricFormat,t.locale),comparison:p(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=p(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=v(e.percentChange,N(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=v(e.ratio,N(t.precision,2),t.locale,"ratio")),n}function ge(e,t){return e&&e!=="auto"?e:t}function de(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function he(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const Me="MM/dd/yyyy",ye=(e,t,n,o="auto")=>{if(!e)return"";try{const r=T(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:Me).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},De=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:C(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function R(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
|
|
2
|
-
`)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function $(e,t=","){return e.map(n=>R(n,t)).join(t)}function _(e,t={}){const{delimiter:n=",",lineEnding:o=`
|
|
3
|
-
`}=t;return e.map(r=>$(r,n)).join(o)}function be(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:o=`
|
|
4
|
-
`,includeHeaders:r=!0,columns:a}=t,i=a||Object.keys(e[0]),s=[];r&&s.push(i);for(const l of e){const u=i.map(g=>{const m=l[g];return m==null?"":String(m)});s.push(u)}return _(s,{delimiter:n,lineEnding:o})}const F="__TOTAL__";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e){return e===F}function we(e){const t=new Map,n=(e.groupByColumns??[]).map((r,a)=>{var u,g,m;if(!D(r))throw new Error(`Aggregate groupByColumns[${a}] is invalid`);const i=typeof r.id=="string"&&r.id.length>0?r.id:void 0,s=i?(m=(g=(u=e.columnKeyMap)==null?void 0:u.byRole)==null?void 0:g.groupby)==null?void 0:m[i]:void 0,l=(s==null?void 0:s.outputKey)||(s==null?void 0:s.rawKey)||(typeof r.alias=="string"&&r.alias.length>0?r.alias:typeof r.name=="string"&&r.name.length>0?r.name:void 0);if(!l)throw new Error(`Aggregate groupByColumns[${a}] has no output key`);return[i,r.alias,r.name,l].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,l)}),l}),o=(e.rowAggregates??[]).flatMap(r=>!D(r)||typeof r.function!="string"||typeof r.groupLevel!="string"?[]:[{function:r.function,groupLevel:r.groupLevel==="ALL"?"ALL":t.get(r.groupLevel)||r.groupLevel,...typeof r.label=="string"?{label:r.label}:{}}]);return{groupColumnKeys:n,rowAggregates:o}}function P(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function U(e){var n;if(e.customLabel)return e.customLabel;const t=P(e.aggregateFunction);if(e.levelValue!==void 0&&!b(e.levelValue)){if(e.levelValue===null){const r=(n=e.formatValue)==null?void 0:n.call(e,null);return r?`Subtotal ${r}`:`Subtotal ${t}`}const o=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(o)return`Subtotal (${o})`}return`Subtotal ${t}`}function O(e,t){return t||`Grand ${P(e)}`}function x(e){var o,r;const t=e.context.groupColumnKeys,n=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const a=(o=e.context.rowAggregates.find(i=>i.groupLevel==="ALL"))==null?void 0:o.label;return{kind:"grand-total",cells:t.map((i,s)=>({columnKey:i,text:s===0?O(n,a):"",placement:s===0?"label":"empty",colSpan:s===0?t.length:1}))}}if(e.row.isSubtotal===!0){if(typeof e.row.subtotalLevel!="string")throw new Error("Aggregate subtotal row is missing subtotalLevel");const a=t.indexOf(e.row.subtotalLevel);if(a<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const i=D(e.row.subtotalContext)?e.row.subtotalContext:void 0,s=D(i==null?void 0:i.groupByValues)?i.groupByValues:{},l=(r=e.context.rowAggregates.find(u=>u.groupLevel===e.row.subtotalLevel&&u.function===n))==null?void 0:r.label;return{kind:"subtotal",cells:t.map((u,g)=>{if(g>a)return{columnKey:u,text:"",placement:"empty",colSpan:1};if(g<a){const m=e.row[u];return{columnKey:u,text:m===void 0||b(m)?"":e.formatValue(m,u),placement:"value",colSpan:1}}return{columnKey:u,text:U({aggregateFunction:n,customLabel:l,levelValue:s[u],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,u):String(e.formatValue(m,u)??"")}),placement:"label",colSpan:t.length-a}})}}return{kind:"data",cells:t.map(a=>{const i=e.row[a];return{columnKey:a,text:i===void 0||b(i)?"":e.formatValue(i,a),placement:"value",colSpan:1}})}}function pe(e){const t=x(e).cells.find(n=>n.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Le(e){return x(e).cells.map(t=>t.text)}class Z extends Error{constructor(n,o){super(`${n}: ${o}`);A(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError"}}function Te(e){var r;const t=e.mode??"formatted",n=e.members.map(a=>{var s;if(t==="canonical"||!a.temporalBucket)return a.value===null?"":String(a.value);const i=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,a.fieldId);if(!i)throw new Z("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${a.fieldId}"`);return j.formatTemporalBucket({value:a.value,metadata:a.temporalBucket,format:i})}),o=((r=e.metricLabel)==null?void 0:r.trim())||void 0;return{memberLabels:n,...o?{metricLabel:o}:{},flattenedLabel:[...n,...o?[o]:[]].join(" / ")}}exports.AGGREGATE_TOTAL_MEMBER_MARKER=F;exports.PivotHeaderPresentationError=Z;exports.arrayToCSV=_;exports.arrayToCSVRow=$;exports.escapeCSVValue=R;exports.formatAggregateGrandTotalLabel=O;exports.formatAggregateGroupCell=pe;exports.formatAggregateGroupRow=Le;exports.formatAggregateSubtotalLabel=U;exports.formatDate=ye;exports.formatDistanceToNow=C;exports.formatDuration=E;exports.formatMetricComparison=me;exports.formatRelativeTime=De;exports.getTimezoneAbbreviation=de;exports.getTimezoneName=he;exports.isAggregateTotalMemberMarker=b;exports.objectsToCSV=be;exports.parseWithSourceTimezone=T;exports.presentAggregateGroupRow=x;exports.presentPivotHeader=Te;exports.resolveAggregateTablePresentationContext=we;exports.resolveTimezone=ge;
|