@bicharts/shape-core 0.6.99 → 0.6.103

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{N as I,V as A,e as R}from"./chunk-CQS6BGRJ.mjs";import{a as h,c as x,d as E,e as L}from"./chunk-A4PQBWRA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import M from"papaparse";var k=500,j=/^[+-]?\d{1,15}$/,N=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,O=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function _(e,o=".",t=!1){if(t)return"DateTime";let r=0,s=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,s++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,j.test(h(m))){r++,s++;continue}if(L(m,o)){s++;continue}if((N.test(m)||O.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":s===l?"Decimal":"String"}function $(e,o,t=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let s=String(e).trim();if(s==="")return null;switch(o){case"Integer":{let i=h(s);return j.test(i)?parseInt(i,10):null}case"Decimal":return E(s,t);case"DateTime":return r?r.read(s):C(s);default:return s}}function q(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*F(e,o){for(let t of e)yield t?.[o]}function g(e,o,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 r=e.length,s=e.map((n,a)=>o.slice(0,k).map(u=>u?.[a])),i=s.map(n=>x(n,t.locale)),l=e.map((n,a)=>n.dataType===void 0||n.dataType==="DateTime"?R(F(o,a),{locale:t.locale??"en"}):null),c=e.map((n,a)=>n.dataType??_(s[a],i[a],l[a]!==null)),m=new Set((t.measures??[]).map(n=>n.toLowerCase())),b=new Set((t.dimensions??[]).map(n=>n.toLowerCase())),P=new Set((t.nonAdditive??[]).map(n=>n.toLowerCase())),D=e.map((n,a)=>{let u=n.name.toLowerCase(),f=n.isMeasure??((c[a]==="Integer"||c[a]==="Decimal")&&!I(n.name));m.has(u)&&(f=!0),b.has(u)&&(f=!1);let T={name:n.name,dataType:c[a],isMeasure:f};return f&&P.has(u)&&(T.discourageAggregationAcrossGroups=!0),T}),d=new A;d.dedupRows=t.dedup!==!1,d.setColumns(D),d.declareDimensions(D.filter((n,a)=>b.has(e[a].name.toLowerCase())));for(let n=0;n<o.length;n++){let a=o[n];d.addRow(Array.from({length:r},(u,f)=>$(a?.[f],c[f],i[f],l[f])),n)}let p=d.getColumnsWithStats(t.privacyLevel??"20",t.locale??"en"),S=new Map(p.map(n=>[n.name,n]));e.forEach(n=>{let a=S.get(n.name);a&&(n.format&&(a.modelFormat=n.format),n.description&&(a.modelDesc=n.description))});let y=n=>{let a=S.get(n);if(a)return[a];let u=n.toLowerCase();return p.filter(f=>f.name.toLowerCase()===u)};for(let[n,a]of Object.entries(t.formats??{}))for(let u of y(n))u.modelFormat=a;for(let[n,a]of Object.entries(t.descriptions??{}))for(let u of y(n))u.modelDesc=a;for(let n of t.groupBy??[])for(let a of y(n))a.isGrouping=!0;return{columns:p,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function w(e,o){return e.map(t=>Array.isArray(t)?t:o.map(r=>t[r]))}function V(e,o){let t=[],r=new Set,s=Math.min(e.length,Math.max(1,o));for(let i=0;i<s;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let c of Object.keys(l))r.has(c)||(r.add(c),t.push(c))}return t}function v(e){let o=String(e??"").replace(/^\uFEFF/,""),t=[],r=[],s=0;return M.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(s,l);s=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||t.push(m)}}),!t.length&&!r.length&&r.push(...M.parse(o,{skipEmptyLines:!0}).errors),{rows:t,errors:r}}function Y(e,o={}){switch(e.kind){case"csv":{let t=v(e.text);if(t.errors.length&&t.rows.length===0)throw new Error(`ingest: CSV parse failed - ${t.errors[0].message}`);let r=t.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let s=r[0].map(i=>(i??"").trim());return g(s.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return g(e.header.map(t=>({name:(t??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let t=e.columns.map(r=>r.name);return g(e.columns,w(e.rows??[],t),o)}case"objects":{let t=e.rows??[],r=e.columns?.length?e.columns:V(t,o.columnScanLimit??k).map(s=>({name:s}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return g(r,w(t,r.map(s=>s.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let t=e.schema.map(r=>{let s=q(r.dataType);return{name:r.name,dataType:s,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(t,w(e.rows??[],t.map(r=>r.name)),o)}default:{let t=e;throw new Error(`ingest: unknown source kind '${t?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{q as a,v as b,Y as c};
@@ -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 he}from"./chunk-U3H6UBOO.mjs";import{a as mt,f as te,g as ye,h as se,i as be,j as ie}from"./chunk-A4PQBWRA.mjs";import{c as ct}from"./chunk-IPPPCWAK.mjs";import{f as lt,k as ut}from"./chunk-INMDBTAR.mjs";import{e as rt,k as ge,m as ot,n as at,o as pe}from"./chunk-HJA26Z2E.mjs";import{A as fe,B as tt,E as nt,a as me,b as ee,c as Ke,d as de,g as He,h as Ye,j as je,l as Xe,m as Ze,o as Qe,p as Q,q as qe,r as Je,u as Ne,w as et}from"./chunk-CZJ7M6A5.mjs";import{c as Ve,f as Ie}from"./chunk-WC4JINEZ.mjs";import{b as it,d as st}from"./chunk-5HI6TVMM.mjs";var Jt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],en=[7,72,-172,-52];function dt(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var ne=n=>Math.round(n*10)/10;function gt(n,e=3){let t=[],i=[],r=0,s=0;for(let l of n){let a=l?.lat,u=l?.lon;if(typeof a!="number"||typeof u!="number"||!isFinite(a)||!isFinite(u)||a<-90||a>90||u<-180||u>180)continue;t.push(a),i.push(u);let m=l?.country?String(l.country).trim().toUpperCase():"",f=m?Se(m):null;f?((m==="US"||m==="USA")&&r++,f==="north-america"&&s++):(Jt.some(c=>dt(a,u,c))&&r++,dt(a,u,en)&&s++)}let o=t.length;return o<e?null:(t.sort((l,a)=>l-a),i.sort((l,a)=>l-a),{pctUsa:ne(r/o*100),pctNa:ne(s/o*100),latP5:ne(Q(t,.05)),latP95:ne(Q(t,.95)),lonP5:ne(Q(i,.05)),lonP95:ne(Q(i,.95)),n:o})}var ft={"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"},oe=(()=>{let n=new Map;for(let e of Object.keys(ft))for(let t of ft[e].split(/\s+/))t&&n.set(t,e);return n})();function tn(n){for(let[e,t]of n){let i=oe.get(e);i&&!oe.has(t)&&oe.set(t,i)}}tn(lt);function Se(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=oe.get(e);if(t)return t;let i=ut(String(n));return i?oe.get(i)??null:null}function oi(n,e=2){return Ee(n.map(t=>[t,1]),e)}function Ee(n,e=2){let t=new Map,i=0;for(let[o,l]of n){let a=Se(o);if(!a)continue;let u=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(a,(t.get(a)??0)+u),i+=u}if(i<e||!t.size)return null;let r="europe",s=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>s&&(r=o,s=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:ne(s/i*100),regionCount:t.size,n:i}}function De(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var ve={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},nn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,rn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,sn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,on=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,an=new Set(["de","del","of"]),ln=new Set(["\u0433","\u0440","r"]),un=/^[\p{L}\p{M}\u0970\u05f3]+$/u,ke=/^\d+$/;function cn(n){let e=+n[1],t=+n[2],i=n[3]===void 0?0:+n[3],r=n[4]!==void 0;if(t>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(n[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:t,s:i,seconds:n[3]!==void 0,meridiem:r}}function pt(n){let e=n.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=mt(e);let t=null,i=nn.exec(e);if(i){if(t=cn(i),!t)return null;e=e.slice(0,i.index)}let r;if(r=sn.exec(e)){let c=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...ve,form:"cjk",key:c,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=rn.exec(e)){let c=r[2],S=r[4];if(c!==S)return null;let I=c.trim(),T=r[6];if(T&&I!==".")return null;let C=[r[1].length,r[3].length,r[5].length],g=C[0]===4,y=C[2]===4;return g===y||(g?C[1]>2||C[2]>2:C[0]>2||C[1]>2)?null:g&&I==="-"&&c==="-"&&C[1]===2&&C[2]===2?"iso":g&&I==="."&&c==="."&&!T&&!(C[1]===2&&C[2]===2)?null:{...ve,form:"numeric",key:`num|${g?"y":"x"}|${c}|${T}`,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:g,sep:c,trail:T}}let s=e.replace(on,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!an.has(c.toLowerCase()));if(s.length===4&&ke.test(s[2])&&ln.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let o=s.map(c=>ke.test(c)?"N":un.test(c)?"W":"?").join(""),l=s.map(c=>ke.test(c)?c:""),a=0,u=0,m="",f;if(o==="NWN"&&l[0].length<=2&&l[2].length===4)a=+l[0],m=s[1],u=+l[2],f="dmy";else if(o==="WNN"&&l[1].length<=2&&l[2].length===4)m=s[0],a=+l[1],u=+l[2],f="mdy";else if(o==="NWN"&&l[0].length===4&&l[2].length<=2)u=+l[0],m=s[1],a=+l[2],f="ymd";else return null;return{...ve,form:"named",key:`named|${f}`,clock:t,day:a,year:u,word:m,namedOrder:f}}var mn=[31,28,31,30,31,30,31,31,30,31,30,31],dn=n=>n%4===0&&n%100!==0||n%400===0;function ht(n,e,t){return n>=1&&n<=9999&&e>=1&&e<=12&&t>=1?t<=(e===2&&dn(n)?29:mn[e-1]):!1}function fn(n,e,t,i){let r=new Date(Date.UTC(2e3,e-1,t,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(n),r}function yt(n,e={}){let t=(e.floor??1)>=1,i=new Map,r=new Map,s=0,o=null;for(let g of n){if(g==null)continue;if(typeof g!="string"){if(t)return null;s++;continue}let y=g.trim();if(y==="")continue;s++;let b=i.get(y);if(b===void 0&&(b=pt(y),i.set(y,b)),b===null||b==="iso"){if(t)return null;continue}if(t){if(o===null)o=b;else if(b.key!==o.key)return null}else r.set(b.key,(r.get(b.key)??0)+1)}if(!t){let g=0,y="";for(let[b,p]of r)p>g&&(g=p,y=b);if(g===0||g/s<e.floor)return null;o=[...i.values()].find(b=>b!==null&&b!=="iso"&&b.key===y)??null}if(o===null)return null;let l=o.key,a=[...i.values()].filter(g=>g!==null&&g!=="iso"&&g.key===l),u,m="shape",f=null;if(o.form==="named"){if(u=o.namedOrder,f=be(a.map(g=>g.word),e.locale),!f)return null}else if(o.form==="cjk"||o.yearFirst)u="ymd";else{let g=0,y=0;for(let b of a)b.a>12&&g++,b.b>12&&y++;if(g>0&&y>0)return null;g>0?(u="dmy",m="values"):y>0?(u="mdy",m="values"):o.sep.trim()==="."?(u="dmy",m="shape"):(u=De(e.locale)?"mdy":"dmy",m="locale")}let c=g=>{if(g.form==="named"){let y=f.get(te(g.word));return y===void 0?null:[g.year,y+1,g.day]}return g.yearFirst?[g.a,g.b,g.c]:u==="dmy"?[g.c,g.b,g.a]:[g.c,g.a,g.b]},S=1/0,I=-1/0,T=0;for(let g of a){let y=c(g);if(!y||!ht(y[0],y[1],y[2])){if(t)return null;T++;continue}S=Math.min(S,y[0]),I=Math.max(I,y[0])}if(!t&&(r.get(l)-T)/s<e.floor||S>=2400&&I<=2699||S>=1300&&I<=1500)return null;let C={form:o.form,order:u,orderFrom:m,hasTime:a.some(g=>g.clock!==null),read(g){if(typeof g!="string")return null;let y=g.trim();if(y==="")return null;let b=i.get(y);if(b===void 0&&(b=pt(y),i.set(y,b)),b===null||b==="iso"||b.key!==l)return null;let p=c(b);return!p||!ht(p[0],p[1],p[2])?null:fn(p[0],p[1],p[2],b.clock)}};if(o.form!=="named"&&!a.some(g=>g.clock?.meridiem)){let g;o.form==="cjk"?g=o.cjkPattern:o.yearFirst?g=`%Y${o.sep}%m${o.sep}%d${o.trail}`:g=(u==="dmy"?`%d${o.sep}%m${o.sep}%Y`:`%m${o.sep}%d${o.sep}%Y`)+o.trail;let y=a.filter(b=>b.clock!==null).length;y===0?C.pattern=g:y===a.length&&(C.pattern=g+(a.every(b=>b.clock.seconds)?" %H:%M:%S":" %H:%M"))}return C}import Yt from"papaparse";var gn=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","capita","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],pn=["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"],hn=["latitude","longitude"],yn=["latitude","longitude"];function q(n){return me(n)}var _t=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],bn=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Sn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],_n=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],_e=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function Oe(n){return[...n].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var At=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Oe(_t)+")\\s+)","i");function bt(n){for(let e of n){let t=e.codePointAt(0)??0;if(t>=11904&&t<=40959||t>=44032&&t<=55215)return!0}return!1}var An="[\u2013\u2014-]";function Ct(n){let e=n.filter(r=>!bt(r)),t=n.filter(bt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+An+"\\s*)("+Oe(e)+")"),t.length&&i.push("\\s*("+Oe(t)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Pe=Ct(Sn),Cn=Ct(_n);function Ae(n,e){let t=e.exec(n);if(!t)return null;let i=n.slice(0,t.index);return i.trim()===""?null:{base:i,label:(t[1]??t[2]??"").toLowerCase()}}function xt(n){let e=q(String(n??"").trim().toLowerCase());if(!e)return null;for(let r of bn)if(e.startsWith(r+" "))return _e[r]??"avg";for(let r of _t)if(e.startsWith(r+" ")||e===r)return _e[r]??"sum";let t=Ae(e,Cn);if(t)return _e[t.label]??"avg";let i=Ae(e,Pe);return i?_e[i.label]??"sum":null}var xn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Mn=new RegExp("\\b("+gn.join("|")+")\\b|("+pn.join("|")+")$","i"),Tn=new RegExp("\\b("+hn.join("|")+")\\b|("+yn.join("|")+")$","i");function xe(n){if(!n)return"";let e=String(n),t=q(e),i=At.exec(t);if(i)return e.slice(i[0].length).trim();let r=Ae(t,Pe);return(r?e.slice(0,r.base.length):e).trim()}function wn(n){if(!n)return!1;let e=q(String(n));return At.test(e)||Ae(e,Pe)!==null}var Rn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],St=new RegExp("^\\s*("+[...Rn].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Mt(n){if(n==null)return"";let e=String(n),t=St.exec(e);if(!t)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(t[1]),s=e.slice(t[0].length),o=0;for(;o<8;){let l=St.exec(s);if(!l||i(l[1])!==r)break;let a=s.slice(l[0].length);if(a.trim()==="")break;s=a,o++}return o===0?e:e.slice(0,t[0].length)+s}function Le(n,e){if(!n||!e)return!1;let t=String(n);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&t.includes(r))return!0}return!1}var Ce={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 "]},Tt=new RegExp("^("+Object.keys(Ce).join("|")+")\\((.+)\\)$");function wt(n){if(!n)return[];let e=Tt.exec(String(n).trim());if(!e)return[];let t=Ce[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let o=i.slice(s+1);if(o.trim()!=="")for(let l of t){let a=l+o;r.includes(a)||r.push(a)}}return r}function Rt(n,e,t){let i=Tt.exec(String(n??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&t==="Decimal")return!0;let s=new Set(Ce[r]),o=String(e??""),l=i[2];for(let a=l.indexOf(".");a>=0;a=l.indexOf(".",a+1)){if(a===0)continue;let u=l.slice(a+1);if(u.trim()!==""){for(let m of Object.values(Ce))for(let f of m)if(!s.has(f)&&o===f+u)return!0}}return!1}function In(n){let e=xe(n);return e.length===0?"":e.replace(xn," ")}function It(n,e){if(!e)return!1;let t=xe(e);return n.test(q(In(e)))||n.test(q(t))||n.test(q(ee(t).join(" ")))}function Nt(n){return It(Tn,n)}function Nn(n){return It(Mn,n)||Nt(n)}var Et=/int|double|decimal|single|float|number|currency|money/i;function En(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||Et.test(String(n?.dataType??""))?"Continuous":"Categorical"}function vn(n){return n?.isMeasure===!0||Et.test(String(n?.dataType??""))}function vt(n){let e=n??{},t=En(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(Nt(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&wn(e.name))){if(i==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Nn(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function kt(n){let e=vt(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return vn(t)?["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 fi(n){return kt(n)[0]}function gi(n,e){return kt(n).indexOf(e)>=0}function pi(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=vt(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var kn={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"]},Dn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],On=["num\xE9ro"],Pn=n=>n.normalize("NFC").toLowerCase();function Ln(n,e,t,i){let r=Ie(t);return!r||!n?null:n===e?"word":r.wordBreaks===!1?Array.from(e).length<Ze?null:(i?n.startsWith(e):n.endsWith(e))&&n.length>e.length?"suffix":null:i?je(n,t).includes(e)?"word":null:r.script==="Hang"?Xe(n,e)?"suffix":null:r.compounds&&Ye(n,e,He)?"suffix":null}function Dt(n){let e=String(n??"").trim();if(!e)return null;let t=de(e),i=de(xe(e));for(let[r,s]of Object.entries(kn)){let o=Dn.includes(r),l=o?i:t;for(let a of s){let u=On.includes(a)||!!Ie(r)?.foldSensitive,m=u?l.words:l.folded;if(m.length===0)continue;let f=u?Pn(a):de(a).folded.join(" "),c=Ln(o?m[0]:m[m.length-1],f,r,o);if(c)return{lang:r,word:a,view:c}}}return null}var Fn=[["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 Me(n){for(let[e,t]of Fn)if(t.test(n))return e;return null}var Wn=[{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]]}],Te=new Map;function Ot(n,e,t,i){let r=Te.get(n);if(r)return r;let s=[];for(let[o,l]of e)for(let a=o;a<=l;a++){let u=String.fromCodePoint(a);Me(u)===t&&(i&&!i.test(u)||s.push(u))}return Te.set(n,s),s}function Bn(n){let t=n.codePointAt(0);for(let o=0;o<9&&Me(String.fromCodePoint(t-1))==="Nd";o++)t--;let i="nd:"+t.toString(16),r=Te.get(i);if(r)return r;let s=[];for(let o=t;o<t+10;o++){let l=String.fromCodePoint(o);Me(l)==="Nd"&&s.push(l)}return Te.set(i,s),s}function Gn(n,e){if(e==="Nd")return Bn(n);for(let r of Wn)if(r.test.test(n))return Ot(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=n.codePointAt(0)&-128;return Ot("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function zn(n,e,t,i){let r=n.filter(s=>!e.has(s));return r.length===0&&(r=n.filter(s=>s!==t)),r.length===0?t:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var $n=/^[\p{L}\p{M}\p{Nd}]$/u,Pt=/^[\p{L}\p{Nd}]$/u;function Lt(n,e){if(!n)return n??"";let t=new Set(Array.from(n)),i=m=>{let f=Me(m);return!f||!$n.test(m)?m:zn(Gn(m,f),t,m,e)},r=m=>{let f=[];for(let c of m)f.push(i(c)),Pt.test(c)&&e()<.2&&f.push(i(c));if(f.length>6){let c=Math.floor(e()*Math.min(3,f.length-6));for(let S=0;S<c;S++)for(let I=0;I<5;I++){let T=Math.floor(e()*f.length);if(Pt.test(f[T])){f.splice(T,1);break}}}return f.join("")};if(!(n.includes("@")&&n.includes(".")))return r(n);let[o,l=""]=n.split("@"),a=l.endsWith(".com"),u=a?l.slice(0,-4):l;return`${r(o)}@${r(u)}${a?".com":""}`}var Un=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Vn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Kn=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function ae(n,e){if(!n||!e)return!1;let t=Vn(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:Un.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function Hn(n){return!!n&&Kn.test(n)}function Ci(n,e,t){return n?Hn(n)?[...e]:[...t,...e].some(i=>ae(n,i))?e.filter(i=>ae(n,i)):[...e]:[]}var Yn=5,jn=6,Xn=3,re=864e5,Zn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Qn=/^(\d{4})[-/](\d{1,2})$/,qn=/^(\d{4})[-\s]?Q([1-4])$/i,Jn=/^Q([1-4])[-\s](\d{4})$/i,er=/^(\d{4})$/,tr=/^(\d{4})(0[1-9]|1[0-2])$/,nr=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,rr=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,ir=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Fe(n,e,t){let i=te(n);if(!i)return 0;if(i==="sept")return 9;for(let o of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=ye(o)[i];if(l!==void 0)return l+1}let r=t?.get(i);if(r!==void 0)return r+1;let s=se(n);if(s.length>0){if(s.every(a=>a.month===s[0].month))return s[0].month+1;let o=Ve(String(e??"").split(/[-_]/)[0])?.code,l=s.find(a=>a.lang===o);if(l)return l.month+1}return 0}function sr(n){let e=ge(n).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let t=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==t.n||i.year!==t.year)?null:H(t.year,(t.n-1)*3+1,1)}function H(n,e,t,i=0,r=0,s=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,i,r,s);if(!Number.isFinite(o))return null;let l=a=>a<10?"0"+a:String(a);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function or(n,e){let t=[],i="";for(let a=0;a<e.length;a++){if(e[a]!=="%"){i+=e[a].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++a]){case"Y":t.push("Y"),i+="(\\d{4})";break;case"m":t.push("m"),i+="(\\d{1,2})";break;case"d":t.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(n);if(!r)return null;let s=0,o=1,l=1;return t.forEach((a,u)=>{let m=+r[u+1];a==="Y"?s=m:a==="m"?o=m:l=m}),s?H(s,o,l):null}function j(n,e,t,i){let r=(n??"").trim();if(r==="")return null;if(e){let a=or(r,e);return a||null}let s=Zn.exec(r);if(s)return H(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=qn.exec(r),s)return H(+s[1],(+s[2]-1)*3+1,1);if(s=Jn.exec(r),s)return H(+s[2],(+s[1]-1)*3+1,1);if(s=Qn.exec(r),s&&+s[2]>=1&&+s[2]<=12)return H(+s[1],+s[2],1);if(s=nr.exec(r),s)return H(+s[1],+s[2],+s[3]);if(s=tr.exec(r),s)return H(+s[1],+s[2],1);if(s=er.exec(r),s){let a=+s[1];return a>=1900&&a<=2100?H(a,1,1):null}let o=sr(r);if(o)return o;if(s=rr.exec(r),s){let a=Fe(s[1],t,i);if(a)return H(+s[2],a,1)}if(s=ir.exec(r),s){let a=Fe(s[2],t,i);if(a)return H(+s[1],a,1)}let l=ie(r);if(l){let a="month"in l?l.month:Fe(l.word,t,i);if(a)return H(l.year,a,1)}return null}function Ft(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function Wt(n,e){if(e<=n)return 0;let t=Math.round((e-n)/re),i=Math.floor(t/7),r=i*5,s=n+i*7*re;for(;s<e;)Ft(s)&&r++,s+=re;return r}function ar(n){if(n.length===0)return 0;let e=[...n].sort((i,r)=>i-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function lr(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function le(n,e,t,i){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*re));case"weekday":return Wt(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/re);default:return i>0?Math.round((e.ms-n.ms)/i):0}}function Bt(n,e){return We(n,e)?.cadence??null}function We(n,e){let t=e?.gapFactor??Yn,i=0,r=0,s=new Map,o=Array.from(n),l;if(!e?.pattern){let p=[];for(let A of o){if(A==null||A==="")continue;let h=ie(String(A));h&&"word"in h&&p.push(h.word)}p.length>0&&(l=be(p,e?.locale)??void 0)}for(let p of o){if(p==null||p==="")continue;i++;let A=j(String(p),e?.pattern,e?.locale,l);A&&(r++,s.set(A.ms,A))}let a=[...s.values()].sort((p,A)=>p.ms-A.ms);if(a.length<Xn||i>0&&r/i<.8)return null;let u=a[a.length-1].ms-a[0].ms;if(u<=0)return null;let m=[];for(let p=1;p<a.length;p++)m.push(a[p].ms-a[p-1].ms);let f=ar(m);if(!(f>0))return null;let c=lr(f/re);c==="day"&&u>=7*re&&a.every(p=>Ft(p.ms))&&Wt(a[0].ms,a[a.length-1].ms)+1>a.length*.5&&(c="weekday");let S=c==="irregular"?a.length:le(a[0],a[a.length-1],c,f)+1,I=1,T=1,C=[],g=a[0],y=1;for(let p=1;p<a.length;p++){let A=le(a[p-1],a[p],c,f);A>I&&(I=A),c!=="irregular"&&A>t?(T++,C.push({from:g.iso,to:a[p-1].iso,points:y}),g=a[p],y=1):y++}C.push({from:g.iso,to:a[a.length-1].iso,points:y});let b={grain:c,points:a.length,expectedPoints:Math.max(S,a.length),coveragePct:Math.round(a.length/Math.max(S,a.length)*1e3)/10,runs:T,largestGapUnits:I,gapFactor:t};return e?.includeBounds&&C.length<=jn&&(b.runBounds=C),{cadence:b,points:a,stepMs:f}}var ur=8,cr=.5,mr=200,dr=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"]),fr=["category","classification","segment","status","priority","severity","channel"],gr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function pr(n){let e=ee(n);if(e.length===0)return!1;let t=e[e.length-1];return dr.has(t)?!0:fr.some(i=>t.length>i.length&&t.endsWith(i))}function hr(n){if(n.isMeasure)return"measure";if(n.isTemporal||n.isDatePart||n.isReassembledDate)return"temporal";let e=Array.from(n.values).filter(t=>t!==""&&t!==null&&t!==void 0);return e.length<2||e.length>mr?"cardinality":n.rows>0&&e.length>=n.rows?"row-identity":n.isBinaryFlag?"flag":pe(e,n.locale)!==null?"ordinal":n.identifierNamed||n.dataType==="String"&&gr.has(he(e))?"identifier":!n.geoKind&&pr(n.name)?"attribute":"entity"}function $t(n){let e=-1,t=1/0,i=!1;return n.forEach((r,s)=>{if(hr(r)!=="entity")return;let o=new Set(Array.from(r.values).filter(a=>a!=="")).size,l=!!r.geoKind;(o<t||o===t&&l&&!i)&&(e=s,t=o,i=l)}),e}var Gt=n=>n<10?"0"+n:String(n);function zt(n,e){switch(e){case"year":return`${n.y}-01-01`;case"quarter":return`${n.y}-${Gt(Math.floor((n.m-1)/3)*3+1)}-01`;case"month":return`${n.y}-${Gt(n.m)}-01`;case"hour":return new Date(n.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return n.iso}}function Ut(n){let{periods:e,series:t}=n,i=Math.min(e.length,t.length),r=new Set;for(let A=0;A<i;A++)e[A]&&r.add(e[A]);let s=We(r,{pattern:n.pattern,locale:n.locale});if(!s)return null;let o=s.cadence.grain;if(o==="irregular")return null;let l=s.points[0],a=le(l,s.points[s.points.length-1],o,s.stepMs)+1;if(a!==s.cadence.expectedPoints)return null;let u=new Map;for(let A of r){let h=j(A,n.pattern,n.locale);if(!h)continue;let w=le(l,h,o,s.stepMs);w>=0&&w<a&&u.set(A,{idx:w,stamp:h})}let m=new Map;for(let A=0;A<i;A++){let h=t[A];if(!h)continue;let w=u.get(e[A]);if(!w)continue;let M=m.get(h);M||(M={seen:new Set,lo:w.idx,hi:w.idx,loStamp:w.stamp,hiStamp:w.stamp,order:m.size},m.set(h,M)),M.seen.add(w.idx),w.idx<M.lo&&(M.lo=w.idx,M.loStamp=w.stamp),w.idx>M.hi&&(M.hi=w.idx,M.hiStamp=w.stamp)}if(m.size<2)return null;let f=0;for(let A of m.values())f+=A.seen.size;if(f/(m.size*a)<(n.minFill??cr))return null;let c=[],S=new Set,I=0,T=0,C=0,g=0,y=0,b=1;for(let[A,h]of m){for(let $ of h.seen)S.add($);if(h.seen.size>=a)continue;let w=[...h.seen].sort(($,X)=>$-X),M=1;for(let $=1;$<w.length;$++)M=Math.max(M,w[$]-w[$-1]);let V={key:A,acc:h,coverage:h.seen.size/a,before:h.lo,after:a-1-h.hi,interior:h.hi-h.lo+1-h.seen.size,gap:M};c.push(V),V.before>0&&I++,V.after>0&&T++,V.interior>0&&C++,g=Math.max(g,V.before),y=Math.max(y,V.after),b=Math.max(b,M)}if(c.length===0)return null;c.sort((A,h)=>A.coverage-h.coverage||A.acc.order-h.acc.order);let p=c.slice(0,n.maxListed??ur);return{seriesColumn:n.seriesColumn,grain:o,periods:a,seriesCount:m.size,incompleteSeries:c.length,lateStarts:I,earlyEnds:T,withHoles:C,columnWideMissing:a-S.size,maxMissingBefore:g,maxMissingAfter:y,largestGap:b,series:p.map(A=>{let h={};return n.includeNames&&(h.name=A.key),n.includeDates&&(h.first=zt(A.acc.loStamp,o),h.last=zt(A.acc.hiStamp,o)),h.missingBefore=A.before,h.missingAfter=A.after,h.missingInterior=A.interior,h.largestGap=A.gap,h.coverage=Math.round(A.coverage*1e3)/1e3,h}),more:c.length-p.length}}var we=6;function ue(n){let e=n.slice().sort((i,r)=>i-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function yr(n){let e=n.length;if(e<we)return null;let t=n[0],i=n[0],r=0;for(let p of n)p<t&&(t=p),p>i&&(i=p),r+=p;if(t===i)return null;let s=ue(n.map(Math.abs));if(s===0)return null;let o=[];for(let p=1;p<e;p++)o.push(n[p]-n[p-1]);let l=ue(o.map(Math.abs))/s,a=(e-1)/2,u=r/e,m=0,f=0,c=0;for(let p=0;p<e;p++)m+=(p-a)*(n[p]-u),f+=(p-a)*(p-a),c+=(n[p]-u)*(n[p]-u);c/=e;let S=m/f,I=u-S*a,T=n.map((p,A)=>p-(I+S*A)),C=T.reduce((p,A)=>p+A,0)/e,g=0,y=0;for(let p=0;p<e;p++)g+=(T[p]-C)*(T[p]-C),p>0&&(y+=(T[p]-T[p-1])*(T[p]-T[p-1]));return g/=e,y/=e-1,{vnDetrended:g<=c*1e-12?2:y/g,relStep:l}}function Be(n){let{stamps:e,series:t,values:i}=n,r=Math.min(e.length,i.length),s=new Map;for(let u=0;u<r;u++){let m=e[u],f=i[u];if(m===null||f===null||!Number.isFinite(f))continue;let c="";if(t&&(c=t[u]??"",c===""))continue;let S=s.get(c);S||s.set(c,S=new Map),S.set(m,(S.get(m)??0)+f)}let o=[],l=[],a=[];for(let u of s.values()){let m=[...u.entries()].sort((c,S)=>c[0]-S[0]).map(c=>c[1]),f=yr(m);f&&(o.push(f.vnDetrended),l.push(f.relStep),a.push(m.length))}return o.length===0?null:{series:o.length,points:Math.round(ue(a)),vnDetrended:Math.round(ue(o)*1e3)/1e3,relStep:Math.round(ue(l)*1e4)/1e4}}function Oi(n){let e=n.times.map(t=>j(t,n.pattern,n.locale)?.ms??null);return Be({stamps:e,series:n.series,values:n.values})}var br=5e5,Sr=8,_r=4,Ar=5,Ge=1,ze=2,Cr=4,xr=8;function Mr(n,e,t){let[i,r]=[...n];if(e.isTemporal){let s=j(i,e.temporalTextPattern,t),o=j(r,e.temporalTextPattern,t);if(s&&o&&s.ms!==o.ms)return s.ms<o.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Tr(n,e,t){let{rows:i,text:r,locale:s}=n,o=Mr(t.values,t,s),l=new Uint8Array(i.length),a=0;for(let u=0;u<i.length;u++){let m=r(i[u][e]);m===o.a?l[u]=1:m===o.b?l[u]=2:a++}return{code:l,blankRows:a,setOrder:o.setOrder}}function wr(n,e){let{rows:t,text:i}=n,r=new Int32Array(t.length),s=new Map;for(let o=0;o<t.length;o++){let l=i(t[o][e]);if(l===""){r[o]=-1;continue}let a=s.get(l);a===void 0&&(a=s.size,s.set(l,a)),r[o]=a}return{ids:r,dict:s}}function Rr(n,e,t){let i=new Uint8Array(t);for(let s=0;s<n.length;s++){let o=e[s];if(o===0)continue;let l=n[s];if(l<0)continue;let a=i[l];i[l]=a&o?a|o<<2:a|o}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<t;s++){let o=i[s];o&Ge&&r.keysA++,o&ze&&r.keysB++,(o&(Ge|ze))===(Ge|ze)&&r.keysBoth++,o&Cr&&r.dupA++,o&xr&&r.dupB++}return r}function Ir(n,e){let t=(n.dupA+n.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(n.keysA+n.keysB);return t<i||t===i&&n.keysBoth>e.keysBoth}var Vt=n=>n==null||typeof n=="string"&&n.trim()==="";function Nr(n,e,t){if(n===e)return!0;let i=Vt(n),r=Vt(e);return i||r?i&&r:typeof n=="number"&&typeof e=="number"?!1:n instanceof Date&&e instanceof Date?n.getTime()===e.getTime():t(n).trim()===t(e).trim()}function Kt(n){let{rows:e,columns:t}=n,i=e.length;if(i<2||i>br)return null;let r=t.map((h,w)=>({c:h,i:w})).filter(({c:h})=>!h.isMeasure&&!h.isTemporal&&!h.isDatePart&&h.distinct>=Ar).sort((h,w)=>(w.c.identifierNamed?1:0)-(h.c.identifierNamed?1:0)||w.c.distinct-h.c.distinct||h.i-w.i).slice(0,Sr),s=t.map((h,w)=>({c:h,i:w})).filter(({c:h})=>!h.isMeasure&&h.values!==null&&h.values.size===2).slice(0,_r);if(r.length===0||s.length===0)return null;let o=s.map(({c:h,i:w})=>Tr(n,w,h)),l=null;for(let{i:h}of r){let w=wr(n,h);for(let M=0;M<s.length;M++){if(s[M].i===h)continue;let V=Rr(w.ids,o[M].code,w.dict.size);V.keysBoth<1||(!l||Ir(V,l.tally))&&(l={tally:V,keyIdx:h,setNo:M,ids:w.ids,dict:w.dict})}}if(!l)return null;let{ids:a,dict:u,tally:m}=l,f=o[l.setNo],c=s[l.setNo].i,S=u.size,I=new Int32Array(S).fill(-1),T=new Int32Array(S).fill(-1);for(let h=0;h<i;h++){let w=f.code[h],M=a[h];w===0||M<0||(w===1?I[M]<0&&(I[M]=h):T[M]<0&&(T[M]=h))}let C=[];for(let h=0;h<t.length;h++)h!==l.keyIdx&&h!==c&&C.push(h);let g=0;for(let h=0;h<S;h++){let w=I[h],M=T[h];if(w<0||M<0)continue;let V=e[w],$=e[M],X=!0;for(let J of C)if(!Nr(V[J],$[J],n.text)){X=!1;break}X&&g++}let y=g===m.keysBoth?100:g===0?0:Math.min(99,Math.max(1,Math.round(g/m.keysBoth*100))),b=new Map,p=new Map;for(let[h,w]of u){let M=I[w]>=0,V=T[w]>=0;if(!M&&!V)continue;let $=it(h);st($)&&(M&&b.set($,(b.get($)??0)+1),V&&p.set($,(p.get($)??0)+1))}let A=h=>{let w=0;for(let M of h.values())M>=2&&(w+=M);return w};return{key:l.keyIdx,discriminator:c,pairing:{form:"long",key:t[l.keyIdx].name,discriminator:t[c].name,keysA:m.keysA,keysB:m.keysB,keysBoth:m.keysBoth,duplicateKeysA:m.dupA,duplicateKeysB:m.dupB,identicalPct:y,discriminatorBlankRows:f.blankRows,looseCollisionsA:A(b),looseCollisionsB:A(p),setOrder:f.setOrder}}}var Er=n=>n==="Integer"||n==="Decimal";function vr(n){let e=[],t=[];return n.forEach((i,r)=>{if(i.twoValues){if(i.isBinaryFlag){e.push(r);return}i.isMeasure||i.isTemporal||i.isDatePart||i.identifierNamed||t.push(r)}}),[...e,...t].slice(0,6)}function kr(n,e){let t=[];for(let i=0;i<n.length&&t.length<12;i++){let r=n[i];e.has(i)||!Er(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||t.push(i)}return t}function Ht(n){let e=new Map,{rows:t,columns:i,text:r}=n;if(t.length===0||t.length>(n.maxRows??5e5))return e;let s=vr(i);if(s.length===0)return e;let o=kr(i,new Set(s));if(o.length===0)return e;let l=s.map(a=>{let[u,m]=i[a].twoValues,f=new Uint8Array(t.length);for(let c=0;c<t.length;c++){let S=r(t[c][a]);f[c]=S===u?1:S===m?2:0}return f});for(let a of o){let u=new Float64Array(t.length),m=0;for(let y=0;y<t.length;y++){let b=t[y][a],p=b==null||b===""?NaN:typeof b=="number"?b:parseFloat(b);u[y]=p,p===p&&p!==1/0&&p!==-1/0&&m++}if(m<2)continue;let f=new Float64Array(m);for(let y=0,b=0;y<t.length;y++){let p=u[y];p===p&&p!==1/0&&p!==-1/0&&(f[b++]=p)}f.sort();let c=new Float64Array(m),S=0;for(let y=0;y<m;y++)(y===0||f[y]!==f[y-1])&&(c[S++]=f[y]);let I=new Int32Array(t.length).fill(-1);for(let y=0;y<t.length;y++){let b=u[y];if(!(b===b&&b!==1/0&&b!==-1/0))continue;let p=0,A=S-1;for(;p<A;){let h=p+A>>>1;c[h]<b?p=h+1:A=h}I[y]=p}let T=[],C=new Int32Array(S),g=new Int32Array(S);for(let y=0;y<s.length;y++){let b=l[y];C.fill(0),g.fill(0);let p=0,A=0;for(let d=0;d<t.length;d++){let _=I[d];_<0||(b[d]===1?(C[_]++,p++):b[d]===2&&(g[_]++,A++))}if(p===0||A===0)continue;let h=p<=A,w=h?p:A,M=h?A:p,V=h?C:g,$=h?g:C,X=0,J=0,Y=0;for(let d=0;d<S;d++){let _=V[d],F=$[d];X+=_*(J+.5*F),J+=F,_+F>=2&&(Y+=_+F)}T.push({outcome:i[s[y]].name,aucMinorityHigh:Math.round(X/(w*M)*1e4)/1e4,nMinority:w,nMajority:M,ties:Y})}T.length>0&&e.set(a,T)}return e}var Dr=12,Or=100,Pr=.3,Lr=.9,Fr=120,Wr=1900,Br=2100,Gr=0,zr=20,$r=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Re(n){if(!n)return!1;let e=ee(n);return e.length===0?!1:$r.has(e[e.length-1])?!0:Dt(n)!==null}var Ur=new Set(["year","yr","fy"]),Vr=n=>ee(n).some(e=>Ur.has(e))||rt(n)!==null,Kr=/^(?:(?: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 $e(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function Ue(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var Hr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Yr=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,jr=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Zt(n,e){let t=[],i=0,r=Xr(n,e,t,()=>{i++});if(r)return r;if(i>0||t.length<2)return null;let s=yt(t,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function Xr(n,e,t,i){let r=0,s=0,o=0,l=0,a=0,u="",m=0,f="",c=0,S=0,I=0,T=0,C=!1;for(let h of n){if(h==null)continue;let w=String(h).trim();if(w==="")continue;r++,t.push(w);let M;if(M=Hr.exec(w)){i();let V=+M[2],$=+M[3];V>=1&&V<=12&&$>=1&&$<=31&&(s++,M[4]!==void 0&&o++,M[6]!==void 0&&l++)}else if(M=Yr.exec(w)){i();let V=+M[3],$=+M[4];V>=1&&V<=12&&$>=1&&$<=31&&(u&&u!==M[2]&&(C=!0),u=M[2],a++)}else if(M=jr.exec(w)){i();let V=+M[1],$=+M[3];V>=1&&V<=31&&$>=1&&$<=31&&(V<=12||$<=12)&&(f&&f!==M[2]&&(C=!0),f=M[2],m++,V>12&&I++,$>12&&T++,M[5]!==void 0&&c++,M[7]!==void 0&&S++)}if(r>=200)break}if(r<2||(s+a+m)/r<.8||(s>0?1:0)+(a>0?1:0)+(m>0?1:0)!==1||C)return null;if(s>0)return o===s?{pattern:l===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(a>0)return{pattern:`%Y${u}%m${u}%d`,orderFrom:"iso"};if(I>0&&T>0)return null;let b,p;I>0?(b=!0,p="values"):T>0?(b=!1,p="values"):f==="."?(b=!0,p="shape"):(b=!De(e),p="locale");let A=b?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return c===m?{pattern:A+(S===m?" %H:%M:%S":" %H:%M"),orderFrom:p}:{pattern:A,orderFrom:p}}function Zr(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let i=te(t);return i.length>0&&e[i]!==void 0}function Qr(n,e){let t=new Map,i=new Map;for(let l of n){let a=ie(l);if(!a||"month"in a)continue;let u=se(a.word),m=u.some(c=>c.lang==="en"),f=te(a.word);for(let c of new Set(u.map(S=>S.lang)))c!=="en"&&(t.has(c)||(t.set(c,new Set),i.set(c,new Set)),t.get(c).add(f),m||i.get(c).add(f))}let r=[...t.keys()].filter(l=>t.get(l).size>=3&&i.get(l).size>=1),s=0,o=new Map(r.map(l=>[l,0]));for(let l of e){let a=ie(l);if(!a)continue;if("month"in a){s++;continue}let u=se(a.word);if(u.length===0)continue;let m=u.some(f=>f.lang==="en");for(let f of r)(m||u.some(c=>c.lang===f))&&o.set(f,o.get(f)+1)}return s+Math.max(0,...o.values())}var qr=/(?:19|20)[0-9]{2}/;function Jr(n){let e=new Map,t=0;for(let r of n){if(!qr.test(me(r)))continue;let s=new Set(ge(r).filter(o=>o.yearDigits===4&&(o.grain==="quarter"||o.grain==="week")).map(o=>o.lang));if(s.size!==0){if(s.has("en")){t++;continue}for(let o of s)e.set(o,(e.get(o)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+t:0}function ei(n){let{dataType:e,name:t,isMeasure:i,distinctCount:r}=n;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=n.minNum,o=n.maxNum;if(!(s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isInteger(s)&&Number.isInteger(o)&&o>=s))return!1;let a=s>=1900&&o<=2100;if(a&&r>=2&&Vr(t)||a&&r>=3&&r===o-s+1)return!0;let u=$e(s)&&$e(o),m=Ue(s)&&Ue(o);if(u||m){if(!n.sampleValues)return!0;let f=0,c=0;for(let S of n.sampleValues){if(S==null||S==="")continue;f++;let I=Number(String(S).trim());if(Number.isFinite(I)&&(u?$e(I):Ue(I))&&c++,f>=60)break}if(f>=2&&c===f)return!0}return!1}if(n.sampleValues){let s=n.locale?ye(n.locale):null,o=0,l=0,a=[],u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;o++;let f=String(m).trim();if(a.push(f),Kr.test(f)||Zr(f,s)?l++:u.push(f),o>=60)break}if(o>=2&&l/o>=.8||o>=2&&(l+Jr(u)+Qr(a,u))/o>=.8||Zt(a,n.locale)!==null)return!0}return!1}function ti(n){let e=q((n||"").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":xt(n)}function ni(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:r,minNum:s,maxNum:o,discourageAgg:l}=n,a=100,u=.01,m="";for(let c of r){if(c.distinct<2||c.distinct>a)continue;let S=r.filter(y=>y.idx!==c.idx).map(y=>y.idx),I=new Map;for(let y of e){let b=y[t];if(typeof b!="number"||!Number.isFinite(b))continue;let p=S.length?S.map(h=>String(y[h])).join(m):"",A=I.get(p);A||(A={sum:0,cset:new Set},I.set(p,A)),A.sum+=b,A.cset.add(String(y[c.idx]))}let T=0,C=0,g=0;for(let y of I.values())y.cset.size<2||(g++,Math.abs(y.sum-100)<=100*u?T++:Math.abs(y.sum-1)<=1*u&&C++);if(g>=2&&(T/g>=.9||C/g>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(l)return{additivity:"intensive_rate"};let f=ti(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&s>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function Qt(n){let{dataType:e,isMeasure:t,name:i,distinct:r,nonblank:s,prec:o,maxval:l,minval:a}=n,u=l-a+1,m=u>0?r/u:1,f=s>0?r/s:0,c=e==="Decimal"||o>0;return!t&&Re(i)?"Categorical":m>=Lr&&(ot(i)&&r<=Fr||a>=Wr&&l<=Br||a>=Gr&&l<=zr)?"Ordinal":t||r>Dr&&(c||r>=Or||f>=Pr)?"Continuous":"Categorical"}function jt(n,e,t){return!n||n.isMeasure||e||n.dataType!=="Integer"&&n.dataType!=="Decimal"?!1:Qt({dataType:n.dataType,isMeasure:!1,name:n.name,distinct:t.distinct,nonblank:t.nonblank,prec:t.prec,maxval:typeof t.maxval=="number"?t.maxval:0,minval:typeof t.minval=="number"?t.minval:0})==="Continuous"}function ri(n){let e=null;for(let t=0;t<n.length;t++){let i=n[t];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=n.slice()),e[t]=r)}return e||n}var Xt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;dedupRows=!0;emitLegacyAggAliases=!1;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let t=0;t<this._cols.length;t++){let i=this._cols[t];!i||!/date|time/i.test(String(i.dataType??""))||tt(this._rows.map(r=>r[t]))&&e.add(t)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(t=>!!(t&&t.isMeasure));return this._cols.forEach((t,i)=>{if(!t||t.isMeasure||this._declaredDimensions.has(t)||t.dataType!=="Integer"&&t.dataType!=="Decimal")return;let r=new Set,s=0,o=0,l=null,a=null;for(let u of this._rows){let m=u[i],f=this.STR(m);if(f!=""&&(r.add(f),s++,(l===null||m<l)&&(l=m),(a===null||m>a)&&(a=m),t.dataType=="Decimal")){let c=this.getPrecision(m);c>o&&(o=c)}}e[i]=jt(t,!1,{distinct:r.size,nonblank:s,prec:o,minval:l,maxval:a})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let t of e)t&&this._declaredDimensions.add(t)}wholeDayIso(e){return et(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=this.wallClockColumnIndexes(),o=[],l=[],a=[];for(let d of this._cols){let _=new Map,F=[],D=0,x=0,k=0,L=null,O=null,v=null,G=!1,z=!0,N=!0,E=null,U=!1,P=s.has(i);for(let R of this._rows){let W=R[i],B=P&&W instanceof Date?fe(W):W,K=this.STR(B);if(K!=""){if(D+=K.length,_.set(K,(_.get(K)||0)+1),x++,d.dataType=="Integer"||d.dataType=="Decimal"||d.dataType=="DateTime")if((L===null||B<L)&&(L=B),(O===null||B>O)&&(O=B),d.dataType=="Integer"||d.dataType=="Decimal"){if(v===null?v=B:v+=B,d.dataType=="Decimal"){let Z=this.getPrecision(B);Z>k&&(k=Z)}F.push(B)}else G=G||this.hasTimeComponent(B);U&&(B<E?z=!1:B>E&&(N=!1)),E=B,U=!0}}if(x>=3&&(z&&!N?d.sortedDirection="asc":N&&!z?d.sortedDirection="desc":d.sortedDirection="none"),x>0&&_.size>0&&!d.isMeasure){let R=0,W=Number.MAX_SAFE_INTEGER;for(let B of _.values())B>R&&(R=B),B<W&&(W=B);if(d.modalShare=R/x,d.minGroupCount=W===Number.MAX_SAFE_INTEGER?null:W,_.size===2){let B=[..._.keys()].map(ce=>Qe(ce).trim().toLowerCase()).sort(),Z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ce=>B[0]===ce[0]&&B[1]===ce[1]),qt=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(d.name);(Z||qt)&&(d.isBinaryFlag=!0)}}else d.isMeasure&&(d.dataType==="Integer"||d.dataType==="Decimal")&&_.size===2&&_.has("0")&&_.has("1")&&(d.isBinaryFlag=!0);if(d.dataType=="DateTime"&&(d.dateWithTime=G,G&&nt(P?this._rows.map(R=>R[i]instanceof Date?fe(R[i]):R[i]):this._rows.map(R=>R[i]))?d.timeOfDayOnly=!0:delete d.timeOfDayOnly),d.isTemporal=ei({dataType:d.dataType,name:d.name,isMeasure:d.isMeasure,distinctCount:_.size,minNum:typeof L=="number"?L:null,maxNum:typeof O=="number"?O:null,sampleValues:_.keys(),locale:t}),d.isTemporal&&d.dataType==="String"&&!d.isMeasure){let R=Zt(_.keys(),t);R&&(d.temporalTextPattern=R.pattern)}if(d.isTemporal&&!d.isMeasure){let R=Bt(_.keys(),{includeBounds:r>=20,pattern:d.temporalTextPattern,locale:t});R&&(d.temporalCadence=R)}this.updateColumnStats10(r,d,x,_,k,O,L),this.updateColumnStats20(r,F,x,v,d,D,G,L,O,k,_,t),jt(d,this._declaredDimensions.has(d),{distinct:_.size,nonblank:x,prec:k,minval:L,maxval:O})&&(d.isMeasure=!0,d.geoKind=void 0,d.geoMatchPct=void 0,d.geoAmbiguous=void 0,d.dominantGeoRegion=void 0,d.dominantGeoRegionPct=void 0,d.geoRegionCount=void 0),o[i]=d.isMeasure||_.size>2e3?null:new Set(_.keys()),l[i]=_.size,a[i]=_.size===2?[..._.keys()].sort():null,i++}let u=[];this._cols.forEach((d,_)=>{d.isMeasure||u.push({idx:_,distinct:d.distinctCount??0,name:d.name})}),this._cols.forEach((d,_)=>{if(!d.isMeasure)return;let F=typeof d.lowValue=="number"?d.lowValue:null,D=typeof d.highValue=="number"?d.highValue:null,x=ni({rows:this._rows,measureColIdx:_,measureName:d.name,candidateDims:u,minNum:F,maxNum:D,discourageAgg:!!d.discourageAggregationAcrossGroups});d.additivity=x.additivity,x.partOfWholeDim&&(d.partOfWholeDim=x.partOfWholeDim)});let m=50,f=4,c=u.filter(d=>d.distinct>=2&&d.distinct<=m);this._cols.forEach((d,_)=>{if(!d.isMeasure)return;let F=[];for(let N of this._rows){let E=N[_];if(E==null||E==="")continue;let U=typeof E=="number"?E:parseFloat(E);isNaN(U)||F.push(U)}if(F.length===0)return;let D=[...F].sort((N,E)=>N-E);if(D[0]===D[D.length-1])d.relativeDispersion=0;else if(D.length>=f){let N=Q(D,.5),E=Q(D,.1),U=Q(D,.9);d.relativeDispersion=Math.abs(N)>1e-9?Math.round((U-E)/Math.abs(N)*1e3)/1e3:void 0}else d.relativeDispersion=void 0;let x=[];for(let N of c){let E=new Set;for(let U of this._rows){let P=U[_];P==null||P===""||E.add(this.STR(U[N.idx])+"")}x.push({otherColumn:N.name,nonBlankGroupCount:E.size})}x.length>0&&(d.nonBlankGroups=x);let k=0;for(let N of F)k+=N;k/=F.length;let L=0;for(let N of F)L+=(N-k)*(N-k);if(L<=1e-12)return;let O=[],v=[],G=N=>{if(N.length<4)return NaN;let E=[...N].sort((P,R)=>P-R),U=P=>E[Math.min(E.length-1,Math.max(0,Math.floor(P*(E.length-1))))];return U(.75)-U(.25)},z=G(F);for(let N of c){let E=new Map;for(let R of this._rows){let W=R[_];if(W==null||W==="")continue;let B=typeof W=="number"?W:parseFloat(W);if(isNaN(B))continue;let K=this.STR(R[N.idx])+"",Z=E.get(K);Z?(Z.s+=B,Z.n++,Z.vals.push(B)):E.set(K,{s:B,n:1,vals:[B]})}let U=0;for(let R of E.values()){let W=R.s/R.n;U+=R.n*(W-k)*(W-k)}O.push({otherColumn:N.name,eta2:Math.round(U/L*1e4)/1e4});let P=[];for(let R of E.values()){let W=G(R.vals);isNaN(W)||P.push(W)}if(P.length>=2&&isFinite(z)&&z>1e-9){let R=(Math.max(...P)-Math.min(...P))/z;v.push({otherColumn:N.name,spreadRatio:Math.round(R*1e4)/1e4})}}O.length>0&&(d.groupDiscrimination=O),v.length>0&&(d.spreadDiscrimination=v)});let S=.97,I=.8,T=8,C=5,g=this._cols.map((d,_)=>({c:d,i:_})).filter(d=>d.c.isMeasure);for(let d=0;d<g.length;d++)for(let _=d+1;_<g.length;_++){let F=g[d].i,D=g[_].i,x=0,k=0,L=0,O=0,v=0,G=0;for(let P of this._rows){let R=P[F],W=P[D];if(R==null||R===""||W===null||W===void 0||W==="")continue;let B=typeof R=="number"?R:parseFloat(R),K=typeof W=="number"?W:parseFloat(W);isNaN(B)||isNaN(K)||(x++,k+=B,L+=K,O+=B*B,v+=K*K,G+=B*K)}if(x<C)continue;let z=x*O-k*k,N=x*v-L*L;if(z<=1e-12||N<=1e-12)continue;let E=(x*G-k*L)/Math.sqrt(z*N),U=Math.min(1,Math.round(Math.abs(E)*1e3)/1e3);for(let P of[g[d].c,g[_].c])(P.maxAbsMeasureCorrelation===void 0||U>P.maxAbsMeasureCorrelation)&&(P.maxAbsMeasureCorrelation=U);if(Math.abs(E)>=S){let P=g[d].c,R=g[_].c;P.collinearWithMeasures||(P.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),P.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(P.name)}else if(Math.abs(E)>=I){let P=g[d].c,R=g[_].c,W=Math.round(E*1e3)/1e3;P.correlatedWithMeasures||(P.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),P.correlatedWithMeasures.push({otherColumn:R.name,r:W}),R.correlatedWithMeasures.push({otherColumn:P.name,r:W})}}for(let{c:d}of g)d.correlatedWithMeasures&&(d.correlatedWithMeasures.sort((_,F)=>Math.abs(F.r)-Math.abs(_.r)||(_.otherColumn<F.otherColumn?-1:1)),d.correlatedWithMeasures.length=Math.min(d.correlatedWithMeasures.length,T));for(let d=0;d<this._cols.length;d++){let _=o[d];if(!_||_.size===0)continue;let F=[];for(let D=0;D<this._cols.length;D++){if(D===d)continue;let x=o[D];if(!x||x.size===0)continue;let k=0;for(let O of _)x.has(O)&&k++;let L=Math.round(k/_.size*100);L>0&&F.push({otherColumn:this._cols[D].name,percentShared:L})}F.length>0&&(this._cols[d].sharedValueRatioWithOthers=F)}let y=50,b=[];for(let d=0;d<this._cols.length;d++){let _=o[d];_&&_.size>=2&&_.size<=y&&b.push(d)}if(b.length>=2){let d=new Map,_=(D,x)=>D+":"+x;for(let D=0;D<b.length;D++)for(let x=D+1;x<b.length;x++)d.set(_(b[D],b[x]),new Map);for(let D of this._rows)for(let x=0;x<b.length;x++){let k=this.STR(D[b[x]])+"";for(let L=x+1;L<b.length;L++){let O=""+this.STR(D[b[L]]),v=d.get(_(b[x],b[L])),G=k+""+O;v.set(G,(v.get(G)??0)+1)}}let F=new Map;for(let D=0;D<b.length;D++)for(let x=D+1;x<b.length;x++){let k=b[D],L=b[x],O=o[k].size,v=o[L].size,G=d.get(_(k,L)),z=G.size,N=0;for(let R of G.values())(N===0||R<N)&&(N=R);let E=Math.round(z/(O*v)*100),U=z===O,P=z===v;if((this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[L].name,fillPct:E,determinesOther:U,minCellCount:N,distinctCombinations:z}),(this._cols[L].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:E,determinesOther:P,minCellCount:N,distinctCombinations:z}),U&&O>v){let R=F.get(k);(!R||v<R.card)&&F.set(k,{name:this._cols[L].name,card:v,ratio:v/O})}if(P&&v>O){let R=F.get(L);(!R||O<R.card)&&F.set(L,{name:this._cols[k].name,card:O,ratio:O/v})}}for(let[D,x]of F)this._cols[D].primaryParentColumn=x.name,this._cols[D].nestingRatio=Math.round(x.ratio*100)/100}let p=6,A=this._rows.length;for(let d=0;d<this._cols.length;d++){let _=this._cols[d];if(_.isMeasure||_.primaryParentColumn)continue;let F=_.distinctCount??0;if(F<=y||A>0&&F>=A)continue;let D=[];for(let x=0;x<this._cols.length;x++){if(x===d)continue;let k=this._cols[x];if(k.isMeasure)continue;let L=k.distinctCount??0;L<2||L>=F||D.push(x)}D.sort((x,k)=>(this._cols[x].distinctCount??0)-(this._cols[k].distinctCount??0));for(let x of D.slice(0,p)){let k=new Map,L=!0;for(let v of this._rows){let G=this.STR(v[d])+"",z=this.STR(v[x])+"",N=k.get(G);if(N===void 0)k.set(G,z);else if(N!==z){L=!1;break}}if(!L)continue;let O=this._cols[x].distinctCount??0;_.primaryParentColumn=this._cols[x].name,_.nestingRatio=Math.round(O/F*100)/100;break}}let h=.01,w=.05,M=.95,V=8,$=8,X=6,J=500,Y=[];for(let d=0;d<this._cols.length&&Y.length<$;d++){let _=this._cols[d].dataType;(_==="Double"||_==="Integer"||_==="Decimal")&&Y.push(d)}if(Y.length>=3&&this._rows.length>=V){let d=Math.min(this._rows.length,J),_=Y.map(O=>{let v=[];for(let N=0;N<d;N++){let E=this._rows[N][O],U=typeof E=="number"?E:parseFloat(String(E).replace(/,/g,""));if(E==null||E===""||!isFinite(U))return null;v.push(U)}let G=v[0],z=!1;for(let N of v)if(N!==G){z=!0;break}return z?v:null}),F=Y.map((O,v)=>v).filter(O=>_[O]!==null),D=O=>{let v=O.slice().sort((z,N)=>z-N),G=v.length>>1;return v.length%2?v[G]:(v[G-1]+v[G])/2},x=null,k=[],L=O=>{if(k.length>=3){let v=k.map(E=>_[E]),G=v[0].length,z=new Array(G);for(let E=0;E<G;E++){let U=0;for(let P of v)U+=P[E];z[E]=U}let N=D(z);if(N>0){let E=0;for(let P of z)Math.abs(P-N)<=N*h&&E++;let U=E/G;if(U>=M){let P=1;for(let R of v){let W=D(R)/N;W<P&&(P=W)}P>=w&&(!x||k.length>x.cols.length)&&(x={cols:k.slice(),total:N,matched:U})}}}if(!(k.length>=X))for(let v=O;v<F.length;v++)k.push(F[v]),L(v+1),k.pop()};if(L(0),x){let O=x,G={columns:O.cols.map(z=>this._cols[Y[z]].name),total:Math.round(O.total*1e3)/1e3,matchedPct:Math.round(O.matched*100)/100};for(let z of O.cols)this._cols[Y[z]].constantSumGroup=G}}return this.applyTwoSetPairing(t,o),this.applyScoreSeparation(l,a),this.applySeriesCompleteness(r,t,o),this.applyMeasurePersistence(t,o),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,t){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=Kt({rows:this._rows,columns:this._cols.map((r,s)=>{let o=t[s];return{name:r.name,values:o,distinct:o?o.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Re(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,t){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=Ht({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Re(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:t[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,t,i){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,m)=>({c:u,i:m})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let s=this.seriesKeyIndex(t,i);if(s<0)return;let o=this._cols[s],l=this._rows.map(u=>this.STR(u[s])),a=e>=20&&(o.dataType!=="String"||Array.isArray(o.safeDistinctValues));for(let{c:u,i:m}of r){let f=Ut({periods:this._rows.map(c=>this.STR(c[m])),series:l,seriesColumn:o.name,pattern:u.temporalTextPattern,locale:t,includeDates:e>=20,includeNames:a});f&&(u.seriesCompleteness=f)}}seriesKeyIndex(e,t){let i=[],r=[];this._cols.forEach((o,l)=>{let a=t[l];a&&(i.push(l),r.push({name:o.name,dataType:o.dataType,isMeasure:!!o.isMeasure,isTemporal:!!o.isTemporal,isDatePart:!!o.isDatePart,isReassembledDate:!!o.isReassembledDate,isBinaryFlag:!!o.isBinaryFlag,geoKind:o.geoKind,identifierNamed:Re(o.name),values:a,rows:this._rows.length,locale:e}))});let s=$t(r);return s<0?-1:i[s]}applyMeasurePersistence(e,t){for(let a of this._cols)a.persistence!==void 0&&delete a.persistence;let i=[];if(this._cols.forEach((a,u)=>{a.isMeasure&&(a.dataType==="Integer"||a.dataType==="Decimal"||a.dataType==="Double")&&i.push(u)}),i.length===0||this._rows.length<we)return;let r=-1,s=[];for(let a=0;a<this._cols.length&&r<0;a++){let u=this._cols[a];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let m=this._rows.map(f=>j(this.STR(f[a]),u.temporalTextPattern,e)?.ms??null);new Set(m.filter(f=>f!==null)).size<we||(r=a,s=m)}if(r<0)return;let o=this.seriesKeyIndex(e,t),l=o>=0?this._rows.map(a=>this.STR(a[o])):void 0;for(let a of i){let u=this._rows.map(f=>{let c=f[a];if(c==null||c==="")return null;let S=typeof c=="number"?c:parseFloat(String(c).replace(/,/g,""));return Number.isFinite(S)?S:null}),m=Be({stamps:s,series:l,values:u});m&&(this._cols[a].persistence={timeColumn:this._cols[r].name,...o>=0?{seriesColumn:this._cols[o].name}:{},...m})}}updateColumnStats20(e,t,i,r,s,o,l,a,u,m,f,c){if(e>=20){let S=[...t].sort((C,g)=>C-g),I=Math.floor(S.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=o/i),this._rows.length>0){let C=g=>{let y=g instanceof Date?g:typeof g=="string"?Ne(g)??new Date(g):new Date(g),b=this.wholeDayIso(y);return b?b+"T00:00:00.000Z":isNaN(y.getTime())?g:y.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!a?s.lowValue=a:s.lowValue=C(a),s.dataType!="DateTime"||l||!u?s.highValue=u:s.highValue=C(u),s.medianValue=S.length===0?null:S.length%2===0?s.dataType=="Integer"?Math.round((S[I-1]+S[I])/2):(S[I-1]+S[I])/2:S[I],s.numericPrecision=m}if(S.length>0){let C=s.avgValue??0,g=S.length,y=0,b=0;for(let A of S){let h=A-C;y+=h*h,b+=h*h*h}let p=y/g;s.skewness=p===0?0:b/g/Math.pow(Math.sqrt(p),3),s.stdDev=Math.sqrt(p)}r!==null&&(s.sum=r);let T=Array.from(f.entries()).sort((C,g)=>g[1]-C[1]);if(s.topCategories=T.slice(0,10).map(C=>C[1]),!s.isMeasure&&T.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=T.slice(0,5).map(C=>C[0])),e>=20)){let C=T.map(y=>y[0]),g=pe(C,c);if(g!==null)s.ordinalPattern=g.pattern,s.orderedDomain=g.orderedDomain;else if(s.dataType==="String"){let y=at(C);y!==null&&(s.safeDistinctValues=y)}}if(S.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let C=g=>S[Math.floor((S.length-1)*g)];s.quantiles={p05:C(.05),p25:C(.25),p75:C(.75),p95:C(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let S=Array.from(f.entries()).sort((C,g)=>g[1]-C[1]).map(C=>C[0]);s.formatSignature=he(S);let I=i>0?o/i:void 0,T=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!T.test(s.formatSignature)&&(I===void 0||I>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let S=Array.from(f.entries()).sort((T,C)=>C[1]-T[1]),I=ct(S.map(T=>T[0]),s.name,c);if(I!==null&&(s.geoKind=I.geoKind,s.geoMatchPct=I.geoMatchPct,I.geoAmbiguous&&(s.geoAmbiguous=!0),I.geoKind.indexOf("country")===0)){let T=Ee(S);T&&(s.dominantGeoRegion=T.dominantGeoRegion,s.dominantGeoRegionPct=T.dominantGeoRegionPct,s.geoRegionCount=T.regionCount)}}}updateColumnStats10(e,t,i,r,s,o,l){let a=this._rows.length-i;e>=10&&(t.blankCount=a),t.distinctCount=r.size+(a!=0?1:0),t.valueNature="Categorical",i>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=Qt({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:r.size,nonblank:i,prec:s,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.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 t=new Set;for(let i of this._rows)t.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>Ke(o,{camel:!0}),t=-1,i=-1,r=-1;if(this._cols.forEach((o,l)=>{let a=e(o.name),u=o.dataType==="Integer"||o.dataType==="Decimal";u&&t<0&&a.some(m=>m==="lat"||m==="latitude")?t=l:u&&i<0&&a.some(m=>m==="lon"||m==="lng"||m==="long"||m==="longitude")&&(i=l),r<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(r=l)}),t<0||i<0)return null;let s=[];for(let o of this._rows){let l=o[t],a=o[i],u=l==null||l===""?null:Number(l),m=a==null||a===""?null:Number(a);s.push({lat:u,lon:m,country:r>=0&&Se(this.STR(o[r]))?this.STR(o[r]):null})}return this._geoExtent=gt(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return Lt(e,Je)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=t[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=t[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=t[r]);return i})}async getCSVAsync(e){let t=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,o=this.wallClockColumnIndexes();for(let a of this._rows){let u={};for(let m=0;m<this._cols.length;m++){let f=this._cols[m],c=a[m];if(this.STR(c)!=""){if(e&&f.dataType=="String")if(s.has(c))c=s.get(c);else{let S=this.obfuscateString(c);s.set(c,S),c=S}else if(f.dataType=="DateTime"&&!f.dateWithTime){let S=c instanceof Date?c:typeof c=="string"?Ne(c)??new Date(c):new Date(c);c=(this.wholeDayIso(S)??S.toISOString().slice(0,10))+"T00:00:00.000Z"}else o.has(m)&&c instanceof Date&&(c=fe(c));r-=this.STR(c).length}else c=null;u[m]=c,--r}if(t.push(u),--i,i<=0||r<=0)break}return await Yt.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Yt.unparse([this._cols.map((t,i)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=Le(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())t.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return t}armAliasesForCode(e){return this.emitLegacyAggAliases=Le(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let i=String(e),r=new Set;for(let o of this._cols)o&&(r.add(this.STR(o.name)),o.hostName&&r.add(this.STR(o.hostName)));let s=new Map;for(let o=0;o<this._cols.length;o++){if(!this._cols[o]||Rt(this._hostQueryNames[o],this._cols[o].name,this._cols[o].dataType))continue;let l=wt(this._hostQueryNames[o]).filter(a=>!r.has(a)&&ae(i,a));l.length===1&&s.set(l[0],[...s.get(l[0])??[],o])}for(let[o,l]of s){if(l.length!==1)continue;let a=this.STR(this._cols[l[0]].name);t.set(l[0],{name:a,alias:o,headerName:!ae(i,a)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,i]of this._englishAliases){let r=this._cols?this._cols[t]:null;r&&this.STR(r.name)===i.name&&e.set(t,i)}return e}addRow(e,t){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=qe(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(ri(e)),this._inferredMeasureFlags=null,this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let t=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Mt(r);!s||s===r||t.has(s)||(t.delete(r),t.add(s),i.hostName=r,i.name=s)}}};export{gt as a,tn as b,Se as c,oi as d,yt as e,gn as f,pn as g,hn as h,yn as i,xe as j,wn as k,Mt as l,Le as m,wt as n,Nt as o,Nn as p,vt as q,kt as r,fi as s,gi as t,pi as u,kn as v,Dn as w,On as x,Dt as y,ae as z,Hn as A,Ci as B,Yn as C,jn as D,j as E,Bt as F,ur as G,cr as H,mr as I,hr as J,$t as K,Ut as L,Oi as M,Re as N,Zt as O,ei as P,ti as Q,ni as R,Qt as S,jt as T,ri as U,Xt as V};
2
+ import{a as he}from"./chunk-U3H6UBOO.mjs";import{a as mt,f as te,g as ye,h as se,i as be,j as ie}from"./chunk-A4PQBWRA.mjs";import{c as ct}from"./chunk-IPPPCWAK.mjs";import{f as lt,k as ut}from"./chunk-INMDBTAR.mjs";import{e as rt,k as ge,m as ot,n as at,o as pe}from"./chunk-HJA26Z2E.mjs";import{A as fe,B as tt,E as nt,a as me,b as ee,c as Ke,d as de,g as He,h as Ye,j as je,l as Xe,m as Ze,o as Qe,p as Q,q as qe,r as Je,u as Ne,w as et}from"./chunk-CZJ7M6A5.mjs";import{c as Ve,f as Ie}from"./chunk-WC4JINEZ.mjs";import{b as it,d as st}from"./chunk-5HI6TVMM.mjs";var Jt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],en=[7,72,-172,-52];function dt(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var ne=n=>Math.round(n*10)/10;function gt(n,e=3){let t=[],i=[],r=0,s=0;for(let l of n){let a=l?.lat,u=l?.lon;if(typeof a!="number"||typeof u!="number"||!isFinite(a)||!isFinite(u)||a<-90||a>90||u<-180||u>180)continue;t.push(a),i.push(u);let m=l?.country?String(l.country).trim().toUpperCase():"",f=m?Se(m):null;f?((m==="US"||m==="USA")&&r++,f==="north-america"&&s++):(Jt.some(c=>dt(a,u,c))&&r++,dt(a,u,en)&&s++)}let o=t.length;return o<e?null:(t.sort((l,a)=>l-a),i.sort((l,a)=>l-a),{pctUsa:ne(r/o*100),pctNa:ne(s/o*100),latP5:ne(Q(t,.05)),latP95:ne(Q(t,.95)),lonP5:ne(Q(i,.05)),lonP95:ne(Q(i,.95)),n:o})}var ft={"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"},oe=(()=>{let n=new Map;for(let e of Object.keys(ft))for(let t of ft[e].split(/\s+/))t&&n.set(t,e);return n})();function tn(n){for(let[e,t]of n){let i=oe.get(e);i&&!oe.has(t)&&oe.set(t,i)}}tn(lt);function Se(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=oe.get(e);if(t)return t;let i=ut(String(n));return i?oe.get(i)??null:null}function oi(n,e=2){return Ee(n.map(t=>[t,1]),e)}function Ee(n,e=2){let t=new Map,i=0;for(let[o,l]of n){let a=Se(o);if(!a)continue;let u=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(a,(t.get(a)??0)+u),i+=u}if(i<e||!t.size)return null;let r="europe",s=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>s&&(r=o,s=l)}return{dominantGeoRegion:r,dominantGeoRegionPct:ne(s/i*100),regionCount:t.size,n:i}}function De(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var ve={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},nn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,rn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,sn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,on=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,an=new Set(["de","del","of"]),ln=new Set(["\u0433","\u0440","r"]),un=/^[\p{L}\p{M}\u0970\u05f3]+$/u,ke=/^\d+$/;function cn(n){let e=+n[1],t=+n[2],i=n[3]===void 0?0:+n[3],r=n[4]!==void 0;if(t>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(n[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:t,s:i,seconds:n[3]!==void 0,meridiem:r}}function pt(n){let e=n.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=mt(e);let t=null,i=nn.exec(e);if(i){if(t=cn(i),!t)return null;e=e.slice(0,i.index)}let r;if(r=sn.exec(e)){let c=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...ve,form:"cjk",key:c,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=rn.exec(e)){let c=r[2],S=r[4];if(c!==S)return null;let I=c.trim(),w=r[6];if(w&&I!==".")return null;let C=[r[1].length,r[3].length,r[5].length],g=C[0]===4,h=C[2]===4;return g===h||(g?C[1]>2||C[2]>2:C[0]>2||C[1]>2)?null:g&&I==="-"&&c==="-"&&C[1]===2&&C[2]===2?"iso":g&&I==="."&&c==="."&&!w&&!(C[1]===2&&C[2]===2)?null:{...ve,form:"numeric",key:`num|${g?"y":"x"}|${c}|${w}`,clock:t,a:+r[1],b:+r[3],c:+r[5],yearFirst:g,sep:c,trail:w}}let s=e.replace(on,"$1").split(/[\s.,/-]+/).filter(c=>c!==""&&!an.has(c.toLowerCase()));if(s.length===4&&ke.test(s[2])&&ln.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let o=s.map(c=>ke.test(c)?"N":un.test(c)?"W":"?").join(""),l=s.map(c=>ke.test(c)?c:""),a=0,u=0,m="",f;if(o==="NWN"&&l[0].length<=2&&l[2].length===4)a=+l[0],m=s[1],u=+l[2],f="dmy";else if(o==="WNN"&&l[1].length<=2&&l[2].length===4)m=s[0],a=+l[1],u=+l[2],f="mdy";else if(o==="NWN"&&l[0].length===4&&l[2].length<=2)u=+l[0],m=s[1],a=+l[2],f="ymd";else return null;return{...ve,form:"named",key:`named|${f}`,clock:t,day:a,year:u,word:m,namedOrder:f}}var mn=[31,28,31,30,31,30,31,31,30,31,30,31],dn=n=>n%4===0&&n%100!==0||n%400===0;function ht(n,e,t){return n>=1&&n<=9999&&e>=1&&e<=12&&t>=1?t<=(e===2&&dn(n)?29:mn[e-1]):!1}function fn(n,e,t,i){let r=new Date(Date.UTC(2e3,e-1,t,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(n),r}function yt(n,e={}){let t=(e.floor??1)>=1,i=new Map,r=new Map,s=0,o=null;for(let g of n){if(g==null)continue;if(typeof g!="string"){if(t)return null;s++;continue}let h=g.trim();if(h==="")continue;s++;let b=i.get(h);if(b===void 0&&(b=pt(h),i.set(h,b)),b===null||b==="iso"){if(t)return null;continue}if(t){if(o===null)o=b;else if(b.key!==o.key)return null}else r.set(b.key,(r.get(b.key)??0)+1)}if(!t){let g=0,h="";for(let[b,p]of r)p>g&&(g=p,h=b);if(g===0||g/s<e.floor)return null;o=[...i.values()].find(b=>b!==null&&b!=="iso"&&b.key===h)??null}if(o===null)return null;let l=o.key,a=[...i.values()].filter(g=>g!==null&&g!=="iso"&&g.key===l),u,m="shape",f=null;if(o.form==="named"){if(u=o.namedOrder,f=be(a.map(g=>g.word),e.locale),!f)return null}else if(o.form==="cjk"||o.yearFirst)u="ymd";else{let g=0,h=0;for(let b of a)b.a>12&&g++,b.b>12&&h++;if(g>0&&h>0)return null;g>0?(u="dmy",m="values"):h>0?(u="mdy",m="values"):o.sep.trim()==="."?(u="dmy",m="shape"):(u=De(e.locale)?"mdy":"dmy",m="locale")}let c=g=>{if(g.form==="named"){let h=f.get(te(g.word));return h===void 0?null:[g.year,h+1,g.day]}return g.yearFirst?[g.a,g.b,g.c]:u==="dmy"?[g.c,g.b,g.a]:[g.c,g.a,g.b]},S=1/0,I=-1/0,w=0;for(let g of a){let h=c(g);if(!h||!ht(h[0],h[1],h[2])){if(t)return null;w++;continue}S=Math.min(S,h[0]),I=Math.max(I,h[0])}if(!t&&(r.get(l)-w)/s<e.floor||S>=2400&&I<=2699||S>=1300&&I<=1500)return null;let C={form:o.form,order:u,orderFrom:m,hasTime:a.some(g=>g.clock!==null),read(g){if(typeof g!="string")return null;let h=g.trim();if(h==="")return null;let b=i.get(h);if(b===void 0&&(b=pt(h),i.set(h,b)),b===null||b==="iso"||b.key!==l)return null;let p=c(b);return!p||!ht(p[0],p[1],p[2])?null:fn(p[0],p[1],p[2],b.clock)}};if(o.form!=="named"&&!a.some(g=>g.clock?.meridiem)){let g;o.form==="cjk"?g=o.cjkPattern:o.yearFirst?g=`%Y${o.sep}%m${o.sep}%d${o.trail}`:g=(u==="dmy"?`%d${o.sep}%m${o.sep}%Y`:`%m${o.sep}%d${o.sep}%Y`)+o.trail;let h=a.filter(b=>b.clock!==null).length;h===0?C.pattern=g:h===a.length&&(C.pattern=g+(a.every(b=>b.clock.seconds)?" %H:%M:%S":" %H:%M"))}return C}import Yt from"papaparse";var gn=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","capita","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],pn=["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"],hn=["latitude","longitude"],yn=["latitude","longitude"];function q(n){return me(n)}var _t=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],bn=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Sn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],_n=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],_e=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function Oe(n){return[...n].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var At=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Oe(_t)+")\\s+)","i");function bt(n){for(let e of n){let t=e.codePointAt(0)??0;if(t>=11904&&t<=40959||t>=44032&&t<=55215)return!0}return!1}var An="[\u2013\u2014-]";function Ct(n){let e=n.filter(r=>!bt(r)),t=n.filter(bt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+An+"\\s*)("+Oe(e)+")"),t.length&&i.push("\\s*("+Oe(t)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Pe=Ct(Sn),Cn=Ct(_n);function Ae(n,e){let t=e.exec(n);if(!t)return null;let i=n.slice(0,t.index);return i.trim()===""?null:{base:i,label:(t[1]??t[2]??"").toLowerCase()}}function xt(n){let e=q(String(n??"").trim().toLowerCase());if(!e)return null;for(let r of bn)if(e.startsWith(r+" "))return _e[r]??"avg";for(let r of _t)if(e.startsWith(r+" ")||e===r)return _e[r]??"sum";let t=Ae(e,Cn);if(t)return _e[t.label]??"avg";let i=Ae(e,Pe);return i?_e[i.label]??"sum":null}var xn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Mn=new RegExp("\\b("+gn.join("|")+")\\b|("+pn.join("|")+")$","i"),Tn=new RegExp("\\b("+hn.join("|")+")\\b|("+yn.join("|")+")$","i");function xe(n){if(!n)return"";let e=String(n),t=q(e),i=At.exec(t);if(i)return e.slice(i[0].length).trim();let r=Ae(t,Pe);return(r?e.slice(0,r.base.length):e).trim()}function wn(n){if(!n)return!1;let e=q(String(n));return At.test(e)||Ae(e,Pe)!==null}var Rn=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],St=new RegExp("^\\s*("+[...Rn].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Mt(n){if(n==null)return"";let e=String(n),t=St.exec(e);if(!t)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(t[1]),s=e.slice(t[0].length),o=0;for(;o<8;){let l=St.exec(s);if(!l||i(l[1])!==r)break;let a=s.slice(l[0].length);if(a.trim()==="")break;s=a,o++}return o===0?e:e.slice(0,t[0].length)+s}function Le(n,e){if(!n||!e)return!1;let t=String(n);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&t.includes(r))return!0}return!1}var Ce={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 "]},Tt=new RegExp("^("+Object.keys(Ce).join("|")+")\\((.+)\\)$");function wt(n){if(!n)return[];let e=Tt.exec(String(n).trim());if(!e)return[];let t=Ce[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let o=i.slice(s+1);if(o.trim()!=="")for(let l of t){let a=l+o;r.includes(a)||r.push(a)}}return r}function Rt(n,e,t){let i=Tt.exec(String(n??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&t==="Decimal")return!0;let s=new Set(Ce[r]),o=String(e??""),l=i[2];for(let a=l.indexOf(".");a>=0;a=l.indexOf(".",a+1)){if(a===0)continue;let u=l.slice(a+1);if(u.trim()!==""){for(let m of Object.values(Ce))for(let f of m)if(!s.has(f)&&o===f+u)return!0}}return!1}function In(n){let e=xe(n);return e.length===0?"":e.replace(xn," ")}function It(n,e){if(!e)return!1;let t=xe(e);return n.test(q(In(e)))||n.test(q(t))||n.test(q(ee(t).join(" ")))}function Nt(n){return It(Tn,n)}function Nn(n){return It(Mn,n)||Nt(n)}var Et=/int|double|decimal|single|float|number|currency|money/i;function En(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||Et.test(String(n?.dataType??""))?"Continuous":"Categorical"}function vn(n){return n?.isMeasure===!0||Et.test(String(n?.dataType??""))}function vt(n){let e=n??{},t=En(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(Nt(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&wn(e.name))){if(i==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Nn(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function kt(n){let e=vt(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return vn(t)?["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 fi(n){return kt(n)[0]}function gi(n,e){return kt(n).indexOf(e)>=0}function pi(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=vt(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var kn={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"]},Dn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],On=["num\xE9ro"],Pn=n=>n.normalize("NFC").toLowerCase();function Ln(n,e,t,i){let r=Ie(t);return!r||!n?null:n===e?"word":r.wordBreaks===!1?Array.from(e).length<Ze?null:(i?n.startsWith(e):n.endsWith(e))&&n.length>e.length?"suffix":null:i?je(n,t).includes(e)?"word":null:r.script==="Hang"?Xe(n,e)?"suffix":null:r.compounds&&Ye(n,e,He)?"suffix":null}function Dt(n){let e=String(n??"").trim();if(!e)return null;let t=de(e),i=de(xe(e));for(let[r,s]of Object.entries(kn)){let o=Dn.includes(r),l=o?i:t;for(let a of s){let u=On.includes(a)||!!Ie(r)?.foldSensitive,m=u?l.words:l.folded;if(m.length===0)continue;let f=u?Pn(a):de(a).folded.join(" "),c=Ln(o?m[0]:m[m.length-1],f,r,o);if(c)return{lang:r,word:a,view:c}}}return null}var Fn=[["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 Me(n){for(let[e,t]of Fn)if(t.test(n))return e;return null}var Wn=[{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]]}],Te=new Map;function Ot(n,e,t,i){let r=Te.get(n);if(r)return r;let s=[];for(let[o,l]of e)for(let a=o;a<=l;a++){let u=String.fromCodePoint(a);Me(u)===t&&(i&&!i.test(u)||s.push(u))}return Te.set(n,s),s}function Bn(n){let t=n.codePointAt(0);for(let o=0;o<9&&Me(String.fromCodePoint(t-1))==="Nd";o++)t--;let i="nd:"+t.toString(16),r=Te.get(i);if(r)return r;let s=[];for(let o=t;o<t+10;o++){let l=String.fromCodePoint(o);Me(l)==="Nd"&&s.push(l)}return Te.set(i,s),s}function Gn(n,e){if(e==="Nd")return Bn(n);for(let r of Wn)if(r.test.test(n))return Ot(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=n.codePointAt(0)&-128;return Ot("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function zn(n,e,t,i){let r=n.filter(s=>!e.has(s));return r.length===0&&(r=n.filter(s=>s!==t)),r.length===0?t:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var $n=/^[\p{L}\p{M}\p{Nd}]$/u,Pt=/^[\p{L}\p{Nd}]$/u;function Lt(n,e){if(!n)return n??"";let t=new Set(Array.from(n)),i=m=>{let f=Me(m);return!f||!$n.test(m)?m:zn(Gn(m,f),t,m,e)},r=m=>{let f=[];for(let c of m)f.push(i(c)),Pt.test(c)&&e()<.2&&f.push(i(c));if(f.length>6){let c=Math.floor(e()*Math.min(3,f.length-6));for(let S=0;S<c;S++)for(let I=0;I<5;I++){let w=Math.floor(e()*f.length);if(Pt.test(f[w])){f.splice(w,1);break}}}return f.join("")};if(!(n.includes("@")&&n.includes(".")))return r(n);let[o,l=""]=n.split("@"),a=l.endsWith(".com"),u=a?l.slice(0,-4):l;return`${r(o)}@${r(u)}${a?".com":""}`}var Un=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Vn=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Kn=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function ae(n,e){if(!n||!e)return!1;let t=Vn(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:Un.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function Hn(n){return!!n&&Kn.test(n)}function Ci(n,e,t){return n?Hn(n)?[...e]:[...t,...e].some(i=>ae(n,i))?e.filter(i=>ae(n,i)):[...e]:[]}var Yn=5,jn=6,Xn=3,re=864e5,Zn=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Qn=/^(\d{4})[-/](\d{1,2})$/,qn=/^(\d{4})[-\s]?Q([1-4])$/i,Jn=/^Q([1-4])[-\s](\d{4})$/i,er=/^(\d{4})$/,tr=/^(\d{4})(0[1-9]|1[0-2])$/,nr=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,rr=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,ir=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Fe(n,e,t){let i=te(n);if(!i)return 0;if(i==="sept")return 9;for(let o of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=ye(o)[i];if(l!==void 0)return l+1}let r=t?.get(i);if(r!==void 0)return r+1;let s=se(n);if(s.length>0){if(s.every(a=>a.month===s[0].month))return s[0].month+1;let o=Ve(String(e??"").split(/[-_]/)[0])?.code,l=s.find(a=>a.lang===o);if(l)return l.month+1}return 0}function sr(n){let e=ge(n).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let t=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==t.n||i.year!==t.year)?null:H(t.year,(t.n-1)*3+1,1)}function H(n,e,t,i=0,r=0,s=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,i,r,s);if(!Number.isFinite(o))return null;let l=a=>a<10?"0"+a:String(a);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function or(n,e){let t=[],i="";for(let a=0;a<e.length;a++){if(e[a]!=="%"){i+=e[a].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++a]){case"Y":t.push("Y"),i+="(\\d{4})";break;case"m":t.push("m"),i+="(\\d{1,2})";break;case"d":t.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(n);if(!r)return null;let s=0,o=1,l=1;return t.forEach((a,u)=>{let m=+r[u+1];a==="Y"?s=m:a==="m"?o=m:l=m}),s?H(s,o,l):null}function j(n,e,t,i){let r=(n??"").trim();if(r==="")return null;if(e){let a=or(r,e);return a||null}let s=Zn.exec(r);if(s)return H(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=qn.exec(r),s)return H(+s[1],(+s[2]-1)*3+1,1);if(s=Jn.exec(r),s)return H(+s[2],(+s[1]-1)*3+1,1);if(s=Qn.exec(r),s&&+s[2]>=1&&+s[2]<=12)return H(+s[1],+s[2],1);if(s=nr.exec(r),s)return H(+s[1],+s[2],+s[3]);if(s=tr.exec(r),s)return H(+s[1],+s[2],1);if(s=er.exec(r),s){let a=+s[1];return a>=1900&&a<=2100?H(a,1,1):null}let o=sr(r);if(o)return o;if(s=rr.exec(r),s){let a=Fe(s[1],t,i);if(a)return H(+s[2],a,1)}if(s=ir.exec(r),s){let a=Fe(s[2],t,i);if(a)return H(+s[1],a,1)}let l=ie(r);if(l){let a="month"in l?l.month:Fe(l.word,t,i);if(a)return H(l.year,a,1)}return null}function Ft(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function Wt(n,e){if(e<=n)return 0;let t=Math.round((e-n)/re),i=Math.floor(t/7),r=i*5,s=n+i*7*re;for(;s<e;)Ft(s)&&r++,s+=re;return r}function ar(n){if(n.length===0)return 0;let e=[...n].sort((i,r)=>i-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function lr(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function le(n,e,t,i){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*re));case"weekday":return Wt(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/re);default:return i>0?Math.round((e.ms-n.ms)/i):0}}function Bt(n,e){return We(n,e)?.cadence??null}function We(n,e){let t=e?.gapFactor??Yn,i=0,r=0,s=new Map,o=Array.from(n),l;if(!e?.pattern){let p=[];for(let _ of o){if(_==null||_==="")continue;let y=ie(String(_));y&&"word"in y&&p.push(y.word)}p.length>0&&(l=be(p,e?.locale)??void 0)}for(let p of o){if(p==null||p==="")continue;i++;let _=j(String(p),e?.pattern,e?.locale,l);_&&(r++,s.set(_.ms,_))}let a=[...s.values()].sort((p,_)=>p.ms-_.ms);if(a.length<Xn||i>0&&r/i<.8)return null;let u=a[a.length-1].ms-a[0].ms;if(u<=0)return null;let m=[];for(let p=1;p<a.length;p++)m.push(a[p].ms-a[p-1].ms);let f=ar(m);if(!(f>0))return null;let c=lr(f/re);c==="day"&&u>=7*re&&a.every(p=>Ft(p.ms))&&Wt(a[0].ms,a[a.length-1].ms)+1>a.length*.5&&(c="weekday");let S=c==="irregular"?a.length:le(a[0],a[a.length-1],c,f)+1,I=1,w=1,C=[],g=a[0],h=1;for(let p=1;p<a.length;p++){let _=le(a[p-1],a[p],c,f);_>I&&(I=_),c!=="irregular"&&_>t?(w++,C.push({from:g.iso,to:a[p-1].iso,points:h}),g=a[p],h=1):h++}C.push({from:g.iso,to:a[a.length-1].iso,points:h});let b={grain:c,points:a.length,expectedPoints:Math.max(S,a.length),coveragePct:Math.round(a.length/Math.max(S,a.length)*1e3)/10,runs:w,largestGapUnits:I,gapFactor:t};return e?.includeBounds&&C.length<=jn&&(b.runBounds=C),{cadence:b,points:a,stepMs:f}}var ur=8,cr=.5,mr=200,dr=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"]),fr=["category","classification","segment","status","priority","severity","channel"],gr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function pr(n){let e=ee(n);if(e.length===0)return!1;let t=e[e.length-1];return dr.has(t)?!0:fr.some(i=>t.length>i.length&&t.endsWith(i))}function hr(n){if(n.isMeasure)return"measure";if(n.isTemporal||n.isDatePart||n.isReassembledDate)return"temporal";let e=Array.from(n.values).filter(t=>t!==""&&t!==null&&t!==void 0);return e.length<2||e.length>mr?"cardinality":n.rows>0&&e.length>=n.rows?"row-identity":n.isBinaryFlag?"flag":pe(e,n.locale)!==null?"ordinal":n.identifierNamed||n.dataType==="String"&&gr.has(he(e))?"identifier":!n.geoKind&&pr(n.name)?"attribute":"entity"}function $t(n){let e=-1,t=1/0,i=!1;return n.forEach((r,s)=>{if(hr(r)!=="entity")return;let o=new Set(Array.from(r.values).filter(a=>a!=="")).size,l=!!r.geoKind;(o<t||o===t&&l&&!i)&&(e=s,t=o,i=l)}),e}var Gt=n=>n<10?"0"+n:String(n);function zt(n,e){switch(e){case"year":return`${n.y}-01-01`;case"quarter":return`${n.y}-${Gt(Math.floor((n.m-1)/3)*3+1)}-01`;case"month":return`${n.y}-${Gt(n.m)}-01`;case"hour":return new Date(n.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return n.iso}}function Ut(n){let{periods:e,series:t}=n,i=Math.min(e.length,t.length),r=new Set;for(let _=0;_<i;_++)e[_]&&r.add(e[_]);let s=We(r,{pattern:n.pattern,locale:n.locale});if(!s)return null;let o=s.cadence.grain;if(o==="irregular")return null;let l=s.points[0],a=le(l,s.points[s.points.length-1],o,s.stepMs)+1;if(a!==s.cadence.expectedPoints)return null;let u=new Map;for(let _ of r){let y=j(_,n.pattern,n.locale);if(!y)continue;let x=le(l,y,o,s.stepMs);x>=0&&x<a&&u.set(_,{idx:x,stamp:y})}let m=new Map;for(let _=0;_<i;_++){let y=t[_];if(!y)continue;let x=u.get(e[_]);if(!x)continue;let T=m.get(y);T||(T={seen:new Set,lo:x.idx,hi:x.idx,loStamp:x.stamp,hiStamp:x.stamp,order:m.size},m.set(y,T)),T.seen.add(x.idx),x.idx<T.lo&&(T.lo=x.idx,T.loStamp=x.stamp),x.idx>T.hi&&(T.hi=x.idx,T.hiStamp=x.stamp)}if(m.size<2)return null;let f=0;for(let _ of m.values())f+=_.seen.size;if(f/(m.size*a)<(n.minFill??cr))return null;let c=[],S=new Set,I=0,w=0,C=0,g=0,h=0,b=1;for(let[_,y]of m){for(let $ of y.seen)S.add($);if(y.seen.size>=a)continue;let x=[...y.seen].sort(($,X)=>$-X),T=1;for(let $=1;$<x.length;$++)T=Math.max(T,x[$]-x[$-1]);let V={key:_,acc:y,coverage:y.seen.size/a,before:y.lo,after:a-1-y.hi,interior:y.hi-y.lo+1-y.seen.size,gap:T};c.push(V),V.before>0&&I++,V.after>0&&w++,V.interior>0&&C++,g=Math.max(g,V.before),h=Math.max(h,V.after),b=Math.max(b,T)}if(c.length===0)return null;c.sort((_,y)=>_.coverage-y.coverage||_.acc.order-y.acc.order);let p=c.slice(0,n.maxListed??ur);return{seriesColumn:n.seriesColumn,grain:o,periods:a,seriesCount:m.size,incompleteSeries:c.length,lateStarts:I,earlyEnds:w,withHoles:C,columnWideMissing:a-S.size,maxMissingBefore:g,maxMissingAfter:h,largestGap:b,series:p.map(_=>{let y={};return n.includeNames&&(y.name=_.key),n.includeDates&&(y.first=zt(_.acc.loStamp,o),y.last=zt(_.acc.hiStamp,o)),y.missingBefore=_.before,y.missingAfter=_.after,y.missingInterior=_.interior,y.largestGap=_.gap,y.coverage=Math.round(_.coverage*1e3)/1e3,y}),more:c.length-p.length}}var we=6;function ue(n){let e=n.slice().sort((i,r)=>i-r),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function yr(n){let e=n.length;if(e<we)return null;let t=n[0],i=n[0],r=0;for(let p of n)p<t&&(t=p),p>i&&(i=p),r+=p;if(t===i)return null;let s=ue(n.map(Math.abs));if(s===0)return null;let o=[];for(let p=1;p<e;p++)o.push(n[p]-n[p-1]);let l=ue(o.map(Math.abs))/s,a=(e-1)/2,u=r/e,m=0,f=0,c=0;for(let p=0;p<e;p++)m+=(p-a)*(n[p]-u),f+=(p-a)*(p-a),c+=(n[p]-u)*(n[p]-u);c/=e;let S=m/f,I=u-S*a,w=n.map((p,_)=>p-(I+S*_)),C=w.reduce((p,_)=>p+_,0)/e,g=0,h=0;for(let p=0;p<e;p++)g+=(w[p]-C)*(w[p]-C),p>0&&(h+=(w[p]-w[p-1])*(w[p]-w[p-1]));return g/=e,h/=e-1,{vnDetrended:g<=c*1e-12?2:h/g,relStep:l}}function Be(n){let{stamps:e,series:t,values:i}=n,r=Math.min(e.length,i.length),s=new Map;for(let u=0;u<r;u++){let m=e[u],f=i[u];if(m===null||f===null||!Number.isFinite(f))continue;let c="";if(t&&(c=t[u]??"",c===""))continue;let S=s.get(c);S||s.set(c,S=new Map),S.set(m,(S.get(m)??0)+f)}let o=[],l=[],a=[];for(let u of s.values()){let m=[...u.entries()].sort((c,S)=>c[0]-S[0]).map(c=>c[1]),f=yr(m);f&&(o.push(f.vnDetrended),l.push(f.relStep),a.push(m.length))}return o.length===0?null:{series:o.length,points:Math.round(ue(a)),vnDetrended:Math.round(ue(o)*1e3)/1e3,relStep:Math.round(ue(l)*1e4)/1e4}}function Oi(n){let e=n.times.map(t=>j(t,n.pattern,n.locale)?.ms??null);return Be({stamps:e,series:n.series,values:n.values})}var br=5e5,Sr=8,_r=4,Ar=5,Ge=1,ze=2,Cr=4,xr=8;function Mr(n,e,t){let[i,r]=[...n];if(e.isTemporal){let s=j(i,e.temporalTextPattern,t),o=j(r,e.temporalTextPattern,t);if(s&&o&&s.ms!==o.ms)return s.ms<o.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Tr(n,e,t){let{rows:i,text:r,locale:s}=n,o=Mr(t.values,t,s),l=new Uint8Array(i.length),a=0;for(let u=0;u<i.length;u++){let m=r(i[u][e]);m===o.a?l[u]=1:m===o.b?l[u]=2:a++}return{code:l,blankRows:a,setOrder:o.setOrder}}function wr(n,e){let{rows:t,text:i}=n,r=new Int32Array(t.length),s=new Map;for(let o=0;o<t.length;o++){let l=i(t[o][e]);if(l===""){r[o]=-1;continue}let a=s.get(l);a===void 0&&(a=s.size,s.set(l,a)),r[o]=a}return{ids:r,dict:s}}function Rr(n,e,t){let i=new Uint8Array(t);for(let s=0;s<n.length;s++){let o=e[s];if(o===0)continue;let l=n[s];if(l<0)continue;let a=i[l];i[l]=a&o?a|o<<2:a|o}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<t;s++){let o=i[s];o&Ge&&r.keysA++,o&ze&&r.keysB++,(o&(Ge|ze))===(Ge|ze)&&r.keysBoth++,o&Cr&&r.dupA++,o&xr&&r.dupB++}return r}function Ir(n,e){let t=(n.dupA+n.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(n.keysA+n.keysB);return t<i||t===i&&n.keysBoth>e.keysBoth}var Vt=n=>n==null||typeof n=="string"&&n.trim()==="";function Nr(n,e,t){if(n===e)return!0;let i=Vt(n),r=Vt(e);return i||r?i&&r:typeof n=="number"&&typeof e=="number"?!1:n instanceof Date&&e instanceof Date?n.getTime()===e.getTime():t(n).trim()===t(e).trim()}function Kt(n){let{rows:e,columns:t}=n,i=e.length;if(i<2||i>br)return null;let r=t.map((y,x)=>({c:y,i:x})).filter(({c:y})=>!y.isMeasure&&!y.isTemporal&&!y.isDatePart&&y.distinct>=Ar).sort((y,x)=>(x.c.identifierNamed?1:0)-(y.c.identifierNamed?1:0)||x.c.distinct-y.c.distinct||y.i-x.i).slice(0,Sr),s=t.map((y,x)=>({c:y,i:x})).filter(({c:y})=>!y.isMeasure&&y.values!==null&&y.values.size===2).slice(0,_r);if(r.length===0||s.length===0)return null;let o=s.map(({c:y,i:x})=>Tr(n,x,y)),l=null;for(let{i:y}of r){let x=wr(n,y);for(let T=0;T<s.length;T++){if(s[T].i===y)continue;let V=Rr(x.ids,o[T].code,x.dict.size);V.keysBoth<1||(!l||Ir(V,l.tally))&&(l={tally:V,keyIdx:y,setNo:T,ids:x.ids,dict:x.dict})}}if(!l)return null;let{ids:a,dict:u,tally:m}=l,f=o[l.setNo],c=s[l.setNo].i,S=u.size,I=new Int32Array(S).fill(-1),w=new Int32Array(S).fill(-1);for(let y=0;y<i;y++){let x=f.code[y],T=a[y];x===0||T<0||(x===1?I[T]<0&&(I[T]=y):w[T]<0&&(w[T]=y))}let C=[];for(let y=0;y<t.length;y++)y!==l.keyIdx&&y!==c&&C.push(y);let g=0;for(let y=0;y<S;y++){let x=I[y],T=w[y];if(x<0||T<0)continue;let V=e[x],$=e[T],X=!0;for(let J of C)if(!Nr(V[J],$[J],n.text)){X=!1;break}X&&g++}let h=g===m.keysBoth?100:g===0?0:Math.min(99,Math.max(1,Math.round(g/m.keysBoth*100))),b=new Map,p=new Map;for(let[y,x]of u){let T=I[x]>=0,V=w[x]>=0;if(!T&&!V)continue;let $=it(y);st($)&&(T&&b.set($,(b.get($)??0)+1),V&&p.set($,(p.get($)??0)+1))}let _=y=>{let x=0;for(let T of y.values())T>=2&&(x+=T);return x};return{key:l.keyIdx,discriminator:c,pairing:{form:"long",key:t[l.keyIdx].name,discriminator:t[c].name,keysA:m.keysA,keysB:m.keysB,keysBoth:m.keysBoth,duplicateKeysA:m.dupA,duplicateKeysB:m.dupB,identicalPct:h,discriminatorBlankRows:f.blankRows,looseCollisionsA:_(b),looseCollisionsB:_(p),setOrder:f.setOrder}}}var Er=n=>n==="Integer"||n==="Decimal";function vr(n){let e=[],t=[];return n.forEach((i,r)=>{if(i.twoValues){if(i.isBinaryFlag){e.push(r);return}i.isMeasure||i.isTemporal||i.isDatePart||i.identifierNamed||t.push(r)}}),[...e,...t].slice(0,6)}function kr(n,e){let t=[];for(let i=0;i<n.length&&t.length<12;i++){let r=n[i];e.has(i)||!Er(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||t.push(i)}return t}function Ht(n){let e=new Map,{rows:t,columns:i,text:r}=n;if(t.length===0||t.length>(n.maxRows??5e5))return e;let s=vr(i);if(s.length===0)return e;let o=kr(i,new Set(s));if(o.length===0)return e;let l=s.map(a=>{let[u,m]=i[a].twoValues,f=new Uint8Array(t.length);for(let c=0;c<t.length;c++){let S=r(t[c][a]);f[c]=S===u?1:S===m?2:0}return f});for(let a of o){let u=new Float64Array(t.length),m=0;for(let h=0;h<t.length;h++){let b=t[h][a],p=b==null||b===""?NaN:typeof b=="number"?b:parseFloat(b);u[h]=p,p===p&&p!==1/0&&p!==-1/0&&m++}if(m<2)continue;let f=new Float64Array(m);for(let h=0,b=0;h<t.length;h++){let p=u[h];p===p&&p!==1/0&&p!==-1/0&&(f[b++]=p)}f.sort();let c=new Float64Array(m),S=0;for(let h=0;h<m;h++)(h===0||f[h]!==f[h-1])&&(c[S++]=f[h]);let I=new Int32Array(t.length).fill(-1);for(let h=0;h<t.length;h++){let b=u[h];if(!(b===b&&b!==1/0&&b!==-1/0))continue;let p=0,_=S-1;for(;p<_;){let y=p+_>>>1;c[y]<b?p=y+1:_=y}I[h]=p}let w=[],C=new Int32Array(S),g=new Int32Array(S);for(let h=0;h<s.length;h++){let b=l[h];C.fill(0),g.fill(0);let p=0,_=0;for(let d=0;d<t.length;d++){let A=I[d];A<0||(b[d]===1?(C[A]++,p++):b[d]===2&&(g[A]++,_++))}if(p===0||_===0)continue;let y=p<=_,x=y?p:_,T=y?_:p,V=y?C:g,$=y?g:C,X=0,J=0,Y=0;for(let d=0;d<S;d++){let A=V[d],F=$[d];X+=A*(J+.5*F),J+=F,A+F>=2&&(Y+=A+F)}w.push({outcome:i[s[h]].name,aucMinorityHigh:Math.round(X/(x*T)*1e4)/1e4,nMinority:x,nMajority:T,ties:Y})}w.length>0&&e.set(a,w)}return e}var Dr=12,Or=100,Pr=.3,Lr=.9,Fr=120,Wr=1900,Br=2100,Gr=0,zr=20,$r=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Re(n){if(!n)return!1;let e=ee(n);return e.length===0?!1:$r.has(e[e.length-1])?!0:Dt(n)!==null}var Ur=new Set(["year","yr","fy"]),Vr=n=>ee(n).some(e=>Ur.has(e))||rt(n)!==null,Kr=/^(?:(?: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 $e(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function Ue(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var Hr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Yr=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,jr=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Zt(n,e){let t=[],i=0,r=Xr(n,e,t,()=>{i++});if(r)return r;if(i>0||t.length<2)return null;let s=yt(t,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function Xr(n,e,t,i){let r=0,s=0,o=0,l=0,a=0,u="",m=0,f="",c=0,S=0,I=0,w=0,C=!1;for(let y of n){if(y==null)continue;let x=String(y).trim();if(x==="")continue;r++,t.push(x);let T;if(T=Hr.exec(x)){i();let V=+T[2],$=+T[3];V>=1&&V<=12&&$>=1&&$<=31&&(s++,T[4]!==void 0&&o++,T[6]!==void 0&&l++)}else if(T=Yr.exec(x)){i();let V=+T[3],$=+T[4];V>=1&&V<=12&&$>=1&&$<=31&&(u&&u!==T[2]&&(C=!0),u=T[2],a++)}else if(T=jr.exec(x)){i();let V=+T[1],$=+T[3];V>=1&&V<=31&&$>=1&&$<=31&&(V<=12||$<=12)&&(f&&f!==T[2]&&(C=!0),f=T[2],m++,V>12&&I++,$>12&&w++,T[5]!==void 0&&c++,T[7]!==void 0&&S++)}if(r>=200)break}if(r<2||(s+a+m)/r<.8||(s>0?1:0)+(a>0?1:0)+(m>0?1:0)!==1||C)return null;if(s>0)return o===s?{pattern:l===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(a>0)return{pattern:`%Y${u}%m${u}%d`,orderFrom:"iso"};if(I>0&&w>0)return null;let b,p;I>0?(b=!0,p="values"):w>0?(b=!1,p="values"):f==="."?(b=!0,p="shape"):(b=!De(e),p="locale");let _=b?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return c===m?{pattern:_+(S===m?" %H:%M:%S":" %H:%M"),orderFrom:p}:{pattern:_,orderFrom:p}}function Zr(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let i=te(t);return i.length>0&&e[i]!==void 0}function Qr(n,e){let t=new Map,i=new Map;for(let l of n){let a=ie(l);if(!a||"month"in a)continue;let u=se(a.word),m=u.some(c=>c.lang==="en"),f=te(a.word);for(let c of new Set(u.map(S=>S.lang)))c!=="en"&&(t.has(c)||(t.set(c,new Set),i.set(c,new Set)),t.get(c).add(f),m||i.get(c).add(f))}let r=[...t.keys()].filter(l=>t.get(l).size>=3&&i.get(l).size>=1),s=0,o=new Map(r.map(l=>[l,0]));for(let l of e){let a=ie(l);if(!a)continue;if("month"in a){s++;continue}let u=se(a.word);if(u.length===0)continue;let m=u.some(f=>f.lang==="en");for(let f of r)(m||u.some(c=>c.lang===f))&&o.set(f,o.get(f)+1)}return s+Math.max(0,...o.values())}var qr=/(?:19|20)[0-9]{2}/;function Jr(n){let e=new Map,t=0;for(let r of n){if(!qr.test(me(r)))continue;let s=new Set(ge(r).filter(o=>o.yearDigits===4&&(o.grain==="quarter"||o.grain==="week")).map(o=>o.lang));if(s.size!==0){if(s.has("en")){t++;continue}for(let o of s)e.set(o,(e.get(o)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+t:0}function ei(n){let{dataType:e,name:t,isMeasure:i,distinctCount:r}=n;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=n.minNum,o=n.maxNum;if(!(s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&Number.isInteger(s)&&Number.isInteger(o)&&o>=s))return!1;let a=s>=1900&&o<=2100;if(a&&r>=2&&Vr(t)||a&&r>=3&&r===o-s+1)return!0;let u=$e(s)&&$e(o),m=Ue(s)&&Ue(o);if(u||m){if(!n.sampleValues)return!0;let f=0,c=0;for(let S of n.sampleValues){if(S==null||S==="")continue;f++;let I=Number(String(S).trim());if(Number.isFinite(I)&&(u?$e(I):Ue(I))&&c++,f>=60)break}if(f>=2&&c===f)return!0}return!1}if(n.sampleValues){let s=n.locale?ye(n.locale):null,o=0,l=0,a=[],u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;o++;let f=String(m).trim();if(a.push(f),Kr.test(f)||Zr(f,s)?l++:u.push(f),o>=60)break}if(o>=2&&l/o>=.8||o>=2&&(l+Jr(u)+Qr(a,u))/o>=.8||Zt(a,n.locale)!==null)return!0}return!1}function ti(n){let e=q((n||"").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":xt(n)}function ni(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:r,minNum:s,maxNum:o,discourageAgg:l}=n,a=100,u=.01,m="";for(let c of r){if(c.distinct<2||c.distinct>a)continue;let S=r.filter(h=>h.idx!==c.idx).map(h=>h.idx),I=new Map;for(let h of e){let b=h[t];if(typeof b!="number"||!Number.isFinite(b))continue;let p=S.length?S.map(y=>String(h[y])).join(m):"",_=I.get(p);_||(_={sum:0,cset:new Set},I.set(p,_)),_.sum+=b,_.cset.add(String(h[c.idx]))}let w=0,C=0,g=0;for(let h of I.values())h.cset.size<2||(g++,Math.abs(h.sum-100)<=100*u?w++:Math.abs(h.sum-1)<=1*u&&C++);if(g>=2&&(w/g>=.9||C/g>=.9))return{additivity:"part_of_whole",partOfWholeDim:c.name}}if(l)return{additivity:"intensive_rate"};let f=ti(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&o!=null&&Number.isFinite(s)&&Number.isFinite(o)&&s>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function Qt(n){let{dataType:e,isMeasure:t,name:i,distinct:r,nonblank:s,prec:o,maxval:l,minval:a}=n,u=l-a+1,m=u>0?r/u:1,f=s>0?r/s:0,c=e==="Decimal"||o>0;return!t&&Re(i)?"Categorical":m>=Lr&&(ot(i)&&r<=Fr||a>=Wr&&l<=Br||a>=Gr&&l<=zr)?"Ordinal":t||r>Dr&&(c||r>=Or||f>=Pr)?"Continuous":"Categorical"}function jt(n,e,t){return!n||n.isMeasure||e||n.dataType!=="Integer"&&n.dataType!=="Decimal"?!1:Qt({dataType:n.dataType,isMeasure:!1,name:n.name,distinct:t.distinct,nonblank:t.nonblank,prec:t.prec,maxval:typeof t.maxval=="number"?t.maxval:0,minval:typeof t.minval=="number"?t.minval:0})==="Continuous"}function ri(n){let e=null;for(let t=0;t<n.length;t++){let i=n[t];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=n.slice()),e[t]=r)}return e||n}var Xt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;dedupRows=!0;emitLegacyAggAliases=!1;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let t=0;t<this._cols.length;t++){let i=this._cols[t];!i||!/date|time/i.test(String(i.dataType??""))||tt(this._rows.map(r=>r[t]))&&e.add(t)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(t=>!!(t&&t.isMeasure));return this._cols.forEach((t,i)=>{if(!t||t.isMeasure||this._declaredDimensions.has(t)||t.dataType!=="Integer"&&t.dataType!=="Decimal")return;let r=new Set,s=0,o=0,l=null,a=null;for(let u of this._rows){let m=u[i],f=this.STR(m);if(f!=""&&(r.add(f),s++,(l===null||m<l)&&(l=m),(a===null||m>a)&&(a=m),t.dataType=="Decimal")){let c=this.getPrecision(m);c>o&&(o=c)}}e[i]=jt(t,!1,{distinct:r.size,nonblank:s,prec:o,minval:l,maxval:a})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let t of e)t&&this._declaredDimensions.add(t)}wholeDayIso(e){return et(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let i=0,r=parseInt(e),s=this.wallClockColumnIndexes(),o=[],l=[],a=[];for(let d of this._cols){let A=new Map,F=[],D=0,M=0,k=0,L=null,O=null,v=null,G=!1,z=!0,N=!0,E=null,U=!1,P=s.has(i);for(let R of this._rows){let W=R[i],B=P&&W instanceof Date?fe(W):W,K=this.STR(B);if(K!=""){if(D+=K.length,A.set(K,(A.get(K)||0)+1),M++,d.dataType=="Integer"||d.dataType=="Decimal"||d.dataType=="DateTime")if((L===null||B<L)&&(L=B),(O===null||B>O)&&(O=B),d.dataType=="Integer"||d.dataType=="Decimal"){if(v===null?v=B:v+=B,d.dataType=="Decimal"){let Z=this.getPrecision(B);Z>k&&(k=Z)}F.push(B)}else G=G||this.hasTimeComponent(B);U&&(B<E?z=!1:B>E&&(N=!1)),E=B,U=!0}}if(M>=3&&(z&&!N?d.sortedDirection="asc":N&&!z?d.sortedDirection="desc":d.sortedDirection="none"),M>0&&A.size>0&&!d.isMeasure){let R=0,W=Number.MAX_SAFE_INTEGER;for(let B of A.values())B>R&&(R=B),B<W&&(W=B);if(d.modalShare=R/M,d.minGroupCount=W===Number.MAX_SAFE_INTEGER?null:W,A.size===2){let B=[...A.keys()].map(ce=>Qe(ce).trim().toLowerCase()).sort(),Z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ce=>B[0]===ce[0]&&B[1]===ce[1]),qt=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(d.name);(Z||qt)&&(d.isBinaryFlag=!0)}}else d.isMeasure&&(d.dataType==="Integer"||d.dataType==="Decimal")&&A.size===2&&A.has("0")&&A.has("1")&&(d.isBinaryFlag=!0);if(d.dataType=="DateTime"&&(d.dateWithTime=G,G&&nt(P?this._rows.map(R=>R[i]instanceof Date?fe(R[i]):R[i]):this._rows.map(R=>R[i]))?d.timeOfDayOnly=!0:delete d.timeOfDayOnly),d.isTemporal=ei({dataType:d.dataType,name:d.name,isMeasure:d.isMeasure,distinctCount:A.size,minNum:typeof L=="number"?L:null,maxNum:typeof O=="number"?O:null,sampleValues:A.keys(),locale:t}),d.isTemporal&&d.dataType==="String"&&!d.isMeasure){let R=Zt(A.keys(),t);R&&(d.temporalTextPattern=R.pattern)}if(d.timeOfDayOnly)delete d.temporalCadence;else if(d.isTemporal&&!d.isMeasure){let R=Bt(A.keys(),{includeBounds:r>=20,pattern:d.temporalTextPattern,locale:t});R&&(d.temporalCadence=R)}this.updateColumnStats10(r,d,M,A,k,O,L),this.updateColumnStats20(r,F,M,v,d,D,G,L,O,k,A,t),jt(d,this._declaredDimensions.has(d),{distinct:A.size,nonblank:M,prec:k,minval:L,maxval:O})&&(d.isMeasure=!0,d.geoKind=void 0,d.geoMatchPct=void 0,d.geoAmbiguous=void 0,d.dominantGeoRegion=void 0,d.dominantGeoRegionPct=void 0,d.geoRegionCount=void 0),o[i]=d.isMeasure||A.size>2e3?null:new Set(A.keys()),l[i]=A.size,a[i]=A.size===2?[...A.keys()].sort():null,i++}let u=[];this._cols.forEach((d,A)=>{d.isMeasure||u.push({idx:A,distinct:d.distinctCount??0,name:d.name})}),this._cols.forEach((d,A)=>{if(!d.isMeasure)return;let F=typeof d.lowValue=="number"?d.lowValue:null,D=typeof d.highValue=="number"?d.highValue:null,M=ni({rows:this._rows,measureColIdx:A,measureName:d.name,candidateDims:u,minNum:F,maxNum:D,discourageAgg:!!d.discourageAggregationAcrossGroups});d.additivity=M.additivity,M.partOfWholeDim&&(d.partOfWholeDim=M.partOfWholeDim)});let m=50,f=4,c=u.filter(d=>d.distinct>=2&&d.distinct<=m);this._cols.forEach((d,A)=>{if(!d.isMeasure)return;let F=[];for(let N of this._rows){let E=N[A];if(E==null||E==="")continue;let U=typeof E=="number"?E:parseFloat(E);isNaN(U)||F.push(U)}if(F.length===0)return;let D=[...F].sort((N,E)=>N-E);if(D[0]===D[D.length-1])d.relativeDispersion=0;else if(D.length>=f){let N=Q(D,.5),E=Q(D,.1),U=Q(D,.9);d.relativeDispersion=Math.abs(N)>1e-9?Math.round((U-E)/Math.abs(N)*1e3)/1e3:void 0}else d.relativeDispersion=void 0;let M=[];for(let N of c){let E=new Set;for(let U of this._rows){let P=U[A];P==null||P===""||E.add(this.STR(U[N.idx])+"")}M.push({otherColumn:N.name,nonBlankGroupCount:E.size})}M.length>0&&(d.nonBlankGroups=M);let k=0;for(let N of F)k+=N;k/=F.length;let L=0;for(let N of F)L+=(N-k)*(N-k);if(L<=1e-12)return;let O=[],v=[],G=N=>{if(N.length<4)return NaN;let E=[...N].sort((P,R)=>P-R),U=P=>E[Math.min(E.length-1,Math.max(0,Math.floor(P*(E.length-1))))];return U(.75)-U(.25)},z=G(F);for(let N of c){let E=new Map;for(let R of this._rows){let W=R[A];if(W==null||W==="")continue;let B=typeof W=="number"?W:parseFloat(W);if(isNaN(B))continue;let K=this.STR(R[N.idx])+"",Z=E.get(K);Z?(Z.s+=B,Z.n++,Z.vals.push(B)):E.set(K,{s:B,n:1,vals:[B]})}let U=0;for(let R of E.values()){let W=R.s/R.n;U+=R.n*(W-k)*(W-k)}O.push({otherColumn:N.name,eta2:Math.round(U/L*1e4)/1e4});let P=[];for(let R of E.values()){let W=G(R.vals);isNaN(W)||P.push(W)}if(P.length>=2&&isFinite(z)&&z>1e-9){let R=(Math.max(...P)-Math.min(...P))/z;v.push({otherColumn:N.name,spreadRatio:Math.round(R*1e4)/1e4})}}O.length>0&&(d.groupDiscrimination=O),v.length>0&&(d.spreadDiscrimination=v)});let S=.97,I=.8,w=8,C=5,g=this._cols.map((d,A)=>({c:d,i:A})).filter(d=>d.c.isMeasure);for(let d=0;d<g.length;d++)for(let A=d+1;A<g.length;A++){let F=g[d].i,D=g[A].i,M=0,k=0,L=0,O=0,v=0,G=0;for(let P of this._rows){let R=P[F],W=P[D];if(R==null||R===""||W===null||W===void 0||W==="")continue;let B=typeof R=="number"?R:parseFloat(R),K=typeof W=="number"?W:parseFloat(W);isNaN(B)||isNaN(K)||(M++,k+=B,L+=K,O+=B*B,v+=K*K,G+=B*K)}if(M<C)continue;let z=M*O-k*k,N=M*v-L*L;if(z<=1e-12||N<=1e-12)continue;let E=(M*G-k*L)/Math.sqrt(z*N),U=Math.min(1,Math.round(Math.abs(E)*1e3)/1e3);for(let P of[g[d].c,g[A].c])(P.maxAbsMeasureCorrelation===void 0||U>P.maxAbsMeasureCorrelation)&&(P.maxAbsMeasureCorrelation=U);if(Math.abs(E)>=S){let P=g[d].c,R=g[A].c;P.collinearWithMeasures||(P.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),P.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(P.name)}else if(Math.abs(E)>=I){let P=g[d].c,R=g[A].c,W=Math.round(E*1e3)/1e3;P.correlatedWithMeasures||(P.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),P.correlatedWithMeasures.push({otherColumn:R.name,r:W}),R.correlatedWithMeasures.push({otherColumn:P.name,r:W})}}for(let{c:d}of g)d.correlatedWithMeasures&&(d.correlatedWithMeasures.sort((A,F)=>Math.abs(F.r)-Math.abs(A.r)||(A.otherColumn<F.otherColumn?-1:1)),d.correlatedWithMeasures.length=Math.min(d.correlatedWithMeasures.length,w));for(let d=0;d<this._cols.length;d++){let A=o[d];if(!A||A.size===0)continue;let F=[];for(let D=0;D<this._cols.length;D++){if(D===d)continue;let M=o[D];if(!M||M.size===0)continue;let k=0;for(let O of A)M.has(O)&&k++;let L=Math.round(k/A.size*100);L>0&&F.push({otherColumn:this._cols[D].name,percentShared:L})}F.length>0&&(this._cols[d].sharedValueRatioWithOthers=F)}let h=50,b=[];for(let d=0;d<this._cols.length;d++){let A=o[d];A&&A.size>=2&&A.size<=h&&b.push(d)}if(b.length>=2){let d=new Map,A=(D,M)=>D+":"+M;for(let D=0;D<b.length;D++)for(let M=D+1;M<b.length;M++)d.set(A(b[D],b[M]),new Map);for(let D of this._rows)for(let M=0;M<b.length;M++){let k=this.STR(D[b[M]])+"";for(let L=M+1;L<b.length;L++){let O=""+this.STR(D[b[L]]),v=d.get(A(b[M],b[L])),G=k+""+O;v.set(G,(v.get(G)??0)+1)}}let F=new Map;for(let D=0;D<b.length;D++)for(let M=D+1;M<b.length;M++){let k=b[D],L=b[M],O=o[k].size,v=o[L].size,G=d.get(A(k,L)),z=G.size,N=0;for(let R of G.values())(N===0||R<N)&&(N=R);let E=Math.round(z/(O*v)*100),U=z===O,P=z===v;if((this._cols[k].categoricalPairStats||=[]).push({otherColumn:this._cols[L].name,fillPct:E,determinesOther:U,minCellCount:N,distinctCombinations:z}),(this._cols[L].categoricalPairStats||=[]).push({otherColumn:this._cols[k].name,fillPct:E,determinesOther:P,minCellCount:N,distinctCombinations:z}),U&&O>v){let R=F.get(k);(!R||v<R.card)&&F.set(k,{name:this._cols[L].name,card:v,ratio:v/O})}if(P&&v>O){let R=F.get(L);(!R||O<R.card)&&F.set(L,{name:this._cols[k].name,card:O,ratio:O/v})}}for(let[D,M]of F)this._cols[D].primaryParentColumn=M.name,this._cols[D].nestingRatio=Math.round(M.ratio*100)/100}let p=6,_=this._rows.length;for(let d=0;d<this._cols.length;d++){let A=this._cols[d];if(A.isMeasure||A.primaryParentColumn)continue;let F=A.distinctCount??0;if(F<=h||_>0&&F>=_)continue;let D=[];for(let M=0;M<this._cols.length;M++){if(M===d)continue;let k=this._cols[M];if(k.isMeasure)continue;let L=k.distinctCount??0;L<2||L>=F||D.push(M)}D.sort((M,k)=>(this._cols[M].distinctCount??0)-(this._cols[k].distinctCount??0));for(let M of D.slice(0,p)){let k=new Map,L=!0;for(let v of this._rows){let G=this.STR(v[d])+"",z=this.STR(v[M])+"",N=k.get(G);if(N===void 0)k.set(G,z);else if(N!==z){L=!1;break}}if(!L)continue;let O=this._cols[M].distinctCount??0;A.primaryParentColumn=this._cols[M].name,A.nestingRatio=Math.round(O/F*100)/100;break}}let y=.01,x=.05,T=.95,V=8,$=8,X=6,J=500,Y=[];for(let d=0;d<this._cols.length&&Y.length<$;d++){let A=this._cols[d].dataType;(A==="Double"||A==="Integer"||A==="Decimal")&&Y.push(d)}if(Y.length>=3&&this._rows.length>=V){let d=Math.min(this._rows.length,J),A=Y.map(O=>{let v=[];for(let N=0;N<d;N++){let E=this._rows[N][O],U=typeof E=="number"?E:parseFloat(String(E).replace(/,/g,""));if(E==null||E===""||!isFinite(U))return null;v.push(U)}let G=v[0],z=!1;for(let N of v)if(N!==G){z=!0;break}return z?v:null}),F=Y.map((O,v)=>v).filter(O=>A[O]!==null),D=O=>{let v=O.slice().sort((z,N)=>z-N),G=v.length>>1;return v.length%2?v[G]:(v[G-1]+v[G])/2},M=null,k=[],L=O=>{if(k.length>=3){let v=k.map(E=>A[E]),G=v[0].length,z=new Array(G);for(let E=0;E<G;E++){let U=0;for(let P of v)U+=P[E];z[E]=U}let N=D(z);if(N>0){let E=0;for(let P of z)Math.abs(P-N)<=N*y&&E++;let U=E/G;if(U>=T){let P=1;for(let R of v){let W=D(R)/N;W<P&&(P=W)}P>=x&&(!M||k.length>M.cols.length)&&(M={cols:k.slice(),total:N,matched:U})}}}if(!(k.length>=X))for(let v=O;v<F.length;v++)k.push(F[v]),L(v+1),k.pop()};if(L(0),M){let O=M,G={columns:O.cols.map(z=>this._cols[Y[z]].name),total:Math.round(O.total*1e3)/1e3,matchedPct:Math.round(O.matched*100)/100};for(let z of O.cols)this._cols[Y[z]].constantSumGroup=G}}return this.applyTwoSetPairing(t,o),this.applyScoreSeparation(l,a),this.applySeriesCompleteness(r,t,o),this.applyMeasurePersistence(t,o),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,t){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=Kt({rows:this._rows,columns:this._cols.map((r,s)=>{let o=t[s];return{name:r.name,values:o,distinct:o?o.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Re(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,t){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=Ht({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Re(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:t[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,t,i){for(let u of this._cols)u.seriesCompleteness!==void 0&&delete u.seriesCompleteness;let r=this._cols.map((u,m)=>({c:u,i:m})).filter(({c:u})=>u.isTemporal&&!u.isMeasure&&u.temporalCadence&&u.temporalCadence.grain!=="irregular");if(r.length===0)return;let s=this.seriesKeyIndex(t,i);if(s<0)return;let o=this._cols[s],l=this._rows.map(u=>this.STR(u[s])),a=e>=20&&(o.dataType!=="String"||Array.isArray(o.safeDistinctValues));for(let{c:u,i:m}of r){let f=Ut({periods:this._rows.map(c=>this.STR(c[m])),series:l,seriesColumn:o.name,pattern:u.temporalTextPattern,locale:t,includeDates:e>=20,includeNames:a});f&&(u.seriesCompleteness=f)}}seriesKeyIndex(e,t){let i=[],r=[];this._cols.forEach((o,l)=>{let a=t[l];a&&(i.push(l),r.push({name:o.name,dataType:o.dataType,isMeasure:!!o.isMeasure,isTemporal:!!o.isTemporal,isDatePart:!!o.isDatePart,isReassembledDate:!!o.isReassembledDate,isBinaryFlag:!!o.isBinaryFlag,geoKind:o.geoKind,identifierNamed:Re(o.name),values:a,rows:this._rows.length,locale:e}))});let s=$t(r);return s<0?-1:i[s]}applyMeasurePersistence(e,t){for(let a of this._cols)a.persistence!==void 0&&delete a.persistence;let i=[];if(this._cols.forEach((a,u)=>{a.isMeasure&&(a.dataType==="Integer"||a.dataType==="Decimal"||a.dataType==="Double")&&i.push(u)}),i.length===0||this._rows.length<we)return;let r=-1,s=[];for(let a=0;a<this._cols.length&&r<0;a++){let u=this._cols[a];if(!u.isTemporal||u.isMeasure||u.isDatePart)continue;let m=this._rows.map(f=>j(this.STR(f[a]),u.temporalTextPattern,e)?.ms??null);new Set(m.filter(f=>f!==null)).size<we||(r=a,s=m)}if(r<0)return;let o=this.seriesKeyIndex(e,t),l=o>=0?this._rows.map(a=>this.STR(a[o])):void 0;for(let a of i){let u=this._rows.map(f=>{let c=f[a];if(c==null||c==="")return null;let S=typeof c=="number"?c:parseFloat(String(c).replace(/,/g,""));return Number.isFinite(S)?S:null}),m=Be({stamps:s,series:l,values:u});m&&(this._cols[a].persistence={timeColumn:this._cols[r].name,...o>=0?{seriesColumn:this._cols[o].name}:{},...m})}}updateColumnStats20(e,t,i,r,s,o,l,a,u,m,f,c){if(e>=20){let S=[...t].sort((C,g)=>C-g),I=Math.floor(S.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=o/i),this._rows.length>0){let C=g=>{let h=g instanceof Date?g:typeof g=="string"?Ne(g)??new Date(g):new Date(g),b=this.wholeDayIso(h);return b?b+"T00:00:00.000Z":isNaN(h.getTime())?g:h.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!a?s.lowValue=a:s.lowValue=C(a),s.dataType!="DateTime"||l||!u?s.highValue=u:s.highValue=C(u),s.medianValue=S.length===0?null:S.length%2===0?s.dataType=="Integer"?Math.round((S[I-1]+S[I])/2):(S[I-1]+S[I])/2:S[I],s.numericPrecision=m}if(S.length>0){let C=s.avgValue??0,g=S.length,h=0,b=0;for(let y of S){let x=y-C;h+=x*x,b+=x*x*x}let p=h/g,_=Math.sqrt(p);s.skewness=p===0?0:b/g/(_*_*_),s.stdDev=Math.sqrt(p)}r!==null&&(s.sum=r);let w=Array.from(f.entries()).sort((C,g)=>g[1]-C[1]);if(s.topCategories=w.slice(0,10).map(C=>C[1]),!s.isMeasure&&w.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=w.slice(0,5).map(C=>C[0])),e>=20)){let C=w.map(h=>h[0]),g=pe(C,c);if(g!==null)s.ordinalPattern=g.pattern,s.orderedDomain=g.orderedDomain;else if(s.dataType==="String"){let h=at(C);h!==null&&(s.safeDistinctValues=h)}}if(S.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let C=g=>S[Math.floor((S.length-1)*g)];s.quantiles={p05:C(.05),p25:C(.25),p75:C(.75),p95:C(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let S=Array.from(f.entries()).sort((C,g)=>g[1]-C[1]).map(C=>C[0]);s.formatSignature=he(S);let I=i>0?o/i:void 0,w=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!w.test(s.formatSignature)&&(I===void 0||I>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let S=Array.from(f.entries()).sort((w,C)=>C[1]-w[1]),I=ct(S.map(w=>w[0]),s.name,c);if(I!==null&&(s.geoKind=I.geoKind,s.geoMatchPct=I.geoMatchPct,I.geoAmbiguous&&(s.geoAmbiguous=!0),I.geoKind.indexOf("country")===0)){let w=Ee(S);w&&(s.dominantGeoRegion=w.dominantGeoRegion,s.dominantGeoRegionPct=w.dominantGeoRegionPct,s.geoRegionCount=w.regionCount)}}}updateColumnStats10(e,t,i,r,s,o,l){let a=this._rows.length-i;e>=10&&(t.blankCount=a),t.distinctCount=r.size+(a!=0?1:0),t.valueNature="Categorical",i>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=Qt({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:r.size,nonblank:i,prec:s,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.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 t=new Set;for(let i of this._rows)t.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>Ke(o,{camel:!0}),t=-1,i=-1,r=-1;if(this._cols.forEach((o,l)=>{let a=e(o.name),u=o.dataType==="Integer"||o.dataType==="Decimal";u&&t<0&&a.some(m=>m==="lat"||m==="latitude")?t=l:u&&i<0&&a.some(m=>m==="lon"||m==="lng"||m==="long"||m==="longitude")&&(i=l),r<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(r=l)}),t<0||i<0)return null;let s=[];for(let o of this._rows){let l=o[t],a=o[i],u=l==null||l===""?null:Number(l),m=a==null||a===""?null:Number(a);s.push({lat:u,lon:m,country:r>=0&&Se(this.STR(o[r]))?this.STR(o[r]):null})}return this._geoExtent=gt(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){return Lt(e,Je)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=t[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=t[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=t[r]);return i})}async getCSVAsync(e){let t=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,o=this.wallClockColumnIndexes();for(let a of this._rows){let u={};for(let m=0;m<this._cols.length;m++){let f=this._cols[m],c=a[m];if(this.STR(c)!=""){if(e&&f.dataType=="String")if(s.has(c))c=s.get(c);else{let S=this.obfuscateString(c);s.set(c,S),c=S}else if(f.dataType=="DateTime"&&!f.dateWithTime){let S=c instanceof Date?c:typeof c=="string"?Ne(c)??new Date(c):new Date(c);c=(this.wholeDayIso(S)??S.toISOString().slice(0,10))+"T00:00:00.000Z"}else o.has(m)&&c instanceof Date&&(c=fe(c));r-=this.STR(c).length}else c=null;u[m]=c,--r}if(t.push(u),--i,i<=0||r<=0)break}return await Yt.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return Yt.unparse([this._cols.map((t,i)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=Le(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())t.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return t}armAliasesForCode(e){return this.emitLegacyAggAliases=Le(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let i=String(e),r=new Set;for(let o of this._cols)o&&(r.add(this.STR(o.name)),o.hostName&&r.add(this.STR(o.hostName)));let s=new Map;for(let o=0;o<this._cols.length;o++){if(!this._cols[o]||Rt(this._hostQueryNames[o],this._cols[o].name,this._cols[o].dataType))continue;let l=wt(this._hostQueryNames[o]).filter(a=>!r.has(a)&&ae(i,a));l.length===1&&s.set(l[0],[...s.get(l[0])??[],o])}for(let[o,l]of s){if(l.length!==1)continue;let a=this.STR(this._cols[l[0]].name);t.set(l[0],{name:a,alias:o,headerName:!ae(i,a)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,i]of this._englishAliases){let r=this._cols?this._cols[t]:null;r&&this.STR(r.name)===i.name&&e.set(t,i)}return e}addRow(e,t){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=qe(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(ri(e)),this._inferredMeasureFlags=null,this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map}setColumns(e){if(this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let t=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Mt(r);!s||s===r||t.has(s)||(t.delete(r),t.add(s),i.hostName=r,i.name=s)}}};export{gt as a,tn as b,Se as c,oi as d,yt as e,gn as f,pn as g,hn as h,yn as i,xe as j,wn as k,Mt as l,Le as m,wt as n,Nt as o,Nn as p,vt as q,kt as r,fi as s,gi as t,pi as u,kn as v,Dn as w,On as x,Dt as y,ae as z,Hn as A,Ci as B,Yn as C,jn as D,j as E,Bt as F,ur as G,cr as H,mr as I,hr as J,$t as K,Ut as L,Oi as M,Re as N,Zt as O,ei as P,ti as Q,ni as R,Qt as S,jt as T,ri as U,Xt as V};
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 Jn,b as Zn}from"./chunk-HIVICMC5.mjs";import{a as er,b as I,c as tr,d as D,e as E,f as nr,g as X,h as J}from"./chunk-4J7WPYLM.mjs";import{a as Yn,b as Qn,c as Xn}from"./chunk-VDEKQOYB.mjs";import{A as Pn,B as vn,C as Ln,D as An,E as Mn,F as In,G as Nn,H as Fn,I as Dn,J as kn,K as Gn,L as Vn,M as Un,N as Wn,O as qn,P as $n,Q as zn,R as Hn,S as Kn,T as Bn,V as jn,a as Qt,b as Xt,c as Jt,d as Zt,f as an,g as ln,h as un,i as cn,j as dn,k as mn,l as fn,m as pn,n as gn,o as yn,p as hn,q as Cn,r as bn,s as En,t as Tn,u as Sn,v as Rn,w as xn,x as wn,y as _n,z as On}from"./chunk-AMXLHWUI.mjs";import{a as en}from"./chunk-U3H6UBOO.mjs";import{b as tn,c as nn,d as rn,f as on,g as sn}from"./chunk-A4PQBWRA.mjs";import{a as le,b as ue,c as Kt,d as Bt,e as jt,f as Yt}from"./chunk-IPPPCWAK.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Dt,m as kt,n as ae,o as v,p as Gt,q as Vt,r as Ut,s as q,t as Wt,u as qt,v as $t,w as zt,x as Q,y as Ht}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as ht,b as Ct,c as bt,d as Et,e as Tt,f as St,g as Rt,h as xt,i as wt,j as _t,k as Ot,l as Pt,m as It,n as Nt,o as Ft}from"./chunk-HJA26Z2E.mjs";import{A as mt,B as ft,C as pt,D as gt,E as yt,a as qe,b as $e,c as ze,d as He,e as Ke,f as Be,g as je,h as Ye,i as Qe,j as Xe,k as Je,l as Ze,m as et,n as tt,o as nt,q as j,r as rt,s as ot,t as it,u as st,v as at,w as lt,x as ut,y as ct,z as dt}from"./chunk-CZJ7M6A5.mjs";import{a as De,b as ke,c as Ge,d as Ve,e as Ue,f as B,g as We}from"./chunk-WC4JINEZ.mjs";import{b as vt,c as Lt,d as At,e as Mt}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(a=>te(a)&&!v(a)).length,o=t.filter(a=>!te(a)&&!!v(a)).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 rr(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let a of n)Q(a,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 or(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function ir(e,t,n,o,a){let u=[],l=[],i={},C={},b=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&b.has(d)&&(i[s]=d)}let g=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&b.has(f)){let s=h(f),d=re(s);d<95?l.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:l.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&b.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?l.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(l.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?l.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),y=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of y){let S=h(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Fe=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Fe<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 y){if(p.has(s))continue;let d=h(s),S=re(d);if(!(S<95)&&de(d,s)&&!(or(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(h(T))){let s=null;for(let d of y){if(p.has(d)||!N(h(d)))continue;let S=ne(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(l.push(`country=${T} (only ${ne(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.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 y){if(p.has(d))continue;let S=h(d),O=rr(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?h(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&&l.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&l.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:l,...Object.keys(C).length?{labelFallback:C}:{}}}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")}),sr=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 ar(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function lr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of ar(n,t)){let a=ie[o];if(a&&a.langs.includes(t))return a.part}return null}function ur(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 cr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),a=o.lastIndexOf(";");return a>=0&&(o=o.slice(a+1)),cr.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),a=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"),l=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&l++;let C=0;for(;(i=a.exec(e))!==null;){let b=i.index+i[0].lastIndexOf(".name");if(!z(e,b))continue;C++;let h=ye(i[1]);if(!n(h))return!1}return C>0&&C===l}function dr(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 mr(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=a.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let l=[];return o.forEach(i=>{n.has(i)||he(e,i)||l.push(i)}),l}function fr(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 pr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let l=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?l:l+" "+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 l=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(l!==""&&(n.has(l)||(t.push(l),n.set(l,0)),u.isDatePart===!0&&n.set(l,n.get(l)+1),u.isReassembledDate===!0&&!o.has(l))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",C=typeof u.name=="string"?u.name.trim():"",b=i!==""?i:C;b!==""&&o.set(l,b)}}let a=[];for(let u of t){let l=o.get(u),i=n.get(u)??0;!l||i===0||a.push(`'${l}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}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},gr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,a]of gr){let u=m(E(e,t+a));u&&(n[o]=u)}return n}function yr(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 hr(e){let t=b=>E(e,b),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),u=Re(e,"point"),l=Re(e,"destPoint");Object.keys(l).length&&(u.dest=l);let i=t("retryable"),C=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:yr(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")),suppressSelectionGlyph:P(t("suppressSelectionGlyph")),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 C=="boolean"?{isPollFinal:C}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}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 l=C=>E(u,C),i=l("recommended");return{name:m(l("chartTypeName")??l("name")),description:m(l("description")??l("chartDesc")),rank:xe(l("rank")),score:xe(l("score")),renderer:k(l("renderer")),language:k(l("language")),isPreview:P(l("isPreview")),alsoWorthALook:P(l("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(l("viaProjection")),viaProjectionKey:k(l("viaProjectionKey")),detailNote:k(l("detailNote"))}}).filter(u=>u.name):null,a=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:a,noFitSummary:m(E(e,"noFitSummary"))}}function br(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 Er(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 Tr="FREEMIUM_ATTEMPT_SPENT",Sr="CLIENT_SECRET_MISMATCH",Rr="FREEMIUM_COLUMN_CAP",xr="OAUTH_TOKEN_EXPIRED",wr="OAUTH_SIGNED_OUT";function _r(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function Or(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 Pr(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function vr(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,a=n??o??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function Lr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),u=e.fetchArmedAtMs,l=t&&typeof u=="number"&&Number.isSafeInteger(u)&&u>0?u:void 0;return{genNew:o,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...l!==void 0?{fetchArmedAtMs:l}:{}}}function Ar(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function Mr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function Ir(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function Nr(e,t,n){let o=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...o(t)?{rowsWithheld:t}:{},...o(n)?{rowsFilteredOut:n}:{}}}var Fr={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 Dr(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function Pe(e,t){return e!=null&&t!=null&&e!==t}function kr(e,t){return e?Pe(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 Gr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function ve(e){let t=String(e??"").trim().toLowerCase();return Gr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",ve(n.dataType)]);return t}function Vr(e){return j(Le(e))}var Ur=2,Wr=3,qr=4,$r=64,zr=8e3,Hr=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"}),Br=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function jr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Yr(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 Qr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let a=`${n}|${o}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function Xr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let a=`${e},${t}|${n}`;return o?`${a}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:a}function Jr(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:a,clock:u}=n,l=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,b=g=>{try{t.onFailure?.(g)}catch{}},h=async(g,f,c,p)=>{let y;try{let T=await a.post(f,c,p,{timeoutMs:i});y=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){b({channel:g,stage:"post",status:null,error:T});return}(y<200||y>299)&&b({channel:g,stage:"status",status:y,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${C()}${l}/LogClientMsg/?nocache=${u.now()}`,c=I(g),p=D(c,o)}catch(y){b({channel:"client-message",stage:"build",status:null,error:y});return}await h("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,y;try{p=`${C()}${l}/eventlog`,y=se(g,t.clientVersion,f,c)}catch(T){b({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",p,y,{"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 eo(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(a,u,l,i){let C=i.timeoutMs,b=Zr(C);if(b)throw b;let h=new AbortController,g=!1,f=setTimeout(()=>{g=!0,h.abort(Me(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,y=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(C):_,L;try{L=await n(a,{method:"POST",body:u,headers:l,credentials:o,signal:h.signal})}catch(_){throw y(),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{y()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){y(),_.close();return}_.enqueue(s.value)}catch(s){y(),_.error(T(s))}},cancel(_){return y(),x.cancel(_)}});return{status:R.status,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300;function Ne(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var to="/LLMChart/",no="/LLMChart/qualify",ro="/VisionReview/",oo="/LLMChart/sample",io="/RefundGenerate/",so=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function ao(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function lo(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:a,clock:u}=n,l=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>t.nocache?t.nocache(g):String(u.now());async function b(g,f,c,p,y){let T=`${i()}${l}${f}?nocache=${C(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&&so(_),cancelled:s,error:_}},x;try{x=await a.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)ao(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 y(x)}}catch(w){return A(!0,w)}}function h(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=h("generate",f),p=c.onStage??void 0;return b("generate",to,I(g),c,y=>J(y,p))},async qualify(g,f){let c=h("qualify",f),p=c.route??no;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return b("qualify",p,I(g),c,H)},async review(g,f){let c=h("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return b("review",ro,p,c,H)},async sample(g,f){let c=h("sample",f);return b("sample",oo,I(g),c,H)},async refund(g,f,c){let p=h("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let y=Ne(c),T=y?{CorrelationID:g.trim(),Reason:y}:{CorrelationID:g.trim()};return b("refund",io,JSON.stringify(T),p,H)}}}export{Y as CITY_ROLE_MATCH_PCT,Kr as CLIENT_EVENT_KINDS,Sr as CLIENT_SECRET_MISMATCH,je as COMPOUND_MIN_STEM,ht as CYCLE_MEMBERS,bt as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,sr as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Ln as DEFAULT_GAP_FACTOR,it as DEFAULT_TEMPERATURE,Br as DRAW_REASONS,Tr as FREEMIUM_ATTEMPT_SPENT,Rr as FREEMIUM_COLUMN_CAP,rt as GET_RANDOM,Qe as GLUED_STEM_MIN,Je as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,xn as IDENTIFIER_HEAD_INITIAL,wn as IDENTIFIER_UNFOLDED,Rn as IDENTIFIER_WORDS,ln as INTENSIVE_SUFFIX_TOKENS,an as INTENSIVE_WORD_TOKENS,jn as IndexedText,Lt as LOOSE_KEY_MIN_LENGTH,Mt as LooseIndex,An as MAX_RUN_BOUNDS,wr as OAUTH_SIGNED_OUT,xr as OAUTH_TOKEN_EXPIRED,xt as PERIOD_CODE_FORMS,Rt as PERIOD_CODE_MEMBERS,wt as PERIOD_ORDINALS,_t as PERIOD_UNFOLDED,cn as POSITIONAL_SUFFIX_TOKENS,un as POSITIONAL_WORD_TOKENS,Jn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,Fr as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,Nn as SERIES_COMPLETENESS_MAX_LISTED,Fn as SERIES_COMPLETENESS_MIN_FILL,Dn as SERIES_KEY_MAX_DISTINCT,qr as SEV_ERROR,Ur as SEV_INFO,$r as SEV_USER_PRESENTED,Wr as SEV_WARNING,j as SIMPLE_STRING_HASH,nt as STR,et as SUBSTRING_MIN,De as SUPPORTED_LANGUAGES,ke as SUPPORTED_LANGUAGE_CODES,Hr as TELEMETRY_TIMEOUT_DEV_MS,zr as TELEMETRY_TIMEOUT_MS,Ue as VOCABULARY_LANGUAGE_CODES,Ve as VOCABULARY_ONLY_LANGUAGES,Ct as YEAR_WORDS,$ as admin1MatchPct,bn as allowedAggregations,gt as anchorLocalWallClockDates,_r as answerIsRetryable,Yt as buildGeoIsoColumn,$t as buildGeoPointColumns,Et as calendarWordIn,Ar as capabilityFields,Ht as cityMatchPct,zt as cityTagsFor,Hn as classifyAdditivity,Yr as classifyDraw,Cn as classifyForAggregation,Kn as classifyNumericValueNature,$n as classifyTemporal,pn as codeNeedsLegacyAggNames,On as codeReadsColumn,Pn as codeReadsColumnsByRoleOrPosition,fn as collapseRepeatedAggPrefix,vn as columnsTheCodeReads,Jt as countryRegion,Qr as createDrawLedger,lo as createGenerateClient,Jr as createTelemetryClient,Or as credentialFields,Nr as dataCompletenessFields,lr as dateLevelPart,ur as dateLevelYearAdmits,yt as datesAreTimeOfDayOnly,ft as datesCarryTimeOfDay,tn as decimalSeparatorOf,En as defaultAggregation,nn as detectDecimalSeparator,en as detectFormatSignature,Kt as detectGeo,Ft as detectOrdinalDomain,qn as detectTextDatePattern,jr as drawLocation,I as encodePayload,Yn as engineTypeForSqlType,gn as englishImplicitAggNames,se as eventLogLine,Lr as fetchFields,eo as fetchTransport,qe as foldName,pr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Xe as gluedPrefixStems,fr as guardColumnNames,er as gzipWireText,Ze as hangulWordEndsWith,mn as hasDefaultAggPrefix,Ke as hasUnsegmentedScript,zn as hostAggHint,Xn as ingest,Tn as isAggregationAllowed,V as isBlankLike,kt as isCityTableLoaded,z as isColumnContextRef,ot as isDeterministicRefusal,Xr as isEventLogCode,Wt as isGeoPointAmbiguity,Wn as isIdentifierName,jt as isJoinGeoKind,nr as isNdjsonContentType,It as isOrdinalFriendlyName,At as isUsableLooseKey,tr as keyedSigner,Ir as leafCardinalityField,ct as localMidnightDateColumns,ut as localMidnightToUtcDay,pt as localWallClockDateColumns,St as localizedCycleIn,_n as localizedIdentifierWordIn,Tt as localizedYearWordIn,N as looksLikeCountryColumn,vt as looseNameKey,tt as matchNameToken,vr as maxNonMeasureCardinality,In as measureCadence,Un as measurePersistence,Vn as measureSeriesCompleteness,D as messageSignature,mr as missingHardColumnRefs,sn as monthLookupFor,ze as nameLetterRuns,hn as nameLooksIntensiveRate,yn as nameLooksPositional,he as nameProbeIsGuarded,dr as nameProbeKeepsDrawing,$e as nameWords,Gt as normalizeCountry,dt as normalizeLocalMidnightDates,on as normalizeMonthKey,U as normalizePlaceName,Ut as normalizeZip5,kr as offeredShortlistFor,Qn as parseCsvRows,st as parseDateStable,hr as parseGenerateResponse,rn as parseNumberText,Cr as parseQualifyResponse,br as parseReviewVerdict,Mn as parseTemporalPoint,Zn as payloadPreview,Pt as periodCodeSeries,Gn as pickSeriesColumn,Er as progressStageOf,Bn as promotesToMeasure,Dr as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,He as readName,Ot as readPeriodCode,E as readWireField,Ne as refundReasonCode,Dt as registerCityTable,Xt as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,qt as resolveGeoPoint,We as resolveLanguage,ir as resolvePointRoles,Mr as retryFields,Nt as safeDistinctValuesToShip,Le as schemaIdentity,Vr as schemaIdentityKey,ve as schemaTypeFamily,kn as seriesKeyVerdict,Sn as shareOfTotalIsHonest,Pe as shortlistIsStale,dn as stripHostAggPrefix,Zt as summarizeCountryRegions,Qt as summarizeGeoExtent,Ge as supportedLanguage,Bt as toGeoIso,Be as unsegmentedRuns,mt as utcWallClock,Pr as viewportFields,B as vocabularyLanguage,at as wholeDayFrame,lt as wholeDayIso,X as wireResponseFromFetch,Ye as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,Vt as zipToPrefix3};
2
+ import{a as Jn,b as Zn}from"./chunk-HIVICMC5.mjs";import{a as er,b as I,c as tr,d as D,e as E,f as nr,g as X,h as J}from"./chunk-4J7WPYLM.mjs";import{a as Yn,b as Qn,c as Xn}from"./chunk-AMMJRSAC.mjs";import{A as Pn,B as vn,C as Ln,D as An,E as Mn,F as In,G as Nn,H as Fn,I as Dn,J as kn,K as Gn,L as Vn,M as Un,N as Wn,O as qn,P as $n,Q as zn,R as Hn,S as Kn,T as Bn,V as jn,a as Qt,b as Xt,c as Jt,d as Zt,f as an,g as ln,h as un,i as cn,j as dn,k as mn,l as fn,m as pn,n as gn,o as yn,p as hn,q as Cn,r as bn,s as En,t as Tn,u as Sn,v as Rn,w as xn,x as wn,y as _n,z as On}from"./chunk-CQS6BGRJ.mjs";import{a as en}from"./chunk-U3H6UBOO.mjs";import{b as tn,c as nn,d as rn,f as on,g as sn}from"./chunk-A4PQBWRA.mjs";import{a as le,b as ue,c as Kt,d as Bt,e as jt,f as Yt}from"./chunk-IPPPCWAK.mjs";import{a as M,b as V,c as Y,d as U,k as W,l as Dt,m as kt,n as ae,o as v,p as Gt,q as Vt,r as Ut,s as q,t as Wt,u as qt,v as $t,w as zt,x as Q,y as Ht}from"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import{a as ht,b as Ct,c as bt,d as Et,e as Tt,f as St,g as Rt,h as xt,i as wt,j as _t,k as Ot,l as Pt,m as It,n as Nt,o as Ft}from"./chunk-HJA26Z2E.mjs";import{A as mt,B as ft,C as pt,D as gt,E as yt,a as qe,b as $e,c as ze,d as He,e as Ke,f as Be,g as je,h as Ye,i as Qe,j as Xe,k as Je,l as Ze,m as et,n as tt,o as nt,q as j,r as rt,s as ot,t as it,u as st,v as at,w as lt,x as ut,y as ct,z as dt}from"./chunk-CZJ7M6A5.mjs";import{a as De,b as ke,c as Ge,d as Ve,e as Ue,f as B,g as We}from"./chunk-WC4JINEZ.mjs";import{b as vt,c as Lt,d as At,e as Mt}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(a=>te(a)&&!v(a)).length,o=t.filter(a=>!te(a)&&!!v(a)).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 rr(e,t){let n=F(e);if(n.length===0)return 0;let o=0;for(let a of n)Q(a,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 or(e,t){let n=0;for(let o of oe(e))t(o)&&n++;return n}function ir(e,t,n,o,a){let u=[],l=[],i={},C={},b=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&b.has(d)&&(i[s]=d)}let g=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&g.has(d)&&(i[s]=d)}let f=n?.zip;if(f&&b.has(f)){let s=h(f),d=re(s);d<95?l.push(`zip=${f} (only ${d}% of values read as ZIPs)`):de(s,f)?i.zip=f:l.push(`zip=${f} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&b.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>ce(S,o))?l.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(l.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):$(s)<95?l.push(`state=${c} (only ${$(s)}% of values are states/provinces)`):i.state=c}let p=new Set(Object.values(i).filter(Boolean)),y=e.filter(s=>!p.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of y){let S=h(d);if(N(S))continue;let O=$(S);if(O<95)continue;let K=ee(S,G=>!!v(G)),Fe=ee(S,G=>!!v(G)&&!ce(G,o));K<Z&&Fe<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 y){if(p.has(s))continue;let d=h(s),S=re(d);if(!(S<95)&&de(d,s)&&!(or(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(h(T))){let s=null;for(let d of y){if(p.has(d)||!N(h(d)))continue;let S=ne(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(l.push(`country=${T} (only ${ne(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.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 y){if(p.has(d))continue;let S=h(d),O=rr(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?h(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&&l.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&l.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:l,...Object.keys(C).length?{labelFallback:C}:{}}}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")}),sr=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 ar(e,t){let n=[],o=B(t);try{o&&n.push(e.toLocaleLowerCase(o.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function lr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let o of ar(n,t)){let a=ie[o];if(a&&a.langs.includes(t))return a.part}return null}function ur(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 cr=/\b(?:columns|cols|column)\b/i;function z(e,t){let n=Math.max(0,t-240),o=e.slice(n,t),a=o.lastIndexOf(";");return a>=0&&(o=o.slice(a+1)),cr.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),a=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"),l=0,i;for(;(i=u.exec(e))!==null;)z(e,i.index)&&l++;let C=0;for(;(i=a.exec(e))!==null;){let b=i.index+i[0].lastIndexOf(".name");if(!z(e,b))continue;C++;let h=ye(i[1]);if(!n(h))return!1}return C>0&&C===l}function dr(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 mr(e,t){if(!e)return[];let n=new Set(t);for(let i of be)n.add(i);let o=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,u;for(;(u=a.exec(e))!==null;)z(e,u.index)&&o.add(u[2]);if(o.size===0)return[];let l=[];return o.forEach(i=>{n.has(i)||he(e,i)||l.push(i)}),l}function fr(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 pr(e,t,n){let o=Ee(e,t);if(o===null||o<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,u=o>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof u!="string"||u.trim().length===0)return null;let l=u.split("{n}").join(String(o)).split("{fields}").join(o===1?"field":"fields"),i=Te(n);return i.length===0?l:l+" "+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 l=typeof u?.dateGroupId=="string"?u.dateGroupId.trim():"";if(l!==""&&(n.has(l)||(t.push(l),n.set(l,0)),u.isDatePart===!0&&n.set(l,n.get(l)+1),u.isReassembledDate===!0&&!o.has(l))){let i=typeof u.sourceField=="string"?u.sourceField.trim():"",C=typeof u.name=="string"?u.name.trim():"",b=i!==""?i:C;b!==""&&o.set(l,b)}}let a=[];for(let u of t){let l=o.get(u),i=n.get(u)??0;!l||i===0||a.push(`'${l}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}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},gr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Re(e,t){let n={};for(let[o,a]of gr){let u=m(E(e,t+a));u&&(n[o]=u)}return n}function yr(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 hr(e){let t=b=>E(e,b),n=t("retryAfterSeconds"),o=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),u=Re(e,"point"),l=Re(e,"destPoint");Object.keys(l).length&&(u.dest=l);let i=t("retryable"),C=t("isPollFinal");return{errorMessage:m(t("errorMessage")),errorCode:m(t("errorCode")),refusalCode:m(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:yr(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")),suppressSelectionGlyph:P(t("suppressSelectionGlyph")),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 C=="boolean"?{isPollFinal:C}:{},...m(t("pollOutcome"))!==""?{pollOutcome:m(t("pollOutcome"))}:{},...typeof o=="boolean"?{overrideThumbnailUpload:o}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}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 l=C=>E(u,C),i=l("recommended");return{name:m(l("chartTypeName")??l("name")),description:m(l("description")??l("chartDesc")),rank:xe(l("rank")),score:xe(l("score")),renderer:k(l("renderer")),language:k(l("language")),isPreview:P(l("isPreview")),alsoWorthALook:P(l("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:k(l("viaProjection")),viaProjectionKey:k(l("viaProjectionKey")),detailNote:k(l("detailNote"))}}).filter(u=>u.name):null,a=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:a,noFitSummary:m(E(e,"noFitSummary"))}}function br(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 Er(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 Tr="FREEMIUM_ATTEMPT_SPENT",Sr="CLIENT_SECRET_MISMATCH",Rr="FREEMIUM_COLUMN_CAP",xr="OAUTH_TOKEN_EXPIRED",wr="OAUTH_SIGNED_OUT";function _r(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function Or(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 Pr(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function vr(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,a=n??o??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function Lr(e){let t=e.fetchCorrelationId!=null,o=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=_e({genNew:o,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),u=e.fetchArmedAtMs,l=t&&typeof u=="number"&&Number.isSafeInteger(u)&&u>0?u:void 0;return{genNew:o,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...l!==void 0?{fetchArmedAtMs:l}:{}}}function Ar(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function Mr(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function Ir(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function Nr(e,t,n){let o=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...o(t)?{rowsWithheld:t}:{},...o(n)?{rowsFilteredOut:n}:{}}}var Fr={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 Dr(e){let t=Oe(e);return t?{qualifyOrder:t}:{}}function Pe(e,t){return e!=null&&t!=null&&e!==t}function kr(e,t){return e?Pe(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 Gr=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function ve(e){let t=String(e??"").trim().toLowerCase();return Gr[t]??t}function Le(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",ve(n.dataType)]);return t}function Vr(e){return j(Le(e))}var Ur=2,Wr=3,qr=4,$r=64,zr=8e3,Hr=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"}),Br=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function jr(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Yr(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 Qr(){let e=new Set,t=new Set;return{firstDraw(n,o){if(!n)return!1;let a=`${n}|${o}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function Xr(e){return!!e&&!e.includes("|")&&!e.includes(",")}function se(e,t,n,o){let a=`${e},${t}|${n}`;return o?`${a}|${Math.max(0,Math.round(o.count))}|${o.nonce}`:a}function Jr(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:a,clock:u}=n,l=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,b=g=>{try{t.onFailure?.(g)}catch{}},h=async(g,f,c,p)=>{let y;try{let T=await a.post(f,c,p,{timeoutMs:i});y=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){b({channel:g,stage:"post",status:null,error:T});return}(y<200||y>299)&&b({channel:g,stage:"status",status:y,error:null})};return{async sendClientMessage(g){let f,c,p;try{f=`${C()}${l}/LogClientMsg/?nocache=${u.now()}`,c=I(g),p=D(c,o)}catch(y){b({channel:"client-message",stage:"build",status:null,error:y});return}await h("client-message",f,c,{"Content-Type":"text/plain","X-Signature":p})},async countEvent(g,f,c){let p,y;try{p=`${C()}${l}/eventlog`,y=se(g,t.clientVersion,f,c)}catch(T){b({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",p,y,{"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 eo(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(a,u,l,i){let C=i.timeoutMs,b=Zr(C);if(b)throw b;let h=new AbortController,g=!1,f=setTimeout(()=>{g=!0,h.abort(Me(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let p=!1,y=()=>{p||(p=!0,clearTimeout(f),i.signal?.removeEventListener("abort",c))},T=_=>g?Me(C):_,L;try{L=await n(a,{method:"POST",body:u,headers:l,credentials:o,signal:h.signal})}catch(_){throw y(),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{y()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){y(),_.close();return}_.enqueue(s.value)}catch(s){y(),_.error(T(s))}},cancel(_){return y(),x.cancel(_)}});return{status:R.status,...A,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ie=300;function Ne(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var to="/LLMChart/",no="/LLMChart/qualify",ro="/VisionReview/",oo="/LLMChart/sample",io="/RefundGenerate/",so=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",H=async e=>JSON.parse(await e.text());function ao(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function lo(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:a,clock:u}=n,l=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=g=>t.nocache?t.nocache(g):String(u.now());async function b(g,f,c,p,y){let T=`${i()}${l}${f}?nocache=${C(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&&so(_),cancelled:s,error:_}},x;try{x=await a.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)ao(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 y(x)}}catch(w){return A(!0,w)}}function h(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=h("generate",f),p=c.onStage??void 0;return b("generate",to,I(g),c,y=>J(y,p))},async qualify(g,f){let c=h("qualify",f),p=c.route??no;if(typeof p!="string"||!p.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return b("qualify",p,I(g),c,H)},async review(g,f){let c=h("review",f),p=JSON.stringify(g);if(typeof p!="string")throw new TypeError("The review wire did not serialize to JSON");return b("review",ro,p,c,H)},async sample(g,f){let c=h("sample",f);return b("sample",oo,I(g),c,H)},async refund(g,f,c){let p=h("refund",f);if(typeof g!="string"||g.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let y=Ne(c),T=y?{CorrelationID:g.trim(),Reason:y}:{CorrelationID:g.trim()};return b("refund",io,JSON.stringify(T),p,H)}}}export{Y as CITY_ROLE_MATCH_PCT,Kr as CLIENT_EVENT_KINDS,Sr as CLIENT_SECRET_MISMATCH,je as COMPOUND_MIN_STEM,ht as CYCLE_MEMBERS,bt as CYCLE_WORDS,ge as DATE_LEVEL_GREGORIAN_YEAR_MAX,pe as DATE_LEVEL_GREGORIAN_YEAR_MIN,sr as DATE_LEVEL_LANGUAGES,ie as DATE_LEVEL_NAMES,fe as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,Ln as DEFAULT_GAP_FACTOR,it as DEFAULT_TEMPERATURE,Br as DRAW_REASONS,Tr as FREEMIUM_ATTEMPT_SPENT,Rr as FREEMIUM_COLUMN_CAP,rt as GET_RANDOM,Qe as GLUED_STEM_MIN,Je as HANGUL_MIN_STEM,be as HOST_SYNTHETIC_COLUMNS,Ie as HTTP_BODY_START_CHARS,xn as IDENTIFIER_HEAD_INITIAL,wn as IDENTIFIER_UNFOLDED,Rn as IDENTIFIER_WORDS,ln as INTENSIVE_SUFFIX_TOKENS,an as INTENSIVE_WORD_TOKENS,jn as IndexedText,Lt as LOOSE_KEY_MIN_LENGTH,Mt as LooseIndex,An as MAX_RUN_BOUNDS,wr as OAUTH_SIGNED_OUT,xr as OAUTH_TOKEN_EXPIRED,xt as PERIOD_CODE_FORMS,Rt as PERIOD_CODE_MEMBERS,wt as PERIOD_ORDINALS,_t as PERIOD_UNFOLDED,cn as POSITIONAL_SUFFIX_TOKENS,un as POSITIONAL_WORD_TOKENS,Jn as PREVIEW_OMITTED_FIELDS,we as PROGRESS_STAGE_IDS,Fr as QUALIFY_ORDER_LABELS,M as ROLE_MATCH_PCT,Nn as SERIES_COMPLETENESS_MAX_LISTED,Fn as SERIES_COMPLETENESS_MIN_FILL,Dn as SERIES_KEY_MAX_DISTINCT,qr as SEV_ERROR,Ur as SEV_INFO,$r as SEV_USER_PRESENTED,Wr as SEV_WARNING,j as SIMPLE_STRING_HASH,nt as STR,et as SUBSTRING_MIN,De as SUPPORTED_LANGUAGES,ke as SUPPORTED_LANGUAGE_CODES,Hr as TELEMETRY_TIMEOUT_DEV_MS,zr as TELEMETRY_TIMEOUT_MS,Ue as VOCABULARY_LANGUAGE_CODES,Ve as VOCABULARY_ONLY_LANGUAGES,Ct as YEAR_WORDS,$ as admin1MatchPct,bn as allowedAggregations,gt as anchorLocalWallClockDates,_r as answerIsRetryable,Yt as buildGeoIsoColumn,$t as buildGeoPointColumns,Et as calendarWordIn,Ar as capabilityFields,Ht as cityMatchPct,zt as cityTagsFor,Hn as classifyAdditivity,Yr as classifyDraw,Cn as classifyForAggregation,Kn as classifyNumericValueNature,$n as classifyTemporal,pn as codeNeedsLegacyAggNames,On as codeReadsColumn,Pn as codeReadsColumnsByRoleOrPosition,fn as collapseRepeatedAggPrefix,vn as columnsTheCodeReads,Jt as countryRegion,Qr as createDrawLedger,lo as createGenerateClient,Jr as createTelemetryClient,Or as credentialFields,Nr as dataCompletenessFields,lr as dateLevelPart,ur as dateLevelYearAdmits,yt as datesAreTimeOfDayOnly,ft as datesCarryTimeOfDay,tn as decimalSeparatorOf,En as defaultAggregation,nn as detectDecimalSeparator,en as detectFormatSignature,Kt as detectGeo,Ft as detectOrdinalDomain,qn as detectTextDatePattern,jr as drawLocation,I as encodePayload,Yn as engineTypeForSqlType,gn as englishImplicitAggNames,se as eventLogLine,Lr as fetchFields,eo as fetchTransport,qe as foldName,pr as freemiumColumnCapRefusal,Ee as freemiumColumnsOverCap,Te as freemiumDateHierarchyClauses,Xe as gluedPrefixStems,fr as guardColumnNames,er as gzipWireText,Ze as hangulWordEndsWith,mn as hasDefaultAggPrefix,Ke as hasUnsegmentedScript,zn as hostAggHint,Xn as ingest,Tn as isAggregationAllowed,V as isBlankLike,kt as isCityTableLoaded,z as isColumnContextRef,ot as isDeterministicRefusal,Xr as isEventLogCode,Wt as isGeoPointAmbiguity,Wn as isIdentifierName,jt as isJoinGeoKind,nr as isNdjsonContentType,It as isOrdinalFriendlyName,At as isUsableLooseKey,tr as keyedSigner,Ir as leafCardinalityField,ct as localMidnightDateColumns,ut as localMidnightToUtcDay,pt as localWallClockDateColumns,St as localizedCycleIn,_n as localizedIdentifierWordIn,Tt as localizedYearWordIn,N as looksLikeCountryColumn,vt as looseNameKey,tt as matchNameToken,vr as maxNonMeasureCardinality,In as measureCadence,Un as measurePersistence,Vn as measureSeriesCompleteness,D as messageSignature,mr as missingHardColumnRefs,sn as monthLookupFor,ze as nameLetterRuns,hn as nameLooksIntensiveRate,yn as nameLooksPositional,he as nameProbeIsGuarded,dr as nameProbeKeepsDrawing,$e as nameWords,Gt as normalizeCountry,dt as normalizeLocalMidnightDates,on as normalizeMonthKey,U as normalizePlaceName,Ut as normalizeZip5,kr as offeredShortlistFor,Qn as parseCsvRows,st as parseDateStable,hr as parseGenerateResponse,rn as parseNumberText,Cr as parseQualifyResponse,br as parseReviewVerdict,Mn as parseTemporalPoint,Zn as payloadPreview,Pt as periodCodeSeries,Gn as pickSeriesColumn,Er as progressStageOf,Bn as promotesToMeasure,Dr as qualifyOrderField,Oe as qualifyOrderOf,J as readGenerateStream,He as readName,Ot as readPeriodCode,E as readWireField,Ne as refundReasonCode,Dt as registerCityTable,Xt as registerIso3Regions,v as resolveAdmin1,_e as resolveFetchVersion,qt as resolveGeoPoint,We as resolveLanguage,ir as resolvePointRoles,Mr as retryFields,Nt as safeDistinctValuesToShip,Le as schemaIdentity,Vr as schemaIdentityKey,ve as schemaTypeFamily,kn as seriesKeyVerdict,Sn as shareOfTotalIsHonest,Pe as shortlistIsStale,dn as stripHostAggPrefix,Zt as summarizeCountryRegions,Qt as summarizeGeoExtent,Ge as supportedLanguage,Bt as toGeoIso,Be as unsegmentedRuns,mt as utcWallClock,Pr as viewportFields,B as vocabularyLanguage,at as wholeDayFrame,lt as wholeDayIso,X as wireResponseFromFetch,Ye as wordEndsWith,re as zipMatchPct,q as zipPrefixCandidates,Vt as zipToPrefix3};
@@ -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{N as a,O as b,P as c,Q as d,R as e,S as f,T as g,U as h,V as i}from"./chunk-AMXLHWUI.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-IPPPCWAK.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-HJA26Z2E.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{i as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as promotesToMeasure,h as trimmedCells};
2
+ import{N as a,O as b,P as c,Q as d,R as e,S as f,T as g,U as h,V as i}from"./chunk-CQS6BGRJ.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-IPPPCWAK.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-HJA26Z2E.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{i as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName,g as promotesToMeasure,h as trimmedCells};
package/dist/ingest.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{a,b,c}from"./chunk-VDEKQOYB.mjs";import"./chunk-AMXLHWUI.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-IPPPCWAK.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-HJA26Z2E.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
2
+ import{a,b,c}from"./chunk-AMMJRSAC.mjs";import"./chunk-CQS6BGRJ.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-A4PQBWRA.mjs";import"./chunk-IPPPCWAK.mjs";import"./chunk-INMDBTAR.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-HJA26Z2E.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";import"./chunk-5HI6TVMM.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
@@ -11,7 +11,7 @@ export type { MeasurePersistence } from "./measurePersistence";
11
11
  export { classifyForAggregation, allowedAggregations, defaultAggregation, isAggregationAllowed, shareOfTotalIsHonest, nameLooksIntensiveRate, nameLooksPositional, stripHostAggPrefix, hasDefaultAggPrefix, collapseRepeatedAggPrefix, codeNeedsLegacyAggNames, englishImplicitAggNames, INTENSIVE_WORD_TOKENS, INTENSIVE_SUFFIX_TOKENS, POSITIONAL_WORD_TOKENS, POSITIONAL_SUFFIX_TOKENS, } from "./aggregation";
12
12
  export type { AggKind, AggAdditivity, AggBasis, AggNature, AggregationClass, AggregationColumn, } from "./aggregation";
13
13
  export type { LLMColumnWithValue, TwoSetPairing, ScoreSeparationEntry } from "./models";
14
- export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, LLMResultNotice, GetLicenseStatusResult, } from "./models";
14
+ export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, LLMResultNotice, GetLicenseStatusResult, ShareAskWire, ShareTargetWire, } from "./models";
15
15
  export { ROLE_MATCH_PCT, CITY_ROLE_MATCH_PCT, isBlankLike } from "./matchQuality";
16
16
  export { detectOrdinalDomain, safeDistinctValuesToShip, isOrdinalFriendlyName } from "./ordinalDetector";
17
17
  export { detectFormatSignature } from "./formatDetector";
@@ -38,11 +38,11 @@ export interface IngestOptions {
38
38
  measures?: string[];
39
39
  /** Force these columns to DIMENSION, by name (case-insensitive). */
40
40
  dimensions?: string[];
41
- /** column -> format string. Overrides a descriptor's own `format`. */
41
+ /** column -> format string, by name (case-insensitive; an exact name wins). Overrides a descriptor's own `format`. */
42
42
  formats?: Record<string, string>;
43
- /** column -> description. Overrides a descriptor's own `description`. */
43
+ /** column -> description, by name (case-insensitive; an exact name wins). Overrides a descriptor's own `description`. */
44
44
  descriptions?: Record<string, string>;
45
- /** Columns that are the primary series/breakdown. Surfaces as isGrouping. */
45
+ /** Columns that are the primary series/breakdown, by name (case-insensitive; an exact name wins). Surfaces as isGrouping. */
46
46
  groupBy?: string[];
47
47
  /** MEASURE columns that must not be summed across groups (a ratio, average or rate). */
48
48
  nonAdditive?: string[];
@@ -461,6 +461,25 @@ export type LLMResultNotice = {
461
461
  severity?: string;
462
462
  text?: string;
463
463
  };
464
+ /** The share-and-rate block a landing status answer may carry (GetLicenseStatusResult.shareAsk, and the Excel
465
+ * view-status answer's). Either casing is accepted, because the hosts' status calls serialise differently. */
466
+ export interface ShareAskWire {
467
+ productUrl?: string;
468
+ ProductUrl?: string;
469
+ rateUrl?: string;
470
+ RateUrl?: string;
471
+ targets?: ShareTargetWire[];
472
+ Targets?: ShareTargetWire[];
473
+ }
474
+ /** One network in a ShareAskWire: its short id ("li", "fb", "x"), its name as drawn, and its compose window. */
475
+ export interface ShareTargetWire {
476
+ id?: string;
477
+ Id?: string;
478
+ label?: string;
479
+ Label?: string;
480
+ url?: string;
481
+ Url?: string;
482
+ }
464
483
  export type GetLicenseStatusResult = {
465
484
  errorMessage: string;
466
485
  errorCode?: string;
@@ -493,6 +512,7 @@ export type GetLicenseStatusResult = {
493
512
  latestVersion?: string;
494
513
  latestVersionIsPreview?: boolean;
495
514
  serverMs?: number;
515
+ shareAsk?: ShareAskWire | null;
496
516
  defaultModelCode?: string;
497
517
  isTrial?: boolean;
498
518
  everPaid?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.99",
3
+ "version": "0.6.103",
4
4
  "description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{N as R,V as I,e as L}from"./chunk-AMXLHWUI.mjs";import{a as y,c as C,d as E,e as x}from"./chunk-A4PQBWRA.mjs";import{u as T}from"./chunk-CZJ7M6A5.mjs";import A from"papaparse";var M=500,k=/^[+-]?\d{1,15}$/,P=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,N=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function O(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let m of e){if(m==null)continue;if(typeof m=="number"){l++,a++,Number.isInteger(m)&&r++;continue}if(m instanceof Date){l++,i++;continue}if(typeof m=="boolean"){l++;continue}let c=String(m).trim();if(c!==""){if(l++,k.test(y(c))){r++,a++;continue}if(x(c,o)){a++;continue}if((P.test(c)||N.test(c))&&!isNaN(Date.parse(c))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function _(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=y(a);return k.test(i)?parseInt(i,10):null}case"Decimal":return E(a,n);case"DateTime":return r?r.read(a):T(a);default:return a}}function $(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*q(e,o){for(let n of e)yield n?.[o]}function f(e,o,n){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let r=e.length,a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>C(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(q(o,s),{locale:n.locale??"en"}):null),m=e.map((t,s)=>t.dataType??O(a[s],i[s],l[s]!==null)),c=new Set((n.measures??[]).map(t=>t.toLowerCase())),w=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),j=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),b=e.map((t,s)=>{let u=t.name.toLowerCase(),g=t.isMeasure??((m[s]==="Integer"||m[s]==="Decimal")&&!R(t.name));c.has(u)&&(g=!0),w.has(u)&&(g=!1);let S={name:t.name,dataType:m[s],isMeasure:g};return g&&j.has(u)&&(S.discourageAggregationAcrossGroups=!0),S}),d=new I;d.dedupRows=n.dedup!==!1,d.setColumns(b),d.declareDimensions(b.filter((t,s)=>w.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,g)=>_(s?.[g],m[g],i[g],l[g])),t)}let D=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),p=new Map(D.map(t=>[t.name,t]));e.forEach(t=>{let s=p.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});for(let[t,s]of Object.entries(n.formats??{})){let u=p.get(t);u&&(u.modelFormat=s)}for(let[t,s]of Object.entries(n.descriptions??{})){let u=p.get(t);u&&(u.modelDesc=s)}for(let t of n.groupBy??[]){let s=p.get(t);s&&(s.isGrouping=!0)}return{columns:D,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function h(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function F(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let m of Object.keys(l))r.has(m)||(r.add(m),n.push(m))}return n}function V(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return A.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,m=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let c=i.data;c.length===1&&c[0]===""&&m.replace(/[\r\n]/g,"")===""||n.push(c)}}),!n.length&&!r.length&&r.push(...A.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function H(e,o={}){switch(e.kind){case"csv":{let n=V(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return f(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return f(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return f(e.columns,h(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:F(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return f(r,h(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=$(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return f(n,h(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{$ as a,V as b,H as c};