@bicharts/shape-core 0.6.119 → 0.6.121
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 be}from"./chunk-U3H6UBOO.mjs";import{a as xt,f as ee,g as Se,h as se,i as _e,j as re}from"./chunk-TZ74QIKA.mjs";import{b as bt,c as St,d as _t,e as At,f as Ct}from"./chunk-YDYFP2T4.mjs";import{c as pt,l as ht,n as he,p as yt,s as ie,w as ye,x as ke,y as De,z as Oe}from"./chunk-DTBXJVUG.mjs";import{e as ct,k as ge,m as ft,n as gt,o as pe}from"./chunk-3ZAS32F5.mjs";import{b as dt,d as mt}from"./chunk-5HI6TVMM.mjs";import{A as fe,B as lt,E as ut,a as ne,b as J,c as Qe,d as de,g as Je,h as et,j as tt,l as nt,m as rt,o as it,p as me,q as st,r as ot,u as Ee,w as at}from"./chunk-CZJ7M6A5.mjs";import{c as Ze,f as Ne}from"./chunk-WC4JINEZ.mjs";var fn=85,gn=60,pn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Pe=t=>Math.round(t*10)/10,Ae=t=>t.split("-")[0];function wt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=he(a);l&&(e.set(l,(e.get(l)||0)+s),n+=s)}),n===0)return{};let[i,r]=[...e].sort((s,a)=>a[1]-s[1])[0];return{dominantRegion:i,dominantRegionPct:Pe(100*r/n)}}function wi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Mt(e,t.provinceKind,t.country);if(!ie())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let i=ye(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return i.status==="resolved"?i.provinceId:null}function Mt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let s=Ct(t,e);return s?"US-"+s:null}if(!ie())return null;if(e==="admin1-code")return Oe(t)?t.toUpperCase():null;let i=n==null?null:String(n),r=new Set(ke(t,i).map(De).filter(s=>!!s));return r.size===1?[...r][0]:null}function Mi(t,e={}){let n=e.deriveProvinces!==!1,i=new Array(t.length),r=new Array(t.length),s=new Set,a=[],l=new Set,o=[],u=0,d=0,f=0,c=A=>{let S=A.toLowerCase();s.has(S)||(s.add(S),a.push(A))},h=A=>A==null||A===""?null:Number(A),x=new Map;return t.forEach((A,S)=>{i[S]=null,r[S]=null;let p=A.country===null||A.country===void 0||String(A.country).trim()===""?null:String(A.country).trim(),y=A.province===null||A.province===void 0?"":String(A.province).trim();if(y){let _=Mt(y,e.provinceKind,p);_?(i[S]=_,r[S]="province",u++):c(y);return}if(!n)return;let C=h(A.lat),g=h(A.lon),w=!1;if(e.locate&&C!==null&&g!==null&&isFinite(C)&&isFinite(g)){w=!0;let _=e.locate(C,g);if(_){i[S]=_,r[S]="coordinates",u++;return}}let b=A.city===null||A.city===void 0?"":String(A.city).trim();if(b&&ie()){let _=b.toLowerCase()+""+(p??""),M=x.get(_);if(M||(M=ye(b,{country:p}),x.set(_,M)),M.status==="resolved"&&M.provinceId){i[S]=M.provinceId,r[S]="city",u++;return}if(M.status==="ambiguous"){d++,l.has(_)||(l.add(_),o.length<8&&o.push(b));return}c(b);return}w&&f++}),{iso:i,source:r,unmatched:a,matchedRows:u,totalRows:t.length,ambiguousRows:d,ambiguousExamples:o,unplacedPoints:f}}function Tt(t,e,n={}){let i=new Map;if(!ie()||e.length===0)return i;let r=t.findIndex(l=>!l.isMeasure&&(l.geoKind||"").startsWith("country")),s=l=>l==null?"":String(l).trim(),a=l=>{let o=new Map;for(let h of e){let x=s(h[l]);if(!x)continue;let A=r>=0&&s(h[r])||null,S=x+""+(A??""),p=o.get(S);p?p.rows++:o.set(S,{city:x,country:A,rows:1})}if(o.size===0)return null;let u=0,d=0,f=new Set,c=new Map;return o.forEach(h=>{let x=ye(h.city,{country:h.country});x.status!=="unmatched"&&d++,!(x.status!=="resolved"||!x.provinceId)&&(u++,f.add(x.provinceId),c.set(x.cc,(c.get(x.cc)||0)+h.rows))}),{signals:{rollupPct:Pe(100*u/o.size),regionCount:f.size,countryCount:c.size,...wt(c)},cityPct:100*d/o.size,distinct:o.size}};return t.forEach((l,o)=>{if(l.isMeasure||o===r)return;let u=l.geoKind||"";if(u.startsWith("city")){if(n.cities===!1)return;let _=a(o);_&&i.set(o,_.signals);return}if(u)return;let d=new Map,f=new Map;for(let _ of e){let M=s(_[o]);M&&(d.set(M,(d.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&s(_[r])||null))}if(d.size<3)return;let c=0,h=0,x=0,A=new Set,S=new Map;d.forEach((_,M)=>{if(Oe(M)){c++;let z=M.toUpperCase();A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_);return}let W=new Set(ke(M,f.get(M)).map(De).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_)}else W.size>1&&x++});let y=pn.test(l.name.replace(/[_-]+/g," "))?gn:fn,C=100*c/d.size,g=100*h/d.size,w=C>=g,b=w?C:g;if(b<y){if(n.cities===!1)return;let _=a(o);if(!_||_.cityPct<pt||_.distinct<_t&&!St(l.name,bt))return;i.set(o,_.signals);return}i.set(o,{kind:w?"admin1-code":"admin1-name",matchPct:Pe(b),ambiguous:!w&&x/d.size>.15?!0:void 0,regionCount:A.size,countryCount:S.size,...wt(S)})}),i}function ze(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Le={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},hn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,yn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,bn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,Sn=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,_n=new Set(["de","del","of"]),An=new Set(["\u0433","\u0440","r"]),Cn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,Fe=/^\d+$/;function xn(t){let e=+t[1],n=+t[2],i=t[3]===void 0?0:+t[3],r=t[4]!==void 0;if(n>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s:i,seconds:t[3]!==void 0,meridiem:r}}function vt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=xt(e);let n=null,i=hn.exec(e);if(i){if(n=xn(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=bn.exec(e)){let c=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Le,form:"cjk",key:c,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=yn.exec(e)){let c=r[2],h=r[4];if(c!==h)return null;let x=c.trim(),A=r[6];if(A&&x!==".")return null;let S=[r[1].length,r[3].length,r[5].length],p=S[0]===4,y=S[2]===4;return p===y||(p?S[1]>2||S[2]>2:S[0]>2||S[1]>2)?null:p&&x==="-"&&c==="-"&&S[1]===2&&S[2]===2?"iso":p&&x==="."&&c==="."&&!A&&!(S[1]===2&&S[2]===2)?null:{...Le,form:"numeric",key:`num|${p?"y":"x"}|${c}|${A}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:p,sep:c,trail:A}}let s=e.replace(Sn,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!_n.has(c.toLowerCase()));if(s.length===4&&Fe.test(s[2])&&An.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(c=>Fe.test(c)?"N":Cn.test(c)?"W":"?").join(""),l=s.map(c=>Fe.test(c)?c:""),o=0,u=0,d="",f;if(a==="NWN"&&l[0].length<=2&&l[2].length===4)o=+l[0],d=s[1],u=+l[2],f="dmy";else if(a==="WNN"&&l[1].length<=2&&l[2].length===4)d=s[0],o=+l[1],u=+l[2],f="mdy";else if(a==="NWN"&&l[0].length===4&&l[2].length<=2)u=+l[0],d=s[1],o=+l[2],f="ymd";else return null;return{...Le,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:d,namedOrder:f}}var wn=[31,28,31,30,31,30,31,31,30,31,30,31],Mn=t=>t%4===0&&t%100!==0||t%400===0;function Rt(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&Mn(t)?29:wn[e-1]):!1}function Tn(t,e,n,i){let r=new Date(Date.UTC(2e3,e-1,n,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(t),r}function It(t,e={}){let n=(e.floor??1)>=1,i=new Map,r=new Map,s=0,a=null;for(let p of t){if(p==null)continue;if(typeof p!="string"){if(n)return null;s++;continue}let y=p.trim();if(y==="")continue;s++;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"){if(n)return null;continue}if(n){if(a===null)a=C;else if(C.key!==a.key)return null}else r.set(C.key,(r.get(C.key)??0)+1)}if(!n){let p=0,y="";for(let[C,g]of r)g>p&&(p=g,y=C);if(p===0||p/s<e.floor)return null;a=[...i.values()].find(C=>C!==null&&C!=="iso"&&C.key===y)??null}if(a===null)return null;let l=a.key,o=[...i.values()].filter(p=>p!==null&&p!=="iso"&&p.key===l),u,d="shape",f=null;if(a.form==="named"){if(u=a.namedOrder,f=_e(o.map(p=>p.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)u="ymd";else{let p=0,y=0;for(let C of o)C.a>12&&p++,C.b>12&&y++;if(p>0&&y>0)return null;p>0?(u="dmy",d="values"):y>0?(u="mdy",d="values"):a.sep.trim()==="."?(u="dmy",d="shape"):(u=ze(e.locale)?"mdy":"dmy",d="locale")}let c=p=>{if(p.form==="named"){let y=f.get(ee(p.word));return y===void 0?null:[p.year,y+1,p.day]}return p.yearFirst?[p.a,p.b,p.c]:u==="dmy"?[p.c,p.b,p.a]:[p.c,p.a,p.b]},h=1/0,x=-1/0,A=0;for(let p of o){let y=c(p);if(!y||!Rt(y[0],y[1],y[2])){if(n)return null;A++;continue}h=Math.min(h,y[0]),x=Math.max(x,y[0])}if(!n&&(r.get(l)-A)/s<e.floor||h>=2400&&x<=2699||h>=1300&&x<=1500)return null;let S={form:a.form,order:u,orderFrom:d,hasTime:o.some(p=>p.clock!==null),read(p){if(typeof p!="string")return null;let y=p.trim();if(y==="")return null;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"||C.key!==l)return null;let g=c(C);return!g||!Rt(g[0],g[1],g[2])?null:Tn(g[0],g[1],g[2],C.clock)}};if(a.form!=="named"&&!o.some(p=>p.clock?.meridiem)){let p;a.form==="cjk"?p=a.cjkPattern:a.yearFirst?p=`%Y${a.sep}%m${a.sep}%d${a.trail}`:p=(u==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let y=o.filter(C=>C.clock!==null).length;y===0?S.pattern=p:y===o.length&&(S.pattern=p+(o.every(C=>C.clock.seconds)?" %H:%M:%S":" %H:%M"))}return S}import on from"papaparse";var vn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},Rn={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},We=t=>ne(t.normalize("NFC")).toLowerCase(),In=new Set(Object.values(vn).flatMap(t=>(t??[]).map(We))),Nn=new Set(Object.values(Rn).flatMap(t=>(t??[]).map(We)));function Nt(t){let e=!1,n=!1;for(let i of t){let r=We(i);In.has(r)?e=!0:Nn.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var En=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","capita","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],kn=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],Dn=["latitude","longitude"],On=["latitude","longitude"];function Z(t){return ne(t)}var Dt=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],Pn=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Ln=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Fn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],Ce=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function $e(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ot=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+$e(Dt)+")\\s+)","i");function Et(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var zn="[\u2013\u2014-]";function Pt(t){let e=t.filter(r=>!Et(r)),n=t.filter(Et),i=[];return e.length&&i.push("(?:\\s+|\\s*"+zn+"\\s*)("+$e(e)+")"),n.length&&i.push("\\s*("+$e(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Be=Pt(Ln),Wn=Pt(Fn);function xe(t,e){let n=e.exec(t);if(!n)return null;let i=t.slice(0,n.index);return i.trim()===""?null:{base:i,label:(n[1]??n[2]??"").toLowerCase()}}function Lt(t){let e=Z(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of Pn)if(e.startsWith(r+" "))return Ce[r]??"avg";for(let r of Dt)if(e.startsWith(r+" ")||e===r)return Ce[r]??"sum";let n=xe(e,Wn);if(n)return Ce[n.label]??"avg";let i=xe(e,Be);return i?Ce[i.label]??"sum":null}var $n=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Bn=new RegExp("\\b("+En.join("|")+")\\b|("+kn.join("|")+")$","i"),Gn=new RegExp("\\b("+Dn.join("|")+")\\b|("+On.join("|")+")$","i");function Me(t){if(!t)return"";let e=String(t),n=Z(e),i=Ot.exec(n);if(i)return e.slice(i[0].length).trim();let r=xe(n,Be);return(r?e.slice(0,r.base.length):e).trim()}function Vn(t){if(!t)return!1;let e=Z(String(t));return Ot.test(e)||xe(e,Be)!==null}var Kn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],kt=new RegExp("^\\s*("+[...Kn].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ge(t){if(t==null)return"";let e=String(t),n=kt.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),s=e.slice(n[0].length),a=0;for(;a<8;){let l=kt.exec(s);if(!l||i(l[1])!==r)break;let o=s.slice(l[0].length);if(o.trim()==="")break;s=o,a++}return a===0?e:e.slice(0,n[0].length)+s}function Ve(t,e){if(!t||!e)return!1;let n=String(t);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&n.includes(r))return!0}return!1}var we={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},Ft=new RegExp("^("+Object.keys(we).join("|")+")\\((.+)\\)$");function zt(t){if(!t)return[];let e=Ft.exec(String(t).trim());if(!e)return[];let n=we[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let a=i.slice(s+1);if(a.trim()!=="")for(let l of n){let o=l+a;r.includes(o)||r.push(o)}}return r}function Wt(t,e,n){let i=Ft.exec(String(t??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&n==="Decimal")return!0;let s=new Set(we[r]),a=String(e??""),l=i[2];for(let o=l.indexOf(".");o>=0;o=l.indexOf(".",o+1)){if(o===0)continue;let u=l.slice(o+1);if(u.trim()!==""){for(let d of Object.values(we))for(let f of d)if(!s.has(f)&&a===f+u)return!0}}return!1}function Un(t){let e=Me(t);return e.length===0?"":e.replace($n," ")}function $t(t,e){if(!e)return!1;let n=Me(e);return t.test(Z(Un(e)))||t.test(Z(n))||t.test(Z(J(n).join(" ")))}function Bt(t){return $t(Gn,t)}function Hn(t){return $t(Bn,t)||Bt(t)}var Gt=/int|double|decimal|single|float|number|currency|money/i;function Yn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Gt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function jn(t){return t?.isMeasure===!0||Gt.test(String(t?.dataType??""))}function Vt(t){let e=t??{},n=Yn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Bt(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Vn(e.name))){if(i==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:n,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:n,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Hn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Kt(t){let e=Vt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return jn(n)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Oi(t){return Kt(t)[0]}function Pi(t,e){return Kt(t).indexOf(e)>=0}function Li(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Vt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var Xn={de:["nr","nummer","kennung","kennziffer","plz","postleitzahl"],nl:["nr","nummer"],sv:["nr","nummer"],da:["nr","nummer"],nb:["nr","nummer"],fi:["tunnus","koodi","nro"],hu:["azonos\xEDt\xF3","k\xF3d"],tr:["kod","kodu","numaras\u0131","numarasi"],zh:["\u7F16\u53F7","\u4EE3\u7801","\u7F16\u7801","\u53F7\u7801","\u90AE\u7F16"],ja:["\u756A\u53F7","\u30B3\u30FC\u30C9"],ko:["\uBC88\uD638","\uCF54\uB4DC"],hi:["\u0915\u094B\u0921","\u0915\u094D\u0930\u092E\u093E\u0902\u0915"],fr:["num\xE9ro"],es:["c\xF3digo"],pt:["c\xF3digo","cep"],it:["codice"],pl:["kod","numer"],cs:["k\xF3d","\u010D\xEDslo"],sk:["k\xF3d","\u010D\xEDslo"],hr:["\u0161ifra","oznaka"],ru:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],uk:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],el:["\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2"],ar:["\u0631\u0645\u0632","\u0643\u0648\u062F","\u0631\u0642\u0645"],he:["\u05E7\u05D5\u05D3"],id:["kode","nomor"],vi:["m\xE3"],th:["\u0E23\u0E2B\u0E31\u0E2A"]},qn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Zn=["num\xE9ro"],Qn=t=>t.normalize("NFC").toLowerCase();function Jn(t,e,n,i){let r=Ne(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<rt?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?tt(t,n).includes(e)?"word":null:r.script==="Hang"?nt(t,e)?"suffix":null:r.compounds&&et(t,e,Je)?"suffix":null}function Ut(t){let e=String(t??"").trim();if(!e)return null;let n=de(e),i=de(Me(e));for(let[r,s]of Object.entries(Xn)){let a=qn.includes(r),l=a?i:n;for(let o of s){let u=Zn.includes(o)||!!Ne(r)?.foldSensitive,d=u?l.words:l.folded;if(d.length===0)continue;let f=u?Qn(o):de(o).folded.join(" "),c=Jn(a?d[0]:d[d.length-1],f,r,a);if(c)return{lang:r,word:o,view:c}}}return null}var er=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function Te(t){for(let[e,n]of er)if(n.test(t))return e;return null}var tr=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],ve=new Map;function Ht(t,e,n,i){let r=ve.get(t);if(r)return r;let s=[];for(let[a,l]of e)for(let o=a;o<=l;o++){let u=String.fromCodePoint(o);Te(u)===n&&(i&&!i.test(u)||s.push(u))}return ve.set(t,s),s}function nr(t){let n=t.codePointAt(0);for(let a=0;a<9&&Te(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),r=ve.get(i);if(r)return r;let s=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);Te(l)==="Nd"&&s.push(l)}return ve.set(i,s),s}function rr(t,e){if(e==="Nd")return nr(t);for(let r of tr)if(r.test.test(t))return Ht(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Ht("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function ir(t,e,n,i){let r=t.filter(s=>!e.has(s));return r.length===0&&(r=t.filter(s=>s!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var sr=/^[\p{L}\p{M}\p{Nd}]$/u,Yt=/^[\p{L}\p{Nd}]$/u;function jt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=d=>{let f=Te(d);return!f||!sr.test(d)?d:ir(rr(d,f),n,d,e)},r=d=>{let f=[];for(let c of d)f.push(i(c)),Yt.test(c)&&e()<.2&&f.push(i(c));if(f.length>6){let c=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<c;h++)for(let x=0;x<5;x++){let A=Math.floor(e()*f.length);if(Yt.test(f[A])){f.splice(A,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[a,l=""]=t.split("@"),o=l.endsWith(".com"),u=o?l.slice(0,-4):l;return`${r(a)}@${r(u)}${o?".com":""}`}var or=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ar=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),lr=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function oe(t,e){if(!t||!e)return!1;let n=ar(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:or.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function ur(t){return!!t&&lr.test(t)}function Vi(t,e,n){return t?ur(t)?[...e]:[...n,...e].some(i=>oe(t,i))?e.filter(i=>oe(t,i)):[...e]:[]}var cr=5,dr=6,mr=3,te=864e5,fr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,gr=/^(\d{4})[-/](\d{1,2})$/,pr=/^(\d{4})[-\s]?Q([1-4])$/i,hr=/^Q([1-4])[-\s](\d{4})$/i,yr=/^(\d{4})$/,br=/^(\d{4})(0[1-9]|1[0-2])$/,Sr=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,_r=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Ar=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ke(t,e,n){let i=ee(t);if(!i)return 0;if(i==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=Se(a)[i];if(l!==void 0)return l+1}let r=n?.get(i);if(r!==void 0)return r+1;let s=se(t);if(s.length>0){if(s.every(o=>o.month===s[0].month))return s[0].month+1;let a=Ze(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function Cr(t){let e=ge(t).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let n=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==n.n||i.year!==n.year)?null:Y(n.year,(n.n-1)*3+1,1)}function Y(t,e,n,i=0,r=0,s=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,i,r,s);if(!Number.isFinite(a))return null;let l=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function xr(t,e){let n=[],i="";for(let o=0;o<e.length;o++){if(e[o]!=="%"){i+=e[o].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++o]){case"Y":n.push("Y"),i+="(\\d{4})";break;case"m":n.push("m"),i+="(\\d{1,2})";break;case"d":n.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let r=new RegExp("^"+i+"$").exec(t);if(!r)return null;let s=0,a=1,l=1;return n.forEach((o,u)=>{let d=+r[u+1];o==="Y"?s=d:o==="m"?a=d:l=d}),s?Y(s,a,l):null}function j(t,e,n,i){let r=(t??"").trim();if(r==="")return null;if(e){let o=xr(r,e);return o||null}let s=fr.exec(r);if(s)return Y(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=pr.exec(r),s)return Y(+s[1],(+s[2]-1)*3+1,1);if(s=hr.exec(r),s)return Y(+s[2],(+s[1]-1)*3+1,1);if(s=gr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return Y(+s[1],+s[2],1);if(s=Sr.exec(r),s)return Y(+s[1],+s[2],+s[3]);if(s=br.exec(r),s)return Y(+s[1],+s[2],1);if(s=yr.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?Y(o,1,1):null}let a=Cr(r);if(a)return a;if(s=_r.exec(r),s){let o=Ke(s[1],n,i);if(o)return Y(+s[2],o,1)}if(s=Ar.exec(r),s){let o=Ke(s[2],n,i);if(o)return Y(+s[1],o,1)}let l=re(r);if(l){let o="month"in l?l.month:Ke(l.word,n,i);if(o)return Y(l.year,o,1)}return null}function Xt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function qt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/te),i=Math.floor(n/7),r=i*5,s=t+i*7*te;for(;s<e;)Xt(s)&&r++,s+=te;return r}function wr(t){if(t.length===0)return 0;let e=[...t].sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Mr(t){return t>0?t<.95?"hour":t<=1.05?"day":t>=6.5&&t<=7.5?"week":t>=27&&t<=31.5?"month":t>=88&&t<=93?"quarter":t>=362&&t<=368?"year":"irregular":"irregular"}function ae(t,e,n,i){switch(n){case"year":return e.y-t.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(t.y*4+Math.floor((t.m-1)/3));case"month":return e.y*12+e.m-(t.y*12+t.m);case"week":return Math.round((e.ms-t.ms)/(7*te));case"weekday":return qt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/te);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function Zt(t,e){return Ue(t,e)?.cadence??null}function Ue(t,e){let n=e?.gapFactor??cr,i=0,r=0,s=new Map,a=Array.from(t),l;if(!e?.pattern){let g=[];for(let w of a){if(w==null||w==="")continue;let b=re(String(w));b&&"word"in b&&g.push(b.word)}g.length>0&&(l=_e(g,e?.locale)??void 0)}for(let g of a){if(g==null||g==="")continue;i++;let w=j(String(g),e?.pattern,e?.locale,l);w&&(r++,s.set(w.ms,w))}let o=[...s.values()].sort((g,w)=>g.ms-w.ms);if(o.length<mr||i>0&&r/i<.8)return null;let u=o[o.length-1].ms-o[0].ms;if(u<=0)return null;let d=[];for(let g=1;g<o.length;g++)d.push(o[g].ms-o[g-1].ms);let f=wr(d);if(!(f>0))return null;let c=Mr(f/te);c==="day"&&u>=7*te&&o.every(g=>Xt(g.ms))&&qt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(c="weekday");let h=c==="irregular"?o.length:ae(o[0],o[o.length-1],c,f)+1,x=1,A=1,S=[],p=o[0],y=1;for(let g=1;g<o.length;g++){let w=ae(o[g-1],o[g],c,f);w>x&&(x=w),c!=="irregular"&&w>n?(A++,S.push({from:p.iso,to:o[g-1].iso,points:y}),p=o[g],y=1):y++}S.push({from:p.iso,to:o[o.length-1].iso,points:y});let C={grain:c,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:A,largestGapUnits:x,gapFactor:n};return e?.includeBounds&&S.length<=dr&&(C.runBounds=S),{cadence:C,points:o,stepMs:f}}var Tr=8,vr=.5,Rr=200,Ir=new Set(["category","categories","subcategory","type","types","kind","class","classes","classification","segment","segments","tier","status","priority","severity","grade","level","band","bucket","group","channel","method","mode","stage","phase","period","shift","gender","sex","result","outcome","reason","flag","genre","sector","source"]),Nr=["category","classification","segment","status","priority","severity","channel"],Er=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function kr(t){let e=J(t);if(e.length===0)return!1;let n=e[e.length-1];return Ir.has(n)?!0:Nr.some(i=>n.length>i.length&&n.endsWith(i))}function Dr(t){if(t.isMeasure)return"measure";if(t.isTemporal||t.isDatePart||t.isReassembledDate)return"temporal";let e=Array.from(t.values).filter(n=>n!==""&&n!==null&&n!==void 0);return e.length<2||e.length>Rr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":pe(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Er.has(be(e))?"identifier":!t.geoKind&&kr(t.name)?"attribute":"entity"}function en(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(Dr(r)!=="entity")return;let a=new Set(Array.from(r.values).filter(o=>o!=="")).size,l=!!r.geoKind;(a<n||a===n&&l&&!i)&&(e=s,n=a,i=l)}),e}var Qt=t=>t<10?"0"+t:String(t);function Jt(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Qt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Qt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function tn(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let w=0;w<i;w++)e[w]&&r.add(e[w]);let s=Ue(r,{pattern:t.pattern,locale:t.locale});if(!s)return null;let a=s.cadence.grain;if(a==="irregular")return null;let l=s.points[0],o=ae(l,s.points[s.points.length-1],a,s.stepMs)+1;if(o!==s.cadence.expectedPoints)return null;let u=new Map;for(let w of r){let b=j(w,t.pattern,t.locale);if(!b)continue;let _=ae(l,b,a,s.stepMs);_>=0&&_<o&&u.set(w,{idx:_,stamp:b})}let d=new Map;for(let w=0;w<i;w++){let b=n[w];if(!b)continue;let _=u.get(e[w]);if(!_)continue;let M=d.get(b);M||(M={seen:new Set,lo:_.idx,hi:_.idx,loStamp:_.stamp,hiStamp:_.stamp,order:d.size},d.set(b,M)),M.seen.add(_.idx),_.idx<M.lo&&(M.lo=_.idx,M.loStamp=_.stamp),_.idx>M.hi&&(M.hi=_.idx,M.hiStamp=_.stamp)}if(d.size<2)return null;let f=0;for(let w of d.values())f+=w.seen.size;if(f/(d.size*o)<(t.minFill??vr))return null;let c=[],h=new Set,x=0,A=0,S=0,p=0,y=0,C=1;for(let[w,b]of d){for(let z of b.seen)h.add(z);if(b.seen.size>=o)continue;let _=[...b.seen].sort((z,X)=>z-X),M=1;for(let z=1;z<_.length;z++)M=Math.max(M,_[z]-_[z-1]);let W={key:w,acc:b,coverage:b.seen.size/o,before:b.lo,after:o-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:M};c.push(W),W.before>0&&x++,W.after>0&&A++,W.interior>0&&S++,p=Math.max(p,W.before),y=Math.max(y,W.after),C=Math.max(C,M)}if(c.length===0)return null;c.sort((w,b)=>w.coverage-b.coverage||w.acc.order-b.acc.order);let g=c.slice(0,t.maxListed??Tr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:d.size,incompleteSeries:c.length,lateStarts:x,earlyEnds:A,withHoles:S,columnWideMissing:o-h.size,maxMissingBefore:p,maxMissingAfter:y,largestGap:C,series:g.map(w=>{let b={};return t.includeNames&&(b.name=w.key),t.includeDates&&(b.first=Jt(w.acc.loStamp,a),b.last=Jt(w.acc.hiStamp,a)),b.missingBefore=w.before,b.missingAfter=w.after,b.missingInterior=w.interior,b.largestGap=w.gap,b.coverage=Math.round(w.coverage*1e3)/1e3,b}),more:c.length-g.length}}var Re=6;function le(t){let e=t.slice().sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Or(t){let e=t.length;if(e<Re)return null;let n=t[0],i=t[0],r=0;for(let g of t)g<n&&(n=g),g>i&&(i=g),r+=g;if(n===i)return null;let s=le(t.map(Math.abs));if(s===0)return null;let a=[];for(let g=1;g<e;g++)a.push(t[g]-t[g-1]);let l=le(a.map(Math.abs))/s,o=(e-1)/2,u=r/e,d=0,f=0,c=0;for(let g=0;g<e;g++)d+=(g-o)*(t[g]-u),f+=(g-o)*(g-o),c+=(t[g]-u)*(t[g]-u);c/=e;let h=d/f,x=u-h*o,A=t.map((g,w)=>g-(x+h*w)),S=A.reduce((g,w)=>g+w,0)/e,p=0,y=0;for(let g=0;g<e;g++)p+=(A[g]-S)*(A[g]-S),g>0&&(y+=(A[g]-A[g-1])*(A[g]-A[g-1]));return p/=e,y/=e-1,{vnDetrended:p<=c*1e-12?2:y/p,relStep:l}}function He(t){let{stamps:e,series:n,values:i}=t,r=Math.min(e.length,i.length),s=new Map;for(let u=0;u<r;u++){let d=e[u],f=i[u];if(d===null||f===null||!Number.isFinite(f))continue;let c="";if(n&&(c=n[u]??"",c===""))continue;let h=s.get(c);h||s.set(c,h=new Map),h.set(d,(h.get(d)??0)+f)}let a=[],l=[],o=[];for(let u of s.values()){let d=[...u.entries()].sort((c,h)=>c[0]-h[0]).map(c=>c[1]),f=Or(d);f&&(a.push(f.vnDetrended),l.push(f.relStep),o.push(d.length))}return a.length===0?null:{series:a.length,points:Math.round(le(o)),vnDetrended:Math.round(le(a)*1e3)/1e3,relStep:Math.round(le(l)*1e4)/1e4}}function ts(t){let e=t.times.map(n=>j(n,t.pattern,t.locale)?.ms??null);return He({stamps:e,series:t.series,values:t.values})}var Pr=5e5,Lr=8,Fr=4,zr=5,Ye=1,je=2,Wr=4,$r=8;function Br(t,e,n){let[i,r]=[...t];if(e.isTemporal){let s=j(i,e.temporalTextPattern,n),a=j(r,e.temporalTextPattern,n);if(s&&a&&s.ms!==a.ms)return s.ms<a.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Gr(t,e,n){let{rows:i,text:r,locale:s}=t,a=Br(n.values,n,s),l=new Uint8Array(i.length),o=0;for(let u=0;u<i.length;u++){let d=r(i[u][e]);d===a.a?l[u]=1:d===a.b?l[u]=2:o++}return{code:l,blankRows:o,setOrder:a.setOrder}}function Vr(t,e){let{rows:n,text:i}=t,r=new Int32Array(n.length),s=new Map;for(let a=0;a<n.length;a++){let l=i(n[a][e]);if(l===""){r[a]=-1;continue}let o=s.get(l);o===void 0&&(o=s.size,s.set(l,o)),r[a]=o}return{ids:r,dict:s}}function Kr(t,e,n){let i=new Uint8Array(n);for(let s=0;s<t.length;s++){let a=e[s];if(a===0)continue;let l=t[s];if(l<0)continue;let o=i[l];i[l]=o&a?o|a<<2:o|a}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<n;s++){let a=i[s];a&Ye&&r.keysA++,a&je&&r.keysB++,(a&(Ye|je))===(Ye|je)&&r.keysBoth++,a&Wr&&r.dupA++,a&$r&&r.dupB++}return r}function Ur(t,e){let n=(t.dupA+t.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(t.keysA+t.keysB);return n<i||n===i&&t.keysBoth>e.keysBoth}var nn=t=>t==null||typeof t=="string"&&t.trim()==="";function Hr(t,e,n){if(t===e)return!0;let i=nn(t),r=nn(e);return i||r?i&&r:typeof t=="number"&&typeof e=="number"?!1:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():n(t).trim()===n(e).trim()}function rn(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Pr)return null;let r=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=zr).sort((b,_)=>(_.c.identifierNamed?1:0)-(b.c.identifierNamed?1:0)||_.c.distinct-b.c.distinct||b.i-_.i).slice(0,Lr),s=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,Fr);if(r.length===0||s.length===0)return null;let a=s.map(({c:b,i:_})=>Gr(t,_,b)),l=null;for(let{i:b}of r){let _=Vr(t,b);for(let M=0;M<s.length;M++){if(s[M].i===b)continue;let W=Kr(_.ids,a[M].code,_.dict.size);W.keysBoth<1||(!l||Ur(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:M,ids:_.ids,dict:_.dict})}}if(!l)return null;let{ids:o,dict:u,tally:d}=l,f=a[l.setNo],c=s[l.setNo].i,h=u.size,x=new Int32Array(h).fill(-1),A=new Int32Array(h).fill(-1);for(let b=0;b<i;b++){let _=f.code[b],M=o[b];_===0||M<0||(_===1?x[M]<0&&(x[M]=b):A[M]<0&&(A[M]=b))}let S=[];for(let b=0;b<n.length;b++)b!==l.keyIdx&&b!==c&&S.push(b);let p=0;for(let b=0;b<h;b++){let _=x[b],M=A[b];if(_<0||M<0)continue;let W=e[_],z=e[M],X=!0;for(let Q of S)if(!Hr(W[Q],z[Q],t.text)){X=!1;break}X&&p++}let y=p===d.keysBoth?100:p===0?0:Math.min(99,Math.max(1,Math.round(p/d.keysBoth*100))),C=new Map,g=new Map;for(let[b,_]of u){let M=x[_]>=0,W=A[_]>=0;if(!M&&!W)continue;let z=dt(b);mt(z)&&(M&&C.set(z,(C.get(z)??0)+1),W&&g.set(z,(g.get(z)??0)+1))}let w=b=>{let _=0;for(let M of b.values())M>=2&&(_+=M);return _};return{key:l.keyIdx,discriminator:c,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[c].name,keysA:d.keysA,keysB:d.keysB,keysBoth:d.keysBoth,duplicateKeysA:d.dupA,duplicateKeysB:d.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:w(C),looseCollisionsB:w(g),setOrder:f.setOrder}}}var Yr=t=>t==="Integer"||t==="Decimal";function jr(t){let e=[],n=[];return t.forEach((i,r)=>{if(i.twoValues){if(i.isBinaryFlag){e.push(r);return}i.isMeasure||i.isTemporal||i.isDatePart||i.identifierNamed||n.push(r)}}),[...e,...n].slice(0,6)}function Xr(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!Yr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function sn(t){let e=new Map,{rows:n,columns:i,text:r}=t;if(n.length===0||n.length>(t.maxRows??5e5))return e;let s=jr(i);if(s.length===0)return e;let a=Xr(i,new Set(s));if(a.length===0)return e;let l=s.map(o=>{let[u,d]=i[o].twoValues,f=new Uint8Array(n.length);for(let c=0;c<n.length;c++){let h=r(n[c][o]);f[c]=h===u?1:h===d?2:0}return f});for(let o of a){let u=new Float64Array(n.length),d=0;for(let y=0;y<n.length;y++){let C=n[y][o],g=C==null||C===""?NaN:typeof C=="number"?C:parseFloat(C);u[y]=g,g===g&&g!==1/0&&g!==-1/0&&d++}if(d<2)continue;let f=new Float64Array(d);for(let y=0,C=0;y<n.length;y++){let g=u[y];g===g&&g!==1/0&&g!==-1/0&&(f[C++]=g)}f.sort();let c=new Float64Array(d),h=0;for(let y=0;y<d;y++)(y===0||f[y]!==f[y-1])&&(c[h++]=f[y]);let x=new Int32Array(n.length).fill(-1);for(let y=0;y<n.length;y++){let C=u[y];if(!(C===C&&C!==1/0&&C!==-1/0))continue;let g=0,w=h-1;for(;g<w;){let b=g+w>>>1;c[b]<C?g=b+1:w=b}x[y]=g}let A=[],S=new Int32Array(h),p=new Int32Array(h);for(let y=0;y<s.length;y++){let C=l[y];S.fill(0),p.fill(0);let g=0,w=0;for(let U=0;U<n.length;U++){let m=x[U];m<0||(C[U]===1?(S[m]++,g++):C[U]===2&&(p[m]++,w++))}if(g===0||w===0)continue;let b=g<=w,_=b?g:w,M=b?w:g,W=b?S:p,z=b?p:S,X=0,Q=0,ue=0;for(let U=0;U<h;U++){let m=W[U],T=z[U];X+=m*(Q+.5*T),Q+=T,m+T>=2&&(ue+=m+T)}A.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(X/(_*M)*1e4)/1e4,nMinority:_,nMajority:M,ties:ue})}A.length>0&&e.set(o,A)}return e}var an=12,qr=100,Zr=.3,Qr=.9,Jr=120,ei=1900,ti=2100,ni=0,ri=20,ii=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ie(t){if(!t)return!1;let e=J(t);return e.length===0?!1:ii.has(e[e.length-1])?!0:Ut(t)!==null}var si=new Set(["year","yr","fy"]),oi=t=>J(t).some(e=>si.has(e))||ct(t)!==null,ai=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function Xe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function qe(t){if(!Number.isInteger(t)||t<19000101||t>21001231)return!1;let e=Math.floor(t/100)%100,n=t%100;return e>=1&&e<=12&&n>=1&&n<=31}var li=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ui=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ci=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function cn(t,e){let n=[],i=0,r=di(t,e,n,()=>{i++});if(r)return r;if(i>0||n.length<2)return null;let s=It(n,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function di(t,e,n,i){let r=0,s=0,a=0,l=0,o=0,u="",d=0,f="",c=0,h=0,x=0,A=0,S=!1;for(let b of t){if(b==null)continue;let _=String(b).trim();if(_==="")continue;r++,n.push(_);let M;if(M=li.exec(_)){i();let W=+M[2],z=+M[3];W>=1&&W<=12&&z>=1&&z<=31&&(s++,M[4]!==void 0&&a++,M[6]!==void 0&&l++)}else if(M=ui.exec(_)){i();let W=+M[3],z=+M[4];W>=1&&W<=12&&z>=1&&z<=31&&(u&&u!==M[2]&&(S=!0),u=M[2],o++)}else if(M=ci.exec(_)){i();let W=+M[1],z=+M[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==M[2]&&(S=!0),f=M[2],d++,W>12&&x++,z>12&&A++,M[5]!==void 0&&c++,M[7]!==void 0&&h++)}if(r>=200)break}if(r<2||(s+o+d)/r<.8||(s>0?1:0)+(o>0?1:0)+(d>0?1:0)!==1||S)return null;if(s>0)return a===s?{pattern:l===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${u}%m${u}%d`,orderFrom:"iso"};if(x>0&&A>0)return null;let C,g;x>0?(C=!0,g="values"):A>0?(C=!1,g="values"):f==="."?(C=!0,g="shape"):(C=!ze(e),g="locale");let w=C?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return c===d?{pattern:w+(h===d?" %H:%M:%S":" %H:%M"),orderFrom:g}:{pattern:w,orderFrom:g}}function mi(t,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(t))return!1;let n=t.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let i=ee(n);return i.length>0&&e[i]!==void 0}function fi(t,e){let n=new Map,i=new Map;for(let l of t){let o=re(l);if(!o||"month"in o)continue;let u=se(o.word),d=u.some(c=>c.lang==="en"),f=ee(o.word);for(let c of new Set(u.map(h=>h.lang)))c!=="en"&&(n.has(c)||(n.set(c,new Set),i.set(c,new Set)),n.get(c).add(f),d||i.get(c).add(f))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&i.get(l).size>=1),s=0,a=new Map(r.map(l=>[l,0]));for(let l of e){let o=re(l);if(!o)continue;if("month"in o){s++;continue}let u=se(o.word);if(u.length===0)continue;let d=u.some(f=>f.lang==="en");for(let f of r)(d||u.some(c=>c.lang===f))&&a.set(f,a.get(f)+1)}return s+Math.max(0,...a.values())}var gi=/(?:19|20)[0-9]{2}/;function pi(t){let e=new Map,n=0;for(let r of t){if(!gi.test(ne(r)))continue;let s=new Set(ge(r).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(s.size!==0){if(s.has("en")){n++;continue}for(let a of s)e.set(a,(e.get(a)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function hi(t){let{dataType:e,name:n,isMeasure:i,distinctCount:r}=t;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=t.minNum,a=t.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let o=s>=1900&&a<=2100;if(o&&r>=2&&oi(n)||o&&r>=3&&r===a-s+1)return!0;let u=Xe(s)&&Xe(a),d=qe(s)&&qe(a);if(u||d){if(!t.sampleValues)return!0;let f=0,c=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let x=Number(String(h).trim());if(Number.isFinite(x)&&(u?Xe(x):qe(x))&&c++,f>=60)break}if(f>=2&&c===f)return!0}return!1}if(t.sampleValues){let s=t.locale?Se(t.locale):null,a=0,l=0,o=[],u=[];for(let d of t.sampleValues){if(d==null||d==="")continue;a++;let f=String(d).trim();if(o.push(f),ai.test(f)||mi(f,s)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+pi(u)+fi(o,u))/a>=.8||cn(o,t.locale)!==null)return!0}return!1}function yi(t){let e=Z((t||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Lt(t)}function bi(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:s,maxNum:a,discourageAgg:l}=t,o=100,u=.01,d="";for(let c of r){if(c.distinct<2||c.distinct>o)continue;let h=r.filter(y=>y.idx!==c.idx).map(y=>y.idx),x=new Map;for(let y of e){let C=y[n];if(typeof C!="number"||!Number.isFinite(C))continue;let g=h.length?h.map(b=>String(y[b])).join(d):"",w=x.get(g);w||(w={sum:0,cset:new Set},x.set(g,w)),w.sum+=C,w.cset.add(String(y[c.idx]))}let A=0,S=0,p=0;for(let y of x.values())y.cset.size<2||(p++,Math.abs(y.sum-100)<=100*u?A++:Math.abs(y.sum-1)<=1*u&&S++);if(p>=2&&(A/p>=.9||S/p>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(l)return{additivity:"intensive_rate"};let f=yi(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&s>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function dn(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:s,prec:a,maxval:l,minval:o}=t,u=l-o+1,d=u>0?r/u:1,f=s>0?r/s:0,c=e==="Decimal"||a>0;return!n&&Ie(i)?"Categorical":d>=Qr&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(ft(i)&&r<=Jr||o>=ei&&l<=ti||o>=ni&&l<=ri)?"Ordinal":n?"Continuous":!c&&Number.isFinite(u)&&r>an&&r===s&&u===r?"Categorical":r>an&&(c||r>=qr||f>=Zr)?"Continuous":"Categorical"}function ln(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:dn({dataType:t.dataType,isMeasure:!1,name:t.name,distinct:n.distinct,nonblank:n.nonblank,prec:n.prec,maxval:typeof n.maxval=="number"?n.maxval:0,minval:typeof n.minval=="number"?n.minval:0,ordinalNeedsWholeNumbers:!0})==="Continuous"}function Si(t){let e=null;for(let n=0;n<t.length;n++){let i=t[n];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=t.slice()),e[n]=r)}return e||t}var un=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;dedupRows=!0;emitLegacyAggAliases=!1;deriveProvinces=!0;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let n=0;n<this._cols.length;n++){let i=this._cols[n];!i||!/date|time/i.test(String(i.dataType??""))||lt(this._rows.map(r=>r[n]))&&e.add(n)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(n=>!!(n&&n.isMeasure));return this._cols.forEach((n,i)=>{if(!n||n.isMeasure||this._declaredDimensions.has(n)||n.dataType!=="Integer"&&n.dataType!=="Decimal")return;let r=new Set,s=0,a=0,l=null,o=null;for(let u of this._rows){let d=u[i],f=this.STR(d);if(f!=""&&(r.add(f),s++,(l===null||d<l)&&(l=d),(o===null||d>o)&&(o=d),n.dataType=="Decimal")){let c=this.getPrecision(d);c>a&&(a=c)}}e[i]=ln(n,!1,{distinct:r.size,nonblank:s,prec:a,minval:l,maxval:o})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return at(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,n){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=this.wallClockColumnIndexes(),a=[],l=[],o=[];for(let m of this._cols){let T=new Map,O=[],D=0,v=0,k=0,F=null,P=null,E=null,G=!1,V=!0,I=!0,N=null,K=!1,L=s.has(i);for(let R of this._rows){let $=R[i],B=L&&$ instanceof Date?fe($):$,H=this.STR(B);if(H!=""){if(D+=H.length,T.set(H,(T.get(H)||0)+1),v++,m.dataType=="Integer"||m.dataType=="Decimal"||m.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),m.dataType=="Integer"||m.dataType=="Decimal"){if(E===null?E=B:E+=B,m.dataType=="Decimal"){let q=this.getPrecision(B);q>k&&(k=q)}O.push(B)}else G=G||this.hasTimeComponent(B);K&&(B<N?V=!1:B>N&&(I=!1)),N=B,K=!0}}if(v>=3&&(V&&!I?m.sortedDirection="asc":I&&!V?m.sortedDirection="desc":m.sortedDirection="none"),v>0&&T.size>0&&!m.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(m.modalShare=R/v,m.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(ce=>it(ce).trim().toLowerCase()).sort(),q=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ce=>B[0]===ce[0]&&B[1]===ce[1]),mn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(m.name);(q||mn)&&(m.isBinaryFlag=!0)}}else m.isMeasure&&(m.dataType==="Integer"||m.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(m.isBinaryFlag=!0);if(m.dataType=="DateTime"&&(m.dateWithTime=G,G&&ut(L?this._rows.map(R=>R[i]instanceof Date?fe(R[i]):R[i]):this._rows.map(R=>R[i]))?m.timeOfDayOnly=!0:delete m.timeOfDayOnly),m.isTemporal=hi({dataType:m.dataType,name:m.name,isMeasure:m.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),m.isTemporal&&m.dataType==="String"&&!m.isMeasure){let R=cn(T.keys(),n);R&&(m.temporalTextPattern=R.pattern)}if(m.timeOfDayOnly)delete m.temporalCadence;else if(m.isTemporal&&!m.isMeasure){let R=Zt(T.keys(),{includeBounds:r>=20,pattern:m.temporalTextPattern,locale:n});R&&(m.temporalCadence=R)}this.updateColumnStats10(r,m,v,T,k,P,F),this.updateColumnStats20(r,O,v,E,m,D,G,F,P,k,T,n),ln(m,this._declaredDimensions.has(m),{distinct:T.size,nonblank:v,prec:k,minval:F,maxval:P})&&(m.isMeasure=!0,m.valueNature="Continuous",m.geoKind=void 0,m.geoMatchPct=void 0,m.geoAmbiguous=void 0,m.dominantGeoRegion=void 0,m.dominantGeoRegionPct=void 0,m.geoRegionCount=void 0),a[i]=m.isMeasure||T.size>2e3?null:new Set(T.keys()),l[i]=T.size,o[i]=T.size===2?[...T.keys()].sort():null,i++}Tt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((m,T)=>{let O=this._cols[T];m.kind&&(O.geoKind=m.kind,O.geoMatchPct=m.matchPct,m.ambiguous&&(O.geoAmbiguous=!0)),m.rollupPct!==void 0&&(O.admin1RollupPct=m.rollupPct),m.regionCount!==void 0&&(O.admin1RegionCount=m.regionCount),m.countryCount!==void 0&&(O.admin1CountryCount=m.countryCount),m.dominantRegion&&(O.dominantGeoRegion=m.dominantRegion,O.dominantGeoRegionPct=m.dominantRegionPct)});let u=this.getGeoExtent();if(u&&u.dominantFrame&&this._geoExtentLatIdx>=0){let m=this._cols[this._geoExtentLatIdx];m.geoKind||(m.dominantGeoRegion=u.dominantFrame,m.dominantGeoRegionPct=u.dominantFramePct,this.deriveProvinces&&(m.admin1RollupPct=u.dominantFramePct))}let d=[];this._cols.forEach((m,T)=>{m.isMeasure||d.push({idx:T,distinct:m.distinctCount??0,name:m.name})}),this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=typeof m.lowValue=="number"?m.lowValue:null,D=typeof m.highValue=="number"?m.highValue:null,v=bi({rows:this._rows,measureColIdx:T,measureName:m.name,candidateDims:d,minNum:O,maxNum:D,discourageAgg:!!m.discourageAggregationAcrossGroups});m.additivity=v.additivity,v.partOfWholeDim&&(m.partOfWholeDim=v.partOfWholeDim)});let f=50,c=4,h=d.filter(m=>m.distinct>=2&&m.distinct<=f);this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let K=typeof N=="number"?N:parseFloat(N);isNaN(K)||O.push(K)}if(O.length===0)return;let D=[...O].sort((I,N)=>I-N);if(D[0]===D[D.length-1])m.relativeDispersion=0;else if(D.length>=c){let I=me(D,.5),N=me(D,.1),K=me(D,.9);m.relativeDispersion=Math.abs(I)>1e-9?Math.round((K-N)/Math.abs(I)*1e3)/1e3:void 0}else m.relativeDispersion=void 0;let v=[];for(let I of h){let N=new Set;for(let K of this._rows){let L=K[T];L==null||L===""||N.add(this.STR(K[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(m.nonBlankGroups=v);let k=0;for(let I of O)k+=I;k/=O.length;let F=0;for(let I of O)F+=(I-k)*(I-k);if(F<=1e-12)return;let P=[],E=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),K=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return K(.75)-K(.25)},V=G(O);for(let I of h){let N=new Map;for(let R of this._rows){let $=R[T];if($==null||$==="")continue;let B=typeof $=="number"?$:parseFloat($);if(isNaN(B))continue;let H=this.STR(R[I.idx])+"",q=N.get(H);q?(q.s+=B,q.n++,q.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let K=0;for(let R of N.values()){let $=R.s/R.n;K+=R.n*($-k)*($-k)}P.push({otherColumn:I.name,eta2:Math.round(K/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(V)&&V>1e-9){let R=(Math.max(...L)-Math.min(...L))/V;E.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(m.groupDiscrimination=P),E.length>0&&(m.spreadDiscrimination=E)});let x=.97,A=.8,S=8,p=5,y=this._cols.map((m,T)=>({c:m,i:T})).filter(m=>m.c.isMeasure);for(let m=0;m<y.length;m++)for(let T=m+1;T<y.length;T++){let O=y[m].i,D=y[T].i,v=0,k=0,F=0,P=0,E=0,G=0;for(let L of this._rows){let R=L[O],$=L[D];if(R==null||R===""||$===null||$===void 0||$==="")continue;let B=typeof R=="number"?R:parseFloat(R),H=typeof $=="number"?$:parseFloat($);isNaN(B)||isNaN(H)||(v++,k+=B,F+=H,P+=B*B,E+=H*H,G+=B*H)}if(v<p)continue;let V=v*P-k*k,I=v*E-F*F;if(V<=1e-12||I<=1e-12)continue;let N=(v*G-k*F)/Math.sqrt(V*I),K=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[y[m].c,y[T].c])(L.maxAbsMeasureCorrelation===void 0||K>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=K);if(Math.abs(N)>=x){let L=y[m].c,R=y[T].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),L.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(L.name)}else if(Math.abs(N)>=A){let L=y[m].c,R=y[T].c,$=Math.round(N*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:R.name,r:$}),R.correlatedWithMeasures.push({otherColumn:L.name,r:$})}}for(let{c:m}of y)m.correlatedWithMeasures&&(m.correlatedWithMeasures.sort((T,O)=>Math.abs(O.r)-Math.abs(T.r)||(T.otherColumn<O.otherColumn?-1:1)),m.correlatedWithMeasures.length=Math.min(m.correlatedWithMeasures.length,S));for(let m=0;m<this._cols.length;m++){let T=a[m];if(!T||T.size===0)continue;let O=[];for(let D=0;D<this._cols.length;D++){if(D===m)continue;let v=a[D];if(!v||v.size===0)continue;let k=0;for(let P of T)v.has(P)&&k++;let F=Math.round(k/T.size*100);F>0&&O.push({otherColumn:this._cols[D].name,percentShared:F})}O.length>0&&(this._cols[m].sharedValueRatioWithOthers=O)}let C=50,g=[];for(let m=0;m<this._cols.length;m++){let T=a[m];T&&T.size>=2&&T.size<=C&&g.push(m)}if(g.length>=2){let m=new Map,T=(D,v)=>D+":"+v;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++)m.set(T(g[D],g[v]),new Map);for(let D of this._rows)for(let v=0;v<g.length;v++){let k=this.STR(D[g[v]])+"";for(let F=v+1;F<g.length;F++){let P=""+this.STR(D[g[F]]),E=m.get(T(g[v],g[F])),G=k+""+P;E.set(G,(E.get(G)??0)+1)}}let O=new Map;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++){let k=g[D],F=g[v],P=a[k].size,E=a[F].size,G=m.get(T(k,F)),V=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(V/(P*E)*100),K=V===P,L=V===E;if((this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:K,minCellCount:I,distinctCombinations:V}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:V}),K&&P>E){let R=O.get(k);(!R||E<R.card)&&O.set(k,{name:this._cols[F].name,card:E,ratio:E/P})}if(L&&E>P){let R=O.get(F);(!R||P<R.card)&&O.set(F,{name:this._cols[k].name,card:P,ratio:P/E})}}for(let[D,v]of O)this._cols[D].primaryParentColumn=v.name,this._cols[D].nestingRatio=Math.round(v.ratio*100)/100}let w=6,b=this._rows.length;for(let m=0;m<this._cols.length;m++){let T=this._cols[m];if(T.isMeasure||T.primaryParentColumn)continue;let O=T.distinctCount??0;if(O<=C||b>0&&O>=b)continue;let D=[];for(let v=0;v<this._cols.length;v++){if(v===m)continue;let k=this._cols[v];if(k.isMeasure)continue;let F=k.distinctCount??0;F<2||F>=O||D.push(v)}D.sort((v,k)=>(this._cols[v].distinctCount??0)-(this._cols[k].distinctCount??0));for(let v of D.slice(0,w)){let k=new Map,F=!0;for(let E of this._rows){let G=this.STR(E[m])+"",V=this.STR(E[v])+"",I=k.get(G);if(I===void 0)k.set(G,V);else if(I!==V){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/O*100)/100;break}}let _=.01,M=.05,W=.95,z=8,X=8,Q=6,ue=500,U=[];for(let m=0;m<this._cols.length&&U.length<X;m++){let T=this._cols[m].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(m)}if(U.length>=3&&this._rows.length>=z){let m=Math.min(this._rows.length,ue),T=U.map(P=>{let E=[];for(let I=0;I<m;I++){let N=this._rows[I][P],K=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(K))return null;E.push(K)}let G=E[0],V=!1;for(let I of E)if(I!==G){V=!0;break}return V?E:null}),O=U.map((P,E)=>E).filter(P=>T[P]!==null),D=P=>{let E=P.slice().sort((V,I)=>V-I),G=E.length>>1;return E.length%2?E[G]:(E[G-1]+E[G])/2},v=null,k=[],F=P=>{if(k.length>=3){let E=k.map(N=>T[N]),G=E[0].length,V=new Array(G);for(let N=0;N<G;N++){let K=0;for(let L of E)K+=L[N];V[N]=K}let I=D(V);if(I>0){let N=0;for(let L of V)Math.abs(L-I)<=I*_&&N++;let K=N/G;if(K>=W){let L=1;for(let R of E){let $=D(R)/I;$<L&&(L=$)}L>=M&&(!v||k.length>v.cols.length)&&(v={cols:k.slice(),total:I,matched:K})}}}if(!(k.length>=Q))for(let E=P;E<O.length;E++)k.push(O[E]),F(E+1),k.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(V=>this._cols[U[V]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let V of P.cols)this._cols[U[V]].constantSumGroup=G}}return this.applyTwoSetPairing(n,a),this.applyScoreSeparation(l,o),this.applySeriesCompleteness(r,n,a),this.applyMeasurePersistence(n,a),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=rn({rows:this._rows,columns:this._cols.map((r,s)=>{let a=n[s];return{name:r.name,values:a,distinct:a?a.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,n){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=sn({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:n[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,n,i){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,d)=>({c:u,i:d})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let s=this.seriesKeyIndex(n,i);if(s<0)return;let a=this._cols[s],l=this._rows.map(u=>this.STR(u[s])),o=e>=20&&(a.dataType!=="String"||Array.isArray(a.safeDistinctValues));for(let{c:u,i:d}of r){let f=tn({periods:this._rows.map(c=>this.STR(c[d])),series:l,seriesColumn:a.name,pattern:u.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:o});f&&(u.seriesCompleteness=f)}}seriesKeyIndex(e,n){let i=[],r=[];this._cols.forEach((a,l)=>{let o=n[l];o&&(i.push(l),r.push({name:a.name,dataType:a.dataType,isMeasure:!!a.isMeasure,isTemporal:!!a.isTemporal,isDatePart:!!a.isDatePart,isReassembledDate:!!a.isReassembledDate,isBinaryFlag:!!a.isBinaryFlag,geoKind:a.geoKind,identifierNamed:Ie(a.name),values:o,rows:this._rows.length,locale:e}))});let s=en(r);return s<0?-1:i[s]}applyMeasurePersistence(e,n){for(let o of this._cols)o.persistence!==void 0&&delete o.persistence;let i=[];if(this._cols.forEach((o,u)=>{o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal"||o.dataType==="Double")&&i.push(u)}),i.length===0||this._rows.length<Re)return;let r=-1,s=[];for(let o=0;o<this._cols.length&&r<0;o++){let u=this._cols[o];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let d=this._rows.map(f=>j(this.STR(f[o]),u.temporalTextPattern,e)?.ms??null);new Set(d.filter(f=>f!==null)).size<Re||(r=o,s=d)}if(r<0)return;let a=this.seriesKeyIndex(e,n),l=a>=0?this._rows.map(o=>this.STR(o[a])):void 0;for(let o of i){let u=this._rows.map(f=>{let c=f[o];if(c==null||c==="")return null;let h=typeof c=="number"?c:parseFloat(String(c).replace(/,/g,""));return Number.isFinite(h)?h:null}),d=He({stamps:s,series:l,values:u});d&&(this._cols[o].persistence={timeColumn:this._cols[r].name,...a>=0?{seriesColumn:this._cols[a].name}:{},...d})}}updateColumnStats20(e,n,i,r,s,a,l,o,u,d,f,c){if(e>=20){let h=[...n].sort((S,p)=>S-p),x=Math.floor(h.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=a/i),this._rows.length>0){let S=p=>{let y=p instanceof Date?p:typeof p=="string"?Ee(p)??new Date(p):new Date(p),C=this.wholeDayIso(y);return C?C+"T00:00:00.000Z":isNaN(y.getTime())?p:y.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!o?s.lowValue=o:s.lowValue=S(o),s.dataType!="DateTime"||l||!u?s.highValue=u:s.highValue=S(u),s.medianValue=h.length===0?null:h.length%2===0?s.dataType=="Integer"?Math.round((h[x-1]+h[x])/2):(h[x-1]+h[x])/2:h[x],s.numericPrecision=d}if(h.length>0){let S=i>0&&r!=null?r/i:s.avgValue??0,p=h.length,y=0,C=0;for(let b of h){let _=b-S;y+=_*_,C+=_*_*_}let g=y/p,w=Math.sqrt(g);s.skewness=g===0?0:C/p/(w*w*w),s.stdDev=Math.sqrt(g)}r!==null&&(s.sum=r);let A=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]);if(s.topCategories=A.slice(0,10).map(S=>S[1]),!s.isMeasure&&A.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=A.slice(0,5).map(S=>S[0])),e>=20)){let S=A.map(y=>y[0]),p=pe(S,c);if(p!==null)s.ordinalPattern=p.pattern,s.orderedDomain=p.orderedDomain;else if(s.dataType==="String"){let y=gt(S);y!==null&&(s.safeDistinctValues=y)}}if(h.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let S=p=>h[Math.floor((h.length-1)*p)];s.quantiles={p05:S(.05),p25:S(.25),p75:S(.75),p95:S(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let h=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]).map(S=>S[0]);s.formatSignature=be(h);let x=i>0?a/i:void 0,A=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!A.test(s.formatSignature)&&(x===void 0||x>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((A,S)=>S[1]-A[1]),x=At(h.map(A=>A[0]),s.name,c);if(x!==null&&(s.geoKind=x.geoKind,s.geoMatchPct=x.geoMatchPct,x.geoAmbiguous&&(s.geoAmbiguous=!0),x.geoKind.indexOf("country")===0)){let A=yt(h);A&&(s.dominantGeoRegion=A.dominantGeoRegion,s.dominantGeoRegionPct=A.dominantGeoRegionPct,s.geoRegionCount=A.regionCount,A.middleEastPct>0&&(s.middleEastPct=A.middleEastPct))}}}updateColumnStats10(e,n,i,r,s,a,l){let o=this._rows.length-i;e>=10&&(n.blankCount=o),n.distinctCount=r.size+(o!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=dn({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:s,maxval:a,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal"))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,r)=>{i.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let i of this._rows)n.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=a=>Qe(a,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((a,l)=>{let o=e(a.name),u=a.dataType==="Integer"||a.dataType==="Decimal";u&&n<0&&o.some(d=>d==="lat"||d==="latitude")?n=l:u&&i<0&&o.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(i=l),r<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(r=l)}),n<0||i<0){let a=(u,d)=>{let f=0;for(let c of this._rows){let h=c[u];if(h==null||h==="")continue;let x=Number(h);if(!Number.isFinite(x)||x<-d||x>d)return!1;f++}return f>0},l=-1,o=-1;if(this._cols.forEach((u,d)=>{if(!(u.dataType==="Integer"||u.dataType==="Decimal"))return;let f=e(u.name),c=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Nt(f);c==="lat"&&l<0&&a(d,90)?l=d:c==="lon"&&o<0&&a(d,180)&&(o=d)}),l<0||o<0)return null;n=l,i=o}this._geoExtentLatIdx=n;let s=[];for(let a of this._rows){let l=a[n],o=a[i],u=l==null||l===""?null:Number(l),d=o==null||o===""?null:Number(o);s.push({lat:u,lon:d,country:r>=0&&he(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=ht(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return jt(e,ot)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=n[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,a=this.wallClockColumnIndexes();for(let o of this._rows){let u={};for(let d=0;d<this._cols.length;d++){let f=this._cols[d],c=o[d];if(this.STR(c)!=""){if(e&&f.dataType=="String")if(s.has(c))c=s.get(c);else{let h=this.obfuscateString(c);s.set(c,h),c=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=c instanceof Date?c:typeof c=="string"?Ee(c)??new Date(c):new Date(c);c=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(d)&&c instanceof Date&&(c=fe(c));r-=this.STR(c).length}else c=null;u[d]=c,--r}if(n.push(u),--i,i<=0||r<=0)break}return await on.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return on.unparse([this._cols.map((n,i)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}setGenerationColumns(e){let n=(e??[]).filter(r=>!!r&&typeof r.n=="string"&&r.n!==""&&typeof r.q=="string"&&r.q!=="").map(r=>({n:r.n,q:r.q})),i=JSON.stringify(n);i!==this._generationColumnsSig&&(this._generationColumns=n,this._generationColumnsSig=i,this._englishAliases=new Map)}aliasesForCode(e){let n=Ve(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:i.reason});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=Ve(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let n of this.liveEnglishAliases().values())e.push({name:n.name,alias:n.alias,reason:n.reason});return e}legacyAliases(){let e=[];for(let n of this._cols)n&&n.hostName&&n.hostName!==n.name&&e.push({name:this.STR(n.name),alias:this.STR(n.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let n=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return n;let i=String(e),r=new Set;for(let l of this._cols)l&&(r.add(this.STR(l.name)),l.hostName&&r.add(this.STR(l.hostName)));let s=new Map,a=new Set;for(let l=0;l<this._cols.length;l++){if(!this._cols[l])continue;let o=this._hostQueryNames[l],u=Wt(o,this._cols[l].name,this._cols[l].dataType)?[]:zt(o),d=this.STR(this._cols[l].name),f=[];if(o){for(let h of this._generationColumns)if(h.q===o)for(let x of[h.n,Ge(h.n)])x&&x!==d&&!u.includes(x)&&!f.includes(x)&&f.push(x)}let c=[...u,...f].filter(h=>!r.has(h)&&oe(i,h));c.length===1&&(s.set(c[0],[...s.get(c[0])??[],l]),f.includes(c[0])&&a.add(c[0]))}for(let[l,o]of s){if(o.length!==1)continue;let u=this.STR(this._cols[o[0]].name);n.set(o[0],{name:u,alias:l,headerName:!oe(i,u),reason:a.has(l)?"stored-query-name":"english-implicit-agg"})}return n}liveEnglishAliases(){let e=new Map;for(let[n,i]of this._englishAliases){let r=this._cols?this._cols[n]:null;r&&this.STR(r.name)===i.name&&e.set(n,i)}return e}addRow(e,n){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=st(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Si(e)),this._inferredMeasureFlags=null,this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}invalidateStats(){this._computedStatsForLevel=null,this._geoExtentComputed=!1,this._geoExtent=null,this._geoExtentLatIdx=-1}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map,this._generationColumns=[],this._generationColumnsSig="[]"}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let n=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Ge(r);!s||s===r||n.has(s)||(n.delete(r),n.add(s),i.hostName=r,i.name=s)}}};export{fn as a,gn as b,wi as c,Mi as d,Tt as e,It as f,vn as g,Rn as h,Nt as i,En as j,kn as k,Dn as l,On as m,Me as n,Vn as o,Ge as p,Ve as q,zt as r,Bt as s,Hn as t,Vt as u,Kt as v,Oi as w,Pi as x,Li as y,Xn as z,qn as A,Zn as B,Ut as C,oe as D,ur as E,Vi as F,cr as G,dr as H,j as I,Zt as J,Tr as K,vr as L,Rr as M,Dr as N,en as O,tn as P,ts as Q,Ie as R,cn as S,hi as T,yi as U,bi as V,dn as W,ln as X,Si as Y,un as Z};
|
|
@@ -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 I,Z as A,f as R}from"./chunk-
|
|
2
|
+
import{R as I,Z as A,f as R}from"./chunk-J5EZ7BH7.mjs";import{a as h,c as x,d as E,e as L}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import M from"papaparse";var k=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})?)?$/,N=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function O(e,o=".",n=!1){if(n)return"DateTime";let r=0,s=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,s++,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++,s++;continue}if(L(m,o)){s++;continue}if((v.test(m)||N.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":s===l?"Decimal":"String"}function _(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 s=String(e).trim();if(s==="")return null;switch(o){case"Integer":{let i=h(s);return P.test(i)?parseInt(i,10):null}case"Decimal":return E(s,n);case"DateTime":return r?r.read(s):C(s);default:return s}}function $(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*q(e,o){for(let n of e)yield n?.[o]}function g(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,s=e.map((t,a)=>o.slice(0,k).map(u=>u?.[a])),i=s.map(t=>x(t,n.locale)),l=e.map((t,a)=>t.dataType===void 0||t.dataType==="DateTime"?R(q(o,a),{locale:n.locale??"en"}):null),c=e.map((t,a)=>t.dataType??O(s[a],i[a],l[a]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),b=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),j=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),D=e.map((t,a)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[a]==="Integer"||c[a]==="Decimal")&&!I(t.name));m.has(u)&&(f=!0),b.has(u)&&(f=!1);let T={name:t.name,dataType:c[a],isMeasure:f};return f&&j.has(u)&&(T.discourageAggregationAcrossGroups=!0),T}),d=new A;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(D),d.declareDimensions(D.filter((t,a)=>b.has(e[a].name.toLowerCase())));for(let t=0;t<o.length;t++){let a=o[t];d.addRow(Array.from({length:r},(u,f)=>_(a?.[f],c[f],i[f],l[f])),t)}let p=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),S=new Map(p.map(t=>[t.name,t]));e.forEach(t=>{let a=S.get(t.name);a&&(t.format&&(a.modelFormat=t.format),t.description&&(a.modelDesc=t.description))});let y=t=>{let a=S.get(t);if(a)return[a];let u=t.toLowerCase();return p.filter(f=>f.name.toLowerCase()===u)};for(let[t,a]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=a;for(let[t,a]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=a;for(let t of n.groupBy??[])for(let a of y(t))a.isGrouping=!0;return{columns:p,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function w(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function F(e,o){let n=[],r=new Set,s=Math.min(e.length,Math.max(1,o));for(let i=0;i<s;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 V(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],s=0;return M.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(s,l);s=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(...M.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function Y(e,o={}){switch(e.kind){case"csv":{let n=V(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 s=r[0].map(i=>(i??"").trim());return g(s.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 g(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 g(e.columns,w(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:F(n,o.columnScanLimit??k).map(s=>({name:s}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return g(r,w(n,r.map(s=>s.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 s=$(r.dataType);return{name:r.name,dataType:s,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(n,w(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{$ as a,V as b,Y as c};
|
package/dist/index.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{a as Sr,b as Rr}from"./chunk-HIVICMC5.mjs";import{a as xr,b as M,c as wr,d as k,e as E,f as _r,g as J,h as Z}from"./chunk-4J7WPYLM.mjs";import{a as br,b as Er,c as Tr}from"./chunk-VTOSDLGO.mjs";import{A as jn,B as Qn,C as Yn,D as Xn,E as Jn,F as Zn,G as er,H as tr,I as nr,J as rr,K as or,L as ir,M as sr,N as ar,O as lr,P as ur,Q as cr,R as dr,S as fr,T as mr,U as pr,V as gr,W as yr,X as hr,Z as Cr,a as hn,b as Cn,c as bn,d as En,e as Tn,g as An,h as Ln,i as vn,j as Pn,k as Mn,l as In,m as Nn,n as Fn,o as kn,p as Dn,q as Gn,r as Un,s as Wn,t as Vn,u as qn,v as Hn,w as Kn,x as zn,y as $n,z as Bn}from"./chunk-3V65PCPL.mjs";import{a as Sn}from"./chunk-U3H6UBOO.mjs";import{b as Rn,c as xn,d as wn,f as _n,g as On}from"./chunk-TZ74QIKA.mjs";import{a as fe,c as me,e as mn,f as pn,g as gn,h as yn}from"./chunk-YDYFP2T4.mjs";import{A as Y,B as nn,C as rn,D as de,E as I,F as on,G as sn,H as an,I as V,J as ln,K as un,L as cn,M as dn,N as X,O as fn,a as P,b as G,c as j,d as U,j as W,k as qt,l as Ht,m as Kt,n as zt,o as $t,q as Bt,r as jt,s as Q,t as Qt,u as Yt,v as Xt,w as Jt,x as Zt,y as en,z as tn}from"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import{a as Rt,b as xt,c as wt,d as _t,e as Ot,f as At,g as Lt,h as vt,i as Pt,j as Mt,k as It,l as Nt,m as Ut,n as Wt,o as Vt}from"./chunk-3ZAS32F5.mjs";import{b as Ft,c as kt,d as Dt,e as Gt}from"./chunk-5HI6TVMM.mjs";import{A as Ct,B as bt,C as Et,D as Tt,E as St,a as je,b as Qe,c as Ye,d as Xe,e as Je,f as Ze,g as et,h as tt,i as nt,j as rt,k as ot,l as it,m as st,n as at,o as lt,q as B,r as ut,s as ct,t as dt,u as ft,v as mt,w as pt,x as gt,y as yt,z as ht}from"./chunk-CZJ7M6A5.mjs";import{a as qe,b as He,c as Ke,d as ze,e as $e,f as $,g as Be}from"./chunk-WC4JINEZ.mjs";var ee=2,ye=400;function ne(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let r=U(String(n));if(!G(r)&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||re(e)<95)return!1;let n=t.filter(a=>ne(a)&&!I(a)).length,r=t.filter(a=>!ne(a)&&!!I(a)).length;return n>=1&&n>=r}function pe(e,t){if(!I(e))return!1;let n=W(e);return n?t==="world"?!0:de.has(n):!1}function re(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)ne(r)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){return I(e)?!0:Q()?Y(e).status!=="unmatched"||Y(e.trim().replace(/\s+/g,"-")).status!=="unmatched":!1}function q(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)oe(r)&&n++;return Math.round(n/t.length*1e3)/10}function se(e){let t=new Set;for(let n of e){if(n==null)continue;let r=String(n).trim();if(!G(U(r))&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function ie(e){let t=se(e);if(t.length===0)return 0;let n=0;for(let r of t)V(r).length>0&&n++;return Math.round(n/t.length*1e3)/10}function ge(e,t){return me(t,fe)?!0:se(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Or(e,t){let n=F(e);if(n.length===0)return 0;let r=0;for(let a of n)X(a,t)&&r++;return Math.round(r/n.length*1e3)/10}function te(e,t){let n=0;for(let r of F(e))t(r)&&n++;return n}function Ar(e,t){let n=0;for(let r of se(e))t(r)&&n++;return n}function Lr(e,t,n,r,a){let l=[],u=[],i={},C={},y=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&y.has(d)&&(i[s]=d)}let m=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&m.has(d)&&(i[s]=d)}let p=n?.zip;if(p&&y.has(p)){let s=h(p),d=ie(s);d<95?u.push(`zip=${p} (only ${d}% of values read as ZIPs)`):ge(s,p)?i.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&y.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>pe(S,r))?u.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(u.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):q(s)<95?u.push(`state=${c} (only ${q(s)}% of values are states/provinces)`):i.state=c}let g=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!g.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=h(d);if(N(S))continue;let O=q(S);if(O<95)continue;let z=te(S,oe),Ve=te(S,ce=>oe(ce)&&!pe(ce,r));z<ee&&Ve<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,g.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(g.has(s))continue;let d=h(s),S=ie(d);if(!(S<95)&&ge(d,s)&&!(Ar(d,O=>V(O).length>0)<ee)){i.zip=s,g.add(s),l.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(h(T))){let s=null;for(let d of b){if(g.has(d)||!N(h(d)))continue;let S=re(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(u.push(`country=${T} (only ${re(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.country=T),i.country=s.name,g.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(g.has(d))continue;let S=h(d),O=Or(S,r);O<j||te(S,z=>X(z,r))<ee||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?h(i.country):[],R=!!i.country&&N(L),v=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&v>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&u.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&u.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:l,refused:u,...Object.keys(C).length?{labelFallback:C}:{}}}var o=(e,...t)=>({part:e,langs:Object.freeze(t)}),ae=Object.freeze({jaar:o("year","nl"),kwartaal:o("quarter","nl"),maand:o("month","nl"),dag:o("day","nl","sv","da","nb"),jahr:o("year","de"),quartal:o("quarter","de"),monat:o("month","de"),tag:o("day","de"),ann\u00E9e:o("year","fr"),mois:o("month","fr"),jour:o("day","fr"),trimestre:o("quarter","fr","es","pt","it"),a\u00F1o:o("year","es"),mes:o("month","es"),d\u00EDa:o("day","es"),ano:o("year","pt"),m\u00EAs:o("month","pt"),dia:o("day","pt"),anno:o("year","it"),mese:o("month","it"),giorno:o("day","it"),\u0433\u043E\u0434:o("year","ru"),\u043C\u0435\u0441\u044F\u0446:o("month","ru"),\u0440\u0456\u043A:o("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:o("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:o("quarter","ru","uk"),\u0434\u0435\u043D\u044C:o("day","ru","uk"),rok:o("year","pl","cs","sk"),kwarta\u0142:o("quarter","pl"),miesi\u0105c:o("month","pl"),dzie\u0144:o("day","pl"),\u010Dtvrtlet\u00ED:o("quarter","cs"),m\u011Bs\u00EDc:o("month","cs"),den:o("day","cs"),\u0161tvr\u0165rok:o("quarter","sk"),mesiac:o("month","sk"),de\u0148:o("day","sk"),\u00E5r:o("year","sv","da","nb"),kvartal:o("quarter","sv","da","nb"),m\u00E5nad:o("month","sv"),m\u00E5ned:o("month","da","nb"),vuosi:o("year","fi"),vuosinelj\u00E4nnes:o("quarter","fi"),kuukausi:o("month","fi"),p\u00E4iv\u00E4:o("day","fi"),\u00E9v:o("year","hu"),negyed\u00E9v:o("quarter","hu"),h\u00F3nap:o("month","hu"),nap:o("day","hu"),y\u0131l:o("year","tr"),\u00E7eyrek:o("quarter","tr"),ay:o("month","tr"),g\u00FCn:o("day","tr"),\u03AD\u03C4\u03BF\u03C2:o("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:o("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:o("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:o("day","el"),an:o("year","ro"),trimestru:o("quarter","ro"),lun\u0103:o("month","ro"),zi:o("day","ro"),godina:o("year","hr"),tromjese\u010Dje:o("quarter","hr"),mjesec:o("month","hr"),dan:o("day","hr"),\u5E74:o("year","ja","zh"),\u56DB\u534A\u671F:o("quarter","ja"),\u5B63\u5EA6:o("quarter","zh"),\u6708:o("month","ja","zh"),\u65E5:o("day","ja","zh"),\uC5F0\uB3C4:o("year","ko"),\uBD84\uAE30:o("quarter","ko"),\uC6D4:o("month","ko"),\uC77C:o("day","ko"),tahun:o("year","id"),kuartal:o("quarter","id"),triwulan:o("quarter","id"),bulan:o("month","id"),hari:o("day","id"),n\u0103m:o("year","vi"),qu\u00FD:o("quarter","vi"),th\u00E1ng:o("month","vi"),ng\u00E0y:o("day","vi"),\u0E1B\u0E35:o("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:o("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:o("month","th"),\u0E27\u0E31\u0E19:o("day","th"),\u0627\u0644\u0633\u0646\u0629:o("year","ar"),\u0633\u0646\u0629:o("year","ar"),\u0627\u0644\u0639\u0627\u0645:o("year","ar"),\u0639\u0627\u0645:o("year","ar"),\u0627\u0644\u0631\u0628\u0639:o("quarter","ar"),\u0631\u0628\u0639:o("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":o("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:o("month","ar"),\u0634\u0647\u0631:o("month","ar"),\u0627\u0644\u064A\u0648\u0645:o("day","ar"),\u064A\u0648\u0645:o("day","ar"),\u05E9\u05E0\u05D4:o("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:o("quarter","he"),\u05D7\u05D5\u05D3\u05E9:o("month","he"),\u05D9\u05D5\u05DD:o("day","he"),\u0935\u0930\u094D\u0937:o("year","hi"),\u0938\u093E\u0932:o("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:o("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:o("month","hi"),\u092E\u093E\u0939:o("month","hi"),\u0926\u093F\u0928:o("day","hi"),\u0633\u0627\u0644:o("year","fa"),\u0645\u0627\u0647:o("month","fa"),\u0631\u0648\u0632:o("day","fa")}),vr=Object.freeze(Array.from(new Set(Object.values(ae).flatMap(e=>e.langs)))),he=Object.freeze(["fa","ar","he","th"]),Ce=1900,be=2100;function Pr(e,t){let n=[],r=$(t);try{r&&n.push(e.toLocaleLowerCase(r.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function Mr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let r of Pr(n,t)){let a=ae[r];if(a&&a.langs.includes(t))return a.part}return null}function Ir(e,t){return he.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=Ce&&t<=be:!0}var Nr=16e3;function Fr(e,t){if(!Array.isArray(e))return"";let n=[];for(let a of e){let l=typeof a?.n=="string"?a.n:"";l!==""&&n.push({n:l,q:typeof a?.q=="string"?a.q:""})}if(n.length===0)return"";let r=JSON.stringify({v:1,l:typeof t=="string"?t:"",c:n});return r.length>16e3?"":r}function kr(e){if(typeof e!="string"||e===""||e.length>16e3)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.v!==1||!Array.isArray(t.c))return null;let n=[];for(let r of t.c){if(!r||typeof r.n!="string"||r.n==="")return null;n.push({n:r.n,q:typeof r.q=="string"?r.q:""})}return n.length===0?null:{v:1,l:typeof t.l=="string"?t.l:"",c:n}}function Dr(e,t){if(!e)return!1;let n=e.l.trim().toLowerCase(),r=String(t??"").trim().toLowerCase();return n===""||r===""||n!==r}function Gr(e,t){if(!t||t.c.length===0)return[];let n=new Set(t.c.map(r=>r.n));return e.filter(r=>!n.has(r))}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ur=/\b(?:columns|cols|column)\b/i;function H(e,t){let n=Math.max(0,t-240),r=e.slice(n,t),a=r.lastIndexOf(";");return a>=0&&(r=r.slice(a+1)),Ur.test(r)}function Te(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Se(e,t,n){let r=Ee(t),a=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${r}\2`,"g"),l=new RegExp(String.raw`\.name\s*===?\s*(['"])${r}\1`,"g"),u=0,i;for(;(i=l.exec(e))!==null;)H(e,i.index)&&u++;let C=0;for(;(i=a.exec(e))!==null;){let y=i.index+i[0].lastIndexOf(".name");if(!H(e,y))continue;C++;let h=Ee(i[1]);if(!n(h))return!1}return C>0&&C===u}function Wr(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var Re=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function Vr(e,t){if(!e)return[];let n=new Set(t);for(let i of Re)n.add(i);let r=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,l;for(;(l=a.exec(e))!==null;)H(e,l.index)&&r.add(l[2]);if(r.size===0)return[];let u=[];return r.forEach(i=>{n.has(i)||Te(e,i)||u.push(i)}),u}function qr(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(r=>r.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let r of e.aliasesForCode(t))n.push(r.alias);return n}function xe(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function Hr(e,t,n){let r=xe(e,t);if(r===null||r<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,l=r>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let u=l.split("{n}").join(String(r)).split("{fields}").join(r===1?"field":"fields"),i=we(n);return i.length===0?u:u+" "+i.join(" ")}function we(e){if(!e||e.length===0)return[];let t=[],n=new Map,r=new Map;for(let l of e){let u=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(u!==""&&(n.has(u)||(t.push(u),n.set(u,0)),l.isDatePart===!0&&n.set(u,n.get(u)+1),l.isReassembledDate===!0&&!r.has(u))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",y=i!==""?i:C;y!==""&&r.set(u,y)}}let a=[];for(let l of t){let u=r.get(l),i=n.get(l)??0;!u||i===0||a.push(`'${u}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}var f=e=>e==null?"":String(e),A=e=>e===!0,le=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},_e=e=>{let t=le(e);return t!==null&&t>0?t:null},Kr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Oe(e,t){let n={};for(let[r,a]of Kr){let l=f(E(e,t+a));l&&(n[r]=l)}return n}function zr(e){return Array.isArray(e)?e.map(t=>({code:f(E(t,"code")),severity:f(E(t,"severity")),text:f(E(t,"text"))})).filter(t=>t.text!==""):[]}function $r(e){let t=m=>E(e,m),n=t("retryAfterSeconds"),r=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),l=Oe(e,"point"),u=Oe(e,"destPoint");Object.keys(u).length&&(l.dest=u);let i=t("retryable"),C=t("isPollFinal"),y=_e(t("chartMinWidth")),h=_e(t("chartMinHeight"));return{errorMessage:f(t("errorMessage")),errorCode:f(t("errorCode")),refusalCode:f(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:zr(t("notices")),freemiumStatusCode:f(t("freemiumStatusCode")),code:f(t("code")),language:f(t("language")),version:Number(t("version")??0),codeSummary:f(t("codeSummary")),chartName:f(t("chartName")??t("chartType")),finalChartName:f(t("finalChartName")),warningMessage:f(t("warningMessage")),outputHash:f(t("outputHash")),validatorToken:f(t("validatorToken")),editCodeKey:f(t("editCodeKey")),signedLLMRequestID:f(t("signedLLMRequestID")),userReply:f(t("userReply")),userReplyOutcome:f(t("userReplyOutcome")),improvementSuggestion:f(t("improvementSuggestion")),geoColumn:f(t("geoColumn")),geoKind:f(t("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:le(t("creditBalanceBefore")),creditCost:le(t("creditCost")),isServiceError:A(t("isServiceError")),isRateLimited:A(t("isRateLimited")),suppressSelectionGlyph:A(t("suppressSelectionGlyph")),isRefusal:A(t("isRefusal")),isVersionNotFound:A(t("isVersionNotFound")),isGenerationCancelled:A(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:f(t("servedCorrelationId")),...typeof C=="boolean"?{isPollFinal:C}:{},...f(t("pollOutcome"))!==""?{pollOutcome:f(t("pollOutcome"))}:{},...y!==null?{chartMinWidth:y}:{},...h!==null?{chartMinHeight:h}:{},...typeof r=="boolean"?{overrideThumbnailUpload:r}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}var Le=["app","table","map","kpi"];function ve(e){return typeof e=="string"&&Le.includes(e)?e:void 0}var Ae=e=>e==null?void 0:Number(e),D=e=>f(e)||void 0;function Br(e){let t=E(e,"charts"),n=E(e,"refused"),r=Array.isArray(t)?t.map(l=>{let u=C=>E(l,C),i=u("recommended");return{name:f(u("chartTypeName")??u("name")),description:f(u("description")??u("chartDesc")),rank:Ae(u("rank")),score:Ae(u("score")),renderer:D(u("renderer")),language:D(u("language")),isPreview:A(u("isPreview")),kind:ve(u("kind")),alsoWorthALook:A(u("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:D(u("viaProjection")),viaProjectionKey:D(u("viaProjectionKey")),detailNote:D(u("detailNote"))}}).filter(l=>l.name):null,a=Array.isArray(n)?n.map(l=>({name:f(E(l,"chartTypeName")??E(l,"name")),reason:f(E(l,"reason")),reasonCode:f(E(l,"reasonCode")),isVeto:A(E(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:f(E(e,"errorMessage")),errorCode:f(E(e,"errorCode")),charts:r,refused:a,noFitSummary:f(E(e,"noFitSummary"))}}function jr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var Pe=["working","analyze","generate","refine","review"];function Qr(e,t){let n=String(e??"").trim().toLowerCase();if(Pe.includes(n))return n;let r=String(t??"").toLowerCase();return r.includes("analyz")?"analyze":r.includes("generat")?"generate":r.includes("refin")?"refine":r.includes("review")?"review":null}var Yr="FREEMIUM_ATTEMPT_SPENT",Xr="CLIENT_SECRET_MISMATCH",Jr="FREEMIUM_COLUMN_CAP",Zr="OAUTH_TOKEN_EXPIRED",eo="OAUTH_SIGNED_OUT";function to(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function no(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,r=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function ro(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function oo(e){let t=0;for(let n of e){if(n.isMeasure)continue;let r=n.distinctCount;typeof r=="number"&&r>t&&(t=r)}return t}function Me(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,r=(e.codeVersion??0)>0?e.codeVersion:null,a=n??r??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function io(e){let t=e.fetchCorrelationId!=null,r=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=Me({genNew:r,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),l=e.fetchArmedAtMs,u=t&&typeof l=="number"&&Number.isSafeInteger(l)&&l>0?l:void 0,i=e.fetchCutAtMs,C=t&&typeof i=="number"&&Number.isSafeInteger(i)&&i>0?i:void 0,y=t?so(e.fetchCause):"";return{genNew:r,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...u!==void 0?{fetchArmedAtMs:u}:{},...C!==void 0?{fetchCutAtMs:C}:{},...y?{fetchCause:y}:{}}}function so(e){if(typeof e!="string")return"";let t=e.replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,120);return/[\ud800-\udbff]$/.test(t)&&(t=t.slice(0,-1)),t.trimEnd()}function ao(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function lo(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function uo(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function co(e,t,n){let r=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...r(t)?{rowsWithheld:t}:{},...r(n)?{rowsFilteredOut:n}:{}}}var fo={fit:"Best fit",variety:"Something different"};function Ie(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function mo(e){let t=Ie(e);return t?{qualifyOrder:t}:{}}function Ne(e,t){return e!=null&&t!=null&&e!==t}function po(e,t){return e?Ne(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var go=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Fe(e){let t=String(e??"").trim().toLowerCase();return go[t]??t}function ke(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Fe(n.dataType)]);return t}function yo(e){return B(ke(e))}var ho=2,Co=3,bo=4,Eo=64,To=8e3,So=6e4,Ro=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),xo=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function wo(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function _o(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Oo(){let e=new Set,t=new Set;return{firstDraw(n,r){if(!n)return!1;let a=`${n}|${r}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function Ao(e){return!!e&&!e.includes("|")&&!e.includes(",")}function ue(e,t,n,r){let a=`${e},${t}|${n}`;return r?`${a}|${Math.max(0,Math.round(r.count))}|${r.nonce}`:a}function Lo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,y=m=>{try{t.onFailure?.(m)}catch{}},h=async(m,p,c,g)=>{let b;try{let T=await a.post(p,c,g,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){y({channel:m,stage:"post",status:null,error:T});return}(b<200||b>299)&&y({channel:m,stage:"status",status:b,error:null})};return{async sendClientMessage(m){let p,c,g;try{p=`${C()}${u}/LogClientMsg/?nocache=${l.now()}`,c=M(m),g=k(c,r)}catch(b){y({channel:"client-message",stage:"build",status:null,error:b});return}await h("client-message",p,c,{"Content-Type":"text/plain","X-Signature":g})},async countEvent(m,p,c){let g,b;try{g=`${C()}${u}/eventlog`,b=ue(m,t.clientVersion,p,c)}catch(T){y({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",g,b,{"Content-Type":"text/plain"})}}}var De=2**31-1;function Ge(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function vo(e){return typeof e=="number"&&e>0&&e<=De?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${De} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Po(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,r=t.credentials??"omit";return{async post(a,l,u,i){let C=i.timeoutMs,y=vo(C);if(y)throw y;let h=new AbortController,m=!1,p=setTimeout(()=>{m=!0,h.abort(Ge(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let g=!1,b=()=>{g||(g=!0,clearTimeout(p),i.signal?.removeEventListener("abort",c))},T=_=>m?Ge(C):_,L;try{L=await n(a,{method:"POST",body:l,headers:u,credentials:r,signal:h.signal})}catch(_){throw b(),T(_)}let R=J(L),v=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...v,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...v,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ue=300;function We(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var Mo="/LLMChart/",Io="/LLMChart/qualify",No="/VisionReview/",Fo="/LLMChart/sample",ko="/RefundGenerate/",Do=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",K=async e=>JSON.parse(await e.text());function Go(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Uo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=m=>t.nocache?t.nocache(m):String(l.now());async function y(m,p,c,g,b){let T=`${i()}${u}${p}?nocache=${C(m)}`,L={"Content-Type":"text/plain","X-Signature":k(c,r)},R=g.signal??void 0,v=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Do(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,L,R?{timeoutMs:g.timeoutMs,signal:R}:{timeoutMs:g.timeoutMs})}catch(w){return v(!1,w)}if(x.status<200||x.status>299){let w="";if(g.readErrorBody===!1)Go(x);else try{w=(await x.text()).slice(0,Ue)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return v(!0,w)}}function h(m,p){if(!p||typeof p.timeoutMs!="number"||!Number.isFinite(p.timeoutMs)||p.timeoutMs<=0)throw new TypeError(`The ${m} call needs a positive deadline in milliseconds`);return p}return{async generate(m,p){let c=h("generate",p),g=c.onStage??void 0;return y("generate",Mo,M(m),c,b=>Z(b,g))},async qualify(m,p){let c=h("qualify",p),g=c.route??Io;if(typeof g!="string"||!g.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return y("qualify",g,M(m),c,K)},async review(m,p){let c=h("review",p),g=JSON.stringify(m);if(typeof g!="string")throw new TypeError("The review wire did not serialize to JSON");return y("review",No,g,c,K)},async sample(m,p){let c=h("sample",p);return y("sample",Fo,M(m),c,K)},async refund(m,p,c){let g=h("refund",p);if(typeof m!="string"||m.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let b=We(c),T=b?{CorrelationID:m.trim(),Reason:b}:{CorrelationID:m.trim()};return y("refund",ko,JSON.stringify(T),g,K)}}}export{hn as ADMIN1_MATCH_PCT,Cn as ADMIN1_MATCH_PCT_NAMED,j as CITY_ROLE_MATCH_PCT,Xt as CITY_TIE_RATIO,Ro as CLIENT_EVENT_KINDS,Xr as CLIENT_SECRET_MISMATCH,et as COMPOUND_MIN_STEM,Rt as CYCLE_MEMBERS,wt as CYCLE_WORDS,be as DATE_LEVEL_GREGORIAN_YEAR_MAX,Ce as DATE_LEVEL_GREGORIAN_YEAR_MIN,vr as DATE_LEVEL_LANGUAGES,ae as DATE_LEVEL_NAMES,he as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,er as DEFAULT_GAP_FACTOR,dt as DEFAULT_TEMPERATURE,xo as DRAW_REASONS,Yr as FREEMIUM_ATTEMPT_SPENT,Jr as FREEMIUM_COLUMN_CAP,Nr as GENERATION_COLUMNS_MAX_CHARS,ut as GET_RANDOM,nt as GLUED_STEM_MIN,ot as HANGUL_MIN_STEM,Re as HOST_SYNTHETIC_COLUMNS,Ue as HTTP_BODY_START_CHARS,jn as IDENTIFIER_HEAD_INITIAL,Qn as IDENTIFIER_UNFOLDED,Bn as IDENTIFIER_WORDS,Mn as INTENSIVE_SUFFIX_TOKENS,Pn as INTENSIVE_WORD_TOKENS,Cr as IndexedText,An as LATITUDE_WORDS,Ln as LONGITUDE_WORDS,kt as LOOSE_KEY_MIN_LENGTH,Gt as LooseIndex,tr as MAX_RUN_BOUNDS,eo as OAUTH_SIGNED_OUT,Zr as OAUTH_TOKEN_EXPIRED,vt as PERIOD_CODE_FORMS,Lt as PERIOD_CODE_MEMBERS,Pt as PERIOD_ORDINALS,Mt as PERIOD_UNFOLDED,Nn as POSITIONAL_SUFFIX_TOKENS,In as POSITIONAL_WORD_TOKENS,Sr as PREVIEW_OMITTED_FIELDS,Pe as PROGRESS_STAGE_IDS,Le as QUALIFY_KINDS,fo as QUALIFY_ORDER_LABELS,qt as REGION_FRAME_WINDOWS,P as ROLE_MATCH_PCT,or as SERIES_COMPLETENESS_MAX_LISTED,ir as SERIES_COMPLETENESS_MIN_FILL,sr as SERIES_KEY_MAX_DISTINCT,bo as SEV_ERROR,ho as SEV_INFO,Eo as SEV_USER_PRESENTED,Co as SEV_WARNING,B as SIMPLE_STRING_HASH,lt as STR,st as SUBSTRING_MIN,qe as SUPPORTED_LANGUAGES,He as SUPPORTED_LANGUAGE_CODES,So as TELEMETRY_TIMEOUT_DEV_MS,To as TELEMETRY_TIMEOUT_MS,$e as VOCABULARY_LANGUAGE_CODES,ze as VOCABULARY_ONLY_LANGUAGES,xt as YEAR_WORDS,Zt as admin1CodesForName,Q as admin1LookupRegistered,q as admin1MatchPct,Hn as allowedAggregations,Tt as anchorLocalWallClockDates,to as answerIsRetryable,yn as buildGeoIsoColumn,cn as buildGeoPointColumns,En as buildProvinceIsoColumn,_t as calendarWordIn,ao as capabilityFields,fn as cityMatchPct,dn as cityTagsFor,gr as classifyAdditivity,_o as classifyDraw,qn as classifyForAggregation,yr as classifyNumericValueNature,mr as classifyTemporal,Qt as clearAdmin1LookupForTests,Gn as codeNeedsLegacyAggNames,Xn as codeReadsColumn,Jn as codeReadsColumnsByRoleOrPosition,Dn as collapseRepeatedAggPrefix,Gr as columnsNeverGeneratedOn,Zn as columnsTheCodeReads,vn as coordinateAxisOfWords,Yt as countryIso2,zt as countryRegion,Oo as createDrawLedger,Uo as createGenerateClient,Lo as createTelemetryClient,no as credentialFields,co as dataCompletenessFields,Mr as dateLevelPart,Ir as dateLevelYearAdmits,St as datesAreTimeOfDayOnly,bt as datesCarryTimeOfDay,Rn as decimalSeparatorOf,Kn as defaultAggregation,xn as detectDecimalSeparator,Sn as detectFormatSignature,mn as detectGeo,Vt as detectOrdinalDomain,fr as detectTextDatePattern,wo as drawLocation,M as encodePayload,br as engineTypeForSqlType,Un as englishImplicitAggNames,ue as eventLogLine,io as fetchFields,Po as fetchTransport,je as foldName,Hr as freemiumColumnCapRefusal,xe as freemiumColumnsOverCap,we as freemiumDateHierarchyClauses,Dr as generationColumnsAnswerInLocale,rt as gluedPrefixStems,qr as guardColumnNames,xr as gzipWireText,it as hangulWordEndsWith,kn as hasDefaultAggPrefix,Je as hasUnsegmentedScript,pr as hostAggHint,Bt as inMiddleEast,Tr as ingest,zn as isAggregationAllowed,G as isBlankLike,rn as isCityTableLoaded,H as isColumnContextRef,ct as isDeterministicRefusal,Ao as isEventLogCode,ln as isGeoPointAmbiguity,dr as isIdentifierName,gn as isJoinGeoKind,tn as isKnownProvinceId,_r as isNdjsonContentType,Ut as isOrdinalFriendlyName,Dt as isUsableLooseKey,wr as keyedSigner,uo as leafCardinalityField,yt as localMidnightDateColumns,gt as localMidnightToUtcDay,Et as localWallClockDateColumns,At as localizedCycleIn,Yn as localizedIdentifierWordIn,Ot as localizedYearWordIn,N as looksLikeCountryColumn,Ft as looseNameKey,at as matchNameToken,oo as maxNonMeasureCardinality,Tn as measureAdmin1Columns,rr as measureCadence,cr as measurePersistence,ur as measureSeriesCompleteness,k as messageSignature,Vr as missingHardColumnRefs,On as monthLookupFor,Ye as nameLetterRuns,Vn as nameLooksIntensiveRate,Wn as nameLooksPositional,Te as nameProbeIsGuarded,Wr as nameProbeKeepsDrawing,Qe as nameWords,on as normalizeCountry,ht as normalizeLocalMidnightDates,_n as normalizeMonthKey,U as normalizePlaceName,an as normalizeZip5,po as offeredShortlistFor,Er as parseCsvRows,ft as parseDateStable,$r as parseGenerateResponse,kr as parseGenerationColumns,wn as parseNumberText,Br as parseQualifyResponse,jr as parseReviewVerdict,nr as parseTemporalPoint,Rr as payloadPreview,Nt as periodCodeSeries,lr as pickSeriesColumn,Qr as progressStageOf,hr as promotesToMeasure,en as provinceIdForAdmin1Code,bn as provinceIdForRow,ve as qualifyKindOf,mo as qualifyOrderField,Ie as qualifyOrderOf,Z as readGenerateStream,Xe as readName,It as readPeriodCode,E as readWireField,We as refundReasonCode,jt as registerAdmin1Lookup,nn as registerCityTable,Kt as registerIso3Regions,I as resolveAdmin1,Jt as resolveCityAdmin1,Me as resolveFetchVersion,un as resolveGeoPoint,Be as resolveLanguage,Lr as resolvePointRoles,lo as retryFields,Wt as safeDistinctValuesToShip,ke as schemaIdentity,yo as schemaIdentityKey,Fe as schemaTypeFamily,Fr as serializeGenerationColumns,ar as seriesKeyVerdict,$n as shareOfTotalIsHonest,Ne as shortlistIsStale,Fn as stripHostAggPrefix,$t as summarizeCountryRegions,Ht as summarizeGeoExtent,Ke as supportedLanguage,pn as toGeoIso,Ze as unsegmentedRuns,Ct as utcWallClock,ro as viewportFields,$ as vocabularyLanguage,mt as wholeDayFrame,pt as wholeDayIso,J as wireResponseFromFetch,tt as wordEndsWith,ie as zipMatchPct,V as zipPrefixCandidates,sn as zipToPrefix3};
|
|
2
|
+
import{a as Sr,b as Rr}from"./chunk-HIVICMC5.mjs";import{a as xr,b as M,c as wr,d as k,e as E,f as _r,g as J,h as Z}from"./chunk-4J7WPYLM.mjs";import{a as br,b as Er,c as Tr}from"./chunk-WNUCHG24.mjs";import{A as jn,B as Qn,C as Yn,D as Xn,E as Jn,F as Zn,G as er,H as tr,I as nr,J as rr,K as or,L as ir,M as sr,N as ar,O as lr,P as ur,Q as cr,R as dr,S as fr,T as mr,U as pr,V as gr,W as yr,X as hr,Z as Cr,a as hn,b as Cn,c as bn,d as En,e as Tn,g as An,h as Ln,i as vn,j as Pn,k as Mn,l as In,m as Nn,n as Fn,o as kn,p as Dn,q as Gn,r as Un,s as Wn,t as Vn,u as qn,v as Hn,w as Kn,x as zn,y as $n,z as Bn}from"./chunk-J5EZ7BH7.mjs";import{a as Sn}from"./chunk-U3H6UBOO.mjs";import{b as Rn,c as xn,d as wn,f as _n,g as On}from"./chunk-TZ74QIKA.mjs";import{a as fe,c as me,e as mn,f as pn,g as gn,h as yn}from"./chunk-YDYFP2T4.mjs";import{A as Y,B as nn,C as rn,D as de,E as I,F as on,G as sn,H as an,I as V,J as ln,K as un,L as cn,M as dn,N as X,O as fn,a as P,b as G,c as j,d as U,j as W,k as qt,l as Ht,m as Kt,n as zt,o as $t,q as Bt,r as jt,s as Q,t as Qt,u as Yt,v as Xt,w as Jt,x as Zt,y as en,z as tn}from"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import{a as Rt,b as xt,c as wt,d as _t,e as Ot,f as At,g as Lt,h as vt,i as Pt,j as Mt,k as It,l as Nt,m as Ut,n as Wt,o as Vt}from"./chunk-3ZAS32F5.mjs";import{b as Ft,c as kt,d as Dt,e as Gt}from"./chunk-5HI6TVMM.mjs";import{A as Ct,B as bt,C as Et,D as Tt,E as St,a as je,b as Qe,c as Ye,d as Xe,e as Je,f as Ze,g as et,h as tt,i as nt,j as rt,k as ot,l as it,m as st,n as at,o as lt,q as B,r as ut,s as ct,t as dt,u as ft,v as mt,w as pt,x as gt,y as yt,z as ht}from"./chunk-CZJ7M6A5.mjs";import{a as qe,b as He,c as Ke,d as ze,e as $e,f as $,g as Be}from"./chunk-WC4JINEZ.mjs";var ee=2,ye=400;function ne(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let r=U(String(n));if(!G(r)&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||re(e)<95)return!1;let n=t.filter(a=>ne(a)&&!I(a)).length,r=t.filter(a=>!ne(a)&&!!I(a)).length;return n>=1&&n>=r}function pe(e,t){if(!I(e))return!1;let n=W(e);return n?t==="world"?!0:de.has(n):!1}function re(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)ne(r)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){return I(e)?!0:Q()?Y(e).status!=="unmatched"||Y(e.trim().replace(/\s+/g,"-")).status!=="unmatched":!1}function q(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)oe(r)&&n++;return Math.round(n/t.length*1e3)/10}function se(e){let t=new Set;for(let n of e){if(n==null)continue;let r=String(n).trim();if(!G(U(r))&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function ie(e){let t=se(e);if(t.length===0)return 0;let n=0;for(let r of t)V(r).length>0&&n++;return Math.round(n/t.length*1e3)/10}function ge(e,t){return me(t,fe)?!0:se(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Or(e,t){let n=F(e);if(n.length===0)return 0;let r=0;for(let a of n)X(a,t)&&r++;return Math.round(r/n.length*1e3)/10}function te(e,t){let n=0;for(let r of F(e))t(r)&&n++;return n}function Ar(e,t){let n=0;for(let r of se(e))t(r)&&n++;return n}function Lr(e,t,n,r,a){let l=[],u=[],i={},C={},y=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&y.has(d)&&(i[s]=d)}let m=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&m.has(d)&&(i[s]=d)}let p=n?.zip;if(p&&y.has(p)){let s=h(p),d=ie(s);d<95?u.push(`zip=${p} (only ${d}% of values read as ZIPs)`):ge(s,p)?i.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&y.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>pe(S,r))?u.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(u.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):q(s)<95?u.push(`state=${c} (only ${q(s)}% of values are states/provinces)`):i.state=c}let g=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!g.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=h(d);if(N(S))continue;let O=q(S);if(O<95)continue;let z=te(S,oe),Ve=te(S,ce=>oe(ce)&&!pe(ce,r));z<ee&&Ve<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,g.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(g.has(s))continue;let d=h(s),S=ie(d);if(!(S<95)&&ge(d,s)&&!(Ar(d,O=>V(O).length>0)<ee)){i.zip=s,g.add(s),l.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(h(T))){let s=null;for(let d of b){if(g.has(d)||!N(h(d)))continue;let S=re(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(u.push(`country=${T} (only ${re(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.country=T),i.country=s.name,g.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(g.has(d))continue;let S=h(d),O=Or(S,r);O<j||te(S,z=>X(z,r))<ee||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?h(i.country):[],R=!!i.country&&N(L),v=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&v>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&u.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&u.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:l,refused:u,...Object.keys(C).length?{labelFallback:C}:{}}}var o=(e,...t)=>({part:e,langs:Object.freeze(t)}),ae=Object.freeze({jaar:o("year","nl"),kwartaal:o("quarter","nl"),maand:o("month","nl"),dag:o("day","nl","sv","da","nb"),jahr:o("year","de"),quartal:o("quarter","de"),monat:o("month","de"),tag:o("day","de"),ann\u00E9e:o("year","fr"),mois:o("month","fr"),jour:o("day","fr"),trimestre:o("quarter","fr","es","pt","it"),a\u00F1o:o("year","es"),mes:o("month","es"),d\u00EDa:o("day","es"),ano:o("year","pt"),m\u00EAs:o("month","pt"),dia:o("day","pt"),anno:o("year","it"),mese:o("month","it"),giorno:o("day","it"),\u0433\u043E\u0434:o("year","ru"),\u043C\u0435\u0441\u044F\u0446:o("month","ru"),\u0440\u0456\u043A:o("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:o("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:o("quarter","ru","uk"),\u0434\u0435\u043D\u044C:o("day","ru","uk"),rok:o("year","pl","cs","sk"),kwarta\u0142:o("quarter","pl"),miesi\u0105c:o("month","pl"),dzie\u0144:o("day","pl"),\u010Dtvrtlet\u00ED:o("quarter","cs"),m\u011Bs\u00EDc:o("month","cs"),den:o("day","cs"),\u0161tvr\u0165rok:o("quarter","sk"),mesiac:o("month","sk"),de\u0148:o("day","sk"),\u00E5r:o("year","sv","da","nb"),kvartal:o("quarter","sv","da","nb"),m\u00E5nad:o("month","sv"),m\u00E5ned:o("month","da","nb"),vuosi:o("year","fi"),vuosinelj\u00E4nnes:o("quarter","fi"),kuukausi:o("month","fi"),p\u00E4iv\u00E4:o("day","fi"),\u00E9v:o("year","hu"),negyed\u00E9v:o("quarter","hu"),h\u00F3nap:o("month","hu"),nap:o("day","hu"),y\u0131l:o("year","tr"),\u00E7eyrek:o("quarter","tr"),ay:o("month","tr"),g\u00FCn:o("day","tr"),\u03AD\u03C4\u03BF\u03C2:o("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:o("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:o("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:o("day","el"),an:o("year","ro"),trimestru:o("quarter","ro"),lun\u0103:o("month","ro"),zi:o("day","ro"),godina:o("year","hr"),tromjese\u010Dje:o("quarter","hr"),mjesec:o("month","hr"),dan:o("day","hr"),\u5E74:o("year","ja","zh"),\u56DB\u534A\u671F:o("quarter","ja"),\u5B63\u5EA6:o("quarter","zh"),\u6708:o("month","ja","zh"),\u65E5:o("day","ja","zh"),\uC5F0\uB3C4:o("year","ko"),\uBD84\uAE30:o("quarter","ko"),\uC6D4:o("month","ko"),\uC77C:o("day","ko"),tahun:o("year","id"),kuartal:o("quarter","id"),triwulan:o("quarter","id"),bulan:o("month","id"),hari:o("day","id"),n\u0103m:o("year","vi"),qu\u00FD:o("quarter","vi"),th\u00E1ng:o("month","vi"),ng\u00E0y:o("day","vi"),\u0E1B\u0E35:o("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:o("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:o("month","th"),\u0E27\u0E31\u0E19:o("day","th"),\u0627\u0644\u0633\u0646\u0629:o("year","ar"),\u0633\u0646\u0629:o("year","ar"),\u0627\u0644\u0639\u0627\u0645:o("year","ar"),\u0639\u0627\u0645:o("year","ar"),\u0627\u0644\u0631\u0628\u0639:o("quarter","ar"),\u0631\u0628\u0639:o("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":o("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:o("month","ar"),\u0634\u0647\u0631:o("month","ar"),\u0627\u0644\u064A\u0648\u0645:o("day","ar"),\u064A\u0648\u0645:o("day","ar"),\u05E9\u05E0\u05D4:o("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:o("quarter","he"),\u05D7\u05D5\u05D3\u05E9:o("month","he"),\u05D9\u05D5\u05DD:o("day","he"),\u0935\u0930\u094D\u0937:o("year","hi"),\u0938\u093E\u0932:o("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:o("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:o("month","hi"),\u092E\u093E\u0939:o("month","hi"),\u0926\u093F\u0928:o("day","hi"),\u0633\u0627\u0644:o("year","fa"),\u0645\u0627\u0647:o("month","fa"),\u0631\u0648\u0632:o("day","fa")}),vr=Object.freeze(Array.from(new Set(Object.values(ae).flatMap(e=>e.langs)))),he=Object.freeze(["fa","ar","he","th"]),Ce=1900,be=2100;function Pr(e,t){let n=[],r=$(t);try{r&&n.push(e.toLocaleLowerCase(r.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function Mr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let r of Pr(n,t)){let a=ae[r];if(a&&a.langs.includes(t))return a.part}return null}function Ir(e,t){return he.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=Ce&&t<=be:!0}var Nr=16e3;function Fr(e,t){if(!Array.isArray(e))return"";let n=[];for(let a of e){let l=typeof a?.n=="string"?a.n:"";l!==""&&n.push({n:l,q:typeof a?.q=="string"?a.q:""})}if(n.length===0)return"";let r=JSON.stringify({v:1,l:typeof t=="string"?t:"",c:n});return r.length>16e3?"":r}function kr(e){if(typeof e!="string"||e===""||e.length>16e3)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.v!==1||!Array.isArray(t.c))return null;let n=[];for(let r of t.c){if(!r||typeof r.n!="string"||r.n==="")return null;n.push({n:r.n,q:typeof r.q=="string"?r.q:""})}return n.length===0?null:{v:1,l:typeof t.l=="string"?t.l:"",c:n}}function Dr(e,t){if(!e)return!1;let n=e.l.trim().toLowerCase(),r=String(t??"").trim().toLowerCase();return n===""||r===""||n!==r}function Gr(e,t){if(!t||t.c.length===0)return[];let n=new Set(t.c.map(r=>r.n));return e.filter(r=>!n.has(r))}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ur=/\b(?:columns|cols|column)\b/i;function H(e,t){let n=Math.max(0,t-240),r=e.slice(n,t),a=r.lastIndexOf(";");return a>=0&&(r=r.slice(a+1)),Ur.test(r)}function Te(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Se(e,t,n){let r=Ee(t),a=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${r}\2`,"g"),l=new RegExp(String.raw`\.name\s*===?\s*(['"])${r}\1`,"g"),u=0,i;for(;(i=l.exec(e))!==null;)H(e,i.index)&&u++;let C=0;for(;(i=a.exec(e))!==null;){let y=i.index+i[0].lastIndexOf(".name");if(!H(e,y))continue;C++;let h=Ee(i[1]);if(!n(h))return!1}return C>0&&C===u}function Wr(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var Re=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function Vr(e,t){if(!e)return[];let n=new Set(t);for(let i of Re)n.add(i);let r=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,l;for(;(l=a.exec(e))!==null;)H(e,l.index)&&r.add(l[2]);if(r.size===0)return[];let u=[];return r.forEach(i=>{n.has(i)||Te(e,i)||u.push(i)}),u}function qr(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(r=>r.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let r of e.aliasesForCode(t))n.push(r.alias);return n}function xe(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function Hr(e,t,n){let r=xe(e,t);if(r===null||r<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,l=r>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let u=l.split("{n}").join(String(r)).split("{fields}").join(r===1?"field":"fields"),i=we(n);return i.length===0?u:u+" "+i.join(" ")}function we(e){if(!e||e.length===0)return[];let t=[],n=new Map,r=new Map;for(let l of e){let u=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(u!==""&&(n.has(u)||(t.push(u),n.set(u,0)),l.isDatePart===!0&&n.set(u,n.get(u)+1),l.isReassembledDate===!0&&!r.has(u))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",y=i!==""?i:C;y!==""&&r.set(u,y)}}let a=[];for(let l of t){let u=r.get(l),i=n.get(l)??0;!u||i===0||a.push(`'${u}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}var f=e=>e==null?"":String(e),A=e=>e===!0,le=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},_e=e=>{let t=le(e);return t!==null&&t>0?t:null},Kr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Oe(e,t){let n={};for(let[r,a]of Kr){let l=f(E(e,t+a));l&&(n[r]=l)}return n}function zr(e){return Array.isArray(e)?e.map(t=>({code:f(E(t,"code")),severity:f(E(t,"severity")),text:f(E(t,"text"))})).filter(t=>t.text!==""):[]}function $r(e){let t=m=>E(e,m),n=t("retryAfterSeconds"),r=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),l=Oe(e,"point"),u=Oe(e,"destPoint");Object.keys(u).length&&(l.dest=u);let i=t("retryable"),C=t("isPollFinal"),y=_e(t("chartMinWidth")),h=_e(t("chartMinHeight"));return{errorMessage:f(t("errorMessage")),errorCode:f(t("errorCode")),refusalCode:f(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:zr(t("notices")),freemiumStatusCode:f(t("freemiumStatusCode")),code:f(t("code")),language:f(t("language")),version:Number(t("version")??0),codeSummary:f(t("codeSummary")),chartName:f(t("chartName")??t("chartType")),finalChartName:f(t("finalChartName")),warningMessage:f(t("warningMessage")),outputHash:f(t("outputHash")),validatorToken:f(t("validatorToken")),editCodeKey:f(t("editCodeKey")),signedLLMRequestID:f(t("signedLLMRequestID")),userReply:f(t("userReply")),userReplyOutcome:f(t("userReplyOutcome")),improvementSuggestion:f(t("improvementSuggestion")),geoColumn:f(t("geoColumn")),geoKind:f(t("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:le(t("creditBalanceBefore")),creditCost:le(t("creditCost")),isServiceError:A(t("isServiceError")),isRateLimited:A(t("isRateLimited")),suppressSelectionGlyph:A(t("suppressSelectionGlyph")),isRefusal:A(t("isRefusal")),isVersionNotFound:A(t("isVersionNotFound")),isGenerationCancelled:A(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:f(t("servedCorrelationId")),...typeof C=="boolean"?{isPollFinal:C}:{},...f(t("pollOutcome"))!==""?{pollOutcome:f(t("pollOutcome"))}:{},...y!==null?{chartMinWidth:y}:{},...h!==null?{chartMinHeight:h}:{},...typeof r=="boolean"?{overrideThumbnailUpload:r}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}var Le=["app","table","map","kpi"];function ve(e){return typeof e=="string"&&Le.includes(e)?e:void 0}var Ae=e=>e==null?void 0:Number(e),D=e=>f(e)||void 0;function Br(e){let t=E(e,"charts"),n=E(e,"refused"),r=Array.isArray(t)?t.map(l=>{let u=C=>E(l,C),i=u("recommended");return{name:f(u("chartTypeName")??u("name")),description:f(u("description")??u("chartDesc")),rank:Ae(u("rank")),score:Ae(u("score")),renderer:D(u("renderer")),language:D(u("language")),isPreview:A(u("isPreview")),kind:ve(u("kind")),alsoWorthALook:A(u("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:D(u("viaProjection")),viaProjectionKey:D(u("viaProjectionKey")),detailNote:D(u("detailNote"))}}).filter(l=>l.name):null,a=Array.isArray(n)?n.map(l=>({name:f(E(l,"chartTypeName")??E(l,"name")),reason:f(E(l,"reason")),reasonCode:f(E(l,"reasonCode")),isVeto:A(E(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:f(E(e,"errorMessage")),errorCode:f(E(e,"errorCode")),charts:r,refused:a,noFitSummary:f(E(e,"noFitSummary"))}}function jr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var Pe=["working","analyze","generate","refine","review"];function Qr(e,t){let n=String(e??"").trim().toLowerCase();if(Pe.includes(n))return n;let r=String(t??"").toLowerCase();return r.includes("analyz")?"analyze":r.includes("generat")?"generate":r.includes("refin")?"refine":r.includes("review")?"review":null}var Yr="FREEMIUM_ATTEMPT_SPENT",Xr="CLIENT_SECRET_MISMATCH",Jr="FREEMIUM_COLUMN_CAP",Zr="OAUTH_TOKEN_EXPIRED",eo="OAUTH_SIGNED_OUT";function to(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function no(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,r=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function ro(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function oo(e){let t=0;for(let n of e){if(n.isMeasure)continue;let r=n.distinctCount;typeof r=="number"&&r>t&&(t=r)}return t}function Me(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,r=(e.codeVersion??0)>0?e.codeVersion:null,a=n??r??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function io(e){let t=e.fetchCorrelationId!=null,r=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=Me({genNew:r,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),l=e.fetchArmedAtMs,u=t&&typeof l=="number"&&Number.isSafeInteger(l)&&l>0?l:void 0,i=e.fetchCutAtMs,C=t&&typeof i=="number"&&Number.isSafeInteger(i)&&i>0?i:void 0,y=t?so(e.fetchCause):"";return{genNew:r,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...u!==void 0?{fetchArmedAtMs:u}:{},...C!==void 0?{fetchCutAtMs:C}:{},...y?{fetchCause:y}:{}}}function so(e){if(typeof e!="string")return"";let t=e.replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,120);return/[\ud800-\udbff]$/.test(t)&&(t=t.slice(0,-1)),t.trimEnd()}function ao(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function lo(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function uo(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function co(e,t,n){let r=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...r(t)?{rowsWithheld:t}:{},...r(n)?{rowsFilteredOut:n}:{}}}var fo={fit:"Best fit",variety:"Something different"};function Ie(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function mo(e){let t=Ie(e);return t?{qualifyOrder:t}:{}}function Ne(e,t){return e!=null&&t!=null&&e!==t}function po(e,t){return e?Ne(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var go=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Fe(e){let t=String(e??"").trim().toLowerCase();return go[t]??t}function ke(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Fe(n.dataType)]);return t}function yo(e){return B(ke(e))}var ho=2,Co=3,bo=4,Eo=64,To=8e3,So=6e4,Ro=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),xo=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function wo(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function _o(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Oo(){let e=new Set,t=new Set;return{firstDraw(n,r){if(!n)return!1;let a=`${n}|${r}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function Ao(e){return!!e&&!e.includes("|")&&!e.includes(",")}function ue(e,t,n,r){let a=`${e},${t}|${n}`;return r?`${a}|${Math.max(0,Math.round(r.count))}|${r.nonce}`:a}function Lo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,y=m=>{try{t.onFailure?.(m)}catch{}},h=async(m,p,c,g)=>{let b;try{let T=await a.post(p,c,g,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){y({channel:m,stage:"post",status:null,error:T});return}(b<200||b>299)&&y({channel:m,stage:"status",status:b,error:null})};return{async sendClientMessage(m){let p,c,g;try{p=`${C()}${u}/LogClientMsg/?nocache=${l.now()}`,c=M(m),g=k(c,r)}catch(b){y({channel:"client-message",stage:"build",status:null,error:b});return}await h("client-message",p,c,{"Content-Type":"text/plain","X-Signature":g})},async countEvent(m,p,c){let g,b;try{g=`${C()}${u}/eventlog`,b=ue(m,t.clientVersion,p,c)}catch(T){y({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",g,b,{"Content-Type":"text/plain"})}}}var De=2**31-1;function Ge(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function vo(e){return typeof e=="number"&&e>0&&e<=De?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${De} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Po(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,r=t.credentials??"omit";return{async post(a,l,u,i){let C=i.timeoutMs,y=vo(C);if(y)throw y;let h=new AbortController,m=!1,p=setTimeout(()=>{m=!0,h.abort(Ge(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let g=!1,b=()=>{g||(g=!0,clearTimeout(p),i.signal?.removeEventListener("abort",c))},T=_=>m?Ge(C):_,L;try{L=await n(a,{method:"POST",body:l,headers:u,credentials:r,signal:h.signal})}catch(_){throw b(),T(_)}let R=J(L),v=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...v,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...v,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ue=300;function We(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var Mo="/LLMChart/",Io="/LLMChart/qualify",No="/VisionReview/",Fo="/LLMChart/sample",ko="/RefundGenerate/",Do=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",K=async e=>JSON.parse(await e.text());function Go(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Uo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=m=>t.nocache?t.nocache(m):String(l.now());async function y(m,p,c,g,b){let T=`${i()}${u}${p}?nocache=${C(m)}`,L={"Content-Type":"text/plain","X-Signature":k(c,r)},R=g.signal??void 0,v=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Do(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,L,R?{timeoutMs:g.timeoutMs,signal:R}:{timeoutMs:g.timeoutMs})}catch(w){return v(!1,w)}if(x.status<200||x.status>299){let w="";if(g.readErrorBody===!1)Go(x);else try{w=(await x.text()).slice(0,Ue)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return v(!0,w)}}function h(m,p){if(!p||typeof p.timeoutMs!="number"||!Number.isFinite(p.timeoutMs)||p.timeoutMs<=0)throw new TypeError(`The ${m} call needs a positive deadline in milliseconds`);return p}return{async generate(m,p){let c=h("generate",p),g=c.onStage??void 0;return y("generate",Mo,M(m),c,b=>Z(b,g))},async qualify(m,p){let c=h("qualify",p),g=c.route??Io;if(typeof g!="string"||!g.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return y("qualify",g,M(m),c,K)},async review(m,p){let c=h("review",p),g=JSON.stringify(m);if(typeof g!="string")throw new TypeError("The review wire did not serialize to JSON");return y("review",No,g,c,K)},async sample(m,p){let c=h("sample",p);return y("sample",Fo,M(m),c,K)},async refund(m,p,c){let g=h("refund",p);if(typeof m!="string"||m.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let b=We(c),T=b?{CorrelationID:m.trim(),Reason:b}:{CorrelationID:m.trim()};return y("refund",ko,JSON.stringify(T),g,K)}}}export{hn as ADMIN1_MATCH_PCT,Cn as ADMIN1_MATCH_PCT_NAMED,j as CITY_ROLE_MATCH_PCT,Xt as CITY_TIE_RATIO,Ro as CLIENT_EVENT_KINDS,Xr as CLIENT_SECRET_MISMATCH,et as COMPOUND_MIN_STEM,Rt as CYCLE_MEMBERS,wt as CYCLE_WORDS,be as DATE_LEVEL_GREGORIAN_YEAR_MAX,Ce as DATE_LEVEL_GREGORIAN_YEAR_MIN,vr as DATE_LEVEL_LANGUAGES,ae as DATE_LEVEL_NAMES,he as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,er as DEFAULT_GAP_FACTOR,dt as DEFAULT_TEMPERATURE,xo as DRAW_REASONS,Yr as FREEMIUM_ATTEMPT_SPENT,Jr as FREEMIUM_COLUMN_CAP,Nr as GENERATION_COLUMNS_MAX_CHARS,ut as GET_RANDOM,nt as GLUED_STEM_MIN,ot as HANGUL_MIN_STEM,Re as HOST_SYNTHETIC_COLUMNS,Ue as HTTP_BODY_START_CHARS,jn as IDENTIFIER_HEAD_INITIAL,Qn as IDENTIFIER_UNFOLDED,Bn as IDENTIFIER_WORDS,Mn as INTENSIVE_SUFFIX_TOKENS,Pn as INTENSIVE_WORD_TOKENS,Cr as IndexedText,An as LATITUDE_WORDS,Ln as LONGITUDE_WORDS,kt as LOOSE_KEY_MIN_LENGTH,Gt as LooseIndex,tr as MAX_RUN_BOUNDS,eo as OAUTH_SIGNED_OUT,Zr as OAUTH_TOKEN_EXPIRED,vt as PERIOD_CODE_FORMS,Lt as PERIOD_CODE_MEMBERS,Pt as PERIOD_ORDINALS,Mt as PERIOD_UNFOLDED,Nn as POSITIONAL_SUFFIX_TOKENS,In as POSITIONAL_WORD_TOKENS,Sr as PREVIEW_OMITTED_FIELDS,Pe as PROGRESS_STAGE_IDS,Le as QUALIFY_KINDS,fo as QUALIFY_ORDER_LABELS,qt as REGION_FRAME_WINDOWS,P as ROLE_MATCH_PCT,or as SERIES_COMPLETENESS_MAX_LISTED,ir as SERIES_COMPLETENESS_MIN_FILL,sr as SERIES_KEY_MAX_DISTINCT,bo as SEV_ERROR,ho as SEV_INFO,Eo as SEV_USER_PRESENTED,Co as SEV_WARNING,B as SIMPLE_STRING_HASH,lt as STR,st as SUBSTRING_MIN,qe as SUPPORTED_LANGUAGES,He as SUPPORTED_LANGUAGE_CODES,So as TELEMETRY_TIMEOUT_DEV_MS,To as TELEMETRY_TIMEOUT_MS,$e as VOCABULARY_LANGUAGE_CODES,ze as VOCABULARY_ONLY_LANGUAGES,xt as YEAR_WORDS,Zt as admin1CodesForName,Q as admin1LookupRegistered,q as admin1MatchPct,Hn as allowedAggregations,Tt as anchorLocalWallClockDates,to as answerIsRetryable,yn as buildGeoIsoColumn,cn as buildGeoPointColumns,En as buildProvinceIsoColumn,_t as calendarWordIn,ao as capabilityFields,fn as cityMatchPct,dn as cityTagsFor,gr as classifyAdditivity,_o as classifyDraw,qn as classifyForAggregation,yr as classifyNumericValueNature,mr as classifyTemporal,Qt as clearAdmin1LookupForTests,Gn as codeNeedsLegacyAggNames,Xn as codeReadsColumn,Jn as codeReadsColumnsByRoleOrPosition,Dn as collapseRepeatedAggPrefix,Gr as columnsNeverGeneratedOn,Zn as columnsTheCodeReads,vn as coordinateAxisOfWords,Yt as countryIso2,zt as countryRegion,Oo as createDrawLedger,Uo as createGenerateClient,Lo as createTelemetryClient,no as credentialFields,co as dataCompletenessFields,Mr as dateLevelPart,Ir as dateLevelYearAdmits,St as datesAreTimeOfDayOnly,bt as datesCarryTimeOfDay,Rn as decimalSeparatorOf,Kn as defaultAggregation,xn as detectDecimalSeparator,Sn as detectFormatSignature,mn as detectGeo,Vt as detectOrdinalDomain,fr as detectTextDatePattern,wo as drawLocation,M as encodePayload,br as engineTypeForSqlType,Un as englishImplicitAggNames,ue as eventLogLine,io as fetchFields,Po as fetchTransport,je as foldName,Hr as freemiumColumnCapRefusal,xe as freemiumColumnsOverCap,we as freemiumDateHierarchyClauses,Dr as generationColumnsAnswerInLocale,rt as gluedPrefixStems,qr as guardColumnNames,xr as gzipWireText,it as hangulWordEndsWith,kn as hasDefaultAggPrefix,Je as hasUnsegmentedScript,pr as hostAggHint,Bt as inMiddleEast,Tr as ingest,zn as isAggregationAllowed,G as isBlankLike,rn as isCityTableLoaded,H as isColumnContextRef,ct as isDeterministicRefusal,Ao as isEventLogCode,ln as isGeoPointAmbiguity,dr as isIdentifierName,gn as isJoinGeoKind,tn as isKnownProvinceId,_r as isNdjsonContentType,Ut as isOrdinalFriendlyName,Dt as isUsableLooseKey,wr as keyedSigner,uo as leafCardinalityField,yt as localMidnightDateColumns,gt as localMidnightToUtcDay,Et as localWallClockDateColumns,At as localizedCycleIn,Yn as localizedIdentifierWordIn,Ot as localizedYearWordIn,N as looksLikeCountryColumn,Ft as looseNameKey,at as matchNameToken,oo as maxNonMeasureCardinality,Tn as measureAdmin1Columns,rr as measureCadence,cr as measurePersistence,ur as measureSeriesCompleteness,k as messageSignature,Vr as missingHardColumnRefs,On as monthLookupFor,Ye as nameLetterRuns,Vn as nameLooksIntensiveRate,Wn as nameLooksPositional,Te as nameProbeIsGuarded,Wr as nameProbeKeepsDrawing,Qe as nameWords,on as normalizeCountry,ht as normalizeLocalMidnightDates,_n as normalizeMonthKey,U as normalizePlaceName,an as normalizeZip5,po as offeredShortlistFor,Er as parseCsvRows,ft as parseDateStable,$r as parseGenerateResponse,kr as parseGenerationColumns,wn as parseNumberText,Br as parseQualifyResponse,jr as parseReviewVerdict,nr as parseTemporalPoint,Rr as payloadPreview,Nt as periodCodeSeries,lr as pickSeriesColumn,Qr as progressStageOf,hr as promotesToMeasure,en as provinceIdForAdmin1Code,bn as provinceIdForRow,ve as qualifyKindOf,mo as qualifyOrderField,Ie as qualifyOrderOf,Z as readGenerateStream,Xe as readName,It as readPeriodCode,E as readWireField,We as refundReasonCode,jt as registerAdmin1Lookup,nn as registerCityTable,Kt as registerIso3Regions,I as resolveAdmin1,Jt as resolveCityAdmin1,Me as resolveFetchVersion,un as resolveGeoPoint,Be as resolveLanguage,Lr as resolvePointRoles,lo as retryFields,Wt as safeDistinctValuesToShip,ke as schemaIdentity,yo as schemaIdentityKey,Fe as schemaTypeFamily,Fr as serializeGenerationColumns,ar as seriesKeyVerdict,$n as shareOfTotalIsHonest,Ne as shortlistIsStale,Fn as stripHostAggPrefix,$t as summarizeCountryRegions,Ht as summarizeGeoExtent,Ke as supportedLanguage,pn as toGeoIso,Ze as unsegmentedRuns,Ct as utcWallClock,ro as viewportFields,$ as vocabularyLanguage,mt as wholeDayFrame,pt as wholeDayIso,J as wireResponseFromFetch,tt as wordEndsWith,ie as zipMatchPct,V as zipPrefixCandidates,sn as zipToPrefix3};
|
package/dist/indexedText.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{R as a,S as b,T as c,U as d,V as e,W as f,X as g,Y as h,Z as i}from"./chunk-
|
|
2
|
+
import{R as a,S as b,T as c,U as d,V as e,W as f,X as g,Y as h,Z as i}from"./chunk-J5EZ7BH7.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{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-WNUCHG24.mjs";import"./chunk-J5EZ7BH7.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.121",
|
|
4
4
|
"description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
package/dist/chunk-3V65PCPL.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a as be}from"./chunk-U3H6UBOO.mjs";import{a as xt,f as ee,g as Se,h as se,i as _e,j as re}from"./chunk-TZ74QIKA.mjs";import{b as bt,c as St,d as _t,e as At,f as Ct}from"./chunk-YDYFP2T4.mjs";import{c as pt,l as ht,n as he,p as yt,s as ie,w as ye,x as ke,y as De,z as Oe}from"./chunk-DTBXJVUG.mjs";import{e as ct,k as ge,m as ft,n as gt,o as pe}from"./chunk-3ZAS32F5.mjs";import{b as dt,d as mt}from"./chunk-5HI6TVMM.mjs";import{A as fe,B as lt,E as ut,a as ne,b as J,c as Qe,d as de,g as Je,h as et,j as tt,l as nt,m as rt,o as it,p as me,q as st,r as ot,u as Ee,w as at}from"./chunk-CZJ7M6A5.mjs";import{c as Ze,f as Ne}from"./chunk-WC4JINEZ.mjs";var mn=85,fn=60,gn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Pe=t=>Math.round(t*10)/10,Ae=t=>t.split("-")[0];function wt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=he(a);l&&(e.set(l,(e.get(l)||0)+s),n+=s)}),n===0)return{};let[i,r]=[...e].sort((s,a)=>a[1]-s[1])[0];return{dominantRegion:i,dominantRegionPct:Pe(100*r/n)}}function wi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Mt(e,t.provinceKind,t.country);if(!ie())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let i=ye(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return i.status==="resolved"?i.provinceId:null}function Mt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let s=Ct(t,e);return s?"US-"+s:null}if(!ie())return null;if(e==="admin1-code")return Oe(t)?t.toUpperCase():null;let i=n==null?null:String(n),r=new Set(ke(t,i).map(De).filter(s=>!!s));return r.size===1?[...r][0]:null}function Mi(t,e={}){let n=e.deriveProvinces!==!1,i=new Array(t.length),r=new Array(t.length),s=new Set,a=[],l=new Set,o=[],u=0,c=0,f=0,d=A=>{let S=A.toLowerCase();s.has(S)||(s.add(S),a.push(A))},h=A=>A==null||A===""?null:Number(A),x=new Map;return t.forEach((A,S)=>{i[S]=null,r[S]=null;let p=A.country===null||A.country===void 0||String(A.country).trim()===""?null:String(A.country).trim(),y=A.province===null||A.province===void 0?"":String(A.province).trim();if(y){let _=Mt(y,e.provinceKind,p);_?(i[S]=_,r[S]="province",u++):d(y);return}if(!n)return;let C=h(A.lat),g=h(A.lon),w=!1;if(e.locate&&C!==null&&g!==null&&isFinite(C)&&isFinite(g)){w=!0;let _=e.locate(C,g);if(_){i[S]=_,r[S]="coordinates",u++;return}}let b=A.city===null||A.city===void 0?"":String(A.city).trim();if(b&&ie()){let _=b.toLowerCase()+""+(p??""),M=x.get(_);if(M||(M=ye(b,{country:p}),x.set(_,M)),M.status==="resolved"&&M.provinceId){i[S]=M.provinceId,r[S]="city",u++;return}if(M.status==="ambiguous"){c++,l.has(_)||(l.add(_),o.length<8&&o.push(b));return}d(b);return}w&&f++}),{iso:i,source:r,unmatched:a,matchedRows:u,totalRows:t.length,ambiguousRows:c,ambiguousExamples:o,unplacedPoints:f}}function Tt(t,e,n={}){let i=new Map;if(!ie()||e.length===0)return i;let r=t.findIndex(l=>!l.isMeasure&&(l.geoKind||"").startsWith("country")),s=l=>l==null?"":String(l).trim(),a=l=>{let o=new Map;for(let h of e){let x=s(h[l]);if(!x)continue;let A=r>=0&&s(h[r])||null,S=x+""+(A??""),p=o.get(S);p?p.rows++:o.set(S,{city:x,country:A,rows:1})}if(o.size===0)return null;let u=0,c=0,f=new Set,d=new Map;return o.forEach(h=>{let x=ye(h.city,{country:h.country});x.status!=="unmatched"&&c++,!(x.status!=="resolved"||!x.provinceId)&&(u++,f.add(x.provinceId),d.set(x.cc,(d.get(x.cc)||0)+h.rows))}),{signals:{rollupPct:Pe(100*u/o.size),regionCount:f.size,countryCount:d.size,...wt(d)},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 _=a(o);_&&i.set(o,_.signals);return}if(u)return;let c=new Map,f=new Map;for(let _ of e){let M=s(_[o]);M&&(c.set(M,(c.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&s(_[r])||null))}if(c.size<3)return;let d=0,h=0,x=0,A=new Set,S=new Map;c.forEach((_,M)=>{if(Oe(M)){d++;let z=M.toUpperCase();A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_);return}let W=new Set(ke(M,f.get(M)).map(De).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];A.add(z),S.set(Ae(z),(S.get(Ae(z))||0)+_)}else W.size>1&&x++});let y=gn.test(l.name.replace(/[_-]+/g," "))?fn:mn,C=100*d/c.size,g=100*h/c.size,w=C>=g,b=w?C:g;if(b<y){if(n.cities===!1)return;let _=a(o);if(!_||_.cityPct<pt||_.distinct<_t&&!St(l.name,bt))return;i.set(o,_.signals);return}i.set(o,{kind:w?"admin1-code":"admin1-name",matchPct:Pe(b),ambiguous:!w&&x/c.size>.15?!0:void 0,regionCount:A.size,countryCount:S.size,...wt(S)})}),i}function ze(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Le={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},pn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,hn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,yn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,bn=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,Sn=new Set(["de","del","of"]),_n=new Set(["\u0433","\u0440","r"]),An=/^[\p{L}\p{M}\u0970\u05f3]+$/u,Fe=/^\d+$/;function Cn(t){let e=+t[1],n=+t[2],i=t[3]===void 0?0:+t[3],r=t[4]!==void 0;if(n>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s:i,seconds:t[3]!==void 0,meridiem:r}}function vt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=xt(e);let n=null,i=pn.exec(e);if(i){if(n=Cn(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=yn.exec(e)){let d=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Le,form:"cjk",key:d,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=hn.exec(e)){let d=r[2],h=r[4];if(d!==h)return null;let x=d.trim(),A=r[6];if(A&&x!==".")return null;let S=[r[1].length,r[3].length,r[5].length],p=S[0]===4,y=S[2]===4;return p===y||(p?S[1]>2||S[2]>2:S[0]>2||S[1]>2)?null:p&&x==="-"&&d==="-"&&S[1]===2&&S[2]===2?"iso":p&&x==="."&&d==="."&&!A&&!(S[1]===2&&S[2]===2)?null:{...Le,form:"numeric",key:`num|${p?"y":"x"}|${d}|${A}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:p,sep:d,trail:A}}let s=e.replace(bn,"$1").split(/[\s.,/-]+/).filter(d=>d!==""&&!Sn.has(d.toLowerCase()));if(s.length===4&&Fe.test(s[2])&&_n.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(d=>Fe.test(d)?"N":An.test(d)?"W":"?").join(""),l=s.map(d=>Fe.test(d)?d:""),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{...Le,form:"named",key:`named|${f}`,clock:n,day:o,year:u,word:c,namedOrder:f}}var xn=[31,28,31,30,31,30,31,31,30,31,30,31],wn=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&&wn(t)?29:xn[e-1]):!1}function Mn(t,e,n,i){let r=new Date(Date.UTC(2e3,e-1,n,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(t),r}function It(t,e={}){let n=(e.floor??1)>=1,i=new Map,r=new Map,s=0,a=null;for(let p of t){if(p==null)continue;if(typeof p!="string"){if(n)return null;s++;continue}let y=p.trim();if(y==="")continue;s++;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"){if(n)return null;continue}if(n){if(a===null)a=C;else if(C.key!==a.key)return null}else r.set(C.key,(r.get(C.key)??0)+1)}if(!n){let p=0,y="";for(let[C,g]of r)g>p&&(p=g,y=C);if(p===0||p/s<e.floor)return null;a=[...i.values()].find(C=>C!==null&&C!=="iso"&&C.key===y)??null}if(a===null)return null;let l=a.key,o=[...i.values()].filter(p=>p!==null&&p!=="iso"&&p.key===l),u,c="shape",f=null;if(a.form==="named"){if(u=a.namedOrder,f=_e(o.map(p=>p.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)u="ymd";else{let p=0,y=0;for(let C of o)C.a>12&&p++,C.b>12&&y++;if(p>0&&y>0)return null;p>0?(u="dmy",c="values"):y>0?(u="mdy",c="values"):a.sep.trim()==="."?(u="dmy",c="shape"):(u=ze(e.locale)?"mdy":"dmy",c="locale")}let d=p=>{if(p.form==="named"){let y=f.get(ee(p.word));return y===void 0?null:[p.year,y+1,p.day]}return p.yearFirst?[p.a,p.b,p.c]:u==="dmy"?[p.c,p.b,p.a]:[p.c,p.a,p.b]},h=1/0,x=-1/0,A=0;for(let p of o){let y=d(p);if(!y||!Rt(y[0],y[1],y[2])){if(n)return null;A++;continue}h=Math.min(h,y[0]),x=Math.max(x,y[0])}if(!n&&(r.get(l)-A)/s<e.floor||h>=2400&&x<=2699||h>=1300&&x<=1500)return null;let S={form:a.form,order:u,orderFrom:c,hasTime:o.some(p=>p.clock!==null),read(p){if(typeof p!="string")return null;let y=p.trim();if(y==="")return null;let C=i.get(y);if(C===void 0&&(C=vt(y),i.set(y,C)),C===null||C==="iso"||C.key!==l)return null;let g=d(C);return!g||!Rt(g[0],g[1],g[2])?null:Mn(g[0],g[1],g[2],C.clock)}};if(a.form!=="named"&&!o.some(p=>p.clock?.meridiem)){let p;a.form==="cjk"?p=a.cjkPattern:a.yearFirst?p=`%Y${a.sep}%m${a.sep}%d${a.trail}`:p=(u==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let y=o.filter(C=>C.clock!==null).length;y===0?S.pattern=p:y===o.length&&(S.pattern=p+(o.every(C=>C.clock.seconds)?" %H:%M:%S":" %H:%M"))}return S}import on from"papaparse";var Tn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},vn={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},We=t=>ne(t.normalize("NFC")).toLowerCase(),Rn=new Set(Object.values(Tn).flatMap(t=>(t??[]).map(We))),In=new Set(Object.values(vn).flatMap(t=>(t??[]).map(We)));function Nt(t){let e=!1,n=!1;for(let i of t){let r=We(i);Rn.has(r)?e=!0:In.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var Nn=["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"],En=["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"],kn=["latitude","longitude"],Dn=["latitude","longitude"];function Z(t){return ne(t)}var Dt=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],On=["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"],Pn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],Ln=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],Ce=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function $e(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ot=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+$e(Dt)+")\\s+)","i");function Et(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var Fn="[\u2013\u2014-]";function Pt(t){let e=t.filter(r=>!Et(r)),n=t.filter(Et),i=[];return e.length&&i.push("(?:\\s+|\\s*"+Fn+"\\s*)("+$e(e)+")"),n.length&&i.push("\\s*("+$e(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Be=Pt(Pn),zn=Pt(Ln);function xe(t,e){let n=e.exec(t);if(!n)return null;let i=t.slice(0,n.index);return i.trim()===""?null:{base:i,label:(n[1]??n[2]??"").toLowerCase()}}function Lt(t){let e=Z(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of On)if(e.startsWith(r+" "))return Ce[r]??"avg";for(let r of Dt)if(e.startsWith(r+" ")||e===r)return Ce[r]??"sum";let n=xe(e,zn);if(n)return Ce[n.label]??"avg";let i=xe(e,Be);return i?Ce[i.label]??"sum":null}var Wn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,$n=new RegExp("\\b("+Nn.join("|")+")\\b|("+En.join("|")+")$","i"),Bn=new RegExp("\\b("+kn.join("|")+")\\b|("+Dn.join("|")+")$","i");function Me(t){if(!t)return"";let e=String(t),n=Z(e),i=Ot.exec(n);if(i)return e.slice(i[0].length).trim();let r=xe(n,Be);return(r?e.slice(0,r.base.length):e).trim()}function Gn(t){if(!t)return!1;let e=Z(String(t));return Ot.test(e)||xe(e,Be)!==null}var Vn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],kt=new RegExp("^\\s*("+[...Vn].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ge(t){if(t==null)return"";let e=String(t),n=kt.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),s=e.slice(n[0].length),a=0;for(;a<8;){let l=kt.exec(s);if(!l||i(l[1])!==r)break;let o=s.slice(l[0].length);if(o.trim()==="")break;s=o,a++}return a===0?e:e.slice(0,n[0].length)+s}function Ve(t,e){if(!t||!e)return!1;let n=String(t);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&n.includes(r))return!0}return!1}var we={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},Ft=new RegExp("^("+Object.keys(we).join("|")+")\\((.+)\\)$");function zt(t){if(!t)return[];let e=Ft.exec(String(t).trim());if(!e)return[];let n=we[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let a=i.slice(s+1);if(a.trim()!=="")for(let l of n){let o=l+a;r.includes(o)||r.push(o)}}return r}function Wt(t,e,n){let i=Ft.exec(String(t??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&n==="Decimal")return!0;let s=new Set(we[r]),a=String(e??""),l=i[2];for(let o=l.indexOf(".");o>=0;o=l.indexOf(".",o+1)){if(o===0)continue;let u=l.slice(o+1);if(u.trim()!==""){for(let c of Object.values(we))for(let f of c)if(!s.has(f)&&a===f+u)return!0}}return!1}function Kn(t){let e=Me(t);return e.length===0?"":e.replace(Wn," ")}function $t(t,e){if(!e)return!1;let n=Me(e);return t.test(Z(Kn(e)))||t.test(Z(n))||t.test(Z(J(n).join(" ")))}function Bt(t){return $t(Bn,t)}function Un(t){return $t($n,t)||Bt(t)}var Gt=/int|double|decimal|single|float|number|currency|money/i;function Hn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Gt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Yn(t){return t?.isMeasure===!0||Gt.test(String(t?.dataType??""))}function Vt(t){let e=t??{},n=Hn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Bt(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Gn(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}:Un(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Kt(t){let e=Vt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Yn(n)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Oi(t){return Kt(t)[0]}function Pi(t,e){return Kt(t).indexOf(e)>=0}function Li(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Vt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var jn={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"]},Xn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],qn=["num\xE9ro"],Zn=t=>t.normalize("NFC").toLowerCase();function Qn(t,e,n,i){let r=Ne(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<rt?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?tt(t,n).includes(e)?"word":null:r.script==="Hang"?nt(t,e)?"suffix":null:r.compounds&&et(t,e,Je)?"suffix":null}function Ut(t){let e=String(t??"").trim();if(!e)return null;let n=de(e),i=de(Me(e));for(let[r,s]of Object.entries(jn)){let a=Xn.includes(r),l=a?i:n;for(let o of s){let u=qn.includes(o)||!!Ne(r)?.foldSensitive,c=u?l.words:l.folded;if(c.length===0)continue;let f=u?Zn(o):de(o).folded.join(" "),d=Qn(a?c[0]:c[c.length-1],f,r,a);if(d)return{lang:r,word:o,view:d}}}return null}var Jn=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function Te(t){for(let[e,n]of Jn)if(n.test(t))return e;return null}var er=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],ve=new Map;function Ht(t,e,n,i){let r=ve.get(t);if(r)return r;let s=[];for(let[a,l]of e)for(let o=a;o<=l;o++){let u=String.fromCodePoint(o);Te(u)===n&&(i&&!i.test(u)||s.push(u))}return ve.set(t,s),s}function tr(t){let n=t.codePointAt(0);for(let a=0;a<9&&Te(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),r=ve.get(i);if(r)return r;let s=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);Te(l)==="Nd"&&s.push(l)}return ve.set(i,s),s}function nr(t,e){if(e==="Nd")return tr(t);for(let r of er)if(r.test.test(t))return Ht(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Ht("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function rr(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 ir=/^[\p{L}\p{M}\p{Nd}]$/u,Yt=/^[\p{L}\p{Nd}]$/u;function jt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=c=>{let f=Te(c);return!f||!ir.test(c)?c:rr(nr(c,f),n,c,e)},r=c=>{let f=[];for(let d of c)f.push(i(d)),Yt.test(d)&&e()<.2&&f.push(i(d));if(f.length>6){let d=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<d;h++)for(let x=0;x<5;x++){let A=Math.floor(e()*f.length);if(Yt.test(f[A])){f.splice(A,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[a,l=""]=t.split("@"),o=l.endsWith(".com"),u=o?l.slice(0,-4):l;return`${r(a)}@${r(u)}${o?".com":""}`}var sr=/^[A-Za-z_$][A-Za-z0-9_$]*$/,or=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ar=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function oe(t,e){if(!t||!e)return!1;let n=or(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:sr.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function lr(t){return!!t&&ar.test(t)}function Vi(t,e,n){return t?lr(t)?[...e]:[...n,...e].some(i=>oe(t,i))?e.filter(i=>oe(t,i)):[...e]:[]}var ur=5,cr=6,dr=3,te=864e5,mr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,fr=/^(\d{4})[-/](\d{1,2})$/,gr=/^(\d{4})[-\s]?Q([1-4])$/i,pr=/^Q([1-4])[-\s](\d{4})$/i,hr=/^(\d{4})$/,yr=/^(\d{4})(0[1-9]|1[0-2])$/,br=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Sr=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,_r=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ke(t,e,n){let i=ee(t);if(!i)return 0;if(i==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=Se(a)[i];if(l!==void 0)return l+1}let r=n?.get(i);if(r!==void 0)return r+1;let s=se(t);if(s.length>0){if(s.every(o=>o.month===s[0].month))return s[0].month+1;let a=Ze(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function Ar(t){let e=ge(t).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let n=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==n.n||i.year!==n.year)?null:Y(n.year,(n.n-1)*3+1,1)}function Y(t,e,n,i=0,r=0,s=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,i,r,s);if(!Number.isFinite(a))return null;let l=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function Cr(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?Y(s,a,l):null}function j(t,e,n,i){let r=(t??"").trim();if(r==="")return null;if(e){let o=Cr(r,e);return o||null}let s=mr.exec(r);if(s)return Y(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=gr.exec(r),s)return Y(+s[1],(+s[2]-1)*3+1,1);if(s=pr.exec(r),s)return Y(+s[2],(+s[1]-1)*3+1,1);if(s=fr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return Y(+s[1],+s[2],1);if(s=br.exec(r),s)return Y(+s[1],+s[2],+s[3]);if(s=yr.exec(r),s)return Y(+s[1],+s[2],1);if(s=hr.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?Y(o,1,1):null}let a=Ar(r);if(a)return a;if(s=Sr.exec(r),s){let o=Ke(s[1],n,i);if(o)return Y(+s[2],o,1)}if(s=_r.exec(r),s){let o=Ke(s[2],n,i);if(o)return Y(+s[1],o,1)}let l=re(r);if(l){let o="month"in l?l.month:Ke(l.word,n,i);if(o)return Y(l.year,o,1)}return null}function Xt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function qt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/te),i=Math.floor(n/7),r=i*5,s=t+i*7*te;for(;s<e;)Xt(s)&&r++,s+=te;return r}function xr(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 wr(t){return t>0?t<.95?"hour":t<=1.05?"day":t>=6.5&&t<=7.5?"week":t>=27&&t<=31.5?"month":t>=88&&t<=93?"quarter":t>=362&&t<=368?"year":"irregular":"irregular"}function ae(t,e,n,i){switch(n){case"year":return e.y-t.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(t.y*4+Math.floor((t.m-1)/3));case"month":return e.y*12+e.m-(t.y*12+t.m);case"week":return Math.round((e.ms-t.ms)/(7*te));case"weekday":return qt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/te);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function Zt(t,e){return Ue(t,e)?.cadence??null}function Ue(t,e){let n=e?.gapFactor??ur,i=0,r=0,s=new Map,a=Array.from(t),l;if(!e?.pattern){let g=[];for(let w of a){if(w==null||w==="")continue;let b=re(String(w));b&&"word"in b&&g.push(b.word)}g.length>0&&(l=_e(g,e?.locale)??void 0)}for(let g of a){if(g==null||g==="")continue;i++;let w=j(String(g),e?.pattern,e?.locale,l);w&&(r++,s.set(w.ms,w))}let o=[...s.values()].sort((g,w)=>g.ms-w.ms);if(o.length<dr||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 g=1;g<o.length;g++)c.push(o[g].ms-o[g-1].ms);let f=xr(c);if(!(f>0))return null;let d=wr(f/te);d==="day"&&u>=7*te&&o.every(g=>Xt(g.ms))&&qt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(d="weekday");let h=d==="irregular"?o.length:ae(o[0],o[o.length-1],d,f)+1,x=1,A=1,S=[],p=o[0],y=1;for(let g=1;g<o.length;g++){let w=ae(o[g-1],o[g],d,f);w>x&&(x=w),d!=="irregular"&&w>n?(A++,S.push({from:p.iso,to:o[g-1].iso,points:y}),p=o[g],y=1):y++}S.push({from:p.iso,to:o[o.length-1].iso,points:y});let C={grain:d,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:A,largestGapUnits:x,gapFactor:n};return e?.includeBounds&&S.length<=cr&&(C.runBounds=S),{cadence:C,points:o,stepMs:f}}var Mr=8,Tr=.5,vr=200,Rr=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"]),Ir=["category","classification","segment","status","priority","severity","channel"],Nr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function Er(t){let e=J(t);if(e.length===0)return!1;let n=e[e.length-1];return Rr.has(n)?!0:Ir.some(i=>n.length>i.length&&n.endsWith(i))}function kr(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>vr?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":pe(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&Nr.has(be(e))?"identifier":!t.geoKind&&Er(t.name)?"attribute":"entity"}function en(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(kr(r)!=="entity")return;let a=new Set(Array.from(r.values).filter(o=>o!=="")).size,l=!!r.geoKind;(a<n||a===n&&l&&!i)&&(e=s,n=a,i=l)}),e}var Qt=t=>t<10?"0"+t:String(t);function Jt(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Qt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Qt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function tn(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let w=0;w<i;w++)e[w]&&r.add(e[w]);let s=Ue(r,{pattern:t.pattern,locale:t.locale});if(!s)return null;let a=s.cadence.grain;if(a==="irregular")return null;let l=s.points[0],o=ae(l,s.points[s.points.length-1],a,s.stepMs)+1;if(o!==s.cadence.expectedPoints)return null;let u=new Map;for(let w of r){let b=j(w,t.pattern,t.locale);if(!b)continue;let _=ae(l,b,a,s.stepMs);_>=0&&_<o&&u.set(w,{idx:_,stamp:b})}let c=new Map;for(let w=0;w<i;w++){let b=n[w];if(!b)continue;let _=u.get(e[w]);if(!_)continue;let M=c.get(b);M||(M={seen:new Set,lo:_.idx,hi:_.idx,loStamp:_.stamp,hiStamp:_.stamp,order:c.size},c.set(b,M)),M.seen.add(_.idx),_.idx<M.lo&&(M.lo=_.idx,M.loStamp=_.stamp),_.idx>M.hi&&(M.hi=_.idx,M.hiStamp=_.stamp)}if(c.size<2)return null;let f=0;for(let w of c.values())f+=w.seen.size;if(f/(c.size*o)<(t.minFill??Tr))return null;let d=[],h=new Set,x=0,A=0,S=0,p=0,y=0,C=1;for(let[w,b]of c){for(let z of b.seen)h.add(z);if(b.seen.size>=o)continue;let _=[...b.seen].sort((z,X)=>z-X),M=1;for(let z=1;z<_.length;z++)M=Math.max(M,_[z]-_[z-1]);let W={key:w,acc:b,coverage:b.seen.size/o,before:b.lo,after:o-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:M};d.push(W),W.before>0&&x++,W.after>0&&A++,W.interior>0&&S++,p=Math.max(p,W.before),y=Math.max(y,W.after),C=Math.max(C,M)}if(d.length===0)return null;d.sort((w,b)=>w.coverage-b.coverage||w.acc.order-b.acc.order);let g=d.slice(0,t.maxListed??Mr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:c.size,incompleteSeries:d.length,lateStarts:x,earlyEnds:A,withHoles:S,columnWideMissing:o-h.size,maxMissingBefore:p,maxMissingAfter:y,largestGap:C,series:g.map(w=>{let b={};return t.includeNames&&(b.name=w.key),t.includeDates&&(b.first=Jt(w.acc.loStamp,a),b.last=Jt(w.acc.hiStamp,a)),b.missingBefore=w.before,b.missingAfter=w.after,b.missingInterior=w.interior,b.largestGap=w.gap,b.coverage=Math.round(w.coverage*1e3)/1e3,b}),more:d.length-g.length}}var Re=6;function le(t){let e=t.slice().sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Dr(t){let e=t.length;if(e<Re)return null;let n=t[0],i=t[0],r=0;for(let g of t)g<n&&(n=g),g>i&&(i=g),r+=g;if(n===i)return null;let s=le(t.map(Math.abs));if(s===0)return null;let a=[];for(let g=1;g<e;g++)a.push(t[g]-t[g-1]);let l=le(a.map(Math.abs))/s,o=(e-1)/2,u=r/e,c=0,f=0,d=0;for(let g=0;g<e;g++)c+=(g-o)*(t[g]-u),f+=(g-o)*(g-o),d+=(t[g]-u)*(t[g]-u);d/=e;let h=c/f,x=u-h*o,A=t.map((g,w)=>g-(x+h*w)),S=A.reduce((g,w)=>g+w,0)/e,p=0,y=0;for(let g=0;g<e;g++)p+=(A[g]-S)*(A[g]-S),g>0&&(y+=(A[g]-A[g-1])*(A[g]-A[g-1]));return p/=e,y/=e-1,{vnDetrended:p<=d*1e-12?2:y/p,relStep:l}}function He(t){let{stamps:e,series:n,values:i}=t,r=Math.min(e.length,i.length),s=new Map;for(let u=0;u<r;u++){let c=e[u],f=i[u];if(c===null||f===null||!Number.isFinite(f))continue;let d="";if(n&&(d=n[u]??"",d===""))continue;let h=s.get(d);h||s.set(d,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((d,h)=>d[0]-h[0]).map(d=>d[1]),f=Dr(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(le(o)),vnDetrended:Math.round(le(a)*1e3)/1e3,relStep:Math.round(le(l)*1e4)/1e4}}function ts(t){let e=t.times.map(n=>j(n,t.pattern,t.locale)?.ms??null);return He({stamps:e,series:t.series,values:t.values})}var Or=5e5,Pr=8,Lr=4,Fr=5,Ye=1,je=2,zr=4,Wr=8;function $r(t,e,n){let[i,r]=[...t];if(e.isTemporal){let s=j(i,e.temporalTextPattern,n),a=j(r,e.temporalTextPattern,n);if(s&&a&&s.ms!==a.ms)return s.ms<a.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Br(t,e,n){let{rows:i,text:r,locale:s}=t,a=$r(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 Gr(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 Vr(t,e,n){let i=new Uint8Array(n);for(let s=0;s<t.length;s++){let a=e[s];if(a===0)continue;let l=t[s];if(l<0)continue;let o=i[l];i[l]=o&a?o|a<<2:o|a}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<n;s++){let a=i[s];a&Ye&&r.keysA++,a&je&&r.keysB++,(a&(Ye|je))===(Ye|je)&&r.keysBoth++,a&zr&&r.dupA++,a&Wr&&r.dupB++}return r}function Kr(t,e){let n=(t.dupA+t.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(t.keysA+t.keysB);return n<i||n===i&&t.keysBoth>e.keysBoth}var nn=t=>t==null||typeof t=="string"&&t.trim()==="";function Ur(t,e,n){if(t===e)return!0;let i=nn(t),r=nn(e);return i||r?i&&r:typeof t=="number"&&typeof e=="number"?!1:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():n(t).trim()===n(e).trim()}function rn(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Or)return null;let r=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&!b.isTemporal&&!b.isDatePart&&b.distinct>=Fr).sort((b,_)=>(_.c.identifierNamed?1:0)-(b.c.identifierNamed?1:0)||_.c.distinct-b.c.distinct||b.i-_.i).slice(0,Pr),s=n.map((b,_)=>({c:b,i:_})).filter(({c:b})=>!b.isMeasure&&b.values!==null&&b.values.size===2).slice(0,Lr);if(r.length===0||s.length===0)return null;let a=s.map(({c:b,i:_})=>Br(t,_,b)),l=null;for(let{i:b}of r){let _=Gr(t,b);for(let M=0;M<s.length;M++){if(s[M].i===b)continue;let W=Vr(_.ids,a[M].code,_.dict.size);W.keysBoth<1||(!l||Kr(W,l.tally))&&(l={tally:W,keyIdx:b,setNo:M,ids:_.ids,dict:_.dict})}}if(!l)return null;let{ids:o,dict:u,tally:c}=l,f=a[l.setNo],d=s[l.setNo].i,h=u.size,x=new Int32Array(h).fill(-1),A=new Int32Array(h).fill(-1);for(let b=0;b<i;b++){let _=f.code[b],M=o[b];_===0||M<0||(_===1?x[M]<0&&(x[M]=b):A[M]<0&&(A[M]=b))}let S=[];for(let b=0;b<n.length;b++)b!==l.keyIdx&&b!==d&&S.push(b);let p=0;for(let b=0;b<h;b++){let _=x[b],M=A[b];if(_<0||M<0)continue;let W=e[_],z=e[M],X=!0;for(let Q of S)if(!Ur(W[Q],z[Q],t.text)){X=!1;break}X&&p++}let y=p===c.keysBoth?100:p===0?0:Math.min(99,Math.max(1,Math.round(p/c.keysBoth*100))),C=new Map,g=new Map;for(let[b,_]of u){let M=x[_]>=0,W=A[_]>=0;if(!M&&!W)continue;let z=dt(b);mt(z)&&(M&&C.set(z,(C.get(z)??0)+1),W&&g.set(z,(g.get(z)??0)+1))}let w=b=>{let _=0;for(let M of b.values())M>=2&&(_+=M);return _};return{key:l.keyIdx,discriminator:d,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[d].name,keysA:c.keysA,keysB:c.keysB,keysBoth:c.keysBoth,duplicateKeysA:c.dupA,duplicateKeysB:c.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:w(C),looseCollisionsB:w(g),setOrder:f.setOrder}}}var Hr=t=>t==="Integer"||t==="Decimal";function Yr(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 jr(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!Hr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function sn(t){let e=new Map,{rows:n,columns:i,text:r}=t;if(n.length===0||n.length>(t.maxRows??5e5))return e;let s=Yr(i);if(s.length===0)return e;let a=jr(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 d=0;d<n.length;d++){let h=r(n[d][o]);f[d]=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 C=n[y][o],g=C==null||C===""?NaN:typeof C=="number"?C:parseFloat(C);u[y]=g,g===g&&g!==1/0&&g!==-1/0&&c++}if(c<2)continue;let f=new Float64Array(c);for(let y=0,C=0;y<n.length;y++){let g=u[y];g===g&&g!==1/0&&g!==-1/0&&(f[C++]=g)}f.sort();let d=new Float64Array(c),h=0;for(let y=0;y<c;y++)(y===0||f[y]!==f[y-1])&&(d[h++]=f[y]);let x=new Int32Array(n.length).fill(-1);for(let y=0;y<n.length;y++){let C=u[y];if(!(C===C&&C!==1/0&&C!==-1/0))continue;let g=0,w=h-1;for(;g<w;){let b=g+w>>>1;d[b]<C?g=b+1:w=b}x[y]=g}let A=[],S=new Int32Array(h),p=new Int32Array(h);for(let y=0;y<s.length;y++){let C=l[y];S.fill(0),p.fill(0);let g=0,w=0;for(let U=0;U<n.length;U++){let m=x[U];m<0||(C[U]===1?(S[m]++,g++):C[U]===2&&(p[m]++,w++))}if(g===0||w===0)continue;let b=g<=w,_=b?g:w,M=b?w:g,W=b?S:p,z=b?p:S,X=0,Q=0,ue=0;for(let U=0;U<h;U++){let m=W[U],T=z[U];X+=m*(Q+.5*T),Q+=T,m+T>=2&&(ue+=m+T)}A.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(X/(_*M)*1e4)/1e4,nMinority:_,nMajority:M,ties:ue})}A.length>0&&e.set(o,A)}return e}var Xr=12,qr=100,Zr=.3,Qr=.9,Jr=120,ei=1900,ti=2100,ni=0,ri=20,ii=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ie(t){if(!t)return!1;let e=J(t);return e.length===0?!1:ii.has(e[e.length-1])?!0:Ut(t)!==null}var si=new Set(["year","yr","fy"]),oi=t=>J(t).some(e=>si.has(e))||ct(t)!==null,ai=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function Xe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function qe(t){if(!Number.isInteger(t)||t<19000101||t>21001231)return!1;let e=Math.floor(t/100)%100,n=t%100;return e>=1&&e<=12&&n>=1&&n<=31}var li=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ui=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ci=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function un(t,e){let n=[],i=0,r=di(t,e,n,()=>{i++});if(r)return r;if(i>0||n.length<2)return null;let s=It(n,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function di(t,e,n,i){let r=0,s=0,a=0,l=0,o=0,u="",c=0,f="",d=0,h=0,x=0,A=0,S=!1;for(let b of t){if(b==null)continue;let _=String(b).trim();if(_==="")continue;r++,n.push(_);let M;if(M=li.exec(_)){i();let W=+M[2],z=+M[3];W>=1&&W<=12&&z>=1&&z<=31&&(s++,M[4]!==void 0&&a++,M[6]!==void 0&&l++)}else if(M=ui.exec(_)){i();let W=+M[3],z=+M[4];W>=1&&W<=12&&z>=1&&z<=31&&(u&&u!==M[2]&&(S=!0),u=M[2],o++)}else if(M=ci.exec(_)){i();let W=+M[1],z=+M[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==M[2]&&(S=!0),f=M[2],c++,W>12&&x++,z>12&&A++,M[5]!==void 0&&d++,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(x>0&&A>0)return null;let C,g;x>0?(C=!0,g="values"):A>0?(C=!1,g="values"):f==="."?(C=!0,g="shape"):(C=!ze(e),g="locale");let w=C?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return d===c?{pattern:w+(h===c?" %H:%M:%S":" %H:%M"),orderFrom:g}:{pattern:w,orderFrom:g}}function mi(t,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(t))return!1;let n=t.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let i=ee(n);return i.length>0&&e[i]!==void 0}function fi(t,e){let n=new Map,i=new Map;for(let l of t){let o=re(l);if(!o||"month"in o)continue;let u=se(o.word),c=u.some(d=>d.lang==="en"),f=ee(o.word);for(let d of new Set(u.map(h=>h.lang)))d!=="en"&&(n.has(d)||(n.set(d,new Set),i.set(d,new Set)),n.get(d).add(f),c||i.get(d).add(f))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&i.get(l).size>=1),s=0,a=new Map(r.map(l=>[l,0]));for(let l of e){let o=re(l);if(!o)continue;if("month"in o){s++;continue}let u=se(o.word);if(u.length===0)continue;let c=u.some(f=>f.lang==="en");for(let f of r)(c||u.some(d=>d.lang===f))&&a.set(f,a.get(f)+1)}return s+Math.max(0,...a.values())}var gi=/(?:19|20)[0-9]{2}/;function pi(t){let e=new Map,n=0;for(let r of t){if(!gi.test(ne(r)))continue;let s=new Set(ge(r).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(s.size!==0){if(s.has("en")){n++;continue}for(let a of s)e.set(a,(e.get(a)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function hi(t){let{dataType:e,name:n,isMeasure:i,distinctCount:r}=t;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=t.minNum,a=t.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let o=s>=1900&&a<=2100;if(o&&r>=2&&oi(n)||o&&r>=3&&r===a-s+1)return!0;let u=Xe(s)&&Xe(a),c=qe(s)&&qe(a);if(u||c){if(!t.sampleValues)return!0;let f=0,d=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let x=Number(String(h).trim());if(Number.isFinite(x)&&(u?Xe(x):qe(x))&&d++,f>=60)break}if(f>=2&&d===f)return!0}return!1}if(t.sampleValues){let s=t.locale?Se(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),ai.test(f)||mi(f,s)?l++:u.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+pi(u)+fi(o,u))/a>=.8||un(o,t.locale)!==null)return!0}return!1}function yi(t){let e=Z((t||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Lt(t)}function bi(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:s,maxNum:a,discourageAgg:l}=t,o=100,u=.01,c="";for(let d of r){if(d.distinct<2||d.distinct>o)continue;let h=r.filter(y=>y.idx!==d.idx).map(y=>y.idx),x=new Map;for(let y of e){let C=y[n];if(typeof C!="number"||!Number.isFinite(C))continue;let g=h.length?h.map(b=>String(y[b])).join(c):"",w=x.get(g);w||(w={sum:0,cset:new Set},x.set(g,w)),w.sum+=C,w.cset.add(String(y[d.idx]))}let A=0,S=0,p=0;for(let y of x.values())y.cset.size<2||(p++,Math.abs(y.sum-100)<=100*u?A++:Math.abs(y.sum-1)<=1*u&&S++);if(p>=2&&(A/p>=.9||S/p>=.9))return{additivity:"part_of_whole",partOfWholeDim:d.name}}if(l)return{additivity:"intensive_rate"};let f=yi(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&s>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function cn(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,d=e==="Decimal"||a>0;return!n&&Ie(i)?"Categorical":c>=Qr&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(ft(i)&&r<=Jr||o>=ei&&l<=ti||o>=ni&&l<=ri)?"Ordinal":n||r>Xr&&(d||r>=qr||f>=Zr)?"Continuous":"Categorical"}function an(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:cn({dataType:t.dataType,isMeasure:!1,name:t.name,distinct:n.distinct,nonblank:n.nonblank,prec:n.prec,maxval:typeof n.maxval=="number"?n.maxval:0,minval:typeof n.minval=="number"?n.minval:0,ordinalNeedsWholeNumbers:!0})==="Continuous"}function Si(t){let e=null;for(let n=0;n<t.length;n++){let i=t[n];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=t.slice()),e[n]=r)}return e||t}var ln=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;dedupRows=!0;emitLegacyAggAliases=!1;deriveProvinces=!0;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let n=0;n<this._cols.length;n++){let i=this._cols[n];!i||!/date|time/i.test(String(i.dataType??""))||lt(this._rows.map(r=>r[n]))&&e.add(n)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(n=>!!(n&&n.isMeasure));return this._cols.forEach((n,i)=>{if(!n||n.isMeasure||this._declaredDimensions.has(n)||n.dataType!=="Integer"&&n.dataType!=="Decimal")return;let r=new Set,s=0,a=0,l=null,o=null;for(let u of this._rows){let 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 d=this.getPrecision(c);d>a&&(a=d)}}e[i]=an(n,!1,{distinct:r.size,nonblank:s,prec:a,minval:l,maxval:o})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return at(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,n){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=this.wallClockColumnIndexes(),a=[],l=[],o=[];for(let m of this._cols){let T=new Map,O=[],D=0,v=0,k=0,F=null,P=null,E=null,G=!1,V=!0,I=!0,N=null,K=!1,L=s.has(i);for(let R of this._rows){let $=R[i],B=L&&$ instanceof Date?fe($):$,H=this.STR(B);if(H!=""){if(D+=H.length,T.set(H,(T.get(H)||0)+1),v++,m.dataType=="Integer"||m.dataType=="Decimal"||m.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),m.dataType=="Integer"||m.dataType=="Decimal"){if(E===null?E=B:E+=B,m.dataType=="Decimal"){let q=this.getPrecision(B);q>k&&(k=q)}O.push(B)}else G=G||this.hasTimeComponent(B);K&&(B<N?V=!1:B>N&&(I=!1)),N=B,K=!0}}if(v>=3&&(V&&!I?m.sortedDirection="asc":I&&!V?m.sortedDirection="desc":m.sortedDirection="none"),v>0&&T.size>0&&!m.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(m.modalShare=R/v,m.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(ce=>it(ce).trim().toLowerCase()).sort(),q=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ce=>B[0]===ce[0]&&B[1]===ce[1]),dn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(m.name);(q||dn)&&(m.isBinaryFlag=!0)}}else m.isMeasure&&(m.dataType==="Integer"||m.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(m.isBinaryFlag=!0);if(m.dataType=="DateTime"&&(m.dateWithTime=G,G&&ut(L?this._rows.map(R=>R[i]instanceof Date?fe(R[i]):R[i]):this._rows.map(R=>R[i]))?m.timeOfDayOnly=!0:delete m.timeOfDayOnly),m.isTemporal=hi({dataType:m.dataType,name:m.name,isMeasure:m.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),m.isTemporal&&m.dataType==="String"&&!m.isMeasure){let R=un(T.keys(),n);R&&(m.temporalTextPattern=R.pattern)}if(m.timeOfDayOnly)delete m.temporalCadence;else if(m.isTemporal&&!m.isMeasure){let R=Zt(T.keys(),{includeBounds:r>=20,pattern:m.temporalTextPattern,locale:n});R&&(m.temporalCadence=R)}this.updateColumnStats10(r,m,v,T,k,P,F),this.updateColumnStats20(r,O,v,E,m,D,G,F,P,k,T,n),an(m,this._declaredDimensions.has(m),{distinct:T.size,nonblank:v,prec:k,minval:F,maxval:P})&&(m.isMeasure=!0,m.valueNature="Continuous",m.geoKind=void 0,m.geoMatchPct=void 0,m.geoAmbiguous=void 0,m.dominantGeoRegion=void 0,m.dominantGeoRegionPct=void 0,m.geoRegionCount=void 0),a[i]=m.isMeasure||T.size>2e3?null:new Set(T.keys()),l[i]=T.size,o[i]=T.size===2?[...T.keys()].sort():null,i++}Tt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((m,T)=>{let O=this._cols[T];m.kind&&(O.geoKind=m.kind,O.geoMatchPct=m.matchPct,m.ambiguous&&(O.geoAmbiguous=!0)),m.rollupPct!==void 0&&(O.admin1RollupPct=m.rollupPct),m.regionCount!==void 0&&(O.admin1RegionCount=m.regionCount),m.countryCount!==void 0&&(O.admin1CountryCount=m.countryCount),m.dominantRegion&&(O.dominantGeoRegion=m.dominantRegion,O.dominantGeoRegionPct=m.dominantRegionPct)});let u=this.getGeoExtent();if(u&&u.dominantFrame&&this._geoExtentLatIdx>=0){let m=this._cols[this._geoExtentLatIdx];m.geoKind||(m.dominantGeoRegion=u.dominantFrame,m.dominantGeoRegionPct=u.dominantFramePct,this.deriveProvinces&&(m.admin1RollupPct=u.dominantFramePct))}let c=[];this._cols.forEach((m,T)=>{m.isMeasure||c.push({idx:T,distinct:m.distinctCount??0,name:m.name})}),this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=typeof m.lowValue=="number"?m.lowValue:null,D=typeof m.highValue=="number"?m.highValue:null,v=bi({rows:this._rows,measureColIdx:T,measureName:m.name,candidateDims:c,minNum:O,maxNum:D,discourageAgg:!!m.discourageAggregationAcrossGroups});m.additivity=v.additivity,v.partOfWholeDim&&(m.partOfWholeDim=v.partOfWholeDim)});let f=50,d=4,h=c.filter(m=>m.distinct>=2&&m.distinct<=f);this._cols.forEach((m,T)=>{if(!m.isMeasure)return;let O=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let K=typeof N=="number"?N:parseFloat(N);isNaN(K)||O.push(K)}if(O.length===0)return;let D=[...O].sort((I,N)=>I-N);if(D[0]===D[D.length-1])m.relativeDispersion=0;else if(D.length>=d){let I=me(D,.5),N=me(D,.1),K=me(D,.9);m.relativeDispersion=Math.abs(I)>1e-9?Math.round((K-N)/Math.abs(I)*1e3)/1e3:void 0}else m.relativeDispersion=void 0;let v=[];for(let I of h){let N=new Set;for(let K of this._rows){let L=K[T];L==null||L===""||N.add(this.STR(K[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(m.nonBlankGroups=v);let k=0;for(let I of O)k+=I;k/=O.length;let F=0;for(let I of O)F+=(I-k)*(I-k);if(F<=1e-12)return;let P=[],E=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),K=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return K(.75)-K(.25)},V=G(O);for(let I of h){let N=new Map;for(let R of this._rows){let $=R[T];if($==null||$==="")continue;let B=typeof $=="number"?$:parseFloat($);if(isNaN(B))continue;let H=this.STR(R[I.idx])+"",q=N.get(H);q?(q.s+=B,q.n++,q.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let K=0;for(let R of N.values()){let $=R.s/R.n;K+=R.n*($-k)*($-k)}P.push({otherColumn:I.name,eta2:Math.round(K/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(V)&&V>1e-9){let R=(Math.max(...L)-Math.min(...L))/V;E.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(m.groupDiscrimination=P),E.length>0&&(m.spreadDiscrimination=E)});let x=.97,A=.8,S=8,p=5,y=this._cols.map((m,T)=>({c:m,i:T})).filter(m=>m.c.isMeasure);for(let m=0;m<y.length;m++)for(let T=m+1;T<y.length;T++){let O=y[m].i,D=y[T].i,v=0,k=0,F=0,P=0,E=0,G=0;for(let L of this._rows){let R=L[O],$=L[D];if(R==null||R===""||$===null||$===void 0||$==="")continue;let B=typeof R=="number"?R:parseFloat(R),H=typeof $=="number"?$:parseFloat($);isNaN(B)||isNaN(H)||(v++,k+=B,F+=H,P+=B*B,E+=H*H,G+=B*H)}if(v<p)continue;let V=v*P-k*k,I=v*E-F*F;if(V<=1e-12||I<=1e-12)continue;let N=(v*G-k*F)/Math.sqrt(V*I),K=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[y[m].c,y[T].c])(L.maxAbsMeasureCorrelation===void 0||K>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=K);if(Math.abs(N)>=x){let L=y[m].c,R=y[T].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),L.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(L.name)}else if(Math.abs(N)>=A){let L=y[m].c,R=y[T].c,$=Math.round(N*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:R.name,r:$}),R.correlatedWithMeasures.push({otherColumn:L.name,r:$})}}for(let{c:m}of y)m.correlatedWithMeasures&&(m.correlatedWithMeasures.sort((T,O)=>Math.abs(O.r)-Math.abs(T.r)||(T.otherColumn<O.otherColumn?-1:1)),m.correlatedWithMeasures.length=Math.min(m.correlatedWithMeasures.length,S));for(let m=0;m<this._cols.length;m++){let T=a[m];if(!T||T.size===0)continue;let O=[];for(let D=0;D<this._cols.length;D++){if(D===m)continue;let v=a[D];if(!v||v.size===0)continue;let k=0;for(let P of T)v.has(P)&&k++;let F=Math.round(k/T.size*100);F>0&&O.push({otherColumn:this._cols[D].name,percentShared:F})}O.length>0&&(this._cols[m].sharedValueRatioWithOthers=O)}let C=50,g=[];for(let m=0;m<this._cols.length;m++){let T=a[m];T&&T.size>=2&&T.size<=C&&g.push(m)}if(g.length>=2){let m=new Map,T=(D,v)=>D+":"+v;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++)m.set(T(g[D],g[v]),new Map);for(let D of this._rows)for(let v=0;v<g.length;v++){let k=this.STR(D[g[v]])+"";for(let F=v+1;F<g.length;F++){let P=""+this.STR(D[g[F]]),E=m.get(T(g[v],g[F])),G=k+""+P;E.set(G,(E.get(G)??0)+1)}}let O=new Map;for(let D=0;D<g.length;D++)for(let v=D+1;v<g.length;v++){let k=g[D],F=g[v],P=a[k].size,E=a[F].size,G=m.get(T(k,F)),V=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(V/(P*E)*100),K=V===P,L=V===E;if((this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:K,minCellCount:I,distinctCombinations:V}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:V}),K&&P>E){let R=O.get(k);(!R||E<R.card)&&O.set(k,{name:this._cols[F].name,card:E,ratio:E/P})}if(L&&E>P){let R=O.get(F);(!R||P<R.card)&&O.set(F,{name:this._cols[k].name,card:P,ratio:P/E})}}for(let[D,v]of O)this._cols[D].primaryParentColumn=v.name,this._cols[D].nestingRatio=Math.round(v.ratio*100)/100}let w=6,b=this._rows.length;for(let m=0;m<this._cols.length;m++){let T=this._cols[m];if(T.isMeasure||T.primaryParentColumn)continue;let O=T.distinctCount??0;if(O<=C||b>0&&O>=b)continue;let D=[];for(let v=0;v<this._cols.length;v++){if(v===m)continue;let k=this._cols[v];if(k.isMeasure)continue;let F=k.distinctCount??0;F<2||F>=O||D.push(v)}D.sort((v,k)=>(this._cols[v].distinctCount??0)-(this._cols[k].distinctCount??0));for(let v of D.slice(0,w)){let k=new Map,F=!0;for(let E of this._rows){let G=this.STR(E[m])+"",V=this.STR(E[v])+"",I=k.get(G);if(I===void 0)k.set(G,V);else if(I!==V){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/O*100)/100;break}}let _=.01,M=.05,W=.95,z=8,X=8,Q=6,ue=500,U=[];for(let m=0;m<this._cols.length&&U.length<X;m++){let T=this._cols[m].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(m)}if(U.length>=3&&this._rows.length>=z){let m=Math.min(this._rows.length,ue),T=U.map(P=>{let E=[];for(let I=0;I<m;I++){let N=this._rows[I][P],K=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(K))return null;E.push(K)}let G=E[0],V=!1;for(let I of E)if(I!==G){V=!0;break}return V?E:null}),O=U.map((P,E)=>E).filter(P=>T[P]!==null),D=P=>{let E=P.slice().sort((V,I)=>V-I),G=E.length>>1;return E.length%2?E[G]:(E[G-1]+E[G])/2},v=null,k=[],F=P=>{if(k.length>=3){let E=k.map(N=>T[N]),G=E[0].length,V=new Array(G);for(let N=0;N<G;N++){let K=0;for(let L of E)K+=L[N];V[N]=K}let I=D(V);if(I>0){let N=0;for(let L of V)Math.abs(L-I)<=I*_&&N++;let K=N/G;if(K>=W){let L=1;for(let R of E){let $=D(R)/I;$<L&&(L=$)}L>=M&&(!v||k.length>v.cols.length)&&(v={cols:k.slice(),total:I,matched:K})}}}if(!(k.length>=Q))for(let E=P;E<O.length;E++)k.push(O[E]),F(E+1),k.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(V=>this._cols[U[V]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let V of P.cols)this._cols[U[V]].constantSumGroup=G}}return this.applyTwoSetPairing(n,a),this.applyScoreSeparation(l,o),this.applySeriesCompleteness(r,n,a),this.applyMeasurePersistence(n,a),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=rn({rows:this._rows,columns:this._cols.map((r,s)=>{let a=n[s];return{name:r.name,values:a,distinct:a?a.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,n){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=sn({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ie(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:n[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,n,i){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,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=tn({periods:this._rows.map(d=>this.STR(d[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=en(r);return s<0?-1:i[s]}applyMeasurePersistence(e,n){for(let o of this._cols)o.persistence!==void 0&&delete o.persistence;let i=[];if(this._cols.forEach((o,u)=>{o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal"||o.dataType==="Double")&&i.push(u)}),i.length===0||this._rows.length<Re)return;let r=-1,s=[];for(let o=0;o<this._cols.length&&r<0;o++){let u=this._cols[o];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let c=this._rows.map(f=>j(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 d=f[o];if(d==null||d==="")return null;let h=typeof d=="number"?d:parseFloat(String(d).replace(/,/g,""));return Number.isFinite(h)?h:null}),c=He({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,d){if(e>=20){let h=[...n].sort((S,p)=>S-p),x=Math.floor(h.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=a/i),this._rows.length>0){let S=p=>{let y=p instanceof Date?p:typeof p=="string"?Ee(p)??new Date(p):new Date(p),C=this.wholeDayIso(y);return C?C+"T00:00:00.000Z":isNaN(y.getTime())?p:y.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!o?s.lowValue=o:s.lowValue=S(o),s.dataType!="DateTime"||l||!u?s.highValue=u:s.highValue=S(u),s.medianValue=h.length===0?null:h.length%2===0?s.dataType=="Integer"?Math.round((h[x-1]+h[x])/2):(h[x-1]+h[x])/2:h[x],s.numericPrecision=c}if(h.length>0){let S=i>0&&r!=null?r/i:s.avgValue??0,p=h.length,y=0,C=0;for(let b of h){let _=b-S;y+=_*_,C+=_*_*_}let g=y/p,w=Math.sqrt(g);s.skewness=g===0?0:C/p/(w*w*w),s.stdDev=Math.sqrt(g)}r!==null&&(s.sum=r);let A=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]);if(s.topCategories=A.slice(0,10).map(S=>S[1]),!s.isMeasure&&A.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=A.slice(0,5).map(S=>S[0])),e>=20)){let S=A.map(y=>y[0]),p=pe(S,d);if(p!==null)s.ordinalPattern=p.pattern,s.orderedDomain=p.orderedDomain;else if(s.dataType==="String"){let y=gt(S);y!==null&&(s.safeDistinctValues=y)}}if(h.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let S=p=>h[Math.floor((h.length-1)*p)];s.quantiles={p05:S(.05),p25:S(.25),p75:S(.75),p95:S(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let h=Array.from(f.entries()).sort((S,p)=>p[1]-S[1]).map(S=>S[0]);s.formatSignature=be(h);let x=i>0?a/i:void 0,A=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!A.test(s.formatSignature)&&(x===void 0||x>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((A,S)=>S[1]-A[1]),x=At(h.map(A=>A[0]),s.name,d);if(x!==null&&(s.geoKind=x.geoKind,s.geoMatchPct=x.geoMatchPct,x.geoAmbiguous&&(s.geoAmbiguous=!0),x.geoKind.indexOf("country")===0)){let A=yt(h);A&&(s.dominantGeoRegion=A.dominantGeoRegion,s.dominantGeoRegionPct=A.dominantGeoRegionPct,s.geoRegionCount=A.regionCount,A.middleEastPct>0&&(s.middleEastPct=A.middleEastPct))}}}updateColumnStats10(e,n,i,r,s,a,l){let o=this._rows.length-i;e>=10&&(n.blankCount=o),n.distinctCount=r.size+(o!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=cn({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:s,maxval:a,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal"))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,r)=>{i.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let i of this._rows)n.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=a=>Qe(a,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((a,l)=>{let o=e(a.name),u=a.dataType==="Integer"||a.dataType==="Decimal";u&&n<0&&o.some(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 d of this._rows){let h=d[u];if(h==null||h==="")continue;let x=Number(h);if(!Number.isFinite(x)||x<-c||x>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),d=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Nt(f);d==="lat"&&l<0&&a(c,90)?l=c:d==="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&&he(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=ht(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return jt(e,ot)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=n[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,a=this.wallClockColumnIndexes();for(let o of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let f=this._cols[c],d=o[c];if(this.STR(d)!=""){if(e&&f.dataType=="String")if(s.has(d))d=s.get(d);else{let h=this.obfuscateString(d);s.set(d,h),d=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=d instanceof Date?d:typeof d=="string"?Ee(d)??new Date(d):new Date(d);d=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(c)&&d instanceof Date&&(d=fe(d));r-=this.STR(d).length}else d=null;u[c]=d,--r}if(n.push(u),--i,i<=0||r<=0)break}return await on.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return on.unparse([this._cols.map((n,i)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}setGenerationColumns(e){let n=(e??[]).filter(r=>!!r&&typeof r.n=="string"&&r.n!==""&&typeof r.q=="string"&&r.q!=="").map(r=>({n:r.n,q:r.q})),i=JSON.stringify(n);i!==this._generationColumnsSig&&(this._generationColumns=n,this._generationColumnsSig=i,this._englishAliases=new Map)}aliasesForCode(e){let n=Ve(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:i.reason});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=Ve(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let n of this.liveEnglishAliases().values())e.push({name:n.name,alias:n.alias,reason:n.reason});return e}legacyAliases(){let e=[];for(let n of this._cols)n&&n.hostName&&n.hostName!==n.name&&e.push({name:this.STR(n.name),alias:this.STR(n.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let n=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return n;let i=String(e),r=new Set;for(let l of this._cols)l&&(r.add(this.STR(l.name)),l.hostName&&r.add(this.STR(l.hostName)));let s=new Map,a=new Set;for(let l=0;l<this._cols.length;l++){if(!this._cols[l])continue;let o=this._hostQueryNames[l],u=Wt(o,this._cols[l].name,this._cols[l].dataType)?[]:zt(o),c=this.STR(this._cols[l].name),f=[];if(o){for(let h of this._generationColumns)if(h.q===o)for(let x of[h.n,Ge(h.n)])x&&x!==c&&!u.includes(x)&&!f.includes(x)&&f.push(x)}let d=[...u,...f].filter(h=>!r.has(h)&&oe(i,h));d.length===1&&(s.set(d[0],[...s.get(d[0])??[],l]),f.includes(d[0])&&a.add(d[0]))}for(let[l,o]of s){if(o.length!==1)continue;let u=this.STR(this._cols[o[0]].name);n.set(o[0],{name:u,alias:l,headerName:!oe(i,u),reason:a.has(l)?"stored-query-name":"english-implicit-agg"})}return n}liveEnglishAliases(){let e=new Map;for(let[n,i]of this._englishAliases){let r=this._cols?this._cols[n]:null;r&&this.STR(r.name)===i.name&&e.set(n,i)}return e}addRow(e,n){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=st(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Si(e)),this._inferredMeasureFlags=null,this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}invalidateStats(){this._computedStatsForLevel=null,this._geoExtentComputed=!1,this._geoExtent=null,this._geoExtentLatIdx=-1}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map,this._generationColumns=[],this._generationColumnsSig="[]"}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let n=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Ge(r);!s||s===r||n.has(s)||(n.delete(r),n.add(s),i.hostName=r,i.name=s)}}};export{mn as a,fn as b,wi as c,Mi as d,Tt as e,It as f,Tn as g,vn as h,Nt as i,Nn as j,En as k,kn as l,Dn as m,Me as n,Gn as o,Ge as p,Ve as q,zt as r,Bt as s,Un as t,Vt as u,Kt as v,Oi as w,Pi as x,Li as y,jn as z,Xn as A,qn as B,Ut as C,oe as D,lr as E,Vi as F,ur as G,cr as H,j as I,Zt as J,Mr as K,Tr as L,vr as M,kr as N,en as O,tn as P,ts as Q,Ie as R,un as S,hi as T,yi as U,bi as V,cn as W,an as X,Si as Y,ln as Z};
|