@bicharts/shape-core 0.6.76 → 0.6.78
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 ae}from"./chunk-U3H6UBOO.mjs";import{a as ue,b as le}from"./chunk-555PKUBU.mjs";import{c as Ge}from"./chunk-KQOVPOVU.mjs";import{f as ke,k as Fe}from"./chunk-INMDBTAR.mjs";import{e as De,k as se,m as Oe,n as Pe,o as oe}from"./chunk-GKXYRUK5.mjs";import{B as pe,D as Le,f as ge,h as re,i as j,j as Me,k as ie,n as xe,o as Re,q as Te,s as Ne,t as Ee,v as Ie,w as H,x as ve,y as we}from"./chunk-4VN252CK.mjs";var ht=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],bt=[7,72,-172,-52];function We(t,e,n){return t>=n[0]&&t<=n[1]&&e>=n[2]&&e<=n[3]}var X=t=>Math.round(t*10)/10;function Be(t,e=3){let n=[],i=[],r=0,o=0;for(let l of t){let u=l?.lat,c=l?.lon;if(typeof u!="number"||typeof c!="number"||!isFinite(u)||!isFinite(c)||u<-90||u>90||c<-180||c>180)continue;n.push(u),i.push(c);let d=l?.country?String(l.country).trim().toUpperCase():"",f=d?ce(d):null;f?((d==="US"||d==="USA")&&r++,f==="north-america"&&o++):(ht.some(m=>We(u,c,m))&&r++,We(u,c,bt)&&o++)}let s=n.length;return s<e?null:(n.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:X(r/s*100),pctNa:X(o/s*100),latP5:X(H(n,.05)),latP95:X(H(n,.95)),lonP5:X(H(i,.05)),lonP95:X(H(i,.95)),n:s})}var ze={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},J=(()=>{let t=new Map;for(let e of Object.keys(ze))for(let n of ze[e].split(/\s+/))n&&t.set(n,e);return t})();function yt(t){for(let[e,n]of t){let i=J.get(e);i&&!J.has(n)&&J.set(n,i)}}yt(ke);function ce(t){if(!t)return null;let e=String(t).trim().toUpperCase();if(!e)return null;let n=J.get(e);if(n)return n;let i=Fe(String(t));return i?J.get(i)??null:null}function Hn(t,e=2){return he(t.map(n=>[n,1]),e)}function he(t,e=2){let n=new Map,i=0;for(let[s,l]of t){let u=ce(s);if(!u)continue;let c=typeof l=="number"&&isFinite(l)&&l>0?l:1;n.set(u,(n.get(u)??0)+c),i+=c}if(i<e||!n.size)return null;let r="europe",o=-1;for(let s of Array.from(n.keys()).sort()){let l=n.get(s);l>o&&(r=s,o=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:X(o/i*100),regionCount:n.size,n:i}}import mt from"papaparse";var St=["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"],_t=["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"],At=["latitude","longitude"],Ct=["latitude","longitude"];function Z(t){return re(t)}var be=["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"],Ue=["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"];function Mt(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var $e=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Mt(be)+")\\s+)","i"),xt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Rt=new RegExp("\\b("+St.join("|")+")\\b|("+_t.join("|")+")$","i"),Tt=new RegExp("\\b("+At.join("|")+")\\b|("+Ct.join("|")+")$","i");function me(t){if(!t)return"";let e=String(t),n=$e.exec(Z(e));return(n?e.slice(n[0].length):e).trim()}function Nt(t){return!!t&&$e.test(Z(String(t)))}var Et=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Ve=new RegExp("^\\s*("+[...Et].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ke(t){if(t==null)return"";let e=String(t),n=Ve.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),o=e.slice(n[0].length),s=0;for(;s<8;){let l=Ve.exec(o);if(!l||i(l[1])!==r)break;let u=o.slice(l[0].length);if(u.trim()==="")break;o=u,s++}return s===0?e:e.slice(0,n[0].length)+o}function ye(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 He={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 "]},It=new RegExp("^("+Object.keys(He).join("|")+")\\((.+)\\)$");function Ye(t){if(!t)return[];let e=It.exec(String(t).trim());if(!e)return[];let n=He[e[1]],i=e[2],r=[];for(let o=i.indexOf(".");o>=0;o=i.indexOf(".",o+1)){if(o===0)continue;let s=i.slice(o+1);if(s.trim()!=="")for(let l of n){let u=l+s;r.includes(u)||r.push(u)}}return r}function vt(t){let e=me(t);return e.length===0?"":e.replace(xt," ")}function je(t,e){if(!e)return!1;let n=me(e);return t.test(Z(vt(e)))||t.test(Z(n))||t.test(Z(j(n).join(" ")))}function Xe(t){return je(Tt,t)}function wt(t){return je(Rt,t)||Xe(t)}var Ze=/int|double|decimal|single|float|number|currency|money/i;function Lt(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Ze.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Dt(t){return t?.isMeasure===!0||Ze.test(String(t?.dataType??""))}function qe(t){let e=t??{},n=Lt(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Xe(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Nt(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}:wt(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Qe(t){let e=qe(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Dt(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 Zn(t){return Qe(t)[0]}function qn(t,e){return Qe(t).indexOf(e)>=0}function Qn(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=qe(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var Ot={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"]},Pt=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],kt=["num\xE9ro"],Ft=t=>t.normalize("NFC").toLowerCase();function Gt(t,e,n,i){let r=ge(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<Ee?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?Te(t,n).includes(e)?"word":null:r.script==="Hang"?Ne(t,e)?"suffix":null:r.compounds&&Re(t,e,xe)?"suffix":null}function Je(t){let e=String(t??"").trim();if(!e)return null;let n=ie(e),i=ie(me(e));for(let[r,o]of Object.entries(Ot)){let s=Pt.includes(r),l=s?i:n;for(let u of o){let c=kt.includes(u)||!!ge(r)?.foldSensitive,d=c?l.words:l.folded;if(d.length===0)continue;let f=c?Ft(u):ie(u).folded.join(" "),m=Gt(s?d[0]:d[d.length-1],f,r,s);if(m)return{lang:r,word:u,view:m}}}return null}var Wt=[["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 de(t){for(let[e,n]of Wt)if(n.test(t))return e;return null}var zt=[{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]]}],fe=new Map;function et(t,e,n,i){let r=fe.get(t);if(r)return r;let o=[];for(let[s,l]of e)for(let u=s;u<=l;u++){let c=String.fromCodePoint(u);de(c)===n&&(i&&!i.test(c)||o.push(c))}return fe.set(t,o),o}function Bt(t){let n=t.codePointAt(0);for(let s=0;s<9&&de(String.fromCodePoint(n-1))==="Nd";s++)n--;let i="nd:"+n.toString(16),r=fe.get(i);if(r)return r;let o=[];for(let s=n;s<n+10;s++){let l=String.fromCodePoint(s);de(l)==="Nd"&&o.push(l)}return fe.set(i,o),o}function Vt(t,e){if(e==="Nd")return Bt(t);for(let r of zt)if(r.test.test(t))return et(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return et("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function Ut(t,e,n,i){let r=t.filter(o=>!e.has(o));return r.length===0&&(r=t.filter(o=>o!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var $t=/^[\p{L}\p{M}\p{Nd}]$/u,tt=/^[\p{L}\p{Nd}]$/u;function nt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=d=>{let f=de(d);return!f||!$t.test(d)?d:Ut(Vt(d,f),n,d,e)},r=d=>{let f=[];for(let m of d)f.push(i(m)),tt.test(m)&&e()<.2&&f.push(i(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let R=0;R<m;R++)for(let S=0;S<5;S++){let O=Math.floor(e()*f.length);if(tt.test(f[O])){f.splice(O,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[s,l=""]=t.split("@"),u=l.endsWith(".com"),c=u?l.slice(0,-4):l;return`${r(s)}@${r(c)}${u?".com":""}`}var Kt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ht=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Yt=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 ee(t,e){if(!t||!e)return!1;let n=Ht(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:Kt.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function jt(t){return!!t&&Yt.test(t)}function sr(t,e,n){return t?jt(t)?[...e]:[...n,...e].some(i=>ee(t,i))?e.filter(i=>ee(t,i)):[...e]:[]}var Xt=5,Zt=6,qt=3,q=864e5,Qt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Jt=/^(\d{4})[-/](\d{1,2})$/,en=/^(\d{4})[-\s]?Q([1-4])$/i,tn=/^Q([1-4])[-\s](\d{4})$/i,nn=/^(\d{4})$/,rn=/^(\d{4})(0[1-9]|1[0-2])$/,sn=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,on=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,an=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function rt(t,e){let n=ue(t);if(!n)return 0;if(n==="sept")return 9;for(let i of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let r=le(i)[n];if(r!==void 0)return r+1}return 0}function un(t){let e=se(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:$(n.year,(n.n-1)*3+1,1)}function $(t,e,n,i=0,r=0,o=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let s=Date.UTC(t,e-1,n,i,r,o);if(!Number.isFinite(s))return null;let l=u=>u<10?"0"+u:String(u);return{ms:s,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function ln(t,e){let n=[],i="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){i+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){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 o=0,s=1,l=1;return n.forEach((u,c)=>{let d=+r[c+1];u==="Y"?o=d:u==="m"?s=d:l=d}),o?$(o,s,l):null}function Se(t,e,n){let i=(t??"").trim();if(i==="")return null;if(e){let s=ln(i,e);return s||null}let r=Qt.exec(i);if(r)return $(+r[1],+r[2],+r[3],+(r[4]??0),+(r[5]??0),+(r[6]??0));if(r=en.exec(i),r)return $(+r[1],(+r[2]-1)*3+1,1);if(r=tn.exec(i),r)return $(+r[2],(+r[1]-1)*3+1,1);if(r=Jt.exec(i),r&&+r[2]>=1&&+r[2]<=12)return $(+r[1],+r[2],1);if(r=sn.exec(i),r)return $(+r[1],+r[2],+r[3]);if(r=rn.exec(i),r)return $(+r[1],+r[2],1);if(r=nn.exec(i),r){let s=+r[1];return s>=1900&&s<=2100?$(s,1,1):null}let o=un(i);if(o)return o;if(r=on.exec(i),r){let s=rt(r[1],n);return s?$(+r[2],s,1):null}if(r=an.exec(i),r){let s=rt(r[2],n);return s?$(+r[1],s,1):null}return null}function it(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function st(t,e){if(e<=t)return 0;let n=Math.round((e-t)/q),i=Math.floor(n/7),r=i*5,o=t+i*7*q;for(;o<e;)it(o)&&r++,o+=q;return r}function cn(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 mn(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 te(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*q));case"weekday":return st(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/q);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function ot(t,e){return _e(t,e)?.cadence??null}function _e(t,e){let n=e?.gapFactor??Xt,i=0,r=0,o=new Map;for(let y of t){if(y==null||y==="")continue;i++;let W=Se(String(y),e?.pattern,e?.locale);W&&(r++,o.set(W.ms,W))}let s=[...o.values()].sort((y,W)=>y.ms-W.ms);if(s.length<qt||i>0&&r/i<.8)return null;let l=s[s.length-1].ms-s[0].ms;if(l<=0)return null;let u=[];for(let y=1;y<s.length;y++)u.push(s[y].ms-s[y-1].ms);let c=cn(u);if(!(c>0))return null;let d=mn(c/q);d==="day"&&l>=7*q&&s.every(y=>it(y.ms))&&st(s[0].ms,s[s.length-1].ms)+1>s.length*.5&&(d="weekday");let f=d==="irregular"?s.length:te(s[0],s[s.length-1],d,c)+1,m=1,R=1,S=[],O=s[0],_=1;for(let y=1;y<s.length;y++){let W=te(s[y-1],s[y],d,c);W>m&&(m=W),d!=="irregular"&&W>n?(R++,S.push({from:O.iso,to:s[y-1].iso,points:_}),O=s[y],_=1):_++}S.push({from:O.iso,to:s[s.length-1].iso,points:_});let w={grain:d,points:s.length,expectedPoints:Math.max(f,s.length),coveragePct:Math.round(s.length/Math.max(f,s.length)*1e3)/10,runs:R,largestGapUnits:m,gapFactor:n};return e?.includeBounds&&S.length<=Zt&&(w.runBounds=S),{cadence:w,points:s,stepMs:c}}var dn=8,fn=.5,gn=200,pn=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"]),hn=["category","classification","segment","status","priority","severity","channel"],bn=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function yn(t){let e=j(t);if(e.length===0)return!1;let n=e[e.length-1];return pn.has(n)?!0:hn.some(i=>n.length>i.length&&n.endsWith(i))}function Sn(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>gn?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":oe(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&bn.has(ae(e))?"identifier":!t.geoKind&&yn(t.name)?"attribute":"entity"}function lt(t){let e=-1,n=1/0,i=!1;return t.forEach((r,o)=>{if(Sn(r)!=="entity")return;let s=new Set(Array.from(r.values).filter(u=>u!=="")).size,l=!!r.geoKind;(s<n||s===n&&l&&!i)&&(e=o,n=s,i=l)}),e}var at=t=>t<10?"0"+t:String(t);function ut(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${at(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${at(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function ct(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let I=0;I<i;I++)e[I]&&r.add(e[I]);let o=_e(r,{pattern:t.pattern,locale:t.locale});if(!o)return null;let s=o.cadence.grain;if(s==="irregular")return null;let l=o.points[0],u=te(l,o.points[o.points.length-1],s,o.stepMs)+1;if(u!==o.cadence.expectedPoints)return null;let c=new Map;for(let I of r){let h=Se(I,t.pattern,t.locale);if(!h)continue;let P=te(l,h,s,o.stepMs);P>=0&&P<u&&c.set(I,{idx:P,stamp:h})}let d=new Map;for(let I=0;I<i;I++){let h=n[I];if(!h)continue;let P=c.get(e[I]);if(!P)continue;let z=d.get(h);z||(z={seen:new Set,lo:P.idx,hi:P.idx,loStamp:P.stamp,hiStamp:P.stamp,order:d.size},d.set(h,z)),z.seen.add(P.idx),P.idx<z.lo&&(z.lo=P.idx,z.loStamp=P.stamp),P.idx>z.hi&&(z.hi=P.idx,z.hiStamp=P.stamp)}if(d.size<2)return null;let f=0;for(let I of d.values())f+=I.seen.size;if(f/(d.size*u)<(t.minFill??fn))return null;let m=[],R=new Set,S=0,O=0,_=0,w=0,y=0,W=1;for(let[I,h]of d){for(let B of h.seen)R.add(B);if(h.seen.size>=u)continue;let P=[...h.seen].sort((B,a)=>B-a),z=1;for(let B=1;B<P.length;B++)z=Math.max(z,P[B]-P[B-1]);let Y={key:I,acc:h,coverage:h.seen.size/u,before:h.lo,after:u-1-h.hi,interior:h.hi-h.lo+1-h.seen.size,gap:z};m.push(Y),Y.before>0&&S++,Y.after>0&&O++,Y.interior>0&&_++,w=Math.max(w,Y.before),y=Math.max(y,Y.after),W=Math.max(W,z)}if(m.length===0)return null;m.sort((I,h)=>I.coverage-h.coverage||I.acc.order-h.acc.order);let U=m.slice(0,t.maxListed??dn);return{seriesColumn:t.seriesColumn,grain:s,periods:u,seriesCount:d.size,incompleteSeries:m.length,lateStarts:S,earlyEnds:O,withHoles:_,columnWideMissing:u-R.size,maxMissingBefore:w,maxMissingAfter:y,largestGap:W,series:U.map(I=>{let h={};return t.includeNames&&(h.name=I.key),t.includeDates&&(h.first=ut(I.acc.loStamp,s),h.last=ut(I.acc.hiStamp,s)),h.missingBefore=I.before,h.missingAfter=I.after,h.missingInterior=I.interior,h.largestGap=I.gap,h.coverage=Math.round(I.coverage*1e3)/1e3,h}),more:m.length-U.length}}var _n=12,An=100,Cn=.3,Mn=.9,xn=120,Rn=1900,Tn=2100,Nn=0,En=20,In=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function gt(t){if(!t)return!1;let e=j(t);return e.length===0?!1:In.has(e[e.length-1])?!0:Je(t)!==null}var vn=new Set(["year","yr","fy"]),wn=t=>j(t).some(e=>vn.has(e))||De(t)!==null,Ln=/^(?:(?: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 Ae(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Ce(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 Dn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,On=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Pn=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function kn(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function pt(t,e){let n=0,i=0,r=0,o=0,s=0,l="",u=0,c="",d=0,f=0,m=0,R=0,S=!1;for(let U of t){if(U==null)continue;let I=String(U).trim();if(I==="")continue;n++;let h;if(h=Dn.exec(I)){let P=+h[2],z=+h[3];P>=1&&P<=12&&z>=1&&z<=31&&(i++,h[4]!==void 0&&r++,h[6]!==void 0&&o++)}else if(h=On.exec(I)){let P=+h[3],z=+h[4];P>=1&&P<=12&&z>=1&&z<=31&&(l&&l!==h[2]&&(S=!0),l=h[2],s++)}else if(h=Pn.exec(I)){let P=+h[1],z=+h[3];P>=1&&P<=31&&z>=1&&z<=31&&(P<=12||z<=12)&&(c&&c!==h[2]&&(S=!0),c=h[2],u++,P>12&&m++,z>12&&R++,h[5]!==void 0&&d++,h[7]!==void 0&&f++)}if(n>=200)break}if(n<2||(i+s+u)/n<.8||(i>0?1:0)+(s>0?1:0)+(u>0?1:0)!==1||S)return null;if(i>0)return r===i?{pattern:o===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(s>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(m>0&&R>0)return null;let w,y;m>0?(w=!0,y="values"):R>0?(w=!1,y="values"):(w=!kn(e),y="locale");let W=w?`%d${c}%m${c}%Y`:`%m${c}%d${c}%Y`;return d===u?{pattern:W+(f===u?" %H:%M:%S":" %H:%M"),orderFrom:y}:{pattern:W,orderFrom:y}}function Fn(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=ue(n);return i.length>0&&e[i]!==void 0}var Gn=/(?:19|20)[0-9]{2}/;function Wn(t){let e=new Map,n=0;for(let r of t){if(!Gn.test(re(r)))continue;let o=new Set(se(r).filter(s=>s.yearDigits===4&&(s.grain==="quarter"||s.grain==="week")).map(s=>s.lang));if(o.size!==0){if(o.has("en")){n++;continue}for(let s of o)e.set(s,(e.get(s)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function zn(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 o=t.minNum,s=t.maxNum;if(!(o!=null&&s!=null&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isInteger(o)&&Number.isInteger(s)&&s>=o))return!1;let u=o>=1900&&s<=2100;if(u&&r>=2&&wn(n)||u&&r>=3&&r===s-o+1)return!0;let c=Ae(o)&&Ae(s),d=Ce(o)&&Ce(s);if(c||d){if(!t.sampleValues)return!0;let f=0,m=0;for(let R of t.sampleValues){if(R==null||R==="")continue;f++;let S=Number(String(R).trim());if(Number.isFinite(S)&&(c?Ae(S):Ce(S))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let o=t.locale?le(t.locale):null,s=0,l=0,u=[],c=[];for(let d of t.sampleValues){if(d==null||d==="")continue;s++;let f=String(d).trim();if(u.push(f),Ln.test(f)||Fn(f,o)?l++:c.push(f),s>=60)break}if(s>=2&&l/s>=.8||s>=2&&(l+Wn(c))/s>=.8||pt(u,t.locale)!==null)return!0}return!1}function Bn(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":Ue.some(n=>e.startsWith(n+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":be.some(n=>e.startsWith(n+" ")||e===n)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Vn(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:o,maxNum:s,discourageAgg:l}=t,u=100,c=.01,d="";for(let m of r){if(m.distinct<2||m.distinct>u)continue;let R=r.filter(y=>y.idx!==m.idx).map(y=>y.idx),S=new Map;for(let y of e){let W=y[n];if(typeof W!="number"||!Number.isFinite(W))continue;let U=R.length?R.map(h=>String(y[h])).join(d):"",I=S.get(U);I||(I={sum:0,cset:new Set},S.set(U,I)),I.sum+=W,I.cset.add(String(y[m.idx]))}let O=0,_=0,w=0;for(let y of S.values())y.cset.size<2||(w++,Math.abs(y.sum-100)<=100*c?O++:Math.abs(y.sum-1)<=1*c&&_++);if(w>=2&&(O/w>=.9||_/w>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=Bn(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:o!=null&&s!=null&&Number.isFinite(o)&&Number.isFinite(s)&&o>=0&&s<=1.0001&&s>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function dt(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:o,prec:s,maxval:l,minval:u}=t,c=l-u+1,d=c>0?r/c:1,f=o>0?r/o:0,m=e==="Decimal"||s>0;return!n&>(i)?"Categorical":d>=Mn&&(Oe(i)&&r<=xn||u>=Rn&&l<=Tn||u>=Nn&&l<=En)?"Ordinal":n||r>_n&&(m||r>=An||f>=Cn)?"Continuous":"Categorical"}function Un(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 ft=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;dedupRows=!0;emitLegacyAggAliases=!1;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}declareDimensions(e){for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return Le(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),o=[];for(let a of this._cols){let p=new Map,D=[],N=0,g=0,T=0,v=null,E=null,x=null,F=!1,k=!0,C=!0,M=null,G=!1;for(let A of this._rows){let b=A[i],L=this.STR(b);if(L!=""){if(N+=L.length,p.set(L,(p.get(L)||0)+1),g++,a.dataType=="Integer"||a.dataType=="Decimal"||a.dataType=="DateTime")if((v===null||b<v)&&(v=b),(E===null||b>E)&&(E=b),a.dataType=="Integer"||a.dataType=="Decimal"){if(x===null?x=b:x+=b,a.dataType=="Decimal"){let V=this.getPrecision(b);V>T&&(T=V)}D.push(b)}else F=F||this.hasTimeComponent(b);G&&(b<M?k=!1:b>M&&(C=!1)),M=b,G=!0}}if(g>=3&&(k&&!C?a.sortedDirection="asc":C&&!k?a.sortedDirection="desc":a.sortedDirection="none"),g>0&&p.size>0&&!a.isMeasure){let A=0,b=Number.MAX_SAFE_INTEGER;for(let L of p.values())L>A&&(A=L),L<b&&(b=L);if(a.modalShare=A/g,a.minGroupCount=b===Number.MAX_SAFE_INTEGER?null:b,p.size===2){let L=[...p.keys()].map(ne=>Ie(ne).trim().toLowerCase()).sort(),K=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ne=>L[0]===ne[0]&&L[1]===ne[1]),Q=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(a.name);(K||Q)&&(a.isBinaryFlag=!0)}}if(a.dataType=="DateTime"&&(a.dateWithTime=F),a.isTemporal=zn({dataType:a.dataType,name:a.name,isMeasure:a.isMeasure,distinctCount:p.size,minNum:typeof v=="number"?v:null,maxNum:typeof E=="number"?E:null,sampleValues:p.keys(),locale:n}),a.isTemporal&&a.dataType==="String"&&!a.isMeasure){let A=pt(p.keys(),n);A&&(a.temporalTextPattern=A.pattern)}if(a.isTemporal&&!a.isMeasure){let A=ot(p.keys(),{includeBounds:r>=20,pattern:a.temporalTextPattern,locale:n});A&&(a.temporalCadence=A)}this.updateColumnStats10(r,a,g,p,T,E,v),this.updateColumnStats20(r,D,g,x,a,N,F,v,E,T,p,n),!a.isMeasure&&!this._declaredDimensions.has(a)&&(a.dataType==="Integer"||a.dataType==="Decimal")&&dt({dataType:a.dataType,isMeasure:!1,name:a.name,distinct:p.size,nonblank:g,prec:T,maxval:typeof E=="number"?E:0,minval:typeof v=="number"?v:0})==="Continuous"&&(a.isMeasure=!0,a.geoKind=void 0,a.geoMatchPct=void 0,a.geoAmbiguous=void 0,a.dominantGeoRegion=void 0,a.dominantGeoRegionPct=void 0,a.geoRegionCount=void 0),o[i]=a.isMeasure||p.size>2e3?null:new Set(p.keys()),i++}let s=[];this._cols.forEach((a,p)=>{a.isMeasure||s.push({idx:p,distinct:a.distinctCount??0,name:a.name})}),this._cols.forEach((a,p)=>{if(!a.isMeasure)return;let D=typeof a.lowValue=="number"?a.lowValue:null,N=typeof a.highValue=="number"?a.highValue:null,g=Vn({rows:this._rows,measureColIdx:p,measureName:a.name,candidateDims:s,minNum:D,maxNum:N,discourageAgg:!!a.discourageAggregationAcrossGroups});a.additivity=g.additivity,g.partOfWholeDim&&(a.partOfWholeDim=g.partOfWholeDim)});let l=50,u=4,c=s.filter(a=>a.distinct>=2&&a.distinct<=l);this._cols.forEach((a,p)=>{if(!a.isMeasure)return;let D=[];for(let C of this._rows){let M=C[p];if(M==null||M==="")continue;let G=typeof M=="number"?M:parseFloat(M);isNaN(G)||D.push(G)}if(D.length===0)return;let N=[...D].sort((C,M)=>C-M);if(N[0]===N[N.length-1])a.relativeDispersion=0;else if(N.length>=u){let C=H(N,.5),M=H(N,.1),G=H(N,.9);a.relativeDispersion=Math.abs(C)>1e-9?Math.round((G-M)/Math.abs(C)*1e3)/1e3:void 0}else a.relativeDispersion=void 0;let g=[];for(let C of c){let M=new Set;for(let G of this._rows){let A=G[p];A==null||A===""||M.add(this.STR(G[C.idx])+"")}g.push({otherColumn:C.name,nonBlankGroupCount:M.size})}g.length>0&&(a.nonBlankGroups=g);let T=0;for(let C of D)T+=C;T/=D.length;let v=0;for(let C of D)v+=(C-T)*(C-T);if(v<=1e-12)return;let E=[],x=[],F=C=>{if(C.length<4)return NaN;let M=[...C].sort((A,b)=>A-b),G=A=>M[Math.min(M.length-1,Math.max(0,Math.floor(A*(M.length-1))))];return G(.75)-G(.25)},k=F(D);for(let C of c){let M=new Map;for(let b of this._rows){let L=b[p];if(L==null||L==="")continue;let V=typeof L=="number"?L:parseFloat(L);if(isNaN(V))continue;let K=this.STR(b[C.idx])+"",Q=M.get(K);Q?(Q.s+=V,Q.n++,Q.vals.push(V)):M.set(K,{s:V,n:1,vals:[V]})}let G=0;for(let b of M.values()){let L=b.s/b.n;G+=b.n*(L-T)*(L-T)}E.push({otherColumn:C.name,eta2:Math.round(G/v*1e4)/1e4});let A=[];for(let b of M.values()){let L=F(b.vals);isNaN(L)||A.push(L)}if(A.length>=2&&isFinite(k)&&k>1e-9){let b=(Math.max(...A)-Math.min(...A))/k;x.push({otherColumn:C.name,spreadRatio:Math.round(b*1e4)/1e4})}}E.length>0&&(a.groupDiscrimination=E),x.length>0&&(a.spreadDiscrimination=x)});let d=.97,f=.8,m=8,R=5,S=this._cols.map((a,p)=>({c:a,i:p})).filter(a=>a.c.isMeasure);for(let a=0;a<S.length;a++)for(let p=a+1;p<S.length;p++){let D=S[a].i,N=S[p].i,g=0,T=0,v=0,E=0,x=0,F=0;for(let A of this._rows){let b=A[D],L=A[N];if(b==null||b===""||L===null||L===void 0||L==="")continue;let V=typeof b=="number"?b:parseFloat(b),K=typeof L=="number"?L:parseFloat(L);isNaN(V)||isNaN(K)||(g++,T+=V,v+=K,E+=V*V,x+=K*K,F+=V*K)}if(g<R)continue;let k=g*E-T*T,C=g*x-v*v;if(k<=1e-12||C<=1e-12)continue;let M=(g*F-T*v)/Math.sqrt(k*C),G=Math.min(1,Math.round(Math.abs(M)*1e3)/1e3);for(let A of[S[a].c,S[p].c])(A.maxAbsMeasureCorrelation===void 0||G>A.maxAbsMeasureCorrelation)&&(A.maxAbsMeasureCorrelation=G);if(Math.abs(M)>=d){let A=S[a].c,b=S[p].c;A.collinearWithMeasures||(A.collinearWithMeasures=[]),b.collinearWithMeasures||(b.collinearWithMeasures=[]),A.collinearWithMeasures.push(b.name),b.collinearWithMeasures.push(A.name)}else if(Math.abs(M)>=f){let A=S[a].c,b=S[p].c,L=Math.round(M*1e3)/1e3;A.correlatedWithMeasures||(A.correlatedWithMeasures=[]),b.correlatedWithMeasures||(b.correlatedWithMeasures=[]),A.correlatedWithMeasures.push({otherColumn:b.name,r:L}),b.correlatedWithMeasures.push({otherColumn:A.name,r:L})}}for(let{c:a}of S)a.correlatedWithMeasures&&(a.correlatedWithMeasures.sort((p,D)=>Math.abs(D.r)-Math.abs(p.r)||(p.otherColumn<D.otherColumn?-1:1)),a.correlatedWithMeasures.length=Math.min(a.correlatedWithMeasures.length,m));for(let a=0;a<this._cols.length;a++){let p=o[a];if(!p||p.size===0)continue;let D=[];for(let N=0;N<this._cols.length;N++){if(N===a)continue;let g=o[N];if(!g||g.size===0)continue;let T=0;for(let E of p)g.has(E)&&T++;let v=Math.round(T/p.size*100);v>0&&D.push({otherColumn:this._cols[N].name,percentShared:v})}D.length>0&&(this._cols[a].sharedValueRatioWithOthers=D)}let O=50,_=[];for(let a=0;a<this._cols.length;a++){let p=o[a];p&&p.size>=2&&p.size<=O&&_.push(a)}if(_.length>=2){let a=new Map,p=(N,g)=>N+":"+g;for(let N=0;N<_.length;N++)for(let g=N+1;g<_.length;g++)a.set(p(_[N],_[g]),new Map);for(let N of this._rows)for(let g=0;g<_.length;g++){let T=this.STR(N[_[g]])+"";for(let v=g+1;v<_.length;v++){let E=""+this.STR(N[_[v]]),x=a.get(p(_[g],_[v])),F=T+""+E;x.set(F,(x.get(F)??0)+1)}}let D=new Map;for(let N=0;N<_.length;N++)for(let g=N+1;g<_.length;g++){let T=_[N],v=_[g],E=o[T].size,x=o[v].size,F=a.get(p(T,v)),k=F.size,C=0;for(let b of F.values())(C===0||b<C)&&(C=b);let M=Math.round(k/(E*x)*100),G=k===E,A=k===x;if((this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[v].name,fillPct:M,determinesOther:G,minCellCount:C,distinctCombinations:k}),(this._cols[v].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:M,determinesOther:A,minCellCount:C,distinctCombinations:k}),G&&E>x){let b=D.get(T);(!b||x<b.card)&&D.set(T,{name:this._cols[v].name,card:x,ratio:x/E})}if(A&&x>E){let b=D.get(v);(!b||E<b.card)&&D.set(v,{name:this._cols[T].name,card:E,ratio:E/x})}}for(let[N,g]of D)this._cols[N].primaryParentColumn=g.name,this._cols[N].nestingRatio=Math.round(g.ratio*100)/100}let w=6,y=this._rows.length;for(let a=0;a<this._cols.length;a++){let p=this._cols[a];if(p.isMeasure||p.primaryParentColumn)continue;let D=p.distinctCount??0;if(D<=O||y>0&&D>=y)continue;let N=[];for(let g=0;g<this._cols.length;g++){if(g===a)continue;let T=this._cols[g];if(T.isMeasure)continue;let v=T.distinctCount??0;v<2||v>=D||N.push(g)}N.sort((g,T)=>(this._cols[g].distinctCount??0)-(this._cols[T].distinctCount??0));for(let g of N.slice(0,w)){let T=new Map,v=!0;for(let x of this._rows){let F=this.STR(x[a])+"",k=this.STR(x[g])+"",C=T.get(F);if(C===void 0)T.set(F,k);else if(C!==k){v=!1;break}}if(!v)continue;let E=this._cols[g].distinctCount??0;p.primaryParentColumn=this._cols[g].name,p.nestingRatio=Math.round(E/D*100)/100;break}}let W=.01,U=.05,I=.95,h=8,P=8,z=6,Y=500,B=[];for(let a=0;a<this._cols.length&&B.length<P;a++){let p=this._cols[a].dataType;(p==="Double"||p==="Integer"||p==="Decimal")&&B.push(a)}if(B.length>=3&&this._rows.length>=h){let a=Math.min(this._rows.length,Y),p=B.map(E=>{let x=[];for(let C=0;C<a;C++){let M=this._rows[C][E],G=typeof M=="number"?M:parseFloat(String(M).replace(/,/g,""));if(M==null||M===""||!isFinite(G))return null;x.push(G)}let F=x[0],k=!1;for(let C of x)if(C!==F){k=!0;break}return k?x:null}),D=B.map((E,x)=>x).filter(E=>p[E]!==null),N=E=>{let x=E.slice().sort((k,C)=>k-C),F=x.length>>1;return x.length%2?x[F]:(x[F-1]+x[F])/2},g=null,T=[],v=E=>{if(T.length>=3){let x=T.map(M=>p[M]),F=x[0].length,k=new Array(F);for(let M=0;M<F;M++){let G=0;for(let A of x)G+=A[M];k[M]=G}let C=N(k);if(C>0){let M=0;for(let A of k)Math.abs(A-C)<=C*W&&M++;let G=M/F;if(G>=I){let A=1;for(let b of x){let L=N(b)/C;L<A&&(A=L)}A>=U&&(!g||T.length>g.cols.length)&&(g={cols:T.slice(),total:C,matched:G})}}}if(!(T.length>=z))for(let x=E;x<D.length;x++)T.push(D[x]),v(x+1),T.pop()};if(v(0),g){let E=g,F={columns:E.cols.map(k=>this._cols[B[k]].name),total:Math.round(E.total*1e3)/1e3,matchedPct:Math.round(E.matched*100)/100};for(let k of E.cols)this._cols[B[k]].constantSumGroup=F}}return this.applySeriesCompleteness(r,n,o),this._computedStatsForLevel=e,this._cols}applySeriesCompleteness(e,n,i){for(let m of this._cols)m.seriesCompleteness!==void 0&&delete m.seriesCompleteness;let r=this._cols.map((m,R)=>({c:m,i:R})).filter(({c:m})=>m.isTemporal&&!m.isMeasure&&m.temporalCadence&&m.temporalCadence.grain!=="irregular");if(r.length===0)return;let o=[],s=[];this._cols.forEach((m,R)=>{let S=i[R];S&&(o.push(R),s.push({name:m.name,dataType:m.dataType,isMeasure:!!m.isMeasure,isTemporal:!!m.isTemporal,isDatePart:!!m.isDatePart,isReassembledDate:!!m.isReassembledDate,isBinaryFlag:!!m.isBinaryFlag,geoKind:m.geoKind,identifierNamed:gt(m.name),values:S,rows:this._rows.length,locale:n}))});let l=lt(s);if(l<0)return;let u=o[l],c=this._cols[u],d=this._rows.map(m=>this.STR(m[u])),f=e>=20&&(c.dataType!=="String"||Array.isArray(c.safeDistinctValues));for(let{c:m,i:R}of r){let S=ct({periods:this._rows.map(O=>this.STR(O[R])),series:d,seriesColumn:c.name,pattern:m.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:f});S&&(m.seriesCompleteness=S)}}updateColumnStats20(e,n,i,r,o,s,l,u,c,d,f,m){if(e>=20){let R=[...n].sort((_,w)=>_-w),S=Math.floor(R.length/2);if(i>0&&r!=null?o.avgValue=o.dataType=="Integer"?Math.round(r/i):r/i:o.avgValue=null,i>0&&(o.avgLength=s/i),this._rows.length>0){let _=w=>{let y=w instanceof Date?w:typeof w=="string"?pe(w)??new Date(w):new Date(w),W=this.wholeDayIso(y);return W?W+"T00:00:00.000Z":isNaN(y.getTime())?w:y.toISOString().slice(0,10)+"T00:00:00.000Z"};o.dataType!="DateTime"||l||!u?o.lowValue=u:o.lowValue=_(u),o.dataType!="DateTime"||l||!c?o.highValue=c:o.highValue=_(c),o.medianValue=R.length===0?null:R.length%2===0?o.dataType=="Integer"?Math.round((R[S-1]+R[S])/2):(R[S-1]+R[S])/2:R[S],o.numericPrecision=d}if(R.length>0){let _=o.avgValue??0,w=R.length,y=0,W=0;for(let I of R){let h=I-_;y+=h*h,W+=h*h*h}let U=y/w;o.skewness=U===0?0:W/w/Math.pow(Math.sqrt(U),3),o.stdDev=Math.sqrt(U)}r!==null&&(o.sum=r);let O=Array.from(f.entries()).sort((_,w)=>w[1]-_[1]);if(o.topCategories=O.slice(0,10).map(_=>_[1]),!o.isMeasure&&O.length>0&&(o.dataType!=="String"&&(o.topCategoryValues=O.slice(0,5).map(_=>_[0])),e>=20)){let _=O.map(y=>y[0]),w=oe(_,m);if(w!==null)o.ordinalPattern=w.pattern,o.orderedDomain=w.orderedDomain;else if(o.dataType==="String"){let y=Pe(_);y!==null&&(o.safeDistinctValues=y)}}if(R.length>=8&&(o.dataType==="Integer"||o.dataType==="Decimal")){let _=w=>R[Math.floor((R.length-1)*w)];o.quantiles={p05:_(.05),p25:_(.25),p75:_(.75),p95:_(.95)}}}if(!o.isMeasure&&o.dataType==="String"&&f.size>0){let R=Array.from(f.entries()).sort((_,w)=>w[1]-_[1]).map(_=>_[0]);o.formatSignature=ae(R);let S=i>0?s/i:void 0,O=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;o.formatSignature&&!O.test(o.formatSignature)&&(S===void 0||S>=3)&&(o.isFreeText=!0)}if(!o.isMeasure&&f.size>0){let R=Array.from(f.entries()).sort((O,_)=>_[1]-O[1]),S=Ge(R.map(O=>O[0]),o.name,m);if(S!==null&&(o.geoKind=S.geoKind,o.geoMatchPct=S.geoMatchPct,S.geoAmbiguous&&(o.geoAmbiguous=!0),S.geoKind.indexOf("country")===0)){let O=he(R);O&&(o.dominantGeoRegion=O.dominantGeoRegion,o.dominantGeoRegionPct=O.dominantGeoRegionPct,o.geoRegionCount=O.regionCount)}}}updateColumnStats10(e,n,i,r,o,s,l){let u=this._rows.length-i;e>=10&&(n.blankCount=u),n.distinctCount=r.size+(u!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=dt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:o,maxval:s,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=s=>Me(s,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((s,l)=>{let u=e(s.name),c=s.dataType==="Integer"||s.dataType==="Decimal";c&&n<0&&u.some(d=>d==="lat"||d==="latitude")?n=l:c&&i<0&&u.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(i=l),r<0&&!s.isMeasure&&typeof s.geoKind=="string"&&s.geoKind.indexOf("country")===0&&(r=l)}),n<0||i<0)return null;let o=[];for(let s of this._rows){let l=s[n],u=s[i],c=l==null||l===""?null:Number(l),d=u==null||u===""?null:Number(u);o.push({lat:c,lon:d,country:r>=0&&ce(this.STR(s[r]))?this.STR(s[r]):null})}return this._geoExtent=Be(o),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return nt(e,we)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,o)=>{i[r.name]=n[o],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[o])});for(let[r,o]of e)Object.prototype.hasOwnProperty.call(i,o.alias)||(i[o.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,o=new Map;for(let l of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let d=this._cols[c],f=l[c];if(this.STR(f)!=""){if(e&&d.dataType=="String")if(o.has(f))f=o.get(f);else{let m=this.obfuscateString(f);o.set(f,m),f=m}else if(d.dataType=="DateTime"&&!d.dateWithTime){let m=f instanceof Date?f:typeof f=="string"?pe(f)??new Date(f):new Date(f);f=(this.wholeDayIso(m)??m.toISOString().slice(0,10))+"T00:00:00.000Z"}r-=this.STR(f).length}else f=null;u[c]=f,--r}if(n.push(u),--i,i<=0||r<=0)break}return await mt.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return mt.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}aliasesForCode(e){let n=ye(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=ye(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:"english-implicit-agg"});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 s of this._cols)s&&(r.add(this.STR(s.name)),s.hostName&&r.add(this.STR(s.hostName)));let o=new Map;for(let s=0;s<this._cols.length;s++){if(!this._cols[s])continue;let l=Ye(this._hostQueryNames[s]).filter(u=>!r.has(u)&&ee(i,u));l.length===1&&o.set(l[0],[...o.get(l[0])??[],s])}for(let[s,l]of o){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);n.set(l[0],{name:u,alias:s,headerName:!ee(i,u)})}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 o of e)i+=this.STR(o)+"~";let r=ve(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Un(e)),this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(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),o=Ke(r);!o||o===r||n.has(o)||(n.delete(r),n.add(o),i.hostName=r,i.name=o)}}};export{Be as a,yt as b,ce as c,Hn as d,St as e,_t as f,At as g,Ct as h,me as i,Nt as j,Ke as k,ye as l,Ye as m,Xe as n,wt as o,qe as p,Qe as q,Zn as r,qn as s,Qn as t,Ot as u,Pt as v,kt as w,Je as x,ee as y,jt as z,sr as A,Xt as B,Zt as C,Se as D,ot as E,dn as F,fn as G,gn as H,Sn as I,lt as J,ct as K,gt as L,pt as M,zn as N,Bn as O,Vn as P,dt as Q,Un as R,ft as S};
|
|
@@ -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{L as x,S as T}from"./chunk-
|
|
2
|
+
import{L as x,S as T}from"./chunk-HRIMAMPX.mjs";import{B as E}from"./chunk-4VN252CK.mjs";import A from"papaparse";function k(e){if(!e)return".";try{return new Intl.NumberFormat(e).formatToParts(1.5).find(t=>t.type==="decimal")?.value===","?",":"."}catch{return"."}}var C="[ \\u00A0\\u202F]",y="(?:[eE][+-]?\\d+)?",O=new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?${y}$`),N=new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+)(?:,\\d+)?${y}$`),P=/^[+-]?\d{1,3}[.,]\d{3}$/,_=[/^[+-]?\d{1,3}(?:,\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:,\\d{3})+|\\d+)\\.\\d+${y}$`)],j=[/^[+-]?\d{1,3}(?:\.\d{3}){2,}$/,new RegExp(`^[+-]?(?:\\d{1,3}(?:\\.\\d{3})+|\\d{1,3}(?:${C}\\d{3})+|\\d+),\\d+${y}$`)];function R(e,r){let t=0,n=0;for(let c of e){if(typeof c!="string")continue;let i=c.trim();i===""||P.test(i)||(_.some(s=>s.test(i))?t++:j.some(s=>s.test(i))&&n++)}return n>0&&t===0?",":t>0?".":k(r)}function h(e,r){let t=String(e??"").trim();return t===""?null:r===","?N.test(t)?parseFloat(t.replace(/[. ]/g,"").replace(",",".")):null:O.test(t)?parseFloat(t.replace(/,/g,"")):null}function M(e,r){return h(e,r)!==null}var I=500,$=/^[+-]?\d{1,15}$/,F=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,q=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function V(e,r="."){let t=0,n=0,c=0,i=0;for(let s of e){if(s==null)continue;if(typeof s=="number"){i++,n++,Number.isInteger(s)&&t++;continue}if(s instanceof Date){i++,c++;continue}if(typeof s=="boolean"){i++;continue}let l=String(s).trim();if(l!==""){if(i++,$.test(l)){t++,n++;continue}if(M(l,r)){n++;continue}if((F.test(l)||q.test(l))&&!isNaN(Date.parse(l))){c++;continue}}}return i===0?"String":c===i?"DateTime":t===i?"Integer":n===i?"Decimal":"String"}function v(e,r,t="."){if(e==null)return null;if(typeof e=="number")return r==="String"?String(e):e;if(e instanceof Date)return r==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let n=String(e).trim();if(n==="")return null;switch(r){case"Integer":return $.test(n)?parseInt(n,10):null;case"Decimal":return h(n,t);case"DateTime":return E(n);default:return n}}function B(e){let r=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(r)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(r)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(r)?"DateTime":(/^(bit|bool|boolean)$/.test(r),"String")}function f(e,r,t){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 n=e.length,c=e.map((o,a)=>r.slice(0,I).map(m=>m?.[a])),i=c.map(o=>R(o,t.locale)),s=e.map((o,a)=>o.dataType??V(c[a],i[a])),l=new Set((t.measures??[]).map(o=>o.toLowerCase())),p=new Set((t.dimensions??[]).map(o=>o.toLowerCase())),L=new Set((t.nonAdditive??[]).map(o=>o.toLowerCase())),b=e.map((o,a)=>{let m=o.name.toLowerCase(),d=o.isMeasure??((s[a]==="Integer"||s[a]==="Decimal")&&!x(o.name));l.has(m)&&(d=!0),p.has(m)&&(d=!1);let D={name:o.name,dataType:s[a],isMeasure:d};return d&&L.has(m)&&(D.discourageAggregationAcrossGroups=!0),D}),u=new T;u.dedupRows=t.dedup!==!1,u.setColumns(b),u.declareDimensions(b.filter((o,a)=>p.has(e[a].name.toLowerCase())));for(let o=0;o<r.length;o++){let a=r[o];u.addRow(Array.from({length:n},(m,d)=>v(a?.[d],s[d],i[d])),o)}let S=u.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),g=new Map(S.map(o=>[o.name,o]));e.forEach(o=>{let a=g.get(o.name);a&&(o.format&&(a.modelFormat=o.format),o.description&&(a.modelDesc=o.description))});for(let[o,a]of Object.entries(t.formats??{})){let m=g.get(o);m&&(m.modelFormat=a)}for(let[o,a]of Object.entries(t.descriptions??{})){let m=g.get(o);m&&(m.modelDesc=a)}for(let o of t.groupBy??[]){let a=g.get(o);a&&(a.isGrouping=!0)}return{columns:S,rows:u.toObjectArray(),totalRows:u.getRowCount(),index:u}}function w(e,r){return e.map(t=>Array.isArray(t)?t:r.map(n=>t[n]))}function U(e,r){let t=[],n=new Set,c=Math.min(e.length,Math.max(1,r));for(let i=0;i<c;i++){let s=e[i];if(!(!s||typeof s!="object"))for(let l of Object.keys(s))n.has(l)||(n.add(l),t.push(l))}return t}function W(e){let r=String(e??"").replace(/^\uFEFF/,""),t=[],n=[],c=0;return A.parse(r,{skipEmptyLines:!1,step:i=>{let s=i.meta.cursor,l=r.slice(c,s);c=s,i.errors?.length&&n.push(...i.errors);let p=i.data;p.length===1&&p[0]===""&&l.replace(/[\r\n]/g,"")===""||t.push(p)}}),!t.length&&!n.length&&n.push(...A.parse(r,{skipEmptyLines:!0}).errors),{rows:t,errors:n}}function Z(e,r={}){switch(e.kind){case"csv":{let t=W(e.text);if(t.errors.length&&t.rows.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let n=t.rows;if(n.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let c=n[0].map(i=>(i??"").trim());return f(c.map(i=>({name:i})),n.slice(1),r)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],r)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(n=>n.name);return f(e.columns,w(e.rows??[],t),r)}case"objects":{let t=e.rows??[],n=e.columns?.length?e.columns:U(t,r.columnScanLimit??I).map(c=>({name:c}));if(!n.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(n,w(t,n.map(c=>c.name)),r)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(n=>{let c=B(n.dataType);return{name:n.name,dataType:c,isMeasure:n.isMeasure,format:n.format,description:n.description}});return f(t,w(e.rows??[],t.map(n=>n.name)),r)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{k as a,R as b,h as c,B as d,W as e,Z as f};
|
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 zn,b as Hn}from"./chunk-HIVICMC5.mjs";import{a as Kn,b as I,c as Bn,d as D,e as E,f as jn,g as X,h as J}from"./chunk-HMLAY26J.mjs";import{a as Gn,b as Vn,c as Un,d as Wn,e as qn,f as $n}from"./chunk-O46IPJKL.mjs";import{A as En,B as Tn,C as Sn,D as Rn,E as xn,F as wn,G as _n,H as On,I as vn,J as Pn,K as Ln,L as An,M as Mn,N as In,O as Nn,P as Fn,Q as Dn,S as kn,a as zt,b as Ht,c as Kt,d as Bt,e as Xt,f as Jt,g as Zt,h as en,i as tn,j as nn,k as rn,l as on,m as sn,n as an,o as ln,p as un,q as cn,r as dn,s as mn,t as fn,u as pn,v as gn,w as yn,x as hn,y as Cn,z as bn}from"./chunk-OPDY2YEA.mjs";import{a as jt}from"./chunk-U3H6UBOO.mjs";import{a as Yt,b as Qt}from"./chunk-555PKUBU.mjs";import{a as le,b as ue,c as Ut,d as Wt,e as qt,f as $t}from"./chunk-KQOVPOVU.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Lt,m as At,n as ae,o as v,p as Mt,q as It,r as Nt,s as q,t as Ft,u as Dt,v as kt,w as Gt,x as Q,y as Vt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as mt,c as ft,d as pt,e as gt,f as yt,g as ht,h as Ct,i as bt,j as Et,k as Tt,l as St,m as Ot,n as vt,o as Pt}from"./chunk-GKXYRUK5.mjs";import{A as ot,B as it,C as st,D as at,E as lt,F as ut,G as ct,a as Fe,b as De,c as ke,d as Ge,e as Ve,f as B,g as Ue,h as We,i as qe,j as $e,k as ze,l as He,m as Ke,n as Be,o as je,p as Ye,q as Qe,r as Xe,s as Je,t as Ze,u as et,v as tt,x as j,y as nt,z as rt}from"./chunk-4VN252CK.mjs";import{b as Rt,c as xt,d as wt,e as _t}from"./chunk-5HI6TVMM.mjs";var Z=2,me=400;function te(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let o=U(String(n));if(!V(o)&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||ne(e)<95)return!1;let n=t.filter(l=>te(l)&&!v(l)).length,o=t.filter(l=>!te(l)&&!!v(l)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function $(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)q(o).length>0&&n++;return Math.round(n/t.length*1e3)/10}function de(e,t){return ue(t,le)?!0:oe(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yn(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let l of n)Q(l,t)&&o++;return Math.round(o/n.length*1e3)/10}function ee(e,t){let n=0;for(let o of F(e))t(o)&&n++;return n}function Qn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Xn(e,t,n,o,l){let u=[],a=[],i={},h={},C=new Set(e),y=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&C.has(d)&&(i[s]=d)}let g=new Set(l??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&C.has(f)){let s=y(f),d=re(s);d<95?a.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:a.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&C.has(c)){let s=y(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?a.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(a.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?a.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=y(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,p.add(s.name),u.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(p.has(s))continue;let d=y(s),S=re(d);if(!(S<95)&&de(d,s)&&!(Qn(d,O=>q(O).length>0)<Z)){i.zip=s,p.add(s),u.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(y(T))){let s=null;for(let d of b){if(p.has(d)||!N(y(d)))continue;let S=ne(y(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(a.push(`country=${T} (only ${ne(y(T))}% of values are country identifiers; using ${s.name} instead)`),h.country=T),i.country=s.name,p.add(s.name),u.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(p.has(d))continue;let S=y(d),O=Yn(S,o);O<Y||ee(S,K=>Q(K,o))<Z||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,u.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?y(i.country):[],R=!!i.country&&N(L),A=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&A>=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&&a.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&a.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:u,refused:a,...Object.keys(h).length?{labelFallback:h}:{}}}var r=(e,...t)=>({part:e,langs:Object.freeze(t)}),ie=Object.freeze({jaar:r("year","nl"),kwartaal:r("quarter","nl"),maand:r("month","nl"),dag:r("day","nl","sv","da","nb"),jahr:r("year","de"),quartal:r("quarter","de"),monat:r("month","de"),tag:r("day","de"),ann\u00E9e:r("year","fr"),mois:r("month","fr"),jour:r("day","fr"),trimestre:r("quarter","fr","es","pt","it"),a\u00F1o:r("year","es"),mes:r("month","es"),d\u00EDa:r("day","es"),ano:r("year","pt"),m\u00EAs:r("month","pt"),dia:r("day","pt"),anno:r("year","it"),mese:r("month","it"),giorno:r("day","it"),\u0433\u043E\u0434:r("year","ru"),\u043C\u0435\u0441\u044F\u0446:r("month","ru"),\u0440\u0456\u043A:r("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:r("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:r("quarter","ru","uk"),\u0434\u0435\u043D\u044C:r("day","ru","uk"),rok:r("year","pl","cs","sk"),kwarta\u0142:r("quarter","pl"),miesi\u0105c:r("month","pl"),dzie\u0144:r("day","pl"),\u010Dtvrtlet\u00ED:r("quarter","cs"),m\u011Bs\u00EDc:r("month","cs"),den:r("day","cs"),\u0161tvr\u0165rok:r("quarter","sk"),mesiac:r("month","sk"),de\u0148:r("day","sk"),\u00E5r:r("year","sv","da","nb"),kvartal:r("quarter","sv","da","nb"),m\u00E5nad:r("month","sv"),m\u00E5ned:r("month","da","nb"),vuosi:r("year","fi"),vuosinelj\u00E4nnes:r("quarter","fi"),kuukausi:r("month","fi"),p\u00E4iv\u00E4:r("day","fi"),\u00E9v:r("year","hu"),negyed\u00E9v:r("quarter","hu"),h\u00F3nap:r("month","hu"),nap:r("day","hu"),y\u0131l:r("year","tr"),\u00E7eyrek:r("quarter","tr"),ay:r("month","tr"),g\u00FCn:r("day","tr"),\u03AD\u03C4\u03BF\u03C2:r("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:r("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:r("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:r("day","el"),an:r("year","ro"),trimestru:r("quarter","ro"),lun\u0103:r("month","ro"),zi:r("day","ro"),godina:r("year","hr"),tromjese\u010Dje:r("quarter","hr"),mjesec:r("month","hr"),dan:r("day","hr"),\u5E74:r("year","ja","zh"),\u56DB\u534A\u671F:r("quarter","ja"),\u5B63\u5EA6:r("quarter","zh"),\u6708:r("month","ja","zh"),\u65E5:r("day","ja","zh"),\uC5F0\uB3C4:r("year","ko"),\uBD84\uAE30:r("quarter","ko"),\uC6D4:r("month","ko"),\uC77C:r("day","ko"),tahun:r("year","id"),kuartal:r("quarter","id"),triwulan:r("quarter","id"),bulan:r("month","id"),hari:r("day","id"),n\u0103m:r("year","vi"),qu\u00FD:r("quarter","vi"),th\u00E1ng:r("month","vi"),ng\u00E0y:r("day","vi"),\u0E1B\u0E35:r("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:r("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:r("month","th"),\u0E27\u0E31\u0E19:r("day","th"),\u0627\u0644\u0633\u0646\u0629:r("year","ar"),\u0633\u0646\u0629:r("year","ar"),\u0627\u0644\u0639\u0627\u0645:r("year","ar"),\u0639\u0627\u0645:r("year","ar"),\u0627\u0644\u0631\u0628\u0639:r("quarter","ar"),\u0631\u0628\u0639:r("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":r("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:r("month","ar"),\u0634\u0647\u0631:r("month","ar"),\u0627\u0644\u064A\u0648\u0645:r("day","ar"),\u064A\u0648\u0645:r("day","ar"),\u05E9\u05E0\u05D4:r("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:r("quarter","he"),\u05D7\u05D5\u05D3\u05E9:r("month","he"),\u05D9\u05D5\u05DD:r("day","he"),\u0935\u0930\u094D\u0937:r("year","hi"),\u0938\u093E\u0932:r("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:r("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:r("month","hi"),\u092E\u093E\u0939:r("month","hi"),\u0926\u093F\u0928:r("day","hi"),\u0633\u0627\u0644:r("year","fa"),\u0645\u0627\u0647:r("month","fa"),\u0631\u0648\u0632:r("day","fa")}),Jn=Object.freeze(Array.from(new Set(Object.values(ie).flatMap(e=>e.langs)))),fe=Object.freeze(["fa","ar","he","th"]),pe=1900,ge=2100;function Zn(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let l=e.toLowerCase();return n.includes(l)||n.push(l),n}function er(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Zn(n,t)){let l=ie[o];if(l&&l.langs.includes(t))return l.part}return null}function tr(e,t){return fe.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=pe&&t<=ge:!0}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),l=o.lastIndexOf(";");return l>=0&&(o=o.slice(l+1)),nr.test(o)}function he(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Ce(e,t,n){let o=ye(t),l=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${o}\2`,"g"),u=new RegExp(String.raw`\.name\s*===?\s*(['"])${o}\1`,"g"),a=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&a++;let h=0;for(;(i=l.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!z(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===a}function rr(e,t){return Ce(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 be=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function or(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,l=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=l.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let a=[];return o.forEach(i=>{n.has(i)||he(e,i)||a.push(i)}),a}function ir(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(o=>o.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let o of e.aliasesForCode(t))n.push(o.alias);return n}function Ee(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 sr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let l=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>l?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let a=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?a:a+" "+i.join(" ")}function Te(e){if(!e||e.length===0)return[];let t=[],n=new Map,o=new Map;for(let u of e){let a=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(a!==""&&(n.has(a)||(t.push(a),n.set(a,0)),u.isDatePart===!0&&n.set(a,n.get(a)+1),u.isReassembledDate===!0&&!o.has(a))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",h=typeof u.name=="string"?u.name.trim():"",C=i!==""?i:h;C!==""&&o.set(a,C)}}let l=[];for(let u of t){let a=o.get(u),i=n.get(u)??0;!a||i===0||l.push(`'${a}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return l}var m=e=>e==null?"":String(e),P=e=>e===!0,Se=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},ar=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,l]of ar){let u=m(E(e,t+l));u&&(n[o]=u)}return n}function lr(e){return Array.isArray(e)?e.map(t=>({code:m(E(t,"code")),severity:m(E(t,"severity")),text:m(E(t,"text"))})).filter(t=>t.text!==""):[]}function ur(e){let t=C=>E(e,C),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),l=t("forceThumbnailUpload"),u=Re(e,"point"),a=Re(e,"destPoint");Object.keys(a).length&&(u.dest=a);let i=t("retryable"),h=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:lr(t("notices")),freemiumStatusCode:m(t("freemiumStatusCode")),code:m(t("code")),language:m(t("language")),version:Number(t("version")??0),codeSummary:m(t("codeSummary")),chartName:m(t("chartName")??t("chartType")),finalChartName:m(t("finalChartName")),warningMessage:m(t("warningMessage")),outputHash:m(t("outputHash")),validatorToken:m(t("validatorToken")),editCodeKey:m(t("editCodeKey")),signedLLMRequestID:m(t("signedLLMRequestID")),userReply:m(t("userReply")),userReplyOutcome:m(t("userReplyOutcome")),improvementSuggestion:m(t("improvementSuggestion")),geoColumn:m(t("geoColumn")),geoKind:m(t("geoKind")),geoPointCols:Object.keys(u).length?u:null,creditBalanceBefore:Se(t("creditBalanceBefore")),creditCost:Se(t("creditCost")),isServiceError:P(t("isServiceError")),isRateLimited:P(t("isRateLimited")),isRefusal:P(t("isRefusal")),isVersionNotFound:P(t("isVersionNotFound")),isGenerationCancelled:P(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:m(t("servedCorrelationId")),...typeof h=="boolean"?{isPollFinal:h}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof l=="boolean"?{forceThumbnailUpload:l}:{}}}var xe=e=>e==null?void 0:Number(e),k=e=>m(e)||void 0;function cr(e){let t=E(e,"charts"),n=E(e,"refused"),o=Array.isArray(t)?t.map(u=>{let a=h=>E(u,h),i=a("recommended");return{name:m(a("chartTypeName")??a("name")),description:m(a("description")??a("chartDesc")),rank:xe(a("rank")),score:xe(a("score")),renderer:k(a("renderer")),language:k(a("language")),isPreview:P(a("isPreview")),alsoWorthALook:P(a("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(a("viaProjection")),viaProjectionKey:k(a("viaProjectionKey")),detailNote:k(a("detailNote"))}}).filter(u=>u.name):null,l=Array.isArray(n)?n.map(u=>({name:m(E(u,"chartTypeName")??E(u,"name")),reason:m(E(u,"reason")),reasonCode:m(E(u,"reasonCode")),isVeto:P(E(u,"isVeto"))})).filter(u=>u.name):[];return{errorMessage:m(E(e,"errorMessage")),errorCode:m(E(e,"errorCode")),charts:o,refused:l,noFitSummary:m(E(e,"noFitSummary"))}}function dr(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 we=["working","analyze","generate","refine","review"];function mr(e,t){let n=String(e??"").trim().toLowerCase();if(we.includes(n))return n;let o=String(t??"").toLowerCase();return o.includes("analyz")?"analyze":o.includes("generat")?"generate":o.includes("refin")?"refine":o.includes("review")?"review":null}var fr="FREEMIUM_ATTEMPT_SPENT",pr="CLIENT_SECRET_MISMATCH",gr="FREEMIUM_COLUMN_CAP",yr="OAUTH_TOKEN_EXPIRED",hr="OAUTH_SIGNED_OUT";function Cr(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function br(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,o=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:o.licenseKey,licensee:o.licensee,secretKey:o.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function Er(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function Tr(e){let t=0;for(let n of e){if(n.isMeasure)continue;let o=n.distinctCount;typeof o=="number"&&o>t&&(t=o)}return t}function _e(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,o=(e.codeVersion??0)>0?e.codeVersion:null,l=n??o??t;return{version:l,fetchOnly:l!=null&&l>0?!0:void 0}}function Sr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,l=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion});return{genNew:o,version:l.version,fetchOnly:l.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function Rr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function xr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function wr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}var _r={fit:"Best fit",variety:"Something different"};function Oe(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function Or(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function vr(e,t){return e?ve(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 Pr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Pe(e){let t=String(e??"").trim().toLowerCase();return Pr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Pe(n.dataType)]);return t}function Lr(e){return j(Le(e))}var Ar=2,Mr=3,Ir=4,Nr=64,Fr=8e3,Dr=6e4,kr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Gr=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Vr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Ur(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 Wr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let l=`${n}|${o}`;return e.has(l)?!1:(e.add(l),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function qr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let l=`${e},${t}|${n}`;return o?`${l}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:l}function $r(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:o,transport:l,clock:u}=n,a=t.apiPath??"/api",i=t.timeoutMs,h=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>{try{t.onFailure?.(g)}catch{}},y=async(g,f,c,p)=>{let b;try{let T=await l.post(f,c,p,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){C({channel:g,stage:"post",status:null,error:T});return}(b<200||b>299)&&C({channel:g,stage:"status",status:b,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${h()}${a}/LogClientMsg/?nocache=${u.now()}`,c=I(g),p=D(c,o)}catch(b){C({channel:"client-message",stage:"build",status:null,error:b});return}await y("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,b;try{p=`${h()}${a}/eventlog`,b=se(g,t.clientVersion,f,c)}catch(T){C({channel:"event-count",stage:"build",status:null,error:T});return}await y("event-count",p,b,{"Content-Type":"text/plain"})}}}var Ae=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function zr(e){return typeof e=="number"&&e>0&&e<=Ae?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Ae} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Hr(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,o=t.credentials??"omit";return{async post(l,u,a,i){let h=i.timeoutMs,C=zr(h);if(C)throw C;let y=new AbortController,g=!1,f=setTimeout(()=>{g=!0,y.abort(Me(h))},h),c=()=>y.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,b=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(h):_,L;try{L=await n(l,{method:"POST",body:u,headers:a,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(L),A=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...A,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,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,Kr="/LLMChart/",Br="/LLMChart/qualify",jr="/VisionReview/",Yr="/LLMChart/sample",Qr="/RefundGenerate/",Xr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function Jr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Zr(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:o,transport:l,clock:u}=n,a=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,h=g=>t.nocache?t.nocache(g):String(u.now());async function C(g,f,c,p,b){let T=`${i()}${a}${f}?nocache=${h(g)}`,L={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,A=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Xr(_),cancelled:s,error:_}},x;try{x=await l.post(T,c,L,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return A(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)Jr(x);else try{w=(await x.text()).slice(0,Ie)}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 A(!0,w)}}function y(g,f){if(!f||typeof f.timeoutMs!="number"||!Number.isFinite(f.timeoutMs)||f.timeoutMs<=0)throw new TypeError(`The ${g} call needs a positive deadline in milliseconds`);return f}return{async generate(g,f){let c=y("generate",f),p=c.onStage??void 0;return C("generate",Kr,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??Br;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,H)},async review(g,f){let c=y("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return C("review",jr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Yr,I(g),c,H)},async refund(g,f){let c=y("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");return C("refund",Qr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,kr as CLIENT_EVENT_KINDS,pr as CLIENT_SECRET_MISMATCH,Be as COMPOUND_MIN_STEM,dt as CYCLE_MEMBERS,ft as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Jn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Tn as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,Gr as DRAW_REASONS,fr as FREEMIUM_ATTEMPT_SPENT,gr as FREEMIUM_COLUMN_CAP,nt as GET_RANDOM,Ye as GLUED_STEM_MIN,Xe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,gn as IDENTIFIER_HEAD_INITIAL,yn as IDENTIFIER_UNFOLDED,pn as IDENTIFIER_WORDS,Jt as INTENSIVE_SUFFIX_TOKENS,Xt as INTENSIVE_WORD_TOKENS,kn as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,Sn as MAX_RUN_BOUNDS,hr as OAUTH_SIGNED_OUT,yr as OAUTH_TOKEN_EXPIRED,Ct as PERIOD_CODE_FORMS,ht as PERIOD_CODE_MEMBERS,bt as PERIOD_ORDINALS,Et as PERIOD_UNFOLDED,en as POSITIONAL_SUFFIX_TOKENS,Zt as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,_r as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,wn as SERIES_COMPLETENESS_MAX_LISTED,_n as SERIES_COMPLETENESS_MIN_FILL,On as SERIES_KEY_MAX_DISTINCT,Ir as SEV_ERROR,Ar as SEV_INFO,Nr as SEV_USER_PRESENTED,Mr as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,Dr as TELEMETRY_TIMEOUT_DEV_MS,Fr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,cn as allowedAggregations,Cr as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,Rr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Fn as classifyAdditivity,Ur as classifyDraw,un as classifyForAggregation,Dn as classifyNumericValueNature,In as classifyTemporal,on as codeNeedsLegacyAggNames,Cn as codeReadsColumn,bn as codeReadsColumnsByRoleOrPosition,rn as collapseRepeatedAggPrefix,En as columnsTheCodeReads,Kt as countryRegion,Wr as createDrawLedger,Zr as createGenerateClient,$r as createTelemetryClient,br as credentialFields,er as dateLevelPart,tr as dateLevelYearAdmits,Gn as decimalSeparatorOf,dn as defaultAggregation,Vn as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Mn as detectTextDatePattern,Vr as drawLocation,I as encodePayload,Wn as engineTypeForSqlType,sn as englishImplicitAggNames,se as eventLogLine,Sr as fetchFields,Hr as fetchTransport,We as foldName,sr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,ir as guardColumnNames,Kn as gzipWireText,Je as hangulWordEndsWith,nn as hasDefaultAggPrefix,He as hasUnsegmentedScript,Nn as hostAggHint,$n as ingest,mn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,qr as isEventLogCode,Ft as isGeoPointAmbiguity,An as isIdentifierName,qt as isJoinGeoKind,jn as isNdjsonContentType,Ot as isOrdinalFriendlyName,wt as isUsableLooseKey,Bn as keyedSigner,wr as leafCardinalityField,ut as localMidnightDateColumns,lt as localMidnightToUtcDay,yt as localizedCycleIn,hn as localizedIdentifierWordIn,gt as localizedYearWordIn,N as looksLikeCountryColumn,Rt as looseNameKey,et as matchNameToken,Tr as maxNonMeasureCardinality,xn as measureCadence,Ln as measureSeriesCompleteness,D as messageSignature,or as missingHardColumnRefs,Qt as monthLookupFor,$e as nameLetterRuns,ln as nameLooksIntensiveRate,an as nameLooksPositional,he as nameProbeIsGuarded,rr as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Yt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,vr as offeredShortlistFor,qn as parseCsvRows,it as parseDateStable,ur as parseGenerateResponse,Un as parseNumberText,cr as parseQualifyResponse,dr as parseReviewVerdict,Rn as parseTemporalPoint,Hn as payloadPreview,St as periodCodeSeries,Pn as pickSeriesColumn,mr as progressStageOf,Or as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Xn as resolvePointRoles,xr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Lr as schemaIdentityKey,Pe as schemaTypeFamily,vn as seriesKeyVerdict,fn as shareOfTotalIsHonest,ve as shortlistIsStale,tn as stripHostAggPrefix,Bt as summarizeCountryRegions,zt as summarizeGeoExtent,ke as supportedLanguage,Wt as toGeoIso,Ke as unsegmentedRuns,Er as viewportFields,B as vocabularyLanguage,st as wholeDayFrame,at as wholeDayIso,X as wireResponseFromFetch,je as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,It as zipToPrefix3};
|
|
2
|
+
import{a as zn,b as Hn}from"./chunk-HIVICMC5.mjs";import{a as Kn,b as I,c as Bn,d as D,e as E,f as jn,g as X,h as J}from"./chunk-HMLAY26J.mjs";import{a as Gn,b as Vn,c as Un,d as Wn,e as qn,f as $n}from"./chunk-JBLITKS6.mjs";import{A as En,B as Tn,C as Sn,D as Rn,E as xn,F as wn,G as _n,H as On,I as vn,J as Pn,K as Ln,L as An,M as Mn,N as In,O as Nn,P as Fn,Q as Dn,S as kn,a as zt,b as Ht,c as Kt,d as Bt,e as Xt,f as Jt,g as Zt,h as en,i as tn,j as nn,k as rn,l as on,m as sn,n as an,o as ln,p as un,q as cn,r as dn,s as mn,t as fn,u as pn,v as gn,w as yn,x as hn,y as Cn,z as bn}from"./chunk-HRIMAMPX.mjs";import{a as jt}from"./chunk-U3H6UBOO.mjs";import{a as Yt,b as Qt}from"./chunk-555PKUBU.mjs";import{a as le,b as ue,c as Ut,d as Wt,e as qt,f as $t}from"./chunk-KQOVPOVU.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Lt,m as At,n as ae,o as v,p as Mt,q as It,r as Nt,s as q,t as Ft,u as Dt,v as kt,w as Gt,x as Q,y as Vt}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as dt,b as mt,c as ft,d as pt,e as gt,f as yt,g as ht,h as Ct,i as bt,j as Et,k as Tt,l as St,m as Ot,n as vt,o as Pt}from"./chunk-GKXYRUK5.mjs";import{A as ot,B as it,C as st,D as at,E as lt,F as ut,G as ct,a as Fe,b as De,c as ke,d as Ge,e as Ve,f as B,g as Ue,h as We,i as qe,j as $e,k as ze,l as He,m as Ke,n as Be,o as je,p as Ye,q as Qe,r as Xe,s as Je,t as Ze,u as et,v as tt,x as j,y as nt,z as rt}from"./chunk-4VN252CK.mjs";import{b as Rt,c as xt,d as wt,e as _t}from"./chunk-5HI6TVMM.mjs";var Z=2,me=400;function te(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let o=U(String(n));if(!V(o)&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||ne(e)<95)return!1;let n=t.filter(l=>te(l)&&!v(l)).length,o=t.filter(l=>!te(l)&&!!v(l)).length;return n>=1&&n>=o}function ce(e,t){if(!v(e))return!1;let n=W(e);return n?t==="world"?!0:ae.has(n):!1}function ne(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)te(o)&&n++;return Math.round(n/t.length*1e3)/10}function $(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let o of t)v(o)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){let t=new Set;for(let n of e){if(n==null)continue;let o=String(n).trim();if(!V(U(o))&&!t.has(o)&&(t.add(o),t.size>=me))break}return Array.from(t)}function re(e){let t=oe(e);if(t.length===0)return 0;let n=0;for(let o of t)q(o).length>0&&n++;return Math.round(n/t.length*1e3)/10}function de(e,t){return ue(t,le)?!0:oe(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yn(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let l of n)Q(l,t)&&o++;return Math.round(o/n.length*1e3)/10}function ee(e,t){let n=0;for(let o of F(e))t(o)&&n++;return n}function Qn(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function Xn(e,t,n,o,l){let u=[],a=[],i={},h={},C=new Set(e),y=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&C.has(d)&&(i[s]=d)}let g=new Set(l??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&C.has(f)){let s=y(f),d=re(s);d<95?a.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:a.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&C.has(c)){let s=y(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?a.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(a.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?a.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=y(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Ne=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Ne<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,p.add(s.name),u.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(p.has(s))continue;let d=y(s),S=re(d);if(!(S<95)&&de(d,s)&&!(Qn(d,O=>q(O).length>0)<Z)){i.zip=s,p.add(s),u.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(y(T))){let s=null;for(let d of b){if(p.has(d)||!N(y(d)))continue;let S=ne(y(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(a.push(`country=${T} (only ${ne(y(T))}% of values are country identifiers; using ${s.name} instead)`),h.country=T),i.country=s.name,p.add(s.name),u.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(p.has(d))continue;let S=y(d),O=Yn(S,o);O<Y||ee(S,K=>Q(K,o))<Z||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,u.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?y(i.country):[],R=!!i.country&&N(L),A=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&A>=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&&a.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&a.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:u,refused:a,...Object.keys(h).length?{labelFallback:h}:{}}}var r=(e,...t)=>({part:e,langs:Object.freeze(t)}),ie=Object.freeze({jaar:r("year","nl"),kwartaal:r("quarter","nl"),maand:r("month","nl"),dag:r("day","nl","sv","da","nb"),jahr:r("year","de"),quartal:r("quarter","de"),monat:r("month","de"),tag:r("day","de"),ann\u00E9e:r("year","fr"),mois:r("month","fr"),jour:r("day","fr"),trimestre:r("quarter","fr","es","pt","it"),a\u00F1o:r("year","es"),mes:r("month","es"),d\u00EDa:r("day","es"),ano:r("year","pt"),m\u00EAs:r("month","pt"),dia:r("day","pt"),anno:r("year","it"),mese:r("month","it"),giorno:r("day","it"),\u0433\u043E\u0434:r("year","ru"),\u043C\u0435\u0441\u044F\u0446:r("month","ru"),\u0440\u0456\u043A:r("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:r("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:r("quarter","ru","uk"),\u0434\u0435\u043D\u044C:r("day","ru","uk"),rok:r("year","pl","cs","sk"),kwarta\u0142:r("quarter","pl"),miesi\u0105c:r("month","pl"),dzie\u0144:r("day","pl"),\u010Dtvrtlet\u00ED:r("quarter","cs"),m\u011Bs\u00EDc:r("month","cs"),den:r("day","cs"),\u0161tvr\u0165rok:r("quarter","sk"),mesiac:r("month","sk"),de\u0148:r("day","sk"),\u00E5r:r("year","sv","da","nb"),kvartal:r("quarter","sv","da","nb"),m\u00E5nad:r("month","sv"),m\u00E5ned:r("month","da","nb"),vuosi:r("year","fi"),vuosinelj\u00E4nnes:r("quarter","fi"),kuukausi:r("month","fi"),p\u00E4iv\u00E4:r("day","fi"),\u00E9v:r("year","hu"),negyed\u00E9v:r("quarter","hu"),h\u00F3nap:r("month","hu"),nap:r("day","hu"),y\u0131l:r("year","tr"),\u00E7eyrek:r("quarter","tr"),ay:r("month","tr"),g\u00FCn:r("day","tr"),\u03AD\u03C4\u03BF\u03C2:r("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:r("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:r("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:r("day","el"),an:r("year","ro"),trimestru:r("quarter","ro"),lun\u0103:r("month","ro"),zi:r("day","ro"),godina:r("year","hr"),tromjese\u010Dje:r("quarter","hr"),mjesec:r("month","hr"),dan:r("day","hr"),\u5E74:r("year","ja","zh"),\u56DB\u534A\u671F:r("quarter","ja"),\u5B63\u5EA6:r("quarter","zh"),\u6708:r("month","ja","zh"),\u65E5:r("day","ja","zh"),\uC5F0\uB3C4:r("year","ko"),\uBD84\uAE30:r("quarter","ko"),\uC6D4:r("month","ko"),\uC77C:r("day","ko"),tahun:r("year","id"),kuartal:r("quarter","id"),triwulan:r("quarter","id"),bulan:r("month","id"),hari:r("day","id"),n\u0103m:r("year","vi"),qu\u00FD:r("quarter","vi"),th\u00E1ng:r("month","vi"),ng\u00E0y:r("day","vi"),\u0E1B\u0E35:r("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:r("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:r("month","th"),\u0E27\u0E31\u0E19:r("day","th"),\u0627\u0644\u0633\u0646\u0629:r("year","ar"),\u0633\u0646\u0629:r("year","ar"),\u0627\u0644\u0639\u0627\u0645:r("year","ar"),\u0639\u0627\u0645:r("year","ar"),\u0627\u0644\u0631\u0628\u0639:r("quarter","ar"),\u0631\u0628\u0639:r("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":r("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:r("month","ar"),\u0634\u0647\u0631:r("month","ar"),\u0627\u0644\u064A\u0648\u0645:r("day","ar"),\u064A\u0648\u0645:r("day","ar"),\u05E9\u05E0\u05D4:r("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:r("quarter","he"),\u05D7\u05D5\u05D3\u05E9:r("month","he"),\u05D9\u05D5\u05DD:r("day","he"),\u0935\u0930\u094D\u0937:r("year","hi"),\u0938\u093E\u0932:r("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:r("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:r("month","hi"),\u092E\u093E\u0939:r("month","hi"),\u0926\u093F\u0928:r("day","hi"),\u0633\u0627\u0644:r("year","fa"),\u0645\u0627\u0647:r("month","fa"),\u0631\u0648\u0632:r("day","fa")}),Jn=Object.freeze(Array.from(new Set(Object.values(ie).flatMap(e=>e.langs)))),fe=Object.freeze(["fa","ar","he","th"]),pe=1900,ge=2100;function Zn(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let l=e.toLowerCase();return n.includes(l)||n.push(l),n}function er(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of Zn(n,t)){let l=ie[o];if(l&&l.langs.includes(t))return l.part}return null}function tr(e,t){return fe.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=pe&&t<=ge:!0}function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),l=o.lastIndexOf(";");return l>=0&&(o=o.slice(l+1)),nr.test(o)}function he(e,t){return Ce(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Ce(e,t,n){let o=ye(t),l=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${o}\2`,"g"),u=new RegExp(String.raw`\.name\s*===?\s*(['"])${o}\1`,"g"),a=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&a++;let h=0;for(;(i=l.exec(e))!==null;){let C=i.index+i[0].lastIndexOf(".name");if(!z(e,C))continue;h++;let y=ye(i[1]);if(!n(y))return!1}return h>0&&h===a}function rr(e,t){return Ce(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 be=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function or(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,l=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=l.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let a=[];return o.forEach(i=>{n.has(i)||he(e,i)||a.push(i)}),a}function ir(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(o=>o.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let o of e.aliasesForCode(t))n.push(o.alias);return n}function Ee(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 sr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let l=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>l?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let a=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?a:a+" "+i.join(" ")}function Te(e){if(!e||e.length===0)return[];let t=[],n=new Map,o=new Map;for(let u of e){let a=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(a!==""&&(n.has(a)||(t.push(a),n.set(a,0)),u.isDatePart===!0&&n.set(a,n.get(a)+1),u.isReassembledDate===!0&&!o.has(a))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",h=typeof u.name=="string"?u.name.trim():"",C=i!==""?i:h;C!==""&&o.set(a,C)}}let l=[];for(let u of t){let a=o.get(u),i=n.get(u)??0;!a||i===0||l.push(`'${a}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return l}var m=e=>e==null?"":String(e),P=e=>e===!0,Se=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},ar=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,l]of ar){let u=m(E(e,t+l));u&&(n[o]=u)}return n}function lr(e){return Array.isArray(e)?e.map(t=>({code:m(E(t,"code")),severity:m(E(t,"severity")),text:m(E(t,"text"))})).filter(t=>t.text!==""):[]}function ur(e){let t=C=>E(e,C),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),l=t("forceThumbnailUpload"),u=Re(e,"point"),a=Re(e,"destPoint");Object.keys(a).length&&(u.dest=a);let i=t("retryable"),h=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:lr(t("notices")),freemiumStatusCode:m(t("freemiumStatusCode")),code:m(t("code")),language:m(t("language")),version:Number(t("version")??0),codeSummary:m(t("codeSummary")),chartName:m(t("chartName")??t("chartType")),finalChartName:m(t("finalChartName")),warningMessage:m(t("warningMessage")),outputHash:m(t("outputHash")),validatorToken:m(t("validatorToken")),editCodeKey:m(t("editCodeKey")),signedLLMRequestID:m(t("signedLLMRequestID")),userReply:m(t("userReply")),userReplyOutcome:m(t("userReplyOutcome")),improvementSuggestion:m(t("improvementSuggestion")),geoColumn:m(t("geoColumn")),geoKind:m(t("geoKind")),geoPointCols:Object.keys(u).length?u:null,creditBalanceBefore:Se(t("creditBalanceBefore")),creditCost:Se(t("creditCost")),isServiceError:P(t("isServiceError")),isRateLimited:P(t("isRateLimited")),isRefusal:P(t("isRefusal")),isVersionNotFound:P(t("isVersionNotFound")),isGenerationCancelled:P(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:m(t("servedCorrelationId")),...typeof h=="boolean"?{isPollFinal:h}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof l=="boolean"?{forceThumbnailUpload:l}:{}}}var xe=e=>e==null?void 0:Number(e),k=e=>m(e)||void 0;function cr(e){let t=E(e,"charts"),n=E(e,"refused"),o=Array.isArray(t)?t.map(u=>{let a=h=>E(u,h),i=a("recommended");return{name:m(a("chartTypeName")??a("name")),description:m(a("description")??a("chartDesc")),rank:xe(a("rank")),score:xe(a("score")),renderer:k(a("renderer")),language:k(a("language")),isPreview:P(a("isPreview")),alsoWorthALook:P(a("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(a("viaProjection")),viaProjectionKey:k(a("viaProjectionKey")),detailNote:k(a("detailNote"))}}).filter(u=>u.name):null,l=Array.isArray(n)?n.map(u=>({name:m(E(u,"chartTypeName")??E(u,"name")),reason:m(E(u,"reason")),reasonCode:m(E(u,"reasonCode")),isVeto:P(E(u,"isVeto"))})).filter(u=>u.name):[];return{errorMessage:m(E(e,"errorMessage")),errorCode:m(E(e,"errorCode")),charts:o,refused:l,noFitSummary:m(E(e,"noFitSummary"))}}function dr(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 we=["working","analyze","generate","refine","review"];function mr(e,t){let n=String(e??"").trim().toLowerCase();if(we.includes(n))return n;let o=String(t??"").toLowerCase();return o.includes("analyz")?"analyze":o.includes("generat")?"generate":o.includes("refin")?"refine":o.includes("review")?"review":null}var fr="FREEMIUM_ATTEMPT_SPENT",pr="CLIENT_SECRET_MISMATCH",gr="FREEMIUM_COLUMN_CAP",yr="OAUTH_TOKEN_EXPIRED",hr="OAUTH_SIGNED_OUT";function Cr(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function br(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,o=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:o.licenseKey,licensee:o.licensee,secretKey:o.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function Er(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function Tr(e){let t=0;for(let n of e){if(n.isMeasure)continue;let o=n.distinctCount;typeof o=="number"&&o>t&&(t=o)}return t}function _e(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,o=(e.codeVersion??0)>0?e.codeVersion:null,l=n??o??t;return{version:l,fetchOnly:l!=null&&l>0?!0:void 0}}function Sr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,l=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion});return{genNew:o,version:l.version,fetchOnly:l.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0}}function Rr(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function xr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function wr(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}var _r={fit:"Best fit",variety:"Something different"};function Oe(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function Or(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function ve(e,t){return e!=null&&t!=null&&e!==t}function vr(e,t){return e?ve(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 Pr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Pe(e){let t=String(e??"").trim().toLowerCase();return Pr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Pe(n.dataType)]);return t}function Lr(e){return j(Le(e))}var Ar=2,Mr=3,Ir=4,Nr=64,Fr=8e3,Dr=6e4,kr=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),Gr=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Vr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Ur(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 Wr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let l=`${n}|${o}`;return e.has(l)?!1:(e.add(l),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function qr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let l=`${e},${t}|${n}`;return o?`${l}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:l}function $r(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:o,transport:l,clock:u}=n,a=t.apiPath??"/api",i=t.timeoutMs,h=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>{try{t.onFailure?.(g)}catch{}},y=async(g,f,c,p)=>{let b;try{let T=await l.post(f,c,p,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){C({channel:g,stage:"post",status:null,error:T});return}(b<200||b>299)&&C({channel:g,stage:"status",status:b,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${h()}${a}/LogClientMsg/?nocache=${u.now()}`,c=I(g),p=D(c,o)}catch(b){C({channel:"client-message",stage:"build",status:null,error:b});return}await y("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,b;try{p=`${h()}${a}/eventlog`,b=se(g,t.clientVersion,f,c)}catch(T){C({channel:"event-count",stage:"build",status:null,error:T});return}await y("event-count",p,b,{"Content-Type":"text/plain"})}}}var Ae=2**31-1;function Me(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function zr(e){return typeof e=="number"&&e>0&&e<=Ae?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${Ae} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Hr(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,o=t.credentials??"omit";return{async post(l,u,a,i){let h=i.timeoutMs,C=zr(h);if(C)throw C;let y=new AbortController,g=!1,f=setTimeout(()=>{g=!0,y.abort(Me(h))},h),c=()=>y.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,b=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(h):_,L;try{L=await n(l,{method:"POST",body:u,headers:a,credentials:o,signal:y.signal})}catch(_){throw b(),T(_)}let R=X(L),A=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...A,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,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300,Kr="/LLMChart/",Br="/LLMChart/qualify",jr="/VisionReview/",Yr="/LLMChart/sample",Qr="/RefundGenerate/",Xr=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function Jr(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Zr(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:o,transport:l,clock:u}=n,a=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,h=g=>t.nocache?t.nocache(g):String(u.now());async function C(g,f,c,p,b){let T=`${i()}${a}${f}?nocache=${h(g)}`,L={"Content-Type":"text/plain","X-Signature":D(c,o)},R=p.signal??void 0,A=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Xr(_),cancelled:s,error:_}},x;try{x=await l.post(T,c,L,R?{timeoutMs:p.timeoutMs,signal:R}:{timeoutMs:p.timeoutMs})}catch(w){return A(!1,w)}if(x.status<200||x.status>299){let w="";if(p.readErrorBody===!1)Jr(x);else try{w=(await x.text()).slice(0,Ie)}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 A(!0,w)}}function y(g,f){if(!f||typeof f.timeoutMs!="number"||!Number.isFinite(f.timeoutMs)||f.timeoutMs<=0)throw new TypeError(`The ${g} call needs a positive deadline in milliseconds`);return f}return{async generate(g,f){let c=y("generate",f),p=c.onStage??void 0;return C("generate",Kr,I(g),c,b=>J(b,p))},async qualify(g,f){let c=y("qualify",f),p=c.route??Br;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return C("qualify",p,I(g),c,H)},async review(g,f){let c=y("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return C("review",jr,p,c,H)},async sample(g,f){let c=y("sample",f);return C("sample",Yr,I(g),c,H)},async refund(g,f){let c=y("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");return C("refund",Qr,JSON.stringify({CorrelationID:g.trim()}),c,H)}}}export{Y as CITY_ROLE_MATCH_PCT,kr as CLIENT_EVENT_KINDS,pr as CLIENT_SECRET_MISMATCH,Be as COMPOUND_MIN_STEM,dt as CYCLE_MEMBERS,ft as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,Jn as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Tn as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,Gr as DRAW_REASONS,fr as FREEMIUM_ATTEMPT_SPENT,gr as FREEMIUM_COLUMN_CAP,nt as GET_RANDOM,Ye as GLUED_STEM_MIN,Xe as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,gn as IDENTIFIER_HEAD_INITIAL,yn as IDENTIFIER_UNFOLDED,pn as IDENTIFIER_WORDS,Jt as INTENSIVE_SUFFIX_TOKENS,Xt as INTENSIVE_WORD_TOKENS,kn as IndexedText,xt as LOOSE_KEY_MIN_LENGTH,_t as LooseIndex,Sn as MAX_RUN_BOUNDS,hr as OAUTH_SIGNED_OUT,yr as OAUTH_TOKEN_EXPIRED,Ct as PERIOD_CODE_FORMS,ht as PERIOD_CODE_MEMBERS,bt as PERIOD_ORDINALS,Et as PERIOD_UNFOLDED,en as POSITIONAL_SUFFIX_TOKENS,Zt as POSITIONAL_WORD_TOKENS,zn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,_r as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,wn as SERIES_COMPLETENESS_MAX_LISTED,_n as SERIES_COMPLETENESS_MIN_FILL,On as SERIES_KEY_MAX_DISTINCT,Ir as SEV_ERROR,Ar as SEV_INFO,Nr as SEV_USER_PRESENTED,Mr as SEV_WARNING,j as SIMPLE_STRING_HASH,tt as STR,Ze as SUBSTRING_MIN,Fe as SUPPORTED_LANGUAGES,De as SUPPORTED_LANGUAGE_CODES,Dr as TELEMETRY_TIMEOUT_DEV_MS,Fr as TELEMETRY_TIMEOUT_MS,Ve as VOCABULARY_LANGUAGE_CODES,Ge as VOCABULARY_ONLY_LANGUAGES,mt as YEAR_WORDS,$ as admin1MatchPct,cn as allowedAggregations,Cr as answerIsRetryable,$t as buildGeoIsoColumn,kt as buildGeoPointColumns,pt as calendarWordIn,Rr as capabilityFields,Vt as cityMatchPct,Gt as cityTagsFor,Fn as classifyAdditivity,Ur as classifyDraw,un as classifyForAggregation,Dn as classifyNumericValueNature,In as classifyTemporal,on as codeNeedsLegacyAggNames,Cn as codeReadsColumn,bn as codeReadsColumnsByRoleOrPosition,rn as collapseRepeatedAggPrefix,En as columnsTheCodeReads,Kt as countryRegion,Wr as createDrawLedger,Zr as createGenerateClient,$r as createTelemetryClient,br as credentialFields,er as dateLevelPart,tr as dateLevelYearAdmits,Gn as decimalSeparatorOf,dn as defaultAggregation,Vn as detectDecimalSeparator,jt as detectFormatSignature,Ut as detectGeo,Pt as detectOrdinalDomain,Mn as detectTextDatePattern,Vr as drawLocation,I as encodePayload,Wn as engineTypeForSqlType,sn as englishImplicitAggNames,se as eventLogLine,Sr as fetchFields,Hr as fetchTransport,We as foldName,sr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Qe as gluedPrefixStems,ir as guardColumnNames,Kn as gzipWireText,Je as hangulWordEndsWith,nn as hasDefaultAggPrefix,He as hasUnsegmentedScript,Nn as hostAggHint,$n as ingest,mn as isAggregationAllowed,V as isBlankLike,At as isCityTableLoaded,z as isColumnContextRef,rt as isDeterministicRefusal,qr as isEventLogCode,Ft as isGeoPointAmbiguity,An as isIdentifierName,qt as isJoinGeoKind,jn as isNdjsonContentType,Ot as isOrdinalFriendlyName,wt as isUsableLooseKey,Bn as keyedSigner,wr as leafCardinalityField,ut as localMidnightDateColumns,lt as localMidnightToUtcDay,yt as localizedCycleIn,hn as localizedIdentifierWordIn,gt as localizedYearWordIn,N as looksLikeCountryColumn,Rt as looseNameKey,et as matchNameToken,Tr as maxNonMeasureCardinality,xn as measureCadence,Ln as measureSeriesCompleteness,D as messageSignature,or as missingHardColumnRefs,Qt as monthLookupFor,$e as nameLetterRuns,ln as nameLooksIntensiveRate,an as nameLooksPositional,he as nameProbeIsGuarded,rr as nameProbeKeepsDrawing,qe as nameWords,Mt as normalizeCountry,ct as normalizeLocalMidnightDates,Yt as normalizeMonthKey,U as normalizePlaceName,Nt as normalizeZip5,vr as offeredShortlistFor,qn as parseCsvRows,it as parseDateStable,ur as parseGenerateResponse,Un as parseNumberText,cr as parseQualifyResponse,dr as parseReviewVerdict,Rn as parseTemporalPoint,Hn as payloadPreview,St as periodCodeSeries,Pn as pickSeriesColumn,mr as progressStageOf,Or as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,ze as readName,Tt as readPeriodCode,E as readWireField,Lt as registerCityTable,Ht as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,Dt as resolveGeoPoint,Ue as resolveLanguage,Xn as resolvePointRoles,xr as retryFields,vt as safeDistinctValuesToShip,Le as schemaIdentity,Lr as schemaIdentityKey,Pe as schemaTypeFamily,vn as seriesKeyVerdict,fn as shareOfTotalIsHonest,ve as shortlistIsStale,tn as stripHostAggPrefix,Bt as summarizeCountryRegions,zt as summarizeGeoExtent,ke as supportedLanguage,Wt as toGeoIso,Ke as unsegmentedRuns,Er as viewportFields,B as vocabularyLanguage,st as wholeDayFrame,at as wholeDayIso,X as wireResponseFromFetch,je as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,It 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{L as a,M as b,N as c,O as d,P as e,Q as f,R as g,S as h}from"./chunk-
|
|
2
|
+
import{L as a,M as b,N as c,O as d,P as e,Q as f,R as g,S as h}from"./chunk-HRIMAMPX.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-555PKUBU.mjs";import"./chunk-KQOVPOVU.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-GKXYRUK5.mjs";import"./chunk-4VN252CK.mjs";import"./chunk-5HI6TVMM.mjs";export{h as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g 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{d as a,e as b,f as c}from"./chunk-
|
|
2
|
+
import{d as a,e as b,f as c}from"./chunk-JBLITKS6.mjs";import"./chunk-HRIMAMPX.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-555PKUBU.mjs";import"./chunk-KQOVPOVU.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-GKXYRUK5.mjs";import"./chunk-4VN252CK.mjs";import"./chunk-5HI6TVMM.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.78",
|
|
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-OPDY2YEA.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 ae}from"./chunk-U3H6UBOO.mjs";import{a as ue,b as le}from"./chunk-555PKUBU.mjs";import{c as Ge}from"./chunk-KQOVPOVU.mjs";import{f as ke,k as Fe}from"./chunk-INMDBTAR.mjs";import{e as De,k as se,m as Oe,n as Pe,o as oe}from"./chunk-GKXYRUK5.mjs";import{B as pe,D as Le,f as ge,h as re,i as j,j as Me,k as ie,n as xe,o as Re,q as Te,s as Ne,t as Ee,v as Ie,w as H,x as ve,y as we}from"./chunk-4VN252CK.mjs";var ht=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],bt=[7,72,-172,-52];function We(t,e,n){return t>=n[0]&&t<=n[1]&&e>=n[2]&&e<=n[3]}var X=t=>Math.round(t*10)/10;function Be(t,e=3){let n=[],i=[],r=0,o=0;for(let l of t){let u=l?.lat,c=l?.lon;if(typeof u!="number"||typeof c!="number"||!isFinite(u)||!isFinite(c)||u<-90||u>90||c<-180||c>180)continue;n.push(u),i.push(c);let d=l?.country?String(l.country).trim().toUpperCase():"",f=d?ce(d):null;f?((d==="US"||d==="USA")&&r++,f==="north-america"&&o++):(ht.some(m=>We(u,c,m))&&r++,We(u,c,bt)&&o++)}let s=n.length;return s<e?null:(n.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:X(r/s*100),pctNa:X(o/s*100),latP5:X(H(n,.05)),latP95:X(H(n,.95)),lonP5:X(H(i,.05)),lonP95:X(H(i,.95)),n:s})}var ze={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},J=(()=>{let t=new Map;for(let e of Object.keys(ze))for(let n of ze[e].split(/\s+/))n&&t.set(n,e);return t})();function yt(t){for(let[e,n]of t){let i=J.get(e);i&&!J.has(n)&&J.set(n,i)}}yt(ke);function ce(t){if(!t)return null;let e=String(t).trim().toUpperCase();if(!e)return null;let n=J.get(e);if(n)return n;let i=Fe(String(t));return i?J.get(i)??null:null}function Hn(t,e=2){return he(t.map(n=>[n,1]),e)}function he(t,e=2){let n=new Map,i=0;for(let[s,l]of t){let u=ce(s);if(!u)continue;let c=typeof l=="number"&&isFinite(l)&&l>0?l:1;n.set(u,(n.get(u)??0)+c),i+=c}if(i<e||!n.size)return null;let r="europe",o=-1;for(let s of Array.from(n.keys()).sort()){let l=n.get(s);l>o&&(r=s,o=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:X(o/i*100),regionCount:n.size,n:i}}import mt from"papaparse";var St=["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","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"],_t=["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"],At=["latitude","longitude"],Ct=["latitude","longitude"];function Z(t){return re(t)}var be=["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"],Ue=["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"];function Mt(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var $e=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Mt(be)+")\\s+)","i"),xt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Rt=new RegExp("\\b("+St.join("|")+")\\b|("+_t.join("|")+")$","i"),Tt=new RegExp("\\b("+At.join("|")+")\\b|("+Ct.join("|")+")$","i");function me(t){if(!t)return"";let e=String(t),n=$e.exec(Z(e));return(n?e.slice(n[0].length):e).trim()}function Nt(t){return!!t&&$e.test(Z(String(t)))}var Et=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Ve=new RegExp("^\\s*("+[...Et].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ke(t){if(t==null)return"";let e=String(t),n=Ve.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),o=e.slice(n[0].length),s=0;for(;s<8;){let l=Ve.exec(o);if(!l||i(l[1])!==r)break;let u=o.slice(l[0].length);if(u.trim()==="")break;o=u,s++}return s===0?e:e.slice(0,n[0].length)+o}function ye(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 He={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 "]},It=new RegExp("^("+Object.keys(He).join("|")+")\\((.+)\\)$");function Ye(t){if(!t)return[];let e=It.exec(String(t).trim());if(!e)return[];let n=He[e[1]],i=e[2],r=[];for(let o=i.indexOf(".");o>=0;o=i.indexOf(".",o+1)){if(o===0)continue;let s=i.slice(o+1);if(s.trim()!=="")for(let l of n){let u=l+s;r.includes(u)||r.push(u)}}return r}function vt(t){let e=me(t);return e.length===0?"":e.replace(xt," ")}function je(t,e){if(!e)return!1;let n=me(e);return t.test(Z(vt(e)))||t.test(Z(n))||t.test(Z(j(n).join(" ")))}function Xe(t){return je(Tt,t)}function wt(t){return je(Rt,t)||Xe(t)}var Ze=/int|double|decimal|single|float|number|currency|money/i;function Lt(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Ze.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Dt(t){return t?.isMeasure===!0||Ze.test(String(t?.dataType??""))}function qe(t){let e=t??{},n=Lt(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Xe(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Nt(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}:wt(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Qe(t){let e=qe(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Dt(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 Zn(t){return Qe(t)[0]}function qn(t,e){return Qe(t).indexOf(e)>=0}function Qn(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=qe(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var Ot={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"]},Pt=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],kt=["num\xE9ro"],Ft=t=>t.normalize("NFC").toLowerCase();function Gt(t,e,n,i){let r=ge(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<Ee?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?Te(t,n).includes(e)?"word":null:r.script==="Hang"?Ne(t,e)?"suffix":null:r.compounds&&Re(t,e,xe)?"suffix":null}function Je(t){let e=String(t??"").trim();if(!e)return null;let n=ie(e),i=ie(me(e));for(let[r,o]of Object.entries(Ot)){let s=Pt.includes(r),l=s?i:n;for(let u of o){let c=kt.includes(u)||!!ge(r)?.foldSensitive,d=c?l.words:l.folded;if(d.length===0)continue;let f=c?Ft(u):ie(u).folded.join(" "),m=Gt(s?d[0]:d[d.length-1],f,r,s);if(m)return{lang:r,word:u,view:m}}}return null}var Wt=[["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 de(t){for(let[e,n]of Wt)if(n.test(t))return e;return null}var zt=[{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]]}],fe=new Map;function et(t,e,n,i){let r=fe.get(t);if(r)return r;let o=[];for(let[s,l]of e)for(let u=s;u<=l;u++){let c=String.fromCodePoint(u);de(c)===n&&(i&&!i.test(c)||o.push(c))}return fe.set(t,o),o}function Bt(t){let n=t.codePointAt(0);for(let s=0;s<9&&de(String.fromCodePoint(n-1))==="Nd";s++)n--;let i="nd:"+n.toString(16),r=fe.get(i);if(r)return r;let o=[];for(let s=n;s<n+10;s++){let l=String.fromCodePoint(s);de(l)==="Nd"&&o.push(l)}return fe.set(i,o),o}function Vt(t,e){if(e==="Nd")return Bt(t);for(let r of zt)if(r.test.test(t))return et(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return et("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function Ut(t,e,n,i){let r=t.filter(o=>!e.has(o));return r.length===0&&(r=t.filter(o=>o!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var $t=/^[\p{L}\p{M}\p{Nd}]$/u,tt=/^[\p{L}\p{Nd}]$/u;function nt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=d=>{let f=de(d);return!f||!$t.test(d)?d:Ut(Vt(d,f),n,d,e)},r=d=>{let f=[];for(let m of d)f.push(i(m)),tt.test(m)&&e()<.2&&f.push(i(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let R=0;R<m;R++)for(let A=0;A<5;A++){let O=Math.floor(e()*f.length);if(tt.test(f[O])){f.splice(O,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[s,l=""]=t.split("@"),u=l.endsWith(".com"),c=u?l.slice(0,-4):l;return`${r(s)}@${r(c)}${u?".com":""}`}var Kt=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Ht=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Yt=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 ee(t,e){if(!t||!e)return!1;let n=Ht(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:Kt.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function jt(t){return!!t&&Yt.test(t)}function sr(t,e,n){return t?jt(t)?[...e]:[...n,...e].some(i=>ee(t,i))?e.filter(i=>ee(t,i)):[...e]:[]}var Xt=5,Zt=6,qt=3,q=864e5,Qt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Jt=/^(\d{4})[-/](\d{1,2})$/,en=/^(\d{4})[-\s]?Q([1-4])$/i,tn=/^Q([1-4])[-\s](\d{4})$/i,nn=/^(\d{4})$/,rn=/^(\d{4})(0[1-9]|1[0-2])$/,sn=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,on=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,an=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function rt(t,e){let n=ue(t);if(!n)return 0;if(n==="sept")return 9;for(let i of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let r=le(i)[n];if(r!==void 0)return r+1}return 0}function un(t){let e=se(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:$(n.year,(n.n-1)*3+1,1)}function $(t,e,n,i=0,r=0,o=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let s=Date.UTC(t,e-1,n,i,r,o);if(!Number.isFinite(s))return null;let l=u=>u<10?"0"+u:String(u);return{ms:s,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function ln(t,e){let n=[],i="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){i+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){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 o=0,s=1,l=1;return n.forEach((u,c)=>{let d=+r[c+1];u==="Y"?o=d:u==="m"?s=d:l=d}),o?$(o,s,l):null}function Se(t,e,n){let i=(t??"").trim();if(i==="")return null;if(e){let s=ln(i,e);return s||null}let r=Qt.exec(i);if(r)return $(+r[1],+r[2],+r[3],+(r[4]??0),+(r[5]??0),+(r[6]??0));if(r=en.exec(i),r)return $(+r[1],(+r[2]-1)*3+1,1);if(r=tn.exec(i),r)return $(+r[2],(+r[1]-1)*3+1,1);if(r=Jt.exec(i),r&&+r[2]>=1&&+r[2]<=12)return $(+r[1],+r[2],1);if(r=sn.exec(i),r)return $(+r[1],+r[2],+r[3]);if(r=rn.exec(i),r)return $(+r[1],+r[2],1);if(r=nn.exec(i),r){let s=+r[1];return s>=1900&&s<=2100?$(s,1,1):null}let o=un(i);if(o)return o;if(r=on.exec(i),r){let s=rt(r[1],n);return s?$(+r[2],s,1):null}if(r=an.exec(i),r){let s=rt(r[2],n);return s?$(+r[1],s,1):null}return null}function it(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function st(t,e){if(e<=t)return 0;let n=Math.round((e-t)/q),i=Math.floor(n/7),r=i*5,o=t+i*7*q;for(;o<e;)it(o)&&r++,o+=q;return r}function cn(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 mn(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 te(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*q));case"weekday":return st(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/q);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function ot(t,e){return _e(t,e)?.cadence??null}function _e(t,e){let n=e?.gapFactor??Xt,i=0,r=0,o=new Map;for(let h of t){if(h==null||h==="")continue;i++;let W=Se(String(h),e?.pattern,e?.locale);W&&(r++,o.set(W.ms,W))}let s=[...o.values()].sort((h,W)=>h.ms-W.ms);if(s.length<qt||i>0&&r/i<.8)return null;let l=s[s.length-1].ms-s[0].ms;if(l<=0)return null;let u=[];for(let h=1;h<s.length;h++)u.push(s[h].ms-s[h-1].ms);let c=cn(u);if(!(c>0))return null;let d=mn(c/q);d==="day"&&l>=7*q&&s.every(h=>it(h.ms))&&st(s[0].ms,s[s.length-1].ms)+1>s.length*.5&&(d="weekday");let f=d==="irregular"?s.length:te(s[0],s[s.length-1],d,c)+1,m=1,R=1,A=[],O=s[0],S=1;for(let h=1;h<s.length;h++){let W=te(s[h-1],s[h],d,c);W>m&&(m=W),d!=="irregular"&&W>n?(R++,A.push({from:O.iso,to:s[h-1].iso,points:S}),O=s[h],S=1):S++}A.push({from:O.iso,to:s[s.length-1].iso,points:S});let w={grain:d,points:s.length,expectedPoints:Math.max(f,s.length),coveragePct:Math.round(s.length/Math.max(f,s.length)*1e3)/10,runs:R,largestGapUnits:m,gapFactor:n};return e?.includeBounds&&A.length<=Zt&&(w.runBounds=A),{cadence:w,points:s,stepMs:c}}var dn=8,fn=.5,gn=200,pn=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"]),hn=["category","classification","segment","status","priority","severity","channel"],bn=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function yn(t){let e=j(t);if(e.length===0)return!1;let n=e[e.length-1];return pn.has(n)?!0:hn.some(i=>n.length>i.length&&n.endsWith(i))}function Sn(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>gn?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":oe(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&bn.has(ae(e))?"identifier":!t.geoKind&&yn(t.name)?"attribute":"entity"}function lt(t){let e=-1,n=1/0,i=!1;return t.forEach((r,o)=>{if(Sn(r)!=="entity")return;let s=new Set(Array.from(r.values).filter(u=>u!=="")).size,l=!!r.geoKind;(s<n||s===n&&l&&!i)&&(e=o,n=s,i=l)}),e}var at=t=>t<10?"0"+t:String(t);function ut(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${at(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${at(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function ct(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let I=0;I<i;I++)e[I]&&r.add(e[I]);let o=_e(r,{pattern:t.pattern,locale:t.locale});if(!o)return null;let s=o.cadence.grain;if(s==="irregular")return null;let l=o.points[0],u=te(l,o.points[o.points.length-1],s,o.stepMs)+1;if(u!==o.cadence.expectedPoints)return null;let c=new Map;for(let I of r){let b=Se(I,t.pattern,t.locale);if(!b)continue;let P=te(l,b,s,o.stepMs);P>=0&&P<u&&c.set(I,{idx:P,stamp:b})}let d=new Map;for(let I=0;I<i;I++){let b=n[I];if(!b)continue;let P=c.get(e[I]);if(!P)continue;let z=d.get(b);z||(z={seen:new Set,lo:P.idx,hi:P.idx,loStamp:P.stamp,hiStamp:P.stamp,order:d.size},d.set(b,z)),z.seen.add(P.idx),P.idx<z.lo&&(z.lo=P.idx,z.loStamp=P.stamp),P.idx>z.hi&&(z.hi=P.idx,z.hiStamp=P.stamp)}if(d.size<2)return null;let f=0;for(let I of d.values())f+=I.seen.size;if(f/(d.size*u)<(t.minFill??fn))return null;let m=[],R=new Set,A=0,O=0,S=0,w=0,h=0,W=1;for(let[I,b]of d){for(let B of b.seen)R.add(B);if(b.seen.size>=u)continue;let P=[...b.seen].sort((B,a)=>B-a),z=1;for(let B=1;B<P.length;B++)z=Math.max(z,P[B]-P[B-1]);let Y={key:I,acc:b,coverage:b.seen.size/u,before:b.lo,after:u-1-b.hi,interior:b.hi-b.lo+1-b.seen.size,gap:z};m.push(Y),Y.before>0&&A++,Y.after>0&&O++,Y.interior>0&&S++,w=Math.max(w,Y.before),h=Math.max(h,Y.after),W=Math.max(W,z)}if(m.length===0)return null;m.sort((I,b)=>I.coverage-b.coverage||I.acc.order-b.acc.order);let U=m.slice(0,t.maxListed??dn);return{seriesColumn:t.seriesColumn,grain:s,periods:u,seriesCount:d.size,incompleteSeries:m.length,lateStarts:A,earlyEnds:O,withHoles:S,columnWideMissing:u-R.size,maxMissingBefore:w,maxMissingAfter:h,largestGap:W,series:U.map(I=>{let b={};return t.includeNames&&(b.name=I.key),t.includeDates&&(b.first=ut(I.acc.loStamp,s),b.last=ut(I.acc.hiStamp,s)),b.missingBefore=I.before,b.missingAfter=I.after,b.missingInterior=I.interior,b.largestGap=I.gap,b.coverage=Math.round(I.coverage*1e3)/1e3,b}),more:m.length-U.length}}var _n=12,An=100,Cn=.3,Mn=.9,xn=120,Rn=1900,Tn=2100,Nn=0,En=20,In=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function gt(t){if(!t)return!1;let e=j(t);return e.length===0?!1:In.has(e[e.length-1])?!0:Je(t)!==null}var vn=new Set(["year","yr","fy"]),wn=t=>j(t).some(e=>vn.has(e))||De(t)!==null,Ln=/^(?:(?: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 Ae(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Ce(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 Dn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,On=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Pn=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function kn(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function pt(t,e){let n=0,i=0,r=0,o=0,s=0,l="",u=0,c="",d=0,f=0,m=0,R=0,A=!1;for(let U of t){if(U==null)continue;let I=String(U).trim();if(I==="")continue;n++;let b;if(b=Dn.exec(I)){let P=+b[2],z=+b[3];P>=1&&P<=12&&z>=1&&z<=31&&(i++,b[4]!==void 0&&r++,b[6]!==void 0&&o++)}else if(b=On.exec(I)){let P=+b[3],z=+b[4];P>=1&&P<=12&&z>=1&&z<=31&&(l&&l!==b[2]&&(A=!0),l=b[2],s++)}else if(b=Pn.exec(I)){let P=+b[1],z=+b[3];P>=1&&P<=31&&z>=1&&z<=31&&(P<=12||z<=12)&&(c&&c!==b[2]&&(A=!0),c=b[2],u++,P>12&&m++,z>12&&R++,b[5]!==void 0&&d++,b[7]!==void 0&&f++)}if(n>=200)break}if(n<2||(i+s+u)/n<.8||(i>0?1:0)+(s>0?1:0)+(u>0?1:0)!==1||A)return null;if(i>0)return r===i?{pattern:o===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(s>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(m>0&&R>0)return null;let w,h;m>0?(w=!0,h="values"):R>0?(w=!1,h="values"):(w=!kn(e),h="locale");let W=w?`%d${c}%m${c}%Y`:`%m${c}%d${c}%Y`;return d===u?{pattern:W+(f===u?" %H:%M:%S":" %H:%M"),orderFrom:h}:{pattern:W,orderFrom:h}}function Fn(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=ue(n);return i.length>0&&e[i]!==void 0}var Gn=/(?:19|20)[0-9]{2}/;function Wn(t){let e=new Map,n=0;for(let r of t){if(!Gn.test(re(r)))continue;let o=new Set(se(r).filter(s=>s.yearDigits===4&&(s.grain==="quarter"||s.grain==="week")).map(s=>s.lang));if(o.size!==0){if(o.has("en")){n++;continue}for(let s of o)e.set(s,(e.get(s)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function zn(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 o=t.minNum,s=t.maxNum;if(!(o!=null&&s!=null&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isInteger(o)&&Number.isInteger(s)&&s>=o))return!1;let u=o>=1900&&s<=2100;if(u&&r>=2&&wn(n)||u&&r>=3&&r===s-o+1)return!0;let c=Ae(o)&&Ae(s),d=Ce(o)&&Ce(s);if(c||d){if(!t.sampleValues)return!0;let f=0,m=0;for(let R of t.sampleValues){if(R==null||R==="")continue;f++;let A=Number(String(R).trim());if(Number.isFinite(A)&&(c?Ae(A):Ce(A))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let o=t.locale?le(t.locale):null,s=0,l=0,u=[],c=[];for(let d of t.sampleValues){if(d==null||d==="")continue;s++;let f=String(d).trim();if(u.push(f),Ln.test(f)||Fn(f,o)?l++:c.push(f),s>=60)break}if(s>=2&&l/s>=.8||s>=2&&(l+Wn(c))/s>=.8||pt(u,t.locale)!==null)return!0}return!1}function Bn(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":Ue.some(n=>e.startsWith(n+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":be.some(n=>e.startsWith(n+" ")||e===n)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Vn(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:o,maxNum:s,discourageAgg:l}=t,u=100,c=.01,d="";for(let m of r){if(m.distinct<2||m.distinct>u)continue;let R=r.filter(h=>h.idx!==m.idx).map(h=>h.idx),A=new Map;for(let h of e){let W=h[n];if(typeof W!="number"||!Number.isFinite(W))continue;let U=R.length?R.map(b=>String(h[b])).join(d):"",I=A.get(U);I||(I={sum:0,cset:new Set},A.set(U,I)),I.sum+=W,I.cset.add(String(h[m.idx]))}let O=0,S=0,w=0;for(let h of A.values())h.cset.size<2||(w++,Math.abs(h.sum-100)<=100*c?O++:Math.abs(h.sum-1)<=1*c&&S++);if(w>=2&&(O/w>=.9||S/w>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=Bn(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:o!=null&&s!=null&&Number.isFinite(o)&&Number.isFinite(s)&&o>=0&&s<=1.0001&&s>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function dt(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:o,prec:s,maxval:l,minval:u}=t,c=l-u+1,d=c>0?r/c:1,f=o>0?r/o:0,m=e==="Decimal"||s>0;return!n&>(i)?"Categorical":d>=Mn&&(Oe(i)&&r<=xn||u>=Rn&&l<=Tn||u>=Nn&&l<=En)?"Ordinal":n||r>_n&&(m||r>=An||f>=Cn)?"Continuous":"Categorical"}function Un(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 ft=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;dedupRows=!0;emitLegacyAggAliases=!1;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}declareDimensions(e){for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return Le(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),o=[];for(let a of this._cols){let p=new Map,D=[],N=0,g=0,T=0,v=null,E=null,x=null,F=!1,k=!0,C=!0,M=null,G=!1;for(let _ of this._rows){let y=_[i],L=this.STR(y);if(L!=""){if(N+=L.length,p.set(L,(p.get(L)||0)+1),g++,a.dataType=="Integer"||a.dataType=="Decimal"||a.dataType=="DateTime")if((v===null||y<v)&&(v=y),(E===null||y>E)&&(E=y),a.dataType=="Integer"||a.dataType=="Decimal"){if(x===null?x=y:x+=y,a.dataType=="Decimal"){let V=this.getPrecision(y);V>T&&(T=V)}D.push(y)}else F=F||this.hasTimeComponent(y);G&&(y<M?k=!1:y>M&&(C=!1)),M=y,G=!0}}if(g>=3&&(k&&!C?a.sortedDirection="asc":C&&!k?a.sortedDirection="desc":a.sortedDirection="none"),g>0&&p.size>0&&!a.isMeasure){let _=0,y=Number.MAX_SAFE_INTEGER;for(let L of p.values())L>_&&(_=L),L<y&&(y=L);if(a.modalShare=_/g,a.minGroupCount=y===Number.MAX_SAFE_INTEGER?null:y,p.size===2){let L=[...p.keys()].map(ne=>Ie(ne).trim().toLowerCase()).sort(),K=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ne=>L[0]===ne[0]&&L[1]===ne[1]),Q=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(a.name);(K||Q)&&(a.isBinaryFlag=!0)}}if(a.dataType=="DateTime"&&(a.dateWithTime=F),a.isTemporal=zn({dataType:a.dataType,name:a.name,isMeasure:a.isMeasure,distinctCount:p.size,minNum:typeof v=="number"?v:null,maxNum:typeof E=="number"?E:null,sampleValues:p.keys(),locale:n}),a.isTemporal&&a.dataType==="String"&&!a.isMeasure){let _=pt(p.keys(),n);_&&(a.temporalTextPattern=_.pattern)}if(a.isTemporal&&!a.isMeasure){let _=ot(p.keys(),{includeBounds:r>=20,pattern:a.temporalTextPattern,locale:n});_&&(a.temporalCadence=_)}this.updateColumnStats10(r,a,g,p,T,E,v),this.updateColumnStats20(r,D,g,x,a,N,F,v,E,T,p,n),!a.isMeasure&&!this._declaredDimensions.has(a)&&(a.dataType==="Integer"||a.dataType==="Decimal")&&dt({dataType:a.dataType,isMeasure:!1,name:a.name,distinct:p.size,nonblank:g,prec:T,maxval:typeof E=="number"?E:0,minval:typeof v=="number"?v:0})==="Continuous"&&(a.isMeasure=!0,a.geoKind=void 0,a.geoMatchPct=void 0,a.geoAmbiguous=void 0,a.dominantGeoRegion=void 0,a.dominantGeoRegionPct=void 0,a.geoRegionCount=void 0),o[i]=a.isMeasure||p.size>2e3?null:new Set(p.keys()),i++}let s=[];this._cols.forEach((a,p)=>{a.isMeasure||s.push({idx:p,distinct:a.distinctCount??0,name:a.name})}),this._cols.forEach((a,p)=>{if(!a.isMeasure)return;let D=typeof a.lowValue=="number"?a.lowValue:null,N=typeof a.highValue=="number"?a.highValue:null,g=Vn({rows:this._rows,measureColIdx:p,measureName:a.name,candidateDims:s,minNum:D,maxNum:N,discourageAgg:!!a.discourageAggregationAcrossGroups});a.additivity=g.additivity,g.partOfWholeDim&&(a.partOfWholeDim=g.partOfWholeDim)});let l=50,u=4,c=s.filter(a=>a.distinct>=2&&a.distinct<=l);this._cols.forEach((a,p)=>{if(!a.isMeasure)return;let D=[];for(let C of this._rows){let M=C[p];if(M==null||M==="")continue;let G=typeof M=="number"?M:parseFloat(M);isNaN(G)||D.push(G)}if(D.length===0)return;let N=[...D].sort((C,M)=>C-M);if(N[0]===N[N.length-1])a.relativeDispersion=0;else if(N.length>=u){let C=H(N,.5),M=H(N,.1),G=H(N,.9);a.relativeDispersion=Math.abs(C)>1e-9?Math.round((G-M)/Math.abs(C)*1e3)/1e3:void 0}else a.relativeDispersion=void 0;let g=[];for(let C of c){let M=new Set;for(let G of this._rows){let _=G[p];_==null||_===""||M.add(this.STR(G[C.idx])+"")}g.push({otherColumn:C.name,nonBlankGroupCount:M.size})}g.length>0&&(a.nonBlankGroups=g);let T=0;for(let C of D)T+=C;T/=D.length;let v=0;for(let C of D)v+=(C-T)*(C-T);if(v<=1e-12)return;let E=[],x=[],F=C=>{if(C.length<4)return NaN;let M=[...C].sort((_,y)=>_-y),G=_=>M[Math.min(M.length-1,Math.max(0,Math.floor(_*(M.length-1))))];return G(.75)-G(.25)},k=F(D);for(let C of c){let M=new Map;for(let y of this._rows){let L=y[p];if(L==null||L==="")continue;let V=typeof L=="number"?L:parseFloat(L);if(isNaN(V))continue;let K=this.STR(y[C.idx])+"",Q=M.get(K);Q?(Q.s+=V,Q.n++,Q.vals.push(V)):M.set(K,{s:V,n:1,vals:[V]})}let G=0;for(let y of M.values()){let L=y.s/y.n;G+=y.n*(L-T)*(L-T)}E.push({otherColumn:C.name,eta2:Math.round(G/v*1e4)/1e4});let _=[];for(let y of M.values()){let L=F(y.vals);isNaN(L)||_.push(L)}if(_.length>=2&&isFinite(k)&&k>1e-9){let y=(Math.max(..._)-Math.min(..._))/k;x.push({otherColumn:C.name,spreadRatio:Math.round(y*1e4)/1e4})}}E.length>0&&(a.groupDiscrimination=E),x.length>0&&(a.spreadDiscrimination=x)});let d=.97,f=.8,m=8,R=5,A=this._cols.map((a,p)=>({c:a,i:p})).filter(a=>a.c.isMeasure);for(let a=0;a<A.length;a++)for(let p=a+1;p<A.length;p++){let D=A[a].i,N=A[p].i,g=0,T=0,v=0,E=0,x=0,F=0;for(let _ of this._rows){let y=_[D],L=_[N];if(y==null||y===""||L===null||L===void 0||L==="")continue;let V=typeof y=="number"?y:parseFloat(y),K=typeof L=="number"?L:parseFloat(L);isNaN(V)||isNaN(K)||(g++,T+=V,v+=K,E+=V*V,x+=K*K,F+=V*K)}if(g<R)continue;let k=g*E-T*T,C=g*x-v*v;if(k<=1e-12||C<=1e-12)continue;let M=(g*F-T*v)/Math.sqrt(k*C),G=Math.min(1,Math.round(Math.abs(M)*1e3)/1e3);for(let _ of[A[a].c,A[p].c])(_.maxAbsMeasureCorrelation===void 0||G>_.maxAbsMeasureCorrelation)&&(_.maxAbsMeasureCorrelation=G);if(Math.abs(M)>=d){let _=A[a].c,y=A[p].c;_.collinearWithMeasures||(_.collinearWithMeasures=[]),y.collinearWithMeasures||(y.collinearWithMeasures=[]),_.collinearWithMeasures.push(y.name),y.collinearWithMeasures.push(_.name)}else if(Math.abs(M)>=f){let _=A[a].c,y=A[p].c,L=Math.round(M*1e3)/1e3;_.correlatedWithMeasures||(_.correlatedWithMeasures=[]),y.correlatedWithMeasures||(y.correlatedWithMeasures=[]),_.correlatedWithMeasures.push({otherColumn:y.name,r:L}),y.correlatedWithMeasures.push({otherColumn:_.name,r:L})}}for(let{c:a}of A)a.correlatedWithMeasures&&(a.correlatedWithMeasures.sort((p,D)=>Math.abs(D.r)-Math.abs(p.r)||(p.otherColumn<D.otherColumn?-1:1)),a.correlatedWithMeasures.length=Math.min(a.correlatedWithMeasures.length,m));for(let a=0;a<this._cols.length;a++){let p=o[a];if(!p||p.size===0)continue;let D=[];for(let N=0;N<this._cols.length;N++){if(N===a)continue;let g=o[N];if(!g||g.size===0)continue;let T=0;for(let E of p)g.has(E)&&T++;let v=Math.round(T/p.size*100);v>0&&D.push({otherColumn:this._cols[N].name,percentShared:v})}D.length>0&&(this._cols[a].sharedValueRatioWithOthers=D)}let O=50,S=[];for(let a=0;a<this._cols.length;a++){let p=o[a];p&&p.size>=2&&p.size<=O&&S.push(a)}if(S.length>=2){let a=new Map,p=(N,g)=>N+":"+g;for(let N=0;N<S.length;N++)for(let g=N+1;g<S.length;g++)a.set(p(S[N],S[g]),new Map);for(let N of this._rows)for(let g=0;g<S.length;g++){let T=this.STR(N[S[g]])+"";for(let v=g+1;v<S.length;v++){let E=""+this.STR(N[S[v]]),x=a.get(p(S[g],S[v])),F=T+""+E;x.set(F,(x.get(F)??0)+1)}}let D=new Map;for(let N=0;N<S.length;N++)for(let g=N+1;g<S.length;g++){let T=S[N],v=S[g],E=o[T].size,x=o[v].size,F=a.get(p(T,v)),k=F.size,C=0;for(let y of F.values())(C===0||y<C)&&(C=y);let M=Math.round(k/(E*x)*100),G=k===E,_=k===x;if((this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[v].name,fillPct:M,determinesOther:G,minCellCount:C,distinctCombinations:k}),(this._cols[v].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:M,determinesOther:_,minCellCount:C,distinctCombinations:k}),G&&E>x){let y=D.get(T);(!y||x<y.card)&&D.set(T,{name:this._cols[v].name,card:x,ratio:x/E})}if(_&&x>E){let y=D.get(v);(!y||E<y.card)&&D.set(v,{name:this._cols[T].name,card:E,ratio:E/x})}}for(let[N,g]of D)this._cols[N].primaryParentColumn=g.name,this._cols[N].nestingRatio=Math.round(g.ratio*100)/100}let w=6,h=this._rows.length;for(let a=0;a<this._cols.length;a++){let p=this._cols[a];if(p.isMeasure||p.primaryParentColumn)continue;let D=p.distinctCount??0;if(D<=O||h>0&&D>=h)continue;let N=[];for(let g=0;g<this._cols.length;g++){if(g===a)continue;let T=this._cols[g];if(T.isMeasure)continue;let v=T.distinctCount??0;v<2||v>=D||N.push(g)}N.sort((g,T)=>(this._cols[g].distinctCount??0)-(this._cols[T].distinctCount??0));for(let g of N.slice(0,w)){let T=new Map,v=!0;for(let x of this._rows){let F=this.STR(x[a])+"",k=this.STR(x[g])+"",C=T.get(F);if(C===void 0)T.set(F,k);else if(C!==k){v=!1;break}}if(!v)continue;let E=this._cols[g].distinctCount??0;p.primaryParentColumn=this._cols[g].name,p.nestingRatio=Math.round(E/D*100)/100;break}}let W=.01,U=.05,I=.95,b=8,P=8,z=6,Y=500,B=[];for(let a=0;a<this._cols.length&&B.length<P;a++){let p=this._cols[a].dataType;(p==="Double"||p==="Integer"||p==="Decimal")&&B.push(a)}if(B.length>=3&&this._rows.length>=b){let a=Math.min(this._rows.length,Y),p=B.map(E=>{let x=[];for(let C=0;C<a;C++){let M=this._rows[C][E],G=typeof M=="number"?M:parseFloat(String(M).replace(/,/g,""));if(M==null||M===""||!isFinite(G))return null;x.push(G)}let F=x[0],k=!1;for(let C of x)if(C!==F){k=!0;break}return k?x:null}),D=B.map((E,x)=>x).filter(E=>p[E]!==null),N=E=>{let x=E.slice().sort((k,C)=>k-C),F=x.length>>1;return x.length%2?x[F]:(x[F-1]+x[F])/2},g=null,T=[],v=E=>{if(T.length>=3){let x=T.map(M=>p[M]),F=x[0].length,k=new Array(F);for(let M=0;M<F;M++){let G=0;for(let _ of x)G+=_[M];k[M]=G}let C=N(k);if(C>0){let M=0;for(let _ of k)Math.abs(_-C)<=C*W&&M++;let G=M/F;if(G>=I){let _=1;for(let y of x){let L=N(y)/C;L<_&&(_=L)}_>=U&&(!g||T.length>g.cols.length)&&(g={cols:T.slice(),total:C,matched:G})}}}if(!(T.length>=z))for(let x=E;x<D.length;x++)T.push(D[x]),v(x+1),T.pop()};if(v(0),g){let E=g,F={columns:E.cols.map(k=>this._cols[B[k]].name),total:Math.round(E.total*1e3)/1e3,matchedPct:Math.round(E.matched*100)/100};for(let k of E.cols)this._cols[B[k]].constantSumGroup=F}}return this.applySeriesCompleteness(r,n,o),this._computedStatsForLevel=e,this._cols}applySeriesCompleteness(e,n,i){for(let m of this._cols)m.seriesCompleteness!==void 0&&delete m.seriesCompleteness;let r=this._cols.map((m,R)=>({c:m,i:R})).filter(({c:m})=>m.isTemporal&&!m.isMeasure&&m.temporalCadence&&m.temporalCadence.grain!=="irregular");if(r.length===0)return;let o=[],s=[];this._cols.forEach((m,R)=>{let A=i[R];A&&(o.push(R),s.push({name:m.name,dataType:m.dataType,isMeasure:!!m.isMeasure,isTemporal:!!m.isTemporal,isDatePart:!!m.isDatePart,isReassembledDate:!!m.isReassembledDate,isBinaryFlag:!!m.isBinaryFlag,geoKind:m.geoKind,identifierNamed:gt(m.name),values:A,rows:this._rows.length,locale:n}))});let l=lt(s);if(l<0)return;let u=o[l],c=this._cols[u],d=this._rows.map(m=>this.STR(m[u])),f=e>=20&&(c.dataType!=="String"||Array.isArray(c.safeDistinctValues));for(let{c:m,i:R}of r){let A=ct({periods:this._rows.map(O=>this.STR(O[R])),series:d,seriesColumn:c.name,pattern:m.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:f});A&&(m.seriesCompleteness=A)}}updateColumnStats20(e,n,i,r,o,s,l,u,c,d,f,m){if(e>=20){let R=[...n].sort((S,w)=>S-w),A=Math.floor(R.length/2);if(i>0&&r!=null?o.avgValue=o.dataType=="Integer"?Math.round(r/i):r/i:o.avgValue=null,i>0&&(o.avgLength=s/i),this._rows.length>0){let S=w=>{let h=w instanceof Date?w:typeof w=="string"?pe(w)??new Date(w):new Date(w),W=this.wholeDayIso(h);return W?W+"T00:00:00.000Z":isNaN(h.getTime())?w:h.toISOString().slice(0,10)+"T00:00:00.000Z"};o.dataType!="DateTime"||l||!u?o.lowValue=u:o.lowValue=S(u),o.dataType!="DateTime"||l||!c?o.highValue=c:o.highValue=S(c),o.medianValue=R.length===0?null:R.length%2===0?o.dataType=="Integer"?Math.round((R[A-1]+R[A])/2):(R[A-1]+R[A])/2:R[A],o.numericPrecision=d}if(R.length>0){let S=o.avgValue??0,w=R.length,h=0,W=0;for(let I of R){let b=I-S;h+=b*b,W+=b*b*b}let U=h/w;o.skewness=U===0?0:W/w/Math.pow(Math.sqrt(U),3),o.stdDev=Math.sqrt(U)}r!==null&&(o.sum=r);let O=Array.from(f.entries()).sort((S,w)=>w[1]-S[1]);if(o.topCategories=O.slice(0,10).map(S=>S[1]),!o.isMeasure&&O.length>0){if(o.dataType==="String"){let S=O.map(h=>h[0]);o.formatSignature=ae(S);let w=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;o.formatSignature&&!w.test(o.formatSignature)&&(o.avgLength===void 0||o.avgLength>=3)&&(o.isFreeText=!0)}else o.topCategoryValues=O.slice(0,5).map(S=>S[0]);if(e>=20){let S=O.map(h=>h[0]),w=oe(S,m);if(w!==null)o.ordinalPattern=w.pattern,o.orderedDomain=w.orderedDomain;else if(o.dataType==="String"){let h=Pe(S);h!==null&&(o.safeDistinctValues=h)}}}if(R.length>=8&&(o.dataType==="Integer"||o.dataType==="Decimal")){let S=w=>R[Math.floor((R.length-1)*w)];o.quantiles={p05:S(.05),p25:S(.25),p75:S(.75),p95:S(.95)}}}if(!o.isMeasure&&f.size>0){let R=Array.from(f.entries()).sort((O,S)=>S[1]-O[1]),A=Ge(R.map(O=>O[0]),o.name,m);if(A!==null&&(o.geoKind=A.geoKind,o.geoMatchPct=A.geoMatchPct,A.geoAmbiguous&&(o.geoAmbiguous=!0),A.geoKind.indexOf("country")===0)){let O=he(R);O&&(o.dominantGeoRegion=O.dominantGeoRegion,o.dominantGeoRegionPct=O.dominantGeoRegionPct,o.geoRegionCount=O.regionCount)}}}updateColumnStats10(e,n,i,r,o,s,l){e>=10&&(n.blankCount=this._rows.length-i,n.distinctCount=r.size+(n.blankCount!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=dt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:o,maxval:s,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=s=>Me(s,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((s,l)=>{let u=e(s.name),c=s.dataType==="Integer"||s.dataType==="Decimal";c&&n<0&&u.some(d=>d==="lat"||d==="latitude")?n=l:c&&i<0&&u.some(d=>d==="lon"||d==="lng"||d==="long"||d==="longitude")&&(i=l),r<0&&!s.isMeasure&&typeof s.geoKind=="string"&&s.geoKind.indexOf("country")===0&&(r=l)}),n<0||i<0)return null;let o=[];for(let s of this._rows){let l=s[n],u=s[i],c=l==null||l===""?null:Number(l),d=u==null||u===""?null:Number(u);o.push({lat:c,lon:d,country:r>=0&&ce(this.STR(s[r]))?this.STR(s[r]):null})}return this._geoExtent=Be(o),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return nt(e,we)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,o)=>{i[r.name]=n[o],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[o])});for(let[r,o]of e)Object.prototype.hasOwnProperty.call(i,o.alias)||(i[o.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,o=new Map;for(let l of this._rows){let u={};for(let c=0;c<this._cols.length;c++){let d=this._cols[c],f=l[c];if(this.STR(f)!=""){if(e&&d.dataType=="String")if(o.has(f))f=o.get(f);else{let m=this.obfuscateString(f);o.set(f,m),f=m}else if(d.dataType=="DateTime"&&!d.dateWithTime){let m=f instanceof Date?f:typeof f=="string"?pe(f)??new Date(f):new Date(f);f=(this.wholeDayIso(m)??m.toISOString().slice(0,10))+"T00:00:00.000Z"}r-=this.STR(f).length}else f=null;u[c]=f,--r}if(n.push(u),--i,i<=0||r<=0)break}return await mt.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return mt.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}aliasesForCode(e){let n=ye(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=ye(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:"english-implicit-agg"});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 s of this._cols)s&&(r.add(this.STR(s.name)),s.hostName&&r.add(this.STR(s.hostName)));let o=new Map;for(let s=0;s<this._cols.length;s++){if(!this._cols[s])continue;let l=Ye(this._hostQueryNames[s]).filter(u=>!r.has(u)&&ee(i,u));l.length===1&&o.set(l[0],[...o.get(l[0])??[],s])}for(let[s,l]of o){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);n.set(l[0],{name:u,alias:s,headerName:!ee(i,u)})}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 o of e)i+=this.STR(o)+"~";let r=ve(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(Un(e)),this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(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),o=Ke(r);!o||o===r||n.has(o)||(n.delete(r),n.add(o),i.hostName=r,i.name=o)}}};export{Be as a,yt as b,ce as c,Hn as d,St as e,_t as f,At as g,Ct as h,me as i,Nt as j,Ke as k,ye as l,Ye as m,Xe as n,wt as o,qe as p,Qe as q,Zn as r,qn as s,Qn as t,Ot as u,Pt as v,kt as w,Je as x,ee as y,jt as z,sr as A,Xt as B,Zt as C,Se as D,ot as E,dn as F,fn as G,gn as H,Sn as I,lt as J,ct as K,gt as L,pt as M,zn as N,Bn as O,Vn as P,dt as Q,Un as R,ft as S};
|