@bicharts/shape-core 0.6.124 → 0.6.125
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/{chunk-O6HX7LOP.mjs → chunk-7RZY5KDP.mjs} +1 -1
- package/dist/chunk-XLROYZFH.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/indexedText.mjs +1 -1
- package/dist/ingest.mjs +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/indexedText.d.ts +4 -1
- package/dist/types/vocab/chartNames.d.ts +15 -0
- package/package.json +1 -1
- package/dist/chunk-J5EZ7BH7.mjs +0 -2
package/dist/indexedText.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{R as a,S as b,T as c,U as d,V as e,W as f,X as g,Y as h,Z as i}from"./chunk-
|
|
2
|
+
import{R as a,S as b,T as c,U as d,V as e,W as f,X as g,Y as h,Z as i}from"./chunk-XLROYZFH.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{i as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as promotesToMeasure,h as trimmedCells};
|
package/dist/ingest.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{c as a,d as b,e as c}from"./chunk-
|
|
2
|
+
import{c as a,d as b,e as c}from"./chunk-7RZY5KDP.mjs";import"./chunk-XLROYZFH.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export { DATE_LEVEL_NAMES, DATE_LEVEL_LANGUAGES, DATE_LEVEL_NON_GREGORIAN_LANGUA
|
|
|
39
39
|
export type { DateLevelPart, DateLevelEntry } from "./vocab/dateLevels";
|
|
40
40
|
export { YEAR_WORDS, CYCLE_WORDS, CYCLE_MEMBERS, calendarWordIn, localizedYearWordIn, localizedCycleIn, } from "./vocab/calendarWords";
|
|
41
41
|
export type { CycleConcept, CalendarWordHit } from "./vocab/calendarWords";
|
|
42
|
+
export { CHART_NAME_LANGUAGES, LOCALIZED_CHART_NAMES, foldChartName, localizedChartName, localizedChartNames, chartNameFromLocalized, } from "./vocab/chartNames";
|
|
42
43
|
export { LATITUDE_WORDS, LONGITUDE_WORDS, coordinateAxisOfWords } from "./vocab/coordinates";
|
|
43
44
|
export { PERIOD_CODE_FORMS, PERIOD_ORDINALS, PERIOD_UNFOLDED, PERIOD_CODE_MEMBERS, readPeriodCode, periodCodeSeries, } from "./vocab/periodCodes";
|
|
44
45
|
export type { PeriodCodeGrain, PeriodCodeForms, PeriodCodeReading, PeriodCodeSeries } from "./vocab/periodCodes";
|
|
@@ -146,6 +146,8 @@ export declare class IndexedText implements IValueCollection {
|
|
|
146
146
|
private _generationColumnsSig;
|
|
147
147
|
private _declaredDimensions;
|
|
148
148
|
private _inferredMeasureFlags;
|
|
149
|
+
private _preStatsFields;
|
|
150
|
+
private _statsAddedKeys;
|
|
149
151
|
/**
|
|
150
152
|
* Collapse value-identical rows on addRow. DEFAULT TRUE — the long-standing behaviour,
|
|
151
153
|
* and the right one for shape measurement. See addRow for when to turn it off.
|
|
@@ -294,7 +296,8 @@ export declare class IndexedText implements IValueCollection {
|
|
|
294
296
|
/**
|
|
295
297
|
* Forget the computed column statistics, keeping the rows, so the next getColumnsWithStats measures again. For a host
|
|
296
298
|
* whose profile changed inputs after the first measurement - the admin-1 lookup arrived, or the reader toggled
|
|
297
|
-
* deriveProvinces - without re-adding every row.
|
|
299
|
+
* deriveProvinces - without re-adding every row. addRow calls it for every row it keeps: a profile taken before the
|
|
300
|
+
* last rows arrived describes a table that no longer exists.
|
|
298
301
|
*/
|
|
299
302
|
invalidateStats(): void;
|
|
300
303
|
reset(): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The languages of the table, in its order. */
|
|
2
|
+
export declare const CHART_NAME_LANGUAGES: readonly string[];
|
|
3
|
+
export declare const LOCALIZED_CHART_NAMES: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
4
|
+
/** The fold a typed name and a table name are compared in: lower case, Latin/Greek/Cyrillic accents removed,
|
|
5
|
+
* whitespace collapsed. */
|
|
6
|
+
export declare function foldChartName(s: string): string;
|
|
7
|
+
/** A chart type's name in `lang`, or undefined when the type or the language has none. */
|
|
8
|
+
export declare function localizedChartName(englishName: string, lang: string): string | undefined;
|
|
9
|
+
/** Every language's name for a chart type (empty for an unknown type). */
|
|
10
|
+
export declare function localizedChartNames(englishName: string): ReadonlyArray<{
|
|
11
|
+
lang: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** The catalogue's English name for a chart type named in any of the table's languages, or undefined. */
|
|
15
|
+
export declare function chartNameFromLocalized(text: string): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.125",
|
|
4
4
|
"description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
package/dist/chunk-J5EZ7BH7.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a as be}from"./chunk-U3H6UBOO.mjs";import{a as xt,f as ee,g as Se,h as se,i as _e,j as re}from"./chunk-TZ74QIKA.mjs";import{b as bt,c as St,d as _t,e as At,f as Ct}from"./chunk-YDYFP2T4.mjs";import{c as pt,l as ht,n as he,p as yt,s as ie,w as ye,x as ke,y as De,z as Oe}from"./chunk-DTBXJVUG.mjs";import{e as ct,k as ge,m as ft,n as gt,o as pe}from"./chunk-3ZAS32F5.mjs";import{b as dt,d as mt}from"./chunk-5HI6TVMM.mjs";import{A as fe,B as lt,E as ut,a as ne,b as J,c as Qe,d as de,g as Je,h as et,j as tt,l as nt,m as rt,o as it,p as me,q as st,r as ot,u as Ee,w as at}from"./chunk-CZJ7M6A5.mjs";import{c as Ze,f as Ne}from"./chunk-WC4JINEZ.mjs";var fn=85,gn=60,pn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Pe=t=>Math.round(t*10)/10,Ae=t=>t.split("-")[0];function wt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=he(a);l&&(e.set(l,(e.get(l)||0)+s),n+=s)}),n===0)return{};let[i,r]=[...e].sort((s,a)=>a[1]-s[1])[0];return{dominantRegion:i,dominantRegionPct:Pe(100*r/n)}}function wi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Mt(e,t.provinceKind,t.country);if(!ie())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let i=ye(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return i.status==="resolved"?i.provinceId:null}function Mt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let s=Ct(t,e);return s?"US-"+s:null}if(!ie())return null;if(e==="admin1-code")return Oe(t)?t.toUpperCase():null;let i=n==null?null:String(n),r=new Set(ke(t,i).map(De).filter(s=>!!s));return r.size===1?[...r][0]:null}function Mi(t,e={}){let n=e.deriveProvinces!==!1,i=new Array(t.length),r=new Array(t.length),s=new Set,a=[],l=new Set,o=[],u=0,d=0,f=0,c=A=>{let S=A.toLowerCase();s.has(S)||(s.add(S),a.push(A))},h=A=>A==null||A===""?null:Number(A),x=new Map;return t.forEach((A,S)=>{i[S]=null,r[S]=null;let p=A.country===null||A.country===void 0||String(A.country).trim()===""?null:String(A.country).trim(),y=A.province===null||A.province===void 0?"":String(A.province).trim();if(y){let _=Mt(y,e.provinceKind,p);_?(i[S]=_,r[S]="province",u++):c(y);return}if(!n)return;let C=h(A.lat),g=h(A.lon),w=!1;if(e.locate&&C!==null&&g!==null&&isFinite(C)&&isFinite(g)){w=!0;let _=e.locate(C,g);if(_){i[S]=_,r[S]="coordinates",u++;return}}let b=A.city===null||A.city===void 0?"":String(A.city).trim();if(b&&ie()){let _=b.toLowerCase()+""+(p??""),M=x.get(_);if(M||(M=ye(b,{country:p}),x.set(_,M)),M.status==="resolved"&&M.provinceId){i[S]=M.provinceId,r[S]="city",u++;return}if(M.status==="ambiguous"){d++,l.has(_)||(l.add(_),o.length<8&&o.push(b));return}c(b);return}w&&f++}),{iso:i,source:r,unmatched:a,matchedRows:u,totalRows:t.length,ambiguousRows:d,ambiguousExamples:o,unplacedPoints:f}}function Tt(t,e,n={}){let i=new Map;if(!ie()||e.length===0)return i;let r=t.findIndex(l=>!l.isMeasure&&(l.geoKind||"").startsWith("country")),s=l=>l==null?"":String(l).trim(),a=l=>{let o=new Map;for(let h of e){let x=s(h[l]);if(!x)continue;let A=r>=0&&s(h[r])||null,S=x+""+(A??""),p=o.get(S);p?p.rows++:o.set(S,{city:x,country:A,rows:1})}if(o.size===0)return null;let u=0,d=0,f=new Set,c=new Map;return o.forEach(h=>{let x=ye(h.city,{country:h.country});x.status!=="unmatched"&&d++,!(x.status!=="resolved"||!x.provinceId)&&(u++,f.add(x.provinceId),c.set(x.cc,(c.get(x.cc)||0)+h.rows))}),{signals:{rollupPct:Pe(100*u/o.size),regionCount:f.size,countryCount:c.size,...wt(c)},cityPct:100*d/o.size,distinct:o.size}};return t.forEach((l,o)=>{if(l.isMeasure||o===r)return;let u=l.geoKind||"";if(u.startsWith("city")){if(n.cities===!1)return;let _=a(o);_&&i.set(o,_.signals);return}if(u)return;let d=new Map,f=new Map;for(let _ of e){let M=s(_[o]);M&&(d.set(M,(d.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&s(_[r])||null))}if(d.size<3)return;let c=0,h=0,x=0,A=new Set,S=new Map;d.forEach((_,M)=>{if(Oe(M)){c++;let z=M.toUpperCase();A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_);return}let W=new Set(ke(M,f.get(M)).map(De).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_)}else W.size>1&&x++});let y=pn.test(l.name.replace(/[_-]+/g," "))?gn:fn,C=100*c/d.size,g=100*h/d.size,w=C>=g,b=w?C:g;if(b<y){if(n.cities===!1)return;let _=a(o);if(!_||_.cityPct<pt||_.distinct<_t&&!St(l.name,bt))return;i.set(o,_.signals);return}i.set(o,{kind:w?"admin1-code":"admin1-name",matchPct:Pe(b),ambiguous:!w&&x/d.size>.15?!0:void 0,regionCount:A.size,countryCount:S.size,...wt(S)})}),i}function ze(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Le={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},hn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,yn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,bn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,Sn=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,_n=new Set(["de","del","of"]),An=new Set(["\u0433","\u0440","r"]),Cn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,Fe=/^\d+$/;function xn(t){let e=+t[1],n=+t[2],i=t[3]===void 0?0:+t[3],r=t[4]!==void 0;if(n>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s:i,seconds:t[3]!==void 0,meridiem:r}}function vt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=xt(e);let n=null,i=hn.exec(e);if(i){if(n=xn(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=bn.exec(e)){let c=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Le,form:"cjk",key:c,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=yn.exec(e)){let c=r[2],h=r[4];if(c!==h)return null;let x=c.trim(),A=r[6];if(A&&x!==".")return null;let S=[r[1].length,r[3].length,r[5].length],p=S[0]===4,y=S[2]===4;return p===y||(p?S[1]>2||S[2]>2:S[0]>2||S[1]>2)?null:p&&x==="-"&&c==="-"&&S[1]===2&&S[2]===2?"iso":p&&x==="."&&c==="."&&!A&&!(S[1]===2&&S[2]===2)?null:{...Le,form:"numeric",key:`num|${p?"y":"x"}|${c}|${A}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:p,sep:c,trail:A}}let s=e.replace(Sn,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!_n.has(c.toLowerCase()));if(s.length===4&&Fe.test(s[2])&&An.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(c=>Fe.test(c)?"N":Cn.test(c)?"W":"?").join(""),l=s.map(c=>Fe.test(c)?c:""),o=0,u=0,d="",f;if(a==="NWN"&&l[0].length<=2&&l[2].length===4)o=+l[0],d=s[1],u=+l[2],f="dmy";else if(a==="WNN"&&l[1].length<=2&&l[2].length===4)d=s[0],o=+l[1],u=+l[2],f="mdy";else if(a==="NWN"&&l[0].length===4&&l[2].length<=2)u=+l[0],d=s[1],o=+l[2],f="ymd";else return null;return{...Le,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:d,namedOrder:f}}var wn=[31,28,31,30,31,30,31,31,30,31,30,31],Mn=t=>t%4===0&&t%100!==0||t%400===0;function Rt(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&Mn(t)?29:wn[e-1]):!1}function Tn(t,e,n,i){let r=new Date(Date.UTC(2e3,e-1,n,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(t),r}function It(t,e={}){let n=(e.floor??1)>=1,i=new Map,r=new Map,s=0,a=null;for(let p of t){if(p==null)continue;if(typeof p!="string"){if(n)return null;s++;continue}let y=p.trim();if(y==="")continue;s++;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"){if(n)return null;continue}if(n){if(a===null)a=C;else if(C.key!==a.key)return null}else r.set(C.key,(r.get(C.key)??0)+1)}if(!n){let p=0,y="";for(let[C,g]of r)g>p&&(p=g,y=C);if(p===0||p/s<e.floor)return null;a=[...i.values()].find(C=>C!==null&&C!=="iso"&&C.key===y)??null}if(a===null)return null;let l=a.key,o=[...i.values()].filter(p=>p!==null&&p!=="iso"&&p.key===l),u,d="shape",f=null;if(a.form==="named"){if(u=a.namedOrder,f=_e(o.map(p=>p.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)u="ymd";else{let p=0,y=0;for(let C of o)C.a>12&&p++,C.b>12&&y++;if(p>0&&y>0)return null;p>0?(u="dmy",d="values"):y>0?(u="mdy",d="values"):a.sep.trim()==="."?(u="dmy",d="shape"):(u=ze(e.locale)?"mdy":"dmy",d="locale")}let c=p=>{if(p.form==="named"){let y=f.get(ee(p.word));return y===void 0?null:[p.year,y+1,p.day]}return p.yearFirst?[p.a,p.b,p.c]:u==="dmy"?[p.c,p.b,p.a]:[p.c,p.a,p.b]},h=1/0,x=-1/0,A=0;for(let p of o){let y=c(p);if(!y||!Rt(y[0],y[1],y[2])){if(n)return null;A++;continue}h=Math.min(h,y[0]),x=Math.max(x,y[0])}if(!n&&(r.get(l)-A)/s<e.floor||h>=2400&&x<=2699||h>=1300&&x<=1500)return null;let S={form:a.form,order:u,orderFrom:d,hasTime:o.some(p=>p.clock!==null),read(p){if(typeof p!="string")return null;let y=p.trim();if(y==="")return null;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"||C.key!==l)return null;let g=c(C);return!g||!Rt(g[0],g[1],g[2])?null:Tn(g[0],g[1],g[2],C.clock)}};if(a.form!=="named"&&!o.some(p=>p.clock?.meridiem)){let p;a.form==="cjk"?p=a.cjkPattern:a.yearFirst?p=`%Y${a.sep}%m${a.sep}%d${a.trail}`:p=(u==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let y=o.filter(C=>C.clock!==null).length;y===0?S.pattern=p:y===o.length&&(S.pattern=p+(o.every(C=>C.clock.seconds)?" %H:%M:%S":" %H:%M"))}return S}import on from"papaparse";var vn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},Rn={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},We=t=>ne(t.normalize("NFC")).toLowerCase(),In=new Set(Object.values(vn).flatMap(t=>(t??[]).map(We))),Nn=new Set(Object.values(Rn).flatMap(t=>(t??[]).map(We)));function Nt(t){let e=!1,n=!1;for(let i of t){let r=We(i);In.has(r)?e=!0:Nn.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var En=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","capita","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],kn=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],Dn=["latitude","longitude"],On=["latitude","longitude"];function Z(t){return ne(t)}var Dt=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],Pn=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Ln=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Fn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],Ce=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function $e(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ot=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+$e(Dt)+")\\s+)","i");function Et(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var zn="[\u2013\u2014-]";function Pt(t){let e=t.filter(r=>!Et(r)),n=t.filter(Et),i=[];return e.length&&i.push("(?:\\s+|\\s*"+zn+"\\s*)("+$e(e)+")"),n.length&&i.push("\\s*("+$e(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Be=Pt(Ln),Wn=Pt(Fn);function xe(t,e){let n=e.exec(t);if(!n)return null;let i=t.slice(0,n.index);return i.trim()===""?null:{base:i,label:(n[1]??n[2]??"").toLowerCase()}}function Lt(t){let e=Z(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of Pn)if(e.startsWith(r+" "))return Ce[r]??"avg";for(let r of Dt)if(e.startsWith(r+" ")||e===r)return Ce[r]??"sum";let n=xe(e,Wn);if(n)return Ce[n.label]??"avg";let i=xe(e,Be);return i?Ce[i.label]??"sum":null}var $n=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Bn=new RegExp("\\b("+En.join("|")+")\\b|("+kn.join("|")+")$","i"),Gn=new RegExp("\\b("+Dn.join("|")+")\\b|("+On.join("|")+")$","i");function Me(t){if(!t)return"";let e=String(t),n=Z(e),i=Ot.exec(n);if(i)return e.slice(i[0].length).trim();let r=xe(n,Be);return(r?e.slice(0,r.base.length):e).trim()}function Vn(t){if(!t)return!1;let e=Z(String(t));return Ot.test(e)||xe(e,Be)!==null}var Kn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],kt=new RegExp("^\\s*("+[...Kn].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ge(t){if(t==null)return"";let e=String(t),n=kt.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),s=e.slice(n[0].length),a=0;for(;a<8;){let l=kt.exec(s);if(!l||i(l[1])!==r)break;let o=s.slice(l[0].length);if(o.trim()==="")break;s=o,a++}return a===0?e:e.slice(0,n[0].length)+s}function Ve(t,e){if(!t||!e)return!1;let n=String(t);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&n.includes(r))return!0}return!1}var we={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},Ft=new RegExp("^("+Object.keys(we).join("|")+")\\((.+)\\)$");function zt(t){if(!t)return[];let e=Ft.exec(String(t).trim());if(!e)return[];let n=we[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let a=i.slice(s+1);if(a.trim()!=="")for(let l of n){let o=l+a;r.includes(o)||r.push(o)}}return r}function Wt(t,e,n){let i=Ft.exec(String(t??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&n==="Decimal")return!0;let s=new Set(we[r]),a=String(e??""),l=i[2];for(let o=l.indexOf(".");o>=0;o=l.indexOf(".",o+1)){if(o===0)continue;let u=l.slice(o+1);if(u.trim()!==""){for(let d of Object.values(we))for(let f of d)if(!s.has(f)&&a===f+u)return!0}}return!1}function Un(t){let e=Me(t);return e.length===0?"":e.replace($n," ")}function $t(t,e){if(!e)return!1;let n=Me(e);return t.test(Z(Un(e)))||t.test(Z(n))||t.test(Z(J(n).join(" ")))}function Bt(t){return $t(Gn,t)}function Hn(t){return $t(Bn,t)||Bt(t)}var Gt=/int|double|decimal|single|float|number|currency|money/i;function Yn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Gt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function jn(t){return t?.isMeasure===!0||Gt.test(String(t?.dataType??""))}function Vt(t){let e=t??{},n=Yn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Bt(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Vn(e.name))){if(i==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:n,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:n,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Hn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Kt(t){let e=Vt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return jn(n)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Oi(t){return Kt(t)[0]}function Pi(t,e){return Kt(t).indexOf(e)>=0}function Li(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Vt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var Xn={de:["nr","nummer","kennung","kennziffer","plz","postleitzahl"],nl:["nr","nummer"],sv:["nr","nummer"],da:["nr","nummer"],nb:["nr","nummer"],fi:["tunnus","koodi","nro"],hu:["azonos\xEDt\xF3","k\xF3d"],tr:["kod","kodu","numaras\u0131","numarasi"],zh:["\u7F16\u53F7","\u4EE3\u7801","\u7F16\u7801","\u53F7\u7801","\u90AE\u7F16"],ja:["\u756A\u53F7","\u30B3\u30FC\u30C9"],ko:["\uBC88\uD638","\uCF54\uB4DC"],hi:["\u0915\u094B\u0921","\u0915\u094D\u0930\u092E\u093E\u0902\u0915"],fr:["num\xE9ro"],es:["c\xF3digo"],pt:["c\xF3digo","cep"],it:["codice"],pl:["kod","numer"],cs:["k\xF3d","\u010D\xEDslo"],sk:["k\xF3d","\u010D\xEDslo"],hr:["\u0161ifra","oznaka"],ru:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],uk:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],el:["\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2"],ar:["\u0631\u0645\u0632","\u0643\u0648\u062F","\u0631\u0642\u0645"],he:["\u05E7\u05D5\u05D3"],id:["kode","nomor"],vi:["m\xE3"],th:["\u0E23\u0E2B\u0E31\u0E2A"]},qn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Zn=["num\xE9ro"],Qn=t=>t.normalize("NFC").toLowerCase();function Jn(t,e,n,i){let r=Ne(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<rt?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?tt(t,n).includes(e)?"word":null:r.script==="Hang"?nt(t,e)?"suffix":null:r.compounds&&et(t,e,Je)?"suffix":null}function Ut(t){let e=String(t??"").trim();if(!e)return null;let n=de(e),i=de(Me(e));for(let[r,s]of Object.entries(Xn)){let a=qn.includes(r),l=a?i:n;for(let o of s){let u=Zn.includes(o)||!!Ne(r)?.foldSensitive,d=u?l.words:l.folded;if(d.length===0)continue;let f=u?Qn(o):de(o).folded.join(" "),c=Jn(a?d[0]:d[d.length-1],f,r,a);if(c)return{lang:r,word:o,view:c}}}return null}var er=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function Te(t){for(let[e,n]of er)if(n.test(t))return e;return null}var tr=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],ve=new Map;function Ht(t,e,n,i){let r=ve.get(t);if(r)return r;let s=[];for(let[a,l]of e)for(let o=a;o<=l;o++){let u=String.fromCodePoint(o);Te(u)===n&&(i&&!i.test(u)||s.push(u))}return ve.set(t,s),s}function nr(t){let n=t.codePointAt(0);for(let a=0;a<9&&Te(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),r=ve.get(i);if(r)return r;let s=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);Te(l)==="Nd"&&s.push(l)}return ve.set(i,s),s}function rr(t,e){if(e==="Nd")return nr(t);for(let r of tr)if(r.test.test(t))return Ht(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Ht("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function ir(t,e,n,i){let r=t.filter(s=>!e.has(s));return r.length===0&&(r=t.filter(s=>s!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var sr=/^[\p{L}\p{M}\p{Nd}]$/u,Yt=/^[\p{L}\p{Nd}]$/u;function jt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=d=>{let f=Te(d);return!f||!sr.test(d)?d:ir(rr(d,f),n,d,e)},r=d=>{let f=[];for(let c of d)f.push(i(c)),Yt.test(c)&&e()<.2&&f.push(i(c));if(f.length>6){let c=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<c;h++)for(let x=0;x<5;x++){let A=Math.floor(e()*f.length);if(Yt.test(f[A])){f.splice(A,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[a,l=""]=t.split("@"),o=l.endsWith(".com"),u=o?l.slice(0,-4):l;return`${r(a)}@${r(u)}${o?".com":""}`}var or=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ar=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),lr=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function oe(t,e){if(!t||!e)return!1;let n=ar(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:or.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function ur(t){return!!t&&lr.test(t)}function Vi(t,e,n){return t?ur(t)?[...e]:[...n,...e].some(i=>oe(t,i))?e.filter(i=>oe(t,i)):[...e]:[]}var cr=5,dr=6,mr=3,te=864e5,fr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,gr=/^(\d{4})[-/](\d{1,2})$/,pr=/^(\d{4})[-\s]?Q([1-4])$/i,hr=/^Q([1-4])[-\s](\d{4})$/i,yr=/^(\d{4})$/,br=/^(\d{4})(0[1-9]|1[0-2])$/,Sr=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,_r=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Ar=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ke(t,e,n){let i=ee(t);if(!i)return 0;if(i==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=Se(a)[i];if(l!==void 0)return l+1}let r=n?.get(i);if(r!==void 0)return r+1;let s=se(t);if(s.length>0){if(s.every(o=>o.month===s[0].month))return s[0].month+1;let a=Ze(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function Cr(t){let e=ge(t).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let n=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==n.n||i.year!==n.year)?null:Y(n.year,(n.n-1)*3+1,1)}function Y(t,e,n,i=0,r=0,s=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,i,r,s);if(!Number.isFinite(a))return null;let l=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function xr(t,e){let n=[],i="";for(let o=0;o<e.length;o++){if(e[o]!=="%"){i+=e[o].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++o]){case"Y":n.push("Y"),i+="(\\d{4})";break;case"m":n.push("m"),i+="(\\d{1,2})";break;case"d":n.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let r=new RegExp("^"+i+"$").exec(t);if(!r)return null;let s=0,a=1,l=1;return n.forEach((o,u)=>{let d=+r[u+1];o==="Y"?s=d:o==="m"?a=d:l=d}),s?Y(s,a,l):null}function j(t,e,n,i){let r=(t??"").trim();if(r==="")return null;if(e){let o=xr(r,e);return o||null}let s=fr.exec(r);if(s)return Y(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=pr.exec(r),s)return Y(+s[1],(+s[2]-1)*3+1,1);if(s=hr.exec(r),s)return Y(+s[2],(+s[1]-1)*3+1,1);if(s=gr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return Y(+s[1],+s[2],1);if(s=Sr.exec(r),s)return Y(+s[1],+s[2],+s[3]);if(s=br.exec(r),s)return Y(+s[1],+s[2],1);if(s=yr.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?Y(o,1,1):null}let a=Cr(r);if(a)return a;if(s=_r.exec(r),s){let o=Ke(s[1],n,i);if(o)return Y(+s[2],o,1)}if(s=Ar.exec(r),s){let o=Ke(s[2],n,i);if(o)return Y(+s[1],o,1)}let l=re(r);if(l){let o="month"in l?l.month:Ke(l.word,n,i);if(o)return Y(l.year,o,1)}return null}function Xt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function qt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/te),i=Math.floor(n/7),r=i*5,s=t+i*7*te;for(;s<e;)Xt(s)&&r++,s+=te;return r}function wr(t){if(t.length===0)return 0;let e=[...t].sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Mr(t){return t>0?t<.95?"hour":t<=1.05?"day":t>=6.5&&t<=7.5?"week":t>=27&&t<=31.5?"month":t>=88&&t<=93?"quarter":t>=362&&t<=368?"year":"irregular":"irregular"}function ae(t,e,n,i){switch(n){case"year":return e.y-t.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(t.y*4+Math.floor((t.m-1)/3));case"month":return e.y*12+e.m-(t.y*12+t.m);case"week":return Math.round((e.ms-t.ms)/(7*te));case"weekday":return qt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/te);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function Zt(t,e){return Ue(t,e)?.cadence??null}function Ue(t,e){let n=e?.gapFactor??cr,i=0,r=0,s=new Map,a=Array.from(t),l;if(!e?.pattern){let g=[];for(let w of a){if(w==null||w==="")continue;let b=re(String(w));b&&"word"in b&&g.push(b.word)}g.length>0&&(l=_e(g,e?.locale)??void 0)}for(let g of a){if(g==null||g==="")continue;i++;let w=j(String(g),e?.pattern,e?.locale,l);w&&(r++,s.set(w.ms,w))}let o=[...s.values()].sort((g,w)=>g.ms-w.ms);if(o.length<mr||i>0&&r/i<.8)return null;let u=o[o.length-1].ms-o[0].ms;if(u<=0)return null;let d=[];for(let g=1;g<o.length;g++)d.push(o[g].ms-o[g-1].ms);let f=wr(d);if(!(f>0))return null;let c=Mr(f/te);c==="day"&&u>=7*te&&o.every(g=>Xt(g.ms))&&qt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(c="weekday");let h=c==="irregular"?o.length:ae(o[0],o[o.length-1],c,f)+1,x=1,A=1,S=[],p=o[0],y=1;for(let g=1;g<o.length;g++){let w=ae(o[g-1],o[g],c,f);w>x&&(x=w),c!=="irregular"&&w>n?(A++,S.push({from:p.iso,to:o[g-1].iso,points:y}),p=o[g],y=1):y++}S.push({from:p.iso,to:o[o.length-1].iso,points:y});let C={grain:c,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:A,largestGapUnits:x,gapFactor:n};return e?.includeBounds&&S.length<=dr&&(C.runBounds=S),{cadence:C,points:o,stepMs:f}}var Tr=8,vr=.5,Rr=200,Ir=new Set(["category","categories","subcategory","type","types","kind","class","classes","classification","segment","segments","tier","status","priority","severity","grade","level","band","bucket","group","channel","method","mode","stage","phase","period","shift","gender","sex","result","outcome","reason","flag","genre","sector","source"]),Nr=["category","classification","segment","status","priority","severity","channel"],Er=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function kr(t){let e=J(t);if(e.length===0)return!1;let n=e[e.length-1];return Ir.has(n)?!0:Nr.some(i=>n.length>i.length&&n.endsWith(i))}function Dr(t){if(t.isMeasure)return"measure";if(t.isTemporal||t.isDatePart||t.isReassembledDate)return"temporal";let e=Array.from(t.values).filter(n=>n!==""&&n!==null&&n!==void 0);return e.length<2||e.length>Rr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":pe(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Er.has(be(e))?"identifier":!t.geoKind&&kr(t.name)?"attribute":"entity"}function en(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(Dr(r)!=="entity")return;let a=new Set(Array.from(r.values).filter(o=>o!=="")).size,l=!!r.geoKind;(a<n||a===n&&l&&!i)&&(e=s,n=a,i=l)}),e}var Qt=t=>t<10?"0"+t:String(t);function Jt(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Qt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Qt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function tn(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let w=0;w<i;w++)e[w]&&r.add(e[w]);let s=Ue(r,{pattern:t.pattern,locale:t.locale});if(!s)return null;let a=s.cadence.grain;if(a==="irregular")return null;let l=s.points[0],o=ae(l,s.points[s.points.length-1],a,s.stepMs)+1;if(o!==s.cadence.expectedPoints)return null;let u=new Map;for(let w of r){let b=j(w,t.pattern,t.locale);if(!b)continue;let _=ae(l,b,a,s.stepMs);_>=0&&_<o&&u.set(w,{idx:_,stamp:b})}let d=new Map;for(let w=0;w<i;w++){let b=n[w];if(!b)continue;let _=u.get(e[w]);if(!_)continue;let M=d.get(b);M||(M={seen:new Set,lo:_.idx,hi:_.idx,loStamp:_.stamp,hiStamp:_.stamp,order:d.size},d.set(b,M)),M.seen.add(_.idx),_.idx<M.lo&&(M.lo=_.idx,M.loStamp=_.stamp),_.idx>M.hi&&(M.hi=_.idx,M.hiStamp=_.stamp)}if(d.size<2)return null;let f=0;for(let w of d.values())f+=w.seen.size;if(f/(d.size*o)<(t.minFill??vr))return null;let c=[],h=new Set,x=0,A=0,S=0,p=0,y=0,C=1;for(let[w,b]of d){for(let z of b.seen)h.add(z);if(b.seen.size>=o)continue;let _=[...b.seen].sort((z,X)=>z-X),M=1;for(let z=1;z<_.length;z++)M=Math.max(M,_[z]-_[z-1]);let W={key:w,acc:b,coverage:b.seen.size/o,before:b.lo,after:o-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:M};c.push(W),W.before>0&&x++,W.after>0&&A++,W.interior>0&&S++,p=Math.max(p,W.before),y=Math.max(y,W.after),C=Math.max(C,M)}if(c.length===0)return null;c.sort((w,b)=>w.coverage-b.coverage||w.acc.order-b.acc.order);let g=c.slice(0,t.maxListed??Tr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:d.size,incompleteSeries:c.length,lateStarts:x,earlyEnds:A,withHoles:S,columnWideMissing:o-h.size,maxMissingBefore:p,maxMissingAfter:y,largestGap:C,series:g.map(w=>{let b={};return t.includeNames&&(b.name=w.key),t.includeDates&&(b.first=Jt(w.acc.loStamp,a),b.last=Jt(w.acc.hiStamp,a)),b.missingBefore=w.before,b.missingAfter=w.after,b.missingInterior=w.interior,b.largestGap=w.gap,b.coverage=Math.round(w.coverage*1e3)/1e3,b}),more:c.length-g.length}}var Re=6;function le(t){let e=t.slice().sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Or(t){let e=t.length;if(e<Re)return null;let n=t[0],i=t[0],r=0;for(let g of t)g<n&&(n=g),g>i&&(i=g),r+=g;if(n===i)return null;let s=le(t.map(Math.abs));if(s===0)return null;let a=[];for(let g=1;g<e;g++)a.push(t[g]-t[g-1]);let l=le(a.map(Math.abs))/s,o=(e-1)/2,u=r/e,d=0,f=0,c=0;for(let g=0;g<e;g++)d+=(g-o)*(t[g]-u),f+=(g-o)*(g-o),c+=(t[g]-u)*(t[g]-u);c/=e;let h=d/f,x=u-h*o,A=t.map((g,w)=>g-(x+h*w)),S=A.reduce((g,w)=>g+w,0)/e,p=0,y=0;for(let g=0;g<e;g++)p+=(A[g]-S)*(A[g]-S),g>0&&(y+=(A[g]-A[g-1])*(A[g]-A[g-1]));return p/=e,y/=e-1,{vnDetrended:p<=c*1e-12?2:y/p,relStep:l}}function He(t){let{stamps:e,series:n,values:i}=t,r=Math.min(e.length,i.length),s=new Map;for(let u=0;u<r;u++){let d=e[u],f=i[u];if(d===null||f===null||!Number.isFinite(f))continue;let c="";if(n&&(c=n[u]??"",c===""))continue;let h=s.get(c);h||s.set(c,h=new Map),h.set(d,(h.get(d)??0)+f)}let a=[],l=[],o=[];for(let u of s.values()){let d=[...u.entries()].sort((c,h)=>c[0]-h[0]).map(c=>c[1]),f=Or(d);f&&(a.push(f.vnDetrended),l.push(f.relStep),o.push(d.length))}return a.length===0?null:{series:a.length,points:Math.round(le(o)),vnDetrended:Math.round(le(a)*1e3)/1e3,relStep:Math.round(le(l)*1e4)/1e4}}function ts(t){let e=t.times.map(n=>j(n,t.pattern,t.locale)?.ms??null);return He({stamps:e,series:t.series,values:t.values})}var Pr=5e5,Lr=8,Fr=4,zr=5,Ye=1,je=2,Wr=4,$r=8;function Br(t,e,n){let[i,r]=[...t];if(e.isTemporal){let s=j(i,e.temporalTextPattern,n),a=j(r,e.temporalTextPattern,n);if(s&&a&&s.ms!==a.ms)return s.ms<a.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Gr(t,e,n){let{rows:i,text:r,locale:s}=t,a=Br(n.values,n,s),l=new Uint8Array(i.length),o=0;for(let u=0;u<i.length;u++){let d=r(i[u][e]);d===a.a?l[u]=1:d===a.b?l[u]=2:o++}return{code:l,blankRows:o,setOrder:a.setOrder}}function Vr(t,e){let{rows:n,text:i}=t,r=new Int32Array(n.length),s=new Map;for(let a=0;a<n.length;a++){let l=i(n[a][e]);if(l===""){r[a]=-1;continue}let o=s.get(l);o===void 0&&(o=s.size,s.set(l,o)),r[a]=o}return{ids:r,dict:s}}function Kr(t,e,n){let i=new Uint8Array(n);for(let s=0;s<t.length;s++){let a=e[s];if(a===0)continue;let l=t[s];if(l<0)continue;let o=i[l];i[l]=o&a?o|a<<2:o|a}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<n;s++){let a=i[s];a&Ye&&r.keysA++,a&je&&r.keysB++,(a&(Ye|je))===(Ye|je)&&r.keysBoth++,a&Wr&&r.dupA++,a&$r&&r.dupB++}return r}function Ur(t,e){let n=(t.dupA+t.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(t.keysA+t.keysB);return n<i||n===i&&t.keysBoth>e.keysBoth}var nn=t=>t==null||typeof t=="string"&&t.trim()==="";function Hr(t,e,n){if(t===e)return!0;let i=nn(t),r=nn(e);return i||r?i&&r:typeof t=="number"&&typeof e=="number"?!1:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():n(t).trim()===n(e).trim()}function rn(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Pr)return null;let r=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=zr).sort((b,_)=>(_.c.identifierNamed?1:0)-(b.c.identifierNamed?1:0)||_.c.distinct-b.c.distinct||b.i-_.i).slice(0,Lr),s=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,Fr);if(r.length===0||s.length===0)return null;let a=s.map(({c:b,i:_})=>Gr(t,_,b)),l=null;for(let{i:b}of r){let _=Vr(t,b);for(let M=0;M<s.length;M++){if(s[M].i===b)continue;let W=Kr(_.ids,a[M].code,_.dict.size);W.keysBoth<1||(!l||Ur(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:M,ids:_.ids,dict:_.dict})}}if(!l)return null;let{ids:o,dict:u,tally:d}=l,f=a[l.setNo],c=s[l.setNo].i,h=u.size,x=new Int32Array(h).fill(-1),A=new Int32Array(h).fill(-1);for(let b=0;b<i;b++){let _=f.code[b],M=o[b];_===0||M<0||(_===1?x[M]<0&&(x[M]=b):A[M]<0&&(A[M]=b))}let S=[];for(let b=0;b<n.length;b++)b!==l.keyIdx&&b!==c&&S.push(b);let p=0;for(let b=0;b<h;b++){let _=x[b],M=A[b];if(_<0||M<0)continue;let W=e[_],z=e[M],X=!0;for(let Q of S)if(!Hr(W[Q],z[Q],t.text)){X=!1;break}X&&p++}let y=p===d.keysBoth?100:p===0?0:Math.min(99,Math.max(1,Math.round(p/d.keysBoth*100))),C=new Map,g=new Map;for(let[b,_]of u){let M=x[_]>=0,W=A[_]>=0;if(!M&&!W)continue;let z=dt(b);mt(z)&&(M&&C.set(z,(C.get(z)??0)+1),W&&g.set(z,(g.get(z)??0)+1))}let w=b=>{let _=0;for(let M of b.values())M>=2&&(_+=M);return _};return{key:l.keyIdx,discriminator:c,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[c].name,keysA:d.keysA,keysB:d.keysB,keysBoth:d.keysBoth,duplicateKeysA:d.dupA,duplicateKeysB:d.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:w(C),looseCollisionsB:w(g),setOrder:f.setOrder}}}var Yr=t=>t==="Integer"||t==="Decimal";function jr(t){let e=[],n=[];return t.forEach((i,r)=>{if(i.twoValues){if(i.isBinaryFlag){e.push(r);return}i.isMeasure||i.isTemporal||i.isDatePart||i.identifierNamed||n.push(r)}}),[...e,...n].slice(0,6)}function Xr(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!Yr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function sn(t){let e=new Map,{rows:n,columns:i,text:r}=t;if(n.length===0||n.length>(t.maxRows??5e5))return e;let s=jr(i);if(s.length===0)return e;let a=Xr(i,new Set(s));if(a.length===0)return e;let l=s.map(o=>{let[u,d]=i[o].twoValues,f=new Uint8Array(n.length);for(let c=0;c<n.length;c++){let h=r(n[c][o]);f[c]=h===u?1:h===d?2:0}return f});for(let o of a){let u=new Float64Array(n.length),d=0;for(let y=0;y<n.length;y++){let C=n[y][o],g=C==null||C===""?NaN:typeof C=="number"?C:parseFloat(C);u[y]=g,g===g&&g!==1/0&&g!==-1/0&&d++}if(d<2)continue;let f=new Float64Array(d);for(let y=0,C=0;y<n.length;y++){let g=u[y];g===g&&g!==1/0&&g!==-1/0&&(f[C++]=g)}f.sort();let c=new Float64Array(d),h=0;for(let y=0;y<d;y++)(y===0||f[y]!==f[y-1])&&(c[h++]=f[y]);let x=new Int32Array(n.length).fill(-1);for(let y=0;y<n.length;y++){let C=u[y];if(!(C===C&&C!==1/0&&C!==-1/0))continue;let g=0,w=h-1;for(;g<w;){let b=g+w>>>1;c[b]<C?g=b+1:w=b}x[y]=g}let A=[],S=new Int32Array(h),p=new Int32Array(h);for(let y=0;y<s.length;y++){let C=l[y];S.fill(0),p.fill(0);let g=0,w=0;for(let U=0;U<n.length;U++){let m=x[U];m<0||(C[U]===1?(S[m]++,g++):C[U]===2&&(p[m]++,w++))}if(g===0||w===0)continue;let b=g<=w,_=b?g:w,M=b?w:g,W=b?S:p,z=b?p:S,X=0,Q=0,ue=0;for(let U=0;U<h;U++){let m=W[U],T=z[U];X+=m*(Q+.5*T),Q+=T,m+T>=2&&(ue+=m+T)}A.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(X/(_*M)*1e4)/1e4,nMinority:_,nMajority:M,ties:ue})}A.length>0&&e.set(o,A)}return e}var an=12,qr=100,Zr=.3,Qr=.9,Jr=120,ei=1900,ti=2100,ni=0,ri=20,ii=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ie(t){if(!t)return!1;let e=J(t);return e.length===0?!1:ii.has(e[e.length-1])?!0:Ut(t)!==null}var si=new Set(["year","yr","fy"]),oi=t=>J(t).some(e=>si.has(e))||ct(t)!==null,ai=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function Xe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function qe(t){if(!Number.isInteger(t)||t<19000101||t>21001231)return!1;let e=Math.floor(t/100)%100,n=t%100;return e>=1&&e<=12&&n>=1&&n<=31}var li=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ui=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ci=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function cn(t,e){let n=[],i=0,r=di(t,e,n,()=>{i++});if(r)return r;if(i>0||n.length<2)return null;let s=It(n,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function di(t,e,n,i){let r=0,s=0,a=0,l=0,o=0,u="",d=0,f="",c=0,h=0,x=0,A=0,S=!1;for(let b of t){if(b==null)continue;let _=String(b).trim();if(_==="")continue;r++,n.push(_);let M;if(M=li.exec(_)){i();let W=+M[2],z=+M[3];W>=1&&W<=12&&z>=1&&z<=31&&(s++,M[4]!==void 0&&a++,M[6]!==void 0&&l++)}else if(M=ui.exec(_)){i();let W=+M[3],z=+M[4];W>=1&&W<=12&&z>=1&&z<=31&&(u&&u!==M[2]&&(S=!0),u=M[2],o++)}else if(M=ci.exec(_)){i();let W=+M[1],z=+M[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==M[2]&&(S=!0),f=M[2],d++,W>12&&x++,z>12&&A++,M[5]!==void 0&&c++,M[7]!==void 0&&h++)}if(r>=200)break}if(r<2||(s+o+d)/r<.8||(s>0?1:0)+(o>0?1:0)+(d>0?1:0)!==1||S)return null;if(s>0)return a===s?{pattern:l===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${u}%m${u}%d`,orderFrom:"iso"};if(x>0&&A>0)return null;let C,g;x>0?(C=!0,g="values"):A>0?(C=!1,g="values"):f==="."?(C=!0,g="shape"):(C=!ze(e),g="locale");let w=C?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return c===d?{pattern:w+(h===d?" %H:%M:%S":" %H:%M"),orderFrom:g}:{pattern:w,orderFrom:g}}function mi(t,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(t))return!1;let n=t.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let i=ee(n);return i.length>0&&e[i]!==void 0}function fi(t,e){let n=new Map,i=new Map;for(let l of t){let o=re(l);if(!o||"month"in o)continue;let u=se(o.word),d=u.some(c=>c.lang==="en"),f=ee(o.word);for(let c of new Set(u.map(h=>h.lang)))c!=="en"&&(n.has(c)||(n.set(c,new Set),i.set(c,new Set)),n.get(c).add(f),d||i.get(c).add(f))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&i.get(l).size>=1),s=0,a=new Map(r.map(l=>[l,0]));for(let l of e){let o=re(l);if(!o)continue;if("month"in o){s++;continue}let u=se(o.word);if(u.length===0)continue;let d=u.some(f=>f.lang==="en");for(let f of r)(d||u.some(c=>c.lang===f))&&a.set(f,a.get(f)+1)}return s+Math.max(0,...a.values())}var gi=/(?:19|20)[0-9]{2}/;function pi(t){let e=new Map,n=0;for(let r of t){if(!gi.test(ne(r)))continue;let s=new Set(ge(r).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(s.size!==0){if(s.has("en")){n++;continue}for(let a of s)e.set(a,(e.get(a)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function hi(t){let{dataType:e,name:n,isMeasure:i,distinctCount:r}=t;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=t.minNum,a=t.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let o=s>=1900&&a<=2100;if(o&&r>=2&&oi(n)||o&&r>=3&&r===a-s+1)return!0;let u=Xe(s)&&Xe(a),d=qe(s)&&qe(a);if(u||d){if(!t.sampleValues)return!0;let f=0,c=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let x=Number(String(h).trim());if(Number.isFinite(x)&&(u?Xe(x):qe(x))&&c++,f>=60)break}if(f>=2&&c===f)return!0}return!1}if(t.sampleValues){let s=t.locale?Se(t.locale):null,a=0,l=0,o=[],u=[];for(let d of t.sampleValues){if(d==null||d==="")continue;a++;let f=String(d).trim();if(o.push(f),ai.test(f)||mi(f,s)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+pi(u)+fi(o,u))/a>=.8||cn(o,t.locale)!==null)return!0}return!1}function yi(t){let e=Z((t||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Lt(t)}function bi(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:s,maxNum:a,discourageAgg:l}=t,o=100,u=.01,d="";for(let c of r){if(c.distinct<2||c.distinct>o)continue;let h=r.filter(y=>y.idx!==c.idx).map(y=>y.idx),x=new Map;for(let y of e){let C=y[n];if(typeof C!="number"||!Number.isFinite(C))continue;let g=h.length?h.map(b=>String(y[b])).join(d):"",w=x.get(g);w||(w={sum:0,cset:new Set},x.set(g,w)),w.sum+=C,w.cset.add(String(y[c.idx]))}let A=0,S=0,p=0;for(let y of x.values())y.cset.size<2||(p++,Math.abs(y.sum-100)<=100*u?A++:Math.abs(y.sum-1)<=1*u&&S++);if(p>=2&&(A/p>=.9||S/p>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(l)return{additivity:"intensive_rate"};let f=yi(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&s>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function dn(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:s,prec:a,maxval:l,minval:o}=t,u=l-o+1,d=u>0?r/u:1,f=s>0?r/s:0,c=e==="Decimal"||a>0;return!n&&Ie(i)?"Categorical":d>=Qr&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(ft(i)&&r<=Jr||o>=ei&&l<=ti||o>=ni&&l<=ri)?"Ordinal":n?"Continuous":!c&&Number.isFinite(u)&&r>an&&r===s&&u===r?"Categorical":r>an&&(c||r>=qr||f>=Zr)?"Continuous":"Categorical"}function ln(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:dn({dataType:t.dataType,isMeasure:!1,name:t.name,distinct:n.distinct,nonblank:n.nonblank,prec:n.prec,maxval:typeof n.maxval=="number"?n.maxval:0,minval:typeof n.minval=="number"?n.minval:0,ordinalNeedsWholeNumbers:!0})==="Continuous"}function Si(t){let e=null;for(let n=0;n<t.length;n++){let i=t[n];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=t.slice()),e[n]=r)}return e||t}var un=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;dedupRows=!0;emitLegacyAggAliases=!1;deriveProvinces=!0;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let n=0;n<this._cols.length;n++){let i=this._cols[n];!i||!/date|time/i.test(String(i.dataType??""))||lt(this._rows.map(r=>r[n]))&&e.add(n)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(n=>!!(n&&n.isMeasure));return this._cols.forEach((n,i)=>{if(!n||n.isMeasure||this._declaredDimensions.has(n)||n.dataType!=="Integer"&&n.dataType!=="Decimal")return;let r=new Set,s=0,a=0,l=null,o=null;for(let u of this._rows){let d=u[i],f=this.STR(d);if(f!=""&&(r.add(f),s++,(l===null||d<l)&&(l=d),(o===null||d>o)&&(o=d),n.dataType=="Decimal")){let c=this.getPrecision(d);c>a&&(a=c)}}e[i]=ln(n,!1,{distinct:r.size,nonblank:s,prec:a,minval:l,maxval:o})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return at(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,n){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=this.wallClockColumnIndexes(),a=[],l=[],o=[];for(let m of this._cols){let T=new Map,O=[],D=0,v=0,k=0,F=null,P=null,E=null,G=!1,V=!0,I=!0,N=null,K=!1,L=s.has(i);for(let R of this._rows){let $=R[i],B=L&&$ instanceof Date?fe($):$,H=this.STR(B);if(H!=""){if(D+=H.length,T.set(H,(T.get(H)||0)+1),v++,m.dataType=="Integer"||m.dataType=="Decimal"||m.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),m.dataType=="Integer"||m.dataType=="Decimal"){if(E===null?E=B:E+=B,m.dataType=="Decimal"){let q=this.getPrecision(B);q>k&&(k=q)}O.push(B)}else G=G||this.hasTimeComponent(B);K&&(B<N?V=!1:B>N&&(I=!1)),N=B,K=!0}}if(v>=3&&(V&&!I?m.sortedDirection="asc":I&&!V?m.sortedDirection="desc":m.sortedDirection="none"),v>0&&T.size>0&&!m.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(m.modalShare=R/v,m.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(ce=>it(ce).trim().toLowerCase()).sort(),q=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ce=>B[0]===ce[0]&&B[1]===ce[1]),mn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(m.name);(q||mn)&&(m.isBinaryFlag=!0)}}else m.isMeasure&&(m.dataType==="Integer"||m.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(m.isBinaryFlag=!0);if(m.dataType=="DateTime"&&(m.dateWithTime=G,G&&ut(L?this._rows.map(R=>R[i]instanceof Date?fe(R[i]):R[i]):this._rows.map(R=>R[i]))?m.timeOfDayOnly=!0:delete m.timeOfDayOnly),m.isTemporal=hi({dataType:m.dataType,name:m.name,isMeasure:m.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),m.isTemporal&&m.dataType==="String"&&!m.isMeasure){let R=cn(T.keys(),n);R&&(m.temporalTextPattern=R.pattern)}if(m.timeOfDayOnly)delete m.temporalCadence;else if(m.isTemporal&&!m.isMeasure){let R=Zt(T.keys(),{includeBounds:r>=20,pattern:m.temporalTextPattern,locale:n});R&&(m.temporalCadence=R)}this.updateColumnStats10(r,m,v,T,k,P,F),this.updateColumnStats20(r,O,v,E,m,D,G,F,P,k,T,n),ln(m,this._declaredDimensions.has(m),{distinct:T.size,nonblank:v,prec:k,minval:F,maxval:P})&&(m.isMeasure=!0,m.valueNature="Continuous",m.geoKind=void 0,m.geoMatchPct=void 0,m.geoAmbiguous=void 0,m.dominantGeoRegion=void 0,m.dominantGeoRegionPct=void 0,m.geoRegionCount=void 0),a[i]=m.isMeasure||T.size>2e3?null:new Set(T.keys()),l[i]=T.size,o[i]=T.size===2?[...T.keys()].sort():null,i++}Tt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((m,T)=>{let O=this._cols[T];m.kind&&(O.geoKind=m.kind,O.geoMatchPct=m.matchPct,m.ambiguous&&(O.geoAmbiguous=!0)),m.rollupPct!==void 0&&(O.admin1RollupPct=m.rollupPct),m.regionCount!==void 0&&(O.admin1RegionCount=m.regionCount),m.countryCount!==void 0&&(O.admin1CountryCount=m.countryCount),m.dominantRegion&&(O.dominantGeoRegion=m.dominantRegion,O.dominantGeoRegionPct=m.dominantRegionPct)});let u=this.getGeoExtent();if(u&&u.dominantFrame&&this._geoExtentLatIdx>=0){let m=this._cols[this._geoExtentLatIdx];m.geoKind||(m.dominantGeoRegion=u.dominantFrame,m.dominantGeoRegionPct=u.dominantFramePct,this.deriveProvinces&&(m.admin1RollupPct=u.dominantFramePct))}let d=[];this._cols.forEach((m,T)=>{m.isMeasure||d.push({idx:T,distinct:m.distinctCount??0,name:m.name})}),this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=typeof m.lowValue=="number"?m.lowValue:null,D=typeof m.highValue=="number"?m.highValue:null,v=bi({rows:this._rows,measureColIdx:T,measureName:m.name,candidateDims:d,minNum:O,maxNum:D,discourageAgg:!!m.discourageAggregationAcrossGroups});m.additivity=v.additivity,v.partOfWholeDim&&(m.partOfWholeDim=v.partOfWholeDim)});let f=50,c=4,h=d.filter(m=>m.distinct>=2&&m.distinct<=f);this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let K=typeof N=="number"?N:parseFloat(N);isNaN(K)||O.push(K)}if(O.length===0)return;let D=[...O].sort((I,N)=>I-N);if(D[0]===D[D.length-1])m.relativeDispersion=0;else if(D.length>=c){let I=me(D,.5),N=me(D,.1),K=me(D,.9);m.relativeDispersion=Math.abs(I)>1e-9?Math.round((K-N)/Math.abs(I)*1e3)/1e3:void 0}else m.relativeDispersion=void 0;let v=[];for(let I of h){let N=new Set;for(let K of this._rows){let L=K[T];L==null||L===""||N.add(this.STR(K[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(m.nonBlankGroups=v);let k=0;for(let I of O)k+=I;k/=O.length;let F=0;for(let I of O)F+=(I-k)*(I-k);if(F<=1e-12)return;let P=[],E=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),K=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return K(.75)-K(.25)},V=G(O);for(let I of h){let N=new Map;for(let R of this._rows){let $=R[T];if($==null||$==="")continue;let B=typeof $=="number"?$:parseFloat($);if(isNaN(B))continue;let H=this.STR(R[I.idx])+"",q=N.get(H);q?(q.s+=B,q.n++,q.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let K=0;for(let R of N.values()){let $=R.s/R.n;K+=R.n*($-k)*($-k)}P.push({otherColumn:I.name,eta2:Math.round(K/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(V)&&V>1e-9){let R=(Math.max(...L)-Math.min(...L))/V;E.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(m.groupDiscrimination=P),E.length>0&&(m.spreadDiscrimination=E)});let x=.97,A=.8,S=8,p=5,y=this._cols.map((m,T)=>({c:m,i:T})).filter(m=>m.c.isMeasure);for(let m=0;m<y.length;m++)for(let T=m+1;T<y.length;T++){let O=y[m].i,D=y[T].i,v=0,k=0,F=0,P=0,E=0,G=0;for(let L of this._rows){let R=L[O],$=L[D];if(R==null||R===""||$===null||$===void 0||$==="")continue;let B=typeof R=="number"?R:parseFloat(R),H=typeof $=="number"?$:parseFloat($);isNaN(B)||isNaN(H)||(v++,k+=B,F+=H,P+=B*B,E+=H*H,G+=B*H)}if(v<p)continue;let V=v*P-k*k,I=v*E-F*F;if(V<=1e-12||I<=1e-12)continue;let N=(v*G-k*F)/Math.sqrt(V*I),K=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[y[m].c,y[T].c])(L.maxAbsMeasureCorrelation===void 0||K>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=K);if(Math.abs(N)>=x){let L=y[m].c,R=y[T].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),L.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(L.name)}else if(Math.abs(N)>=A){let L=y[m].c,R=y[T].c,$=Math.round(N*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:R.name,r:$}),R.correlatedWithMeasures.push({otherColumn:L.name,r:$})}}for(let{c:m}of y)m.correlatedWithMeasures&&(m.correlatedWithMeasures.sort((T,O)=>Math.abs(O.r)-Math.abs(T.r)||(T.otherColumn<O.otherColumn?-1:1)),m.correlatedWithMeasures.length=Math.min(m.correlatedWithMeasures.length,S));for(let m=0;m<this._cols.length;m++){let T=a[m];if(!T||T.size===0)continue;let O=[];for(let D=0;D<this._cols.length;D++){if(D===m)continue;let v=a[D];if(!v||v.size===0)continue;let k=0;for(let P of T)v.has(P)&&k++;let F=Math.round(k/T.size*100);F>0&&O.push({otherColumn:this._cols[D].name,percentShared:F})}O.length>0&&(this._cols[m].sharedValueRatioWithOthers=O)}let C=50,g=[];for(let m=0;m<this._cols.length;m++){let T=a[m];T&&T.size>=2&&T.size<=C&&g.push(m)}if(g.length>=2){let m=new Map,T=(D,v)=>D+":"+v;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++)m.set(T(g[D],g[v]),new Map);for(let D of this._rows)for(let v=0;v<g.length;v++){let k=this.STR(D[g[v]])+"";for(let F=v+1;F<g.length;F++){let P=""+this.STR(D[g[F]]),E=m.get(T(g[v],g[F])),G=k+""+P;E.set(G,(E.get(G)??0)+1)}}let O=new Map;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++){let k=g[D],F=g[v],P=a[k].size,E=a[F].size,G=m.get(T(k,F)),V=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(V/(P*E)*100),K=V===P,L=V===E;if((this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:K,minCellCount:I,distinctCombinations:V}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:V}),K&&P>E){let R=O.get(k);(!R||E<R.card)&&O.set(k,{name:this._cols[F].name,card:E,ratio:E/P})}if(L&&E>P){let R=O.get(F);(!R||P<R.card)&&O.set(F,{name:this._cols[k].name,card:P,ratio:P/E})}}for(let[D,v]of O)this._cols[D].primaryParentColumn=v.name,this._cols[D].nestingRatio=Math.round(v.ratio*100)/100}let w=6,b=this._rows.length;for(let m=0;m<this._cols.length;m++){let T=this._cols[m];if(T.isMeasure||T.primaryParentColumn)continue;let O=T.distinctCount??0;if(O<=C||b>0&&O>=b)continue;let D=[];for(let v=0;v<this._cols.length;v++){if(v===m)continue;let k=this._cols[v];if(k.isMeasure)continue;let F=k.distinctCount??0;F<2||F>=O||D.push(v)}D.sort((v,k)=>(this._cols[v].distinctCount??0)-(this._cols[k].distinctCount??0));for(let v of D.slice(0,w)){let k=new Map,F=!0;for(let E of this._rows){let G=this.STR(E[m])+"",V=this.STR(E[v])+"",I=k.get(G);if(I===void 0)k.set(G,V);else if(I!==V){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/O*100)/100;break}}let _=.01,M=.05,W=.95,z=8,X=8,Q=6,ue=500,U=[];for(let m=0;m<this._cols.length&&U.length<X;m++){let T=this._cols[m].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(m)}if(U.length>=3&&this._rows.length>=z){let m=Math.min(this._rows.length,ue),T=U.map(P=>{let E=[];for(let I=0;I<m;I++){let N=this._rows[I][P],K=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(K))return null;E.push(K)}let G=E[0],V=!1;for(let I of E)if(I!==G){V=!0;break}return V?E:null}),O=U.map((P,E)=>E).filter(P=>T[P]!==null),D=P=>{let E=P.slice().sort((V,I)=>V-I),G=E.length>>1;return E.length%2?E[G]:(E[G-1]+E[G])/2},v=null,k=[],F=P=>{if(k.length>=3){let E=k.map(N=>T[N]),G=E[0].length,V=new Array(G);for(let N=0;N<G;N++){let K=0;for(let L of E)K+=L[N];V[N]=K}let I=D(V);if(I>0){let N=0;for(let L of V)Math.abs(L-I)<=I*_&&N++;let K=N/G;if(K>=W){let L=1;for(let R of E){let $=D(R)/I;$<L&&(L=$)}L>=M&&(!v||k.length>v.cols.length)&&(v={cols:k.slice(),total:I,matched:K})}}}if(!(k.length>=Q))for(let E=P;E<O.length;E++)k.push(O[E]),F(E+1),k.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(V=>this._cols[U[V]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let V of P.cols)this._cols[U[V]].constantSumGroup=G}}return this.applyTwoSetPairing(n,a),this.applyScoreSeparation(l,o),this.applySeriesCompleteness(r,n,a),this.applyMeasurePersistence(n,a),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=rn({rows:this._rows,columns:this._cols.map((r,s)=>{let a=n[s];return{name:r.name,values:a,distinct:a?a.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,n){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=sn({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:n[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,n,i){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,d)=>({c:u,i:d})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let s=this.seriesKeyIndex(n,i);if(s<0)return;let a=this._cols[s],l=this._rows.map(u=>this.STR(u[s])),o=e>=20&&(a.dataType!=="String"||Array.isArray(a.safeDistinctValues));for(let{c:u,i:d}of r){let f=tn({periods:this._rows.map(c=>this.STR(c[d])),series:l,seriesColumn:a.name,pattern:u.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:o});f&&(u.seriesCompleteness=f)}}seriesKeyIndex(e,n){let i=[],r=[];this._cols.forEach((a,l)=>{let o=n[l];o&&(i.push(l),r.push({name:a.name,dataType:a.dataType,isMeasure:!!a.isMeasure,isTemporal:!!a.isTemporal,isDatePart:!!a.isDatePart,isReassembledDate:!!a.isReassembledDate,isBinaryFlag:!!a.isBinaryFlag,geoKind:a.geoKind,identifierNamed:Ie(a.name),values:o,rows:this._rows.length,locale:e}))});let s=en(r);return s<0?-1:i[s]}applyMeasurePersistence(e,n){for(let o of this._cols)o.persistence!==void 0&&delete o.persistence;let i=[];if(this._cols.forEach((o,u)=>{o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal"||o.dataType==="Double")&&i.push(u)}),i.length===0||this._rows.length<Re)return;let r=-1,s=[];for(let o=0;o<this._cols.length&&r<0;o++){let u=this._cols[o];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let d=this._rows.map(f=>j(this.STR(f[o]),u.temporalTextPattern,e)?.ms??null);new Set(d.filter(f=>f!==null)).size<Re||(r=o,s=d)}if(r<0)return;let a=this.seriesKeyIndex(e,n),l=a>=0?this._rows.map(o=>this.STR(o[a])):void 0;for(let o of i){let u=this._rows.map(f=>{let c=f[o];if(c==null||c==="")return null;let h=typeof c=="number"?c:parseFloat(String(c).replace(/,/g,""));return Number.isFinite(h)?h:null}),d=He({stamps:s,series:l,values:u});d&&(this._cols[o].persistence={timeColumn:this._cols[r].name,...a>=0?{seriesColumn:this._cols[a].name}:{},...d})}}updateColumnStats20(e,n,i,r,s,a,l,o,u,d,f,c){if(e>=20){let h=[...n].sort((S,p)=>S-p),x=Math.floor(h.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=a/i),this._rows.length>0){let S=p=>{let y=p instanceof Date?p:typeof p=="string"?Ee(p)??new Date(p):new Date(p),C=this.wholeDayIso(y);return C?C+"T00:00:00.000Z":isNaN(y.getTime())?p:y.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!o?s.lowValue=o:s.lowValue=S(o),s.dataType!="DateTime"||l||!u?s.highValue=u:s.highValue=S(u),s.medianValue=h.length===0?null:h.length%2===0?s.dataType=="Integer"?Math.round((h[x-1]+h[x])/2):(h[x-1]+h[x])/2:h[x],s.numericPrecision=d}if(h.length>0){let S=i>0&&r!=null?r/i:s.avgValue??0,p=h.length,y=0,C=0;for(let b of h){let _=b-S;y+=_*_,C+=_*_*_}let g=y/p,w=Math.sqrt(g);s.skewness=g===0?0:C/p/(w*w*w),s.stdDev=Math.sqrt(g)}r!==null&&(s.sum=r);let A=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]);if(s.topCategories=A.slice(0,10).map(S=>S[1]),!s.isMeasure&&A.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=A.slice(0,5).map(S=>S[0])),e>=20)){let S=A.map(y=>y[0]),p=pe(S,c);if(p!==null)s.ordinalPattern=p.pattern,s.orderedDomain=p.orderedDomain;else if(s.dataType==="String"){let y=gt(S);y!==null&&(s.safeDistinctValues=y)}}if(h.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let S=p=>h[Math.floor((h.length-1)*p)];s.quantiles={p05:S(.05),p25:S(.25),p75:S(.75),p95:S(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let h=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]).map(S=>S[0]);s.formatSignature=be(h);let x=i>0?a/i:void 0,A=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!A.test(s.formatSignature)&&(x===void 0||x>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((A,S)=>S[1]-A[1]),x=At(h.map(A=>A[0]),s.name,c);if(x!==null&&(s.geoKind=x.geoKind,s.geoMatchPct=x.geoMatchPct,x.geoAmbiguous&&(s.geoAmbiguous=!0),x.geoKind.indexOf("country")===0)){let A=yt(h);A&&(s.dominantGeoRegion=A.dominantGeoRegion,s.dominantGeoRegionPct=A.dominantGeoRegionPct,s.geoRegionCount=A.regionCount,A.middleEastPct>0&&(s.middleEastPct=A.middleEastPct))}}}updateColumnStats10(e,n,i,r,s,a,l){let o=this._rows.length-i;e>=10&&(n.blankCount=o),n.distinctCount=r.size+(o!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=dn({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:s,maxval:a,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal"))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,r)=>{i.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let i of this._rows)n.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=a=>Qe(a,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((a,l)=>{let o=e(a.name),u=a.dataType==="Integer"||a.dataType==="Decimal";u&&n<0&&o.some(d=>d==="lat"||d==="latitude")?n=l:u&&i<0&&o.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(i=l),r<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(r=l)}),n<0||i<0){let a=(u,d)=>{let f=0;for(let c of this._rows){let h=c[u];if(h==null||h==="")continue;let x=Number(h);if(!Number.isFinite(x)||x<-d||x>d)return!1;f++}return f>0},l=-1,o=-1;if(this._cols.forEach((u,d)=>{if(!(u.dataType==="Integer"||u.dataType==="Decimal"))return;let f=e(u.name),c=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Nt(f);c==="lat"&&l<0&&a(d,90)?l=d:c==="lon"&&o<0&&a(d,180)&&(o=d)}),l<0||o<0)return null;n=l,i=o}this._geoExtentLatIdx=n;let s=[];for(let a of this._rows){let l=a[n],o=a[i],u=l==null||l===""?null:Number(l),d=o==null||o===""?null:Number(o);s.push({lat:u,lon:d,country:r>=0&&he(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=ht(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return jt(e,ot)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=n[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,a=this.wallClockColumnIndexes();for(let o of this._rows){let u={};for(let d=0;d<this._cols.length;d++){let f=this._cols[d],c=o[d];if(this.STR(c)!=""){if(e&&f.dataType=="String")if(s.has(c))c=s.get(c);else{let h=this.obfuscateString(c);s.set(c,h),c=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=c instanceof Date?c:typeof c=="string"?Ee(c)??new Date(c):new Date(c);c=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(d)&&c instanceof Date&&(c=fe(c));r-=this.STR(c).length}else c=null;u[d]=c,--r}if(n.push(u),--i,i<=0||r<=0)break}return await on.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return on.unparse([this._cols.map((n,i)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}setGenerationColumns(e){let n=(e??[]).filter(r=>!!r&&typeof r.n=="string"&&r.n!==""&&typeof r.q=="string"&&r.q!=="").map(r=>({n:r.n,q:r.q})),i=JSON.stringify(n);i!==this._generationColumnsSig&&(this._generationColumns=n,this._generationColumnsSig=i,this._englishAliases=new Map)}aliasesForCode(e){let n=Ve(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:i.reason});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=Ve(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let n of this.liveEnglishAliases().values())e.push({name:n.name,alias:n.alias,reason:n.reason});return e}legacyAliases(){let e=[];for(let n of this._cols)n&&n.hostName&&n.hostName!==n.name&&e.push({name:this.STR(n.name),alias:this.STR(n.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let n=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return n;let i=String(e),r=new Set;for(let l of this._cols)l&&(r.add(this.STR(l.name)),l.hostName&&r.add(this.STR(l.hostName)));let s=new Map,a=new Set;for(let l=0;l<this._cols.length;l++){if(!this._cols[l])continue;let o=this._hostQueryNames[l],u=Wt(o,this._cols[l].name,this._cols[l].dataType)?[]:zt(o),d=this.STR(this._cols[l].name),f=[];if(o){for(let h of this._generationColumns)if(h.q===o)for(let x of[h.n,Ge(h.n)])x&&x!==d&&!u.includes(x)&&!f.includes(x)&&f.push(x)}let c=[...u,...f].filter(h=>!r.has(h)&&oe(i,h));c.length===1&&(s.set(c[0],[...s.get(c[0])??[],l]),f.includes(c[0])&&a.add(c[0]))}for(let[l,o]of s){if(o.length!==1)continue;let u=this.STR(this._cols[o[0]].name);n.set(o[0],{name:u,alias:l,headerName:!oe(i,u),reason:a.has(l)?"stored-query-name":"english-implicit-agg"})}return n}liveEnglishAliases(){let e=new Map;for(let[n,i]of this._englishAliases){let r=this._cols?this._cols[n]:null;r&&this.STR(r.name)===i.name&&e.set(n,i)}return e}addRow(e,n){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=st(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Si(e)),this._inferredMeasureFlags=null,this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}invalidateStats(){this._computedStatsForLevel=null,this._geoExtentComputed=!1,this._geoExtent=null,this._geoExtentLatIdx=-1}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map,this._generationColumns=[],this._generationColumnsSig="[]"}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let n=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Ge(r);!s||s===r||n.has(s)||(n.delete(r),n.add(s),i.hostName=r,i.name=s)}}};export{fn as a,gn as b,wi as c,Mi as d,Tt as e,It as f,vn as g,Rn as h,Nt as i,En as j,kn as k,Dn as l,On as m,Me as n,Vn as o,Ge as p,Ve as q,zt as r,Bt as s,Hn as t,Vt as u,Kt as v,Oi as w,Pi as x,Li as y,Xn as z,qn as A,Zn as B,Ut as C,oe as D,ur as E,Vi as F,cr as G,dr as H,j as I,Zt as J,Tr as K,vr as L,Rr as M,Dr as N,en as O,tn as P,ts as Q,Ie as R,cn as S,hi as T,yi as U,bi as V,dn as W,ln as X,Si as Y,un as Z};
|