@holistics/anfra-sdk 0.25.0-rc.1 → 0.25.0-rc.2
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/api.d.ts +1 -1
- package/dist/app.d.ts +5 -5
- package/dist/app.js +2 -2
- package/dist/{bootstrap-CwJOl1um.d.ts → bootstrap-Bte507aH.d.ts} +3 -3
- package/dist/build.d.ts +2 -2
- package/dist/{chunk-KYYUVUTI.js → chunk-FWP6LU4D.js} +1 -1
- package/dist/{chunk-SXMFP3VD.js → chunk-WCRSI7ZB.js} +1 -1
- package/dist/{chunk-EEVYUAN3.js → chunk-XF2OX24G.js} +1 -1
- package/dist/common.d.ts +3 -3
- package/dist/declaration.js +1 -0
- package/dist/{errors-BPMEaMlH.d.ts → errors-x9pGAmXi.d.ts} +1 -1
- package/dist/host.d.ts +2 -2
- package/dist/host.js +1 -1
- package/dist/{overview-SWHBQMBY.js → overview-EQPGLWMO.js} +2 -2
- package/dist/{plugin-B-Ordph_.d.ts → plugin-BWEDh1nW.d.ts} +2 -2
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +11 -5
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/{theme-Don0p5bX.d.ts → theme-CIkvL5kZ.d.ts} +1 -1
- package/dist/{types-MrmVSxfu.d.ts → types-ks7G6AVA.d.ts} +29 -5
- package/package.json +5 -3
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from 'openapi-fetch';
|
|
2
|
-
import { aG as paths, aF as components } from './types-
|
|
2
|
+
import { aG as paths, aF as components } from './types-ks7G6AVA.js';
|
|
3
3
|
import { DatasetDescriptor, Backend, BackendExportRequest, BackendQueryRequest } from './app.js';
|
|
4
4
|
import { DataAppError } from './app.js';
|
|
5
5
|
|
package/dist/app.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { S as Sdk } from './bootstrap-
|
|
2
|
-
export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuEntry, f as FrameMenuItem, I as InstalledPlugins, M as Mapping, g as ModalInput, O as OVERLAY_ID, h as Opened, i as PluginApi, j as PluginMembers, k as PluginName, P as PluginSetup, l as PopoverInput, m as PopoverSide, Q as Query, n as STRUCTURE_ATTRIBUTES, V as VERSION, o as bootstrap, p as buildStructure, q as createSdk, r as parseRef } from './bootstrap-
|
|
3
|
-
export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-
|
|
4
|
-
export { A as Aggregation, a as Annotation, b as AnnotationInput, c as AnnotationKind, d as AnnotationSeverity, e as AppDeclaration, f as AppJson, g as ArrowType, B as Backend, h as BackendCondition, i as BackendDateDrill, j as BackendExportRequest, k as BackendFilter, l as BackendLineageRequest, m as BackendQueryRequest, n as BackendQueryResult, o as BackendSort, C as CallStamp, p as ColumnMeta, q as Condition, r as ConditionValue, s as ControlMappingJson, t as CrossFilterJson, D as DatasetDescriptor, u as DatasetRelationship, v as DateDrillDeclaration, w as DateGrain, x as DateTransformation, E as EntityKind, y as EntityRef, z as EntityUsage, F as ExecuteOptions, G as ExecuteSummary, H as ExportFormat, I as ExportFormatOptions, J as ExportOptions, K as ExportResult, L as FILTER_AGGREGATIONS, M as FieldLineage, N as FieldSuggestionsRequest, O as FilterAggregation, P as FilterDeclaration, Q as FilterValueType, R as InspectedApp, S as InspectedControl, T as InspectedError, U as InspectedQuery, V as InspectedSelection, W as InspectedStructure, X as LineageCard, Y as LineageDiagram, Z as LineageNode, _ as LineageOptions, $ as LineageResult, a0 as LineageTarget, a1 as Listener, a2 as LocateKind, a3 as LocateTarget, a4 as MappingJson, a5 as Operator, a6 as QueryCacheResult, a7 as QueryCacheSettings, a8 as QueryDebug, a9 as QueryDeclaration, aa as QueryInput, ab as QueryInputDefaults, ac as QueryPagination, ad as QueryPivot, ae as QueryRequest, af as QueryResult, ag as QuerySeeds, ah as QuerySort, ai as QueryStamp, aj as QueryState, ak as QueryTimings, al as RangeAnchor, am as RenderFormat, an as RenderRequest, ao as Rendering, ap as ResolvedRowsAnchor, aq as Row, ar as RowsAnchor, as as SdkEnvironment, at as SdkFeatures, au as Selection, av as SelectionCondition, aw as SemanticType, ax as SeriesAnchor, ay as SeriesPoint, az as StructureKind, aA as StructureNode, aB as Unsubscribe, aC as User, aD as ValueAnchor, aE as WeekStartDay } from './types-
|
|
1
|
+
import { S as Sdk } from './bootstrap-Bte507aH.js';
|
|
2
|
+
export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuEntry, f as FrameMenuItem, I as InstalledPlugins, M as Mapping, g as ModalInput, O as OVERLAY_ID, h as Opened, i as PluginApi, j as PluginMembers, k as PluginName, P as PluginSetup, l as PopoverInput, m as PopoverSide, Q as Query, n as STRUCTURE_ATTRIBUTES, V as VERSION, o as bootstrap, p as buildStructure, q as createSdk, r as parseRef } from './bootstrap-Bte507aH.js';
|
|
3
|
+
export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-x9pGAmXi.js';
|
|
4
|
+
export { A as Aggregation, a as Annotation, b as AnnotationInput, c as AnnotationKind, d as AnnotationSeverity, e as AppDeclaration, f as AppJson, g as ArrowType, B as Backend, h as BackendCondition, i as BackendDateDrill, j as BackendExportRequest, k as BackendFilter, l as BackendLineageRequest, m as BackendQueryRequest, n as BackendQueryResult, o as BackendSort, C as CallStamp, p as ColumnMeta, q as Condition, r as ConditionValue, s as ControlMappingJson, t as CrossFilterJson, D as DatasetDescriptor, u as DatasetRelationship, v as DateDrillDeclaration, w as DateGrain, x as DateTransformation, E as EntityKind, y as EntityRef, z as EntityUsage, F as ExecuteOptions, G as ExecuteSummary, H as ExportFormat, I as ExportFormatOptions, J as ExportOptions, K as ExportResult, L as FILTER_AGGREGATIONS, M as FieldLineage, N as FieldSuggestionsRequest, O as FilterAggregation, P as FilterDeclaration, Q as FilterValueType, R as InspectedApp, S as InspectedControl, T as InspectedError, U as InspectedQuery, V as InspectedSelection, W as InspectedStructure, X as LineageCard, Y as LineageDiagram, Z as LineageNode, _ as LineageOptions, $ as LineageResult, a0 as LineageTarget, a1 as Listener, a2 as LocateKind, a3 as LocateTarget, a4 as MappingJson, a5 as Operator, a6 as QueryCacheResult, a7 as QueryCacheSettings, a8 as QueryDebug, a9 as QueryDeclaration, aa as QueryInput, ab as QueryInputDefaults, ac as QueryPagination, ad as QueryPivot, ae as QueryRequest, af as QueryResult, ag as QuerySeeds, ah as QuerySort, ai as QueryStamp, aj as QueryState, ak as QueryTimings, al as RangeAnchor, am as RenderFormat, an as RenderRequest, ao as Rendering, ap as ResolvedRowsAnchor, aq as Row, ar as RowsAnchor, as as SdkEnvironment, at as SdkFeatures, au as Selection, av as SelectionCondition, aw as SemanticType, ax as SeriesAnchor, ay as SeriesPoint, az as StructureKind, aA as StructureNode, aB as Unsubscribe, aC as User, aD as ValueAnchor, aE as WeekStartDay } from './types-ks7G6AVA.js';
|
|
5
5
|
export { A as AppConsoleEvent, a as AppErrorEvent, b as AppErrorKind } from './runtimeErrors-gswksjDk.js';
|
|
6
|
-
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetPoint, h as TargetRect, i as Theme, j as ThemeInput, k as ThemeScheme, l as ThemeToken, m as ThemeTokens, n as checkTarget, o as designTheme, r as resolveTheme } from './theme-
|
|
6
|
+
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetPoint, h as TargetRect, i as Theme, j as ThemeInput, k as ThemeScheme, l as ThemeToken, m as ThemeTokens, n as checkTarget, o as designTheme, r as resolveTheme } from './theme-CIkvL5kZ.js';
|
|
7
7
|
|
|
8
8
|
declare const SANDBOX_GLOBAL = "Anfra";
|
|
9
9
|
/**
|
package/dist/app.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createSdk,
|
|
23
23
|
installSandbox,
|
|
24
24
|
parseRef
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-WCRSI7ZB.js";
|
|
26
26
|
import {
|
|
27
27
|
FILTER_AGGREGATIONS
|
|
28
28
|
} from "./chunk-XIUFHRZE.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
designTheme,
|
|
36
36
|
resolveTheme
|
|
37
37
|
} from "./chunk-RXPNL7UR.js";
|
|
38
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-FWP6LU4D.js";
|
|
39
39
|
import "./chunk-GPBYPSWK.js";
|
|
40
40
|
import {
|
|
41
41
|
DataAppError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DataAppError, V as ValidationError, k as invalidRequest, h as forbidden, g as connectionFailed, f as callFailed, i as fromHttpStatus, j as hasErrorCode, l as isDataAppError } from './errors-
|
|
2
|
-
import { a1 as Listener, aB as Unsubscribe, D as DatasetDescriptor, J as ExportOptions, K as ExportResult, an as RenderRequest, ao as Rendering, a0 as LineageTarget, _ as LineageOptions, $ as LineageResult, E as EntityKind, q as Condition, P as FilterDeclaration, B as Backend, Q as FilterValueType, r as ConditionValue, v as DateDrillDeclaration, w as DateGrain, O as FilterAggregation, t as CrossFilterJson, s as ControlMappingJson, ab as QueryInputDefaults, at as SdkFeatures, au as Selection, av as SelectionCondition, aq as Row, F as ExecuteOptions, G as ExecuteSummary, a2 as LocateKind, aa as QueryInput, a9 as QueryDeclaration, a7 as QueryCacheSettings, ah as QuerySort, aj as QueryState, af as QueryResult, a as Annotation, b as AnnotationInput, W as InspectedStructure, ae as QueryRequest, C as CallStamp, e as AppDeclaration, aE as WeekStartDay, j as BackendExportRequest, f as AppJson, R as InspectedApp, aC as User, as as SdkEnvironment } from './types-
|
|
3
|
-
import { d as MenuTargetKind, c as MenuTarget, N as NodeTarget, R as RowsTarget, e as PluginInfo, k as ThemeScheme, m as ThemeTokens, i as Theme } from './theme-
|
|
1
|
+
import { D as DataAppError, V as ValidationError, k as invalidRequest, h as forbidden, g as connectionFailed, f as callFailed, i as fromHttpStatus, j as hasErrorCode, l as isDataAppError } from './errors-x9pGAmXi.js';
|
|
2
|
+
import { a1 as Listener, aB as Unsubscribe, D as DatasetDescriptor, J as ExportOptions, K as ExportResult, an as RenderRequest, ao as Rendering, a0 as LineageTarget, _ as LineageOptions, $ as LineageResult, E as EntityKind, q as Condition, P as FilterDeclaration, B as Backend, Q as FilterValueType, r as ConditionValue, v as DateDrillDeclaration, w as DateGrain, O as FilterAggregation, t as CrossFilterJson, s as ControlMappingJson, ab as QueryInputDefaults, at as SdkFeatures, au as Selection, av as SelectionCondition, aq as Row, F as ExecuteOptions, G as ExecuteSummary, a2 as LocateKind, aa as QueryInput, a9 as QueryDeclaration, a7 as QueryCacheSettings, ah as QuerySort, aj as QueryState, af as QueryResult, a as Annotation, b as AnnotationInput, W as InspectedStructure, ae as QueryRequest, C as CallStamp, e as AppDeclaration, aE as WeekStartDay, j as BackendExportRequest, f as AppJson, R as InspectedApp, aC as User, as as SdkEnvironment } from './types-ks7G6AVA.js';
|
|
3
|
+
import { d as MenuTargetKind, c as MenuTarget, N as NodeTarget, R as RowsTarget, e as PluginInfo, k as ThemeScheme, m as ThemeTokens, i as Theme } from './theme-CIkvL5kZ.js';
|
|
4
4
|
|
|
5
5
|
interface NotificationTarget {
|
|
6
6
|
notifyChange(): void;
|
package/dist/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FrameHalf } from './host.js';
|
|
2
|
-
import './types-
|
|
3
|
-
import './theme-
|
|
2
|
+
import './types-ks7G6AVA.js';
|
|
3
|
+
import './theme-CIkvL5kZ.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @holistics/anfra-sdk/build: building an SDK plugin's frame half into the script source a host
|
package/dist/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-
|
|
2
|
-
export { A as Aggregation, a as Annotation, b as AnnotationInput, c as AnnotationKind, d as AnnotationSeverity, e as AppDeclaration, f as AppJson, g as ArrowType, B as Backend, h as BackendCondition, i as BackendDateDrill, j as BackendExportRequest, k as BackendFilter, l as BackendLineageRequest, m as BackendQueryRequest, n as BackendQueryResult, o as BackendSort, C as CallStamp, p as ColumnMeta, q as Condition, r as ConditionValue, s as ControlMappingJson, t as CrossFilterJson, D as DatasetDescriptor, u as DatasetRelationship, v as DateDrillDeclaration, w as DateGrain, x as DateTransformation, E as EntityKind, y as EntityRef, z as EntityUsage, F as ExecuteOptions, G as ExecuteSummary, H as ExportFormat, I as ExportFormatOptions, J as ExportOptions, K as ExportResult, L as FILTER_AGGREGATIONS, M as FieldLineage, N as FieldSuggestionsRequest, O as FilterAggregation, P as FilterDeclaration, Q as FilterValueType, R as InspectedApp, S as InspectedControl, T as InspectedError, U as InspectedQuery, V as InspectedSelection, W as InspectedStructure, X as LineageCard, Y as LineageDiagram, Z as LineageNode, _ as LineageOptions, $ as LineageResult, a0 as LineageTarget, a1 as Listener, a2 as LocateKind, a3 as LocateTarget, a4 as MappingJson, a5 as Operator, a6 as QueryCacheResult, a7 as QueryCacheSettings, a8 as QueryDebug, a9 as QueryDeclaration, aa as QueryInput, ab as QueryInputDefaults, ac as QueryPagination, ad as QueryPivot, ae as QueryRequest, af as QueryResult, ag as QuerySeeds, ah as QuerySort, ai as QueryStamp, aj as QueryState, ak as QueryTimings, al as RangeAnchor, am as RenderFormat, an as RenderRequest, ao as Rendering, ap as ResolvedRowsAnchor, aq as Row, ar as RowsAnchor, as as SdkEnvironment, at as SdkFeatures, au as Selection, av as SelectionCondition, aw as SemanticType, ax as SeriesAnchor, ay as SeriesPoint, az as StructureKind, aA as StructureNode, aB as Unsubscribe, aC as User, aD as ValueAnchor, aE as WeekStartDay } from './types-
|
|
1
|
+
export { A as ApiErrorCode, D as DataAppError, a as DataAppErrorInit, E as ErrorCode, b as ErrorContextEntry, c as ErrorDetails, d as ErrorScope, F as FromHttpStatusOptions, G as GENERIC_CODES, e as GenericCode, V as ValidationError, f as callFailed, g as connectionFailed, h as forbidden, i as fromHttpStatus, j as hasErrorCode, k as invalidRequest, l as isDataAppError } from './errors-x9pGAmXi.js';
|
|
2
|
+
export { A as Aggregation, a as Annotation, b as AnnotationInput, c as AnnotationKind, d as AnnotationSeverity, e as AppDeclaration, f as AppJson, g as ArrowType, B as Backend, h as BackendCondition, i as BackendDateDrill, j as BackendExportRequest, k as BackendFilter, l as BackendLineageRequest, m as BackendQueryRequest, n as BackendQueryResult, o as BackendSort, C as CallStamp, p as ColumnMeta, q as Condition, r as ConditionValue, s as ControlMappingJson, t as CrossFilterJson, D as DatasetDescriptor, u as DatasetRelationship, v as DateDrillDeclaration, w as DateGrain, x as DateTransformation, E as EntityKind, y as EntityRef, z as EntityUsage, F as ExecuteOptions, G as ExecuteSummary, H as ExportFormat, I as ExportFormatOptions, J as ExportOptions, K as ExportResult, L as FILTER_AGGREGATIONS, M as FieldLineage, N as FieldSuggestionsRequest, O as FilterAggregation, P as FilterDeclaration, Q as FilterValueType, R as InspectedApp, S as InspectedControl, T as InspectedError, U as InspectedQuery, V as InspectedSelection, W as InspectedStructure, X as LineageCard, Y as LineageDiagram, Z as LineageNode, _ as LineageOptions, $ as LineageResult, a0 as LineageTarget, a1 as Listener, a2 as LocateKind, a3 as LocateTarget, a4 as MappingJson, a5 as Operator, a6 as QueryCacheResult, a7 as QueryCacheSettings, a8 as QueryDebug, a9 as QueryDeclaration, aa as QueryInput, ab as QueryInputDefaults, ac as QueryPagination, ad as QueryPivot, ae as QueryRequest, af as QueryResult, ag as QuerySeeds, ah as QuerySort, ai as QueryStamp, aj as QueryState, ak as QueryTimings, al as RangeAnchor, am as RenderFormat, an as RenderRequest, ao as Rendering, ap as ResolvedRowsAnchor, aq as Row, ar as RowsAnchor, as as SdkEnvironment, at as SdkFeatures, au as Selection, av as SelectionCondition, aw as SemanticType, ax as SeriesAnchor, ay as SeriesPoint, az as StructureKind, aA as StructureNode, aB as Unsubscribe, aC as User, aD as ValueAnchor, aE as WeekStartDay } from './types-ks7G6AVA.js';
|
|
3
3
|
export { A as AppConsoleEvent, a as AppErrorEvent, b as AppErrorKind } from './runtimeErrors-gswksjDk.js';
|
|
4
|
-
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetPoint, h as TargetRect, i as Theme, j as ThemeInput, k as ThemeScheme, l as ThemeToken, m as ThemeTokens, n as checkTarget, o as designTheme, r as resolveTheme } from './theme-
|
|
4
|
+
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetPoint, h as TargetRect, i as Theme, j as ThemeInput, k as ThemeScheme, l as ThemeToken, m as ThemeTokens, n as checkTarget, o as designTheme, r as resolveTheme } from './theme-CIkvL5kZ.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __anfraDeclaration=(()=>{var C=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Ot=Object.prototype.hasOwnProperty;var It=(r,t,e)=>t in r?C(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var s=(r,t)=>C(r,"name",{value:t,configurable:!0});var Ft=(r,t)=>{for(var e in t)C(r,e,{get:t[e],enumerable:!0})},Mt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $t(t))!Ot.call(r,o)&&o!==e&&C(r,o,{get:()=>t[o],enumerable:!(n=_t(t,o))||n.enumerable});return r};var Qt=r=>Mt(C({},"__esModule",{value:!0}),r);var l=(r,t,e)=>It(r,typeof t!="symbol"?t+"":t,e);var Ln={};Ft(Ln,{fire:()=>Qn,protocol:()=>Tn,read:()=>Nn,setup:()=>Fn,thrown:()=>Mn});var Z=new WeakMap;function Q(r,t){typeof r=="object"&&r!==null&&Z.set(r,t)}s(Q,"tagCall");function ee(r,t){let e=Z.get(r);return e&&Z.set(t,e),t}s(ee,"copyCallTag");var Nt;function T(r,t){try{Nt?.(r,t)}catch{}}s(T,"reportError");var te=class te{constructor(t){l(this,"listeners",new Set);l(this,"parent");this.parent=t}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notifyChange(){this.listeners.forEach(t=>{try{t()}catch(e){console.error("anfra: a subscribe() listener threw; the queries carry on.",e),T("app.listener",e)}}),this.parent?.notifyChange()}notify(){this.notifyChange()}};s(te,"Observable");var k=te;var N=class N extends Error{constructor(e){super(e.message);l(this,"code");l(this,"scope");l(this,"status");l(this,"details");l(this,"context");l(this,"requestId");l(this,"entity");l(this,"cause");this.name=new.target.name,this.code=e.code,this.scope=e.scope,e.status!==void 0&&(this.status=e.status),e.details!==void 0&&(this.details=e.details),e.context!==void 0&&(this.context=e.context),e.requestId!==void 0&&(this.requestId=e.requestId),e.entity!==void 0&&(this.entity=e.entity),e.cause!==void 0&&(this.cause=e.cause),Object.setPrototypeOf(this,new.target.prototype)}about(e){return this.entity===e?this:ee(this,new N({...Lt(this),entity:e}))}};s(N,"DataAppError");var w=N,L=class L extends w{constructor(t,e){super({code:"declaration_invalid",scope:"client",message:t,entity:e})}about(t){return this.entity===t?this:ee(this,new L(this.message,t))}};s(L,"ValidationError");var u=L;function ne(r){if(r instanceof w)return!0;let t=r;return t instanceof Error&&(t.name==="DataAppError"||t.name==="ValidationError")&&typeof t.code=="string"}s(ne,"isDataAppError");function Lt(r){return{code:r.code,scope:r.scope,message:r.message,status:r.status,details:r.details,context:r.context,requestId:r.requestId,entity:r.entity,cause:r.cause}}s(Lt,"fieldsOf");var re=["sum","avg","max","min","count","count distinct","median","stdev","stdevp","var","varp"];function Pt(r,t){let e=r.length+1,n=t.length+1,o=Array.from({length:n},(i,a)=>a);for(let i=1;i<e;i++){let a=[i];for(let d=1;d<n;d++)a[d]=Math.min(o[d]+1,a[d-1]+1,o[d-1]+(r[i-1]===t[d-1]?0:1));o=a}return o[n-1]}s(Pt,"editDistance");function oe(r,t){let e,n=1/0;t.forEach(i=>{let a=Pt(r.toLowerCase(),i.toLowerCase());a<n&&(n=a,e=i)});let o=Math.max(2,Math.floor(r.length/3));return n<=o?e:void 0}s(oe,"suggest");function v(r,t,e){let n=oe(t,e);return n?`${r} Did you mean '${n}'?`:r}s(v,"withSuggestion");var se=class se{constructor(t){l(this,"descriptor");l(this,"fields",new Map);l(this,"references");this.descriptor=t,t.data_models.forEach(e=>{e.fields.forEach(n=>{let o=String(e.name);this.fields.set(`${o}.${n.name}`,{modelName:o,fieldName:n.name,isMetric:!1,type:n.type,label:n.label??n.name})})}),t.metrics.forEach(e=>{this.fields.set(e.name,{fieldName:e.name,isMetric:!0,type:e.type,label:e.label??e.name})}),this.references=[...this.fields.keys()]}resolve(t,e){let n=this.fields.get(t);if(n)return n;throw new u(v(`Unknown field '${t}' on dataset '${this.descriptor.name}'.`,t,this.references),e)}};s(se,"DatasetIndex");var P=se;function je(r,t,e){let n=r[t];if(n)return n;throw new u(v(`Unknown dataset '${t}'.`,t,Object.keys(r)),e)}s(je,"resolveDataset");function Be(r,t){if(!re.includes(r))throw new u(v(`Invalid filter aggregation '${r}'.`,r,[...re]),t)}s(Be,"assertValidFilterAggregation");function qe(r,t,e){if(!t)throw new u(`A ${e} needs a name.`);for(let n of r)if(n===t)throw new u(`'${t}' is already declared in this app.`,t)}s(qe,"assertUniqueName");var jt={ns:1e-6,us:.001,\u00B5s:.001,ms:1,s:1e3,m:6e4,h:36e5},Bt=168*36e5;function qt(r){if(r==="0")return 0;let t=/(\d+(?:\.\d*)?|\.\d+)(ns|us|µs|ms|s|m|h)/y,e=0,n=0;for(let o=t.exec(r);o;o=t.exec(r))e+=parseFloat(o[1])*jt[o[2]],n=t.lastIndex;return n>0&&n===r.length?e:void 0}s(qt,"parseDuration");function R(r,t,e,n){let o=JSON.stringify(e);return n==="sets"?`${r} sets ${t} to ${o}`:`${r} declares ${t} ${o}`}s(R,"gave");var ie=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function j(r,t,e,n="declares"){if(r===void 0||ie.includes(r))return;let o=`${R(t,e,r,n)}.`,i=typeof r=="string"?oe(r.trim(),[...ie]):void 0;if(i)throw new u(`${o} Did you mean ${JSON.stringify(i)}?`);let a=ie.map(d=>JSON.stringify(d));throw new u(`${o} Use one of: ${a.slice(0,-1).join(", ")}, or ${a[a.length-1]}.`)}s(j,"assertWeekStartDay");function B(r,t,e,n,o="declares"){if(r===void 0)return;let i=typeof r=="string"?qt(r):void 0;if(i===void 0)throw new u(`${R(t,e,r,o)}, which isn't a duration. Use one such as 30s, 10m or 2h.`,n);if(i>Bt)throw new u(`${R(t,e,r,o)}, which is over 168h (7 days), the longest a result can be cached.`,n)}s(B,"assertCacheDuration");var Vt=s((r,t)=>JSON.stringify(r??null)===JSON.stringify(t??null),"sameValue"),ae=s((r,t)=>Object.keys(r).every(e=>Vt(r[e],t[e])),"rowMatches");function Ve(r,t){let e=[];for(let[n,o]of r)o.forEach((i,a)=>{let d=`${n}:${i.id??a}`;if(i.kind!=="mark"&&i.kind!=="focus"){e.push({...i,plugin:n,key:d});return}let c=[],p=[];for(let m of i.anchor.rows){let f=!1;t.forEach((h,y)=>{ae(m,h)&&(f=!0,p.includes(y)||p.push(y))}),f&&c.push(m)}p.length&&e.push({...i,anchor:{...i.anchor,rows:c,index:p.sort((m,f)=>m-f)},plugin:n,key:d})});return e}s(Ve,"resolveAnnotations");function le(r,t,e="declares"){if(!t.aql?.trim())throw new u(`Query '${r}' ${e} no AQL.`,r);let{pageSize:n}=t;if(n!==void 0&&!(Number.isInteger(n)&&n>=1))throw new u(`${R(`Query '${r}'`,"pageSize",n,e)}, but it must be a whole number of at least 1.`,r);B(t.cache?.duration,`Query '${r}'`,"cache.duration",r,e)}s(le,"assertDeclaration");var de=class de extends k{constructor(e,n,o,i){super(n);l(this,"kind","query");l(this,"name");l(this,"id");l(this,"_declaration");l(this,"_dataset");l(this,"removed",!1);l(this,"app");l(this,"_state","idle");l(this,"runFailed",!1);l(this,"_result");l(this,"_error");l(this,"_page",1);l(this,"_run");l(this,"_sort",[]);l(this,"resultSuperseded",!1);l(this,"lastRunSignature");l(this,"lastPageRows",0);l(this,"controller");l(this,"runningSignature");l(this,"startedRun");l(this,"failedSignature");l(this,"annotationSets",new Map);l(this,"currentResults",new WeakSet);l(this,"resolvedAnnotations");le(e,o),this.name=e,this.id=i,this.app=n,this._declaration=o,this._dataset=n.datasetIndex(o.dataset,e)}get declaration(){return this._declaration}get dataset(){return this._dataset}get isRemoved(){return this.removed}update(e){this.assertLive(),this.app.updateQuery(this,e)}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new u(`Query '${this.name}' was removed from its app; it can't be used any more.`,this.name)}replaceDeclaration(e,n,o){this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0,this._state==="executing"&&(this._state=this._result?"success":"idle"),this.resultSuperseded=!0,this.clearAnnotations(),this.currentResults=new WeakSet,this._declaration=e,this._dataset=n,this._sort=[...o],this._run=void 0,this.resetPage(),this.notify()}markRemoved(){this.removed=!0,this.clearAnnotations(),this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0}locate(){return this.assertLive(),this.app.locate("query",this.name)}get state(){return this._state}get result(){return this._result}get error(){return this._error}get pageSize(){return this.declaration.pageSize}get page(){return this._page}get sort(){return this._sort}setSort(e){this.assertLive(),this._sort=[...e],this.notify()}get hasMore(){return!this._result||this.pageSize===void 0||this.resultSuperseded?!1:this._result.meta.hasMore??this.lastPageRows>=this.pageSize}signature(e="pending"){let n=this.app.mappingsTo(this.name).map(o=>({field:o.field,aggregation:o.aggregation,condition:e==="pending"?o.from.condition:o.from.appliedCondition})).sort((o,i)=>o.field.localeCompare(i.field)||JSON.stringify(o).localeCompare(JSON.stringify(i)));return JSON.stringify({declaration:this.declaration,conditions:n,selection:this.app.selectionConditionsFor(this.name,e),selectionExpression:this.app.selectionExpressionFor(this.name,e),sort:this._sort,inputDefaults:this.app.queryInputDefaults,page:this._page})}get isDirty(){return this.lastRunSignature!==void 0&&this.signature()!==this.lastRunSignature}hasUnappliedChange(e){let n=this.signature();return n===this.runningSignature?!1:this.runFailed?n!==this.failedSignature:this.lastRunSignature===void 0?e&&this.runningSignature===void 0:n!==this.lastRunSignature}shouldRun(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.isDirty}runInFlightWith(e){let n=this.startedRun;if(!(!n||n.controller!==this.controller||n.controller.signal.aborted))return n.signature===e?n.outcome:void 0}shouldRunAlone(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.signature("applied")!==this.lastRunSignature}execute(e={}){return this.assertLive(),this.app.executeQuery(this,e)}abort(){this.assertLive(),this.controller?.abort()}async fetchMore(){try{if(this.assertLive(),this.pageSize===void 0)throw new u(`Query '${this.name}' declares no pageSize, so it has no more pages.`,this.name);if(!this.hasMore)return;this._page+=1,await this.app.fetchPage(this)}catch(e){throw Q(e,"fetch_more"),e}}async inspect(e={}){return this.assertLive(),this.app.inspect("query",this.name,e.tab)}menu(e,n,o={}){return this.assertLive(),this.app.menu(this,e,Array.isArray(n)?n:[n],o.fields,o.measure)}select(e,n={}){this.assertLive(),this.app.select(this,Array.isArray(e)?e:[e],n.fields)}get selectedRows(){let{selection:e}=this.app;if(e?.source!==this.name)return[];let n=this._result?.rows;if(!n)return e.rows;let o=s(a=>JSON.stringify(e.fields.map(d=>a[d]??null)),"key"),i=new Set(e.rows.map(o));return n.filter(a=>i.has(o(a)))}get annotations(){return this.resolvedAnnotations??(this.resolvedAnnotations=Object.freeze(Ve(this.annotationSets,this._result?.rows??[]))),this.resolvedAnnotations}isCurrentResult(e){return this.currentResults.has(e)}setAnnotations(e,n){if(n.length)this.annotationSets.set(e,n);else if(!this.annotationSets.delete(e))return;this.resolvedAnnotations=void 0,this.notify()}clearAnnotations(){this.annotationSets.clear(),this.resolvedAnnotations=void 0}markExecuting(){this.removed||(this._state="executing",this._error=void 0,this.notify())}get cacheDuration(){return this.declaration.cache?.duration??this.app.queryCacheDefaultDuration}get run(){return this._run}markSuccess(e,n,o,i){if(!this.removed){if(this._state="success",o||(this._run=i,this.resultSuperseded=!1),this._error=void 0,o||(this.runFailed=!1),this.lastRunSignature=n,this.lastPageRows=e.rows.length,o?this.resolvedAnnotations=void 0:this.clearAnnotations(),o&&this._result){let a=e.meta.pivot?zt(this._result.rows,e.rows):e.rows,d=[...this._result.rows,...a];this._result={...e,rows:d,meta:{...e.meta,numRows:d.length}}}else this._result=e,this.currentResults=new WeakSet;this.currentResults.add(this._result),this.notify()}}markError(e,n=!1,o){this.removed||(n||(this.runFailed=!0,this.failedSignature=o),this._state="error",this._error=e,this.notify())}rewindPage(){this._page>1&&(this._page-=1)}resetPage(){this._page=1,this.lastPageRows=0}toJSON(){return this._declaration}};s(de,"Query");var x=de,ze="__pivot_row__";function zt(r,t){let e=new Set(r.map(n=>String(n[ze])));return t.filter(n=>!e.has(String(n[ze])))}s(zt,"newGridRows");function Ke(){let r=new Error("Aborted");return r.name="AbortError",r}s(Ke,"abortError");function _(r,t,e=Object.keys(t)){let n={...r};return e.forEach(o=>{if(!(o in t))return;let i=t[o];i===void 0?delete n[o]:n[o]=i}),n}s(_,"withChanges");var Ue=["year","quarter","month","week","day","hour","minute"];function Gt(r,t){if(!Ue.includes(t))throw new u(`Invalid grain '${t}'. Expected one of: ${Ue.join(", ")}.`,r)}s(Gt,"assertGrain");function ce(r,t){return t?(Gt(r,t),{operator:"transform_date_drill",values:[`datetrunc ${t}`]}):{operator:"none"}}s(ce,"drillCondition");function Jt(r){let t=r.toLowerCase();return t.includes("date")||t.includes("time")?"date":t.includes("int")||t.includes("number")||t.includes("float")||t.includes("decimal")?"number":t.includes("bool")?"boolean":"string"}s(Jt,"inferType");function Wt(r,t){return JSON.stringify(r??null)===JSON.stringify(t??null)}s(Wt,"sameCondition");var ue=class ue extends k{constructor(e,n,o){super(n);l(this,"name");l(this,"app");l(this,"pending");l(this,"applied");l(this,"initial");l(this,"removed",!1);this.name=e,this.app=n,this.initial=o,this.pending=o}locate(){return this.assertLive(),this.app.locate("control",this.name)}async inspect(e={}){return this.assertLive(),this.app.inspect("control",this.name,e.tab)}get isRemoved(){return this.removed}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new u(`Control '${this.name}' was removed from its app; it can't be used any more.`,this.name)}markRemoved(){this.removed=!0,this.dropInFlight()}dropInFlight(){}redefault(e,n){this.initial=e,n&&(this.pending=e)}get condition(){return this.pending}get appliedCondition(){return this.applied}get isDirty(){return this.applied!==void 0&&!Wt(this.pending,this.applied)}setCondition(e){this.assertLive(),this.pending=e,this.notify()}reset(){this.assertLive(),this.setCondition(this.initial)}commit(){this.applied=this.pending}};s(ue,"Control");var S=ue,$=class $ extends S{constructor(e,n,o,i,a){super(e,n,o.default??{operator:"is",values:[]});l(this,"kind","filter");l(this,"_declaration");l(this,"resolution");l(this,"backend");l(this,"loadedOptions");l(this,"loading",new Set);this.backend=a,this.resolution=$.resolve(e,o,i),this._declaration=o,this.assertValues(this.condition.values??[]),this.assertValues(o.options??[])}static resolve(e,n,o){if(n.field){if(!o)throw new u(`Filter '${e}' names a field but no dataset. Pass \`dataset\` alongside \`field\`.`,e);let i=o.resolve(n.field,e);return{resolved:i,datasetName:o.descriptor.name,type:n.type??Jt(i.type)}}if(!n.type)throw new u(`Filter '${e}' is a manual filter, so it needs a \`type\`.`,e);return{type:n.type}}get declaration(){return this._declaration}get type(){return this.resolution.type}setCondition(e){this.assertLive(),this.assertValues(e.values??[]),super.setCondition(e)}update(e){this.assertLive();let n=_(this._declaration,e),o=this._declaration,i=["field","dataset","type"].some(p=>n[p]!==o[p]),a=i?$.resolve(this.name,n,this.app.filterDataset(this.name,n)):this.resolution,d=n.default??{operator:"is",values:[]},c=s(p=>p.values??[],"values");this.assertValuesOf(a.type,c(d)),this.assertValuesOf(a.type,n.options??[]),i||this.assertValuesOf(a.type,c(this.condition)),this._declaration=n,this.resolution=a,this.redefault(d,i),i&&(this.loadedOptions=void 0,this.dropInFlight()),this.notify()}dropInFlight(){this.loading.forEach(e=>e.abort()),this.loading.clear()}assertValues(e){this.assertValuesOf(this.type,e)}assertValuesOf(e,n){if(e!=="number")return;let o=n.find(i=>typeof i=="number");if(o!==void 0)throw new u(`Filter '${this.name}' filters numbers: give its values as strings, as query results give them (${JSON.stringify(String(o))}, not ${String(o)}), so none has lost a digit.`,this.name)}get isFieldBacked(){return this.resolution.resolved!==void 0}get options(){return this.loadedOptions??this._declaration.options??[]}async loadOptions(e,n=new AbortController().signal){this.assertLive();let{resolved:o,datasetName:i}=this.resolution,a=o?.modelName;if(!o||!a||!this.backend||!i)return this.options;let d=new AbortController,c=s(()=>d.abort(),"follow");n.aborted?d.abort():n.addEventListener("abort",c,{once:!0}),this.loading.add(d);try{let p=await this.backend.fieldSuggestions({dataset:i,model:a,field:o.fieldName,q:e??""},d.signal).catch(m=>{throw Q(m,"load_options"),m});if(d.signal.aborted&&!this.loading.has(d))throw Ke();return this.loadedOptions=[...p??[]],this.notify(),this.loadedOptions}finally{this.loading.delete(d),n.removeEventListener("abort",c)}}toJSON(){return this._declaration}};s($,"Filter");var q=$,pe=class pe extends S{constructor(e,n,o={}){super(e,n,ce(e,o.default));l(this,"kind","dateDrill");l(this,"_declaration");this._declaration=o}get declaration(){return this._declaration}update(e){this.assertLive();let n=_(this._declaration,e),o=ce(this.name,n.default);this._declaration=n,this.redefault(o,!1),this.notify()}setGrain(e){this.assertLive(),this.setCondition(ce(this.name,e))}toJSON(){return this._declaration}};s(pe,"DateDrillControl");var V=pe;function Ge(r,t){if(t)throw new u(`Edge '${r.id}' was removed from its app; map again to have it back.`,r.from.name)}s(Ge,"assertLive");var fe=class fe{constructor(t,e,n,o,i){l(this,"kind","control");l(this,"from");l(this,"to");l(this,"field");l(this,"aggregation");l(this,"owner");l(this,"removed",!1);this.from=t,this.to=e,this.field=n,this.aggregation=o,this.owner=i}remove(){Ge(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}.${this.field}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:this.from.kind,name:this.from.name},to:{kind:"query",name:this.to.name},field:this.field,...this.aggregation?{aggregation:this.aggregation}:{}}}};s(fe,"Mapping");var z=fe,me=class me{constructor(t,e,n){l(this,"kind","crossFilter");l(this,"from");l(this,"to");l(this,"owner");l(this,"removed",!1);this.from=t,this.to=e,this.owner=n}remove(){Ge(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:"query",name:this.from.name},to:{kind:"query",name:this.to.name}}}};s(me,"CrossFilter");var K=me;function Ht(r,t){if(!(!t||t.operator==="none"||t.operator==="transform_date_drill"||!["is_null","not_null","is_true","is_false","transform_pop_none"].includes(t.operator)&&!t.values?.length))return{field:r.field,operator:t.operator,values:t.values??[],...t.modifier?{modifier:t.modifier}:{},...r.aggregation?{aggregation:r.aggregation}:{}}}s(Ht,"toFilter");function Yt(r,t){if(t?.operator!=="transform_date_drill")return;let e=t.values?.[0];if(typeof e!="string")return;let n=e.replace(/^datetrunc\s+/,"");return{field:r.field,grain:n}}s(Yt,"toDateDrill");function Xt(r,t){let e=t.columns??[],n=(t.values??[]).map(i=>{let a={};return e.forEach((d,c)=>{a[d.name]=i[c]}),a}),{pageSize:o}=r;return{columns:e,rows:n,meta:{...o!==void 0?{page:t.meta?.page??r.page,pageSize:t.meta?.pageSize??o,...t.meta?.hasMore!==void 0?{hasMore:t.meta.hasMore}:{},...t.meta?.pivot?{pivot:t.meta.pivot}:{}}:{},numRows:t.meta?.numRows??n.length},...t.debug?{debug:t.debug}:{}}}s(Xt,"toResult");function U(r,t,e,n){let o=t.map(c=>Ht(c,c.from.appliedCondition)).filter(c=>c!==void 0),i=t.map(c=>Yt(c,c.from.appliedCondition)).filter(c=>c!==void 0),a=e.conditions.map(c=>({field:c.field,operator:c.operator,values:c.values})),d=e.expression?[{expr:e.expression}]:[];return{dataset:r.dataset.descriptor.name,aql:r.declaration.aql,input:{filters:[...o,...a],conditions:d,sorts:r.sort.map(c=>({field:c.field,direction:c.direction??"asc"})),dateDrills:i,...n.timezone?{timezone:n.timezone}:{},...n.weekStartDay?{weekStartDay:n.weekStartDay}:{}},...r.cacheDuration?{cacheDuration:r.cacheDuration}:{}}}s(U,"buildQuery");function he(r,t,e,n){let{input:o,...i}=U(r,t,e,n);return{...i,input:We(o,r),...n.bustCache?{bustCache:!0}:{}}}s(he,"buildRequest");function Je(r,t){return{dataset:r.dataset.descriptor.name,aql:r.declaration.aql,input:We(t.input,r),...r.cacheDuration?{cacheDuration:r.cacheDuration}:{},...t.cachedAt?{minCachedAt:t.cachedAt}:{}}}s(Je,"pageRequest");function We(r,t){let{pagination:e,...n}=r;return t.pageSize!==void 0?{...n,pagination:{page:t.page,pageSize:t.pageSize}}:n}s(We,"withPage");function Zt(r,t){let e=t?.replace(/[/\\]/g,"-").replace(/\p{Cc}/gu,"").trim();return e?`${e} - ${r.name}`:r.name}s(Zt,"defaultExportFilename");function He(r,t,e,n,o,i){let a=o.format??"csv",d=a==="csv"?{bom:!0,...o.formatOptions}:o.formatOptions,c=U(r,t,e,n),{pagination:p,...m}=i?.input??c.input;return{...c,input:m,...i?.cachedAt?{minCachedAt:i.cachedAt}:{},format:a,...d?{formatOptions:d}:{},filename:o.filename?.trim()||Zt(r,n.title)}}s(He,"buildExportRequest");async function ge(r,t,e,n,o){let i=await e.submitQuery(t,n,o),a=i.debug?.cache?.cachedAt?.toISOString();return{result:Xt(r,i),run:{input:i.input??t.input,...a?{cachedAt:a}:{}}}}s(ge,"runQuery");function en(r,t){if(r===null)return"null";if(typeof r=="boolean")return r?"true":"false";if(t==="number"&&typeof r=="string")return rn(r);if(typeof r=="number"){if(!Number.isFinite(r))throw new RangeError(`Cannot express ${r} in AQL.`);return Math.abs(r)>=1e21?BigInt(r).toString():String(r)}return JSON.stringify(r).split("\u2028").join("\\u2028").split("\u2029").join("\\u2029")}s(en,"literal");function Ye(r,t,e){return t===null?`is(${r}, null)`:`${r} is ${en(t,e)}`}s(Ye,"equals");var tn=new Set(["NaN","Infinity","-Infinity"]),nn=/^(-?)(0|[1-9]\d*)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;function rn(r){let t=nn.exec(r);if(!t)throw tn.has(r)?new RangeError(`Cannot express ${r} in AQL.`):new TypeError(`${JSON.stringify(r)} is not a number: a number is a string in JSON's number syntax.`);let[,e,n,o="",i]=t;if(i===void 0)return r;let a=n+o,d=n.length+Number(i),c;return d<=0?c=`0.${"0".repeat(-d)}${a}`:d>=a.length?c=a+"0".repeat(d-a.length):c=`${a.slice(0,d)}.${a.slice(d)}`,e+c.replace(/^0+(?=\d)/,"")}s(rn,"numberLiteral");function Xe(r,t,e){return`${r} matches @(${t} until ${e})`}s(Xe,"dateRange");function Ze(r,t){if(t.length===0)throw new RangeError(`\`${r}\` needs at least one operand.`);return t.length===1?t[0]:`${r}(${t.join(", ")})`}s(Ze,"combine");var et=s(r=>Ze("and",r),"and"),tt=s(r=>Ze("or",r),"or");var on=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/,sn={week:7*864e5,day:864e5,hour:36e5,minute:6e4};function nt(r){if(typeof r!="string")return;let t=on.exec(r);if(t)return{year:Number(t[1]),month:Number(t[2])-1,day:Number(t[3]),hour:Number(t[4]??0),minute:Number(t[5]??0),second:Number(t[6]??0),hasTime:t[4]!==void 0}}s(nt,"parseStamp");function O(r,t){let e=new Date(r),n=s(i=>String(i).padStart(2,"0"),"pad"),o=`${e.getUTCFullYear()}-${n(e.getUTCMonth()+1)}-${n(e.getUTCDate())}`;return t?`${o} ${n(e.getUTCHours())}:${n(e.getUTCMinutes())}:${n(e.getUTCSeconds())}`:o}s(O,"format");function rt(r){return Date.UTC(r.year,r.month,r.day,r.hour,r.minute,r.second)}s(rt,"toMs");function ye(r){let t=nt(r);if(t)return O(rt(t),t.hasTime)}s(ye,"normalise");function be(r,t){let e=nt(r);if(!e)return;let{year:n,month:o,day:i,hour:a,minute:d,second:c,hasTime:p}=e;return O(t==="year"?Date.UTC(n+1,o,i,a,d,c):t==="quarter"?Date.UTC(n,o+3,i,a,d,c):t==="month"?Date.UTC(n,o+1,i,a,d,c):rt(e)+sn[t],p)}s(be,"addGrain");function ot(r){if(r?.startsWith("datetrunc "))return r.slice(10)}s(ot,"grainOf");function an(r){let t=new Set;return r.filter(e=>{let n=`${typeof e}:${String(e)}`;return t.has(n)?!1:(t.add(n),!0)})}s(an,"distinct");function ln(r,t){let e=r.map(ye);if(e.some(o=>o===void 0))return!1;let n=e.slice().sort();for(let o=1;o<n.length;o+=1)if(be(n[o-1],t)!==n[o])return!1;return!0}s(ln,"isContiguous");function dn(r,t,e){let n=t.map(ye);if(n.some(c=>c===void 0))return;let o=n.slice().sort(),i=o[0],a=be(o[o.length-1],e);if(!a)return;let d=ln(t,e);return{condition:{field:r,operator:"matches",values:[`${i} until ${a}`]},admits:d?t.length:Number.POSITIVE_INFINITY,lossy:!d}}s(dn,"dateRange");function cn(r,t,e){let n=e.filter(d=>d!=null),o=an(n);if(!o.length)return{condition:{field:r,operator:"is_null",values:[]},admits:1,lossy:!1};let i=n.length!==e.length,a=ot(t);if(a){let d=dn(r,o,a);if(d)return{...d,lossy:d.lossy||i}}return{condition:{field:r,operator:"is",values:o},admits:o.length,lossy:i}}s(cn,"deriveOne");function it(r){return r.modelId?`${r.modelId}.${r.fieldName}`:r.fieldName}s(it,"fieldReferenceOf");function un(r,t,e,n){try{let o=e.map(i=>et(t.map(a=>{let d=r.get(a),c=it(d),p=i[a]??null,m=ot(n[c]);if(m&&typeof p=="string"){let f=ye(p),h=be(p,m);if(f&&h)return Xe(c,f,h)}if(p!==null&&typeof p!="string"&&typeof p!="number"&&typeof p!="boolean")throw new TypeError("no AQL spelling");return Ye(c,p,d.semantic_type)})));return tt(o)}catch{return}}s(un,"selectionExpression");function we(r,t,e,n={}){let o=r.result?.columns??[],i=new Map(o.map(g=>[g.name,g]));e?.forEach(g=>{let b=i.get(g);if(b){if(b.adhoc)throw new u(`Query '${r.name}' cannot cross-filter on '${g}': it is a query-local AQL expression, which only this query's result carries. The target query would receive a condition naming a field it has never heard of.`,r.name);if(b.isMeasure)throw new u(`Query '${r.name}' cannot cross-filter on '${g}': it is a measure, and a selection conditions dimensions only.`,r.name);return}throw new u(v(`Query '${r.name}' has no column '${g}' in its last result.`,g,[...i.keys()]),r.name)});let a=o.filter(g=>!g.isMeasure),d=a.filter(g=>!g.adhoc).map(g=>g.name),c=e?[...e]:d;if(!t.length||!c.length)return;let p=[],m=1,f=!e&&d.length!==a.length,h=!1;c.forEach(g=>{let b=i.get(g),Pe=it(b),X=cn(Pe,n[Pe],t.map(Rt=>Rt[g]));p.push(X.condition),m*=X.admits,h=h||X.lossy});let y=new Set(t.map(g=>JSON.stringify(c.map(b=>g[b]??null))));m>y.size&&(h=!0);let Tt=p.sort((g,b)=>g.field.localeCompare(b.field)),Le={source:r.name,rows:[...t],fields:c};if(h){let g=un(i,c,t,n);if(g)return{...Le,conditions:[],expression:g,lossy:f}}return{...Le,conditions:Tt,lossy:f||h}}s(we,"deriveSelection");var pn=["color-bg","color-fg","color-muted","color-border","color-accent","color-danger","radius","font","font-mono","color-bg-sunken","color-fg-weak","color-border-strong","color-hover","color-active","color-selected","color-warning","color-success"],st="'Inter Variable', ui-sans-serif, system-ui, sans-serif",at="'Geist Mono Variable', ui-monospace, monospace",lt={light:{"color-bg":"oklch(1 0 0)","color-bg-sunken":"oklch(0.973 0.005 95.1)","color-fg":"oklch(0.201 0.022 301.1)","color-fg-weak":"oklch(0.392 0.021 304.3)","color-muted":"oklch(0.485 0.022 306.3)","color-border":"oklch(0.201 0.022 301.1 / 0.12)","color-border-strong":"oklch(0.201 0.022 301.1 / 0.24)","color-accent":"oklch(0.484 0.181 298.1)","color-danger":"oklch(0.501 0.17 27.2)","color-warning":"oklch(0.501 0.1 70.3)","color-success":"oklch(0.479 0.1 151.8)","color-hover":"oklch(0.201 0.022 301.1 / 0.05)","color-active":"oklch(0.201 0.022 301.1 / 0.09)","color-selected":"oklch(0.946 0.027 304.8)",radius:"10px",font:st,"font-mono":at},dark:{"color-bg":"oklch(0.19 0.012 300)","color-bg-sunken":"oklch(0.157 0.009 296.9)","color-fg":"oklch(0.961 0.007 304.2)","color-fg-weak":"oklch(0.879 0.016 302.5)","color-muted":"oklch(0.835 0.018 300)","color-border":"oklch(0.343 0.025 298.2)","color-border-strong":"oklch(0.392 0.021 304.3)","color-accent":"oklch(0.845 0.085 300)","color-danger":"oklch(0.82 0.09 27)","color-warning":"oklch(0.84 0.12 69.6)","color-success":"oklch(0.8 0.12 151.9)","color-hover":"oklch(1 0 0 / 0.06)","color-active":"oklch(1 0 0 / 0.1)","color-selected":"oklch(0.565 0.194 300.3 / 0.18)",radius:"10px",font:st,"font-mono":at}};function dt(r,t){for(let e of pn)r.setProperty(`--anfra-${e}`,t.tokens[e]);r.setProperty("color-scheme",t.scheme)}s(dt,"applyTheme");var ct="data-anfra-layer",fn=new WeakMap,mn="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483647;";function hn(r){let t=r.querySelector(`[${ct}]`);if(t instanceof(r.defaultView?.HTMLElement??HTMLElement))return t;let e=r.createElement("div");e.setAttribute(ct,""),e.setAttribute("style",mn);let n=fn.get(r);return n&&dt(e.style,n),(r.body??r.documentElement).appendChild(e),e}s(hn,"layerOf");function G(r,t){let e=hn(r),n=[...e.children].find(i=>i.getAttribute("data-part")===t);if(n?.shadowRoot)return n.shadowRoot;let o=r.createElement("div");return o.setAttribute("data-part",t),e.appendChild(o),o.attachShadow({mode:"open"})}s(G,"layerRoot");var E={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},Yr=`[${E.container}],[${E.block}],[${E.query}],[${E.control}]`;function gn(r){let t=/^(?:(\d+)\/)?([^/\s]+)$/.exec(r);if(t)return{app:t[1]===void 0?0:Number(t[1]),name:t[2]}}s(gn,"parseRef");var yn=s(r=>(r??"").split(/\s+/).filter(Boolean),"tokens");function ut(r,t,e,n){let o=t==="query"?E.query:E.control;return[...r.querySelectorAll(`[${o}]`)].filter(i=>yn(i.getAttribute(o)).some(a=>{let d=gn(a);return d?.app===e&&d.name===n}))}s(ut,"markersFor");var pt;function ft(r,t){return pt?pt(r,t):!1}s(ft,"openRowsMenu");var ro=`[${E.block}]`;function J(r,t){return t?.forEach((e,n)=>{let o=!1,i;Object.defineProperty(r,n,{configurable:!0,enumerable:!1,get(){return o||(i=e(r),o=!0),i}})}),r}s(J,"applyExtensions");var mt="anfra-overlay",bn=1500,wn="position:fixed;box-sizing:border-box;background:oklch(0.546 0.215 262.9 / 0.22);outline:1px solid oklch(0.546 0.215 262.9);outline-offset:-1px;",vn="position:fixed;max-width:60vw;display:flex;gap:6px;align-items:baseline;padding:3px 8px;border-radius:4px;background:oklch(0.208 0.04 265.8);color:oklch(0.984 0.003 247.9);font:12px/1.4 system-ui,sans-serif;white-space:nowrap;box-shadow:0 2px 8px oklch(0 0 0 / 0.35);",kn={kind:"color:oklch(0.711 0.035 256.8);",name:"color:oklch(0.809 0.096 251.8);font-weight:700;",label:"color:oklch(0.984 0.003 247.9);",note:"color:oklch(0.711 0.035 256.8);",size:"color:oklch(0.711 0.035 256.8);margin-left:10px;"},ke=class ke{constructor(t){l(this,"doc",t);l(this,"root");l(this,"shown",[]);l(this,"text",{kind:"",name:""});l(this,"timer");l(this,"reposition",s(()=>this.draw(),"reposition"));let e=G(t,"anfra"),n=e.getElementById(mt);n instanceof(t.defaultView?.HTMLElement??HTMLElement)?this.root=n:(this.root=t.createElement("div"),this.root.id=mt,this.root.setAttribute("aria-hidden","true"),this.root.setAttribute("style","position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:none;"),e.appendChild(this.root))}show(t,e){if(this.clearTimer(),this.root.isConnected||G(this.doc,"anfra").appendChild(this.root),this.shown=[...t],this.text=e,!this.shown.length){this.hide();return}this.root.style.display="block",this.draw(),this.doc.addEventListener("scroll",this.reposition,{capture:!0,passive:!0}),this.doc.defaultView?.addEventListener("resize",this.reposition)}flash(t,e,n=bn){this.show(t,e),this.timer=setTimeout(()=>this.hide(),n)}hide(){this.clearTimer(),this.shown=[],this.root.style.display="none",this.root.replaceChildren(),this.doc.removeEventListener("scroll",this.reposition,{capture:!0}),this.doc.defaultView?.removeEventListener("resize",this.reposition)}get visible(){return this.shown.length>0}clearTimer(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}draw(){let t=this.shown.map(d=>{let c=d.getBoundingClientRect(),p=this.doc.createElement("div");return p.setAttribute("style",`${wn}left:${c.left}px;top:${c.top}px;width:${c.width}px;height:${c.height}px;`),p}),e=this.shown[0].getBoundingClientRect(),n=this.doc.createElement("div");n.setAttribute("data-testid","anfra-overlay-label");let o=this.doc.defaultView?.innerHeight??0,i=e.top>=26?e.top-24:Math.max(4,e.top+4),a=Math.max(4,Math.min(e.left,(this.doc.defaultView?.innerWidth??0)-24));n.setAttribute("style",`${vn}left:${a}px;top:${Math.min(i,o-24)}px;`);for(let d of["kind","name","label","note","size"]){let c=this.text[d];if(!c)continue;let p=this.doc.createElement("span");p.setAttribute("style",kn[d]),p.setAttribute("data-part",d),p.textContent=c,n.appendChild(p)}this.root.replaceChildren(...t,n)}};s(ke,"Overlay");var ve=ke,ht=new WeakMap;function gt(r){let t=ht.get(r);return t||(t=new ve(r),ht.set(r,t)),t}s(gt,"overlayFor");function yt(r){typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}s(yt,"scrollTo");var Ee=Object.freeze([]);function xe(r){return r instanceof Error&&r.name==="AbortError"}s(xe,"isAbort");function W(r,t){return r.controller!==t}s(W,"superseded");function En(r){return{name:r.name,code:r.code,scope:r.scope,message:r.message,...r.entity?{entity:r.entity}:{},...typeof r.status=="number"?{status:r.status}:{},...r.requestId?{requestId:r.requestId}:{},...r.stack?{stack:r.stack}:{}}}s(En,"inspectError");function xn(r){let{result:t}=r;return{id:r.id,state:r.state,isDirty:r.isDirty,page:r.page,hasMore:r.hasMore,columns:t?t.columns.map(e=>({...e})):[],rowCount:t?.meta.numRows??0,selectedRowCount:r.selectedRows.length,signature:r.signature(),...r.error?{error:En(r.error)}:{},...t?.debug?{debug:{...t.debug}}:{}}}s(xn,"inspectQuery");function Sn(r){let{options:t}=r;return{kind:r.kind,condition:{...r.condition},...r.appliedCondition?{appliedCondition:{...r.appliedCondition}}:{},isDirty:r.isDirty,...t?{options:[...t]}:{}}}s(Sn,"inspectControl");function bt(r){return{source:r.source,fields:[...r.fields],rowCount:r.rows.length,conditions:r.conditions.map(t=>({...t})),...r.expression?{expression:r.expression}:{},lossy:r.lossy}}s(bt,"inspectSelection");function wt(r){return r?JSON.stringify({source:r.source,conditions:r.conditions,expression:r.expression}):"none"}s(wt,"selectionKey");function Se(r,t,e="The query failed."){return ne(r)?r.about(t):(console.error(`anfra: '${t}' failed; the app is told only that it failed.`,r),new w({code:"call_failed",scope:"server",message:e,entity:t,cause:r}))}s(Se,"toDataAppError");var De=class De extends k{constructor(e,n,o,i,a){super();l(this,"extensions",a);l(this,"title");l(this,"_timezone");l(this,"_weekStartDay");l(this,"queryInput");l(this,"queryCacheDefaultDuration");l(this,"datasets");l(this,"backend");l(this,"features");l(this,"_queries",new Map);l(this,"_controls",new Map);l(this,"_mappings",[]);l(this,"_crossFilters",[]);l(this,"_selection");l(this,"_appliedSelection");l(this,"selectionCommitted",!1);l(this,"nextQueryId",1);l(this,"removedListeners",new Set);l(this,"revealer");l(this,"index",0);this.title=e.title,this._timezone=e.timezone,j(e.weekStartDay,"The app","weekStartDay"),this._weekStartDay=e.weekStartDay;let d=e.query?.default?.input??{};j(d.weekStartDay,"The app","query.default.input.weekStartDay"),this.queryInput={...d};let c=e.query?.default?.cache?.duration;B(c,"The app","query.default.cache.duration"),this.queryCacheDefaultDuration=c,this.datasets=n,this.backend=o,this.features=i}get queries(){return Object.fromEntries(this._queries)}get controls(){return Object.fromEntries(this._controls)}get mappings(){return[...this._mappings,...this._crossFilters]}get crossFilters(){return this._crossFilters}createQuery(e,n){this.assertNameFree(e,"query");let o=J(new x(e,this,n,this.nextQueryId++),this.extensions?.query);return this._queries.set(e,o),this.notify(),o}createFilter(e,n){this.assertNameFree(e,"filter");let o=this.filterDataset(e,n),i=J(new q(e,this,n,o,this.backend),this.extensions?.control);return this._controls.set(e,i),this.notify(),i}createDateDrill(e,n={}){if(this.features?.dateDrill===!1)throw new u(`Date drill '${e}' needs a capability this workspace has not enabled. Ask an admin to turn on \`interactive_control:date_drill\`.`,e);this.assertNameFree(e,"date drill control");let o=J(new V(e,this,n),this.extensions?.control);return this._controls.set(e,o),this.notify(),o}mapControl(e,n,o){if(!(e instanceof S))throw new u("mapControl expects a control as its source. To let one query cross-filter another, use app.mapCrossFilter(from, to) \u2014 a cross-filter edge names no field.");if(e.assertLive(),n.assertLive(),this._controls.get(e.name)!==e)throw new u(`Control '${e.name}' belongs to a different app.`,e.name);if(this._queries.get(n.name)!==n)throw new u(`Query '${n.name}' belongs to a different app.`,n.name);o.aggregation&&Be(o.aggregation,e.name);let i=new z(e,n,o.field,o.aggregation,this);if(this._mappings.some(a=>a.id===i.id))throw new u(`Mapping '${i.id}' is already declared.`,e.name);return this.assertAcyclic(i),this._mappings.push(i),this.notify(),i}mapCrossFilter(e,n){if(!(e instanceof x)||!(n instanceof x))throw new u("mapCrossFilter expects two queries. To let a control condition a query, use app.mapControl(from, to, { field }).");if(e.assertLive(),n.assertLive(),this._queries.get(e.name)!==e)throw new u(`Query '${e.name}' belongs to a different app.`,e.name);if(this._queries.get(n.name)!==n)throw new u(`Query '${n.name}' belongs to a different app.`,n.name);if(e===n)throw new u(`Query '${e.name}' cannot cross-filter itself. A source keeps its own rows so it can show what is selected; filtering it would erase the very rows the reader clicked.`,e.name);if(e.declaration.dataset!==n.declaration.dataset)throw new u(`Cross-filter '${e.name}' -> '${n.name}' spans two datasets ('${e.declaration.dataset}' and '${n.declaration.dataset}'). A selection carries field references, which mean nothing outside the dataset that resolved them.`,e.name);let o=new K(e,n,this);if(this._crossFilters.some(i=>i.id===o.id))throw new u(`Cross-filter '${o.id}' is already declared.`,e.name);return this._crossFilters.push(o),this.notify(),o}updateQuery(e,n){let o=e.declaration,i=_(o,n,["dataset","aql","pageSize","cache"]);le(e.name,i,"sets");let a=this.datasetIndex(i.dataset,e.name);if(i.dataset!==o.dataset){let p=this._crossFilters.filter(m=>m.from===e?m.to.declaration.dataset!==i.dataset:m.to===e?m.from.declaration.dataset!==i.dataset:!1);if(p.length)throw new u(`Query '${e.name}' can't move to dataset '${i.dataset}': its cross-filters ${p.map(m=>`'${m.id}'`).join(", ")} would span two datasets. Remove them first.`,e.name)}let d=i.aql!==o.aql||i.dataset!==o.dataset,c=n.sort??(d?[]:e.sort);d&&this.dropSelectionFrom(e.name),e.replaceDeclaration(i,a,c)}removeEntity(e){if(e instanceof x){if(this._queries.get(e.name)!==e)throw new u(`Query '${e.name}' belongs to a different app.`,e.name);this._queries.delete(e.name),this.dropEdges(n=>n.to===e||n.from===e),this.dropSelectionFrom(e.name)}else{if(this._controls.get(e.name)!==e)throw new u(`Control '${e.name}' belongs to a different app.`,e.name);this._controls.delete(e.name),this.dropEdges(n=>n.from===e)}e.markRemoved(),this.removedListeners.forEach(n=>{try{n(e)}catch{}}),this.notify()}removeEdge(e){if(!this.dropEdges(n=>n===e))throw new u(`Edge '${e.id}' belongs to a different app.`,e.from.name);this.notify()}onRemoved(e){return this.removedListeners.add(e),()=>{this.removedListeners.delete(e)}}dropEdges(e){let n=this.mappings.filter(e);n.forEach(i=>i.markRemoved());let o=s(i=>{let a=i.filter(d=>!n.includes(d));i.splice(0,i.length,...a)},"keep");return o(this._mappings),o(this._crossFilters),n.length>0}dropSelectionFrom(e){this._selection?.source===e&&(this._selection=void 0),this._appliedSelection?.source===e&&(this._appliedSelection=void 0)}get selection(){return this._selection}get appliedSelection(){return this._appliedSelection}clearSelection(){this._selection&&(this._selection=void 0,this.notify())}setTimezone(e){this._timezone=e,this.notify()}get timezone(){return this._timezone}setWeekStartDay(e){j(e,"The app","weekStartDay","sets"),this._weekStartDay=e,this.notify()}get weekStartDay(){return this._weekStartDay}get queryInputDefaults(){let e=this.queryInput.timezone??this._timezone,n=this.queryInput.weekStartDay??this._weekStartDay;return{...e?{timezone:e}:{},...n?{weekStartDay:n}:{}}}datasetIndex(e,n){return je(this.datasets,e,n)}filterDataset(e,n){return n.dataset?this.datasetIndex(n.dataset,e):this.soleDataset(e,n.field)}mappingsTo(e){return this._mappings.filter(n=>n.to.name===e)}selectionExpressionFor(e,n){return this.selectionFor(e,n)?.expression}selectionFor(e,n){let o=n==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?void 0:this._crossFilters.some(a=>a.from.name===o.source&&a.to.name===e)?o:void 0}selectionConditionsFor(e,n){let o=n==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?Ee:this._crossFilters.some(a=>a.from.name===o.source&&a.to.name===e)?o.conditions:Ee}drillTransformations(e){let n={};return this._mappings.forEach(o=>{if(o.to!==e)return;let i=o.from.appliedCondition;if(i?.operator!=="transform_date_drill")return;let[a]=i.values??[];typeof a=="string"&&(n[o.field]=a)}),n}menu(e,n,o,i,a){if(this._queries.get(e.name)!==e)throw new u(`Query '${e.name}' belongs to a different app.`,e.name);if(a!==void 0){let d=e.result?.columns??[],c=d.find(p=>p.name===a);if(!c?.isMeasure)throw new u(c?`Query '${e.name}' can't open a menu on '${a}' as its measure: it is a dimension.`:v(`Query '${e.name}' has no measure '${a}' in its last result.`,a,d.filter(p=>p.isMeasure).map(p=>p.name)),e.name)}return ft(n,this.rowsTarget(e,o,i,a))}rowsTarget(e,n,o,i){let a=we(e,n,o,this.drillTransformations(e)),d=e.annotations.filter(c=>(c.kind==="mark"||c.kind==="focus")&&(i===void 0||c.anchor.measure===void 0||c.anchor.measure===i)&&c.anchor.rows.some(p=>n.some(m=>ae(p,m))));return{kind:"rows",app:this.index,query:e.name,rows:[...n],fields:a?.fields?[...a.fields]:[],...i!==void 0?{measure:i}:{},conditions:a?.conditions?[...a.conditions]:[],...a?.expression?{expression:a.expression}:{},...d.length?{annotations:d}:{}}}requestFor(e){if(this._queries.get(e.name)!==e)throw new u(`Query '${e.name}' belongs to a different app.`,e.name);return U(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},this.queryInputDefaults)}select(e,n,o){if(this._queries.get(e.name)!==e)throw new u(`Query '${e.name}' belongs to a different app.`,e.name);let i=we(e,n,o,this.drillTransformations(e));i?.lossy&&console.warn(`[anfra-sdk] The selection in '${e.name}' filters more broadly than it was made. Its conditions are combined field by field and ANDed, which cannot express "(A and B) or (C and D)", so the targets will also show combinations that were not selected. Select within one dimension, or narrow with \`fields\`, to avoid this.`),this._selection=i,this.notify()}get hasChanges(){return[...this._controls.values()].some(e=>e.isDirty)||this.isSelectionDirty||[...this._queries.values()].some(e=>e.hasUnappliedChange(this.selectionCommitted))}get isSelectionDirty(){return this.selectionCommitted?wt(this._selection)!==wt(this._appliedSelection):!1}async execute(e={}){let n=[...this._queries.values()].filter(d=>d.shouldRun(e.force));this._controls.forEach(d=>d.commit()),this._appliedSelection=this._selection,this.selectionCommitted=!0;let o={backend:this.backend,...this.queryInputDefaults,bustCache:e.bustCache},i=[],a=[];return await Promise.all(n.map(async d=>{let c=await this.runWith(d,"pending",o,e.force);c==="succeeded"?i.push(d.name):c==="failed"&&a.push(d.name)})),{succeeded:i,failed:a}}async executeQuery(e,n={}){if(!e.shouldRunAlone(n.force))return{succeeded:[],failed:[]};let o=await this.runWith(e,"applied",{backend:this.backend,...this.queryInputDefaults,bustCache:n.bustCache},n.force);return{succeeded:o==="succeeded"?[e.name]:[],failed:o==="failed"?[e.name]:[]}}runWith(e,n,o,i=!1){let a=i||o.bustCache?void 0:e.runInFlightWith(e.signature(n));return a||(e.controller?.abort(),e.resetPage(),this.run(e,e.signature(n),o))}run(e,n,o){let i=new AbortController;e.controller=i,e.runningSignature=n;let a,d=new Promise((c,p)=>{a={resolve:c,reject:p}});return e.startedRun={controller:i,signature:n,outcome:d},e.markExecuting(),this.runFirstPage(e,n,o,i).then(a.resolve,a.reject),d}async runFirstPage(e,n,o,i){try{let a=he(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},o),{result:d,run:c}=await ge(e,a,o.backend,i.signal,this.stampOf(e));return W(e,i)?void 0:(e.markSuccess(d,n,!1,c),"succeeded")}catch(a){if(W(e,i)||xe(a))return;let d=Se(a,e.name);return e.markError(d,!1,n),T("call.query",d),"failed"}finally{e.controller===i&&(e.controller=void 0,e.runningSignature=void 0)}}async refresh(){return this.execute({force:!0,bustCache:!0})}abort(){this._queries.forEach(e=>e.abort())}async fetchPage(e){let n=new AbortController,o=e.signature("applied");e.controller=n,e.runningSignature=o,e.markExecuting();try{let i=e.run?Je(e,e.run):he(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{backend:this.backend,...this.queryInputDefaults}),{result:a}=await ge(e,i,this.backend,n.signal,this.stampOf(e));if(W(e,n))return;e.markSuccess(a,o,!0)}catch(i){if(W(e,n)||(e.rewindPage(),xe(i)))return;let a=Se(i,e.name);throw e.markError(a,!0),a}finally{e.controller===n&&(e.controller=void 0,e.runningSignature=void 0)}}async exportQuery(e,n,o){let i=He(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{...this.queryInputDefaults,title:this.title},n,e.run);try{return await o(i,n.signal??new AbortController().signal,{app:this.index,query:e.name})}catch(a){throw xe(a)?a:Se(a,e.name,"The export failed.")}}toJSON(){let e=s(n=>Object.fromEntries([...this._controls.entries()].filter(([,o])=>o.kind===n).map(([o,i])=>[o,i.toJSON()])),"byKind");return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},queries:Object.fromEntries([...this._queries.entries()].map(([n,o])=>[n,o.toJSON()])),filters:e("filter"),dateDrills:e("dateDrill"),mappings:[...this._mappings.map(n=>n.toJSON()),...this._crossFilters.map(n=>n.toJSON())]}}toInspectJSON(){return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},...Object.keys(this.queryInput).length>0?{queryInput:{...this.queryInput}}:{},hasChanges:this.hasChanges,declaration:this.toJSON(),queries:Object.fromEntries([...this._queries.entries()].map(([e,n])=>[e,xn(n)])),controls:Object.fromEntries([...this._controls.entries()].map(([e,n])=>[e,Sn(n)])),...this._selection?{selection:bt(this._selection)}:{},...this._appliedSelection?{appliedSelection:bt(this._appliedSelection)}:{}}}inspect(e,n,o){return this.revealer?this.revealer({app:this.index,entity:e,name:n,...o!==void 0?{tab:o}:{}}):Promise.resolve(!1)}locate(e,n){let o=globalThis.document;if(!o)return!1;let i=ut(o,e,this.index,n);return i.length?(yt(i[0]),gt(o).flash(i,{kind:e,name:n,...i.length>1?{note:`in ${i.length} places`}:{}}),!0):!1}stampOf(e){return{app:this.index,query:e.name,id:e.id}}assertNameFree(e,n){qe([...this._queries.keys(),...this._controls.keys()],e,n)}soleDataset(e,n){if(!n)return;let o=Object.keys(this.datasets);if(o.length===1)return this.datasets[o[0]];throw new u(o.length?`Filter '${e}' names a field but the environment has ${o.length} datasets. Say which one: ${o.join(", ")}.`:`Filter '${e}' names a field but the environment has no datasets.`,e)}assertAcyclic(e){let n=[...this._mappings,e],o=new Map;n.forEach(c=>{let p=c.from.name;o.set(p,[...o.get(p)??[],c.to.name])});let i=new Set,a=new Set,d=s(c=>{if(i.has(c))return!0;if(a.has(c))return!1;i.add(c);let p=(o.get(c)??[]).some(d);return i.delete(c),a.add(c),p},"walk");if([...o.keys()].some(d))throw new u(`Mapping '${e.id}' would make the app's mappings cyclic.`,e.from.name)}};s(De,"App");var H=De;var vt="0.25.0-rc.2";var Re=class Re{constructor(){l(this,"current",{scheme:"light",tokens:lt.light});l(this,"listeners",new Set)}get scheme(){return this.current.scheme}get tokens(){return this.current.tokens}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.current=t,this.listeners.forEach(e=>{try{e(t)}catch{}})}};s(Re,"HostTheme");var Ae=Re,_e=class _e{constructor(t){l(this,"list");this.list=Object.freeze(t.map(({name:e,version:n})=>Object.freeze({name:e,version:n})))}has(t){return this.list.some(e=>e.name===t)}version(t){return this.list.find(e=>e.name===t)?.version}};s(_e,"InstalledPlugins");var Ce=_e,An=vt,$e=class $e{constructor(t){l(this,"version",An);l(this,"_apps",[]);l(this,"datasets");l(this,"user");l(this,"indices");l(this,"backend");l(this,"plugins");l(this,"theme",new Ae);l(this,"gates");l(this,"deprecatedFeatures");l(this,"extensions",{query:new Map,control:new Map});if(!t?.datasets)throw new u("No datasets provided. The host must call createSdk({ datasets }) before an app can be declared.");if(!t.user)throw new u("No user provided. The host must call createSdk({ user }) before an app can be declared.");if(!t.backend)throw new u("No backend provided. The host must call createSdk({ backend }) before an app can run a query.");this.datasets=Object.freeze({...t.datasets}),this.user=Object.freeze({...t.user,permissions:Object.freeze({...t.user.permissions})}),this.indices=Object.fromEntries(Object.entries(t.datasets).map(([e,n])=>[e,new P(n)])),this.backend=t.backend,this.gates=Object.freeze({...t.features}),this.plugins=new Ce(t.plugins??[])}get features(){return this.deprecatedFeatures||(console.warn("anfra: Anfra.features is deprecated and will be removed. Check Anfra.plugins.has('export'), Anfra.plugins.has('render') or Anfra.plugins.has('lineage') instead."),this.deprecatedFeatures=Object.freeze({...this.gates,export:this.plugins.has("export"),render:this.plugins.has("render"),lineage:this.plugins.has("lineage")})),this.deprecatedFeatures}createApp(t={}){let e=new H(t,this.indices,this.backend,this.gates,this.extensions);return e.index=this._apps.length,this._apps.push(e),e}get apps(){return this._apps}};s($e,"Sdk");var Te=$e;function kt(r){return new Te(r)}s(kt,"createSdk");var I="Anfra";function Et(r,t=globalThis){let e=t[I],n=I in t;return t[I]=r,()=>{n?t[I]=e:delete t[I]}}s(Et,"installSandbox");function F(){let r=new Map,t=new Proxy(function(){},{get(e,n){if(n===Symbol.toPrimitive)return o=>o==="number"?0:"";if(n===Symbol.iterator)return function*(){};if(!(typeof n=="symbol"||n==="then"))return n==="length"?0:n==="toString"||n==="valueOf"?()=>"":(r.has(n)||r.set(n,F()),r.get(n))},set(e,n,o,i){return i!==t?Object.defineProperty(i,n,{value:o,writable:!0,enumerable:!0,configurable:!0}):r.set(n,o),!0},has:s(()=>!0,"has"),apply:s(()=>F(),"apply"),construct:s(()=>F(),"construct")});return t}s(F,"anything");var Ie=class Ie{constructor(){l(this,"byType",new Map)}add(t,e){if(!e)return;let n=this.byType.get(t)??[];n.includes(e)||n.push(e),this.byType.set(t,n)}remove(t,e){let n=this.byType.get(t);n&&e&&this.byType.set(t,n.filter(o=>o!==e))}get(t){return[...this.byType.get(t)??[]]}};s(Ie,"Listeners");var M=Ie;function xt(r){return{addEventListener:s((t,e)=>r.add(t,e),"addEventListener"),removeEventListener:s((t,e)=>r.remove(t,e),"removeEventListener"),dispatchEvent:s(()=>!0,"dispatchEvent")}}s(xt,"eventTarget");var Fe=class Fe{constructor(){l(this,"aborted",!1);l(this,"reason");l(this,"onabort",null);l(this,"listeners",new M)}addEventListener(t,e){this.listeners.add(t,e)}removeEventListener(t,e){this.listeners.remove(t,e)}throwIfAborted(){if(this.aborted)throw this.reason}abort(t){if(this.aborted)return;this.aborted=!0,this.reason=t??new Error("This operation was aborted");let e={type:"abort",target:this};this.onabort?.(e),this.listeners.get("abort").forEach(n=>typeof n=="function"?n(e):n.handleEvent(e))}};s(Fe,"StubAbortSignal");var Y=Fe,Me=class Me{constructor(){l(this,"signal",new Y)}abort(t){this.signal.abort(t)}};s(Me,"StubAbortController");var Oe=Me,D,A,Cn={NumberFormat:(D=class{format(t){return String(t)}resolvedOptions(){return{locale:"en-US"}}},s(D,"NumberFormat"),D),DateTimeFormat:(A=class{format(t){return new Date(t).toISOString()}resolvedOptions(){return{locale:"en-US",timeZone:"UTC"}}},s(A,"DateTimeFormat"),A)};function St(r,t){let e=new M,n=new M,o={readyState:"loading",defaultView:r,...xt(n)},i=new Proxy(o,{get:s((f,h)=>h in f?f[h]:f[h]=F(),"get")}),a=0,d=s(()=>++a,"later"),c=s(()=>{},"ignore"),p=new Proxy({},{get:s(()=>c,"get")});Object.assign(r,{window:r,self:r,globalThis:r,document:i,...xt(e),console:p,setTimeout:d,setInterval:d,requestAnimationFrame:d,requestIdleCallback:d,clearTimeout:c,clearInterval:c,cancelAnimationFrame:c,cancelIdleCallback:c,queueMicrotask:s(f=>{Promise.resolve().then(()=>{try{f()}catch(h){t(h)}})},"queueMicrotask"),matchMedia:s(f=>({matches:!1,media:f,onchange:null,addEventListener:c,removeEventListener:c,addListener:c,removeListener:c}),"matchMedia"),AbortController:Oe,AbortSignal:Y}),typeof r.Intl>"u"&&(r.Intl=Cn);let m=s((f,h)=>{try{typeof f=="function"?f.call(r,h):f?.handleEvent(h)}catch(y){t(y)}},"call");return{fire(f){if(o.readyState=f==="DOMContentLoaded"?"interactive":"complete",f==="DOMContentLoaded"){let h={type:f,target:i,bubbles:!0,preventDefault:c,stopPropagation:c};n.get(f).forEach(y=>m(y,h)),e.get(f).forEach(y=>m(y,h))}else{let h={type:f,target:r,bubbles:!1,preventDefault:c,stopPropagation:c};e.get(f).forEach(y=>m(y,h)),typeof r.onload=="function"&&m(r.onload,h)}},unknownGlobals(){Object.setPrototypeOf(r,F())}}}s(St,"installPage");function Dt(r){return{id:r.fqn,name:r.fqn,...r.label?{label:r.label}:{},data_models:(r.models??[]).map(t=>({id:t.fqn,name:t.fqn,...t.label?{label:t.label}:{},fields:t.fields.map(e=>({name:e.name,...e.label?{label:e.label}:{},type:e.type,is_custom_measure:e.role==="measure",...e.definedInDataset?{defined_in_dataset:!0}:{},...e.hidden?{is_hidden:!0}:{},...e.role==="param"?{is_param:!0}:{}}))})),metrics:(r.metrics??[]).map(t=>({name:t.name,...t.label?{label:t.label}:{},type:t.type})),relationships:(r.relationships??[]).map(t=>({...t.name?{name:t.name}:{},from:t.from,to:t.to,type:t.type,active:t.active,direction:t.direction}))}}s(Dt,"toDescriptor");var Tn=1,Rn={id:0,name:"",email:"",role:"",timezone:"UTC",permissions:{canViewGeneratedSql:!1,canExportData:!1}},_n={submitQuery:s(()=>new Promise(()=>{}),"submitQuery"),fieldSuggestions:s(async()=>[],"fieldSuggestions")},$n=/definition\.html:(\d+)/,Qe,At,Ne=[];function On(r){try{return String(r)}catch{return"A value that cannot be printed was thrown."}}s(On,"messageOf");function In(r){let t=r?.stack;if(typeof t!="string")return;let e=$n.exec(t);return e?Number(e[1]):void 0}s(In,"lineOf");function Ct(r){let t=On(r);if(t==="InternalError: out of memory"){Ne.push({kind:"limit",message:"The definition used more memory than reading a declaration allows."});return}let e=In(r);Ne.push({kind:"script_error",message:t,...e?{line:e}:{}})}s(Ct,"report");function Fn(r){let t={};r.filter(o=>o.models).forEach(o=>{t[o.fqn]=Dt(o)});let e=globalThis,n=St(e,Ct);At=n,Qe=kt({datasets:t,user:Rn,backend:_n}),Et(Qe,e),n.unknownGlobals()}s(Fn,"setup");function Mn(r){Ct(r)}s(Mn,"thrown");function Qn(r){At?.fire(r)}s(Qn,"fire");function Nn(){let r=(Qe?.apps??[]).map(t=>t.toJSON());return JSON.stringify({apps:r,problems:Ne})}s(Nn,"read");return Qt(Ln);})();
|
package/dist/host.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginInfo, Theme, ThemeInput, Provision } from './app.js';
|
|
2
2
|
import { DatasetDescriptor, User } from './app.js';
|
|
3
|
-
import { C as Command, T as Tab, a as CallOptions, P as Panel, b as CommandState, c as Plugin, M as Middleware, d as CommandContribution, e as TabContribution, f as Contribution } from './plugin-
|
|
4
|
-
export { g as CallContext, h as CallDefinition, i as CallHandler, j as Caller, k as CommandRun, l as CommandStateContext, E as EventCheck, F as FrameHalf, H as HandlerCallOptions, m as HandlerContext, n as HostHalf, o as MountContext, p as PanelVerb, R as Reveal, q as RevealTarget, S as Snapshot, r as TabContext, s as definePlugin } from './plugin-
|
|
3
|
+
import { C as Command, T as Tab, a as CallOptions, P as Panel, b as CommandState, c as Plugin, M as Middleware, d as CommandContribution, e as TabContribution, f as Contribution } from './plugin-BWEDh1nW.js';
|
|
4
|
+
export { g as CallContext, h as CallDefinition, i as CallHandler, j as Caller, k as CommandRun, l as CommandStateContext, E as EventCheck, F as FrameHalf, H as HandlerCallOptions, m as HandlerContext, n as HostHalf, o as MountContext, p as PanelVerb, R as Reveal, q as RevealTarget, S as Snapshot, r as TabContext, s as definePlugin } from './plugin-BWEDh1nW.js';
|
|
5
5
|
export { A as AppConsoleEvent, a as AppErrorEvent, b as AppErrorKind } from './runtimeErrors-gswksjDk.js';
|
|
6
6
|
|
|
7
7
|
interface HostOptions {
|
package/dist/host.js
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
import "./chunk-PKBMQBKP.js";
|
|
31
31
|
|
|
32
32
|
// anfra-sdk:anfra-sdk:frame-script
|
|
33
|
-
var anfra_sdk_frame_script_default = '"use strict";var __anfraKernel=(()=>{var U=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var On=Object.prototype.hasOwnProperty;var In=(t,n,e)=>n in t?U(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var i=(t,n)=>U(t,"name",{value:n,configurable:!0});var Fn=(t,n)=>{for(var e in n)U(t,e,{get:n[e],enumerable:!0})},Mn=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of $n(n))!On.call(t,o)&&o!==e&&U(t,o,{get:()=>n[o],enumerable:!(r=_n(n,o))||r.enumerable});return t};var Qn=t=>Mn(U({},"__esModule",{value:!0}),t);var c=(t,n,e)=>In(t,typeof n!="symbol"?n+"":n,e);var Wr={};Fn(Wr,{bootstrap:()=>Tn});var wt="anfra-provision";function G(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9]+/g,"_").toLowerCase()}i(G,"snakeCase");var ne=new WeakMap;function W(t,n){typeof t=="object"&&t!==null&&ne.set(t,n)}i(W,"tagCall");function bt(t){for(let n=t,e=0;typeof n=="object"&&n!==null&&e<5;n=n.cause,e+=1){let r=ne.get(n);if(r)return r}}i(bt,"callOf");function Re(t,n){let e=ne.get(t);return e&&ne.set(n,e),n}i(Re,"copyCallTag");function De(t,n){return function(...e){let r=t.apply(this,e);return r&&typeof r.then=="function"?r.then(void 0,o=>{throw W(o,n),o}):r}}i(De,"namedCall");var Te=2e3,Nn=4e3;function re(t,n){return t.length<=n?t:`${t.slice(0,n)}\\u2026 (truncated)`}i(re,"truncate");function vt(t,n){let e=n,r=typeof e=="object"&&e!==null,o={kind:t,message:re(r&&typeof e.message=="string"?e.message:String(n),Te),at:new Date().toISOString()};if(!r)return o;for(let a of["code","scope","requestId","entity"]){let l=e[a];typeof l=="string"&&(o[a]=l)}return!t.startsWith("call.")&&typeof e.stack=="string"&&(o.stack=re(e.stack,Nn)),o}i(vt,"describeError");function _e(t,n=()=>{},e=Date.now){let r=e(),o=0,a=0,l,s=i(()=>{l=void 0;let d=a;if(a=0,d>0)try{n(d)}catch{}},"flush");return{take(){let d=e();return d-r>=6e4&&(l!==void 0&&clearTimeout(l),s(),r=d,o=0),o<t?(o+=1,!0):(a+=1,l===void 0&&(l=setTimeout(s,Math.max(0,r+6e4-d))),!1)},dispose(){l!==void 0&&clearTimeout(l),s()}}}i(_e,"createBudget");var kt={query_invalid:"user",query_failed:"user",forbidden:"user",unauthenticated:"user",invalid_request:"client",declaration_invalid:"client",connection_failed:"server",call_failed:"server",internal_server_error:"server"},oe=class oe extends Error{constructor(e){super(e.message);c(this,"code");c(this,"scope");c(this,"status");c(this,"details");c(this,"context");c(this,"requestId");c(this,"entity");c(this,"cause");this.name=new.target.name,this.code=e.code,this.scope=e.scope,e.status!==void 0&&(this.status=e.status),e.details!==void 0&&(this.details=e.details),e.context!==void 0&&(this.context=e.context),e.requestId!==void 0&&(this.requestId=e.requestId),e.entity!==void 0&&(this.entity=e.entity),e.cause!==void 0&&(this.cause=e.cause),Object.setPrototypeOf(this,new.target.prototype)}about(e){return this.entity===e?this:Re(this,new oe({...Ln(this),entity:e}))}};i(oe,"DataAppError");var M=oe,ie=class ie extends M{constructor(n,e){super({code:"declaration_invalid",scope:"client",message:n,entity:e})}about(n){return this.entity===n?this:Re(this,new ie(this.message,n))}};i(ie,"ValidationError");var y=ie;function j(t){if(t instanceof M)return!0;let n=t;return n instanceof Error&&(n.name==="DataAppError"||n.name==="ValidationError")&&typeof n.code=="string"}i(j,"isDataAppError");function Et(t,n){return j(t)&&t.code===n}i(Et,"hasErrorCode");function St(t){if(!Array.isArray(t))return;let n=t.filter(e=>typeof e?.text=="string").map(e=>typeof e.step=="string"?{step:e.step,text:e.text}:{text:e.text});return n.length?n:void 0}i(St,"contextOf");function se(t,n){return new M({code:"invalid_request",scope:"client",message:t,entity:n})}i(se,"invalidRequest");function xt(t,n){return new M({code:"forbidden",scope:"user",message:t,entity:n})}i(xt,"forbidden");function At(t,n){return new M({code:"connection_failed",scope:"server",message:t,status:n})}i(At,"connectionFailed");function J(t){return new M({code:"call_failed",scope:"server",message:"The call failed.",cause:t})}i(J,"callFailed");function Ct(t,n,e={}){let{refused:r="invalid_request",requestId:o,entity:a}=e,l;return t===void 0||t===0?l="connection_failed":t===401?l="unauthenticated":t===403?l="forbidden":t>=400&&t<500?l=r:l="internal_server_error",new M({code:l,scope:Pn(l,t),message:n,status:t||void 0,requestId:o,entity:a})}i(Ct,"fromHttpStatus");function Pn(t,n){return t in kt?kt[t]:n!==void 0&&n>=400&&n<500?"user":"server"}i(Pn,"scopeOf");function Rt(t){return t==="user"||t==="client"||t==="server"?t:"server"}i(Rt,"toScope");function Ln(t){return{code:t.code,scope:t.scope,message:t.message,status:t.status,details:t.details,context:t.context,requestId:t.requestId,entity:t.entity,cause:t.cause}}i(Ln,"fieldsOf");function ae(){let t=new Error("Aborted");return t.name="AbortError",t}i(ae,"abortError");function Bn(t){return t?.name==="AbortError"}i(Bn,"isAbortError");function Kn(t){return{app:t.app,query:t.query,...t.id!==void 0&&{id:t.id},...t.variant!==void 0&&{variant:t.variant}}}i(Kn,"copyStamp");var jn=new Set(["query_invalid","validation_failed","invalid_request","result_too_large","page_too_large"]);function $e(t,n){let e=typeof n.code=="string"&&n.code?n.code:"call_failed",r={name:t,code:e,scope:Rt(n.scope),message:typeof n.message=="string"&&n.message?n.message:"The call failed."};typeof n.status=="number"&&(r.status=n.status),n.details!==void 0&&jn.has(e)&&(r.details=n.details);let o=St(n.context);return o&&(r.context=o),typeof n.requestId=="string"&&(r.requestId=n.requestId),r}i($e,"crossing");function qn(t){return j(t)?$e(t.name,t):$e("DataAppError",J())}i(qn,"toBridgeError");function Vn(t){if(!t||typeof t!="object")return J();let n=$e(t.name,t);return n.name==="ValidationError"&&n.code==="declaration_invalid"?new y(n.message):new M({code:n.code,scope:n.scope,message:n.message,status:n.status,details:n.details,context:n.context,requestId:n.requestId})}i(Vn,"fromBridgeError");function Dt(t,n){let e=new Map,r=new Map,o=1,a=i((l,s,d,u)=>{let f=new AbortController;r.set(l,f),Promise.resolve().then(()=>n.answer(s,d,f.signal,u)).then(v=>{f.signal.aborted||t({type:"anfra:result",id:l,ok:!0,result:v})}).catch(v=>{if(f.signal.aborted||Bn(v))return;let k=qn(v);if(!j(v))if(n.hidden)try{n.hidden(s,v)}catch{}else console.error(`anfra: \'${s}\' failed; the other side is told only that the call failed.`,v);t({type:"anfra:result",id:l,ok:!1,error:k})}).finally(()=>{r.get(l)===f&&r.delete(l)})},"answer");return{call(l,s,d,u){return new Promise((f,v)=>{if(d?.aborted){v(ae());return}let k=o++;e.set(k,{resolve:f,reject:v}),d?.addEventListener("abort",()=>{e.delete(k)&&(t({type:"anfra:cancel",id:k}),v(ae()))},{once:!0}),t({type:"anfra:call",id:k,name:l,request:s,...u?{stamp:Kn(u)}:{}})})},emit(l,s){t({type:"anfra:event",name:l,payload:s})},receive(l){switch(l?.type){case"anfra:call":return a(l.id,l.name,l.request,l.stamp),!0;case"anfra:result":{let s=e.get(l.id);return s&&(e.delete(l.id),l.ok?s.resolve(l.result):s.reject(Vn(l.error))),!0}case"anfra:cancel":return r.get(l.id)?.abort(),r.delete(l.id),!0;case"anfra:event":return n.event(l.name,l.payload),!0;default:return!1}},close(l){r.forEach(s=>s.abort()),r.clear(),e.forEach(({reject:s})=>s(l)),e.clear()}}}i(Dt,"createEndpoint");var Ie;function $(t,n){try{Ie?.(t,n)}catch{}}i($,"reportError");var Oe=120;function zn(t){if(typeof t=="string")return t;if(t instanceof Error)return`${t.name}: ${t.message}`;try{return JSON.stringify(t)??String(t)}catch{return String(t)}}i(zn,"textOf");function Tt(t,n,e,r=Date.now){let o=i(v=>k=>n.console?.warn(`anfra: ${k} ${v} over the ${Oe} a minute a frame sends were not sent to the host.`),"dropped"),a=_e(Oe,o("runtime errors"),r),l=_e(Oe,o("console lines"),r);Ie=i((v,k)=>{a.take()&&t.emit("error",vt(v,k))},"reporter");let s=i(v=>$("app.uncaught",v.error??v.message),"onError"),d=i(v=>{let k=bt(v.reason);$(k?`call.${k}`:"app.uncaught",v.reason)},"onRejection");n.addEventListener("error",s),n.addEventListener("unhandledrejection",d);let u=n.console,f={};if(e&&u)for(let v of["error","warn"]){let k=u[v];f[v]=k,u[v]=(...S)=>{if(k.apply(u,S),!(typeof S[0]=="string"&&S[0].startsWith("anfra:")))try{l.take()&&t.emit("console",{level:v,message:re(S.map(zn).join(" "),Te),at:new Date().toISOString()})}catch{}}}return()=>{Ie=void 0,a.dispose(),l.dispose(),n.removeEventListener("error",s),n.removeEventListener("unhandledrejection",d);for(let[v,k]of Object.entries(f))u[v]=k}}i(Tt,"installReporting");var Fe=class Fe{constructor(n){c(this,"listeners",new Set);c(this,"parent");this.parent=n}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}notifyChange(){this.listeners.forEach(n=>{try{n()}catch(e){console.error("anfra: a subscribe() listener threw; the queries carry on.",e),$("app.listener",e)}}),this.parent?.notifyChange()}notify(){this.notifyChange()}};i(Fe,"Observable");var q=Fe;function H(t,n,e=Object.keys(n)){let r={...t};return e.forEach(o=>{if(!(o in n))return;let a=n[o];a===void 0?delete r[o]:r[o]=a}),r}i(H,"withChanges");var _t=["year","quarter","month","week","day","hour","minute"];function Un(t,n){if(!_t.includes(n))throw new y(`Invalid grain \'${n}\'. Expected one of: ${_t.join(", ")}.`,t)}i(Un,"assertGrain");function Me(t,n){return n?(Un(t,n),{operator:"transform_date_drill",values:[`datetrunc ${n}`]}):{operator:"none"}}i(Me,"drillCondition");function Gn(t){let n=t.toLowerCase();return n.includes("date")||n.includes("time")?"date":n.includes("int")||n.includes("number")||n.includes("float")||n.includes("decimal")?"number":n.includes("bool")?"boolean":"string"}i(Gn,"inferType");function Wn(t,n){return JSON.stringify(t??null)===JSON.stringify(n??null)}i(Wn,"sameCondition");var Qe=class Qe extends q{constructor(e,r,o){super(r);c(this,"name");c(this,"app");c(this,"pending");c(this,"applied");c(this,"initial");c(this,"removed",!1);this.name=e,this.app=r,this.initial=o,this.pending=o}locate(){return this.assertLive(),this.app.locate("control",this.name)}async inspect(e={}){return this.assertLive(),this.app.inspect("control",this.name,e.tab)}get isRemoved(){return this.removed}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new y(`Control \'${this.name}\' was removed from its app; it can\'t be used any more.`,this.name)}markRemoved(){this.removed=!0,this.dropInFlight()}dropInFlight(){}redefault(e,r){this.initial=e,r&&(this.pending=e)}get condition(){return this.pending}get appliedCondition(){return this.applied}get isDirty(){return this.applied!==void 0&&!Wn(this.pending,this.applied)}setCondition(e){this.assertLive(),this.pending=e,this.notify()}reset(){this.assertLive(),this.setCondition(this.initial)}commit(){this.applied=this.pending}};i(Qe,"Control");var N=Qe,Y=class Y extends N{constructor(e,r,o,a,l){super(e,r,o.default??{operator:"is",values:[]});c(this,"kind","filter");c(this,"_declaration");c(this,"resolution");c(this,"backend");c(this,"loadedOptions");c(this,"loading",new Set);this.backend=l,this.resolution=Y.resolve(e,o,a),this._declaration=o,this.assertValues(this.condition.values??[]),this.assertValues(o.options??[])}static resolve(e,r,o){if(r.field){if(!o)throw new y(`Filter \'${e}\' names a field but no dataset. Pass \\`dataset\\` alongside \\`field\\`.`,e);let a=o.resolve(r.field,e);return{resolved:a,datasetName:o.descriptor.name,type:r.type??Gn(a.type)}}if(!r.type)throw new y(`Filter \'${e}\' is a manual filter, so it needs a \\`type\\`.`,e);return{type:r.type}}get declaration(){return this._declaration}get type(){return this.resolution.type}setCondition(e){this.assertLive(),this.assertValues(e.values??[]),super.setCondition(e)}update(e){this.assertLive();let r=H(this._declaration,e),o=this._declaration,a=["field","dataset","type"].some(u=>r[u]!==o[u]),l=a?Y.resolve(this.name,r,this.app.filterDataset(this.name,r)):this.resolution,s=r.default??{operator:"is",values:[]},d=i(u=>u.values??[],"values");this.assertValuesOf(l.type,d(s)),this.assertValuesOf(l.type,r.options??[]),a||this.assertValuesOf(l.type,d(this.condition)),this._declaration=r,this.resolution=l,this.redefault(s,a),a&&(this.loadedOptions=void 0,this.dropInFlight()),this.notify()}dropInFlight(){this.loading.forEach(e=>e.abort()),this.loading.clear()}assertValues(e){this.assertValuesOf(this.type,e)}assertValuesOf(e,r){if(e!=="number")return;let o=r.find(a=>typeof a=="number");if(o!==void 0)throw new y(`Filter \'${this.name}\' filters numbers: give its values as strings, as query results give them (${JSON.stringify(String(o))}, not ${String(o)}), so none has lost a digit.`,this.name)}get isFieldBacked(){return this.resolution.resolved!==void 0}get options(){return this.loadedOptions??this._declaration.options??[]}async loadOptions(e,r=new AbortController().signal){this.assertLive();let{resolved:o,datasetName:a}=this.resolution,l=o?.modelName;if(!o||!l||!this.backend||!a)return this.options;let s=new AbortController,d=i(()=>s.abort(),"follow");r.aborted?s.abort():r.addEventListener("abort",d,{once:!0}),this.loading.add(s);try{let u=await this.backend.fieldSuggestions({dataset:a,model:l,field:o.fieldName,q:e??""},s.signal).catch(f=>{throw W(f,"load_options"),f});if(s.signal.aborted&&!this.loading.has(s))throw ae();return this.loadedOptions=[...u??[]],this.notify(),this.loadedOptions}finally{this.loading.delete(s),r.removeEventListener("abort",d)}}toJSON(){return this._declaration}};i(Y,"Filter");var le=Y,Ne=class Ne extends N{constructor(e,r,o={}){super(e,r,Me(e,o.default));c(this,"kind","dateDrill");c(this,"_declaration");this._declaration=o}get declaration(){return this._declaration}update(e){this.assertLive();let r=H(this._declaration,e),o=Me(this.name,r.default);this._declaration=r,this.redefault(o,!1),this.notify()}setGrain(e){this.assertLive(),this.setCondition(Me(this.name,e))}toJSON(){return this._declaration}};i(Ne,"DateDrillControl");var de=Ne;function $t(t){t.handle("execute",async()=>{let n=await Promise.all(t.sdk.apps.map(e=>e.refresh()));return{succeeded:n.flatMap(e=>e.succeeded),failed:n.flatMap(e=>e.failed)}})}i($t,"installCore");var O={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},ue=`[${O.container}],[${O.block}],[${O.query}],[${O.control}]`;function Ot(t){let n=/^(?:(\\d+)\\/)?([^/\\s]+)$/.exec(t);if(n)return{app:n[1]===void 0?0:Number(n[1]),name:n[2]}}i(Ot,"parseRef");var It=i(t=>(t??"").split(/\\s+/).filter(Boolean),"tokens");function ce(t,n,e,r){let o=n==="query"?O.query:O.control;return[...t.querySelectorAll(`[${o}]`)].filter(a=>It(a.getAttribute(o)).some(l=>{let s=Ot(l);return s?.app===e&&s.name===r}))}i(ce,"markersFor");var Jn=i((t,n,e)=>{let r=t[e.app];return r?Object.prototype.hasOwnProperty.call(n==="query"?r.queries:r.controls,e.name):!1},"hasEntity");function Ft(t,n){var v;let e=[],r=new Map,o=new Map,a=new Map,l=new Map,s={container:new Set,block:new Set},d={},u=i((k,S,R)=>{let I=k?a.get(k).children:e,h=k?`${a.get(k).key}.`:"",b={...S,key:`${h}${I.length}`,children:[]};return I.push(b),r.set(b.key,R),o.set(R,[...o.get(R)??[],b.key]),b},"place");for(let k of t.querySelectorAll(ue)){let S=k.parentElement?.closest(ue)??null,R=k.getAttribute(O.container),I=k.getAttribute(O.block),h=k.getAttribute(O.label)??void 0,b=S&&(l.get(S)==="block"?S:S.closest(`[${O.block}]`)),m;if(R!==null||I!==null){let p=R!==null?"container":"block",g=(R??I??"").trim(),w=[];R!==null&&I!==null&&w.push("This element is marked as a container and as a block. It counts as a container."),g?s[p].has(g)?w.push(`Another ${p} already has the id "${g}".`):s[p].add(g):w.push(`This ${p} has no id.`),b&&w.push(`A block can\'t hold a ${p}. This one is inside the block "${b.getAttribute(O.block)}".`),m=u(S,{kind:p,id:g,...h!==void 0?{label:h}:{},problems:w},k),a.set(k,m),l.set(k,p)}let C=m?k:S;for(let p of["query","control"])for(let g of It(k.getAttribute(p==="query"?O.query:O.control))){let w=Ot(g),E=[];if(w?Jn(n,p,w)||E.push(n[w.app]?`No ${p} is called "${w.name}" in app ${w.app}.`:`The page has no app ${w.app}.`):E.push(`Can\'t read "${g}". Write the ${p}\'s name, or app/name when the page has several apps.`),u(C,{kind:p,name:w?.name??g,app:w?.app??0,problems:E},k),w&&!E.length){let A=`${w.app}/${w.name}`,x=d[v=`${p}:${A}`]??(d[v]={elements:new Set,blocks:new Set});x.elements.add(k);let T=m?.kind==="block"?m.id:b?.getAttribute(O.block);T&&x.blocks.add(T)}}}let f=Object.fromEntries(Object.entries(d).map(([k,S])=>[k,{markers:S.elements.size,blocks:[...S.blocks]}]));return{nodes:e,usage:f,elements:r,keysOf:o}}i(Ft,"buildStructure");var Hn=i((t,n,e)=>`${t}:${n}/${e}`,"usageKey");function Yn(t){let n=t.getBoundingClientRect();return`${Math.round(n.width)} \\xD7 ${Math.round(n.height)}`}i(Yn,"sizeOf");function Mt(t,n,e){let r=Yn(n);if(t.kind==="container"||t.kind==="block")return{kind:t.kind,name:t.id??"",...t.label?{label:t.label}:{},size:r};let o=e.usage[Hn(t.kind,t.app??0,t.name??"")];return{kind:t.kind,name:t.name??"",...o&&o.markers>1?{note:`1 of ${o.markers}`}:{},size:r}}i(Mt,"describeNode");var Pt=["color-bg","color-fg","color-muted","color-border","color-accent","color-danger","radius","font","font-mono","color-bg-sunken","color-fg-weak","color-border-strong","color-hover","color-active","color-selected","color-warning","color-success"],Qt="\'Inter Variable\', ui-sans-serif, system-ui, sans-serif",Nt="\'Geist Mono Variable\', ui-monospace, monospace",Pe={light:{"color-bg":"oklch(1 0 0)","color-bg-sunken":"oklch(0.973 0.005 95.1)","color-fg":"oklch(0.201 0.022 301.1)","color-fg-weak":"oklch(0.392 0.021 304.3)","color-muted":"oklch(0.485 0.022 306.3)","color-border":"oklch(0.201 0.022 301.1 / 0.12)","color-border-strong":"oklch(0.201 0.022 301.1 / 0.24)","color-accent":"oklch(0.484 0.181 298.1)","color-danger":"oklch(0.501 0.17 27.2)","color-warning":"oklch(0.501 0.1 70.3)","color-success":"oklch(0.479 0.1 151.8)","color-hover":"oklch(0.201 0.022 301.1 / 0.05)","color-active":"oklch(0.201 0.022 301.1 / 0.09)","color-selected":"oklch(0.946 0.027 304.8)",radius:"10px",font:Qt,"font-mono":Nt},dark:{"color-bg":"oklch(0.19 0.012 300)","color-bg-sunken":"oklch(0.157 0.009 296.9)","color-fg":"oklch(0.961 0.007 304.2)","color-fg-weak":"oklch(0.879 0.016 302.5)","color-muted":"oklch(0.835 0.018 300)","color-border":"oklch(0.343 0.025 298.2)","color-border-strong":"oklch(0.392 0.021 304.3)","color-accent":"oklch(0.845 0.085 300)","color-danger":"oklch(0.82 0.09 27)","color-warning":"oklch(0.84 0.12 69.6)","color-success":"oklch(0.8 0.12 151.9)","color-hover":"oklch(1 0 0 / 0.06)","color-active":"oklch(1 0 0 / 0.1)","color-selected":"oklch(0.565 0.194 300.3 / 0.18)",radius:"10px",font:Qt,"font-mono":Nt}};var Xn=/[;{}<>]|url\\(|expression\\(|@import|\\\\/i;function Lt(t){let n=typeof t=="object"&&t!==null?t:{},e=n.scheme==="dark"?"dark":"light",r={...Pe[e]},o=typeof n.tokens=="object"&&n.tokens!==null?n.tokens:{},a=new Set;for(let l of Pt){let s=o[l];typeof s=="string"&&s.trim()!==""&&s.length<=200&&!Xn.test(s)&&(r[l]=s.trim(),a.add(l))}for(let[l,{from:s,value:d}]of Object.entries(Zn)){if(a.has(l)||!s.some(f=>a.has(f)))continue;let u=d(r);u.length<=200&&(r[l]=u)}return Object.freeze({scheme:e,tokens:Object.freeze(r)})}i(Lt,"resolveTheme");var Zn={"color-bg-sunken":{from:["color-fg","color-bg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 4%, ${t["color-bg"]})`,"value")},"color-fg-weak":{from:["color-fg","color-bg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 80%, ${t["color-bg"]})`,"value")},"color-border-strong":{from:["color-fg","color-border"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 10%, ${t["color-border"]})`,"value")},"color-hover":{from:["color-fg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 7%, transparent)`,"value")},"color-active":{from:["color-fg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 12%, transparent)`,"value")},"color-selected":{from:["color-accent"],value:i(t=>`color-mix(in srgb, ${t["color-accent"]} 14%, transparent)`,"value")}};function Le(t,n){for(let e of Pt)t.setProperty(`--anfra-${e}`,n.tokens[e]);t.setProperty("color-scheme",n.scheme)}i(Le,"applyTheme");var Be="data-anfra-layer",Bt=new WeakMap,er="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483647;";function tr(t){let n=t.querySelector(`[${Be}]`);if(n instanceof(t.defaultView?.HTMLElement??HTMLElement))return n;let e=t.createElement("div");e.setAttribute(Be,""),e.setAttribute("style",er);let r=Bt.get(t);return r&&Le(e.style,r),(t.body??t.documentElement).appendChild(e),e}i(tr,"layerOf");function K(t,n){let e=tr(t),r=[...e.children].find(a=>a.getAttribute("data-part")===n);if(r?.shadowRoot)return r.shadowRoot;let o=t.createElement("div");return o.setAttribute("data-part",n),e.appendChild(o),o.attachShadow({mode:"open"})}i(K,"layerRoot");function Kt(t,n){Bt.set(t,n);let e=t.querySelector(`[${Be}]`);e&&Le(e.style,n)}i(Kt,"themeLayer");var jt="anfra-overlay",nr=1500,rr="position:fixed;box-sizing:border-box;background:oklch(0.546 0.215 262.9 / 0.22);outline:1px solid oklch(0.546 0.215 262.9);outline-offset:-1px;",or="position:fixed;max-width:60vw;display:flex;gap:6px;align-items:baseline;padding:3px 8px;border-radius:4px;background:oklch(0.208 0.04 265.8);color:oklch(0.984 0.003 247.9);font:12px/1.4 system-ui,sans-serif;white-space:nowrap;box-shadow:0 2px 8px oklch(0 0 0 / 0.35);",ir={kind:"color:oklch(0.711 0.035 256.8);",name:"color:oklch(0.809 0.096 251.8);font-weight:700;",label:"color:oklch(0.984 0.003 247.9);",note:"color:oklch(0.711 0.035 256.8);",size:"color:oklch(0.711 0.035 256.8);margin-left:10px;"},je=class je{constructor(n){c(this,"doc",n);c(this,"root");c(this,"shown",[]);c(this,"text",{kind:"",name:""});c(this,"timer");c(this,"reposition",i(()=>this.draw(),"reposition"));let e=K(n,"anfra"),r=e.getElementById(jt);r instanceof(n.defaultView?.HTMLElement??HTMLElement)?this.root=r:(this.root=n.createElement("div"),this.root.id=jt,this.root.setAttribute("aria-hidden","true"),this.root.setAttribute("style","position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:none;"),e.appendChild(this.root))}show(n,e){if(this.clearTimer(),this.root.isConnected||K(this.doc,"anfra").appendChild(this.root),this.shown=[...n],this.text=e,!this.shown.length){this.hide();return}this.root.style.display="block",this.draw(),this.doc.addEventListener("scroll",this.reposition,{capture:!0,passive:!0}),this.doc.defaultView?.addEventListener("resize",this.reposition)}flash(n,e,r=nr){this.show(n,e),this.timer=setTimeout(()=>this.hide(),r)}hide(){this.clearTimer(),this.shown=[],this.root.style.display="none",this.root.replaceChildren(),this.doc.removeEventListener("scroll",this.reposition,{capture:!0}),this.doc.defaultView?.removeEventListener("resize",this.reposition)}get visible(){return this.shown.length>0}clearTimer(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}draw(){let n=this.shown.map(s=>{let d=s.getBoundingClientRect(),u=this.doc.createElement("div");return u.setAttribute("style",`${rr}left:${d.left}px;top:${d.top}px;width:${d.width}px;height:${d.height}px;`),u}),e=this.shown[0].getBoundingClientRect(),r=this.doc.createElement("div");r.setAttribute("data-testid","anfra-overlay-label");let o=this.doc.defaultView?.innerHeight??0,a=e.top>=26?e.top-24:Math.max(4,e.top+4),l=Math.max(4,Math.min(e.left,(this.doc.defaultView?.innerWidth??0)-24));r.setAttribute("style",`${or}left:${l}px;top:${Math.min(a,o-24)}px;`);for(let s of["kind","name","label","note","size"]){let d=this.text[s];if(!d)continue;let u=this.doc.createElement("span");u.setAttribute("style",ir[s]),u.setAttribute("data-part",s),u.textContent=d,r.appendChild(u)}this.root.replaceChildren(...n,r)}};i(je,"Overlay");var Ke=je,qt=new WeakMap;function pe(t){let n=qt.get(t);return n||(n=new Ke(t),qt.set(t,n)),n}i(pe,"overlayFor");function fe(t){typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}i(fe,"scrollTo");function Vt(t,n){let e=null,r=i(d=>d.target instanceof Element?d.target.closest(ue):null,"under"),o=i(d=>{let u=r(d);u!==e&&(e=u,n.onHover(u))},"onMove"),a=i(d=>{d.preventDefault(),d.stopPropagation();let u=r(d);u&&n.onPick(u)},"onClick"),l=i(d=>{d.key==="Escape"&&n.onCancel()},"onKey"),s={capture:!0};return t.addEventListener("mousemove",o,s),t.addEventListener("click",a,s),t.addEventListener("keydown",l,s),()=>{t.removeEventListener("mousemove",o,s),t.removeEventListener("click",a,s),t.removeEventListener("keydown",l,s)}}i(Vt,"startPick");function zt(t,n){for(let e of t){if(e.key===n)return e;let r=zt(e.children,n);if(r)return r}}i(zt,"findNode");function Ut(t){let n=t.window,e=n.document,r=!1,o,a,l="",s,d;function u(){if(o=void 0,!!r)try{a=t.structure(),l=JSON.stringify(a.nodes),t.emit("snapshot",{apps:t.sdk.apps.map(h=>h.toInspectJSON()),structure:{nodes:a.nodes,usage:a.usage}})}catch{}}i(u,"postSnapshot");function f(){r&&o===void 0&&(o=setTimeout(u,50))}i(f,"scheduleSnapshot");function v(){let h=n.MutationObserver;if(s||typeof h!="function")return;let b=new h(()=>{if(!(!r||o!==void 0))try{JSON.stringify(t.structure().nodes)!==l&&f()}catch{}});s=b,b.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Object.values(O)})}i(v,"observeStructure");function k(h){let b=h!==null&&a?zt(a.nodes,h):void 0,m=h!==null?a?.elements.get(h):void 0;if(!b||!m||!a){t.overlay.hide();return}t.overlay.show([m],Mt(b,m,a))}i(k,"highlight");function S(h){if(!h){d?.(),d=void 0;return}if(d)return;let b=i(m=>a?.keysOf.get(m)?.[0],"keyOf");d=Vt(e,{onHover:i(m=>k(m?b(m)??null:null),"onHover"),onPick:i(m=>{let C=b(m);C!==void 0&&t.emit("picked",{node:C})},"onPick"),onCancel:i(()=>{S(!1),t.overlay.hide(),t.emit("picked",{node:null})},"onCancel")})}i(S,"setPicking");function R(h){r=h,h?(v(),u()):(s?.disconnect(),s=void 0,S(!1),t.overlay.hide(),a=void 0,l="")}i(R,"setInspecting");function I(h){if("node"in h){let b=a?.elements.get(h.node);b&&fe(b),k(h.node)}else t.sdk.apps[h.app]?.locate(h.kind,h.name);f()}i(I,"locate"),t.on("watch",h=>R(h===!0)),t.on("highlight",h=>k(h)),t.on("locate",h=>I(h)),t.on("pick",h=>S(h===!0)),t.onApp(h=>{h.subscribe(f),f()})}i(Ut,"installInspection");function Ve(t){return{label:t.label||sr(t),...t.detail?{detail:t.detail}:{},...t.severity?{severity:t.severity}:{},plugin:t.plugin}}i(Ve,"annotationNote");function sr(t){switch(t.kind){case"line":return`${t.anchor.column} at ${t.anchor.value}`;case"band":return`${t.anchor.column} from ${t.anchor.from} to ${t.anchor.to}`;case"series":return`A series of ${t.anchor.measure}`;case"focus":return"In focus";case"mark":return"Marked"}}i(sr,"defaultLabel");function Gt(t){if(t.kind!=="rows"||!t.annotations)return t;let{annotations:n,...e}=t;return e}i(Gt,"forHost");var qe;function Wt(t,n){return qe?qe(t,n):!1}i(Wt,"openRowsMenu");var ar=`[${O.block}]`,lr=\'[data-anfra-menu="off"]\',dr=i(t=>({...t,children:t.children.map(n=>({...n,children:[]}))}),"bare");function Jt(t,n,e=[]){for(let r of t){if(r.key===n)return[...e,r];let o=Jt(r.children,n,[...e,r]);if(o)return o}}i(Jt,"pathTo");var ur=i(t=>typeof t?.closest=="function","isElement");function Ht(t){let n=t.window,e=n.document,r=[],o=new Set,a=!1,l,s,d=i(()=>t.body(),"ui"),u=i(()=>K(e,"anfra-ui"),"root"),f=i(p=>o.has(p)||r.some(g=>g.target===p),"offered"),v=i(()=>{let p=l;l=void 0,s=void 0,p?.()},"closeCurrent");function k(p){let g=ur(p)?p.closest(ar):null;return g&&!g.closest(lr)?g:void 0}i(k,"blockOf");function S(p){let g=t.structure(),w=g.keysOf.get(p)?.[0],E=w!==void 0?Jt(g.nodes,w):void 0;if(!E)return;let{x:A,y:x,width:T,height:_}=p.getBoundingClientRect();return{kind:"node",node:dr(E[E.length-1]),ancestors:E.slice(0,-1).map(D=>({...D,children:[]})),rect:{x:A,y:x,width:T,height:_}}}i(S,"nodeTarget");function R(p){let g=new Map,w=[];for(let E of r){if(E.target!==p.kind)continue;let A=!0;try{A=E.when?E.when(p)!==!1:!0}catch{A=!1}if(!A)continue;let x=`frame:${E.full}:${p.kind}`;if(!E.entries){w.push({id:x,label:E.label}),g.set(x,()=>E.run(p));continue}let T=[];try{T=E.entries(p)??[]}catch{T=[]}T.forEach((_,D)=>{if(typeof _?.label!="string")return;let F=typeof _.disabled=="string"&&_.disabled?_.disabled:void 0;if(!F&&typeof _.run!="function")return;let L=`${x}:${D}`;w.push({id:L,label:_.label,...F?{disabled:F}:{}}),F||g.set(L,_.run)})}return{entries:w,run:g}}i(R,"frameEntries");async function I(p,g){let w=new Map(g.run),E=[...g.entries];if(o.has(p.kind))try{let A=await t.call("anfra.menu",Gt(p));for(let x of Array.isArray(A)?A:[]){if(typeof x?.id!="string"||typeof x.label!="string")continue;let T=`host:${x.id}:${p.kind}`;E.push({id:T,label:x.label,...typeof x.disabled=="string"?{disabled:x.disabled}:{}}),w.set(T,()=>t.call("anfra.run",{id:x.id,target:Gt(p)}))}}catch{}return{entries:E,run:w}}i(I,"entriesFor");function h(p,g,w){let E=g.flatMap(D=>D.kind==="rows"?D.annotations??[]:[]).map(Ve),A=g.map(D=>({target:D,own:R(D)})).filter(({target:D,own:F})=>F.entries.length||o.has(D.kind));if(!A.length&&!E.length)return!1;p.preventDefault();let x=p,T=typeof x.clientX=="number"?x.clientX:0,_=typeof x.clientY=="number"?x.clientY:0;return(async()=>{let[D,...F]=await Promise.all([d(),...A.map(({target:B,own:V})=>I(B,V))]),L=F.map(B=>B.entries).filter(B=>B.length);if(!L.length&&!E.length)return;v();let z=D.menu(u(),{x:T,y:_,...E.length?{notes:E}:{},groups:L,onPick:i(B=>{let V=F.map(te=>te.run.get(B)).find(Boolean);Promise.resolve().then(V).catch(te=>{n.console?.error("anfra: a menu item failed:",te),$("plugin.uncaught",te)})},"onPick"),onClose:i(()=>{l===z&&(l=void 0)},"onClose")});l=z,s=w})().catch(D=>{n.console?.error("anfra: the menu failed to open:",D),$("plugin.uncaught",D)}),!0}i(h,"open");function b(){a||!(f("node")||f("rows"))||(a=!0,n.addEventListener("contextmenu",p=>{if(p.defaultPrevented||p.shiftKey)return;let g=k(p.target),w=g&&S(g);w&&h(p,[w])}))}i(b,"listen"),qe=i((p,g)=>{if(p.defaultPrevented||p.shiftKey)return!1;let w=k(p.target),E=w?S(w):void 0,A=p,x=typeof A.clientX=="number"&&typeof A.clientY=="number"?{x:A.clientX,y:A.clientY}:void 0,T={...g,...E?{node:E}:{},...x?{at:x}:{}};return h(p,E?[T,E]:[T],{app:g.app,query:g.query})},"rowsOpener"),t.onApp(p=>p.onRemoved(g=>{g.kind==="query"&&s?.app===p.index&&s.query===g.name&&v()})),t.on("menu",p=>{let g=p?.kinds;o=new Set((Array.isArray(g)?g:[]).filter(w=>w==="node"||w==="rows")),b()});let m=i(p=>g=>{try{return p(g)}catch(w){throw $("plugin.uncaught",w),w}},"reported");async function C(p,g){let w=await d();v();let E=i(()=>{},"close");return E=g(w,i(()=>{l===E&&(l=void 0);try{p.onClose?.()}catch{}},"onClose")),l=E,s=p.about?{app:p.about.app,query:p.about.query}:void 0,{close:E}}return i(C,"show"),{addItem(p,g){r.push({...g,full:`${p}.${g.id}`,plugin:p}),b()},modal:i(p=>C(p,(g,w)=>g.modal(u(),{title:p.title,size:p.size,mount:m(p.mount),onClose:w})),"modal"),popoverAt:i((p,g)=>C(g,(w,E)=>w.popover(u(),{anchor:p,side:g.side,mount:m(g.mount),dismiss:g.dismiss,closeButton:g.closeButton,onClose:E})),"popoverAt"),rowsEntries(p,g){return r.filter(w=>w.plugin===p).flatMap(w=>{if(w.target!=="rows")return[];try{return w.when&&w.when(g)===!1?[]:w.entries?(w.entries(g)??[]).filter(E=>typeof E?.label=="string"&&(E.disabled||typeof E.run=="function")):[{label:w.label,run:i(()=>w.run(g),"run")}]}catch{return[]}})},popover:i(p=>C(p,(g,w)=>{let{anchor:E}=p,A;if("kind"in E){let x=t.structure().elements.get(E.node.key);A=i(()=>{if(!x?.isConnected)return;let{x:T,y:_,width:D,height:F}=x.getBoundingClientRect();return{x:T,y:_,width:D,height:F}},"rect")}else A=i(()=>({x:E.x,y:E.y,width:0,height:0}),"rect");return g.popover(u(),{anchor:A,side:p.side,mount:m(p.mount),dismiss:p.dismiss,closeButton:p.closeButton,onClose:w})}),"popover")}}i(Ht,"installContentUi");var cr={query:"Query",control:"Control"};function pr(t){let n=t.navigator.userActivation;return n?n.isActive:!0}i(pr,"activated");function Yt(t){let n=i(async e=>{if(!pr(t.window))return $("call.inspect",new y(`${cr[e.entity]} \'${e.name}\' can\'t open the panel without a reader\'s click. Call inspect() from a click handler, such as a button\'s.`,e.name)),!1;try{return await t.call("anfra.reveal",e)===!0}catch(r){return $("call.inspect",r),!1}},"reveal");t.onApp(e=>{e.revealer=n})}i(Yt,"installReveal");function fr(t,n){let e=t.length+1,r=n.length+1,o=Array.from({length:r},(a,l)=>l);for(let a=1;a<e;a++){let l=[a];for(let s=1;s<r;s++)l[s]=Math.min(o[s]+1,l[s-1]+1,o[s-1]+(t[a-1]===n[s-1]?0:1));o=l}return o[r-1]}i(fr,"editDistance");function ze(t,n){let e,r=1/0;n.forEach(a=>{let l=fr(t.toLowerCase(),a.toLowerCase());l<r&&(r=l,e=a)});let o=Math.max(2,Math.floor(t.length/3));return r<=o?e:void 0}i(ze,"suggest");function P(t,n,e){let r=ze(n,e);return r?`${t} Did you mean \'${r}\'?`:t}i(P,"withSuggestion");var me=["mark","focus","line","band","series"],ge=["info","warning","critical"],he=i(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"isObject");function Xt(t,n,e,r){if(!Array.isArray(r))throw new y(`Plugin \'${t}\' annotated query \'${n}\' with something other than a list of annotations.`,n);let o=new Set;return r.map((a,l)=>{let s=`Annotation ${l} of plugin \'${t}\' on query \'${n}\'`,d=i(S=>{throw new y(`${s} ${S}`,n)},"fail");if(!he(a))return d("is not an object.");let{kind:u}=a;if(!me.includes(u))return d(`has kind \'${String(u)}\', but a kind is one of ${me.map(S=>`\'${S}\'`).join(", ")}.`);let f={};for(let S of["id","label","detail"]){let R=a[S];R!==void 0&&(typeof R!="string"&&d(`has a ${S} that isn\'t a string.`),f[S]=R)}f.id!==void 0&&(o.has(f.id)&&d(`has the id \'${f.id}\', which another annotation in the set has.`),o.add(f.id)),a.severity!==void 0&&(ge.includes(a.severity)||d(`has severity \'${String(a.severity)}\', but a severity is \'info\', \'warning\' or \'critical\'.`),f.severity=a.severity);let v=mr(e.columns,d),k=he(a.anchor)?a.anchor:d("has no anchor.");return{kind:u,...f,anchor:v(u,k)}})}i(Xt,"checkAnnotations");function mr(t,n){let e=i((l,s)=>{let d=typeof l=="string"?t.find(u=>u.name===l):void 0;return d||n(typeof l=="string"?P(`names ${s} \'${l}\', but the result has no column \'${l}\'.`,l,t.map(u=>u.name)):`has no ${s}.`)},"column"),r=i(l=>{let s=e(l,"the measure");return s.isMeasure||n(`names \'${s.name}\' as its measure, but \'${s.name}\' is not a measure column.`),s.name},"measure"),o=i((l,s)=>typeof l=="string"?l:n(`has a ${s} that isn\'t a string. Values are strings, as rows carry them.`),"string"),a=i((l,s)=>{if(!he(l)||!Object.keys(l).length)return n(`has a ${s} that doesn\'t name a row by its dimension values.`);for(let d of Object.keys(l))e(d,"the column").isMeasure&&n(`names a ${s} by \'${d}\', a measure; name rows by their dimension values.`);return{...l}},"dimensions");return(l,s)=>{if(l==="mark"||l==="focus")return(!Array.isArray(s.rows)||!s.rows.length)&&n("has no rows in its anchor."),{rows:s.rows.map(v=>a(v,"row")),...s.measure!==void 0?{measure:r(s.measure)}:{}};if(l==="line")return{column:e(s.column,"the column").name,value:o(s.value,"value")};if(l==="band")return(s.from===void 0||s.to===void 0)&&n("needs a from and a to in its anchor."),{column:e(s.column,"the column").name,from:o(s.from,"from"),to:o(s.to,"to")};let d=r(s.measure);(!Array.isArray(s.points)||!s.points.length)&&n("has no points in its anchor.");let u=s.points.map(f=>{if(!he(f))return n("has a point that is not an object.");let v=f.lower!==void 0&&f.upper!==void 0;return f.value===void 0&&!v&&n("has a point with neither a value nor both bounds (lower and upper)."),f.lower===void 0!=(f.upper===void 0)&&n("has a point with one bound: give its value or bounds, both lower and upper."),{at:a(f.at,"point"),...f.value!==void 0?{value:o(f.value,"value")}:{},...v?{lower:o(f.lower,"lower bound"),upper:o(f.upper,"upper bound")}:{}}});return{measure:d,points:u}}}i(mr,"anchorChecker");var hr=i((t,n)=>JSON.stringify(t??null)===JSON.stringify(n??null),"sameValue"),Ue=i((t,n)=>Object.keys(t).every(e=>hr(t[e],n[e])),"rowMatches");function Zt(t,n){let e=[];for(let[r,o]of t)o.forEach((a,l)=>{let s=`${r}:${a.id??l}`;if(a.kind!=="mark"&&a.kind!=="focus"){e.push({...a,plugin:r,key:s});return}let d=[],u=[];for(let f of a.anchor.rows){let v=!1;n.forEach((k,S)=>{Ue(f,k)&&(v=!0,u.includes(S)||u.push(S))}),v&&d.push(f)}u.length&&e.push({...a,anchor:{...a.anchor,rows:d,index:u.sort((f,v)=>f-v)},plugin:r,key:s})});return e}i(Zt,"resolveAnnotations");var en="data-anfra-annotations";function gr(t){let n=t.getAttribute(en);return n?.trim()==="off"?"off":new Set((n??"").split(/\\s+/).filter(e=>me.includes(e)))}i(gr,"drawnBy");function yr(t,n){let e=gr(t);return e==="off"?[]:n.filter(r=>!e.has(r.kind))}i(yr,"badgedAnnotations");function wr(t){let n=-1;for(let{severity:e}of t)n=Math.max(n,e?ge.indexOf(e):-1);return n<0?void 0:ge[n]}i(wr,"highest");var br=i((t,n)=>`${t} annotation${t===1?"":"s"}${n?`, highest: ${n}`:""}`,"describe");function tn(t,n){let e=t.window.document,r=t.window,o=[],a=!1,l=!1,s,d=new WeakMap,u=0,f=i(m=>(d.has(m)||d.set(m,u+=1),d.get(m)),"listId"),v=i(()=>t.body(),"ui");function k(m,C,p,g){let w=C.result?.rows;if(p.kind!=="mark"&&p.kind!=="focus"||!w)return[];let E=m.rowsTarget(C,p.anchor.index.map(A=>w[A]),void 0,p.anchor.measure);return n.rowsEntries(p.plugin,{...E,...g?{at:g}:{},annotations:[p]})}i(k,"actionsFor");async function S(m,C,p,g){let w=await v(),E=g(),A=E?{x:E.x,y:E.y+E.height}:void 0,x=n.popoverAt(g,{about:{app:m.index,query:C.name},side:"bottom",dismiss:"outside",mount:i(T=>w.annotationList(T,p.map(_=>({...Ve(_),actions:k(m,C,_,A)})),_=>{x.then(D=>D.close()),Promise.resolve().then(_.run).catch(D=>{r.console?.error("anfra: an annotation\'s action failed:",D),$("plugin.uncaught",D)})}),"mount")});await x}i(S,"open");let R={signature:"",elements:[]};async function I(){a=!1;let m=[],C=[],p=!1;for(let A of o)for(let x of Object.values(A.queries)){let{annotations:T}=x;T.length&&(p=!0,ce(e,"query",A.index,x.name).forEach((_,D)=>{let F=yr(_,T);if(!F.length)return;let L=wr(F),z=`${A.index}/${x.name}#${D}`;C.push(`${z}:${f(T)}:${F.length}`),m.push({id:z,element:_,count:F.length,...L?{severity:L}:{},label:br(F.length,L),onOpen:i(B=>{S(A,x,F,B).catch(V=>{r.console?.error("anfra: the annotations popover failed to open:",V),$("plugin.uncaught",V)})},"onOpen")})}))}b(p);let g=m.map(A=>A.element),w=C.join("|");if(w===R.signature&&g.every((A,x)=>A===R.elements[x])||(R={signature:w,elements:g},!m.length&&!l))return;l=!0,(await v()).badges(K(e,"anfra-badges"),m)}i(I,"draw");let h=i(()=>{a||(a=!0,queueMicrotask(()=>{I().catch(m=>{r.console?.error("anfra: the annotations badge failed to draw:",m),$("plugin.uncaught",m)})}))},"schedule");function b(m){m&&!s&&typeof r.MutationObserver=="function"?(s=new r.MutationObserver(h),s.observe(e.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[O.query,en]})):!m&&s&&(s.disconnect(),s=void 0)}i(b,"watchPage"),t.onApp(m=>{o.push(m),m.subscribe(h),m.onRemoved(h)})}i(tn,"installAnnotationBadges");var nn=["ctrl","alt","shift","meta"];function rn(t){if(typeof t!="string")return;let n=t.split("+").map(o=>o.trim().toLowerCase()).filter(Boolean),e=n.pop(),r=i(o=>nn.includes(o),"isModifier");if(!(!e||r(e)||!n.every(r)))return[...nn.filter(o=>n.includes(o)),e].join("+")}i(rn,"normalizeShortcut");function on(t){let n=t;return!n||typeof n.tagName!="string"?!1:n.isContentEditable===!0||["INPUT","TEXTAREA","SELECT"].includes(n.tagName.toUpperCase())}i(on,"isTyping");function sn(t){let n=typeof t.code=="string"?t.code:"",e=/^Key[A-Z]$/.test(n)?n.slice(3).toLowerCase():/^Digit[0-9]$/.test(n)?n.slice(5):(t.key??"").toLowerCase();return[t.ctrlKey&&"ctrl",t.altKey&&"alt",t.shiftKey&&"shift",t.metaKey&&"meta",e].filter(Boolean).join("+")}i(sn,"eventShortcut");function Ge(t,n,e,r,o){if(r in n||t.has(r))throw new y(`Plugin \'${r}\' can\'t add \'${r}\' to a ${e}: it already has one.`);t.set(r,o)}i(Ge,"addExtension");function ye(t,n){return n?.forEach((e,r)=>{let o=!1,a;Object.defineProperty(t,r,{configurable:!0,enumerable:!1,get(){return o||(a=e(t),o=!0),a}})}),t}i(ye,"applyExtensions");var vr="anfra.body",We="__anfraBodyExports",kr={DataAppError:M,ValidationError:y,invalidRequest:se,forbidden:xt,connectionFailed:At,callFailed:J,fromHttpStatus:Ct,hasErrorCode:Et,isDataAppError:j};function Er(t,n){let e=t,r=t.document.createElement("script");r.textContent=`(function () { var __anfraBody;\n${n}\n;self[${JSON.stringify(We)}] = __anfraBody; })();`,(t.document.head??t.document.documentElement).appendChild(r),r.remove();let o=e[We];if(delete e[We],!o)throw new y("The host sent a plugin body that did not run.");return o.default??o}i(Er,"runBody");function Je(t,n){if(typeof t=="function")return De(t,n);if(typeof t!="object"||t===null)return t;let e=new Map;return new Proxy(t,{get(r,o,a){let l=Reflect.get(r,o,a);if(typeof l!="function"||typeof o!="string")return l;let s=e.get(o);if(s?.of===l)return s.fn;let d=De(l.bind(r),`${n}_${G(o)}`);return e.set(o,{of:l,fn:d}),d}})}i(Je,"namedMember");function Sr(t,{app:n,query:e,variant:r}){let o=t.apps[n]?.queries??{},a=Object.hasOwn(o,e)?o[e]?.id:void 0;return{app:n,query:e,...a!==void 0&&{id:a},...r!==void 0&&{variant:r}}}i(Sr,"withQueryId");function we(t,n,e){let{window:r,sdk:o,endpoint:a}=n,l;return{plugin:t,window:r,sdk:o,errors:kr,get overlay(){return pe(r.document)},structure:i(()=>Ft(r.document,o.apps),"structure"),queryRequest(s){let d=o.apps.find(u=>u.queries[s?.name]===s);if(!d)throw new y(`Query \'${String(s?.name)}\' belongs to no app.`,s?.name);return d.requestFor(s)},call:i((s,d,u,f)=>a.call(s,d??null,u,f&&Sr(o,f)),"call"),emit:i((s,d)=>a.emit(`${t}.${s}`,d??null),"emit"),handle(s,d){n.handlers.set(`${t}.${s}`,d)},on(s,d){let u=`${t}.${s}`;n.listeners.has(u)||n.listeners.set(u,new Set),n.listeners.get(u).add(d)},onApp(s){n.appListeners.add(s),o.apps.forEach(d=>s(d))},provide(s){if(t in o)throw new y(`Plugin \'${t}\' can\'t add a member Anfra already has.`);Object.defineProperty(o,t,{value:Je(s,G(t)),enumerable:!0})},provideOnQuery:i(s=>Ge(o.extensions.query,e.Query.prototype,"query",t,d=>Je(s(d),G(t))),"provideOnQuery"),provideOnControl:i(s=>Ge(o.extensions.control,e.Control.prototype,"control",t,d=>Je(s(d),G(t))),"provideOnControl"),layer:i(()=>K(r.document,t),"layer"),menuItem:i(s=>n.contentUi?.addItem(t,s),"menuItem"),modal:i(s=>n.contentUi.modal(s),"modal"),popover:i(s=>n.contentUi.popover(s),"popover"),annotate(s,d,u){if(s?.isRemoved)return!1;if(!o.apps.find(v=>v.queries[s?.name]===s))throw new y(`Plugin \'${t}\' annotated a query that belongs to no app.`,s?.name);if(!u||typeof u.result!="object"||u.result===null)throw new y(`Plugin \'${t}\' annotated query \'${s.name}\' without the result it computed them from ({ result: query.result }).`,s.name);return s.isCurrentResult(u.result)?(s.setAnnotations(t,Xt(t,s.name,u.result,d)),!0):!1},body(){return l??(l=a.call(vr,{plugin:t}).then(s=>Er(r,s)).catch(s=>{throw l=void 0,s})),l}}}i(we,"createKernel");var He=["sum","avg","max","min","count","count distinct","median","stdev","stdevp","var","varp"];var Xe=class Xe{constructor(n){c(this,"descriptor");c(this,"fields",new Map);c(this,"references");this.descriptor=n,n.data_models.forEach(e=>{e.fields.forEach(r=>{let o=String(e.name);this.fields.set(`${o}.${r.name}`,{modelName:o,fieldName:r.name,isMetric:!1,type:r.type,label:r.label??r.name})})}),n.metrics.forEach(e=>{this.fields.set(e.name,{fieldName:e.name,isMetric:!0,type:e.type,label:e.label??e.name})}),this.references=[...this.fields.keys()]}resolve(n,e){let r=this.fields.get(n);if(r)return r;throw new y(P(`Unknown field \'${n}\' on dataset \'${this.descriptor.name}\'.`,n,this.references),e)}};i(Xe,"DatasetIndex");var be=Xe;function an(t,n,e){let r=t[n];if(r)return r;throw new y(P(`Unknown dataset \'${n}\'.`,n,Object.keys(t)),e)}i(an,"resolveDataset");function ln(t,n){if(!He.includes(t))throw new y(P(`Invalid filter aggregation \'${t}\'.`,t,[...He]),n)}i(ln,"assertValidFilterAggregation");function dn(t,n,e){if(!n)throw new y(`A ${e} needs a name.`);for(let r of t)if(r===n)throw new y(`\'${n}\' is already declared in this app.`,n)}i(dn,"assertUniqueName");var xr={ns:1e-6,us:.001,\\u00B5s:.001,ms:1,s:1e3,m:6e4,h:36e5},Ar=168*36e5;function Cr(t){if(t==="0")return 0;let n=/(\\d+(?:\\.\\d*)?|\\.\\d+)(ns|us|\xB5s|ms|s|m|h)/y,e=0,r=0;for(let o=n.exec(t);o;o=n.exec(t))e+=parseFloat(o[1])*xr[o[2]],r=n.lastIndex;return r>0&&r===t.length?e:void 0}i(Cr,"parseDuration");function X(t,n,e,r){let o=JSON.stringify(e);return r==="sets"?`${t} sets ${n} to ${o}`:`${t} declares ${n} ${o}`}i(X,"gave");var Ye=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function ve(t,n,e,r="declares"){if(t===void 0||Ye.includes(t))return;let o=`${X(n,e,t,r)}.`,a=typeof t=="string"?ze(t.trim(),[...Ye]):void 0;if(a)throw new y(`${o} Did you mean ${JSON.stringify(a)}?`);let l=Ye.map(s=>JSON.stringify(s));throw new y(`${o} Use one of: ${l.slice(0,-1).join(", ")}, or ${l[l.length-1]}.`)}i(ve,"assertWeekStartDay");function ke(t,n,e,r,o="declares"){if(t===void 0)return;let a=typeof t=="string"?Cr(t):void 0;if(a===void 0)throw new y(`${X(n,e,t,o)}, which isn\'t a duration. Use one such as 30s, 10m or 2h.`,r);if(a>Ar)throw new y(`${X(n,e,t,o)}, which is over 168h (7 days), the longest a result can be cached.`,r)}i(ke,"assertCacheDuration");function Ze(t,n,e="declares"){if(!n.aql?.trim())throw new y(`Query \'${t}\' ${e} no AQL.`,t);let{pageSize:r}=n;if(r!==void 0&&!(Number.isInteger(r)&&r>=1))throw new y(`${X(`Query \'${t}\'`,"pageSize",r,e)}, but it must be a whole number of at least 1.`,t);ke(n.cache?.duration,`Query \'${t}\'`,"cache.duration",t,e)}i(Ze,"assertDeclaration");var et=class et extends q{constructor(e,r,o,a){super(r);c(this,"kind","query");c(this,"name");c(this,"id");c(this,"_declaration");c(this,"_dataset");c(this,"removed",!1);c(this,"app");c(this,"_state","idle");c(this,"runFailed",!1);c(this,"_result");c(this,"_error");c(this,"_page",1);c(this,"_run");c(this,"_sort",[]);c(this,"resultSuperseded",!1);c(this,"lastRunSignature");c(this,"lastPageRows",0);c(this,"controller");c(this,"runningSignature");c(this,"startedRun");c(this,"failedSignature");c(this,"annotationSets",new Map);c(this,"currentResults",new WeakSet);c(this,"resolvedAnnotations");Ze(e,o),this.name=e,this.id=a,this.app=r,this._declaration=o,this._dataset=r.datasetIndex(o.dataset,e)}get declaration(){return this._declaration}get dataset(){return this._dataset}get isRemoved(){return this.removed}update(e){this.assertLive(),this.app.updateQuery(this,e)}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new y(`Query \'${this.name}\' was removed from its app; it can\'t be used any more.`,this.name)}replaceDeclaration(e,r,o){this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0,this._state==="executing"&&(this._state=this._result?"success":"idle"),this.resultSuperseded=!0,this.clearAnnotations(),this.currentResults=new WeakSet,this._declaration=e,this._dataset=r,this._sort=[...o],this._run=void 0,this.resetPage(),this.notify()}markRemoved(){this.removed=!0,this.clearAnnotations(),this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0}locate(){return this.assertLive(),this.app.locate("query",this.name)}get state(){return this._state}get result(){return this._result}get error(){return this._error}get pageSize(){return this.declaration.pageSize}get page(){return this._page}get sort(){return this._sort}setSort(e){this.assertLive(),this._sort=[...e],this.notify()}get hasMore(){return!this._result||this.pageSize===void 0||this.resultSuperseded?!1:this._result.meta.hasMore??this.lastPageRows>=this.pageSize}signature(e="pending"){let r=this.app.mappingsTo(this.name).map(o=>({field:o.field,aggregation:o.aggregation,condition:e==="pending"?o.from.condition:o.from.appliedCondition})).sort((o,a)=>o.field.localeCompare(a.field)||JSON.stringify(o).localeCompare(JSON.stringify(a)));return JSON.stringify({declaration:this.declaration,conditions:r,selection:this.app.selectionConditionsFor(this.name,e),selectionExpression:this.app.selectionExpressionFor(this.name,e),sort:this._sort,inputDefaults:this.app.queryInputDefaults,page:this._page})}get isDirty(){return this.lastRunSignature!==void 0&&this.signature()!==this.lastRunSignature}hasUnappliedChange(e){let r=this.signature();return r===this.runningSignature?!1:this.runFailed?r!==this.failedSignature:this.lastRunSignature===void 0?e&&this.runningSignature===void 0:r!==this.lastRunSignature}shouldRun(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.isDirty}runInFlightWith(e){let r=this.startedRun;if(!(!r||r.controller!==this.controller||r.controller.signal.aborted))return r.signature===e?r.outcome:void 0}shouldRunAlone(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.signature("applied")!==this.lastRunSignature}execute(e={}){return this.assertLive(),this.app.executeQuery(this,e)}abort(){this.assertLive(),this.controller?.abort()}async fetchMore(){try{if(this.assertLive(),this.pageSize===void 0)throw new y(`Query \'${this.name}\' declares no pageSize, so it has no more pages.`,this.name);if(!this.hasMore)return;this._page+=1,await this.app.fetchPage(this)}catch(e){throw W(e,"fetch_more"),e}}async inspect(e={}){return this.assertLive(),this.app.inspect("query",this.name,e.tab)}menu(e,r,o={}){return this.assertLive(),this.app.menu(this,e,Array.isArray(r)?r:[r],o.fields,o.measure)}select(e,r={}){this.assertLive(),this.app.select(this,Array.isArray(e)?e:[e],r.fields)}get selectedRows(){let{selection:e}=this.app;if(e?.source!==this.name)return[];let r=this._result?.rows;if(!r)return e.rows;let o=i(l=>JSON.stringify(e.fields.map(s=>l[s]??null)),"key"),a=new Set(e.rows.map(o));return r.filter(l=>a.has(o(l)))}get annotations(){return this.resolvedAnnotations??(this.resolvedAnnotations=Object.freeze(Zt(this.annotationSets,this._result?.rows??[]))),this.resolvedAnnotations}isCurrentResult(e){return this.currentResults.has(e)}setAnnotations(e,r){if(r.length)this.annotationSets.set(e,r);else if(!this.annotationSets.delete(e))return;this.resolvedAnnotations=void 0,this.notify()}clearAnnotations(){this.annotationSets.clear(),this.resolvedAnnotations=void 0}markExecuting(){this.removed||(this._state="executing",this._error=void 0,this.notify())}get cacheDuration(){return this.declaration.cache?.duration??this.app.queryCacheDefaultDuration}get run(){return this._run}markSuccess(e,r,o,a){if(!this.removed){if(this._state="success",o||(this._run=a,this.resultSuperseded=!1),this._error=void 0,o||(this.runFailed=!1),this.lastRunSignature=r,this.lastPageRows=e.rows.length,o?this.resolvedAnnotations=void 0:this.clearAnnotations(),o&&this._result){let l=e.meta.pivot?Rr(this._result.rows,e.rows):e.rows,s=[...this._result.rows,...l];this._result={...e,rows:s,meta:{...e.meta,numRows:s.length}}}else this._result=e,this.currentResults=new WeakSet;this.currentResults.add(this._result),this.notify()}}markError(e,r=!1,o){this.removed||(r||(this.runFailed=!0,this.failedSignature=o),this._state="error",this._error=e,this.notify())}rewindPage(){this._page>1&&(this._page-=1)}resetPage(){this._page=1,this.lastPageRows=0}toJSON(){return this._declaration}};i(et,"Query");var Q=et,un="__pivot_row__";function Rr(t,n){let e=new Set(t.map(r=>String(r[un])));return n.filter(r=>!e.has(String(r[un])))}i(Rr,"newGridRows");function cn(t,n){if(n)throw new y(`Edge \'${t.id}\' was removed from its app; map again to have it back.`,t.from.name)}i(cn,"assertLive");var tt=class tt{constructor(n,e,r,o,a){c(this,"kind","control");c(this,"from");c(this,"to");c(this,"field");c(this,"aggregation");c(this,"owner");c(this,"removed",!1);this.from=n,this.to=e,this.field=r,this.aggregation=o,this.owner=a}remove(){cn(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}.${this.field}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:this.from.kind,name:this.from.name},to:{kind:"query",name:this.to.name},field:this.field,...this.aggregation?{aggregation:this.aggregation}:{}}}};i(tt,"Mapping");var Ee=tt,nt=class nt{constructor(n,e,r){c(this,"kind","crossFilter");c(this,"from");c(this,"to");c(this,"owner");c(this,"removed",!1);this.from=n,this.to=e,this.owner=r}remove(){cn(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:"query",name:this.from.name},to:{kind:"query",name:this.to.name}}}};i(nt,"CrossFilter");var Se=nt;function Dr(t,n){if(!(!n||n.operator==="none"||n.operator==="transform_date_drill"||!["is_null","not_null","is_true","is_false","transform_pop_none"].includes(n.operator)&&!n.values?.length))return{field:t.field,operator:n.operator,values:n.values??[],...n.modifier?{modifier:n.modifier}:{},...t.aggregation?{aggregation:t.aggregation}:{}}}i(Dr,"toFilter");function Tr(t,n){if(n?.operator!=="transform_date_drill")return;let e=n.values?.[0];if(typeof e!="string")return;let r=e.replace(/^datetrunc\\s+/,"");return{field:t.field,grain:r}}i(Tr,"toDateDrill");function _r(t,n){let e=n.columns??[],r=(n.values??[]).map(a=>{let l={};return e.forEach((s,d)=>{l[s.name]=a[d]}),l}),{pageSize:o}=t;return{columns:e,rows:r,meta:{...o!==void 0?{page:n.meta?.page??t.page,pageSize:n.meta?.pageSize??o,...n.meta?.hasMore!==void 0?{hasMore:n.meta.hasMore}:{},...n.meta?.pivot?{pivot:n.meta.pivot}:{}}:{},numRows:n.meta?.numRows??r.length},...n.debug?{debug:n.debug}:{}}}i(_r,"toResult");function xe(t,n,e,r){let o=n.map(d=>Dr(d,d.from.appliedCondition)).filter(d=>d!==void 0),a=n.map(d=>Tr(d,d.from.appliedCondition)).filter(d=>d!==void 0),l=e.conditions.map(d=>({field:d.field,operator:d.operator,values:d.values})),s=e.expression?[{expr:e.expression}]:[];return{dataset:t.dataset.descriptor.name,aql:t.declaration.aql,input:{filters:[...o,...l],conditions:s,sorts:t.sort.map(d=>({field:d.field,direction:d.direction??"asc"})),dateDrills:a,...r.timezone?{timezone:r.timezone}:{},...r.weekStartDay?{weekStartDay:r.weekStartDay}:{}},...t.cacheDuration?{cacheDuration:t.cacheDuration}:{}}}i(xe,"buildQuery");function rt(t,n,e,r){let{input:o,...a}=xe(t,n,e,r);return{...a,input:fn(o,t),...r.bustCache?{bustCache:!0}:{}}}i(rt,"buildRequest");function pn(t,n){return{dataset:t.dataset.descriptor.name,aql:t.declaration.aql,input:fn(n.input,t),...t.cacheDuration?{cacheDuration:t.cacheDuration}:{},...n.cachedAt?{minCachedAt:n.cachedAt}:{}}}i(pn,"pageRequest");function fn(t,n){let{pagination:e,...r}=t;return n.pageSize!==void 0?{...r,pagination:{page:n.page,pageSize:n.pageSize}}:r}i(fn,"withPage");function $r(t,n){let e=n?.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim();return e?`${e} - ${t.name}`:t.name}i($r,"defaultExportFilename");function mn(t,n,e,r,o,a){let l=o.format??"csv",s=l==="csv"?{bom:!0,...o.formatOptions}:o.formatOptions,d=xe(t,n,e,r),{pagination:u,...f}=a?.input??d.input;return{...d,input:f,...a?.cachedAt?{minCachedAt:a.cachedAt}:{},format:l,...s?{formatOptions:s}:{},filename:o.filename?.trim()||$r(t,r.title)}}i(mn,"buildExportRequest");async function ot(t,n,e,r,o){let a=await e.submitQuery(n,r,o),l=a.debug?.cache?.cachedAt?.toISOString();return{result:_r(t,a),run:{input:a.input??n.input,...l?{cachedAt:l}:{}}}}i(ot,"runQuery");function Or(t,n){if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(n==="number"&&typeof t=="string")return Mr(t);if(typeof t=="number"){if(!Number.isFinite(t))throw new RangeError(`Cannot express ${t} in AQL.`);return Math.abs(t)>=1e21?BigInt(t).toString():String(t)}return JSON.stringify(t).split("\\u2028").join("\\\\u2028").split("\\u2029").join("\\\\u2029")}i(Or,"literal");function hn(t,n,e){return n===null?`is(${t}, null)`:`${t} is ${Or(n,e)}`}i(hn,"equals");var Ir=new Set(["NaN","Infinity","-Infinity"]),Fr=/^(-?)(0|[1-9]\\d*)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/;function Mr(t){let n=Fr.exec(t);if(!n)throw Ir.has(t)?new RangeError(`Cannot express ${t} in AQL.`):new TypeError(`${JSON.stringify(t)} is not a number: a number is a string in JSON\'s number syntax.`);let[,e,r,o="",a]=n;if(a===void 0)return t;let l=r+o,s=r.length+Number(a),d;return s<=0?d=`0.${"0".repeat(-s)}${l}`:s>=l.length?d=l+"0".repeat(s-l.length):d=`${l.slice(0,s)}.${l.slice(s)}`,e+d.replace(/^0+(?=\\d)/,"")}i(Mr,"numberLiteral");function gn(t,n,e){return`${t} matches @(${n} until ${e})`}i(gn,"dateRange");function yn(t,n){if(n.length===0)throw new RangeError(`\\`${t}\\` needs at least one operand.`);return n.length===1?n[0]:`${t}(${n.join(", ")})`}i(yn,"combine");var wn=i(t=>yn("and",t),"and"),bn=i(t=>yn("or",t),"or");var Qr=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?)?/,Nr={week:7*864e5,day:864e5,hour:36e5,minute:6e4};function vn(t){if(typeof t!="string")return;let n=Qr.exec(t);if(n)return{year:Number(n[1]),month:Number(n[2])-1,day:Number(n[3]),hour:Number(n[4]??0),minute:Number(n[5]??0),second:Number(n[6]??0),hasTime:n[4]!==void 0}}i(vn,"parseStamp");function Z(t,n){let e=new Date(t),r=i(a=>String(a).padStart(2,"0"),"pad"),o=`${e.getUTCFullYear()}-${r(e.getUTCMonth()+1)}-${r(e.getUTCDate())}`;return n?`${o} ${r(e.getUTCHours())}:${r(e.getUTCMinutes())}:${r(e.getUTCSeconds())}`:o}i(Z,"format");function kn(t){return Date.UTC(t.year,t.month,t.day,t.hour,t.minute,t.second)}i(kn,"toMs");function it(t){let n=vn(t);if(n)return Z(kn(n),n.hasTime)}i(it,"normalise");function st(t,n){let e=vn(t);if(!e)return;let{year:r,month:o,day:a,hour:l,minute:s,second:d,hasTime:u}=e;return Z(n==="year"?Date.UTC(r+1,o,a,l,s,d):n==="quarter"?Date.UTC(r,o+3,a,l,s,d):n==="month"?Date.UTC(r,o+1,a,l,s,d):kn(e)+Nr[n],u)}i(st,"addGrain");function En(t){if(t?.startsWith("datetrunc "))return t.slice(10)}i(En,"grainOf");function Pr(t){let n=new Set;return t.filter(e=>{let r=`${typeof e}:${String(e)}`;return n.has(r)?!1:(n.add(r),!0)})}i(Pr,"distinct");function Lr(t,n){let e=t.map(it);if(e.some(o=>o===void 0))return!1;let r=e.slice().sort();for(let o=1;o<r.length;o+=1)if(st(r[o-1],n)!==r[o])return!1;return!0}i(Lr,"isContiguous");function Br(t,n,e){let r=n.map(it);if(r.some(d=>d===void 0))return;let o=r.slice().sort(),a=o[0],l=st(o[o.length-1],e);if(!l)return;let s=Lr(n,e);return{condition:{field:t,operator:"matches",values:[`${a} until ${l}`]},admits:s?n.length:Number.POSITIVE_INFINITY,lossy:!s}}i(Br,"dateRange");function Kr(t,n,e){let r=e.filter(s=>s!=null),o=Pr(r);if(!o.length)return{condition:{field:t,operator:"is_null",values:[]},admits:1,lossy:!1};let a=r.length!==e.length,l=En(n);if(l){let s=Br(t,o,l);if(s)return{...s,lossy:s.lossy||a}}return{condition:{field:t,operator:"is",values:o},admits:o.length,lossy:a}}i(Kr,"deriveOne");function Sn(t){return t.modelId?`${t.modelId}.${t.fieldName}`:t.fieldName}i(Sn,"fieldReferenceOf");function jr(t,n,e,r){try{let o=e.map(a=>wn(n.map(l=>{let s=t.get(l),d=Sn(s),u=a[l]??null,f=En(r[d]);if(f&&typeof u=="string"){let v=it(u),k=st(u,f);if(v&&k)return gn(d,v,k)}if(u!==null&&typeof u!="string"&&typeof u!="number"&&typeof u!="boolean")throw new TypeError("no AQL spelling");return hn(d,u,s.semantic_type)})));return bn(o)}catch{return}}i(jr,"selectionExpression");function at(t,n,e,r={}){let o=t.result?.columns??[],a=new Map(o.map(h=>[h.name,h]));e?.forEach(h=>{let b=a.get(h);if(b){if(b.adhoc)throw new y(`Query \'${t.name}\' cannot cross-filter on \'${h}\': it is a query-local AQL expression, which only this query\'s result carries. The target query would receive a condition naming a field it has never heard of.`,t.name);if(b.isMeasure)throw new y(`Query \'${t.name}\' cannot cross-filter on \'${h}\': it is a measure, and a selection conditions dimensions only.`,t.name);return}throw new y(P(`Query \'${t.name}\' has no column \'${h}\' in its last result.`,h,[...a.keys()]),t.name)});let l=o.filter(h=>!h.isMeasure),s=l.filter(h=>!h.adhoc).map(h=>h.name),d=e?[...e]:s;if(!n.length||!d.length)return;let u=[],f=1,v=!e&&s.length!==l.length,k=!1;d.forEach(h=>{let b=a.get(h),m=Sn(b),C=Kr(m,r[m],n.map(p=>p[h]));u.push(C.condition),f*=C.admits,k=k||C.lossy});let S=new Set(n.map(h=>JSON.stringify(d.map(b=>h[b]??null))));f>S.size&&(k=!0);let R=u.sort((h,b)=>h.field.localeCompare(b.field)),I={source:t.name,rows:[...n],fields:d};if(k){let h=jr(a,d,n,r);if(h)return{...I,conditions:[],expression:h,lossy:v}}return{...I,conditions:R,lossy:v||k}}i(at,"deriveSelection");var lt=Object.freeze([]);function dt(t){return t instanceof Error&&t.name==="AbortError"}i(dt,"isAbort");function Ae(t,n){return t.controller!==n}i(Ae,"superseded");function qr(t){return{name:t.name,code:t.code,scope:t.scope,message:t.message,...t.entity?{entity:t.entity}:{},...typeof t.status=="number"?{status:t.status}:{},...t.requestId?{requestId:t.requestId}:{},...t.stack?{stack:t.stack}:{}}}i(qr,"inspectError");function Vr(t){let{result:n}=t;return{id:t.id,state:t.state,isDirty:t.isDirty,page:t.page,hasMore:t.hasMore,columns:n?n.columns.map(e=>({...e})):[],rowCount:n?.meta.numRows??0,selectedRowCount:t.selectedRows.length,signature:t.signature(),...t.error?{error:qr(t.error)}:{},...n?.debug?{debug:{...n.debug}}:{}}}i(Vr,"inspectQuery");function zr(t){let{options:n}=t;return{kind:t.kind,condition:{...t.condition},...t.appliedCondition?{appliedCondition:{...t.appliedCondition}}:{},isDirty:t.isDirty,...n?{options:[...n]}:{}}}i(zr,"inspectControl");function xn(t){return{source:t.source,fields:[...t.fields],rowCount:t.rows.length,conditions:t.conditions.map(n=>({...n})),...t.expression?{expression:t.expression}:{},lossy:t.lossy}}i(xn,"inspectSelection");function An(t){return t?JSON.stringify({source:t.source,conditions:t.conditions,expression:t.expression}):"none"}i(An,"selectionKey");function ut(t,n,e="The query failed."){return j(t)?t.about(n):(console.error(`anfra: \'${n}\' failed; the app is told only that it failed.`,t),new M({code:"call_failed",scope:"server",message:e,entity:n,cause:t}))}i(ut,"toDataAppError");var ct=class ct extends q{constructor(e,r,o,a,l){super();c(this,"extensions",l);c(this,"title");c(this,"_timezone");c(this,"_weekStartDay");c(this,"queryInput");c(this,"queryCacheDefaultDuration");c(this,"datasets");c(this,"backend");c(this,"features");c(this,"_queries",new Map);c(this,"_controls",new Map);c(this,"_mappings",[]);c(this,"_crossFilters",[]);c(this,"_selection");c(this,"_appliedSelection");c(this,"selectionCommitted",!1);c(this,"nextQueryId",1);c(this,"removedListeners",new Set);c(this,"revealer");c(this,"index",0);this.title=e.title,this._timezone=e.timezone,ve(e.weekStartDay,"The app","weekStartDay"),this._weekStartDay=e.weekStartDay;let s=e.query?.default?.input??{};ve(s.weekStartDay,"The app","query.default.input.weekStartDay"),this.queryInput={...s};let d=e.query?.default?.cache?.duration;ke(d,"The app","query.default.cache.duration"),this.queryCacheDefaultDuration=d,this.datasets=r,this.backend=o,this.features=a}get queries(){return Object.fromEntries(this._queries)}get controls(){return Object.fromEntries(this._controls)}get mappings(){return[...this._mappings,...this._crossFilters]}get crossFilters(){return this._crossFilters}createQuery(e,r){this.assertNameFree(e,"query");let o=ye(new Q(e,this,r,this.nextQueryId++),this.extensions?.query);return this._queries.set(e,o),this.notify(),o}createFilter(e,r){this.assertNameFree(e,"filter");let o=this.filterDataset(e,r),a=ye(new le(e,this,r,o,this.backend),this.extensions?.control);return this._controls.set(e,a),this.notify(),a}createDateDrill(e,r={}){if(this.features?.dateDrill===!1)throw new y(`Date drill \'${e}\' needs a capability this workspace has not enabled. Ask an admin to turn on \\`interactive_control:date_drill\\`.`,e);this.assertNameFree(e,"date drill control");let o=ye(new de(e,this,r),this.extensions?.control);return this._controls.set(e,o),this.notify(),o}mapControl(e,r,o){if(!(e instanceof N))throw new y("mapControl expects a control as its source. To let one query cross-filter another, use app.mapCrossFilter(from, to) \\u2014 a cross-filter edge names no field.");if(e.assertLive(),r.assertLive(),this._controls.get(e.name)!==e)throw new y(`Control \'${e.name}\' belongs to a different app.`,e.name);if(this._queries.get(r.name)!==r)throw new y(`Query \'${r.name}\' belongs to a different app.`,r.name);o.aggregation&&ln(o.aggregation,e.name);let a=new Ee(e,r,o.field,o.aggregation,this);if(this._mappings.some(l=>l.id===a.id))throw new y(`Mapping \'${a.id}\' is already declared.`,e.name);return this.assertAcyclic(a),this._mappings.push(a),this.notify(),a}mapCrossFilter(e,r){if(!(e instanceof Q)||!(r instanceof Q))throw new y("mapCrossFilter expects two queries. To let a control condition a query, use app.mapControl(from, to, { field }).");if(e.assertLive(),r.assertLive(),this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);if(this._queries.get(r.name)!==r)throw new y(`Query \'${r.name}\' belongs to a different app.`,r.name);if(e===r)throw new y(`Query \'${e.name}\' cannot cross-filter itself. A source keeps its own rows so it can show what is selected; filtering it would erase the very rows the reader clicked.`,e.name);if(e.declaration.dataset!==r.declaration.dataset)throw new y(`Cross-filter \'${e.name}\' -> \'${r.name}\' spans two datasets (\'${e.declaration.dataset}\' and \'${r.declaration.dataset}\'). A selection carries field references, which mean nothing outside the dataset that resolved them.`,e.name);let o=new Se(e,r,this);if(this._crossFilters.some(a=>a.id===o.id))throw new y(`Cross-filter \'${o.id}\' is already declared.`,e.name);return this._crossFilters.push(o),this.notify(),o}updateQuery(e,r){let o=e.declaration,a=H(o,r,["dataset","aql","pageSize","cache"]);Ze(e.name,a,"sets");let l=this.datasetIndex(a.dataset,e.name);if(a.dataset!==o.dataset){let u=this._crossFilters.filter(f=>f.from===e?f.to.declaration.dataset!==a.dataset:f.to===e?f.from.declaration.dataset!==a.dataset:!1);if(u.length)throw new y(`Query \'${e.name}\' can\'t move to dataset \'${a.dataset}\': its cross-filters ${u.map(f=>`\'${f.id}\'`).join(", ")} would span two datasets. Remove them first.`,e.name)}let s=a.aql!==o.aql||a.dataset!==o.dataset,d=r.sort??(s?[]:e.sort);s&&this.dropSelectionFrom(e.name),e.replaceDeclaration(a,l,d)}removeEntity(e){if(e instanceof Q){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);this._queries.delete(e.name),this.dropEdges(r=>r.to===e||r.from===e),this.dropSelectionFrom(e.name)}else{if(this._controls.get(e.name)!==e)throw new y(`Control \'${e.name}\' belongs to a different app.`,e.name);this._controls.delete(e.name),this.dropEdges(r=>r.from===e)}e.markRemoved(),this.removedListeners.forEach(r=>{try{r(e)}catch{}}),this.notify()}removeEdge(e){if(!this.dropEdges(r=>r===e))throw new y(`Edge \'${e.id}\' belongs to a different app.`,e.from.name);this.notify()}onRemoved(e){return this.removedListeners.add(e),()=>{this.removedListeners.delete(e)}}dropEdges(e){let r=this.mappings.filter(e);r.forEach(a=>a.markRemoved());let o=i(a=>{let l=a.filter(s=>!r.includes(s));a.splice(0,a.length,...l)},"keep");return o(this._mappings),o(this._crossFilters),r.length>0}dropSelectionFrom(e){this._selection?.source===e&&(this._selection=void 0),this._appliedSelection?.source===e&&(this._appliedSelection=void 0)}get selection(){return this._selection}get appliedSelection(){return this._appliedSelection}clearSelection(){this._selection&&(this._selection=void 0,this.notify())}setTimezone(e){this._timezone=e,this.notify()}get timezone(){return this._timezone}setWeekStartDay(e){ve(e,"The app","weekStartDay","sets"),this._weekStartDay=e,this.notify()}get weekStartDay(){return this._weekStartDay}get queryInputDefaults(){let e=this.queryInput.timezone??this._timezone,r=this.queryInput.weekStartDay??this._weekStartDay;return{...e?{timezone:e}:{},...r?{weekStartDay:r}:{}}}datasetIndex(e,r){return an(this.datasets,e,r)}filterDataset(e,r){return r.dataset?this.datasetIndex(r.dataset,e):this.soleDataset(e,r.field)}mappingsTo(e){return this._mappings.filter(r=>r.to.name===e)}selectionExpressionFor(e,r){return this.selectionFor(e,r)?.expression}selectionFor(e,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?void 0:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===e)?o:void 0}selectionConditionsFor(e,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?lt:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===e)?o.conditions:lt}drillTransformations(e){let r={};return this._mappings.forEach(o=>{if(o.to!==e)return;let a=o.from.appliedCondition;if(a?.operator!=="transform_date_drill")return;let[l]=a.values??[];typeof l=="string"&&(r[o.field]=l)}),r}menu(e,r,o,a,l){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);if(l!==void 0){let s=e.result?.columns??[],d=s.find(u=>u.name===l);if(!d?.isMeasure)throw new y(d?`Query \'${e.name}\' can\'t open a menu on \'${l}\' as its measure: it is a dimension.`:P(`Query \'${e.name}\' has no measure \'${l}\' in its last result.`,l,s.filter(u=>u.isMeasure).map(u=>u.name)),e.name)}return Wt(r,this.rowsTarget(e,o,a,l))}rowsTarget(e,r,o,a){let l=at(e,r,o,this.drillTransformations(e)),s=e.annotations.filter(d=>(d.kind==="mark"||d.kind==="focus")&&(a===void 0||d.anchor.measure===void 0||d.anchor.measure===a)&&d.anchor.rows.some(u=>r.some(f=>Ue(u,f))));return{kind:"rows",app:this.index,query:e.name,rows:[...r],fields:l?.fields?[...l.fields]:[],...a!==void 0?{measure:a}:{},conditions:l?.conditions?[...l.conditions]:[],...l?.expression?{expression:l.expression}:{},...s.length?{annotations:s}:{}}}requestFor(e){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);return xe(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},this.queryInputDefaults)}select(e,r,o){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);let a=at(e,r,o,this.drillTransformations(e));a?.lossy&&console.warn(`[anfra-sdk] The selection in \'${e.name}\' filters more broadly than it was made. Its conditions are combined field by field and ANDed, which cannot express "(A and B) or (C and D)", so the targets will also show combinations that were not selected. Select within one dimension, or narrow with \\`fields\\`, to avoid this.`),this._selection=a,this.notify()}get hasChanges(){return[...this._controls.values()].some(e=>e.isDirty)||this.isSelectionDirty||[...this._queries.values()].some(e=>e.hasUnappliedChange(this.selectionCommitted))}get isSelectionDirty(){return this.selectionCommitted?An(this._selection)!==An(this._appliedSelection):!1}async execute(e={}){let r=[...this._queries.values()].filter(s=>s.shouldRun(e.force));this._controls.forEach(s=>s.commit()),this._appliedSelection=this._selection,this.selectionCommitted=!0;let o={backend:this.backend,...this.queryInputDefaults,bustCache:e.bustCache},a=[],l=[];return await Promise.all(r.map(async s=>{let d=await this.runWith(s,"pending",o,e.force);d==="succeeded"?a.push(s.name):d==="failed"&&l.push(s.name)})),{succeeded:a,failed:l}}async executeQuery(e,r={}){if(!e.shouldRunAlone(r.force))return{succeeded:[],failed:[]};let o=await this.runWith(e,"applied",{backend:this.backend,...this.queryInputDefaults,bustCache:r.bustCache},r.force);return{succeeded:o==="succeeded"?[e.name]:[],failed:o==="failed"?[e.name]:[]}}runWith(e,r,o,a=!1){let l=a||o.bustCache?void 0:e.runInFlightWith(e.signature(r));return l||(e.controller?.abort(),e.resetPage(),this.run(e,e.signature(r),o))}run(e,r,o){let a=new AbortController;e.controller=a,e.runningSignature=r;let l,s=new Promise((d,u)=>{l={resolve:d,reject:u}});return e.startedRun={controller:a,signature:r,outcome:s},e.markExecuting(),this.runFirstPage(e,r,o,a).then(l.resolve,l.reject),s}async runFirstPage(e,r,o,a){try{let l=rt(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},o),{result:s,run:d}=await ot(e,l,o.backend,a.signal,this.stampOf(e));return Ae(e,a)?void 0:(e.markSuccess(s,r,!1,d),"succeeded")}catch(l){if(Ae(e,a)||dt(l))return;let s=ut(l,e.name);return e.markError(s,!1,r),$("call.query",s),"failed"}finally{e.controller===a&&(e.controller=void 0,e.runningSignature=void 0)}}async refresh(){return this.execute({force:!0,bustCache:!0})}abort(){this._queries.forEach(e=>e.abort())}async fetchPage(e){let r=new AbortController,o=e.signature("applied");e.controller=r,e.runningSignature=o,e.markExecuting();try{let a=e.run?pn(e,e.run):rt(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{backend:this.backend,...this.queryInputDefaults}),{result:l}=await ot(e,a,this.backend,r.signal,this.stampOf(e));if(Ae(e,r))return;e.markSuccess(l,o,!0)}catch(a){if(Ae(e,r)||(e.rewindPage(),dt(a)))return;let l=ut(a,e.name);throw e.markError(l,!0),l}finally{e.controller===r&&(e.controller=void 0,e.runningSignature=void 0)}}async exportQuery(e,r,o){let a=mn(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{...this.queryInputDefaults,title:this.title},r,e.run);try{return await o(a,r.signal??new AbortController().signal,{app:this.index,query:e.name})}catch(l){throw dt(l)?l:ut(l,e.name,"The export failed.")}}toJSON(){let e=i(r=>Object.fromEntries([...this._controls.entries()].filter(([,o])=>o.kind===r).map(([o,a])=>[o,a.toJSON()])),"byKind");return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},queries:Object.fromEntries([...this._queries.entries()].map(([r,o])=>[r,o.toJSON()])),filters:e("filter"),dateDrills:e("dateDrill"),mappings:[...this._mappings.map(r=>r.toJSON()),...this._crossFilters.map(r=>r.toJSON())]}}toInspectJSON(){return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},...Object.keys(this.queryInput).length>0?{queryInput:{...this.queryInput}}:{},hasChanges:this.hasChanges,declaration:this.toJSON(),queries:Object.fromEntries([...this._queries.entries()].map(([e,r])=>[e,Vr(r)])),controls:Object.fromEntries([...this._controls.entries()].map(([e,r])=>[e,zr(r)])),...this._selection?{selection:xn(this._selection)}:{},...this._appliedSelection?{appliedSelection:xn(this._appliedSelection)}:{}}}inspect(e,r,o){return this.revealer?this.revealer({app:this.index,entity:e,name:r,...o!==void 0?{tab:o}:{}}):Promise.resolve(!1)}locate(e,r){let o=globalThis.document;if(!o)return!1;let a=ce(o,e,this.index,r);return a.length?(fe(a[0]),pe(o).flash(a,{kind:e,name:r,...a.length>1?{note:`in ${a.length} places`}:{}}),!0):!1}stampOf(e){return{app:this.index,query:e.name,id:e.id}}assertNameFree(e,r){dn([...this._queries.keys(),...this._controls.keys()],e,r)}soleDataset(e,r){if(!r)return;let o=Object.keys(this.datasets);if(o.length===1)return this.datasets[o[0]];throw new y(o.length?`Filter \'${e}\' names a field but the environment has ${o.length} datasets. Say which one: ${o.join(", ")}.`:`Filter \'${e}\' names a field but the environment has no datasets.`,e)}assertAcyclic(e){let r=[...this._mappings,e],o=new Map;r.forEach(d=>{let u=d.from.name;o.set(u,[...o.get(u)??[],d.to.name])});let a=new Set,l=new Set,s=i(d=>{if(a.has(d))return!0;if(l.has(d))return!1;a.add(d);let u=(o.get(d)??[]).some(s);return a.delete(d),l.add(d),u},"walk");if([...o.keys()].some(s))throw new y(`Mapping \'${e.id}\' would make the app\'s mappings cyclic.`,e.from.name)}};i(ct,"App");var Ce=ct;var Cn="0.25.0-rc.1";var ht=class ht{constructor(){c(this,"current",{scheme:"light",tokens:Pe.light});c(this,"listeners",new Set)}get scheme(){return this.current.scheme}get tokens(){return this.current.tokens}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}set(n){this.current=n,this.listeners.forEach(e=>{try{e(n)}catch{}})}};i(ht,"HostTheme");var pt=ht,gt=class gt{constructor(n){c(this,"list");this.list=Object.freeze(n.map(({name:e,version:r})=>Object.freeze({name:e,version:r})))}has(n){return this.list.some(e=>e.name===n)}version(n){return this.list.find(e=>e.name===n)?.version}};i(gt,"InstalledPlugins");var ft=gt,Gr=Cn,yt=class yt{constructor(n){c(this,"version",Gr);c(this,"_apps",[]);c(this,"datasets");c(this,"user");c(this,"indices");c(this,"backend");c(this,"plugins");c(this,"theme",new pt);c(this,"gates");c(this,"deprecatedFeatures");c(this,"extensions",{query:new Map,control:new Map});if(!n?.datasets)throw new y("No datasets provided. The host must call createSdk({ datasets }) before an app can be declared.");if(!n.user)throw new y("No user provided. The host must call createSdk({ user }) before an app can be declared.");if(!n.backend)throw new y("No backend provided. The host must call createSdk({ backend }) before an app can run a query.");this.datasets=Object.freeze({...n.datasets}),this.user=Object.freeze({...n.user,permissions:Object.freeze({...n.user.permissions})}),this.indices=Object.fromEntries(Object.entries(n.datasets).map(([e,r])=>[e,new be(r)])),this.backend=n.backend,this.gates=Object.freeze({...n.features}),this.plugins=new ft(n.plugins??[])}get features(){return this.deprecatedFeatures||(console.warn("anfra: Anfra.features is deprecated and will be removed. Check Anfra.plugins.has(\'export\'), Anfra.plugins.has(\'render\') or Anfra.plugins.has(\'lineage\') instead."),this.deprecatedFeatures=Object.freeze({...this.gates,export:this.plugins.has("export"),render:this.plugins.has("render"),lineage:this.plugins.has("lineage")})),this.deprecatedFeatures}createApp(n={}){let e=new Ce(n,this.indices,this.backend,this.gates,this.extensions);return e.index=this._apps.length,this._apps.push(e),e}get apps(){return this._apps}};i(yt,"Sdk");var mt=yt;function Rn(t){return new mt(t)}i(Rn,"createSdk");var ee="Anfra";function Dn(t,n=globalThis){let e=n[ee],r=ee in n;return n[ee]=t,()=>{r?n[ee]=e:delete n[ee]}}i(Dn,"installSandbox");function Tn(t,n=[]){let e=t.document.getElementById(wt);if(!e?.textContent)throw new Error("anfra: this frame was not provisioned by a host.");let r=JSON.parse(e.textContent),o=i(b=>t.parent.postMessage(b,r.hostOrigin),"post"),a=new Map,l=new Map,s=Dt(o,{answer:i(async(b,m,C)=>{let p=a.get(b);if(!p)throw se(`Nothing in this frame answers \'${b}\'.`);return p(m,C)},"answer"),hidden:i((b,m)=>{t.console?.error(`anfra: \'${b}\' failed; the host is told only that the call failed.`,m),$("plugin.uncaught",m)},"hidden"),event:i((b,m)=>{l.get(b)?.forEach(C=>{try{C(m)}catch{}})},"event")}),d=i(b=>b.source===t.parent||!!r.hostOrigin&&r.hostOrigin!=="null"&&b.origin===r.hostOrigin,"fromHost");t.addEventListener("message",b=>{d(b)&&s.receive(b.data)});let u={submitQuery:i((b,m,C)=>s.call("core.submitQuery",b,m,C).then(p=>(p.debug?.executedAt&&(p.debug.executedAt=new Date(p.debug.executedAt)),p)),"submitQuery"),fieldSuggestions:i((b,m)=>s.call("core.fieldSuggestions",b,m),"fieldSuggestions")},f=Rn({datasets:r.datasets,user:r.user,backend:u,plugins:r.plugins??[]}),v=new Set,k=f.createApp.bind(f);f.createApp=b=>{let m=k(b);return v.forEach(C=>{try{C(m)}catch{}}),m};let S={window:t,sdk:f,endpoint:s,handlers:a,listeners:l,appListeners:v},R=we("anfra",S,{Query:Q,Control:N});Tt(R,t,r.captureConsole===!0),Ut(R),$t(we("core",S,{Query:Q,Control:N})),S.contentUi=Ht(R),Yt(R),tn(R,S.contentUi),R.on("theme",b=>{let m=Lt(b);Kt(t.document,m),f.theme.set(m)});let I=new Set,h=!1;R.on("shortcuts",b=>{I=new Set((Array.isArray(b)?b:[]).map(rn).filter(m=>!!m)),!(h||!I.size)&&(h=!0,t.addEventListener("keydown",m=>{if(m.defaultPrevented||m.repeat||on(m.target))return;let C=sn(m);I.has(C)&&(m.preventDefault(),R.emit("shortcut",C))}))});for(let[b,m]of n)if(typeof m=="function")try{m(we(b,S,{Query:Q,Control:N}))}catch(C){t.console?.error(`anfra: plugin \'${b}\' failed to set up:`,C),$("plugin.uncaught",C)}Dn(f,t),o({type:"anfra:ready"})}i(Tn,"bootstrap");return Qn(Wr);})();\n';
|
|
33
|
+
var anfra_sdk_frame_script_default = '"use strict";var __anfraKernel=(()=>{var U=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var On=Object.prototype.hasOwnProperty;var In=(t,n,e)=>n in t?U(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var i=(t,n)=>U(t,"name",{value:n,configurable:!0});var Fn=(t,n)=>{for(var e in n)U(t,e,{get:n[e],enumerable:!0})},Mn=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of $n(n))!On.call(t,o)&&o!==e&&U(t,o,{get:()=>n[o],enumerable:!(r=_n(n,o))||r.enumerable});return t};var Qn=t=>Mn(U({},"__esModule",{value:!0}),t);var c=(t,n,e)=>In(t,typeof n!="symbol"?n+"":n,e);var Wr={};Fn(Wr,{bootstrap:()=>Tn});var wt="anfra-provision";function G(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9]+/g,"_").toLowerCase()}i(G,"snakeCase");var ne=new WeakMap;function W(t,n){typeof t=="object"&&t!==null&&ne.set(t,n)}i(W,"tagCall");function bt(t){for(let n=t,e=0;typeof n=="object"&&n!==null&&e<5;n=n.cause,e+=1){let r=ne.get(n);if(r)return r}}i(bt,"callOf");function Re(t,n){let e=ne.get(t);return e&&ne.set(n,e),n}i(Re,"copyCallTag");function De(t,n){return function(...e){let r=t.apply(this,e);return r&&typeof r.then=="function"?r.then(void 0,o=>{throw W(o,n),o}):r}}i(De,"namedCall");var Te=2e3,Nn=4e3;function re(t,n){return t.length<=n?t:`${t.slice(0,n)}\\u2026 (truncated)`}i(re,"truncate");function vt(t,n){let e=n,r=typeof e=="object"&&e!==null,o={kind:t,message:re(r&&typeof e.message=="string"?e.message:String(n),Te),at:new Date().toISOString()};if(!r)return o;for(let a of["code","scope","requestId","entity"]){let l=e[a];typeof l=="string"&&(o[a]=l)}return!t.startsWith("call.")&&typeof e.stack=="string"&&(o.stack=re(e.stack,Nn)),o}i(vt,"describeError");function _e(t,n=()=>{},e=Date.now){let r=e(),o=0,a=0,l,s=i(()=>{l=void 0;let d=a;if(a=0,d>0)try{n(d)}catch{}},"flush");return{take(){let d=e();return d-r>=6e4&&(l!==void 0&&clearTimeout(l),s(),r=d,o=0),o<t?(o+=1,!0):(a+=1,l===void 0&&(l=setTimeout(s,Math.max(0,r+6e4-d))),!1)},dispose(){l!==void 0&&clearTimeout(l),s()}}}i(_e,"createBudget");var kt={query_invalid:"user",query_failed:"user",forbidden:"user",unauthenticated:"user",invalid_request:"client",declaration_invalid:"client",connection_failed:"server",call_failed:"server",internal_server_error:"server"},oe=class oe extends Error{constructor(e){super(e.message);c(this,"code");c(this,"scope");c(this,"status");c(this,"details");c(this,"context");c(this,"requestId");c(this,"entity");c(this,"cause");this.name=new.target.name,this.code=e.code,this.scope=e.scope,e.status!==void 0&&(this.status=e.status),e.details!==void 0&&(this.details=e.details),e.context!==void 0&&(this.context=e.context),e.requestId!==void 0&&(this.requestId=e.requestId),e.entity!==void 0&&(this.entity=e.entity),e.cause!==void 0&&(this.cause=e.cause),Object.setPrototypeOf(this,new.target.prototype)}about(e){return this.entity===e?this:Re(this,new oe({...Ln(this),entity:e}))}};i(oe,"DataAppError");var M=oe,ie=class ie extends M{constructor(n,e){super({code:"declaration_invalid",scope:"client",message:n,entity:e})}about(n){return this.entity===n?this:Re(this,new ie(this.message,n))}};i(ie,"ValidationError");var y=ie;function j(t){if(t instanceof M)return!0;let n=t;return n instanceof Error&&(n.name==="DataAppError"||n.name==="ValidationError")&&typeof n.code=="string"}i(j,"isDataAppError");function Et(t,n){return j(t)&&t.code===n}i(Et,"hasErrorCode");function St(t){if(!Array.isArray(t))return;let n=t.filter(e=>typeof e?.text=="string").map(e=>typeof e.step=="string"?{step:e.step,text:e.text}:{text:e.text});return n.length?n:void 0}i(St,"contextOf");function se(t,n){return new M({code:"invalid_request",scope:"client",message:t,entity:n})}i(se,"invalidRequest");function xt(t,n){return new M({code:"forbidden",scope:"user",message:t,entity:n})}i(xt,"forbidden");function At(t,n){return new M({code:"connection_failed",scope:"server",message:t,status:n})}i(At,"connectionFailed");function J(t){return new M({code:"call_failed",scope:"server",message:"The call failed.",cause:t})}i(J,"callFailed");function Ct(t,n,e={}){let{refused:r="invalid_request",requestId:o,entity:a}=e,l;return t===void 0||t===0?l="connection_failed":t===401?l="unauthenticated":t===403?l="forbidden":t>=400&&t<500?l=r:l="internal_server_error",new M({code:l,scope:Pn(l,t),message:n,status:t||void 0,requestId:o,entity:a})}i(Ct,"fromHttpStatus");function Pn(t,n){return t in kt?kt[t]:n!==void 0&&n>=400&&n<500?"user":"server"}i(Pn,"scopeOf");function Rt(t){return t==="user"||t==="client"||t==="server"?t:"server"}i(Rt,"toScope");function Ln(t){return{code:t.code,scope:t.scope,message:t.message,status:t.status,details:t.details,context:t.context,requestId:t.requestId,entity:t.entity,cause:t.cause}}i(Ln,"fieldsOf");function ae(){let t=new Error("Aborted");return t.name="AbortError",t}i(ae,"abortError");function Bn(t){return t?.name==="AbortError"}i(Bn,"isAbortError");function Kn(t){return{app:t.app,query:t.query,...t.id!==void 0&&{id:t.id},...t.variant!==void 0&&{variant:t.variant}}}i(Kn,"copyStamp");var jn=new Set(["query_invalid","validation_failed","invalid_request","result_too_large","page_too_large"]);function $e(t,n){let e=typeof n.code=="string"&&n.code?n.code:"call_failed",r={name:t,code:e,scope:Rt(n.scope),message:typeof n.message=="string"&&n.message?n.message:"The call failed."};typeof n.status=="number"&&(r.status=n.status),n.details!==void 0&&jn.has(e)&&(r.details=n.details);let o=St(n.context);return o&&(r.context=o),typeof n.requestId=="string"&&(r.requestId=n.requestId),r}i($e,"crossing");function qn(t){return j(t)?$e(t.name,t):$e("DataAppError",J())}i(qn,"toBridgeError");function Vn(t){if(!t||typeof t!="object")return J();let n=$e(t.name,t);return n.name==="ValidationError"&&n.code==="declaration_invalid"?new y(n.message):new M({code:n.code,scope:n.scope,message:n.message,status:n.status,details:n.details,context:n.context,requestId:n.requestId})}i(Vn,"fromBridgeError");function Dt(t,n){let e=new Map,r=new Map,o=1,a=i((l,s,d,u)=>{let f=new AbortController;r.set(l,f),Promise.resolve().then(()=>n.answer(s,d,f.signal,u)).then(v=>{f.signal.aborted||t({type:"anfra:result",id:l,ok:!0,result:v})}).catch(v=>{if(f.signal.aborted||Bn(v))return;let k=qn(v);if(!j(v))if(n.hidden)try{n.hidden(s,v)}catch{}else console.error(`anfra: \'${s}\' failed; the other side is told only that the call failed.`,v);t({type:"anfra:result",id:l,ok:!1,error:k})}).finally(()=>{r.get(l)===f&&r.delete(l)})},"answer");return{call(l,s,d,u){return new Promise((f,v)=>{if(d?.aborted){v(ae());return}let k=o++;e.set(k,{resolve:f,reject:v}),d?.addEventListener("abort",()=>{e.delete(k)&&(t({type:"anfra:cancel",id:k}),v(ae()))},{once:!0}),t({type:"anfra:call",id:k,name:l,request:s,...u?{stamp:Kn(u)}:{}})})},emit(l,s){t({type:"anfra:event",name:l,payload:s})},receive(l){switch(l?.type){case"anfra:call":return a(l.id,l.name,l.request,l.stamp),!0;case"anfra:result":{let s=e.get(l.id);return s&&(e.delete(l.id),l.ok?s.resolve(l.result):s.reject(Vn(l.error))),!0}case"anfra:cancel":return r.get(l.id)?.abort(),r.delete(l.id),!0;case"anfra:event":return n.event(l.name,l.payload),!0;default:return!1}},close(l){r.forEach(s=>s.abort()),r.clear(),e.forEach(({reject:s})=>s(l)),e.clear()}}}i(Dt,"createEndpoint");var Ie;function $(t,n){try{Ie?.(t,n)}catch{}}i($,"reportError");var Oe=120;function zn(t){if(typeof t=="string")return t;if(t instanceof Error)return`${t.name}: ${t.message}`;try{return JSON.stringify(t)??String(t)}catch{return String(t)}}i(zn,"textOf");function Tt(t,n,e,r=Date.now){let o=i(v=>k=>n.console?.warn(`anfra: ${k} ${v} over the ${Oe} a minute a frame sends were not sent to the host.`),"dropped"),a=_e(Oe,o("runtime errors"),r),l=_e(Oe,o("console lines"),r);Ie=i((v,k)=>{a.take()&&t.emit("error",vt(v,k))},"reporter");let s=i(v=>$("app.uncaught",v.error??v.message),"onError"),d=i(v=>{let k=bt(v.reason);$(k?`call.${k}`:"app.uncaught",v.reason)},"onRejection");n.addEventListener("error",s),n.addEventListener("unhandledrejection",d);let u=n.console,f={};if(e&&u)for(let v of["error","warn"]){let k=u[v];f[v]=k,u[v]=(...S)=>{if(k.apply(u,S),!(typeof S[0]=="string"&&S[0].startsWith("anfra:")))try{l.take()&&t.emit("console",{level:v,message:re(S.map(zn).join(" "),Te),at:new Date().toISOString()})}catch{}}}return()=>{Ie=void 0,a.dispose(),l.dispose(),n.removeEventListener("error",s),n.removeEventListener("unhandledrejection",d);for(let[v,k]of Object.entries(f))u[v]=k}}i(Tt,"installReporting");var Fe=class Fe{constructor(n){c(this,"listeners",new Set);c(this,"parent");this.parent=n}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}notifyChange(){this.listeners.forEach(n=>{try{n()}catch(e){console.error("anfra: a subscribe() listener threw; the queries carry on.",e),$("app.listener",e)}}),this.parent?.notifyChange()}notify(){this.notifyChange()}};i(Fe,"Observable");var q=Fe;function H(t,n,e=Object.keys(n)){let r={...t};return e.forEach(o=>{if(!(o in n))return;let a=n[o];a===void 0?delete r[o]:r[o]=a}),r}i(H,"withChanges");var _t=["year","quarter","month","week","day","hour","minute"];function Un(t,n){if(!_t.includes(n))throw new y(`Invalid grain \'${n}\'. Expected one of: ${_t.join(", ")}.`,t)}i(Un,"assertGrain");function Me(t,n){return n?(Un(t,n),{operator:"transform_date_drill",values:[`datetrunc ${n}`]}):{operator:"none"}}i(Me,"drillCondition");function Gn(t){let n=t.toLowerCase();return n.includes("date")||n.includes("time")?"date":n.includes("int")||n.includes("number")||n.includes("float")||n.includes("decimal")?"number":n.includes("bool")?"boolean":"string"}i(Gn,"inferType");function Wn(t,n){return JSON.stringify(t??null)===JSON.stringify(n??null)}i(Wn,"sameCondition");var Qe=class Qe extends q{constructor(e,r,o){super(r);c(this,"name");c(this,"app");c(this,"pending");c(this,"applied");c(this,"initial");c(this,"removed",!1);this.name=e,this.app=r,this.initial=o,this.pending=o}locate(){return this.assertLive(),this.app.locate("control",this.name)}async inspect(e={}){return this.assertLive(),this.app.inspect("control",this.name,e.tab)}get isRemoved(){return this.removed}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new y(`Control \'${this.name}\' was removed from its app; it can\'t be used any more.`,this.name)}markRemoved(){this.removed=!0,this.dropInFlight()}dropInFlight(){}redefault(e,r){this.initial=e,r&&(this.pending=e)}get condition(){return this.pending}get appliedCondition(){return this.applied}get isDirty(){return this.applied!==void 0&&!Wn(this.pending,this.applied)}setCondition(e){this.assertLive(),this.pending=e,this.notify()}reset(){this.assertLive(),this.setCondition(this.initial)}commit(){this.applied=this.pending}};i(Qe,"Control");var N=Qe,Y=class Y extends N{constructor(e,r,o,a,l){super(e,r,o.default??{operator:"is",values:[]});c(this,"kind","filter");c(this,"_declaration");c(this,"resolution");c(this,"backend");c(this,"loadedOptions");c(this,"loading",new Set);this.backend=l,this.resolution=Y.resolve(e,o,a),this._declaration=o,this.assertValues(this.condition.values??[]),this.assertValues(o.options??[])}static resolve(e,r,o){if(r.field){if(!o)throw new y(`Filter \'${e}\' names a field but no dataset. Pass \\`dataset\\` alongside \\`field\\`.`,e);let a=o.resolve(r.field,e);return{resolved:a,datasetName:o.descriptor.name,type:r.type??Gn(a.type)}}if(!r.type)throw new y(`Filter \'${e}\' is a manual filter, so it needs a \\`type\\`.`,e);return{type:r.type}}get declaration(){return this._declaration}get type(){return this.resolution.type}setCondition(e){this.assertLive(),this.assertValues(e.values??[]),super.setCondition(e)}update(e){this.assertLive();let r=H(this._declaration,e),o=this._declaration,a=["field","dataset","type"].some(u=>r[u]!==o[u]),l=a?Y.resolve(this.name,r,this.app.filterDataset(this.name,r)):this.resolution,s=r.default??{operator:"is",values:[]},d=i(u=>u.values??[],"values");this.assertValuesOf(l.type,d(s)),this.assertValuesOf(l.type,r.options??[]),a||this.assertValuesOf(l.type,d(this.condition)),this._declaration=r,this.resolution=l,this.redefault(s,a),a&&(this.loadedOptions=void 0,this.dropInFlight()),this.notify()}dropInFlight(){this.loading.forEach(e=>e.abort()),this.loading.clear()}assertValues(e){this.assertValuesOf(this.type,e)}assertValuesOf(e,r){if(e!=="number")return;let o=r.find(a=>typeof a=="number");if(o!==void 0)throw new y(`Filter \'${this.name}\' filters numbers: give its values as strings, as query results give them (${JSON.stringify(String(o))}, not ${String(o)}), so none has lost a digit.`,this.name)}get isFieldBacked(){return this.resolution.resolved!==void 0}get options(){return this.loadedOptions??this._declaration.options??[]}async loadOptions(e,r=new AbortController().signal){this.assertLive();let{resolved:o,datasetName:a}=this.resolution,l=o?.modelName;if(!o||!l||!this.backend||!a)return this.options;let s=new AbortController,d=i(()=>s.abort(),"follow");r.aborted?s.abort():r.addEventListener("abort",d,{once:!0}),this.loading.add(s);try{let u=await this.backend.fieldSuggestions({dataset:a,model:l,field:o.fieldName,q:e??""},s.signal).catch(f=>{throw W(f,"load_options"),f});if(s.signal.aborted&&!this.loading.has(s))throw ae();return this.loadedOptions=[...u??[]],this.notify(),this.loadedOptions}finally{this.loading.delete(s),r.removeEventListener("abort",d)}}toJSON(){return this._declaration}};i(Y,"Filter");var le=Y,Ne=class Ne extends N{constructor(e,r,o={}){super(e,r,Me(e,o.default));c(this,"kind","dateDrill");c(this,"_declaration");this._declaration=o}get declaration(){return this._declaration}update(e){this.assertLive();let r=H(this._declaration,e),o=Me(this.name,r.default);this._declaration=r,this.redefault(o,!1),this.notify()}setGrain(e){this.assertLive(),this.setCondition(Me(this.name,e))}toJSON(){return this._declaration}};i(Ne,"DateDrillControl");var de=Ne;function $t(t){t.handle("execute",async()=>{let n=await Promise.all(t.sdk.apps.map(e=>e.refresh()));return{succeeded:n.flatMap(e=>e.succeeded),failed:n.flatMap(e=>e.failed)}})}i($t,"installCore");var O={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},ue=`[${O.container}],[${O.block}],[${O.query}],[${O.control}]`;function Ot(t){let n=/^(?:(\\d+)\\/)?([^/\\s]+)$/.exec(t);if(n)return{app:n[1]===void 0?0:Number(n[1]),name:n[2]}}i(Ot,"parseRef");var It=i(t=>(t??"").split(/\\s+/).filter(Boolean),"tokens");function ce(t,n,e,r){let o=n==="query"?O.query:O.control;return[...t.querySelectorAll(`[${o}]`)].filter(a=>It(a.getAttribute(o)).some(l=>{let s=Ot(l);return s?.app===e&&s.name===r}))}i(ce,"markersFor");var Jn=i((t,n,e)=>{let r=t[e.app];return r?Object.prototype.hasOwnProperty.call(n==="query"?r.queries:r.controls,e.name):!1},"hasEntity");function Ft(t,n){var v;let e=[],r=new Map,o=new Map,a=new Map,l=new Map,s={container:new Set,block:new Set},d={},u=i((k,S,R)=>{let I=k?a.get(k).children:e,h=k?`${a.get(k).key}.`:"",b={...S,key:`${h}${I.length}`,children:[]};return I.push(b),r.set(b.key,R),o.set(R,[...o.get(R)??[],b.key]),b},"place");for(let k of t.querySelectorAll(ue)){let S=k.parentElement?.closest(ue)??null,R=k.getAttribute(O.container),I=k.getAttribute(O.block),h=k.getAttribute(O.label)??void 0,b=S&&(l.get(S)==="block"?S:S.closest(`[${O.block}]`)),m;if(R!==null||I!==null){let p=R!==null?"container":"block",g=(R??I??"").trim(),w=[];R!==null&&I!==null&&w.push("This element is marked as a container and as a block. It counts as a container."),g?s[p].has(g)?w.push(`Another ${p} already has the id "${g}".`):s[p].add(g):w.push(`This ${p} has no id.`),b&&w.push(`A block can\'t hold a ${p}. This one is inside the block "${b.getAttribute(O.block)}".`),m=u(S,{kind:p,id:g,...h!==void 0?{label:h}:{},problems:w},k),a.set(k,m),l.set(k,p)}let C=m?k:S;for(let p of["query","control"])for(let g of It(k.getAttribute(p==="query"?O.query:O.control))){let w=Ot(g),E=[];if(w?Jn(n,p,w)||E.push(n[w.app]?`No ${p} is called "${w.name}" in app ${w.app}.`:`The page has no app ${w.app}.`):E.push(`Can\'t read "${g}". Write the ${p}\'s name, or app/name when the page has several apps.`),u(C,{kind:p,name:w?.name??g,app:w?.app??0,problems:E},k),w&&!E.length){let A=`${w.app}/${w.name}`,x=d[v=`${p}:${A}`]??(d[v]={elements:new Set,blocks:new Set});x.elements.add(k);let T=m?.kind==="block"?m.id:b?.getAttribute(O.block);T&&x.blocks.add(T)}}}let f=Object.fromEntries(Object.entries(d).map(([k,S])=>[k,{markers:S.elements.size,blocks:[...S.blocks]}]));return{nodes:e,usage:f,elements:r,keysOf:o}}i(Ft,"buildStructure");var Hn=i((t,n,e)=>`${t}:${n}/${e}`,"usageKey");function Yn(t){let n=t.getBoundingClientRect();return`${Math.round(n.width)} \\xD7 ${Math.round(n.height)}`}i(Yn,"sizeOf");function Mt(t,n,e){let r=Yn(n);if(t.kind==="container"||t.kind==="block")return{kind:t.kind,name:t.id??"",...t.label?{label:t.label}:{},size:r};let o=e.usage[Hn(t.kind,t.app??0,t.name??"")];return{kind:t.kind,name:t.name??"",...o&&o.markers>1?{note:`1 of ${o.markers}`}:{},size:r}}i(Mt,"describeNode");var Pt=["color-bg","color-fg","color-muted","color-border","color-accent","color-danger","radius","font","font-mono","color-bg-sunken","color-fg-weak","color-border-strong","color-hover","color-active","color-selected","color-warning","color-success"],Qt="\'Inter Variable\', ui-sans-serif, system-ui, sans-serif",Nt="\'Geist Mono Variable\', ui-monospace, monospace",Pe={light:{"color-bg":"oklch(1 0 0)","color-bg-sunken":"oklch(0.973 0.005 95.1)","color-fg":"oklch(0.201 0.022 301.1)","color-fg-weak":"oklch(0.392 0.021 304.3)","color-muted":"oklch(0.485 0.022 306.3)","color-border":"oklch(0.201 0.022 301.1 / 0.12)","color-border-strong":"oklch(0.201 0.022 301.1 / 0.24)","color-accent":"oklch(0.484 0.181 298.1)","color-danger":"oklch(0.501 0.17 27.2)","color-warning":"oklch(0.501 0.1 70.3)","color-success":"oklch(0.479 0.1 151.8)","color-hover":"oklch(0.201 0.022 301.1 / 0.05)","color-active":"oklch(0.201 0.022 301.1 / 0.09)","color-selected":"oklch(0.946 0.027 304.8)",radius:"10px",font:Qt,"font-mono":Nt},dark:{"color-bg":"oklch(0.19 0.012 300)","color-bg-sunken":"oklch(0.157 0.009 296.9)","color-fg":"oklch(0.961 0.007 304.2)","color-fg-weak":"oklch(0.879 0.016 302.5)","color-muted":"oklch(0.835 0.018 300)","color-border":"oklch(0.343 0.025 298.2)","color-border-strong":"oklch(0.392 0.021 304.3)","color-accent":"oklch(0.845 0.085 300)","color-danger":"oklch(0.82 0.09 27)","color-warning":"oklch(0.84 0.12 69.6)","color-success":"oklch(0.8 0.12 151.9)","color-hover":"oklch(1 0 0 / 0.06)","color-active":"oklch(1 0 0 / 0.1)","color-selected":"oklch(0.565 0.194 300.3 / 0.18)",radius:"10px",font:Qt,"font-mono":Nt}};var Xn=/[;{}<>]|url\\(|expression\\(|@import|\\\\/i;function Lt(t){let n=typeof t=="object"&&t!==null?t:{},e=n.scheme==="dark"?"dark":"light",r={...Pe[e]},o=typeof n.tokens=="object"&&n.tokens!==null?n.tokens:{},a=new Set;for(let l of Pt){let s=o[l];typeof s=="string"&&s.trim()!==""&&s.length<=200&&!Xn.test(s)&&(r[l]=s.trim(),a.add(l))}for(let[l,{from:s,value:d}]of Object.entries(Zn)){if(a.has(l)||!s.some(f=>a.has(f)))continue;let u=d(r);u.length<=200&&(r[l]=u)}return Object.freeze({scheme:e,tokens:Object.freeze(r)})}i(Lt,"resolveTheme");var Zn={"color-bg-sunken":{from:["color-fg","color-bg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 4%, ${t["color-bg"]})`,"value")},"color-fg-weak":{from:["color-fg","color-bg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 80%, ${t["color-bg"]})`,"value")},"color-border-strong":{from:["color-fg","color-border"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 10%, ${t["color-border"]})`,"value")},"color-hover":{from:["color-fg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 7%, transparent)`,"value")},"color-active":{from:["color-fg"],value:i(t=>`color-mix(in srgb, ${t["color-fg"]} 12%, transparent)`,"value")},"color-selected":{from:["color-accent"],value:i(t=>`color-mix(in srgb, ${t["color-accent"]} 14%, transparent)`,"value")}};function Le(t,n){for(let e of Pt)t.setProperty(`--anfra-${e}`,n.tokens[e]);t.setProperty("color-scheme",n.scheme)}i(Le,"applyTheme");var Be="data-anfra-layer",Bt=new WeakMap,er="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483647;";function tr(t){let n=t.querySelector(`[${Be}]`);if(n instanceof(t.defaultView?.HTMLElement??HTMLElement))return n;let e=t.createElement("div");e.setAttribute(Be,""),e.setAttribute("style",er);let r=Bt.get(t);return r&&Le(e.style,r),(t.body??t.documentElement).appendChild(e),e}i(tr,"layerOf");function K(t,n){let e=tr(t),r=[...e.children].find(a=>a.getAttribute("data-part")===n);if(r?.shadowRoot)return r.shadowRoot;let o=t.createElement("div");return o.setAttribute("data-part",n),e.appendChild(o),o.attachShadow({mode:"open"})}i(K,"layerRoot");function Kt(t,n){Bt.set(t,n);let e=t.querySelector(`[${Be}]`);e&&Le(e.style,n)}i(Kt,"themeLayer");var jt="anfra-overlay",nr=1500,rr="position:fixed;box-sizing:border-box;background:oklch(0.546 0.215 262.9 / 0.22);outline:1px solid oklch(0.546 0.215 262.9);outline-offset:-1px;",or="position:fixed;max-width:60vw;display:flex;gap:6px;align-items:baseline;padding:3px 8px;border-radius:4px;background:oklch(0.208 0.04 265.8);color:oklch(0.984 0.003 247.9);font:12px/1.4 system-ui,sans-serif;white-space:nowrap;box-shadow:0 2px 8px oklch(0 0 0 / 0.35);",ir={kind:"color:oklch(0.711 0.035 256.8);",name:"color:oklch(0.809 0.096 251.8);font-weight:700;",label:"color:oklch(0.984 0.003 247.9);",note:"color:oklch(0.711 0.035 256.8);",size:"color:oklch(0.711 0.035 256.8);margin-left:10px;"},je=class je{constructor(n){c(this,"doc",n);c(this,"root");c(this,"shown",[]);c(this,"text",{kind:"",name:""});c(this,"timer");c(this,"reposition",i(()=>this.draw(),"reposition"));let e=K(n,"anfra"),r=e.getElementById(jt);r instanceof(n.defaultView?.HTMLElement??HTMLElement)?this.root=r:(this.root=n.createElement("div"),this.root.id=jt,this.root.setAttribute("aria-hidden","true"),this.root.setAttribute("style","position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:none;"),e.appendChild(this.root))}show(n,e){if(this.clearTimer(),this.root.isConnected||K(this.doc,"anfra").appendChild(this.root),this.shown=[...n],this.text=e,!this.shown.length){this.hide();return}this.root.style.display="block",this.draw(),this.doc.addEventListener("scroll",this.reposition,{capture:!0,passive:!0}),this.doc.defaultView?.addEventListener("resize",this.reposition)}flash(n,e,r=nr){this.show(n,e),this.timer=setTimeout(()=>this.hide(),r)}hide(){this.clearTimer(),this.shown=[],this.root.style.display="none",this.root.replaceChildren(),this.doc.removeEventListener("scroll",this.reposition,{capture:!0}),this.doc.defaultView?.removeEventListener("resize",this.reposition)}get visible(){return this.shown.length>0}clearTimer(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}draw(){let n=this.shown.map(s=>{let d=s.getBoundingClientRect(),u=this.doc.createElement("div");return u.setAttribute("style",`${rr}left:${d.left}px;top:${d.top}px;width:${d.width}px;height:${d.height}px;`),u}),e=this.shown[0].getBoundingClientRect(),r=this.doc.createElement("div");r.setAttribute("data-testid","anfra-overlay-label");let o=this.doc.defaultView?.innerHeight??0,a=e.top>=26?e.top-24:Math.max(4,e.top+4),l=Math.max(4,Math.min(e.left,(this.doc.defaultView?.innerWidth??0)-24));r.setAttribute("style",`${or}left:${l}px;top:${Math.min(a,o-24)}px;`);for(let s of["kind","name","label","note","size"]){let d=this.text[s];if(!d)continue;let u=this.doc.createElement("span");u.setAttribute("style",ir[s]),u.setAttribute("data-part",s),u.textContent=d,r.appendChild(u)}this.root.replaceChildren(...n,r)}};i(je,"Overlay");var Ke=je,qt=new WeakMap;function pe(t){let n=qt.get(t);return n||(n=new Ke(t),qt.set(t,n)),n}i(pe,"overlayFor");function fe(t){typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}i(fe,"scrollTo");function Vt(t,n){let e=null,r=i(d=>d.target instanceof Element?d.target.closest(ue):null,"under"),o=i(d=>{let u=r(d);u!==e&&(e=u,n.onHover(u))},"onMove"),a=i(d=>{d.preventDefault(),d.stopPropagation();let u=r(d);u&&n.onPick(u)},"onClick"),l=i(d=>{d.key==="Escape"&&n.onCancel()},"onKey"),s={capture:!0};return t.addEventListener("mousemove",o,s),t.addEventListener("click",a,s),t.addEventListener("keydown",l,s),()=>{t.removeEventListener("mousemove",o,s),t.removeEventListener("click",a,s),t.removeEventListener("keydown",l,s)}}i(Vt,"startPick");function zt(t,n){for(let e of t){if(e.key===n)return e;let r=zt(e.children,n);if(r)return r}}i(zt,"findNode");function Ut(t){let n=t.window,e=n.document,r=!1,o,a,l="",s,d;function u(){if(o=void 0,!!r)try{a=t.structure(),l=JSON.stringify(a.nodes),t.emit("snapshot",{apps:t.sdk.apps.map(h=>h.toInspectJSON()),structure:{nodes:a.nodes,usage:a.usage}})}catch{}}i(u,"postSnapshot");function f(){r&&o===void 0&&(o=setTimeout(u,50))}i(f,"scheduleSnapshot");function v(){let h=n.MutationObserver;if(s||typeof h!="function")return;let b=new h(()=>{if(!(!r||o!==void 0))try{JSON.stringify(t.structure().nodes)!==l&&f()}catch{}});s=b,b.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Object.values(O)})}i(v,"observeStructure");function k(h){let b=h!==null&&a?zt(a.nodes,h):void 0,m=h!==null?a?.elements.get(h):void 0;if(!b||!m||!a){t.overlay.hide();return}t.overlay.show([m],Mt(b,m,a))}i(k,"highlight");function S(h){if(!h){d?.(),d=void 0;return}if(d)return;let b=i(m=>a?.keysOf.get(m)?.[0],"keyOf");d=Vt(e,{onHover:i(m=>k(m?b(m)??null:null),"onHover"),onPick:i(m=>{let C=b(m);C!==void 0&&t.emit("picked",{node:C})},"onPick"),onCancel:i(()=>{S(!1),t.overlay.hide(),t.emit("picked",{node:null})},"onCancel")})}i(S,"setPicking");function R(h){r=h,h?(v(),u()):(s?.disconnect(),s=void 0,S(!1),t.overlay.hide(),a=void 0,l="")}i(R,"setInspecting");function I(h){if("node"in h){let b=a?.elements.get(h.node);b&&fe(b),k(h.node)}else t.sdk.apps[h.app]?.locate(h.kind,h.name);f()}i(I,"locate"),t.on("watch",h=>R(h===!0)),t.on("highlight",h=>k(h)),t.on("locate",h=>I(h)),t.on("pick",h=>S(h===!0)),t.onApp(h=>{h.subscribe(f),f()})}i(Ut,"installInspection");function Ve(t){return{label:t.label||sr(t),...t.detail?{detail:t.detail}:{},...t.severity?{severity:t.severity}:{},plugin:t.plugin}}i(Ve,"annotationNote");function sr(t){switch(t.kind){case"line":return`${t.anchor.column} at ${t.anchor.value}`;case"band":return`${t.anchor.column} from ${t.anchor.from} to ${t.anchor.to}`;case"series":return`A series of ${t.anchor.measure}`;case"focus":return"In focus";case"mark":return"Marked"}}i(sr,"defaultLabel");function Gt(t){if(t.kind!=="rows"||!t.annotations)return t;let{annotations:n,...e}=t;return e}i(Gt,"forHost");var qe;function Wt(t,n){return qe?qe(t,n):!1}i(Wt,"openRowsMenu");var ar=`[${O.block}]`,lr=\'[data-anfra-menu="off"]\',dr=i(t=>({...t,children:t.children.map(n=>({...n,children:[]}))}),"bare");function Jt(t,n,e=[]){for(let r of t){if(r.key===n)return[...e,r];let o=Jt(r.children,n,[...e,r]);if(o)return o}}i(Jt,"pathTo");var ur=i(t=>typeof t?.closest=="function","isElement");function Ht(t){let n=t.window,e=n.document,r=[],o=new Set,a=!1,l,s,d=i(()=>t.body(),"ui"),u=i(()=>K(e,"anfra-ui"),"root"),f=i(p=>o.has(p)||r.some(g=>g.target===p),"offered"),v=i(()=>{let p=l;l=void 0,s=void 0,p?.()},"closeCurrent");function k(p){let g=ur(p)?p.closest(ar):null;return g&&!g.closest(lr)?g:void 0}i(k,"blockOf");function S(p){let g=t.structure(),w=g.keysOf.get(p)?.[0],E=w!==void 0?Jt(g.nodes,w):void 0;if(!E)return;let{x:A,y:x,width:T,height:_}=p.getBoundingClientRect();return{kind:"node",node:dr(E[E.length-1]),ancestors:E.slice(0,-1).map(D=>({...D,children:[]})),rect:{x:A,y:x,width:T,height:_}}}i(S,"nodeTarget");function R(p){let g=new Map,w=[];for(let E of r){if(E.target!==p.kind)continue;let A=!0;try{A=E.when?E.when(p)!==!1:!0}catch{A=!1}if(!A)continue;let x=`frame:${E.full}:${p.kind}`;if(!E.entries){w.push({id:x,label:E.label}),g.set(x,()=>E.run(p));continue}let T=[];try{T=E.entries(p)??[]}catch{T=[]}T.forEach((_,D)=>{if(typeof _?.label!="string")return;let F=typeof _.disabled=="string"&&_.disabled?_.disabled:void 0;if(!F&&typeof _.run!="function")return;let L=`${x}:${D}`;w.push({id:L,label:_.label,...F?{disabled:F}:{}}),F||g.set(L,_.run)})}return{entries:w,run:g}}i(R,"frameEntries");async function I(p,g){let w=new Map(g.run),E=[...g.entries];if(o.has(p.kind))try{let A=await t.call("anfra.menu",Gt(p));for(let x of Array.isArray(A)?A:[]){if(typeof x?.id!="string"||typeof x.label!="string")continue;let T=`host:${x.id}:${p.kind}`;E.push({id:T,label:x.label,...typeof x.disabled=="string"?{disabled:x.disabled}:{}}),w.set(T,()=>t.call("anfra.run",{id:x.id,target:Gt(p)}))}}catch{}return{entries:E,run:w}}i(I,"entriesFor");function h(p,g,w){let E=g.flatMap(D=>D.kind==="rows"?D.annotations??[]:[]).map(Ve),A=g.map(D=>({target:D,own:R(D)})).filter(({target:D,own:F})=>F.entries.length||o.has(D.kind));if(!A.length&&!E.length)return!1;p.preventDefault();let x=p,T=typeof x.clientX=="number"?x.clientX:0,_=typeof x.clientY=="number"?x.clientY:0;return(async()=>{let[D,...F]=await Promise.all([d(),...A.map(({target:B,own:V})=>I(B,V))]),L=F.map(B=>B.entries).filter(B=>B.length);if(!L.length&&!E.length)return;v();let z=D.menu(u(),{x:T,y:_,...E.length?{notes:E}:{},groups:L,onPick:i(B=>{let V=F.map(te=>te.run.get(B)).find(Boolean);Promise.resolve().then(V).catch(te=>{n.console?.error("anfra: a menu item failed:",te),$("plugin.uncaught",te)})},"onPick"),onClose:i(()=>{l===z&&(l=void 0)},"onClose")});l=z,s=w})().catch(D=>{n.console?.error("anfra: the menu failed to open:",D),$("plugin.uncaught",D)}),!0}i(h,"open");function b(){a||!(f("node")||f("rows"))||(a=!0,n.addEventListener("contextmenu",p=>{if(p.defaultPrevented||p.shiftKey)return;let g=k(p.target),w=g&&S(g);w&&h(p,[w])}))}i(b,"listen"),qe=i((p,g)=>{if(p.defaultPrevented||p.shiftKey)return!1;let w=k(p.target),E=w?S(w):void 0,A=p,x=typeof A.clientX=="number"&&typeof A.clientY=="number"?{x:A.clientX,y:A.clientY}:void 0,T={...g,...E?{node:E}:{},...x?{at:x}:{}};return h(p,E?[T,E]:[T],{app:g.app,query:g.query})},"rowsOpener"),t.onApp(p=>p.onRemoved(g=>{g.kind==="query"&&s?.app===p.index&&s.query===g.name&&v()})),t.on("menu",p=>{let g=p?.kinds;o=new Set((Array.isArray(g)?g:[]).filter(w=>w==="node"||w==="rows")),b()});let m=i(p=>g=>{try{return p(g)}catch(w){throw $("plugin.uncaught",w),w}},"reported");async function C(p,g){let w=await d();v();let E=i(()=>{},"close");return E=g(w,i(()=>{l===E&&(l=void 0);try{p.onClose?.()}catch{}},"onClose")),l=E,s=p.about?{app:p.about.app,query:p.about.query}:void 0,{close:E}}return i(C,"show"),{addItem(p,g){r.push({...g,full:`${p}.${g.id}`,plugin:p}),b()},modal:i(p=>C(p,(g,w)=>g.modal(u(),{title:p.title,size:p.size,mount:m(p.mount),onClose:w})),"modal"),popoverAt:i((p,g)=>C(g,(w,E)=>w.popover(u(),{anchor:p,side:g.side,mount:m(g.mount),dismiss:g.dismiss,closeButton:g.closeButton,onClose:E})),"popoverAt"),rowsEntries(p,g){return r.filter(w=>w.plugin===p).flatMap(w=>{if(w.target!=="rows")return[];try{return w.when&&w.when(g)===!1?[]:w.entries?(w.entries(g)??[]).filter(E=>typeof E?.label=="string"&&(E.disabled||typeof E.run=="function")):[{label:w.label,run:i(()=>w.run(g),"run")}]}catch{return[]}})},popover:i(p=>C(p,(g,w)=>{let{anchor:E}=p,A;if("kind"in E){let x=t.structure().elements.get(E.node.key);A=i(()=>{if(!x?.isConnected)return;let{x:T,y:_,width:D,height:F}=x.getBoundingClientRect();return{x:T,y:_,width:D,height:F}},"rect")}else A=i(()=>({x:E.x,y:E.y,width:0,height:0}),"rect");return g.popover(u(),{anchor:A,side:p.side,mount:m(p.mount),dismiss:p.dismiss,closeButton:p.closeButton,onClose:w})}),"popover")}}i(Ht,"installContentUi");var cr={query:"Query",control:"Control"};function pr(t){let n=t.navigator.userActivation;return n?n.isActive:!0}i(pr,"activated");function Yt(t){let n=i(async e=>{if(!pr(t.window))return $("call.inspect",new y(`${cr[e.entity]} \'${e.name}\' can\'t open the panel without a reader\'s click. Call inspect() from a click handler, such as a button\'s.`,e.name)),!1;try{return await t.call("anfra.reveal",e)===!0}catch(r){return $("call.inspect",r),!1}},"reveal");t.onApp(e=>{e.revealer=n})}i(Yt,"installReveal");function fr(t,n){let e=t.length+1,r=n.length+1,o=Array.from({length:r},(a,l)=>l);for(let a=1;a<e;a++){let l=[a];for(let s=1;s<r;s++)l[s]=Math.min(o[s]+1,l[s-1]+1,o[s-1]+(t[a-1]===n[s-1]?0:1));o=l}return o[r-1]}i(fr,"editDistance");function ze(t,n){let e,r=1/0;n.forEach(a=>{let l=fr(t.toLowerCase(),a.toLowerCase());l<r&&(r=l,e=a)});let o=Math.max(2,Math.floor(t.length/3));return r<=o?e:void 0}i(ze,"suggest");function P(t,n,e){let r=ze(n,e);return r?`${t} Did you mean \'${r}\'?`:t}i(P,"withSuggestion");var me=["mark","focus","line","band","series"],ge=["info","warning","critical"],he=i(t=>typeof t=="object"&&t!==null&&!Array.isArray(t),"isObject");function Xt(t,n,e,r){if(!Array.isArray(r))throw new y(`Plugin \'${t}\' annotated query \'${n}\' with something other than a list of annotations.`,n);let o=new Set;return r.map((a,l)=>{let s=`Annotation ${l} of plugin \'${t}\' on query \'${n}\'`,d=i(S=>{throw new y(`${s} ${S}`,n)},"fail");if(!he(a))return d("is not an object.");let{kind:u}=a;if(!me.includes(u))return d(`has kind \'${String(u)}\', but a kind is one of ${me.map(S=>`\'${S}\'`).join(", ")}.`);let f={};for(let S of["id","label","detail"]){let R=a[S];R!==void 0&&(typeof R!="string"&&d(`has a ${S} that isn\'t a string.`),f[S]=R)}f.id!==void 0&&(o.has(f.id)&&d(`has the id \'${f.id}\', which another annotation in the set has.`),o.add(f.id)),a.severity!==void 0&&(ge.includes(a.severity)||d(`has severity \'${String(a.severity)}\', but a severity is \'info\', \'warning\' or \'critical\'.`),f.severity=a.severity);let v=mr(e.columns,d),k=he(a.anchor)?a.anchor:d("has no anchor.");return{kind:u,...f,anchor:v(u,k)}})}i(Xt,"checkAnnotations");function mr(t,n){let e=i((l,s)=>{let d=typeof l=="string"?t.find(u=>u.name===l):void 0;return d||n(typeof l=="string"?P(`names ${s} \'${l}\', but the result has no column \'${l}\'.`,l,t.map(u=>u.name)):`has no ${s}.`)},"column"),r=i(l=>{let s=e(l,"the measure");return s.isMeasure||n(`names \'${s.name}\' as its measure, but \'${s.name}\' is not a measure column.`),s.name},"measure"),o=i((l,s)=>typeof l=="string"?l:n(`has a ${s} that isn\'t a string. Values are strings, as rows carry them.`),"string"),a=i((l,s)=>{if(!he(l)||!Object.keys(l).length)return n(`has a ${s} that doesn\'t name a row by its dimension values.`);for(let d of Object.keys(l))e(d,"the column").isMeasure&&n(`names a ${s} by \'${d}\', a measure; name rows by their dimension values.`);return{...l}},"dimensions");return(l,s)=>{if(l==="mark"||l==="focus")return(!Array.isArray(s.rows)||!s.rows.length)&&n("has no rows in its anchor."),{rows:s.rows.map(v=>a(v,"row")),...s.measure!==void 0?{measure:r(s.measure)}:{}};if(l==="line")return{column:e(s.column,"the column").name,value:o(s.value,"value")};if(l==="band")return(s.from===void 0||s.to===void 0)&&n("needs a from and a to in its anchor."),{column:e(s.column,"the column").name,from:o(s.from,"from"),to:o(s.to,"to")};let d=r(s.measure);(!Array.isArray(s.points)||!s.points.length)&&n("has no points in its anchor.");let u=s.points.map(f=>{if(!he(f))return n("has a point that is not an object.");let v=f.lower!==void 0&&f.upper!==void 0;return f.value===void 0&&!v&&n("has a point with neither a value nor both bounds (lower and upper)."),f.lower===void 0!=(f.upper===void 0)&&n("has a point with one bound: give its value or bounds, both lower and upper."),{at:a(f.at,"point"),...f.value!==void 0?{value:o(f.value,"value")}:{},...v?{lower:o(f.lower,"lower bound"),upper:o(f.upper,"upper bound")}:{}}});return{measure:d,points:u}}}i(mr,"anchorChecker");var hr=i((t,n)=>JSON.stringify(t??null)===JSON.stringify(n??null),"sameValue"),Ue=i((t,n)=>Object.keys(t).every(e=>hr(t[e],n[e])),"rowMatches");function Zt(t,n){let e=[];for(let[r,o]of t)o.forEach((a,l)=>{let s=`${r}:${a.id??l}`;if(a.kind!=="mark"&&a.kind!=="focus"){e.push({...a,plugin:r,key:s});return}let d=[],u=[];for(let f of a.anchor.rows){let v=!1;n.forEach((k,S)=>{Ue(f,k)&&(v=!0,u.includes(S)||u.push(S))}),v&&d.push(f)}u.length&&e.push({...a,anchor:{...a.anchor,rows:d,index:u.sort((f,v)=>f-v)},plugin:r,key:s})});return e}i(Zt,"resolveAnnotations");var en="data-anfra-annotations";function gr(t){let n=t.getAttribute(en);return n?.trim()==="off"?"off":new Set((n??"").split(/\\s+/).filter(e=>me.includes(e)))}i(gr,"drawnBy");function yr(t,n){let e=gr(t);return e==="off"?[]:n.filter(r=>!e.has(r.kind))}i(yr,"badgedAnnotations");function wr(t){let n=-1;for(let{severity:e}of t)n=Math.max(n,e?ge.indexOf(e):-1);return n<0?void 0:ge[n]}i(wr,"highest");var br=i((t,n)=>`${t} annotation${t===1?"":"s"}${n?`, highest: ${n}`:""}`,"describe");function tn(t,n){let e=t.window.document,r=t.window,o=[],a=!1,l=!1,s,d=new WeakMap,u=0,f=i(m=>(d.has(m)||d.set(m,u+=1),d.get(m)),"listId"),v=i(()=>t.body(),"ui");function k(m,C,p,g){let w=C.result?.rows;if(p.kind!=="mark"&&p.kind!=="focus"||!w)return[];let E=m.rowsTarget(C,p.anchor.index.map(A=>w[A]),void 0,p.anchor.measure);return n.rowsEntries(p.plugin,{...E,...g?{at:g}:{},annotations:[p]})}i(k,"actionsFor");async function S(m,C,p,g){let w=await v(),E=g(),A=E?{x:E.x,y:E.y+E.height}:void 0,x=n.popoverAt(g,{about:{app:m.index,query:C.name},side:"bottom",dismiss:"outside",mount:i(T=>w.annotationList(T,p.map(_=>({...Ve(_),actions:k(m,C,_,A)})),_=>{x.then(D=>D.close()),Promise.resolve().then(_.run).catch(D=>{r.console?.error("anfra: an annotation\'s action failed:",D),$("plugin.uncaught",D)})}),"mount")});await x}i(S,"open");let R={signature:"",elements:[]};async function I(){a=!1;let m=[],C=[],p=!1;for(let A of o)for(let x of Object.values(A.queries)){let{annotations:T}=x;T.length&&(p=!0,ce(e,"query",A.index,x.name).forEach((_,D)=>{let F=yr(_,T);if(!F.length)return;let L=wr(F),z=`${A.index}/${x.name}#${D}`;C.push(`${z}:${f(T)}:${F.length}`),m.push({id:z,element:_,count:F.length,...L?{severity:L}:{},label:br(F.length,L),onOpen:i(B=>{S(A,x,F,B).catch(V=>{r.console?.error("anfra: the annotations popover failed to open:",V),$("plugin.uncaught",V)})},"onOpen")})}))}b(p);let g=m.map(A=>A.element),w=C.join("|");if(w===R.signature&&g.every((A,x)=>A===R.elements[x])||(R={signature:w,elements:g},!m.length&&!l))return;l=!0,(await v()).badges(K(e,"anfra-badges"),m)}i(I,"draw");let h=i(()=>{a||(a=!0,queueMicrotask(()=>{I().catch(m=>{r.console?.error("anfra: the annotations badge failed to draw:",m),$("plugin.uncaught",m)})}))},"schedule");function b(m){m&&!s&&typeof r.MutationObserver=="function"?(s=new r.MutationObserver(h),s.observe(e.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[O.query,en]})):!m&&s&&(s.disconnect(),s=void 0)}i(b,"watchPage"),t.onApp(m=>{o.push(m),m.subscribe(h),m.onRemoved(h)})}i(tn,"installAnnotationBadges");var nn=["ctrl","alt","shift","meta"];function rn(t){if(typeof t!="string")return;let n=t.split("+").map(o=>o.trim().toLowerCase()).filter(Boolean),e=n.pop(),r=i(o=>nn.includes(o),"isModifier");if(!(!e||r(e)||!n.every(r)))return[...nn.filter(o=>n.includes(o)),e].join("+")}i(rn,"normalizeShortcut");function on(t){let n=t;return!n||typeof n.tagName!="string"?!1:n.isContentEditable===!0||["INPUT","TEXTAREA","SELECT"].includes(n.tagName.toUpperCase())}i(on,"isTyping");function sn(t){let n=typeof t.code=="string"?t.code:"",e=/^Key[A-Z]$/.test(n)?n.slice(3).toLowerCase():/^Digit[0-9]$/.test(n)?n.slice(5):(t.key??"").toLowerCase();return[t.ctrlKey&&"ctrl",t.altKey&&"alt",t.shiftKey&&"shift",t.metaKey&&"meta",e].filter(Boolean).join("+")}i(sn,"eventShortcut");function Ge(t,n,e,r,o){if(r in n||t.has(r))throw new y(`Plugin \'${r}\' can\'t add \'${r}\' to a ${e}: it already has one.`);t.set(r,o)}i(Ge,"addExtension");function ye(t,n){return n?.forEach((e,r)=>{let o=!1,a;Object.defineProperty(t,r,{configurable:!0,enumerable:!1,get(){return o||(a=e(t),o=!0),a}})}),t}i(ye,"applyExtensions");var vr="anfra.body",We="__anfraBodyExports",kr={DataAppError:M,ValidationError:y,invalidRequest:se,forbidden:xt,connectionFailed:At,callFailed:J,fromHttpStatus:Ct,hasErrorCode:Et,isDataAppError:j};function Er(t,n){let e=t,r=t.document.createElement("script");r.textContent=`(function () { var __anfraBody;\n${n}\n;self[${JSON.stringify(We)}] = __anfraBody; })();`,(t.document.head??t.document.documentElement).appendChild(r),r.remove();let o=e[We];if(delete e[We],!o)throw new y("The host sent a plugin body that did not run.");return o.default??o}i(Er,"runBody");function Je(t,n){if(typeof t=="function")return De(t,n);if(typeof t!="object"||t===null)return t;let e=new Map;return new Proxy(t,{get(r,o,a){let l=Reflect.get(r,o,a);if(typeof l!="function"||typeof o!="string")return l;let s=e.get(o);if(s?.of===l)return s.fn;let d=De(l.bind(r),`${n}_${G(o)}`);return e.set(o,{of:l,fn:d}),d}})}i(Je,"namedMember");function Sr(t,{app:n,query:e,variant:r}){let o=t.apps[n]?.queries??{},a=Object.hasOwn(o,e)?o[e]?.id:void 0;return{app:n,query:e,...a!==void 0&&{id:a},...r!==void 0&&{variant:r}}}i(Sr,"withQueryId");function we(t,n,e){let{window:r,sdk:o,endpoint:a}=n,l;return{plugin:t,window:r,sdk:o,errors:kr,get overlay(){return pe(r.document)},structure:i(()=>Ft(r.document,o.apps),"structure"),queryRequest(s){let d=o.apps.find(u=>u.queries[s?.name]===s);if(!d)throw new y(`Query \'${String(s?.name)}\' belongs to no app.`,s?.name);return d.requestFor(s)},call:i((s,d,u,f)=>a.call(s,d??null,u,f&&Sr(o,f)),"call"),emit:i((s,d)=>a.emit(`${t}.${s}`,d??null),"emit"),handle(s,d){n.handlers.set(`${t}.${s}`,d)},on(s,d){let u=`${t}.${s}`;n.listeners.has(u)||n.listeners.set(u,new Set),n.listeners.get(u).add(d)},onApp(s){n.appListeners.add(s),o.apps.forEach(d=>s(d))},provide(s){if(t in o)throw new y(`Plugin \'${t}\' can\'t add a member Anfra already has.`);Object.defineProperty(o,t,{value:Je(s,G(t)),enumerable:!0})},provideOnQuery:i(s=>Ge(o.extensions.query,e.Query.prototype,"query",t,d=>Je(s(d),G(t))),"provideOnQuery"),provideOnControl:i(s=>Ge(o.extensions.control,e.Control.prototype,"control",t,d=>Je(s(d),G(t))),"provideOnControl"),layer:i(()=>K(r.document,t),"layer"),menuItem:i(s=>n.contentUi?.addItem(t,s),"menuItem"),modal:i(s=>n.contentUi.modal(s),"modal"),popover:i(s=>n.contentUi.popover(s),"popover"),annotate(s,d,u){if(s?.isRemoved)return!1;if(!o.apps.find(v=>v.queries[s?.name]===s))throw new y(`Plugin \'${t}\' annotated a query that belongs to no app.`,s?.name);if(!u||typeof u.result!="object"||u.result===null)throw new y(`Plugin \'${t}\' annotated query \'${s.name}\' without the result it computed them from ({ result: query.result }).`,s.name);return s.isCurrentResult(u.result)?(s.setAnnotations(t,Xt(t,s.name,u.result,d)),!0):!1},body(){return l??(l=a.call(vr,{plugin:t}).then(s=>Er(r,s)).catch(s=>{throw l=void 0,s})),l}}}i(we,"createKernel");var He=["sum","avg","max","min","count","count distinct","median","stdev","stdevp","var","varp"];var Xe=class Xe{constructor(n){c(this,"descriptor");c(this,"fields",new Map);c(this,"references");this.descriptor=n,n.data_models.forEach(e=>{e.fields.forEach(r=>{let o=String(e.name);this.fields.set(`${o}.${r.name}`,{modelName:o,fieldName:r.name,isMetric:!1,type:r.type,label:r.label??r.name})})}),n.metrics.forEach(e=>{this.fields.set(e.name,{fieldName:e.name,isMetric:!0,type:e.type,label:e.label??e.name})}),this.references=[...this.fields.keys()]}resolve(n,e){let r=this.fields.get(n);if(r)return r;throw new y(P(`Unknown field \'${n}\' on dataset \'${this.descriptor.name}\'.`,n,this.references),e)}};i(Xe,"DatasetIndex");var be=Xe;function an(t,n,e){let r=t[n];if(r)return r;throw new y(P(`Unknown dataset \'${n}\'.`,n,Object.keys(t)),e)}i(an,"resolveDataset");function ln(t,n){if(!He.includes(t))throw new y(P(`Invalid filter aggregation \'${t}\'.`,t,[...He]),n)}i(ln,"assertValidFilterAggregation");function dn(t,n,e){if(!n)throw new y(`A ${e} needs a name.`);for(let r of t)if(r===n)throw new y(`\'${n}\' is already declared in this app.`,n)}i(dn,"assertUniqueName");var xr={ns:1e-6,us:.001,\\u00B5s:.001,ms:1,s:1e3,m:6e4,h:36e5},Ar=168*36e5;function Cr(t){if(t==="0")return 0;let n=/(\\d+(?:\\.\\d*)?|\\.\\d+)(ns|us|\xB5s|ms|s|m|h)/y,e=0,r=0;for(let o=n.exec(t);o;o=n.exec(t))e+=parseFloat(o[1])*xr[o[2]],r=n.lastIndex;return r>0&&r===t.length?e:void 0}i(Cr,"parseDuration");function X(t,n,e,r){let o=JSON.stringify(e);return r==="sets"?`${t} sets ${n} to ${o}`:`${t} declares ${n} ${o}`}i(X,"gave");var Ye=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function ve(t,n,e,r="declares"){if(t===void 0||Ye.includes(t))return;let o=`${X(n,e,t,r)}.`,a=typeof t=="string"?ze(t.trim(),[...Ye]):void 0;if(a)throw new y(`${o} Did you mean ${JSON.stringify(a)}?`);let l=Ye.map(s=>JSON.stringify(s));throw new y(`${o} Use one of: ${l.slice(0,-1).join(", ")}, or ${l[l.length-1]}.`)}i(ve,"assertWeekStartDay");function ke(t,n,e,r,o="declares"){if(t===void 0)return;let a=typeof t=="string"?Cr(t):void 0;if(a===void 0)throw new y(`${X(n,e,t,o)}, which isn\'t a duration. Use one such as 30s, 10m or 2h.`,r);if(a>Ar)throw new y(`${X(n,e,t,o)}, which is over 168h (7 days), the longest a result can be cached.`,r)}i(ke,"assertCacheDuration");function Ze(t,n,e="declares"){if(!n.aql?.trim())throw new y(`Query \'${t}\' ${e} no AQL.`,t);let{pageSize:r}=n;if(r!==void 0&&!(Number.isInteger(r)&&r>=1))throw new y(`${X(`Query \'${t}\'`,"pageSize",r,e)}, but it must be a whole number of at least 1.`,t);ke(n.cache?.duration,`Query \'${t}\'`,"cache.duration",t,e)}i(Ze,"assertDeclaration");var et=class et extends q{constructor(e,r,o,a){super(r);c(this,"kind","query");c(this,"name");c(this,"id");c(this,"_declaration");c(this,"_dataset");c(this,"removed",!1);c(this,"app");c(this,"_state","idle");c(this,"runFailed",!1);c(this,"_result");c(this,"_error");c(this,"_page",1);c(this,"_run");c(this,"_sort",[]);c(this,"resultSuperseded",!1);c(this,"lastRunSignature");c(this,"lastPageRows",0);c(this,"controller");c(this,"runningSignature");c(this,"startedRun");c(this,"failedSignature");c(this,"annotationSets",new Map);c(this,"currentResults",new WeakSet);c(this,"resolvedAnnotations");Ze(e,o),this.name=e,this.id=a,this.app=r,this._declaration=o,this._dataset=r.datasetIndex(o.dataset,e)}get declaration(){return this._declaration}get dataset(){return this._dataset}get isRemoved(){return this.removed}update(e){this.assertLive(),this.app.updateQuery(this,e)}remove(){this.assertLive(),this.app.removeEntity(this)}assertLive(){if(this.removed)throw new y(`Query \'${this.name}\' was removed from its app; it can\'t be used any more.`,this.name)}replaceDeclaration(e,r,o){this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0,this._state==="executing"&&(this._state=this._result?"success":"idle"),this.resultSuperseded=!0,this.clearAnnotations(),this.currentResults=new WeakSet,this._declaration=e,this._dataset=r,this._sort=[...o],this._run=void 0,this.resetPage(),this.notify()}markRemoved(){this.removed=!0,this.clearAnnotations(),this.controller?.abort(),this.controller=void 0,this.runningSignature=void 0}locate(){return this.assertLive(),this.app.locate("query",this.name)}get state(){return this._state}get result(){return this._result}get error(){return this._error}get pageSize(){return this.declaration.pageSize}get page(){return this._page}get sort(){return this._sort}setSort(e){this.assertLive(),this._sort=[...e],this.notify()}get hasMore(){return!this._result||this.pageSize===void 0||this.resultSuperseded?!1:this._result.meta.hasMore??this.lastPageRows>=this.pageSize}signature(e="pending"){let r=this.app.mappingsTo(this.name).map(o=>({field:o.field,aggregation:o.aggregation,condition:e==="pending"?o.from.condition:o.from.appliedCondition})).sort((o,a)=>o.field.localeCompare(a.field)||JSON.stringify(o).localeCompare(JSON.stringify(a)));return JSON.stringify({declaration:this.declaration,conditions:r,selection:this.app.selectionConditionsFor(this.name,e),selectionExpression:this.app.selectionExpressionFor(this.name,e),sort:this._sort,inputDefaults:this.app.queryInputDefaults,page:this._page})}get isDirty(){return this.lastRunSignature!==void 0&&this.signature()!==this.lastRunSignature}hasUnappliedChange(e){let r=this.signature();return r===this.runningSignature?!1:this.runFailed?r!==this.failedSignature:this.lastRunSignature===void 0?e&&this.runningSignature===void 0:r!==this.lastRunSignature}shouldRun(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.isDirty}runInFlightWith(e){let r=this.startedRun;if(!(!r||r.controller!==this.controller||r.controller.signal.aborted))return r.signature===e?r.outcome:void 0}shouldRunAlone(e=!1){return e||this.runFailed||this.lastRunSignature===void 0||this.signature("applied")!==this.lastRunSignature}execute(e={}){return this.assertLive(),this.app.executeQuery(this,e)}abort(){this.assertLive(),this.controller?.abort()}async fetchMore(){try{if(this.assertLive(),this.pageSize===void 0)throw new y(`Query \'${this.name}\' declares no pageSize, so it has no more pages.`,this.name);if(!this.hasMore)return;this._page+=1,await this.app.fetchPage(this)}catch(e){throw W(e,"fetch_more"),e}}async inspect(e={}){return this.assertLive(),this.app.inspect("query",this.name,e.tab)}menu(e,r,o={}){return this.assertLive(),this.app.menu(this,e,Array.isArray(r)?r:[r],o.fields,o.measure)}select(e,r={}){this.assertLive(),this.app.select(this,Array.isArray(e)?e:[e],r.fields)}get selectedRows(){let{selection:e}=this.app;if(e?.source!==this.name)return[];let r=this._result?.rows;if(!r)return e.rows;let o=i(l=>JSON.stringify(e.fields.map(s=>l[s]??null)),"key"),a=new Set(e.rows.map(o));return r.filter(l=>a.has(o(l)))}get annotations(){return this.resolvedAnnotations??(this.resolvedAnnotations=Object.freeze(Zt(this.annotationSets,this._result?.rows??[]))),this.resolvedAnnotations}isCurrentResult(e){return this.currentResults.has(e)}setAnnotations(e,r){if(r.length)this.annotationSets.set(e,r);else if(!this.annotationSets.delete(e))return;this.resolvedAnnotations=void 0,this.notify()}clearAnnotations(){this.annotationSets.clear(),this.resolvedAnnotations=void 0}markExecuting(){this.removed||(this._state="executing",this._error=void 0,this.notify())}get cacheDuration(){return this.declaration.cache?.duration??this.app.queryCacheDefaultDuration}get run(){return this._run}markSuccess(e,r,o,a){if(!this.removed){if(this._state="success",o||(this._run=a,this.resultSuperseded=!1),this._error=void 0,o||(this.runFailed=!1),this.lastRunSignature=r,this.lastPageRows=e.rows.length,o?this.resolvedAnnotations=void 0:this.clearAnnotations(),o&&this._result){let l=e.meta.pivot?Rr(this._result.rows,e.rows):e.rows,s=[...this._result.rows,...l];this._result={...e,rows:s,meta:{...e.meta,numRows:s.length}}}else this._result=e,this.currentResults=new WeakSet;this.currentResults.add(this._result),this.notify()}}markError(e,r=!1,o){this.removed||(r||(this.runFailed=!0,this.failedSignature=o),this._state="error",this._error=e,this.notify())}rewindPage(){this._page>1&&(this._page-=1)}resetPage(){this._page=1,this.lastPageRows=0}toJSON(){return this._declaration}};i(et,"Query");var Q=et,un="__pivot_row__";function Rr(t,n){let e=new Set(t.map(r=>String(r[un])));return n.filter(r=>!e.has(String(r[un])))}i(Rr,"newGridRows");function cn(t,n){if(n)throw new y(`Edge \'${t.id}\' was removed from its app; map again to have it back.`,t.from.name)}i(cn,"assertLive");var tt=class tt{constructor(n,e,r,o,a){c(this,"kind","control");c(this,"from");c(this,"to");c(this,"field");c(this,"aggregation");c(this,"owner");c(this,"removed",!1);this.from=n,this.to=e,this.field=r,this.aggregation=o,this.owner=a}remove(){cn(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}.${this.field}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:this.from.kind,name:this.from.name},to:{kind:"query",name:this.to.name},field:this.field,...this.aggregation?{aggregation:this.aggregation}:{}}}};i(tt,"Mapping");var Ee=tt,nt=class nt{constructor(n,e,r){c(this,"kind","crossFilter");c(this,"from");c(this,"to");c(this,"owner");c(this,"removed",!1);this.from=n,this.to=e,this.owner=r}remove(){cn(this,this.removed),this.owner?.removeEdge(this)}markRemoved(){this.removed=!0}get id(){return`${this.from.name}.${this.to.name}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:"query",name:this.from.name},to:{kind:"query",name:this.to.name}}}};i(nt,"CrossFilter");var Se=nt;function Dr(t,n){if(!(!n||n.operator==="none"||n.operator==="transform_date_drill"||!["is_null","not_null","is_true","is_false","transform_pop_none"].includes(n.operator)&&!n.values?.length))return{field:t.field,operator:n.operator,values:n.values??[],...n.modifier?{modifier:n.modifier}:{},...t.aggregation?{aggregation:t.aggregation}:{}}}i(Dr,"toFilter");function Tr(t,n){if(n?.operator!=="transform_date_drill")return;let e=n.values?.[0];if(typeof e!="string")return;let r=e.replace(/^datetrunc\\s+/,"");return{field:t.field,grain:r}}i(Tr,"toDateDrill");function _r(t,n){let e=n.columns??[],r=(n.values??[]).map(a=>{let l={};return e.forEach((s,d)=>{l[s.name]=a[d]}),l}),{pageSize:o}=t;return{columns:e,rows:r,meta:{...o!==void 0?{page:n.meta?.page??t.page,pageSize:n.meta?.pageSize??o,...n.meta?.hasMore!==void 0?{hasMore:n.meta.hasMore}:{},...n.meta?.pivot?{pivot:n.meta.pivot}:{}}:{},numRows:n.meta?.numRows??r.length},...n.debug?{debug:n.debug}:{}}}i(_r,"toResult");function xe(t,n,e,r){let o=n.map(d=>Dr(d,d.from.appliedCondition)).filter(d=>d!==void 0),a=n.map(d=>Tr(d,d.from.appliedCondition)).filter(d=>d!==void 0),l=e.conditions.map(d=>({field:d.field,operator:d.operator,values:d.values})),s=e.expression?[{expr:e.expression}]:[];return{dataset:t.dataset.descriptor.name,aql:t.declaration.aql,input:{filters:[...o,...l],conditions:s,sorts:t.sort.map(d=>({field:d.field,direction:d.direction??"asc"})),dateDrills:a,...r.timezone?{timezone:r.timezone}:{},...r.weekStartDay?{weekStartDay:r.weekStartDay}:{}},...t.cacheDuration?{cacheDuration:t.cacheDuration}:{}}}i(xe,"buildQuery");function rt(t,n,e,r){let{input:o,...a}=xe(t,n,e,r);return{...a,input:fn(o,t),...r.bustCache?{bustCache:!0}:{}}}i(rt,"buildRequest");function pn(t,n){return{dataset:t.dataset.descriptor.name,aql:t.declaration.aql,input:fn(n.input,t),...t.cacheDuration?{cacheDuration:t.cacheDuration}:{},...n.cachedAt?{minCachedAt:n.cachedAt}:{}}}i(pn,"pageRequest");function fn(t,n){let{pagination:e,...r}=t;return n.pageSize!==void 0?{...r,pagination:{page:n.page,pageSize:n.pageSize}}:r}i(fn,"withPage");function $r(t,n){let e=n?.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim();return e?`${e} - ${t.name}`:t.name}i($r,"defaultExportFilename");function mn(t,n,e,r,o,a){let l=o.format??"csv",s=l==="csv"?{bom:!0,...o.formatOptions}:o.formatOptions,d=xe(t,n,e,r),{pagination:u,...f}=a?.input??d.input;return{...d,input:f,...a?.cachedAt?{minCachedAt:a.cachedAt}:{},format:l,...s?{formatOptions:s}:{},filename:o.filename?.trim()||$r(t,r.title)}}i(mn,"buildExportRequest");async function ot(t,n,e,r,o){let a=await e.submitQuery(n,r,o),l=a.debug?.cache?.cachedAt?.toISOString();return{result:_r(t,a),run:{input:a.input??n.input,...l?{cachedAt:l}:{}}}}i(ot,"runQuery");function Or(t,n){if(t===null)return"null";if(typeof t=="boolean")return t?"true":"false";if(n==="number"&&typeof t=="string")return Mr(t);if(typeof t=="number"){if(!Number.isFinite(t))throw new RangeError(`Cannot express ${t} in AQL.`);return Math.abs(t)>=1e21?BigInt(t).toString():String(t)}return JSON.stringify(t).split("\\u2028").join("\\\\u2028").split("\\u2029").join("\\\\u2029")}i(Or,"literal");function hn(t,n,e){return n===null?`is(${t}, null)`:`${t} is ${Or(n,e)}`}i(hn,"equals");var Ir=new Set(["NaN","Infinity","-Infinity"]),Fr=/^(-?)(0|[1-9]\\d*)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/;function Mr(t){let n=Fr.exec(t);if(!n)throw Ir.has(t)?new RangeError(`Cannot express ${t} in AQL.`):new TypeError(`${JSON.stringify(t)} is not a number: a number is a string in JSON\'s number syntax.`);let[,e,r,o="",a]=n;if(a===void 0)return t;let l=r+o,s=r.length+Number(a),d;return s<=0?d=`0.${"0".repeat(-s)}${l}`:s>=l.length?d=l+"0".repeat(s-l.length):d=`${l.slice(0,s)}.${l.slice(s)}`,e+d.replace(/^0+(?=\\d)/,"")}i(Mr,"numberLiteral");function gn(t,n,e){return`${t} matches @(${n} until ${e})`}i(gn,"dateRange");function yn(t,n){if(n.length===0)throw new RangeError(`\\`${t}\\` needs at least one operand.`);return n.length===1?n[0]:`${t}(${n.join(", ")})`}i(yn,"combine");var wn=i(t=>yn("and",t),"and"),bn=i(t=>yn("or",t),"or");var Qr=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?)?/,Nr={week:7*864e5,day:864e5,hour:36e5,minute:6e4};function vn(t){if(typeof t!="string")return;let n=Qr.exec(t);if(n)return{year:Number(n[1]),month:Number(n[2])-1,day:Number(n[3]),hour:Number(n[4]??0),minute:Number(n[5]??0),second:Number(n[6]??0),hasTime:n[4]!==void 0}}i(vn,"parseStamp");function Z(t,n){let e=new Date(t),r=i(a=>String(a).padStart(2,"0"),"pad"),o=`${e.getUTCFullYear()}-${r(e.getUTCMonth()+1)}-${r(e.getUTCDate())}`;return n?`${o} ${r(e.getUTCHours())}:${r(e.getUTCMinutes())}:${r(e.getUTCSeconds())}`:o}i(Z,"format");function kn(t){return Date.UTC(t.year,t.month,t.day,t.hour,t.minute,t.second)}i(kn,"toMs");function it(t){let n=vn(t);if(n)return Z(kn(n),n.hasTime)}i(it,"normalise");function st(t,n){let e=vn(t);if(!e)return;let{year:r,month:o,day:a,hour:l,minute:s,second:d,hasTime:u}=e;return Z(n==="year"?Date.UTC(r+1,o,a,l,s,d):n==="quarter"?Date.UTC(r,o+3,a,l,s,d):n==="month"?Date.UTC(r,o+1,a,l,s,d):kn(e)+Nr[n],u)}i(st,"addGrain");function En(t){if(t?.startsWith("datetrunc "))return t.slice(10)}i(En,"grainOf");function Pr(t){let n=new Set;return t.filter(e=>{let r=`${typeof e}:${String(e)}`;return n.has(r)?!1:(n.add(r),!0)})}i(Pr,"distinct");function Lr(t,n){let e=t.map(it);if(e.some(o=>o===void 0))return!1;let r=e.slice().sort();for(let o=1;o<r.length;o+=1)if(st(r[o-1],n)!==r[o])return!1;return!0}i(Lr,"isContiguous");function Br(t,n,e){let r=n.map(it);if(r.some(d=>d===void 0))return;let o=r.slice().sort(),a=o[0],l=st(o[o.length-1],e);if(!l)return;let s=Lr(n,e);return{condition:{field:t,operator:"matches",values:[`${a} until ${l}`]},admits:s?n.length:Number.POSITIVE_INFINITY,lossy:!s}}i(Br,"dateRange");function Kr(t,n,e){let r=e.filter(s=>s!=null),o=Pr(r);if(!o.length)return{condition:{field:t,operator:"is_null",values:[]},admits:1,lossy:!1};let a=r.length!==e.length,l=En(n);if(l){let s=Br(t,o,l);if(s)return{...s,lossy:s.lossy||a}}return{condition:{field:t,operator:"is",values:o},admits:o.length,lossy:a}}i(Kr,"deriveOne");function Sn(t){return t.modelId?`${t.modelId}.${t.fieldName}`:t.fieldName}i(Sn,"fieldReferenceOf");function jr(t,n,e,r){try{let o=e.map(a=>wn(n.map(l=>{let s=t.get(l),d=Sn(s),u=a[l]??null,f=En(r[d]);if(f&&typeof u=="string"){let v=it(u),k=st(u,f);if(v&&k)return gn(d,v,k)}if(u!==null&&typeof u!="string"&&typeof u!="number"&&typeof u!="boolean")throw new TypeError("no AQL spelling");return hn(d,u,s.semantic_type)})));return bn(o)}catch{return}}i(jr,"selectionExpression");function at(t,n,e,r={}){let o=t.result?.columns??[],a=new Map(o.map(h=>[h.name,h]));e?.forEach(h=>{let b=a.get(h);if(b){if(b.adhoc)throw new y(`Query \'${t.name}\' cannot cross-filter on \'${h}\': it is a query-local AQL expression, which only this query\'s result carries. The target query would receive a condition naming a field it has never heard of.`,t.name);if(b.isMeasure)throw new y(`Query \'${t.name}\' cannot cross-filter on \'${h}\': it is a measure, and a selection conditions dimensions only.`,t.name);return}throw new y(P(`Query \'${t.name}\' has no column \'${h}\' in its last result.`,h,[...a.keys()]),t.name)});let l=o.filter(h=>!h.isMeasure),s=l.filter(h=>!h.adhoc).map(h=>h.name),d=e?[...e]:s;if(!n.length||!d.length)return;let u=[],f=1,v=!e&&s.length!==l.length,k=!1;d.forEach(h=>{let b=a.get(h),m=Sn(b),C=Kr(m,r[m],n.map(p=>p[h]));u.push(C.condition),f*=C.admits,k=k||C.lossy});let S=new Set(n.map(h=>JSON.stringify(d.map(b=>h[b]??null))));f>S.size&&(k=!0);let R=u.sort((h,b)=>h.field.localeCompare(b.field)),I={source:t.name,rows:[...n],fields:d};if(k){let h=jr(a,d,n,r);if(h)return{...I,conditions:[],expression:h,lossy:v}}return{...I,conditions:R,lossy:v||k}}i(at,"deriveSelection");var lt=Object.freeze([]);function dt(t){return t instanceof Error&&t.name==="AbortError"}i(dt,"isAbort");function Ae(t,n){return t.controller!==n}i(Ae,"superseded");function qr(t){return{name:t.name,code:t.code,scope:t.scope,message:t.message,...t.entity?{entity:t.entity}:{},...typeof t.status=="number"?{status:t.status}:{},...t.requestId?{requestId:t.requestId}:{},...t.stack?{stack:t.stack}:{}}}i(qr,"inspectError");function Vr(t){let{result:n}=t;return{id:t.id,state:t.state,isDirty:t.isDirty,page:t.page,hasMore:t.hasMore,columns:n?n.columns.map(e=>({...e})):[],rowCount:n?.meta.numRows??0,selectedRowCount:t.selectedRows.length,signature:t.signature(),...t.error?{error:qr(t.error)}:{},...n?.debug?{debug:{...n.debug}}:{}}}i(Vr,"inspectQuery");function zr(t){let{options:n}=t;return{kind:t.kind,condition:{...t.condition},...t.appliedCondition?{appliedCondition:{...t.appliedCondition}}:{},isDirty:t.isDirty,...n?{options:[...n]}:{}}}i(zr,"inspectControl");function xn(t){return{source:t.source,fields:[...t.fields],rowCount:t.rows.length,conditions:t.conditions.map(n=>({...n})),...t.expression?{expression:t.expression}:{},lossy:t.lossy}}i(xn,"inspectSelection");function An(t){return t?JSON.stringify({source:t.source,conditions:t.conditions,expression:t.expression}):"none"}i(An,"selectionKey");function ut(t,n,e="The query failed."){return j(t)?t.about(n):(console.error(`anfra: \'${n}\' failed; the app is told only that it failed.`,t),new M({code:"call_failed",scope:"server",message:e,entity:n,cause:t}))}i(ut,"toDataAppError");var ct=class ct extends q{constructor(e,r,o,a,l){super();c(this,"extensions",l);c(this,"title");c(this,"_timezone");c(this,"_weekStartDay");c(this,"queryInput");c(this,"queryCacheDefaultDuration");c(this,"datasets");c(this,"backend");c(this,"features");c(this,"_queries",new Map);c(this,"_controls",new Map);c(this,"_mappings",[]);c(this,"_crossFilters",[]);c(this,"_selection");c(this,"_appliedSelection");c(this,"selectionCommitted",!1);c(this,"nextQueryId",1);c(this,"removedListeners",new Set);c(this,"revealer");c(this,"index",0);this.title=e.title,this._timezone=e.timezone,ve(e.weekStartDay,"The app","weekStartDay"),this._weekStartDay=e.weekStartDay;let s=e.query?.default?.input??{};ve(s.weekStartDay,"The app","query.default.input.weekStartDay"),this.queryInput={...s};let d=e.query?.default?.cache?.duration;ke(d,"The app","query.default.cache.duration"),this.queryCacheDefaultDuration=d,this.datasets=r,this.backend=o,this.features=a}get queries(){return Object.fromEntries(this._queries)}get controls(){return Object.fromEntries(this._controls)}get mappings(){return[...this._mappings,...this._crossFilters]}get crossFilters(){return this._crossFilters}createQuery(e,r){this.assertNameFree(e,"query");let o=ye(new Q(e,this,r,this.nextQueryId++),this.extensions?.query);return this._queries.set(e,o),this.notify(),o}createFilter(e,r){this.assertNameFree(e,"filter");let o=this.filterDataset(e,r),a=ye(new le(e,this,r,o,this.backend),this.extensions?.control);return this._controls.set(e,a),this.notify(),a}createDateDrill(e,r={}){if(this.features?.dateDrill===!1)throw new y(`Date drill \'${e}\' needs a capability this workspace has not enabled. Ask an admin to turn on \\`interactive_control:date_drill\\`.`,e);this.assertNameFree(e,"date drill control");let o=ye(new de(e,this,r),this.extensions?.control);return this._controls.set(e,o),this.notify(),o}mapControl(e,r,o){if(!(e instanceof N))throw new y("mapControl expects a control as its source. To let one query cross-filter another, use app.mapCrossFilter(from, to) \\u2014 a cross-filter edge names no field.");if(e.assertLive(),r.assertLive(),this._controls.get(e.name)!==e)throw new y(`Control \'${e.name}\' belongs to a different app.`,e.name);if(this._queries.get(r.name)!==r)throw new y(`Query \'${r.name}\' belongs to a different app.`,r.name);o.aggregation&&ln(o.aggregation,e.name);let a=new Ee(e,r,o.field,o.aggregation,this);if(this._mappings.some(l=>l.id===a.id))throw new y(`Mapping \'${a.id}\' is already declared.`,e.name);return this.assertAcyclic(a),this._mappings.push(a),this.notify(),a}mapCrossFilter(e,r){if(!(e instanceof Q)||!(r instanceof Q))throw new y("mapCrossFilter expects two queries. To let a control condition a query, use app.mapControl(from, to, { field }).");if(e.assertLive(),r.assertLive(),this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);if(this._queries.get(r.name)!==r)throw new y(`Query \'${r.name}\' belongs to a different app.`,r.name);if(e===r)throw new y(`Query \'${e.name}\' cannot cross-filter itself. A source keeps its own rows so it can show what is selected; filtering it would erase the very rows the reader clicked.`,e.name);if(e.declaration.dataset!==r.declaration.dataset)throw new y(`Cross-filter \'${e.name}\' -> \'${r.name}\' spans two datasets (\'${e.declaration.dataset}\' and \'${r.declaration.dataset}\'). A selection carries field references, which mean nothing outside the dataset that resolved them.`,e.name);let o=new Se(e,r,this);if(this._crossFilters.some(a=>a.id===o.id))throw new y(`Cross-filter \'${o.id}\' is already declared.`,e.name);return this._crossFilters.push(o),this.notify(),o}updateQuery(e,r){let o=e.declaration,a=H(o,r,["dataset","aql","pageSize","cache"]);Ze(e.name,a,"sets");let l=this.datasetIndex(a.dataset,e.name);if(a.dataset!==o.dataset){let u=this._crossFilters.filter(f=>f.from===e?f.to.declaration.dataset!==a.dataset:f.to===e?f.from.declaration.dataset!==a.dataset:!1);if(u.length)throw new y(`Query \'${e.name}\' can\'t move to dataset \'${a.dataset}\': its cross-filters ${u.map(f=>`\'${f.id}\'`).join(", ")} would span two datasets. Remove them first.`,e.name)}let s=a.aql!==o.aql||a.dataset!==o.dataset,d=r.sort??(s?[]:e.sort);s&&this.dropSelectionFrom(e.name),e.replaceDeclaration(a,l,d)}removeEntity(e){if(e instanceof Q){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);this._queries.delete(e.name),this.dropEdges(r=>r.to===e||r.from===e),this.dropSelectionFrom(e.name)}else{if(this._controls.get(e.name)!==e)throw new y(`Control \'${e.name}\' belongs to a different app.`,e.name);this._controls.delete(e.name),this.dropEdges(r=>r.from===e)}e.markRemoved(),this.removedListeners.forEach(r=>{try{r(e)}catch{}}),this.notify()}removeEdge(e){if(!this.dropEdges(r=>r===e))throw new y(`Edge \'${e.id}\' belongs to a different app.`,e.from.name);this.notify()}onRemoved(e){return this.removedListeners.add(e),()=>{this.removedListeners.delete(e)}}dropEdges(e){let r=this.mappings.filter(e);r.forEach(a=>a.markRemoved());let o=i(a=>{let l=a.filter(s=>!r.includes(s));a.splice(0,a.length,...l)},"keep");return o(this._mappings),o(this._crossFilters),r.length>0}dropSelectionFrom(e){this._selection?.source===e&&(this._selection=void 0),this._appliedSelection?.source===e&&(this._appliedSelection=void 0)}get selection(){return this._selection}get appliedSelection(){return this._appliedSelection}clearSelection(){this._selection&&(this._selection=void 0,this.notify())}setTimezone(e){this._timezone=e,this.notify()}get timezone(){return this._timezone}setWeekStartDay(e){ve(e,"The app","weekStartDay","sets"),this._weekStartDay=e,this.notify()}get weekStartDay(){return this._weekStartDay}get queryInputDefaults(){let e=this.queryInput.timezone??this._timezone,r=this.queryInput.weekStartDay??this._weekStartDay;return{...e?{timezone:e}:{},...r?{weekStartDay:r}:{}}}datasetIndex(e,r){return an(this.datasets,e,r)}filterDataset(e,r){return r.dataset?this.datasetIndex(r.dataset,e):this.soleDataset(e,r.field)}mappingsTo(e){return this._mappings.filter(r=>r.to.name===e)}selectionExpressionFor(e,r){return this.selectionFor(e,r)?.expression}selectionFor(e,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?void 0:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===e)?o:void 0}selectionConditionsFor(e,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===e?lt:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===e)?o.conditions:lt}drillTransformations(e){let r={};return this._mappings.forEach(o=>{if(o.to!==e)return;let a=o.from.appliedCondition;if(a?.operator!=="transform_date_drill")return;let[l]=a.values??[];typeof l=="string"&&(r[o.field]=l)}),r}menu(e,r,o,a,l){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);if(l!==void 0){let s=e.result?.columns??[],d=s.find(u=>u.name===l);if(!d?.isMeasure)throw new y(d?`Query \'${e.name}\' can\'t open a menu on \'${l}\' as its measure: it is a dimension.`:P(`Query \'${e.name}\' has no measure \'${l}\' in its last result.`,l,s.filter(u=>u.isMeasure).map(u=>u.name)),e.name)}return Wt(r,this.rowsTarget(e,o,a,l))}rowsTarget(e,r,o,a){let l=at(e,r,o,this.drillTransformations(e)),s=e.annotations.filter(d=>(d.kind==="mark"||d.kind==="focus")&&(a===void 0||d.anchor.measure===void 0||d.anchor.measure===a)&&d.anchor.rows.some(u=>r.some(f=>Ue(u,f))));return{kind:"rows",app:this.index,query:e.name,rows:[...r],fields:l?.fields?[...l.fields]:[],...a!==void 0?{measure:a}:{},conditions:l?.conditions?[...l.conditions]:[],...l?.expression?{expression:l.expression}:{},...s.length?{annotations:s}:{}}}requestFor(e){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);return xe(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},this.queryInputDefaults)}select(e,r,o){if(this._queries.get(e.name)!==e)throw new y(`Query \'${e.name}\' belongs to a different app.`,e.name);let a=at(e,r,o,this.drillTransformations(e));a?.lossy&&console.warn(`[anfra-sdk] The selection in \'${e.name}\' filters more broadly than it was made. Its conditions are combined field by field and ANDed, which cannot express "(A and B) or (C and D)", so the targets will also show combinations that were not selected. Select within one dimension, or narrow with \\`fields\\`, to avoid this.`),this._selection=a,this.notify()}get hasChanges(){return[...this._controls.values()].some(e=>e.isDirty)||this.isSelectionDirty||[...this._queries.values()].some(e=>e.hasUnappliedChange(this.selectionCommitted))}get isSelectionDirty(){return this.selectionCommitted?An(this._selection)!==An(this._appliedSelection):!1}async execute(e={}){let r=[...this._queries.values()].filter(s=>s.shouldRun(e.force));this._controls.forEach(s=>s.commit()),this._appliedSelection=this._selection,this.selectionCommitted=!0;let o={backend:this.backend,...this.queryInputDefaults,bustCache:e.bustCache},a=[],l=[];return await Promise.all(r.map(async s=>{let d=await this.runWith(s,"pending",o,e.force);d==="succeeded"?a.push(s.name):d==="failed"&&l.push(s.name)})),{succeeded:a,failed:l}}async executeQuery(e,r={}){if(!e.shouldRunAlone(r.force))return{succeeded:[],failed:[]};let o=await this.runWith(e,"applied",{backend:this.backend,...this.queryInputDefaults,bustCache:r.bustCache},r.force);return{succeeded:o==="succeeded"?[e.name]:[],failed:o==="failed"?[e.name]:[]}}runWith(e,r,o,a=!1){let l=a||o.bustCache?void 0:e.runInFlightWith(e.signature(r));return l||(e.controller?.abort(),e.resetPage(),this.run(e,e.signature(r),o))}run(e,r,o){let a=new AbortController;e.controller=a,e.runningSignature=r;let l,s=new Promise((d,u)=>{l={resolve:d,reject:u}});return e.startedRun={controller:a,signature:r,outcome:s},e.markExecuting(),this.runFirstPage(e,r,o,a).then(l.resolve,l.reject),s}async runFirstPage(e,r,o,a){try{let l=rt(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},o),{result:s,run:d}=await ot(e,l,o.backend,a.signal,this.stampOf(e));return Ae(e,a)?void 0:(e.markSuccess(s,r,!1,d),"succeeded")}catch(l){if(Ae(e,a)||dt(l))return;let s=ut(l,e.name);return e.markError(s,!1,r),$("call.query",s),"failed"}finally{e.controller===a&&(e.controller=void 0,e.runningSignature=void 0)}}async refresh(){return this.execute({force:!0,bustCache:!0})}abort(){this._queries.forEach(e=>e.abort())}async fetchPage(e){let r=new AbortController,o=e.signature("applied");e.controller=r,e.runningSignature=o,e.markExecuting();try{let a=e.run?pn(e,e.run):rt(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{backend:this.backend,...this.queryInputDefaults}),{result:l}=await ot(e,a,this.backend,r.signal,this.stampOf(e));if(Ae(e,r))return;e.markSuccess(l,o,!0)}catch(a){if(Ae(e,r)||(e.rewindPage(),dt(a)))return;let l=ut(a,e.name);throw e.markError(l,!0),l}finally{e.controller===r&&(e.controller=void 0,e.runningSignature=void 0)}}async exportQuery(e,r,o){let a=mn(e,this.mappingsTo(e.name),{conditions:this.selectionConditionsFor(e.name,"applied"),expression:this.selectionExpressionFor(e.name,"applied")},{...this.queryInputDefaults,title:this.title},r,e.run);try{return await o(a,r.signal??new AbortController().signal,{app:this.index,query:e.name})}catch(l){throw dt(l)?l:ut(l,e.name,"The export failed.")}}toJSON(){let e=i(r=>Object.fromEntries([...this._controls.entries()].filter(([,o])=>o.kind===r).map(([o,a])=>[o,a.toJSON()])),"byKind");return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},queries:Object.fromEntries([...this._queries.entries()].map(([r,o])=>[r,o.toJSON()])),filters:e("filter"),dateDrills:e("dateDrill"),mappings:[...this._mappings.map(r=>r.toJSON()),...this._crossFilters.map(r=>r.toJSON())]}}toInspectJSON(){return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},...this._weekStartDay?{weekStartDay:this._weekStartDay}:{},...Object.keys(this.queryInput).length>0?{queryInput:{...this.queryInput}}:{},hasChanges:this.hasChanges,declaration:this.toJSON(),queries:Object.fromEntries([...this._queries.entries()].map(([e,r])=>[e,Vr(r)])),controls:Object.fromEntries([...this._controls.entries()].map(([e,r])=>[e,zr(r)])),...this._selection?{selection:xn(this._selection)}:{},...this._appliedSelection?{appliedSelection:xn(this._appliedSelection)}:{}}}inspect(e,r,o){return this.revealer?this.revealer({app:this.index,entity:e,name:r,...o!==void 0?{tab:o}:{}}):Promise.resolve(!1)}locate(e,r){let o=globalThis.document;if(!o)return!1;let a=ce(o,e,this.index,r);return a.length?(fe(a[0]),pe(o).flash(a,{kind:e,name:r,...a.length>1?{note:`in ${a.length} places`}:{}}),!0):!1}stampOf(e){return{app:this.index,query:e.name,id:e.id}}assertNameFree(e,r){dn([...this._queries.keys(),...this._controls.keys()],e,r)}soleDataset(e,r){if(!r)return;let o=Object.keys(this.datasets);if(o.length===1)return this.datasets[o[0]];throw new y(o.length?`Filter \'${e}\' names a field but the environment has ${o.length} datasets. Say which one: ${o.join(", ")}.`:`Filter \'${e}\' names a field but the environment has no datasets.`,e)}assertAcyclic(e){let r=[...this._mappings,e],o=new Map;r.forEach(d=>{let u=d.from.name;o.set(u,[...o.get(u)??[],d.to.name])});let a=new Set,l=new Set,s=i(d=>{if(a.has(d))return!0;if(l.has(d))return!1;a.add(d);let u=(o.get(d)??[]).some(s);return a.delete(d),l.add(d),u},"walk");if([...o.keys()].some(s))throw new y(`Mapping \'${e.id}\' would make the app\'s mappings cyclic.`,e.from.name)}};i(ct,"App");var Ce=ct;var Cn="0.25.0-rc.2";var ht=class ht{constructor(){c(this,"current",{scheme:"light",tokens:Pe.light});c(this,"listeners",new Set)}get scheme(){return this.current.scheme}get tokens(){return this.current.tokens}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}set(n){this.current=n,this.listeners.forEach(e=>{try{e(n)}catch{}})}};i(ht,"HostTheme");var pt=ht,gt=class gt{constructor(n){c(this,"list");this.list=Object.freeze(n.map(({name:e,version:r})=>Object.freeze({name:e,version:r})))}has(n){return this.list.some(e=>e.name===n)}version(n){return this.list.find(e=>e.name===n)?.version}};i(gt,"InstalledPlugins");var ft=gt,Gr=Cn,yt=class yt{constructor(n){c(this,"version",Gr);c(this,"_apps",[]);c(this,"datasets");c(this,"user");c(this,"indices");c(this,"backend");c(this,"plugins");c(this,"theme",new pt);c(this,"gates");c(this,"deprecatedFeatures");c(this,"extensions",{query:new Map,control:new Map});if(!n?.datasets)throw new y("No datasets provided. The host must call createSdk({ datasets }) before an app can be declared.");if(!n.user)throw new y("No user provided. The host must call createSdk({ user }) before an app can be declared.");if(!n.backend)throw new y("No backend provided. The host must call createSdk({ backend }) before an app can run a query.");this.datasets=Object.freeze({...n.datasets}),this.user=Object.freeze({...n.user,permissions:Object.freeze({...n.user.permissions})}),this.indices=Object.fromEntries(Object.entries(n.datasets).map(([e,r])=>[e,new be(r)])),this.backend=n.backend,this.gates=Object.freeze({...n.features}),this.plugins=new ft(n.plugins??[])}get features(){return this.deprecatedFeatures||(console.warn("anfra: Anfra.features is deprecated and will be removed. Check Anfra.plugins.has(\'export\'), Anfra.plugins.has(\'render\') or Anfra.plugins.has(\'lineage\') instead."),this.deprecatedFeatures=Object.freeze({...this.gates,export:this.plugins.has("export"),render:this.plugins.has("render"),lineage:this.plugins.has("lineage")})),this.deprecatedFeatures}createApp(n={}){let e=new Ce(n,this.indices,this.backend,this.gates,this.extensions);return e.index=this._apps.length,this._apps.push(e),e}get apps(){return this._apps}};i(yt,"Sdk");var mt=yt;function Rn(t){return new mt(t)}i(Rn,"createSdk");var ee="Anfra";function Dn(t,n=globalThis){let e=n[ee],r=ee in n;return n[ee]=t,()=>{r?n[ee]=e:delete n[ee]}}i(Dn,"installSandbox");function Tn(t,n=[]){let e=t.document.getElementById(wt);if(!e?.textContent)throw new Error("anfra: this frame was not provisioned by a host.");let r=JSON.parse(e.textContent),o=i(b=>t.parent.postMessage(b,r.hostOrigin),"post"),a=new Map,l=new Map,s=Dt(o,{answer:i(async(b,m,C)=>{let p=a.get(b);if(!p)throw se(`Nothing in this frame answers \'${b}\'.`);return p(m,C)},"answer"),hidden:i((b,m)=>{t.console?.error(`anfra: \'${b}\' failed; the host is told only that the call failed.`,m),$("plugin.uncaught",m)},"hidden"),event:i((b,m)=>{l.get(b)?.forEach(C=>{try{C(m)}catch{}})},"event")}),d=i(b=>b.source===t.parent||!!r.hostOrigin&&r.hostOrigin!=="null"&&b.origin===r.hostOrigin,"fromHost");t.addEventListener("message",b=>{d(b)&&s.receive(b.data)});let u={submitQuery:i((b,m,C)=>s.call("core.submitQuery",b,m,C).then(p=>(p.debug?.executedAt&&(p.debug.executedAt=new Date(p.debug.executedAt)),p)),"submitQuery"),fieldSuggestions:i((b,m)=>s.call("core.fieldSuggestions",b,m),"fieldSuggestions")},f=Rn({datasets:r.datasets,user:r.user,backend:u,plugins:r.plugins??[]}),v=new Set,k=f.createApp.bind(f);f.createApp=b=>{let m=k(b);return v.forEach(C=>{try{C(m)}catch{}}),m};let S={window:t,sdk:f,endpoint:s,handlers:a,listeners:l,appListeners:v},R=we("anfra",S,{Query:Q,Control:N});Tt(R,t,r.captureConsole===!0),Ut(R),$t(we("core",S,{Query:Q,Control:N})),S.contentUi=Ht(R),Yt(R),tn(R,S.contentUi),R.on("theme",b=>{let m=Lt(b);Kt(t.document,m),f.theme.set(m)});let I=new Set,h=!1;R.on("shortcuts",b=>{I=new Set((Array.isArray(b)?b:[]).map(rn).filter(m=>!!m)),!(h||!I.size)&&(h=!0,t.addEventListener("keydown",m=>{if(m.defaultPrevented||m.repeat||on(m.target))return;let C=sn(m);I.has(C)&&(m.preventDefault(),R.emit("shortcut",C))}))});for(let[b,m]of n)if(typeof m=="function")try{m(we(b,S,{Query:Q,Control:N}))}catch(C){t.console?.error(`anfra: plugin \'${b}\' failed to set up:`,C),$("plugin.uncaught",C)}Dn(f,t),o({type:"anfra:ready"})}i(Tn,"bootstrap");return Qn(Wr);})();\n';
|
|
34
34
|
|
|
35
35
|
// anfra-sdk:anfra-sdk:ui
|
|
36
36
|
var anfra_sdk_ui_default = '"use strict";var __anfraBody=(()=>{var R=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var l=(o,t)=>R(o,"name",{value:t,configurable:!0});var V=(o,t)=>{for(var e in t)R(o,e,{get:t[e],enumerable:!0})},Y=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of z(t))!K.call(o,d)&&d!==e&&R(o,d,{get:()=>t[d],enumerable:!(n=H(t,d))||n.enumerable});return o};var _=o=>Y(R({},"__esModule",{value:!0}),o);var ne={};V(ne,{default:()=>oe});var P=`\n[data-severity="critical"] { --dot: var(--anfra-color-danger, oklch(0.501 0.17 27.2)); }\n[data-severity="warning"] { --dot: var(--anfra-color-warning, oklch(0.501 0.1 70.3)); }\n[data-severity="info"] { --dot: var(--anfra-color-accent, oklch(0.484 0.181 298.1)); }\n.dot { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--anfra-color-muted, oklch(0.485 0.022 306.3))); }\n`,B=`\n.note { display: flex; gap: 8px; align-items: baseline; padding: 4px; }\n.note > div { min-width: 0; }\n.label { font-weight: 500; }\n.detail { display: block; color: var(--anfra-color-fg-weak, oklch(0.392 0.021 304.3)); }\n.plugin { display: block; font-size: 11px; color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); }\n`,G=`\n:host { all: initial; }\n* { box-sizing: border-box; }\n/* A part\'s container: over the whole viewport in the top layer, letting the pointer through to the page. */\n.part { position: fixed; inset: 0; width: auto; height: auto; margin: 0; padding: 0; border: 0; overflow: visible; background: none; pointer-events: none; }\n.surface, .backdrop { pointer-events: auto; }\n.surface { position: fixed; z-index: 1; color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); background: var(--anfra-color-bg, oklch(1 0 0));\n border: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); border-radius: calc(var(--anfra-radius, 10px) + 4px); /* a surface: the controls\' radius plus 4px, anfra-design\'s xl */\n box-shadow: 0 8px 24px oklch(0 0 0 / 18%), 0 1px 3px oklch(0 0 0 / 10%); font: 13px/1.45 var(--anfra-font, system-ui, sans-serif); }\n.menu { min-width: 180px; max-width: 320px; padding: 4px; outline: none; }\n.menu button { display: block; width: 100%; padding: 6px 10px; border: 0; border-radius: var(--anfra-radius, 10px); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }\n/* One highlight, as a native menu has: the focused entry, which the pointer and the arrows both move. */\n.menu button:focus { outline: none; background: color-mix(in srgb, var(--anfra-color-accent, oklch(0.484 0.181 298.1)) 14%, transparent); }\n.menu button[aria-disabled="true"] { color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); cursor: default; }\n.menu .reason { display: block; font-size: 11px; color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); }\n.menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); }\n.backdrop { position: fixed; inset: 0; background: oklch(0 0 0 / 40%); }\n.modal { display: flex; flex-direction: column; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }\n.modal.sm { width: 360px; } .modal.md { width: 560px; } .modal.lg { width: 860px; }\n.modal.full { width: calc(100vw - 32px); height: calc(100vh - 32px); }\n.modal header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); }\n.modal h2 { flex: 1; margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.close { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); cursor: pointer; font: 18px/1 var(--anfra-font, system-ui, sans-serif); }\n.close:hover { color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); background: color-mix(in srgb, var(--anfra-color-fg, oklch(0.201 0.022 301.1)) 7%, transparent); }\n.content { flex: 1; min-height: 0; overflow: auto; }\n.popover { max-width: min(360px, calc(100vw - 16px)); outline: none; }\n.popover > .close { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; font-size: 16px; }\n.popover.closable > .content { padding-right: 26px; }\n\n.notes { margin: 0; padding: 4px 6px; list-style: none; }\n${P}\n${B}\n`,C=6,k=8;function D(o){return{width:o.innerWidth,height:o.innerHeight}}l(D,"viewport");function U(o,t,e,n,d){let{width:f,height:r}=D(o),a=e,g=n;return a+t.width>f-k&&(a=d?d.left-t.width:f-k-t.width),g+t.height>r-k&&(g=d?d.top-t.height:r-k-t.height),{left:Math.max(k,a),top:Math.max(k,g)}}l(U,"place");var M={right:"left",left:"right",bottom:"top",top:"bottom"};function q(o,t,e,n){let{width:d,height:f}=D(o),r=l(i=>i==="right"?{left:e.x+e.width+C,top:e.y}:i==="left"?{left:e.x-t.width-C,top:e.y}:i==="bottom"?{left:e.x,top:e.y+e.height+C}:{left:e.x,top:e.y-t.height-C},"at"),a=l(i=>{let{left:c,top:p}=r(i);return i==="right"||i==="left"?c>=k&&c+t.width<=d-k:p>=k&&p+t.height<=f-k},"fits"),g=[n,M[n],...["right","bottom","left","top"].filter(i=>i!==n&&i!==M[n])],{left:m,top:u}=r(g.find(a)??n),b=l((i,c,p)=>Math.max(k,Math.min(i,p-k-c)),"clamp");return{left:b(m,t.width,d),top:b(u,t.height,f)}}l(q,"beside");function O(o){let t=o.ownerDocument,e=t.createElement("div");e.className="part",e.setAttribute("popover","manual");let n=t.createElement("style");return n.textContent=G,e.append(n),o.append(e),e.showPopover?.(),{container:e,remove:l(()=>e.remove(),"remove")}}l(O,"part");function $(o,t){let e=o.createElement("div");return e.className=t,{element:e,root:e.attachShadow({mode:"open"})}}l($,"contentRoot");function W(o,t,e){try{let n=t(e);return typeof n=="function"?n:()=>{}}catch(n){return o.console?.error("anfra: a plugin failed to draw:",n),()=>{}}}l(W,"mountContent");function I(o,t,e){let n=o.createElement("li");n.className="note",t.severity&&(n.dataset.severity=t.severity);let d=o.createElement("span");d.className="dot",t.severity&&(d.title=t.severity);let f=o.createElement("div"),r=o.createElement("span");if(r.className="label",r.textContent=t.label,f.append(r),t.detail){let a=o.createElement("span");a.className="detail",a.textContent=t.detail,f.append(a)}if(e){let a=o.createElement("span");a.className="plugin",a.textContent=t.plugin,f.append(a)}return n.append(d,f),n}l(I,"noteItem");function j(o,t){let e=o.ownerDocument,n=e.defaultView,{container:d,remove:f}=O(o),r=e.createElement("div");r.className="surface menu",r.setAttribute("role","menu");let a=[];if(t.notes?.length){let s=e.createElement("ul");s.className="notes",s.setAttribute("aria-label","Annotations"),t.notes.forEach(v=>s.append(I(e,v,!1))),r.append(s)}t.groups.filter(s=>s.length).forEach((s,v)=>{(v>0||t.notes?.length)&&r.append(e.createElement("hr"));for(let x of s){let w=e.createElement("button");if(w.type="button",w.setAttribute("role","menuitem"),w.dataset.item=x.id,w.textContent=x.label,x.disabled){w.setAttribute("aria-disabled","true"),w.title=x.disabled;let L=e.createElement("span");L.className="reason",L.textContent=x.disabled,w.append(L)}w.addEventListener("click",()=>{x.disabled||(y(),t.onPick(x.id))}),a.push(w),r.append(w)}}),d.append(r);let g=r.getBoundingClientRect(),{left:m,top:u}=U(n,g,t.x,t.y,{left:t.x,top:t.y});r.style.left=`${m}px`,r.style.top=`${u}px`,r.tabIndex=-1,r.focus();let b=a.filter(s=>!s.hasAttribute("aria-disabled"));r.addEventListener("pointermove",s=>{let v=s.composedPath().find(x=>a.includes(x));v&&b.includes(v)?o.activeElement!==v&&v.focus():o.activeElement!==r&&r.focus()}),r.addEventListener("pointerleave",()=>r.focus());let i=l(s=>{if(s.key==="Escape"){s.preventDefault(),y();return}if(s.key!=="ArrowDown"&&s.key!=="ArrowUp"||(s.preventDefault(),!b.length))return;let v=b.indexOf(o.activeElement),x=s.key==="ArrowDown"?1:-1,w=v===-1?x===1?0:b.length-1:(v+x+b.length)%b.length;b[w].focus()},"onKey"),c=l(s=>{s.composedPath().includes(r)||y()},"onOutside"),p=l(()=>y(),"onAway"),E=[[e,"keydown",i,!0],[e,"pointerdown",c,!0],[n,"scroll",p,!0],[n,"resize",p,!1],[n,"blur",p,!1]];E.forEach(([s,v,x,w])=>s.addEventListener(v,x,w));let h=!1;function y(){h||(h=!0,E.forEach(([s,v,x,w])=>s.removeEventListener(v,x,w)),f(),t.onClose())}return l(y,"close"),y}l(j,"menu");function J(o,t){let e=o.ownerDocument,n=e.defaultView,{container:d,remove:f}=O(o),r=e.createElement("div");r.className="backdrop";let a=e.createElement("section");a.className=`surface modal ${t.size??"md"}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true");let g=e.createElement("header"),m=e.createElement("h2");m.id="anfra-modal-title",m.textContent=t.title,a.setAttribute("aria-labelledby",m.id);let u=e.createElement("button");u.type="button",u.className="close",u.setAttribute("aria-label","Close"),u.textContent="\\xD7",u.addEventListener("click",()=>L()),g.append(m,u);let b=$(e,"content");a.append(g,b.element),d.append(r,a);let i=o.host.parentElement,c=n,p=[],E=l(A=>{for(let S of A)!(S instanceof c.Element)||S===i||S.hasAttribute("inert")||(S.setAttribute("inert",""),p.push(S))},"inert");E(e.body.children);let h=new c.MutationObserver(A=>A.forEach(S=>E(S.addedNodes)));h.observe(e.body,{childList:!0});let y=e.documentElement,s={overflow:y.style.overflow,gutter:y.style.getPropertyValue("scrollbar-gutter")};n.innerWidth>y.clientWidth&&y.style.setProperty("scrollbar-gutter","stable"),y.style.overflow="hidden";let v=W(n,t.mount,b.root);u.focus();let x=l(A=>{A.key==="Escape"&&(A.preventDefault(),L())},"onKey");e.addEventListener("keydown",x,!0);let w=!1;function L(){if(!w){w=!0,e.removeEventListener("keydown",x,!0);try{v()}catch{}h.disconnect(),p.forEach(A=>A.removeAttribute("inert")),y.style.overflow=s.overflow,s.gutter?y.style.setProperty("scrollbar-gutter",s.gutter):y.style.removeProperty("scrollbar-gutter"),f(),t.onClose()}}return l(L,"close"),L}l(J,"modal");function Q(o,t){let e=o.ownerDocument,n=e.defaultView,{container:d,remove:f}=O(o),r=e.createElement("section");r.className="surface popover",r.setAttribute("role","dialog"),r.tabIndex=-1;let a=$(e,"content");if(r.append(a.element),t.closeButton!==!1){r.classList.add("closable");let h=e.createElement("button");h.type="button",h.className="close",h.setAttribute("aria-label","Close"),h.textContent="\\xD7",h.addEventListener("click",()=>E()),r.append(h)}d.append(r);let g=W(n,t.mount,a.root);a.root.activeElement||r.focus();let m=!1,u=l(()=>{m=!1;let h=t.anchor();if(!h){E();return}let y=r.getBoundingClientRect(),{left:s,top:v}=q(n,y,h,t.side??"right");r.style.left=`${s}px`,r.style.top=`${v}px`},"position"),b=l(()=>{m||(m=!0,n.requestAnimationFrame(u))},"schedule"),i=!1;if(u(),i)return E;let c=l(h=>{h.key==="Escape"&&(h.preventDefault(),E())},"onKey"),p=l(h=>{h.composedPath().includes(r)||E()},"onOutside");e.addEventListener("keydown",c,!0),n.addEventListener("scroll",b,!0),n.addEventListener("resize",b),t.dismiss==="outside"&&e.addEventListener("pointerdown",p,!0);function E(){if(!i){i=!0,e.removeEventListener("keydown",c,!0),n.removeEventListener("scroll",b,!0),n.removeEventListener("resize",b),e.removeEventListener("pointerdown",p,!0);try{g()}catch{}f(),t.onClose()}}return l(E,"close"),E}l(Q,"popover");var X=`\n:host { all: initial; }\n.badges { position: fixed; inset: 0; pointer-events: none; }\n.badge { position: fixed; display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; pointer-events: auto; cursor: pointer;\n color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); background: var(--anfra-color-bg, oklch(1 0 0));\n border: 1px solid var(--anfra-color-border-strong, oklch(0.201 0.022 301.1 / 0.24)); border-radius: 9999px;\n font: 500 11px/1 var(--anfra-font, system-ui, sans-serif); font-variant-numeric: tabular-nums; }\n.badge:hover { background: var(--anfra-color-hover, oklch(0.201 0.022 301.1 / 0.05)); }\n.badge:focus-visible { outline: 2px solid var(--anfra-color-accent, oklch(0.484 0.181 298.1)); outline-offset: 1px; }\n.badge[hidden] { display: none; }\n${P}\n`,T=6,N=new WeakMap;function Z(o,t){if(N.get(o)?.(),N.delete(o),o.replaceChildren(),!t.length)return;let e=o.ownerDocument,n=e.defaultView,d=n,f=e.createElement("style");f.textContent=X;let r=e.createElement("div");r.className="badges";let a=t.map(i=>{let c=e.createElement("button");c.type="button",c.className="badge",c.dataset.for=i.id,i.severity&&(c.dataset.severity=i.severity),c.setAttribute("aria-label",i.label),c.title=i.label;let p=e.createElement("span");p.className="dot",p.setAttribute("aria-hidden","true"),c.append(p,String(i.count));let E=l(()=>{if(!c.isConnected)return;let{x:h,y,width:s,height:v}=c.getBoundingClientRect();return{x:h,y,width:s,height:v}},"anchor");return c.addEventListener("click",()=>i.onOpen(E)),r.append(c),{badge:i,button:c}});o.append(f,r);let g=!1,m=l(()=>{g=!1;for(let{badge:i,button:c}of a){let p=i.element.isConnected?i.element.getBoundingClientRect():void 0;if(c.hidden=!p||p.width===0&&p.height===0,!p||c.hidden)continue;let E=c.getBoundingClientRect().width;c.style.left=`${p.x+p.width-E-T}px`,c.style.top=`${p.y+T}px`}},"position"),u=l(()=>{g||(g=!0,n.requestAnimationFrame(m))},"schedule");m(),n.addEventListener("scroll",u,!0),n.addEventListener("resize",u);let b=typeof d.ResizeObserver=="function"?new d.ResizeObserver(u):void 0;a.forEach(({badge:i})=>b?.observe(i.element)),N.set(o,()=>{n.removeEventListener("scroll",u,!0),n.removeEventListener("resize",u),b?.disconnect()})}l(Z,"badges");var F=`\n:host { display: block; width: 300px; max-width: 100%; font: 13px/1.45 var(--anfra-font, system-ui, sans-serif); color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); }\nul { margin: 0; padding: 8px; list-style: none; max-height: 60vh; overflow: auto; }\nli + li { border-top: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); }\n.note { padding: 6px 4px; }\n.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }\n.actions button { padding: 2px 8px; border: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); border-radius: var(--anfra-radius, 10px);\n background: none; color: inherit; font: inherit; font-size: 12px; cursor: pointer; }\n.actions button:hover { background: var(--anfra-color-hover, oklch(0.201 0.022 301.1 / 0.05)); }\n.actions button[aria-disabled="true"] { color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); cursor: default; }\n${B}\n${P}\n`;function ee(o,t,e){let n=o.ownerDocument,d=n.createElement("style");d.textContent=F;let f=n.createElement("ul");f.setAttribute("aria-label","Annotations");for(let r of t){let a=I(n,r,!0);if(r.actions.length){let g=n.createElement("div");g.className="actions";for(let m of r.actions){let u=n.createElement("button");u.type="button",u.textContent=m.label,m.disabled&&(u.setAttribute("aria-disabled","true"),u.title=m.disabled),u.addEventListener("click",()=>{m.disabled||e(m)}),g.append(u)}a.lastElementChild.append(g)}f.append(a)}o.replaceChildren(d,f)}l(ee,"annotationList");var te={menu:j,modal:J,popover:Q,badges:Z,annotationList:ee},oe=te;return _(ne);})();\n';
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
} from "./chunk-HA3ZB3LG.js";
|
|
9
9
|
import {
|
|
10
10
|
PLUGIN_VERSION
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XF2OX24G.js";
|
|
12
12
|
import {
|
|
13
13
|
follow,
|
|
14
14
|
isCurrent,
|
|
15
15
|
queryOf,
|
|
16
16
|
stateOf
|
|
17
17
|
} from "./chunk-XREEBDSR.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-FWP6LU4D.js";
|
|
19
19
|
import "./chunk-GPBYPSWK.js";
|
|
20
20
|
import "./chunk-HELL45MM.js";
|
|
21
21
|
import {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as InspectedApp, W as InspectedStructure, a3 as LocateTarget, aC as User, D as DatasetDescriptor, ai as QueryStamp } from './types-
|
|
2
|
-
import { d as MenuTargetKind, c as MenuTarget, e as PluginInfo, i as Theme } from './theme-
|
|
1
|
+
import { R as InspectedApp, W as InspectedStructure, a3 as LocateTarget, aC as User, D as DatasetDescriptor, ai as QueryStamp } from './types-ks7G6AVA.js';
|
|
2
|
+
import { d as MenuTargetKind, c as MenuTarget, e as PluginInfo, i as Theme } from './theme-CIkvL5kZ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The panel: one per mounted Data App, the host's devtools over it. The runtime owns its state (open
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Backend } from './app.js';
|
|
2
2
|
import { Plugin } from './host.js';
|
|
3
|
-
import './theme-
|
|
3
|
+
import './theme-CIkvL5kZ.js';
|
|
4
4
|
|
|
5
5
|
/** What `core` answers with: a Backend's two required methods, `coreApiBackend` on any host. */
|
|
6
6
|
type CoreBackend = Pick<Backend, 'submitQuery' | 'fieldSuggestions'>;
|
package/dist/plugins.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLUGIN_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XF2OX24G.js";
|
|
4
4
|
import {
|
|
5
5
|
dropState as dropState2,
|
|
6
6
|
stateOf as stateOf2
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
definePlugin
|
|
10
10
|
} from "./chunk-7K6Z63QO.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-FWP6LU4D.js";
|
|
12
12
|
import "./chunk-GPBYPSWK.js";
|
|
13
13
|
import {
|
|
14
14
|
invalidRequest
|
|
@@ -157,9 +157,15 @@ function pictureFilename(filename, ext) {
|
|
|
157
157
|
const name = (typeof filename === "string" ? filename : "").replace(/[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, "").replace(/[\\/:*?"<>|]/g, "-").trim().replace(/^[.\s]+|[.\s]+$/g, "").slice(0, 200) || "Rendering";
|
|
158
158
|
return name.toLowerCase().endsWith(`.${ext}`) ? name : `${name}.${ext}`;
|
|
159
159
|
}
|
|
160
|
+
function isBlob(value) {
|
|
161
|
+
if (value instanceof Blob) return true;
|
|
162
|
+
const tag = Object.prototype.toString.call(value);
|
|
163
|
+
return tag === "[object Blob]" || tag === "[object File]";
|
|
164
|
+
}
|
|
160
165
|
async function saveBlob(doc, request) {
|
|
161
|
-
const
|
|
162
|
-
if (!(
|
|
166
|
+
const sent = request?.blob;
|
|
167
|
+
if (!isBlob(sent)) throw invalidRequest("A rendering must be saved as a file.");
|
|
168
|
+
const blob = sent instanceof Blob ? sent : new Blob([sent]);
|
|
163
169
|
const head = new Uint8Array(await blob.slice(0, 8).arrayBuffer());
|
|
164
170
|
const picture = PICTURES.find(({ signature }) => signature.every((byte, i) => head[i] === byte));
|
|
165
171
|
if (!picture) throw invalidRequest("Only a PNG or a PDF rendering can be saved.");
|
|
@@ -293,7 +299,7 @@ function inspectPlugin() {
|
|
|
293
299
|
run: { panel: "reveal" }
|
|
294
300
|
}],
|
|
295
301
|
tabs: [
|
|
296
|
-
tab("overview", "Overview", "overview", 10, () => import("./overview-
|
|
302
|
+
tab("overview", "Overview", "overview", 10, () => import("./overview-EQPGLWMO.js")),
|
|
297
303
|
tab("data", "Data", "table", 20, () => import("./data-G6DCTXTJ.js")),
|
|
298
304
|
tab("queries", "Queries", "query", 30, () => import("./queries-77M6ZM74.js")),
|
|
299
305
|
tab("structure", "Structure", "tree", 40, () => import("./structure-RX5MANTK.js"), "pick"),
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginInfo } from './app.js';
|
|
2
2
|
import { User, DatasetDescriptor } from './app.js';
|
|
3
3
|
import { Sdk, PluginSetup } from './app.js';
|
|
4
|
-
import './errors-
|
|
4
|
+
import './errors-x9pGAmXi.js';
|
|
5
5
|
|
|
6
6
|
/** The reader a test frame is provisioned with unless given. */
|
|
7
7
|
declare const TEST_READER: User;
|
package/dist/testing.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bootstrap
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WCRSI7ZB.js";
|
|
4
4
|
import "./chunk-XIUFHRZE.js";
|
|
5
5
|
import "./chunk-4UEESYHH.js";
|
|
6
6
|
import {
|
|
7
7
|
PROVISION_ELEMENT_ID
|
|
8
8
|
} from "./chunk-RXPNL7UR.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-FWP6LU4D.js";
|
|
10
10
|
import {
|
|
11
11
|
createEndpoint
|
|
12
12
|
} from "./chunk-GPBYPSWK.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ai as QueryStamp, D as DatasetDescriptor, aC as User, aq as Row, av as SelectionCondition, aA as StructureNode, a as Annotation } from './types-
|
|
1
|
+
import { ai as QueryStamp, D as DatasetDescriptor, aC as User, aq as Row, av as SelectionCondition, aA as StructureNode, a as Annotation } from './types-ks7G6AVA.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The bridge: the postMessage protocol between a Data App's frame (`app`'s bootstrap) and the
|
|
@@ -193,7 +193,9 @@ interface paths {
|
|
|
193
193
|
* Show the repo's datasets, or one dataset, with their models, fields, and metrics
|
|
194
194
|
* @description Show the repo's datasets, or one dataset, with their models, fields, and metrics, as AQL can query them.
|
|
195
195
|
*
|
|
196
|
-
* With no fqn, it shows the repo and every dataset in full, and with a dataset's fqn, that dataset in full. It shows names, labels, types, roles, @tags,
|
|
196
|
+
* With no fqn, it shows the repo and every dataset in full, and with a dataset's fqn, that dataset in full. It shows names, labels, types, roles, @tags, AQL definitions, and the file that defines each dataset, never SQL or tables. At the index detail, it shows only each dataset's fqn, name, and the file that defines it, and the repo's models too, which is quicker when you only need to find where something is defined.
|
|
197
|
+
*
|
|
198
|
+
* Problems that affect the result come with it as diagnostics, such as a file that doesn't compile, or a data source the repo doesn't configure.
|
|
197
199
|
*/
|
|
198
200
|
post: operations["core.show"];
|
|
199
201
|
delete?: never;
|
|
@@ -1193,12 +1195,14 @@ interface components {
|
|
|
1193
1195
|
*/
|
|
1194
1196
|
kind: "dataset";
|
|
1195
1197
|
label?: string;
|
|
1196
|
-
/** @description
|
|
1198
|
+
/** @description where it's defined */
|
|
1199
|
+
location?: components["schemas"]["ShowLocation"];
|
|
1200
|
+
/** @description the dataset's metrics. Absent when the dataset is shown in outline, or at the index detail. */
|
|
1197
1201
|
metrics?: components["schemas"]["ShowField"][];
|
|
1198
|
-
/** @description the models the dataset uses. Absent when the dataset is shown in outline. */
|
|
1202
|
+
/** @description the models the dataset uses. Absent when the dataset is shown in outline, or at the index detail. */
|
|
1199
1203
|
models?: components["schemas"]["ShowModel"][];
|
|
1200
1204
|
name: string;
|
|
1201
|
-
/** @description the relationships between its models. Absent if the dataset failed to load. */
|
|
1205
|
+
/** @description the relationships between its models. Absent if the dataset failed to load, or at the index detail. */
|
|
1202
1206
|
relationships?: components["schemas"]["ShowRelationship"][];
|
|
1203
1207
|
/** @description its @tags, in the order the AML writes them. Absent when it has none. */
|
|
1204
1208
|
tags?: components["schemas"]["ShowTag"][];
|
|
@@ -1224,7 +1228,21 @@ interface components {
|
|
|
1224
1228
|
/** @description the field's semantic type, such as number, text, date, datetime, or truefalse */
|
|
1225
1229
|
type: string;
|
|
1226
1230
|
};
|
|
1231
|
+
ShowIndexEntry: {
|
|
1232
|
+
/** @description its fully qualified name */
|
|
1233
|
+
fqn: string;
|
|
1234
|
+
/** @enum {string} */
|
|
1235
|
+
kind: "model";
|
|
1236
|
+
location: components["schemas"]["ShowLocation"];
|
|
1237
|
+
name: string;
|
|
1238
|
+
};
|
|
1227
1239
|
ShowInput: {
|
|
1240
|
+
/**
|
|
1241
|
+
* @description how much to show of each object. "full": a dataset's models, fields and metrics. "index": only its fqn, name and the file that defines it, and for the repo, its models too.
|
|
1242
|
+
* @default full
|
|
1243
|
+
* @enum {string}
|
|
1244
|
+
*/
|
|
1245
|
+
detail?: "full" | "index";
|
|
1228
1246
|
/** @description the fqn of the dataset to show, the whole repo by default */
|
|
1229
1247
|
fqn?: string;
|
|
1230
1248
|
/**
|
|
@@ -1234,6 +1252,10 @@ interface components {
|
|
|
1234
1252
|
*/
|
|
1235
1253
|
type?: "aml.dataset";
|
|
1236
1254
|
};
|
|
1255
|
+
ShowLocation: {
|
|
1256
|
+
/** @description the file that defines it, relative to the repo's root, such as models/orders.model.aml */
|
|
1257
|
+
file: string;
|
|
1258
|
+
};
|
|
1237
1259
|
ShowModel: {
|
|
1238
1260
|
description?: string;
|
|
1239
1261
|
fields: components["schemas"]["ShowField"][];
|
|
@@ -1265,13 +1287,15 @@ interface components {
|
|
|
1265
1287
|
type: "one_to_one" | "many_to_one" | "range" | "many_to_many";
|
|
1266
1288
|
};
|
|
1267
1289
|
ShowRepo: {
|
|
1268
|
-
/** @description the repo's datasets, each in full, or in outline (without its models and metrics) when the dataset can't be shown in full. A diagnostic then says why. */
|
|
1290
|
+
/** @description the repo's datasets, each in full, or in outline (without its models and metrics) when the dataset can't be shown in full. A diagnostic then says why. At the index detail, each has only its kind, fqn, name and location. */
|
|
1269
1291
|
datasets: components["schemas"]["ShowDataset"][];
|
|
1270
1292
|
/**
|
|
1271
1293
|
* @description discriminator enum property added by openapi-typescript
|
|
1272
1294
|
* @enum {string}
|
|
1273
1295
|
*/
|
|
1274
1296
|
kind: "repo";
|
|
1297
|
+
/** @description the repo's models, each with its fqn, name and location, sorted by fqn. Only at the index detail. */
|
|
1298
|
+
models?: components["schemas"]["ShowIndexEntry"][];
|
|
1275
1299
|
};
|
|
1276
1300
|
ShowResult: {
|
|
1277
1301
|
/** @description the problems in the repo that affect what is shown, such as files that don't compile, a dataset's data source that isn't configured, or a dataset that can't be shown in full. Empty when what is shown is complete. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holistics/anfra-sdk",
|
|
3
|
-
"version": "0.25.0-rc.
|
|
3
|
+
"version": "0.25.0-rc.2",
|
|
4
4
|
"description": "Data Apps on anfra: the authoring layer (app), what hosts one (host), anfra's plugins (plugins), the core API client (api), and their shared contract (common)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"./ambient": {
|
|
42
42
|
"types": "./dist/ambient.d.ts"
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"./declaration.js": "./dist/declaration.js"
|
|
44
45
|
},
|
|
45
46
|
"files": [
|
|
46
47
|
"dist",
|
|
@@ -52,7 +53,8 @@
|
|
|
52
53
|
"@holistics:registry": "https://registry.npmjs.org/"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
|
-
"build": "tsup && node scripts/ambient.mjs",
|
|
56
|
+
"build": "tsup && node scripts/ambient.mjs && pnpm run build:declaration",
|
|
57
|
+
"build:declaration": "node scripts/declaration.mjs",
|
|
56
58
|
"test": "TZ=\"Asia/Kuala_Lumpur\" vitest run",
|
|
57
59
|
"test:watch": "TZ=\"Asia/Kuala_Lumpur\" vitest watch",
|
|
58
60
|
"typecheck": "tsc --noEmit",
|