@bicharts/shape-core 0.6.137 → 0.6.139

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.
@@ -0,0 +1,2 @@
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 _e}from"./chunk-U3H6UBOO.mjs";import{a as wt,f as te,g as Ae,h as oe,i as Ce,j as ie}from"./chunk-DEDI5YYD.mjs";import{b as St,c as _t,d as At,e as Ct,f as xt}from"./chunk-2RTTKMKE.mjs";import{c as ht,l as yt,n as be,p as bt,s as se,w as Se,x as Oe,y as Le,z as Pe}from"./chunk-S7AJDE7I.mjs";import{e as mt,k as he,m as De,n as pt,o as ye}from"./chunk-ZATHQUWM.mjs";import{b as ft,d as gt}from"./chunk-5HI6TVMM.mjs";import{A as pe,B as ct,E as dt,a as re,b as ee,c as et,d as fe,g as tt,h as nt,j as rt,l as it,m as st,o as ot,p as ge,q as at,r as lt,u as ke,w as ut}from"./chunk-BLMRLXQJ.mjs";import{c as Je,f as Ne}from"./chunk-F6UNSFU6.mjs";var bn=85,Sn=60,_n=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Fe=t=>Math.round(t*10)/10,xe=t=>t.split("-")[0];function Tt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=be(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:Fe(100*r/n)}}function Gi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Mt(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=Se(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=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(Oe(t,i).map(Le).filter(s=>!!s));return r.size===1?[...r][0]:null}function Ui(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=Mt(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??""),T=w.get(x);if(T||(T=Se(b,{country:g}),w.set(x,T)),T.status==="resolved"&&T.provinceId){i[S]=T.provinceId,r[S]="city",u++;return}if(T.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=Se(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:Fe(100*u/o.size),regionCount:f.size,countryCount:m.size,...Tt(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 T=s(x[o]);T&&(c.set(T,(c.get(T)||0)+1),f.has(T)||f.set(T,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,T)=>{if(Pe(T)){m++;let z=T.toUpperCase();C.add(z),S.set(xe(z),(S.get(xe(z))||0)+x);return}let W=new Set(Oe(T,f.get(T)).map(Le).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];C.add(z),S.set(xe(z),(S.get(xe(z))||0)+x)}else W.size>1&&w++});let y=_n.test(l.name.replace(/[_-]+/g," "))?Sn:bn,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:Fe(b),ambiguous:!_&&w/c.size>.15?!0:void 0,regionCount:C.size,countryCount:S.size,...Tt(S)})}),i}function $e(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var ze={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},An=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,Cn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,xn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,wn=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,Tn=new Set(["de","del","of"]),Mn=new Set(["\u0433","\u0440","r"]),vn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,We=/^\d+$/;function En(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 Et(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=wt(e);let n=null,i=An.exec(e);if(i){if(n=En(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=xn.exec(e)){let m=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...ze,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=Cn.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:{...ze,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(wn,"$1").split(/[\s.,/-]+/).filter(m=>m!==""&&!Tn.has(m.toLowerCase()));if(s.length===4&&We.test(s[2])&&Mn.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(m=>We.test(m)?"N":vn.test(m)?"W":"?").join(""),l=s.map(m=>We.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{...ze,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:c,namedOrder:f}}var Rn=[31,28,31,30,31,30,31,31,30,31,30,31],In=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&&In(t)?29:Rn[e-1]):!1}function Nn(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 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=Et(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=Ce(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=$e(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||!Rt(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=Et(y),i.set(y,A)),A===null||A==="iso"||A.key!==l)return null;let p=m(A);return!p||!Rt(p[0],p[1],p[2])?null:Nn(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 un from"papaparse";var kn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},Dn={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},Ve=t=>re(t.normalize("NFC")).toLowerCase(),On=new Set(Object.values(kn).flatMap(t=>(t??[]).map(Ve))),Ln=new Set(Object.values(Dn).flatMap(t=>(t??[]).map(Ve)));function Nt(t){let e=!1,n=!1;for(let i of t){let r=Ve(i);On.has(r)?e=!0:Ln.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var Pn=["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"],Fn=["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"],zn=["latitude","longitude"],Wn=["latitude","longitude"];function Z(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"],$n=["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"],Vn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Bn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],we=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 Lt=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 Kn="[\u2013\u2014-]";function Pt(t){let e=t.filter(r=>!kt(r)),n=t.filter(kt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+Kn+"\\s*)("+Be(e)+")"),n.length&&i.push("\\s*("+Be(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Ke=Pt(Vn),Gn=Pt(Bn);function Te(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=Z(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of $n)if(e.startsWith(r+" "))return we[r]??"avg";for(let r of Ot)if(e.startsWith(r+" ")||e===r)return we[r]??"sum";let n=Te(e,Gn);if(n)return we[n.label]??"avg";let i=Te(e,Ke);return i?we[i.label]??"sum":null}var zt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Un=new RegExp("\\b("+Pn.join("|")+")\\b|("+Fn.join("|")+")$","i"),Hn=new RegExp("\\b("+zn.join("|")+")\\b|("+Wn.join("|")+")$","i");function ae(t){if(!t)return"";let e=String(t),n=Z(e),i=Lt.exec(n);if(i)return e.slice(i[0].length).trim();let r=Te(n,Ke);return(r?e.slice(0,r.base.length):e).trim()}function Yn(t){if(!t)return!1;let e=Z(String(t));return Lt.test(e)||Te(e,Ke)!==null}var jn=["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*("+[...jn].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=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 Wt(t){let e=t.map(r=>String(r??"")),n=new Set(e),i=new Set;for(let r=0;r<e.length;r++){if(!i.has(e[r])){i.add(e[r]);continue}let s=2;for(;n.has(`${e[r]} (${s})`);)s++;e[r]=`${e[r]} (${s})`,n.add(e[r]),i.add(e[r])}return e}function Ue(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 "]},$t=new RegExp("^("+Object.keys(Me).join("|")+")\\((.+)\\)$");function Vt(t){if(!t)return[];let e=$t.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 Bt(t,e,n){let i=$t.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 Xn(t){let e=ae(t);return e.length===0?"":e.replace(zt," ")}function Kt(t,e){if(!e)return!1;let n=ae(e);return t.test(Z(Xn(e)))||t.test(Z(n))||t.test(Z(ee(n).join(" ")))}function Gt(t){return Kt(Hn,t)}function qn(t){return Kt(Un,t)||Gt(t)}var Zn=["open","high","low","close","adj close","adjusted close"],Qn=["price","prices","precio","precios","prix","preis","preco","precos","prezzo","prijs"],Jn=["total","totals","subtotal","amt","amount","amounts"],er=["level","levels","nivel","niveau"],tr=["days","dias"],nr=["to","until","till","open","hand","lead","stay","transit","stage","since","growing"],rr=new Set(Zn),ir=new Set(Qn),sr=new Set(Jn),or=new Set(er),ar=new Set(tr),lr=new Set(nr);function ur(t){let e=ae(t);return e.length===0?[]:(e.indexOf("%")>=0&&(e=e.split("%").join(" pct ")),Z(e.replace(zt," ")).toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(i=>i.length>0))}function cr(t){if(!t)return!1;let e=ur(String(t));if(e.length===0)return!1;if(rr.has(e.join(" "))||e.some(n=>ir.has(n))&&!e.some(n=>sr.has(n))||e.some(n=>n==="temp"||or.has(n)))return!0;for(let n=0;n+1<e.length;n++)if(e[n]==="life"&&e[n+1]==="expectancy")return!0;return!!(e.some(n=>ar.has(n))&&e.some(n=>lr.has(n)))}var Ut=/int|double|decimal|single|float|number|currency|money/i;function dr(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Ut.test(String(t?.dataType??""))?"Continuous":"Categorical"}function mr(t){return t?.isMeasure===!0||Ut.test(String(t?.dataType??""))}function Ht(t){let e=t??{},n=dr(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"&&Yn(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}:qn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:cr(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Yt(t){let e=Ht(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return mr(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 es(t){return Yt(t)[0]}function ts(t,e){return Yt(t).indexOf(e)>=0}function ns(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Ht(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var fr={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"]},gr=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],pr=["num\xE9ro"],hr=t=>t.normalize("NFC").toLowerCase();function yr(t,e,n,i){let r=Ne(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<st?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?rt(t,n).includes(e)?"word":null:r.script==="Hang"?it(t,e)?"suffix":null:r.compounds&&nt(t,e,tt)?"suffix":null}function jt(t){let e=String(t??"").trim();if(!e)return null;let n=fe(e),i=fe(ae(e));for(let[r,s]of Object.entries(fr)){let a=gr.includes(r),l=a?i:n;for(let o of s){let u=pr.includes(o)||!!Ne(r)?.foldSensitive,c=u?l.words:l.folded;if(c.length===0)continue;let f=u?hr(o):fe(o).folded.join(" "),m=yr(a?c[0]:c[c.length-1],f,r,a);if(m)return{lang:r,word:o,view:m}}}return null}var br=[["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 br)if(n.test(t))return e;return null}var Sr=[{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]]}],Ee=new Map;function Xt(t,e,n,i){let r=Ee.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 Ee.set(t,s),s}function _r(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=Ee.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 Ee.set(i,s),s}function Ar(t,e){if(e==="Nd")return _r(t);for(let r of Sr)if(r.test.test(t))return Xt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Xt("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function Cr(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 xr=/^[\p{L}\p{M}\p{Nd}]$/u,qt=/^[\p{L}\p{Nd}]$/u;function Zt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=c=>{let f=ve(c);return!f||!xr.test(c)?c:Cr(Ar(c,f),n,c,e)},r=c=>{let f=[];for(let m of c)f.push(i(m)),qt.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(qt.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 wr=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Tr=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Mr=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 le(t,e){if(!t||!e)return!1;let n=Tr(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:wr.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function vr(t){return!!t&&Mr.test(t)}function us(t,e,n){return t?vr(t)?[...e]:[...n,...e].some(i=>le(t,i))?e.filter(i=>le(t,i)):[...e]:[]}var Er=5,Rr=6,Ir=3,ne=864e5,Nr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,kr=/^(\d{4})[-/](\d{1,2})$/,Dr=/^(\d{4})[-\s]?Q([1-4])$/i,Or=/^Q([1-4])[-\s](\d{4})$/i,Lr=/^(\d{4})$/,Pr=/^(\d{4})(0[1-9]|1[0-2])$/,Fr=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,zr=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Wr=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function He(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=Ae(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=Je(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function $r(t){let e=he(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 Vr(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=Vr(r,e);return o||null}let s=Nr.exec(r);if(s)return j(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=Dr.exec(r),s)return j(+s[1],(+s[2]-1)*3+1,1);if(s=Or.exec(r),s)return j(+s[2],(+s[1]-1)*3+1,1);if(s=kr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return j(+s[1],+s[2],1);if(s=Fr.exec(r),s)return j(+s[1],+s[2],+s[3]);if(s=Pr.exec(r),s)return j(+s[1],+s[2],1);if(s=Lr.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?j(o,1,1):null}let a=$r(r);if(a)return a;if(s=zr.exec(r),s){let o=He(s[1],n,i);if(o)return j(+s[2],o,1)}if(s=Wr.exec(r),s){let o=He(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:He(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 Jt(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 Br(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 Kr(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 ue(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 Jt(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 en(t,e){return Ye(t,e)?.cadence??null}function Ye(t,e){let n=e?.gapFactor??Er,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=Ce(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<Ir||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=Br(c);if(!(f>0))return null;let m=Kr(f/ne);m==="day"&&u>=7*ne&&o.every(p=>Qt(p.ms))&&Jt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(m="weekday");let h=m==="irregular"?o.length:ue(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 _=ue(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<=Rr&&(A.runBounds=S),{cadence:A,points:o,stepMs:f}}var Gr=8,Ur=.5,Hr=200,Yr=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"]),jr=["category","classification","segment","status","priority","severity","channel"],Xr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function qr(t){let e=ee(t);if(e.length===0)return!1;let n=e[e.length-1];return Yr.has(n)?!0:jr.some(i=>n.length>i.length&&n.endsWith(i))}function Zr(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>Hr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":ye(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Xr.has(_e(e))?"identifier":!t.geoKind&&qr(t.name)?"attribute":"entity"}function rn(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(Zr(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 tn=t=>t<10?"0"+t:String(t);function nn(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${tn(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${tn(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function sn(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=Ye(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=ue(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=ue(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 T=c.get(b);T||(T={seen:new Set,lo:x.idx,hi:x.idx,loStamp:x.stamp,hiStamp:x.stamp,order:c.size},c.set(b,T)),T.seen.add(x.idx),x.idx<T.lo&&(T.lo=x.idx,T.loStamp=x.stamp),x.idx>T.hi&&(T.hi=x.idx,T.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??Ur))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),T=1;for(let z=1;z<x.length;z++)T=Math.max(T,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:T};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,T)}if(m.length===0)return null;m.sort((_,b)=>_.coverage-b.coverage||_.acc.order-b.acc.order);let p=m.slice(0,t.maxListed??Gr);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=nn(_.acc.loStamp,a),b.last=nn(_.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 Re=6;function ce(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 Qr(t){let e=t.length;if(e<Re)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=ce(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=ce(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 je(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=Qr(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(ce(o)),vnDetrended:Math.round(ce(a)*1e3)/1e3,relStep:Math.round(ce(l)*1e4)/1e4}}function As(t){let e=t.times.map(n=>X(n,t.pattern,t.locale)?.ms??null);return je({stamps:e,series:t.series,values:t.values})}var Jr=5e5,ei=8,ti=4,ni=5,Xe=1,qe=2,ri=4,ii=8;function si(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 oi(t,e,n){let{rows:i,text:r,locale:s}=t,a=si(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 ai(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 li(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&Xe&&r.keysA++,a&qe&&r.keysB++,(a&(Xe|qe))===(Xe|qe)&&r.keysBoth++,a&ri&&r.dupA++,a&ii&&r.dupB++}return r}function ui(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 on=t=>t==null||typeof t=="string"&&t.trim()==="";function ci(t,e,n){if(t===e)return!0;let i=on(t),r=on(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 an(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Jr)return null;let r=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=ni).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,ei),s=n.map((b,x)=>({c:b,i:x})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,ti);if(r.length===0||s.length===0)return null;let a=s.map(({c:b,i:x})=>oi(t,x,b)),l=null;for(let{i:b}of r){let x=ai(t,b);for(let T=0;T<s.length;T++){if(s[T].i===b)continue;let W=li(x.ids,a[T].code,x.dict.size);W.keysBoth<1||(!l||ui(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:T,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],T=o[b];x===0||T<0||(x===1?w[T]<0&&(w[T]=b):C[T]<0&&(C[T]=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],T=C[b];if(x<0||T<0)continue;let W=e[x],z=e[T],q=!0;for(let J of S)if(!ci(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 T=w[x]>=0,W=C[x]>=0;if(!T&&!W)continue;let z=ft(b);gt(z)&&(T&&A.set(z,(A.get(z)??0)+1),W&&p.set(z,(p.get(z)??0)+1))}let _=b=>{let x=0;for(let T of b.values())T>=2&&(x+=T);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 di=t=>t==="Integer"||t==="Decimal";function mi(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 fi(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!di(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function ln(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=mi(i);if(s.length===0)return e;let a=fi(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:_,T=b?_:p,W=b?S:g,z=b?g:S,q=0,J=0,de=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&&(de+=U+d)}C.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(q/(x*T)*1e4)/1e4,nMinority:x,nMajority:T,ties:de})}C.length>0&&e.set(o,C)}return e}var cn=12,gi=100,pi=.3,hi=3,yi=.75,dn=.9,bi=120,mn=1900,fn=2100,Si=0,_i=20,Ai=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=ee(t);return e.length===0?!1:Ai.has(e[e.length-1])?!0:jt(t)!==null}var Ci=new Set(["year","yr","fy"]),xi=t=>ee(t).some(e=>Ci.has(e))||mt(t)!==null,wi=/^(?:(?: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 Ze(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 Ti=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Mi=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,vi=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function hn(t,e){let n=[],i=0,r=Ei(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 Ei(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 T;if(T=Ti.exec(x)){i();let W=+T[2],z=+T[3];W>=1&&W<=12&&z>=1&&z<=31&&(s++,T[4]!==void 0&&a++,T[6]!==void 0&&l++)}else if(T=Mi.exec(x)){i();let W=+T[3],z=+T[4];W>=1&&W<=12&&z>=1&&z<=31&&(u&&u!==T[2]&&(S=!0),u=T[2],o++)}else if(T=vi.exec(x)){i();let W=+T[1],z=+T[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==T[2]&&(S=!0),f=T[2],c++,W>12&&w++,z>12&&C++,T[5]!==void 0&&m++,T[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=!$e(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 Ri(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 Ii(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 Ni=/(?:19|20)[0-9]{2}/;function ki(t){let e=new Map,n=0;for(let r of t){if(!Ni.test(re(r)))continue;let s=new Set(he(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 Di(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&&xi(n)||o&&r>=3&&r===a-s+1)return!0;let u=Ze(s)&&Ze(a),c=Qe(s)&&Qe(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?Ze(w):Qe(w))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let s=t.locale?Ae(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),wi.test(f)||Ri(f,s)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+ki(u)+Ii(o,u))/a>=.8||hn(o,t.locale)!==null)return!0}return!1}function Oi(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":Ft(t)}function Li(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=Oi(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 yn(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&&Ie(i)?"Categorical":c>=dn&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(De(i)&&r<=bi||o>=mn&&l<=fn||o>=Si&&l<=_i)?"Ordinal":n?"Continuous":!m&&Number.isFinite(u)&&r>cn&&r===s&&u===r?"Categorical":r>cn&&(m||r>=gi||f>=pi)||r>=hi&&f>=yi&&(m||c<dn&&!De(i)&&!(o>=mn&&l<=fn))?"Continuous":"Categorical"}function gn(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:yn({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 Pi(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 pn=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;tellApartNames=!0;_renamedRepeats=[];getRenamedRepeats(){return this._renamedRepeats}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??""))||ct(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]=gn(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 ut(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,M)=>{let N=this._preStatsFields[M];if(!(!d||!N)){for(let k of this._statsAddedKeys[M]??[])delete d[k];for(let k of Object.keys(N))d[k]=N[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 M=new Map,N=[],k=0,v=0,O=0,F=null,L=null,D=null,B=!1,K=!0,R=!0,I=null,G=!1,P=a.has(r);for(let E of this._rows){let $=E[r],V=P&&$ instanceof Date?pe($):$,H=this.STR(V);if(H!=""){if(k+=H.length,M.set(H,(M.get(H)||0)+1),v++,d.dataType=="Integer"||d.dataType=="Decimal"||d.dataType=="DateTime")if((F===null||V<F)&&(F=V),(L===null||V>L)&&(L=V),d.dataType=="Integer"||d.dataType=="Decimal"){if(D===null?D=V:D+=V,d.dataType=="Decimal"){let Q=this.getPrecision(V);Q>O&&(O=Q)}N.push(V)}else B=B||this.hasTimeComponent(V);G&&(V<I?K=!1:V>I&&(R=!1)),I=V,G=!0}}if(v>=3&&(K&&!R?d.sortedDirection="asc":R&&!K?d.sortedDirection="desc":d.sortedDirection="none"),v>0&&M.size>0&&!d.isMeasure){let E=0,$=Number.MAX_SAFE_INTEGER;for(let V of M.values())V>E&&(E=V),V<$&&($=V);if(d.modalShare=E/v,d.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,M.size===2){let V=[...M.keys()].map(me=>ot(me).trim().toLowerCase()).sort();([["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(me=>V[0]===me[0]&&V[1]===me[1])||Wi(d.name))&&(d.isBinaryFlag=!0)}}else d.isMeasure&&(d.dataType==="Integer"||d.dataType==="Decimal")&&M.size===2&&M.has("0")&&M.has("1")&&(d.isBinaryFlag=!0);if(d.dataType=="DateTime"&&(d.dateWithTime=B,B&&dt(P?this._rows.map(E=>E[r]instanceof Date?pe(E[r]):E[r]):this._rows.map(E=>E[r]))?d.timeOfDayOnly=!0:delete d.timeOfDayOnly),d.isTemporal=Di({dataType:d.dataType,name:d.name,isMeasure:d.isMeasure,distinctCount:M.size,minNum:typeof F=="number"?F:null,maxNum:typeof L=="number"?L:null,sampleValues:M.keys(),locale:n}),d.isTemporal&&d.dataType==="String"&&!d.isMeasure){let E=hn(M.keys(),n);E&&(d.temporalTextPattern=E.pattern)}if(d.timeOfDayOnly)delete d.temporalCadence;else if(d.isTemporal&&!d.isMeasure){let E=en(M.keys(),{includeBounds:s>=20,pattern:d.temporalTextPattern,locale:n});E&&(d.temporalCadence=E)}this.updateColumnStats10(s,d,v,M,O,L,F),this.updateColumnStats20(s,N,v,D,d,k,B,F,L,O,M,n),gn(d,this._declaredDimensions.has(d),{distinct:M.size,nonblank:v,prec:O,minval:F,maxval:L})&&(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||M.size>2e3?null:new Set(M.keys()),o[r]=M.size,u[r]=M.size===2?[...M.keys()].sort():null,r++}vt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((d,M)=>{let N=this._cols[M];d.kind&&(N.geoKind=d.kind,N.geoMatchPct=d.matchPct,d.ambiguous&&(N.geoAmbiguous=!0)),d.rollupPct!==void 0&&(N.admin1RollupPct=d.rollupPct),d.regionCount!==void 0&&(N.admin1RegionCount=d.regionCount),d.countryCount!==void 0&&(N.admin1CountryCount=d.countryCount),d.dominantRegion&&(N.dominantGeoRegion=d.dominantRegion,N.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,M)=>{d.isMeasure||f.push({idx:M,distinct:d.distinctCount??0,name:d.name})}),this._cols.forEach((d,M)=>{if(!d.isMeasure)return;let N=typeof d.lowValue=="number"?d.lowValue:null,k=typeof d.highValue=="number"?d.highValue:null,v=Li({rows:this._rows,measureColIdx:M,measureName:d.name,candidateDims:f,minNum:N,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,M)=>{if(!d.isMeasure)return;let N=[];for(let R of this._rows){let I=R[M];if(I==null||I==="")continue;let G=typeof I=="number"?I:parseFloat(I);isNaN(G)||N.push(G)}if(N.length===0)return;let k=[...N].sort((R,I)=>R-I);if(k[0]===k[k.length-1])d.relativeDispersion=0;else if(k.length>=h){let R=ge(k,.5),I=ge(k,.1),G=ge(k,.9);d.relativeDispersion=Math.abs(R)>1e-9?Math.round((G-I)/Math.abs(R)*1e3)/1e3:void 0}else d.relativeDispersion=void 0;let v=[];for(let R of w){let I=new Set;for(let G of this._rows){let P=G[M];P==null||P===""||I.add(this.STR(G[R.idx])+"")}v.push({otherColumn:R.name,nonBlankGroupCount:I.size})}v.length>0&&(d.nonBlankGroups=v);let O=0;for(let R of N)O+=R;O/=N.length;let F=0;for(let R of N)F+=(R-O)*(R-O);if(F<=1e-12)return;let L=[],D=[],B=R=>{if(R.length<4)return NaN;let I=[...R].sort((P,E)=>P-E),G=P=>I[Math.min(I.length-1,Math.max(0,Math.floor(P*(I.length-1))))];return G(.75)-G(.25)},K=B(N);for(let R of w){let I=new Map;for(let E of this._rows){let $=E[M];if($==null||$==="")continue;let V=typeof $=="number"?$:parseFloat($);if(isNaN(V))continue;let H=this.STR(E[R.idx])+"",Q=I.get(H);Q?(Q.s+=V,Q.n++,Q.vals.push(V)):I.set(H,{s:V,n:1,vals:[V]})}let G=0;for(let E of I.values()){let $=E.s/E.n;G+=E.n*($-O)*($-O)}L.push({otherColumn:R.name,eta2:Math.round(G/F*1e4)/1e4});let P=[];for(let E of I.values()){let $=B(E.vals);isNaN($)||P.push($)}if(P.length>=2&&isFinite(K)&&K>1e-9){let E=(Math.max(...P)-Math.min(...P))/K;D.push({otherColumn:R.name,spreadRatio:Math.round(E*1e4)/1e4})}}L.length>0&&(d.groupDiscrimination=L),D.length>0&&(d.spreadDiscrimination=D)});let C=.97,S=.8,g=8,y=5,A=this._cols.map((d,M)=>({c:d,i:M})).filter(d=>d.c.isMeasure);for(let d=0;d<A.length;d++)for(let M=d+1;M<A.length;M++){let N=A[d].i,k=A[M].i,v=0,O=0,F=0,L=0,D=0,B=0;for(let P of this._rows){let E=P[N],$=P[k];if(E==null||E===""||$===null||$===void 0||$==="")continue;let V=typeof E=="number"?E:parseFloat(E),H=typeof $=="number"?$:parseFloat($);isNaN(V)||isNaN(H)||(v++,O+=V,F+=H,L+=V*V,D+=H*H,B+=V*H)}if(v<y)continue;let K=v*L-O*O,R=v*D-F*F;if(K<=1e-12||R<=1e-12)continue;let I=(v*B-O*F)/Math.sqrt(K*R),G=Math.min(1,Math.round(Math.abs(I)*1e3)/1e3);for(let P of[A[d].c,A[M].c])(P.maxAbsMeasureCorrelation===void 0||G>P.maxAbsMeasureCorrelation)&&(P.maxAbsMeasureCorrelation=G);if(Math.abs(I)>=C){let P=A[d].c,E=A[M].c;P.collinearWithMeasures||(P.collinearWithMeasures=[]),E.collinearWithMeasures||(E.collinearWithMeasures=[]),P.collinearWithMeasures.push(E.name),E.collinearWithMeasures.push(P.name)}else if(Math.abs(I)>=S){let P=A[d].c,E=A[M].c,$=Math.round(I*1e3)/1e3;P.correlatedWithMeasures||(P.correlatedWithMeasures=[]),E.correlatedWithMeasures||(E.correlatedWithMeasures=[]),P.correlatedWithMeasures.push({otherColumn:E.name,r:$}),E.correlatedWithMeasures.push({otherColumn:P.name,r:$})}}for(let{c:d}of A)d.correlatedWithMeasures&&(d.correlatedWithMeasures.sort((M,N)=>Math.abs(N.r)-Math.abs(M.r)||(M.otherColumn<N.otherColumn?-1:1)),d.correlatedWithMeasures.length=Math.min(d.correlatedWithMeasures.length,g));for(let d=0;d<this._cols.length;d++){let M=l[d];if(!M||M.size===0)continue;let N=[];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 L of M)v.has(L)&&O++;let F=Math.round(O/M.size*100);F>0&&N.push({otherColumn:this._cols[k].name,percentShared:F})}N.length>0&&(this._cols[d].sharedValueRatioWithOthers=N)}let p=50,_=[];for(let d=0;d<this._cols.length;d++){let M=l[d];M&&M.size>=2&&M.size<=p&&_.push(d)}if(_.length>=2){let d=new Map,M=(k,v)=>k+":"+v;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++)d.set(M(_[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 L=""+this.STR(k[_[F]]),D=d.get(M(_[v],_[F])),B=O+""+L;D.set(B,(D.get(B)??0)+1)}}let N=new Map;for(let k=0;k<_.length;k++)for(let v=k+1;v<_.length;v++){let O=_[k],F=_[v],L=l[O].size,D=l[F].size,B=d.get(M(O,F)),K=B.size,R=0;for(let E of B.values())(R===0||E<R)&&(R=E);let I=Math.round(K/(L*D)*100),G=K===L,P=K===D;if((this._cols[O].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:I,determinesOther:G,minCellCount:R,distinctCombinations:K}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[O].name,fillPct:I,determinesOther:P,minCellCount:R,distinctCombinations:K}),G&&L>D){let E=N.get(O);(!E||D<E.card)&&N.set(O,{name:this._cols[F].name,card:D,ratio:D/L})}if(P&&D>L){let E=N.get(F);(!E||L<E.card)&&N.set(F,{name:this._cols[O].name,card:L,ratio:L/D})}}for(let[k,v]of N)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 M=this._cols[d];if(M.isMeasure||M.primaryParentColumn)continue;let N=M.distinctCount??0;if(N<=p||x>0&&N>=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>=N||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 B=this.STR(D[d])+"",K=this.STR(D[v])+"",R=O.get(B);if(R===void 0)O.set(B,K);else if(R!==K){F=!1;break}}if(!F)continue;let L=this._cols[v].distinctCount??0;M.primaryParentColumn=this._cols[v].name,M.nestingRatio=Math.round(L/N*100)/100;break}}let T=.01,W=.05,z=.95,q=8,J=8,de=6,Y=500,U=[];for(let d=0;d<this._cols.length&&U.length<J;d++){let M=this._cols[d].dataType;(M==="Double"||M==="Integer"||M==="Decimal")&&U.push(d)}if(U.length>=3&&this._rows.length>=q){let d=Math.min(this._rows.length,Y),M=U.map(L=>{let D=[];for(let R=0;R<d;R++){let I=this._rows[R][L],G=typeof I=="number"?I:parseFloat(String(I).replace(/,/g,""));if(I==null||I===""||!isFinite(G))return null;D.push(G)}let B=D[0],K=!1;for(let R of D)if(R!==B){K=!0;break}return K?D:null}),N=U.map((L,D)=>D).filter(L=>M[L]!==null),k=L=>{let D=L.slice().sort((K,R)=>K-R),B=D.length>>1;return D.length%2?D[B]:(D[B-1]+D[B])/2},v=null,O=[],F=L=>{if(O.length>=3){let D=O.map(I=>M[I]),B=D[0].length,K=new Array(B);for(let I=0;I<B;I++){let G=0;for(let P of D)G+=P[I];K[I]=G}let R=k(K);if(R>0){let I=0;for(let P of K)Math.abs(P-R)<=R*T&&I++;let G=I/B;if(G>=z){let P=1;for(let E of D){let $=k(E)/R;$<P&&(P=$)}P>=W&&(!v||O.length>v.cols.length)&&(v={cols:O.slice(),total:R,matched:G})}}}if(!(O.length>=de))for(let D=L;D<N.length;D++)O.push(N[D]),F(D+1),O.pop()};if(F(0),v){let L=v,B={columns:L.cols.map(K=>this._cols[U[K]].name),total:Math.round(L.total*1e3)/1e3,matchedPct:Math.round(L.matched*100)/100};for(let K of L.cols)this._cols[U[K]].constantSumGroup=B}}return this.applyTwoSetPairing(n,l),this.applyScoreSeparation(o,u),this.applySeriesCompleteness(s,n,l),this.applyMeasurePersistence(n,l),this._statsAddedKeys=this._cols.map((d,M)=>d?Object.keys(d).filter(N=>!i[M].has(N)):[]),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=an({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=ln({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,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=sn({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:Ie(a.name),values:o,rows:this._rows.length,locale:e}))});let s=rn(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 c=this._rows.map(f=>X(this.STR(f[o]),u.temporalTextPattern,e)?.ms??null);new Set(c.filter(f=>f!==null)).size<Re||(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=je({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=ye(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=_e(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=yn({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=>et(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":Nt(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&&be(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 Zt(e,lt)}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=pe(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 un.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return un.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=Ue(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=Ue(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=Bt(c,this._cols[u].name,this._cols[u].dataType)?[]:Vt(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,Ge(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)&&le(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:!le(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=at(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Pi(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="[]",this._renamedRepeats=[]}setColumns(e){if(this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,this._inferredMeasureFlags=null,this._cols=e,this._renamedRepeats=[],!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)}if(this.tellApartNames){let i=e.map(s=>this.STR(s?.name)),r=Wt(i);for(let s=0;s<e.length;s++)!e[s]||r[s]===i[s]||(this._renamedRepeats.push({index:s,from:i[s],to:r[s]}),e[s].name=r[s])}}},Fi=new Set(["active","inactive","flag","flags","flagged","paid","unpaid","win","wins","won","winner","pass","passed","passes","fail","failed","fails","failure","failures"]),zi=/^(?:default|churn|fraud|approv|convert|cancel|delinquen)/u;function Wi(t){let e=String(t??"");return/^(is|has)[_\p{L}\p{N}]/iu.test(e)?!0:e.replace(/([\p{Ll}\p{N}])(\p{Lu})/gu,"$1 $2").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(i=>i.length>0).some(i=>Fi.has(i)||zi.test(i))}export{bn as a,Sn as b,Gi as c,Ui as d,vt as e,It as f,kn as g,Dn as h,Nt as i,Pn as j,Fn as k,zn as l,Wn as m,ae as n,Yn as o,Ge as p,Ue as q,Vt as r,Gt as s,qn as t,cr as u,Ht as v,Yt as w,es as x,ts as y,ns as z,fr as A,gr as B,pr as C,jt as D,le as E,vr as F,us as G,Er as H,Rr as I,X as J,en as K,Gr as L,Ur as M,Hr as N,Zr as O,rn as P,sn as Q,As as R,Ie as S,hn as T,Di as U,Oi as V,Li as W,yn as X,gn as Y,Pi as Z,pn as _,Wi as $};
@@ -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{a,b,c,d,e,f,g,h}from"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{b as CITY_NAME_TOKENS,d as NAME_KIND_MIN_DISTINCT,a as ZIP_NAME_TOKENS,h as buildGeoIsoColumn,e as detectGeo,c as hasAnyToken,g as isJoinGeoKind,f as toGeoIso};
2
+ import{a,b,c,d,e,f,g,h}from"./chunk-2RTTKMKE.mjs";import"./chunk-S7AJDE7I.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-BLMRLXQJ.mjs";import"./chunk-F6UNSFU6.mjs";export{b as CITY_NAME_TOKENS,d as NAME_KIND_MIN_DISTINCT,a as ZIP_NAME_TOKENS,h as buildGeoIsoColumn,e as detectGeo,c as hasAnyToken,g as isJoinGeoKind,f as toGeoIso};
package/dist/geoPoint.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{B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i,J as j,K as k,L as l,M as m,N as n,O as o,d as a}from"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{d as NORTH_AMERICA_COUNTRIES,l as buildGeoPointColumns,o as cityMatchPct,m as cityTagsFor,c as isCityTableLoaded,j as isGeoPointAmbiguity,n as isKnownCity,f as normalizeCountry,a as normalizePlaceName,h as normalizeZip5,b as registerCityTable,e as resolveAdmin1,k as resolveGeoPoint,i as zipPrefixCandidates,g as zipToPrefix3};
2
+ import{B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i,J as j,K as k,L as l,M as m,N as n,O as o,d as a}from"./chunk-S7AJDE7I.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-BLMRLXQJ.mjs";import"./chunk-F6UNSFU6.mjs";export{d as NORTH_AMERICA_COUNTRIES,l as buildGeoPointColumns,o as cityMatchPct,m as cityTagsFor,c as isCityTableLoaded,j as isGeoPointAmbiguity,n as isKnownCity,f as normalizeCountry,a as normalizePlaceName,h as normalizeZip5,b as registerCityTable,e as resolveAdmin1,k as resolveGeoPoint,i as zipPrefixCandidates,g as zipToPrefix3};