@bicharts/shape-core 0.6.133 → 0.6.135

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.
@@ -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-R7VGZR7L.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};
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-UHEXA4HI.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-QKOU2RYW.mjs";import"./chunk-R7VGZR7L.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};
2
+ import{c as a,d as b,e as c}from"./chunk-TZFHDUVE.mjs";import"./chunk-UHEXA4HI.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};
@@ -132,6 +132,14 @@ export declare function hasDefaultAggPrefix(name: string | null | undefined): bo
132
132
  * canonicalised one: this removes a duplication, it does not restyle a name.
133
133
  */
134
134
  export declare function collapseRepeatedAggPrefix(name: string | null | undefined): string;
135
+ /**
136
+ * TWO COLUMNS, ONE NAME. A row keyed by name keeps only the LAST of them and a lookup by name finds only the FIRST, so the
137
+ * chart and the prompt disagree about which column a name means, and the first column's data cannot be reached. The first
138
+ * keeps its name; the second and later become `Name (2)`, `Name (3)` - the rule the Excel add-in's header reader already
139
+ * applies, so a workbook and a report name the same pair the same way. Exact match, the test a keyed object applies.
140
+ * Returns the names to use, same length and order; unchanged when nothing repeats.
141
+ */
142
+ export declare function tellApartRepeatedNames(names: ReadonlyArray<string | null | undefined>): string[];
135
143
  /**
136
144
  * THE OTHER HALF OF THE RENAME, and the reason it is safe to ship. Code generated before the
137
145
  * collapse existed reads the host's ORIGINAL key - `row["Sum of Sum of Revenue"]` - and a
@@ -156,6 +156,18 @@ export declare class IndexedText implements IValueCollection {
156
156
  * callers construct IndexedText with no arguments and are unaffected.
157
157
  */
158
158
  dedupRows: boolean;
159
+ /**
160
+ * Tell columns that arrive with the same name apart (see setColumns). DEFAULT TRUE. A host may turn it off for a source
161
+ * whose repeated names are the layout's own wording and are resolved before charting.
162
+ */
163
+ tellApartNames: boolean;
164
+ private _renamedRepeats;
165
+ /** Which columns setColumns renamed because their name repeated an earlier column's (index, old name, new name). */
166
+ getRenamedRepeats(): ReadonlyArray<{
167
+ index: number;
168
+ from: string;
169
+ to: string;
170
+ }>;
159
171
  /**
160
172
  * ALSO key each row by the host's ORIGINAL column name, for columns the doubled-prefix
161
173
  * collapse renamed (see setColumns). OFF by default, and it must stay off for anything
@@ -320,6 +332,10 @@ export declare class IndexedText implements IValueCollection {
320
332
  *
321
333
  * Idempotent (a collapsed name has nothing left to collapse), so the matrix-recovery path's
322
334
  * repeated setColumns calls are safe.
335
+ *
336
+ * TWO COLUMNS WITH ONE NAME ARE TOLD APART LAST (tellApartRepeatedNames): the first keeps the
337
+ * name, later ones become `Name (2)`. Last, so a collapsed name that now equals another column's
338
+ * is told apart too. Same seam, same reason: the shape and the rows stay in step. Also idempotent.
323
339
  */
324
340
  setColumns(cols: LLMColumnWithValue[]): void;
325
341
  }
@@ -68,6 +68,12 @@ export interface IngestOptions {
68
68
  * measurement decision, not a formatting one.
69
69
  */
70
70
  dedup?: boolean;
71
+ /**
72
+ * Tell columns that arrive with the same name apart (`Name (2)`). Default true. Set false for a source whose repeated
73
+ * names are the layout's own wording and are resolved before charting (a pivot report read from its cells repeats its
74
+ * value fields' captions under every column item); the columns then keep their names as given.
75
+ */
76
+ tellApartNames?: boolean;
71
77
  /**
72
78
  * For the `objects` decoder: how many rows to scan when discovering column names.
73
79
  * Default 500. Raise it for sparse payloads where late rows introduce new keys.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.133",
3
+ "version": "0.6.135",
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",
@@ -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{R,Z as N,f as L}from"./chunk-R7VGZR7L.mjs";import{a as h,c as x,d as A,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,a++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,a++;continue}if(I(m,o)){a++;continue}if((v.test(m)||V.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return A(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*W(e,o){for(let n of e)yield n?.[o]}function p(e,o,n){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let r=e.length;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>x(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),c=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[s]==="Integer"||c[s]==="Decimal")&&!R(t.name));m.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:c[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new N;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],c[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return p(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return p(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return p(r,b(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{O as a,w as b,G as c,K as d,ee as e};
@@ -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 Se}from"./chunk-U3H6UBOO.mjs";import{a as wt,f as te,g as _e,h as oe,i as Ae,j as ie}from"./chunk-TZ74QIKA.mjs";import{b as St,c as _t,d as At,e as Ct,f as xt}from"./chunk-YDYFP2T4.mjs";import{c as ht,l as yt,n as ye,p as bt,s as se,w as be,x as De,y as Oe,z as Pe}from"./chunk-DTBXJVUG.mjs";import{e as dt,k as pe,m as gt,n as pt,o as he}from"./chunk-3ZAS32F5.mjs";import{b as mt,d as ft}from"./chunk-5HI6TVMM.mjs";import{A as ge,B as ut,E as ct,a as re,b as ee,c as Je,d as me,g as et,h as tt,j as nt,l as rt,m as it,o as st,p as fe,q as ot,r as at,u as ke,w as lt}from"./chunk-CZJ7M6A5.mjs";import{c as Qe,f as Ee}from"./chunk-WC4JINEZ.mjs";var gn=85,pn=60,hn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Le=t=>Math.round(t*10)/10,Ce=t=>t.split("-")[0];function Mt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=ye(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:Le(100*r/n)}}function Mi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Tt(e,t.provinceKind,t.country);if(!se())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let i=be(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return i.status==="resolved"?i.provinceId:null}function Tt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let s=xt(t,e);return s?"US-"+s:null}if(!se())return null;if(e==="admin1-code")return Pe(t)?t.toUpperCase():null;let i=n==null?null:String(n),r=new Set(De(t,i).map(Oe).filter(s=>!!s));return r.size===1?[...r][0]:null}function Ti(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,c=0,f=0,m=C=>{let S=C.toLowerCase();s.has(S)||(s.add(S),a.push(C))},h=C=>C==null||C===""?null:Number(C),w=new Map;return t.forEach((C,S)=>{i[S]=null,r[S]=null;let g=C.country===null||C.country===void 0||String(C.country).trim()===""?null:String(C.country).trim(),y=C.province===null||C.province===void 0?"":String(C.province).trim();if(y){let x=Tt(y,e.provinceKind,g);x?(i[S]=x,r[S]="province",u++):m(y);return}if(!n)return;let A=h(C.lat),p=h(C.lon),_=!1;if(e.locate&&A!==null&&p!==null&&isFinite(A)&&isFinite(p)){_=!0;let x=e.locate(A,p);if(x){i[S]=x,r[S]="coordinates",u++;return}}let b=C.city===null||C.city===void 0?"":String(C.city).trim();if(b&&se()){let x=b.toLowerCase()+""+(g??""),M=w.get(x);if(M||(M=be(b,{country:g}),w.set(x,M)),M.status==="resolved"&&M.provinceId){i[S]=M.provinceId,r[S]="city",u++;return}if(M.status==="ambiguous"){c++,l.has(x)||(l.add(x),o.length<8&&o.push(b));return}m(b);return}_&&f++}),{iso:i,source:r,unmatched:a,matchedRows:u,totalRows:t.length,ambiguousRows:c,ambiguousExamples:o,unplacedPoints:f}}function vt(t,e,n={}){let i=new Map;if(!se()||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 w=s(h[l]);if(!w)continue;let C=r>=0&&s(h[r])||null,S=w+""+(C??""),g=o.get(S);g?g.rows++:o.set(S,{city:w,country:C,rows:1})}if(o.size===0)return null;let u=0,c=0,f=new Set,m=new Map;return o.forEach(h=>{let w=be(h.city,{country:h.country});w.status!=="unmatched"&&c++,!(w.status!=="resolved"||!w.provinceId)&&(u++,f.add(w.provinceId),m.set(w.cc,(m.get(w.cc)||0)+h.rows))}),{signals:{rollupPct:Le(100*u/o.size),regionCount:f.size,countryCount:m.size,...Mt(m)},cityPct:100*c/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 x=a(o);x&&i.set(o,x.signals);return}if(u)return;let c=new Map,f=new Map;for(let x of e){let M=s(x[o]);M&&(c.set(M,(c.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&s(x[r])||null))}if(c.size<3)return;let m=0,h=0,w=0,C=new Set,S=new Map;c.forEach((x,M)=>{if(Pe(M)){m++;let z=M.toUpperCase();C.add(z),S.set(Ce(z),(S.get(Ce(z))||0)+x);return}let W=new Set(De(M,f.get(M)).map(Oe).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];C.add(z),S.set(Ce(z),(S.get(Ce(z))||0)+x)}else W.size>1&&w++});let y=hn.test(l.name.replace(/[_-]+/g," "))?pn:gn,A=100*m/c.size,p=100*h/c.size,_=A>=p,b=_?A:p;if(b<y){if(n.cities===!1)return;let x=a(o);if(!x||x.cityPct<ht||x.distinct<At&&!_t(l.name,St))return;i.set(o,x.signals);return}i.set(o,{kind:_?"admin1-code":"admin1-name",matchPct:Le(b),ambiguous:!_&&w/c.size>.15?!0:void 0,regionCount:C.size,countryCount:S.size,...Mt(S)})}),i}function We(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Fe={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},yn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,bn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,Sn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,_n=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,An=new Set(["de","del","of"]),Cn=new Set(["\u0433","\u0440","r"]),xn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,ze=/^\d+$/;function wn(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 Rt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=wt(e);let n=null,i=yn.exec(e);if(i){if(n=wn(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=Sn.exec(e)){let m=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Fe,form:"cjk",key:m,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=bn.exec(e)){let m=r[2],h=r[4];if(m!==h)return null;let w=m.trim(),C=r[6];if(C&&w!==".")return null;let S=[r[1].length,r[3].length,r[5].length],g=S[0]===4,y=S[2]===4;return g===y||(g?S[1]>2||S[2]>2:S[0]>2||S[1]>2)?null:g&&w==="-"&&m==="-"&&S[1]===2&&S[2]===2?"iso":g&&w==="."&&m==="."&&!C&&!(S[1]===2&&S[2]===2)?null:{...Fe,form:"numeric",key:`num|${g?"y":"x"}|${m}|${C}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:g,sep:m,trail:C}}let s=e.replace(_n,"$1").split(/[\s.,/-]+/).filter(m=>m!==""&&!An.has(m.toLowerCase()));if(s.length===4&&ze.test(s[2])&&Cn.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(m=>ze.test(m)?"N":xn.test(m)?"W":"?").join(""),l=s.map(m=>ze.test(m)?m:""),o=0,u=0,c="",f;if(a==="NWN"&&l[0].length<=2&&l[2].length===4)o=+l[0],c=s[1],u=+l[2],f="dmy";else if(a==="WNN"&&l[1].length<=2&&l[2].length===4)c=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],c=s[1],o=+l[2],f="ymd";else return null;return{...Fe,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:c,namedOrder:f}}var Mn=[31,28,31,30,31,30,31,31,30,31,30,31],Tn=t=>t%4===0&&t%100!==0||t%400===0;function It(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&Tn(t)?29:Mn[e-1]):!1}function vn(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 Nt(t,e={}){let n=(e.floor??1)>=1,i=new Map,r=new Map,s=0,a=null;for(let g of t){if(g==null)continue;if(typeof g!="string"){if(n)return null;s++;continue}let y=g.trim();if(y==="")continue;s++;let A=i.get(y);if(A===void 0&&(A=Rt(y),i.set(y,A)),A===null||A==="iso"){if(n)return null;continue}if(n){if(a===null)a=A;else if(A.key!==a.key)return null}else r.set(A.key,(r.get(A.key)??0)+1)}if(!n){let g=0,y="";for(let[A,p]of r)p>g&&(g=p,y=A);if(g===0||g/s<e.floor)return null;a=[...i.values()].find(A=>A!==null&&A!=="iso"&&A.key===y)??null}if(a===null)return null;let l=a.key,o=[...i.values()].filter(g=>g!==null&&g!=="iso"&&g.key===l),u,c="shape",f=null;if(a.form==="named"){if(u=a.namedOrder,f=Ae(o.map(g=>g.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)u="ymd";else{let g=0,y=0;for(let A of o)A.a>12&&g++,A.b>12&&y++;if(g>0&&y>0)return null;g>0?(u="dmy",c="values"):y>0?(u="mdy",c="values"):a.sep.trim()==="."?(u="dmy",c="shape"):(u=We(e.locale)?"mdy":"dmy",c="locale")}let m=g=>{if(g.form==="named"){let y=f.get(te(g.word));return y===void 0?null:[g.year,y+1,g.day]}return g.yearFirst?[g.a,g.b,g.c]:u==="dmy"?[g.c,g.b,g.a]:[g.c,g.a,g.b]},h=1/0,w=-1/0,C=0;for(let g of o){let y=m(g);if(!y||!It(y[0],y[1],y[2])){if(n)return null;C++;continue}h=Math.min(h,y[0]),w=Math.max(w,y[0])}if(!n&&(r.get(l)-C)/s<e.floor||h>=2400&&w<=2699||h>=1300&&w<=1500)return null;let S={form:a.form,order:u,orderFrom:c,hasTime:o.some(g=>g.clock!==null),read(g){if(typeof g!="string")return null;let y=g.trim();if(y==="")return null;let A=i.get(y);if(A===void 0&&(A=Rt(y),i.set(y,A)),A===null||A==="iso"||A.key!==l)return null;let p=m(A);return!p||!It(p[0],p[1],p[2])?null:vn(p[0],p[1],p[2],A.clock)}};if(a.form!=="named"&&!o.some(g=>g.clock?.meridiem)){let g;a.form==="cjk"?g=a.cjkPattern:a.yearFirst?g=`%Y${a.sep}%m${a.sep}%d${a.trail}`:g=(u==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let y=o.filter(A=>A.clock!==null).length;y===0?S.pattern=g:y===o.length&&(S.pattern=g+(o.every(A=>A.clock.seconds)?" %H:%M:%S":" %H:%M"))}return S}import an from"papaparse";var Rn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},In={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},$e=t=>re(t.normalize("NFC")).toLowerCase(),Nn=new Set(Object.values(Rn).flatMap(t=>(t??[]).map($e))),En=new Set(Object.values(In).flatMap(t=>(t??[]).map($e)));function Et(t){let e=!1,n=!1;for(let i of t){let r=$e(i);Nn.has(r)?e=!0:En.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var kn=["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"],Dn=["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"],On=["latitude","longitude"],Pn=["latitude","longitude"];function Q(t){return re(t)}var Ot=["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"],Ln=["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"],Fn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],zn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],xe=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 Be(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Pt=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Be(Ot)+")\\s+)","i");function kt(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 Wn="[\u2013\u2014-]";function Lt(t){let e=t.filter(r=>!kt(r)),n=t.filter(kt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+Wn+"\\s*)("+Be(e)+")"),n.length&&i.push("\\s*("+Be(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Ge=Lt(Fn),$n=Lt(zn);function we(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 Ft(t){let e=Q(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of Ln)if(e.startsWith(r+" "))return xe[r]??"avg";for(let r of Ot)if(e.startsWith(r+" ")||e===r)return xe[r]??"sum";let n=we(e,$n);if(n)return xe[n.label]??"avg";let i=we(e,Ge);return i?xe[i.label]??"sum":null}var Bn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Gn=new RegExp("\\b("+kn.join("|")+")\\b|("+Dn.join("|")+")$","i"),Kn=new RegExp("\\b("+On.join("|")+")\\b|("+Pn.join("|")+")$","i");function Te(t){if(!t)return"";let e=String(t),n=Q(e),i=Pt.exec(n);if(i)return e.slice(i[0].length).trim();let r=we(n,Ge);return(r?e.slice(0,r.base.length):e).trim()}function Vn(t){if(!t)return!1;let e=Q(String(t));return Pt.test(e)||we(e,Ge)!==null}var Un=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Dt=new RegExp("^\\s*("+[...Un].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ke(t){if(t==null)return"";let e=String(t),n=Dt.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=Dt.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 Me={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 "]},zt=new RegExp("^("+Object.keys(Me).join("|")+")\\((.+)\\)$");function Wt(t){if(!t)return[];let e=zt.exec(String(t).trim());if(!e)return[];let n=Me[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 $t(t,e,n){let i=zt.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(Me[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 c of Object.values(Me))for(let f of c)if(!s.has(f)&&a===f+u)return!0}}return!1}function Hn(t){let e=Te(t);return e.length===0?"":e.replace(Bn," ")}function Bt(t,e){if(!e)return!1;let n=Te(e);return t.test(Q(Hn(e)))||t.test(Q(n))||t.test(Q(ee(n).join(" ")))}function Gt(t){return Bt(Kn,t)}function Yn(t){return Bt(Gn,t)||Gt(t)}var Kt=/int|double|decimal|single|float|number|currency|money/i;function jn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Kt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Xn(t){return t?.isMeasure===!0||Kt.test(String(t?.dataType??""))}function Vt(t){let e=t??{},n=jn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Gt(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}:Yn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Ut(t){let e=Vt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Xn(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 Pi(t){return Ut(t)[0]}function Li(t,e){return Ut(t).indexOf(e)>=0}function Fi(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 qn={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"]},Zn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Qn=["num\xE9ro"],Jn=t=>t.normalize("NFC").toLowerCase();function er(t,e,n,i){let r=Ee(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<it?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?nt(t,n).includes(e)?"word":null:r.script==="Hang"?rt(t,e)?"suffix":null:r.compounds&&tt(t,e,et)?"suffix":null}function Ht(t){let e=String(t??"").trim();if(!e)return null;let n=me(e),i=me(Te(e));for(let[r,s]of Object.entries(qn)){let a=Zn.includes(r),l=a?i:n;for(let o of s){let u=Qn.includes(o)||!!Ee(r)?.foldSensitive,c=u?l.words:l.folded;if(c.length===0)continue;let f=u?Jn(o):me(o).folded.join(" "),m=er(a?c[0]:c[c.length-1],f,r,a);if(m)return{lang:r,word:o,view:m}}}return null}var tr=[["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 ve(t){for(let[e,n]of tr)if(n.test(t))return e;return null}var nr=[{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]]}],Re=new Map;function Yt(t,e,n,i){let r=Re.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);ve(u)===n&&(i&&!i.test(u)||s.push(u))}return Re.set(t,s),s}function rr(t){let n=t.codePointAt(0);for(let a=0;a<9&&ve(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),r=Re.get(i);if(r)return r;let s=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);ve(l)==="Nd"&&s.push(l)}return Re.set(i,s),s}function ir(t,e){if(e==="Nd")return rr(t);for(let r of nr)if(r.test.test(t))return Yt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Yt("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function sr(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 or=/^[\p{L}\p{M}\p{Nd}]$/u,jt=/^[\p{L}\p{Nd}]$/u;function Xt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=c=>{let f=ve(c);return!f||!or.test(c)?c:sr(ir(c,f),n,c,e)},r=c=>{let f=[];for(let m of c)f.push(i(m)),jt.test(m)&&e()<.2&&f.push(i(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<m;h++)for(let w=0;w<5;w++){let C=Math.floor(e()*f.length);if(jt.test(f[C])){f.splice(C,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 ar=/^[A-Za-z_$][A-Za-z0-9_$]*$/,lr=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ur=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 ae(t,e){if(!t||!e)return!1;let n=lr(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:ar.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function cr(t){return!!t&&ur.test(t)}function Vi(t,e,n){return t?cr(t)?[...e]:[...n,...e].some(i=>ae(t,i))?e.filter(i=>ae(t,i)):[...e]:[]}var dr=5,mr=6,fr=3,ne=864e5,gr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,pr=/^(\d{4})[-/](\d{1,2})$/,hr=/^(\d{4})[-\s]?Q([1-4])$/i,yr=/^Q([1-4])[-\s](\d{4})$/i,br=/^(\d{4})$/,Sr=/^(\d{4})(0[1-9]|1[0-2])$/,_r=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Ar=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Cr=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ue(t,e,n){let i=te(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=_e(a)[i];if(l!==void 0)return l+1}let r=n?.get(i);if(r!==void 0)return r+1;let s=oe(t);if(s.length>0){if(s.every(o=>o.month===s[0].month))return s[0].month+1;let a=Qe(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function xr(t){let e=pe(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:j(n.year,(n.n-1)*3+1,1)}function j(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 wr(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 c=+r[u+1];o==="Y"?s=c:o==="m"?a=c:l=c}),s?j(s,a,l):null}function X(t,e,n,i){let r=(t??"").trim();if(r==="")return null;if(e){let o=wr(r,e);return o||null}let s=gr.exec(r);if(s)return j(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=hr.exec(r),s)return j(+s[1],(+s[2]-1)*3+1,1);if(s=yr.exec(r),s)return j(+s[2],(+s[1]-1)*3+1,1);if(s=pr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return j(+s[1],+s[2],1);if(s=_r.exec(r),s)return j(+s[1],+s[2],+s[3]);if(s=Sr.exec(r),s)return j(+s[1],+s[2],1);if(s=br.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?j(o,1,1):null}let a=xr(r);if(a)return a;if(s=Ar.exec(r),s){let o=Ue(s[1],n,i);if(o)return j(+s[2],o,1)}if(s=Cr.exec(r),s){let o=Ue(s[2],n,i);if(o)return j(+s[1],o,1)}let l=ie(r);if(l){let o="month"in l?l.month:Ue(l.word,n,i);if(o)return j(l.year,o,1)}return null}function qt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Zt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/ne),i=Math.floor(n/7),r=i*5,s=t+i*7*ne;for(;s<e;)qt(s)&&r++,s+=ne;return r}function Mr(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 Tr(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 le(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*ne));case"weekday":return Zt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/ne);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function Qt(t,e){return He(t,e)?.cadence??null}function He(t,e){let n=e?.gapFactor??dr,i=0,r=0,s=new Map,a=Array.from(t),l;if(!e?.pattern){let p=[];for(let _ of a){if(_==null||_==="")continue;let b=ie(String(_));b&&"word"in b&&p.push(b.word)}p.length>0&&(l=Ae(p,e?.locale)??void 0)}for(let p of a){if(p==null||p==="")continue;i++;let _=X(String(p),e?.pattern,e?.locale,l);_&&(r++,s.set(_.ms,_))}let o=[...s.values()].sort((p,_)=>p.ms-_.ms);if(o.length<fr||i>0&&r/i<.8)return null;let u=o[o.length-1].ms-o[0].ms;if(u<=0)return null;let c=[];for(let p=1;p<o.length;p++)c.push(o[p].ms-o[p-1].ms);let f=Mr(c);if(!(f>0))return null;let m=Tr(f/ne);m==="day"&&u>=7*ne&&o.every(p=>qt(p.ms))&&Zt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(m="weekday");let h=m==="irregular"?o.length:le(o[0],o[o.length-1],m,f)+1,w=1,C=1,S=[],g=o[0],y=1;for(let p=1;p<o.length;p++){let _=le(o[p-1],o[p],m,f);_>w&&(w=_),m!=="irregular"&&_>n?(C++,S.push({from:g.iso,to:o[p-1].iso,points:y}),g=o[p],y=1):y++}S.push({from:g.iso,to:o[o.length-1].iso,points:y});let A={grain:m,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:C,largestGapUnits:w,gapFactor:n};return e?.includeBounds&&S.length<=mr&&(A.runBounds=S),{cadence:A,points:o,stepMs:f}}var vr=8,Rr=.5,Ir=200,Nr=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"]),Er=["category","classification","segment","status","priority","severity","channel"],kr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function Dr(t){let e=ee(t);if(e.length===0)return!1;let n=e[e.length-1];return Nr.has(n)?!0:Er.some(i=>n.length>i.length&&n.endsWith(i))}function Or(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>Ir?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":he(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&kr.has(Se(e))?"identifier":!t.geoKind&&Dr(t.name)?"attribute":"entity"}function tn(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(Or(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 Jt=t=>t<10?"0"+t:String(t);function en(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Jt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Jt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function nn(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let _=0;_<i;_++)e[_]&&r.add(e[_]);let s=He(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=le(l,s.points[s.points.length-1],a,s.stepMs)+1;if(o!==s.cadence.expectedPoints)return null;let u=new Map;for(let _ of r){let b=X(_,t.pattern,t.locale);if(!b)continue;let x=le(l,b,a,s.stepMs);x>=0&&x<o&&u.set(_,{idx:x,stamp:b})}let c=new Map;for(let _=0;_<i;_++){let b=n[_];if(!b)continue;let x=u.get(e[_]);if(!x)continue;let M=c.get(b);M||(M={seen:new Set,lo:x.idx,hi:x.idx,loStamp:x.stamp,hiStamp:x.stamp,order:c.size},c.set(b,M)),M.seen.add(x.idx),x.idx<M.lo&&(M.lo=x.idx,M.loStamp=x.stamp),x.idx>M.hi&&(M.hi=x.idx,M.hiStamp=x.stamp)}if(c.size<2)return null;let f=0;for(let _ of c.values())f+=_.seen.size;if(f/(c.size*o)<(t.minFill??Rr))return null;let m=[],h=new Set,w=0,C=0,S=0,g=0,y=0,A=1;for(let[_,b]of c){for(let z of b.seen)h.add(z);if(b.seen.size>=o)continue;let x=[...b.seen].sort((z,q)=>z-q),M=1;for(let z=1;z<x.length;z++)M=Math.max(M,x[z]-x[z-1]);let W={key:_,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};m.push(W),W.before>0&&w++,W.after>0&&C++,W.interior>0&&S++,g=Math.max(g,W.before),y=Math.max(y,W.after),A=Math.max(A,M)}if(m.length===0)return null;m.sort((_,b)=>_.coverage-b.coverage||_.acc.order-b.acc.order);let p=m.slice(0,t.maxListed??vr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:c.size,incompleteSeries:m.length,lateStarts:w,earlyEnds:C,withHoles:S,columnWideMissing:o-h.size,maxMissingBefore:g,maxMissingAfter:y,largestGap:A,series:p.map(_=>{let b={};return t.includeNames&&(b.name=_.key),t.includeDates&&(b.first=en(_.acc.loStamp,a),b.last=en(_.acc.hiStamp,a)),b.missingBefore=_.before,b.missingAfter=_.after,b.missingInterior=_.interior,b.largestGap=_.gap,b.coverage=Math.round(_.coverage*1e3)/1e3,b}),more:m.length-p.length}}var Ie=6;function ue(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 Pr(t){let e=t.length;if(e<Ie)return null;let n=t[0],i=t[0],r=0;for(let p of t)p<n&&(n=p),p>i&&(i=p),r+=p;if(n===i)return null;let s=ue(t.map(Math.abs));if(s===0)return null;let a=[];for(let p=1;p<e;p++)a.push(t[p]-t[p-1]);let l=ue(a.map(Math.abs))/s,o=(e-1)/2,u=r/e,c=0,f=0,m=0;for(let p=0;p<e;p++)c+=(p-o)*(t[p]-u),f+=(p-o)*(p-o),m+=(t[p]-u)*(t[p]-u);m/=e;let h=c/f,w=u-h*o,C=t.map((p,_)=>p-(w+h*_)),S=C.reduce((p,_)=>p+_,0)/e,g=0,y=0;for(let p=0;p<e;p++)g+=(C[p]-S)*(C[p]-S),p>0&&(y+=(C[p]-C[p-1])*(C[p]-C[p-1]));return g/=e,y/=e-1,{vnDetrended:g<=m*1e-12?2:y/g,relStep:l}}function Ye(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 c=e[u],f=i[u];if(c===null||f===null||!Number.isFinite(f))continue;let m="";if(n&&(m=n[u]??"",m===""))continue;let h=s.get(m);h||s.set(m,h=new Map),h.set(c,(h.get(c)??0)+f)}let a=[],l=[],o=[];for(let u of s.values()){let c=[...u.entries()].sort((m,h)=>m[0]-h[0]).map(m=>m[1]),f=Pr(c);f&&(a.push(f.vnDetrended),l.push(f.relStep),o.push(c.length))}return a.length===0?null:{series:a.length,points:Math.round(ue(o)),vnDetrended:Math.round(ue(a)*1e3)/1e3,relStep:Math.round(ue(l)*1e4)/1e4}}function ns(t){let e=t.times.map(n=>X(n,t.pattern,t.locale)?.ms??null);return Ye({stamps:e,series:t.series,values:t.values})}var Lr=5e5,Fr=8,zr=4,Wr=5,je=1,Xe=2,$r=4,Br=8;function Gr(t,e,n){let[i,r]=[...t];if(e.isTemporal){let s=X(i,e.temporalTextPattern,n),a=X(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 Kr(t,e,n){let{rows:i,text:r,locale:s}=t,a=Gr(n.values,n,s),l=new Uint8Array(i.length),o=0;for(let u=0;u<i.length;u++){let c=r(i[u][e]);c===a.a?l[u]=1:c===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 Ur(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&je&&r.keysA++,a&Xe&&r.keysB++,(a&(je|Xe))===(je|Xe)&&r.keysBoth++,a&$r&&r.dupA++,a&Br&&r.dupB++}return r}function Hr(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 rn=t=>t==null||typeof t=="string"&&t.trim()==="";function Yr(t,e,n){if(t===e)return!0;let i=rn(t),r=rn(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 sn(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Lr)return null;let r=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=Wr).sort((b,x)=>(x.c.identifierNamed?1:0)-(b.c.identifierNamed?1:0)||x.c.distinct-b.c.distinct||b.i-x.i).slice(0,Fr),s=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,zr);if(r.length===0||s.length===0)return null;let a=s.map(({c:b,i:x})=>Kr(t,x,b)),l=null;for(let{i:b}of r){let x=Vr(t,b);for(let M=0;M<s.length;M++){if(s[M].i===b)continue;let W=Ur(x.ids,a[M].code,x.dict.size);W.keysBoth<1||(!l||Hr(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:M,ids:x.ids,dict:x.dict})}}if(!l)return null;let{ids:o,dict:u,tally:c}=l,f=a[l.setNo],m=s[l.setNo].i,h=u.size,w=new Int32Array(h).fill(-1),C=new Int32Array(h).fill(-1);for(let b=0;b<i;b++){let x=f.code[b],M=o[b];x===0||M<0||(x===1?w[M]<0&&(w[M]=b):C[M]<0&&(C[M]=b))}let S=[];for(let b=0;b<n.length;b++)b!==l.keyIdx&&b!==m&&S.push(b);let g=0;for(let b=0;b<h;b++){let x=w[b],M=C[b];if(x<0||M<0)continue;let W=e[x],z=e[M],q=!0;for(let J of S)if(!Yr(W[J],z[J],t.text)){q=!1;break}q&&g++}let y=g===c.keysBoth?100:g===0?0:Math.min(99,Math.max(1,Math.round(g/c.keysBoth*100))),A=new Map,p=new Map;for(let[b,x]of u){let M=w[x]>=0,W=C[x]>=0;if(!M&&!W)continue;let z=mt(b);ft(z)&&(M&&A.set(z,(A.get(z)??0)+1),W&&p.set(z,(p.get(z)??0)+1))}let _=b=>{let x=0;for(let M of b.values())M>=2&&(x+=M);return x};return{key:l.keyIdx,discriminator:m,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[m].name,keysA:c.keysA,keysB:c.keysB,keysBoth:c.keysBoth,duplicateKeysA:c.dupA,duplicateKeysB:c.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:_(A),looseCollisionsB:_(p),setOrder:f.setOrder}}}var jr=t=>t==="Integer"||t==="Decimal";function Xr(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 qr(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!jr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function on(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=Xr(i);if(s.length===0)return e;let a=qr(i,new Set(s));if(a.length===0)return e;let l=s.map(o=>{let[u,c]=i[o].twoValues,f=new Uint8Array(n.length);for(let m=0;m<n.length;m++){let h=r(n[m][o]);f[m]=h===u?1:h===c?2:0}return f});for(let o of a){let u=new Float64Array(n.length),c=0;for(let y=0;y<n.length;y++){let A=n[y][o],p=A==null||A===""?NaN:typeof A=="number"?A:parseFloat(A);u[y]=p,p===p&&p!==1/0&&p!==-1/0&&c++}if(c<2)continue;let f=new Float64Array(c);for(let y=0,A=0;y<n.length;y++){let p=u[y];p===p&&p!==1/0&&p!==-1/0&&(f[A++]=p)}f.sort();let m=new Float64Array(c),h=0;for(let y=0;y<c;y++)(y===0||f[y]!==f[y-1])&&(m[h++]=f[y]);let w=new Int32Array(n.length).fill(-1);for(let y=0;y<n.length;y++){let A=u[y];if(!(A===A&&A!==1/0&&A!==-1/0))continue;let p=0,_=h-1;for(;p<_;){let b=p+_>>>1;m[b]<A?p=b+1:_=b}w[y]=p}let C=[],S=new Int32Array(h),g=new Int32Array(h);for(let y=0;y<s.length;y++){let A=l[y];S.fill(0),g.fill(0);let p=0,_=0;for(let Y=0;Y<n.length;Y++){let U=w[Y];U<0||(A[Y]===1?(S[U]++,p++):A[Y]===2&&(g[U]++,_++))}if(p===0||_===0)continue;let b=p<=_,x=b?p:_,M=b?_:p,W=b?S:g,z=b?g:S,q=0,J=0,ce=0;for(let Y=0;Y<h;Y++){let U=W[Y],d=z[Y];q+=U*(J+.5*d),J+=d,U+d>=2&&(ce+=U+d)}C.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(q/(x*M)*1e4)/1e4,nMinority:x,nMajority:M,ties:ce})}C.length>0&&e.set(o,C)}return e}var ln=12,Zr=100,Qr=.3,Jr=.9,ei=120,ti=1900,ni=2100,ri=0,ii=20,si=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ne(t){if(!t)return!1;let e=ee(t);return e.length===0?!1:si.has(e[e.length-1])?!0:Ht(t)!==null}var oi=new Set(["year","yr","fy"]),ai=t=>ee(t).some(e=>oi.has(e))||dt(t)!==null,li=/^(?:(?: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 qe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Ze(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 ui=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ci=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,di=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function dn(t,e){let n=[],i=0,r=mi(t,e,n,()=>{i++});if(r)return r;if(i>0||n.length<2)return null;let s=Nt(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 mi(t,e,n,i){let r=0,s=0,a=0,l=0,o=0,u="",c=0,f="",m=0,h=0,w=0,C=0,S=!1;for(let b of t){if(b==null)continue;let x=String(b).trim();if(x==="")continue;r++,n.push(x);let M;if(M=ui.exec(x)){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=ci.exec(x)){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=di.exec(x)){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],c++,W>12&&w++,z>12&&C++,M[5]!==void 0&&m++,M[7]!==void 0&&h++)}if(r>=200)break}if(r<2||(s+o+c)/r<.8||(s>0?1:0)+(o>0?1:0)+(c>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(w>0&&C>0)return null;let A,p;w>0?(A=!0,p="values"):C>0?(A=!1,p="values"):f==="."?(A=!0,p="shape"):(A=!We(e),p="locale");let _=A?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return m===c?{pattern:_+(h===c?" %H:%M:%S":" %H:%M"),orderFrom:p}:{pattern:_,orderFrom:p}}function fi(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=te(n);return i.length>0&&e[i]!==void 0}function gi(t,e){let n=new Map,i=new Map;for(let l of t){let o=ie(l);if(!o||"month"in o)continue;let u=oe(o.word),c=u.some(m=>m.lang==="en"),f=te(o.word);for(let m of new Set(u.map(h=>h.lang)))m!=="en"&&(n.has(m)||(n.set(m,new Set),i.set(m,new Set)),n.get(m).add(f),c||i.get(m).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=ie(l);if(!o)continue;if("month"in o){s++;continue}let u=oe(o.word);if(u.length===0)continue;let c=u.some(f=>f.lang==="en");for(let f of r)(c||u.some(m=>m.lang===f))&&a.set(f,a.get(f)+1)}return s+Math.max(0,...a.values())}var pi=/(?:19|20)[0-9]{2}/;function hi(t){let e=new Map,n=0;for(let r of t){if(!pi.test(re(r)))continue;let s=new Set(pe(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 yi(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&&ai(n)||o&&r>=3&&r===a-s+1)return!0;let u=qe(s)&&qe(a),c=Ze(s)&&Ze(a);if(u||c){if(!t.sampleValues)return!0;let f=0,m=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let w=Number(String(h).trim());if(Number.isFinite(w)&&(u?qe(w):Ze(w))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let s=t.locale?_e(t.locale):null,a=0,l=0,o=[],u=[];for(let c of t.sampleValues){if(c==null||c==="")continue;a++;let f=String(c).trim();if(o.push(f),li.test(f)||fi(f,s)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+hi(u)+gi(o,u))/a>=.8||dn(o,t.locale)!==null)return!0}return!1}function bi(t){let e=Q((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":Ft(t)}function Si(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:s,maxNum:a,discourageAgg:l}=t,o=100,u=.01,c="";for(let m of r){if(m.distinct<2||m.distinct>o)continue;let h=r.filter(y=>y.idx!==m.idx).map(y=>y.idx),w=new Map;for(let y of e){let A=y[n];if(typeof A!="number"||!Number.isFinite(A))continue;let p=h.length?h.map(b=>String(y[b])).join(c):"",_=w.get(p);_||(_={sum:0,cset:new Set},w.set(p,_)),_.sum+=A,_.cset.add(String(y[m.idx]))}let C=0,S=0,g=0;for(let y of w.values())y.cset.size<2||(g++,Math.abs(y.sum-100)<=100*u?C++:Math.abs(y.sum-1)<=1*u&&S++);if(g>=2&&(C/g>=.9||S/g>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=bi(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 mn(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:s,prec:a,maxval:l,minval:o}=t,u=l-o+1,c=u>0?r/u:1,f=s>0?r/s:0,m=e==="Decimal"||a>0;return!n&&Ne(i)?"Categorical":c>=Jr&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(gt(i)&&r<=ei||o>=ti&&l<=ni||o>=ri&&l<=ii)?"Ordinal":n?"Continuous":!m&&Number.isFinite(u)&&r>ln&&r===s&&u===r?"Categorical":r>ln&&(m||r>=Zr||f>=Qr)?"Continuous":"Categorical"}function un(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:mn({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 _i(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 cn=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;_preStatsFields=null;_statsAddedKeys=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??""))||ut(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 c=u[i],f=this.STR(c);if(f!=""&&(r.add(f),s++,(l===null||c<l)&&(l=c),(o===null||c>o)&&(o=c),n.dataType=="Decimal")){let m=this.getPrecision(c);m>a&&(a=m)}}e[i]=un(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 lt(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;this._preStatsFields&&this._statsAddedKeys&&this._preStatsFields.length===this._cols.length?this._cols.forEach((d,T)=>{let E=this._preStatsFields[T];if(!(!d||!E)){for(let k of this._statsAddedKeys[T]??[])delete d[k];for(let k of Object.keys(E))d[k]=E[k]}}):this._preStatsFields=this._cols.map(d=>d?{...d}:null);let i=this._cols.map(d=>new Set(d?Object.keys(d):[])),r=0,s=parseInt(e),a=this.wallClockColumnIndexes(),l=[],o=[],u=[];for(let d of this._cols){let T=new Map,E=[],k=0,v=0,O=0,F=null,P=null,D=null,G=!1,K=!0,I=!0,N=null,V=!1,L=a.has(r);for(let R of this._rows){let $=R[r],B=L&&$ instanceof Date?ge($):$,H=this.STR(B);if(H!=""){if(k+=H.length,T.set(H,(T.get(H)||0)+1),v++,d.dataType=="Integer"||d.dataType=="Decimal"||d.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),d.dataType=="Integer"||d.dataType=="Decimal"){if(D===null?D=B:D+=B,d.dataType=="Decimal"){let Z=this.getPrecision(B);Z>O&&(O=Z)}E.push(B)}else G=G||this.hasTimeComponent(B);V&&(B<N?K=!1:B>N&&(I=!1)),N=B,V=!0}}if(v>=3&&(K&&!I?d.sortedDirection="asc":I&&!K?d.sortedDirection="desc":d.sortedDirection="none"),v>0&&T.size>0&&!d.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(d.modalShare=R/v,d.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(de=>st(de).trim().toLowerCase()).sort(),Z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(de=>B[0]===de[0]&&B[1]===de[1]),fn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(d.name);(Z||fn)&&(d.isBinaryFlag=!0)}}else d.isMeasure&&(d.dataType==="Integer"||d.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(d.isBinaryFlag=!0);if(d.dataType=="DateTime"&&(d.dateWithTime=G,G&&ct(L?this._rows.map(R=>R[r]instanceof Date?ge(R[r]):R[r]):this._rows.map(R=>R[r]))?d.timeOfDayOnly=!0:delete d.timeOfDayOnly),d.isTemporal=yi({dataType:d.dataType,name:d.name,isMeasure:d.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),d.isTemporal&&d.dataType==="String"&&!d.isMeasure){let R=dn(T.keys(),n);R&&(d.temporalTextPattern=R.pattern)}if(d.timeOfDayOnly)delete d.temporalCadence;else if(d.isTemporal&&!d.isMeasure){let R=Qt(T.keys(),{includeBounds:s>=20,pattern:d.temporalTextPattern,locale:n});R&&(d.temporalCadence=R)}this.updateColumnStats10(s,d,v,T,O,P,F),this.updateColumnStats20(s,E,v,D,d,k,G,F,P,O,T,n),un(d,this._declaredDimensions.has(d),{distinct:T.size,nonblank:v,prec:O,minval:F,maxval:P})&&(d.isMeasure=!0,d.valueNature="Continuous",d.geoKind=void 0,d.geoMatchPct=void 0,d.geoAmbiguous=void 0,d.dominantGeoRegion=void 0,d.dominantGeoRegionPct=void 0,d.geoRegionCount=void 0),l[r]=d.isMeasure||T.size>2e3?null:new Set(T.keys()),o[r]=T.size,u[r]=T.size===2?[...T.keys()].sort():null,r++}vt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((d,T)=>{let E=this._cols[T];d.kind&&(E.geoKind=d.kind,E.geoMatchPct=d.matchPct,d.ambiguous&&(E.geoAmbiguous=!0)),d.rollupPct!==void 0&&(E.admin1RollupPct=d.rollupPct),d.regionCount!==void 0&&(E.admin1RegionCount=d.regionCount),d.countryCount!==void 0&&(E.admin1CountryCount=d.countryCount),d.dominantRegion&&(E.dominantGeoRegion=d.dominantRegion,E.dominantGeoRegionPct=d.dominantRegionPct)});let c=this.getGeoExtent();if(c&&c.dominantFrame&&this._geoExtentLatIdx>=0){let d=this._cols[this._geoExtentLatIdx];d.geoKind||(d.dominantGeoRegion=c.dominantFrame,d.dominantGeoRegionPct=c.dominantFramePct,this.deriveProvinces&&(d.admin1RollupPct=c.dominantFramePct))}let f=[];this._cols.forEach((d,T)=>{d.isMeasure||f.push({idx:T,distinct:d.distinctCount??0,name:d.name})}),this._cols.forEach((d,T)=>{if(!d.isMeasure)return;let E=typeof d.lowValue=="number"?d.lowValue:null,k=typeof d.highValue=="number"?d.highValue:null,v=Si({rows:this._rows,measureColIdx:T,measureName:d.name,candidateDims:f,minNum:E,maxNum:k,discourageAgg:!!d.discourageAggregationAcrossGroups});d.additivity=v.additivity,v.partOfWholeDim&&(d.partOfWholeDim=v.partOfWholeDim)});let m=50,h=4,w=f.filter(d=>d.distinct>=2&&d.distinct<=m);this._cols.forEach((d,T)=>{if(!d.isMeasure)return;let E=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let V=typeof N=="number"?N:parseFloat(N);isNaN(V)||E.push(V)}if(E.length===0)return;let k=[...E].sort((I,N)=>I-N);if(k[0]===k[k.length-1])d.relativeDispersion=0;else if(k.length>=h){let I=fe(k,.5),N=fe(k,.1),V=fe(k,.9);d.relativeDispersion=Math.abs(I)>1e-9?Math.round((V-N)/Math.abs(I)*1e3)/1e3:void 0}else d.relativeDispersion=void 0;let v=[];for(let I of w){let N=new Set;for(let V of this._rows){let L=V[T];L==null||L===""||N.add(this.STR(V[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(d.nonBlankGroups=v);let O=0;for(let I of E)O+=I;O/=E.length;let F=0;for(let I of E)F+=(I-O)*(I-O);if(F<=1e-12)return;let P=[],D=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),V=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return V(.75)-V(.25)},K=G(E);for(let I of w){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])+"",Z=N.get(H);Z?(Z.s+=B,Z.n++,Z.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let V=0;for(let R of N.values()){let $=R.s/R.n;V+=R.n*($-O)*($-O)}P.push({otherColumn:I.name,eta2:Math.round(V/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(K)&&K>1e-9){let R=(Math.max(...L)-Math.min(...L))/K;D.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(d.groupDiscrimination=P),D.length>0&&(d.spreadDiscrimination=D)});let C=.97,S=.8,g=8,y=5,A=this._cols.map((d,T)=>({c:d,i:T})).filter(d=>d.c.isMeasure);for(let d=0;d<A.length;d++)for(let T=d+1;T<A.length;T++){let E=A[d].i,k=A[T].i,v=0,O=0,F=0,P=0,D=0,G=0;for(let L of this._rows){let R=L[E],$=L[k];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++,O+=B,F+=H,P+=B*B,D+=H*H,G+=B*H)}if(v<y)continue;let K=v*P-O*O,I=v*D-F*F;if(K<=1e-12||I<=1e-12)continue;let N=(v*G-O*F)/Math.sqrt(K*I),V=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[A[d].c,A[T].c])(L.maxAbsMeasureCorrelation===void 0||V>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=V);if(Math.abs(N)>=C){let L=A[d].c,R=A[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)>=S){let L=A[d].c,R=A[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:d}of A)d.correlatedWithMeasures&&(d.correlatedWithMeasures.sort((T,E)=>Math.abs(E.r)-Math.abs(T.r)||(T.otherColumn<E.otherColumn?-1:1)),d.correlatedWithMeasures.length=Math.min(d.correlatedWithMeasures.length,g));for(let d=0;d<this._cols.length;d++){let T=l[d];if(!T||T.size===0)continue;let E=[];for(let k=0;k<this._cols.length;k++){if(k===d)continue;let v=l[k];if(!v||v.size===0)continue;let O=0;for(let P of T)v.has(P)&&O++;let F=Math.round(O/T.size*100);F>0&&E.push({otherColumn:this._cols[k].name,percentShared:F})}E.length>0&&(this._cols[d].sharedValueRatioWithOthers=E)}let p=50,_=[];for(let d=0;d<this._cols.length;d++){let T=l[d];T&&T.size>=2&&T.size<=p&&_.push(d)}if(_.length>=2){let d=new Map,T=(k,v)=>k+":"+v;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++)d.set(T(_[k],_[v]),new Map);for(let k of this._rows)for(let v=0;v<_.length;v++){let O=this.STR(k[_[v]])+"";for(let F=v+1;F<_.length;F++){let P=""+this.STR(k[_[F]]),D=d.get(T(_[v],_[F])),G=O+""+P;D.set(G,(D.get(G)??0)+1)}}let E=new Map;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++){let O=_[k],F=_[v],P=l[O].size,D=l[F].size,G=d.get(T(O,F)),K=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(K/(P*D)*100),V=K===P,L=K===D;if((this._cols[O].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:V,minCellCount:I,distinctCombinations:K}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[O].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:K}),V&&P>D){let R=E.get(O);(!R||D<R.card)&&E.set(O,{name:this._cols[F].name,card:D,ratio:D/P})}if(L&&D>P){let R=E.get(F);(!R||P<R.card)&&E.set(F,{name:this._cols[O].name,card:P,ratio:P/D})}}for(let[k,v]of E)this._cols[k].primaryParentColumn=v.name,this._cols[k].nestingRatio=Math.round(v.ratio*100)/100}let b=6,x=this._rows.length;for(let d=0;d<this._cols.length;d++){let T=this._cols[d];if(T.isMeasure||T.primaryParentColumn)continue;let E=T.distinctCount??0;if(E<=p||x>0&&E>=x)continue;let k=[];for(let v=0;v<this._cols.length;v++){if(v===d)continue;let O=this._cols[v];if(O.isMeasure)continue;let F=O.distinctCount??0;F<2||F>=E||k.push(v)}k.sort((v,O)=>(this._cols[v].distinctCount??0)-(this._cols[O].distinctCount??0));for(let v of k.slice(0,b)){let O=new Map,F=!0;for(let D of this._rows){let G=this.STR(D[d])+"",K=this.STR(D[v])+"",I=O.get(G);if(I===void 0)O.set(G,K);else if(I!==K){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/E*100)/100;break}}let M=.01,W=.05,z=.95,q=8,J=8,ce=6,Y=500,U=[];for(let d=0;d<this._cols.length&&U.length<J;d++){let T=this._cols[d].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(d)}if(U.length>=3&&this._rows.length>=q){let d=Math.min(this._rows.length,Y),T=U.map(P=>{let D=[];for(let I=0;I<d;I++){let N=this._rows[I][P],V=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(V))return null;D.push(V)}let G=D[0],K=!1;for(let I of D)if(I!==G){K=!0;break}return K?D:null}),E=U.map((P,D)=>D).filter(P=>T[P]!==null),k=P=>{let D=P.slice().sort((K,I)=>K-I),G=D.length>>1;return D.length%2?D[G]:(D[G-1]+D[G])/2},v=null,O=[],F=P=>{if(O.length>=3){let D=O.map(N=>T[N]),G=D[0].length,K=new Array(G);for(let N=0;N<G;N++){let V=0;for(let L of D)V+=L[N];K[N]=V}let I=k(K);if(I>0){let N=0;for(let L of K)Math.abs(L-I)<=I*M&&N++;let V=N/G;if(V>=z){let L=1;for(let R of D){let $=k(R)/I;$<L&&(L=$)}L>=W&&(!v||O.length>v.cols.length)&&(v={cols:O.slice(),total:I,matched:V})}}}if(!(O.length>=ce))for(let D=P;D<E.length;D++)O.push(E[D]),F(D+1),O.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(K=>this._cols[U[K]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let K of P.cols)this._cols[U[K]].constantSumGroup=G}}return this.applyTwoSetPairing(n,l),this.applyScoreSeparation(o,u),this.applySeriesCompleteness(s,n,l),this.applyMeasurePersistence(n,l),this._statsAddedKeys=this._cols.map((d,T)=>d?Object.keys(d).filter(E=>!i[T].has(E)):[]),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=sn({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:Ne(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=on({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:Ne(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,c)=>({c:u,i:c})).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:c}of r){let f=nn({periods:this._rows.map(m=>this.STR(m[c])),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:Ne(a.name),values:o,rows:this._rows.length,locale:e}))});let s=tn(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<Ie)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 c=this._rows.map(f=>X(this.STR(f[o]),u.temporalTextPattern,e)?.ms??null);new Set(c.filter(f=>f!==null)).size<Ie||(r=o,s=c)}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 m=f[o];if(m==null||m==="")return null;let h=typeof m=="number"?m:parseFloat(String(m).replace(/,/g,""));return Number.isFinite(h)?h:null}),c=Ye({stamps:s,series:l,values:u});c&&(this._cols[o].persistence={timeColumn:this._cols[r].name,...a>=0?{seriesColumn:this._cols[a].name}:{},...c})}}updateColumnStats20(e,n,i,r,s,a,l,o,u,c,f,m){if(e>=20){let h=[...n].sort((S,g)=>S-g),w=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=g=>{let y=g instanceof Date?g:typeof g=="string"?ke(g)??new Date(g):new Date(g),A=this.wholeDayIso(y);return A?A+"T00:00:00.000Z":isNaN(y.getTime())?g: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[w-1]+h[w])/2):(h[w-1]+h[w])/2:h[w],s.numericPrecision=c}if(h.length>0){let S=i>0&&r!=null?r/i:s.avgValue??0,g=h.length,y=0,A=0;for(let b of h){let x=b-S;y+=x*x,A+=x*x*x}let p=y/g,_=Math.sqrt(p);s.skewness=p===0?0:A/g/(_*_*_),s.stdDev=Math.sqrt(p)}r!==null&&(s.sum=r);let C=Array.from(f.entries()).sort((S,g)=>g[1]-S[1]);if(s.topCategories=C.slice(0,10).map(S=>S[1]),!s.isMeasure&&C.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=C.slice(0,5).map(S=>S[0])),e>=20)){let S=C.map(y=>y[0]),g=he(S,m);if(g!==null)s.ordinalPattern=g.pattern,s.orderedDomain=g.orderedDomain;else if(s.dataType==="String"){let y=pt(S);y!==null&&(s.safeDistinctValues=y)}}if(h.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let S=g=>h[Math.floor((h.length-1)*g)];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,g)=>g[1]-S[1]).map(S=>S[0]);s.formatSignature=Se(h);let w=i>0?a/i:void 0,C=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!C.test(s.formatSignature)&&(w===void 0||w>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((C,S)=>S[1]-C[1]),w=Ct(h.map(C=>C[0]),s.name,m);if(w!==null&&(s.geoKind=w.geoKind,s.geoMatchPct=w.geoMatchPct,w.geoAmbiguous&&(s.geoAmbiguous=!0),w.geoKind.indexOf("country")===0)){let C=bt(h);C&&(s.dominantGeoRegion=C.dominantGeoRegion,s.dominantGeoRegionPct=C.dominantGeoRegionPct,s.geoRegionCount=C.regionCount,C.middleEastPct>0&&(s.middleEastPct=C.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=mn({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=>Je(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(c=>c==="lat"||c==="latitude")?n=l:u&&i<0&&o.some(c=>c==="lon"||c==="lng"||c==="long"||c==="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,c)=>{let f=0;for(let m of this._rows){let h=m[u];if(h==null||h==="")continue;let w=Number(h);if(!Number.isFinite(w)||w<-c||w>c)return!1;f++}return f>0},l=-1,o=-1;if(this._cols.forEach((u,c)=>{if(!(u.dataType==="Integer"||u.dataType==="Decimal"))return;let f=e(u.name),m=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Et(f);m==="lat"&&l<0&&a(c,90)?l=c:m==="lon"&&o<0&&a(c,180)&&(o=c)}),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),c=o==null||o===""?null:Number(o);s.push({lat:u,lon:c,country:r>=0&&ye(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=yt(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return Xt(e,at)}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 c=0;c<this._cols.length;c++){let f=this._cols[c],m=o[c];if(this.STR(m)!=""){if(e&&f.dataType=="String")if(s.has(m))m=s.get(m);else{let h=this.obfuscateString(m);s.set(m,h),m=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=m instanceof Date?m:typeof m=="string"?ke(m)??new Date(m):new Date(m);m=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(c)&&m instanceof Date&&(m=ge(m));r-=this.STR(m).length}else m=null;u[c]=m,--r}if(n.push(u),--i,i<=0||r<=0)break}return await an.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return an.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,i=(this._cols??[]).some(u=>!!u&&!!u.isReassembledDate&&!!u.sourceField);if(!e||this._hostQueryNames.length===0&&!i||!this._cols||this._cols.length===0)return n;let r=String(e),s=new Set;for(let u of this._cols)u&&(s.add(this.STR(u.name)),u.hostName&&s.add(this.STR(u.hostName)));let a=new Map,l=new Set,o=new Set;for(let u=0;u<this._cols.length;u++){if(!this._cols[u])continue;let c=this._hostQueryNames[u],f=$t(c,this._cols[u].name,this._cols[u].dataType)?[]:Wt(c),m=this.STR(this._cols[u].name),h=[];if(c){for(let g of this._generationColumns)if(g.q===c)for(let y of[g.n,Ke(g.n)])y&&y!==m&&!f.includes(y)&&!h.includes(y)&&h.push(y)}let w=this._cols[u].isReassembledDate?this.STR(this._cols[u].sourceField):"",C=w&&w!==m&&!f.includes(w)&&!h.includes(w)?[w]:[],S=[...f,...h,...C].filter(g=>!s.has(g)&&ae(r,g));S.length===1&&(a.set(S[0],[...a.get(S[0])??[],u]),h.includes(S[0])?l.add(S[0]):C.includes(S[0])&&o.add(S[0]))}for(let[u,c]of a){if(c.length!==1)continue;let f=this.STR(this._cols[c[0]].name);n.set(c[0],{name:f,alias:u,headerName:!ae(r,f),reason:l.has(u)?"stored-query-name":o.has(u)?"reassembled-date-source-field":"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=ot(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(_i(e)),this.invalidateStats(),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,this._leafCardinality=null,this._inferredMeasureFlags=null}reset(){this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,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.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,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=Ke(r);!s||s===r||n.has(s)||(n.delete(r),n.add(s),i.hostName=r,i.name=s)}}};export{gn as a,pn as b,Mi as c,Ti as d,vt as e,Nt as f,Rn as g,In as h,Et as i,kn as j,Dn as k,On as l,Pn as m,Te as n,Vn as o,Ke as p,Ve as q,Wt as r,Gt as s,Yn as t,Vt as u,Ut as v,Pi as w,Li as x,Fi as y,qn as z,Zn as A,Qn as B,Ht as C,ae as D,cr as E,Vi as F,dr as G,mr as H,X as I,Qt as J,vr as K,Rr as L,Ir as M,Or as N,tn as O,nn as P,ns as Q,Ne as R,dn as S,yi as T,bi as U,Si as V,mn as W,un as X,_i as Y,cn as Z};