@bicharts/shape-core 0.6.123 → 0.6.125

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{R,Z as N,f as L}from"./chunk-XLROYZFH.mjs";import{a as h,c as x,d as A,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,a++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,a++;continue}if(I(m,o)){a++;continue}if((v.test(m)||V.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return A(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*W(e,o){for(let n of e)yield n?.[o]}function p(e,o,n){if(e.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let r=e.length;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>x(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),c=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[s]==="Integer"||c[s]==="Decimal")&&!R(t.name));m.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:c[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new N;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],c[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return p(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return p(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return p(r,b(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{O as a,w as b,G as c,K as d,ee as e};
@@ -0,0 +1,2 @@
1
+ /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
+ import{a as Se}from"./chunk-U3H6UBOO.mjs";import{a as wt,f as te,g as _e,h as oe,i as Ae,j as ie}from"./chunk-TZ74QIKA.mjs";import{b as St,c as _t,d as At,e as Ct,f as xt}from"./chunk-YDYFP2T4.mjs";import{c as ht,l as yt,n as ye,p as bt,s as se,w as be,x as De,y as Oe,z as Pe}from"./chunk-DTBXJVUG.mjs";import{e as dt,k as pe,m as gt,n as pt,o as he}from"./chunk-3ZAS32F5.mjs";import{b as mt,d as ft}from"./chunk-5HI6TVMM.mjs";import{A as ge,B as ut,E as ct,a as re,b as ee,c as Je,d as me,g as et,h as tt,j as nt,l as rt,m as it,o as st,p as fe,q as ot,r as at,u as ke,w as lt}from"./chunk-CZJ7M6A5.mjs";import{c as Qe,f as Ee}from"./chunk-WC4JINEZ.mjs";var gn=85,pn=60,hn=/(^|[^a-z])(state|province|provincia|provinz|region|regione|regiao|county|department|departement|departamento|prefecture|oblast|canton|kanton|bundesland|land|territory)([^a-z]|$)/i,Le=t=>Math.round(t*10)/10,Ce=t=>t.split("-")[0];function Mt(t){let e=new Map,n=0;if(t.forEach((s,a)=>{let l=ye(a);l&&(e.set(l,(e.get(l)||0)+s),n+=s)}),n===0)return{};let[i,r]=[...e].sort((s,a)=>a[1]-s[1])[0];return{dominantRegion:i,dominantRegionPct:Le(100*r/n)}}function Mi(t){let e=t.province===null||t.province===void 0?"":String(t.province).trim();if(e)return Tt(e,t.provinceKind,t.country);if(!se())return null;let n=t.city===null||t.city===void 0?"":String(t.city).trim();if(!n)return null;let i=be(n,{country:t.country===null||t.country===void 0?null:String(t.country)});return i.status==="resolved"?i.provinceId:null}function Tt(t,e,n){if(e==="us-state-code"||e==="us-state-name"){let s=xt(t,e);return s?"US-"+s:null}if(!se())return null;if(e==="admin1-code")return Pe(t)?t.toUpperCase():null;let i=n==null?null:String(n),r=new Set(De(t,i).map(Oe).filter(s=>!!s));return r.size===1?[...r][0]:null}function Ti(t,e={}){let n=e.deriveProvinces!==!1,i=new Array(t.length),r=new Array(t.length),s=new Set,a=[],l=new Set,o=[],d=0,u=0,f=0,m=x=>{let A=x.toLowerCase();s.has(A)||(s.add(A),a.push(x))},h=x=>x==null||x===""?null:Number(x),w=new Map;return t.forEach((x,A)=>{i[A]=null,r[A]=null;let p=x.country===null||x.country===void 0||String(x.country).trim()===""?null:String(x.country).trim(),b=x.province===null||x.province===void 0?"":String(x.province).trim();if(b){let C=Tt(b,e.provinceKind,p);C?(i[A]=C,r[A]="province",d++):m(b);return}if(!n)return;let _=h(x.lat),g=h(x.lon),S=!1;if(e.locate&&_!==null&&g!==null&&isFinite(_)&&isFinite(g)){S=!0;let C=e.locate(_,g);if(C){i[A]=C,r[A]="coordinates",d++;return}}let y=x.city===null||x.city===void 0?"":String(x.city).trim();if(y&&se()){let C=y.toLowerCase()+""+(p??""),M=w.get(C);if(M||(M=be(y,{country:p}),w.set(C,M)),M.status==="resolved"&&M.provinceId){i[A]=M.provinceId,r[A]="city",d++;return}if(M.status==="ambiguous"){u++,l.has(C)||(l.add(C),o.length<8&&o.push(y));return}m(y);return}S&&f++}),{iso:i,source:r,unmatched:a,matchedRows:d,totalRows:t.length,ambiguousRows:u,ambiguousExamples:o,unplacedPoints:f}}function vt(t,e,n={}){let i=new Map;if(!se()||e.length===0)return i;let r=t.findIndex(l=>!l.isMeasure&&(l.geoKind||"").startsWith("country")),s=l=>l==null?"":String(l).trim(),a=l=>{let o=new Map;for(let h of e){let w=s(h[l]);if(!w)continue;let x=r>=0&&s(h[r])||null,A=w+""+(x??""),p=o.get(A);p?p.rows++:o.set(A,{city:w,country:x,rows:1})}if(o.size===0)return null;let d=0,u=0,f=new Set,m=new Map;return o.forEach(h=>{let w=be(h.city,{country:h.country});w.status!=="unmatched"&&u++,!(w.status!=="resolved"||!w.provinceId)&&(d++,f.add(w.provinceId),m.set(w.cc,(m.get(w.cc)||0)+h.rows))}),{signals:{rollupPct:Le(100*d/o.size),regionCount:f.size,countryCount:m.size,...Mt(m)},cityPct:100*u/o.size,distinct:o.size}};return t.forEach((l,o)=>{if(l.isMeasure||o===r)return;let d=l.geoKind||"";if(d.startsWith("city")){if(n.cities===!1)return;let C=a(o);C&&i.set(o,C.signals);return}if(d)return;let u=new Map,f=new Map;for(let C of e){let M=s(C[o]);M&&(u.set(M,(u.get(M)||0)+1),f.has(M)||f.set(M,r>=0&&s(C[r])||null))}if(u.size<3)return;let m=0,h=0,w=0,x=new Set,A=new Map;u.forEach((C,M)=>{if(Pe(M)){m++;let z=M.toUpperCase();x.add(z),A.set(Ce(z),(A.get(Ce(z))||0)+C);return}let W=new Set(De(M,f.get(M)).map(Oe).filter(z=>!!z));if(W.size===1){h++;let z=[...W][0];x.add(z),A.set(Ce(z),(A.get(Ce(z))||0)+C)}else W.size>1&&w++});let b=hn.test(l.name.replace(/[_-]+/g," "))?pn:gn,_=100*m/u.size,g=100*h/u.size,S=_>=g,y=S?_:g;if(y<b){if(n.cities===!1)return;let C=a(o);if(!C||C.cityPct<ht||C.distinct<At&&!_t(l.name,St))return;i.set(o,C.signals);return}i.set(o,{kind:S?"admin1-code":"admin1-name",matchPct:Le(y),ambiguous:!S&&w/u.size>.15?!0:void 0,regionCount:x.size,countryCount:A.size,...Mt(A)})}),i}function We(t){let e=(t||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}var Fe={a:0,b:0,c:0,yearFirst:!1,sep:"",trail:"",word:"",day:0,year:0,namedOrder:"dmy",cjkPattern:""},yn=/\s+(\d{1,2}):(\d{2})(?::(\d{2})(?:[.,]\d{1,9})?)?(?:\s*([ap])\.?\s?m\.?)?$/i,bn=/^(\d{1,4})(\s*[./-]\s*)(\d{1,2})(\s*[./-]\s*)(\d{1,4})(\.?)$/,Sn=/^(\d{4})(\s*[年년]\s*)(\d{1,2})(\s*[月월]\s*)(\d{1,2})(\s*[日일号])$/,_n=/(\d)(?:st|nd|rd|th|er|º|ª)(?=[\s.,/-]|$)/gi,An=new Set(["de","del","of"]),Cn=new Set(["\u0433","\u0440","r"]),xn=/^[\p{L}\p{M}\u0970\u05f3]+$/u,ze=/^\d+$/;function wn(t){let e=+t[1],n=+t[2],i=t[3]===void 0?0:+t[3],r=t[4]!==void 0;if(n>59||i>59)return null;if(r){if(e<1||e>12)return null;e=e%12+(t[4].toLowerCase()==="p"?12:0)}else if(e>23)return null;return{h:e,mi:n,s:i,seconds:t[3]!==void 0,meridiem:r}}function Rt(t){let e=t.replace(/[\u200e\u200f\u061c]/g,"").replace(/\s+/g," ").trim();if(e==="")return null;e=wt(e);let n=null,i=yn.exec(e);if(i){if(n=wn(i),!n)return null;e=e.slice(0,i.index)}let r;if(r=Sn.exec(e)){let m=`cjk|${r[2]}|${r[4]}|${r[6]}`;return{...Fe,form:"cjk",key:m,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:!0,cjkPattern:`%Y${r[2]}%m${r[4]}%d${r[6]}`}}if(r=bn.exec(e)){let m=r[2],h=r[4];if(m!==h)return null;let w=m.trim(),x=r[6];if(x&&w!==".")return null;let A=[r[1].length,r[3].length,r[5].length],p=A[0]===4,b=A[2]===4;return p===b||(p?A[1]>2||A[2]>2:A[0]>2||A[1]>2)?null:p&&w==="-"&&m==="-"&&A[1]===2&&A[2]===2?"iso":p&&w==="."&&m==="."&&!x&&!(A[1]===2&&A[2]===2)?null:{...Fe,form:"numeric",key:`num|${p?"y":"x"}|${m}|${x}`,clock:n,a:+r[1],b:+r[3],c:+r[5],yearFirst:p,sep:m,trail:x}}let s=e.replace(_n,"$1").split(/[\s.,/-]+/).filter(m=>m!==""&&!An.has(m.toLowerCase()));if(s.length===4&&ze.test(s[2])&&Cn.has(s[3].toLowerCase())&&s.pop(),s.length!==3)return null;let a=s.map(m=>ze.test(m)?"N":xn.test(m)?"W":"?").join(""),l=s.map(m=>ze.test(m)?m:""),o=0,d=0,u="",f;if(a==="NWN"&&l[0].length<=2&&l[2].length===4)o=+l[0],u=s[1],d=+l[2],f="dmy";else if(a==="WNN"&&l[1].length<=2&&l[2].length===4)u=s[0],o=+l[1],d=+l[2],f="mdy";else if(a==="NWN"&&l[0].length===4&&l[2].length<=2)d=+l[0],u=s[1],o=+l[2],f="ymd";else return null;return{...Fe,form:"named",key:`named|${f}`,clock:n,day:o,year:d,word:u,namedOrder:f}}var Mn=[31,28,31,30,31,30,31,31,30,31,30,31],Tn=t=>t%4===0&&t%100!==0||t%400===0;function It(t,e,n){return t>=1&&t<=9999&&e>=1&&e<=12&&n>=1?n<=(e===2&&Tn(t)?29:Mn[e-1]):!1}function vn(t,e,n,i){let r=new Date(Date.UTC(2e3,e-1,n,i?.h??0,i?.mi??0,i?.s??0));return r.setUTCFullYear(t),r}function Nt(t,e={}){let n=(e.floor??1)>=1,i=new Map,r=new Map,s=0,a=null;for(let p of t){if(p==null)continue;if(typeof p!="string"){if(n)return null;s++;continue}let b=p.trim();if(b==="")continue;s++;let _=i.get(b);if(_===void 0&&(_=Rt(b),i.set(b,_)),_===null||_==="iso"){if(n)return null;continue}if(n){if(a===null)a=_;else if(_.key!==a.key)return null}else r.set(_.key,(r.get(_.key)??0)+1)}if(!n){let p=0,b="";for(let[_,g]of r)g>p&&(p=g,b=_);if(p===0||p/s<e.floor)return null;a=[...i.values()].find(_=>_!==null&&_!=="iso"&&_.key===b)??null}if(a===null)return null;let l=a.key,o=[...i.values()].filter(p=>p!==null&&p!=="iso"&&p.key===l),d,u="shape",f=null;if(a.form==="named"){if(d=a.namedOrder,f=Ae(o.map(p=>p.word),e.locale),!f)return null}else if(a.form==="cjk"||a.yearFirst)d="ymd";else{let p=0,b=0;for(let _ of o)_.a>12&&p++,_.b>12&&b++;if(p>0&&b>0)return null;p>0?(d="dmy",u="values"):b>0?(d="mdy",u="values"):a.sep.trim()==="."?(d="dmy",u="shape"):(d=We(e.locale)?"mdy":"dmy",u="locale")}let m=p=>{if(p.form==="named"){let b=f.get(te(p.word));return b===void 0?null:[p.year,b+1,p.day]}return p.yearFirst?[p.a,p.b,p.c]:d==="dmy"?[p.c,p.b,p.a]:[p.c,p.a,p.b]},h=1/0,w=-1/0,x=0;for(let p of o){let b=m(p);if(!b||!It(b[0],b[1],b[2])){if(n)return null;x++;continue}h=Math.min(h,b[0]),w=Math.max(w,b[0])}if(!n&&(r.get(l)-x)/s<e.floor||h>=2400&&w<=2699||h>=1300&&w<=1500)return null;let A={form:a.form,order:d,orderFrom:u,hasTime:o.some(p=>p.clock!==null),read(p){if(typeof p!="string")return null;let b=p.trim();if(b==="")return null;let _=i.get(b);if(_===void 0&&(_=Rt(b),i.set(b,_)),_===null||_==="iso"||_.key!==l)return null;let g=m(_);return!g||!It(g[0],g[1],g[2])?null:vn(g[0],g[1],g[2],_.clock)}};if(a.form!=="named"&&!o.some(p=>p.clock?.meridiem)){let p;a.form==="cjk"?p=a.cjkPattern:a.yearFirst?p=`%Y${a.sep}%m${a.sep}%d${a.trail}`:p=(d==="dmy"?`%d${a.sep}%m${a.sep}%Y`:`%m${a.sep}%d${a.sep}%Y`)+a.trail;let b=o.filter(_=>_.clock!==null).length;b===0?A.pattern=p:b===o.length&&(A.pattern=p+(o.every(_=>_.clock.seconds)?" %H:%M:%S":" %H:%M"))}return A}import an from"papaparse";var Rn={es:["latitud"],pt:["latitude"],fr:["latitude"],it:["latitudine"],nl:["breedtegraad"],de:["breitengrad"]},In={es:["longitud"],pt:["longitude"],fr:["longitude"],it:["longitudine"],nl:["lengtegraad"],de:["l\xE4ngengrad"]},$e=t=>re(t.normalize("NFC")).toLowerCase(),Nn=new Set(Object.values(Rn).flatMap(t=>(t??[]).map($e))),En=new Set(Object.values(In).flatMap(t=>(t??[]).map($e)));function Et(t){let e=!1,n=!1;for(let i of t){let r=$e(i);Nn.has(r)?e=!0:En.has(r)&&(n=!0)}return e===n?null:e?"lat":"lon"}var kn=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","capita","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan","ocupacion","ocupacao","occupazione","auslastung","bezetting","belaggning","belaegning","belegg","kayttoaste","oblozenie","obsazenost","obsadenost","kihasznaltsag","doluluk","ocupare","popunjenost","efficacite","eficiencia","efficienza","effizienz","effectiviteit","verimlilik"],Dn=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],On=["latitude","longitude"],Pn=["latitude","longitude"];function Q(t){return re(t)}var Ot=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z","sum pa","\u0441\u0443\u043C\u043C\u0430","\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E","\u0441\u0443\u043C\u0430","\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C","\u03B1\u03B8\u03C1\u03BF\u03B9\u03C3\u03BC\u03B1","\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2"],Ln=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von","prom.","\u0441\u0440\u0435\u0434\u043D\u0435\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435","\u0441\u0440\u0435\u0434\u043D\u0435\u0435","\u0441\u0435\u0440\u0435\u0434\u043D\u0454","\u03BC\u03B5\u03C3\u03BF\u03C2 \u03BF\u03C1\u03BF\u03C2","\u0645\u06CC\u0627\u0646\u06AF\u06CC\u0646"],Fn=["osszege","sucet","\u7684\u603B\u548C","\u7684\u8BA1\u6570","\u306E\u5408\u8A08","\uC758 \uD569\uACC4"],zn=["atlaga","priemer","\u7684\u5E73\u5747\u503C","\u306E\u5E73\u5747","\uC758 \uD3C9\uADE0"],xe=Object.freeze({"nombre de":"count","recuento de":"count","contagem de":"count","anzahl von":"count","aantal van":"count","conteggio di":"count","antal av":"count",lukumaara:"count","pocet z":"count",\u043A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E:"count",\u043A\u0456\u043B\u044C\u043A\u0456\u0441\u0442\u044C:"count",\u03C0\u03BB\u03B7\u03B8\u03BF\u03C2:"count",\u7684\u8BA1\u6570:"count","minimum de":"min","minimo de":"min","minimo di":"min","minimum von":"min","maximum de":"max","maximo de":"max","massimo di":"max","maximum von":"max"});function Be(t){return[...t].sort((e,n)=>n.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Pt=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+Be(Ot)+")\\s+)","i");function kt(t){for(let e of t){let n=e.codePointAt(0)??0;if(n>=11904&&n<=40959||n>=44032&&n<=55215)return!0}return!1}var Wn="[\u2013\u2014-]";function Lt(t){let e=t.filter(r=>!kt(r)),n=t.filter(kt),i=[];return e.length&&i.push("(?:\\s+|\\s*"+Wn+"\\s*)("+Be(e)+")"),n.length&&i.push("\\s*("+Be(n)+")"),new RegExp("(?:"+i.join("|")+")\\s*$","i")}var Ge=Lt(Fn),$n=Lt(zn);function we(t,e){let n=e.exec(t);if(!n)return null;let i=t.slice(0,n.index);return i.trim()===""?null:{base:i,label:(n[1]??n[2]??"").toLowerCase()}}function Ft(t){let e=Q(String(t??"").trim().toLowerCase());if(!e)return null;for(let r of Ln)if(e.startsWith(r+" "))return xe[r]??"avg";for(let r of Ot)if(e.startsWith(r+" ")||e===r)return xe[r]??"sum";let n=we(e,$n);if(n)return xe[n.label]??"avg";let i=we(e,Ge);return i?xe[i.label]??"sum":null}var Bn=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Gn=new RegExp("\\b("+kn.join("|")+")\\b|("+Dn.join("|")+")$","i"),Kn=new RegExp("\\b("+On.join("|")+")\\b|("+Pn.join("|")+")$","i");function Te(t){if(!t)return"";let e=String(t),n=Q(e),i=Pt.exec(n);if(i)return e.slice(i[0].length).trim();let r=we(n,Ge);return(r?e.slice(0,r.base.length):e).trim()}function Vn(t){if(!t)return!1;let e=Q(String(t));return Pt.test(e)||we(e,Ge)!==null}var Un=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Dt=new RegExp("^\\s*("+[...Un].sort((t,e)=>e.length-t.length).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ke(t){if(t==null)return"";let e=String(t),n=Dt.exec(e);if(!n)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),r=i(n[1]),s=e.slice(n[0].length),a=0;for(;a<8;){let l=Dt.exec(s);if(!l||i(l[1])!==r)break;let o=s.slice(l[0].length);if(o.trim()==="")break;s=o,a++}return a===0?e:e.slice(0,n[0].length)+s}function Ve(t,e){if(!t||!e)return!1;let n=String(t);for(let i of e){let r=i?.hostName;if(r&&r!==i?.name&&n.includes(r))return!0}return!1}var Me={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},zt=new RegExp("^("+Object.keys(Me).join("|")+")\\((.+)\\)$");function Wt(t){if(!t)return[];let e=zt.exec(String(t).trim());if(!e)return[];let n=Me[e[1]],i=e[2],r=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let a=i.slice(s+1);if(a.trim()!=="")for(let l of n){let o=l+a;r.includes(o)||r.push(o)}}return r}function $t(t,e,n){let i=zt.exec(String(t??"").trim());if(!i)return!1;let r=i[1];if((r==="Count"||r==="CountNonNull")&&n==="Decimal")return!0;let s=new Set(Me[r]),a=String(e??""),l=i[2];for(let o=l.indexOf(".");o>=0;o=l.indexOf(".",o+1)){if(o===0)continue;let d=l.slice(o+1);if(d.trim()!==""){for(let u of Object.values(Me))for(let f of u)if(!s.has(f)&&a===f+d)return!0}}return!1}function Hn(t){let e=Te(t);return e.length===0?"":e.replace(Bn," ")}function Bt(t,e){if(!e)return!1;let n=Te(e);return t.test(Q(Hn(e)))||t.test(Q(n))||t.test(Q(ee(n).join(" ")))}function Gt(t){return Bt(Kn,t)}function Yn(t){return Bt(Gn,t)||Gt(t)}var Kt=/int|double|decimal|single|float|number|currency|money/i;function jn(t){let e=String(t?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||t?.isMeasure===!0||Kt.test(String(t?.dataType??""))?"Continuous":"Categorical"}function Xn(t){return t?.isMeasure===!0||Kt.test(String(t?.dataType??""))}function Vt(t){let e=t??{},n=jn(e);if(n!=="Continuous")return{nature:n,additivity:"unknown",basis:"role",suppressed:!1};if(Gt(e.name))return{nature:n,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&Vn(e.name))){if(i==="additive")return{nature:n,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:n,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:n,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:n,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Yn(e.name)?{nature:n,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:n,additivity:"additive",basis:"default",suppressed:!1}}function Ut(t){let e=Vt(t),n=t??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return Xn(n)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Pi(t){return Ut(t)[0]}function Li(t,e){return Ut(t).indexOf(e)>=0}function Fi(t,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let n=Vt(t);return n.additivity==="additive"||n.additivity==="part_of_whole"||n.additivity==="unknown"}var qn={de:["nr","nummer","kennung","kennziffer","plz","postleitzahl"],nl:["nr","nummer"],sv:["nr","nummer"],da:["nr","nummer"],nb:["nr","nummer"],fi:["tunnus","koodi","nro"],hu:["azonos\xEDt\xF3","k\xF3d"],tr:["kod","kodu","numaras\u0131","numarasi"],zh:["\u7F16\u53F7","\u4EE3\u7801","\u7F16\u7801","\u53F7\u7801","\u90AE\u7F16"],ja:["\u756A\u53F7","\u30B3\u30FC\u30C9"],ko:["\uBC88\uD638","\uCF54\uB4DC"],hi:["\u0915\u094B\u0921","\u0915\u094D\u0930\u092E\u093E\u0902\u0915"],fr:["num\xE9ro"],es:["c\xF3digo"],pt:["c\xF3digo","cep"],it:["codice"],pl:["kod","numer"],cs:["k\xF3d","\u010D\xEDslo"],sk:["k\xF3d","\u010D\xEDslo"],hr:["\u0161ifra","oznaka"],ru:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],uk:["\u043A\u043E\u0434","\u043D\u043E\u043C\u0435\u0440"],el:["\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2"],ar:["\u0631\u0645\u0632","\u0643\u0648\u062F","\u0631\u0642\u0645"],he:["\u05E7\u05D5\u05D3"],id:["kode","nomor"],vi:["m\xE3"],th:["\u0E23\u0E2B\u0E31\u0E2A"]},Zn=["fr","es","pt","it","pl","cs","sk","hr","ru","uk","el","ar","he","id","vi","th"],Qn=["num\xE9ro"],Jn=t=>t.normalize("NFC").toLowerCase();function er(t,e,n,i){let r=Ee(n);return!r||!t?null:t===e?"word":r.wordBreaks===!1?Array.from(e).length<it?null:(i?t.startsWith(e):t.endsWith(e))&&t.length>e.length?"suffix":null:i?nt(t,n).includes(e)?"word":null:r.script==="Hang"?rt(t,e)?"suffix":null:r.compounds&&tt(t,e,et)?"suffix":null}function Ht(t){let e=String(t??"").trim();if(!e)return null;let n=me(e),i=me(Te(e));for(let[r,s]of Object.entries(qn)){let a=Zn.includes(r),l=a?i:n;for(let o of s){let d=Qn.includes(o)||!!Ee(r)?.foldSensitive,u=d?l.words:l.folded;if(u.length===0)continue;let f=d?Jn(o):me(o).folded.join(" "),m=er(a?u[0]:u[u.length-1],f,r,a);if(m)return{lang:r,word:o,view:m}}}return null}var tr=[["Lu",/^\p{Lu}$/u],["Ll",/^\p{Ll}$/u],["Lt",/^\p{Lt}$/u],["Lm",/^\p{Lm}$/u],["Lo",/^\p{Lo}$/u],["Mn",/^\p{Mn}$/u],["Mc",/^\p{Mc}$/u],["Nd",/^\p{Nd}$/u]];function ve(t){for(let[e,n]of tr)if(n.test(t))return e;return null}var nr=[{id:"ascii",test:/^[A-Za-z]$/,ranges:[[65,90],[97,122]]},{id:"latin",test:/^[\u00C0-\u017F]$/u,ranges:[[192,383]]},{id:"cyrillic",test:/^[\u0400-\u045F\u0490-\u0491]$/u,ranges:[[1024,1119],[1168,1169]]},{id:"greek",test:/^[\u0386-\u03CE]$/u,ranges:[[902,974]]},{id:"han",test:/^[\u4E00-\u9FFF]$/u,ranges:[[19968,40959]]},{id:"hiragana",test:/^\p{Script=Hiragana}$/u,ranges:[[12353,12447]]},{id:"katakana",test:/^\p{Script=Katakana}$/u,ranges:[[12448,12543]]},{id:"hangul",test:/^[\uAC00-\uD7A3]$/u,ranges:[[44032,55203]]},{id:"arabic",test:/^[\u0620-\u0652\u0671-\u06D3]$/u,ranges:[[1568,1618],[1649,1747]]},{id:"hebrew",test:/^[\u05B0-\u05EA]$/u,ranges:[[1456,1514]]},{id:"devanagari",test:/^\p{Script=Devanagari}$/u,ranges:[[2304,2431]]},{id:"thai",test:/^\p{Script=Thai}$/u,ranges:[[3585,3662]]}],Re=new Map;function Yt(t,e,n,i){let r=Re.get(t);if(r)return r;let s=[];for(let[a,l]of e)for(let o=a;o<=l;o++){let d=String.fromCodePoint(o);ve(d)===n&&(i&&!i.test(d)||s.push(d))}return Re.set(t,s),s}function rr(t){let n=t.codePointAt(0);for(let a=0;a<9&&ve(String.fromCodePoint(n-1))==="Nd";a++)n--;let i="nd:"+n.toString(16),r=Re.get(i);if(r)return r;let s=[];for(let a=n;a<n+10;a++){let l=String.fromCodePoint(a);ve(l)==="Nd"&&s.push(l)}return Re.set(i,s),s}function ir(t,e){if(e==="Nd")return rr(t);for(let r of nr)if(r.test.test(t))return Yt(r.id+":"+e,r.ranges,e,r.id==="ascii"?null:r.test);let i=t.codePointAt(0)&-128;return Yt("block:"+i.toString(16)+":"+e,[[i,i+127]],e,null)}function sr(t,e,n,i){let r=t.filter(s=>!e.has(s));return r.length===0&&(r=t.filter(s=>s!==n)),r.length===0?n:r[Math.min(r.length-1,Math.floor(i()*r.length))]}var or=/^[\p{L}\p{M}\p{Nd}]$/u,jt=/^[\p{L}\p{Nd}]$/u;function Xt(t,e){if(!t)return t??"";let n=new Set(Array.from(t)),i=u=>{let f=ve(u);return!f||!or.test(u)?u:sr(ir(u,f),n,u,e)},r=u=>{let f=[];for(let m of u)f.push(i(m)),jt.test(m)&&e()<.2&&f.push(i(m));if(f.length>6){let m=Math.floor(e()*Math.min(3,f.length-6));for(let h=0;h<m;h++)for(let w=0;w<5;w++){let x=Math.floor(e()*f.length);if(jt.test(f[x])){f.splice(x,1);break}}}return f.join("")};if(!(t.includes("@")&&t.includes(".")))return r(t);let[a,l=""]=t.split("@"),o=l.endsWith(".com"),d=o?l.slice(0,-4):l;return`${r(a)}@${r(d)}${o?".com":""}`}var ar=/^[A-Za-z_$][A-Za-z0-9_$]*$/,lr=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ur=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function ae(t,e){if(!t||!e)return!1;let n=lr(e);return new RegExp("['\"`]"+n+"['\"`]").test(t)?!0:ar.test(e)&&new RegExp("\\."+n+"(?![A-Za-z0-9_$])").test(t)}function cr(t){return!!t&&ur.test(t)}function Vi(t,e,n){return t?cr(t)?[...e]:[...n,...e].some(i=>ae(t,i))?e.filter(i=>ae(t,i)):[...e]:[]}var dr=5,mr=6,fr=3,ne=864e5,gr=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,pr=/^(\d{4})[-/](\d{1,2})$/,hr=/^(\d{4})[-\s]?Q([1-4])$/i,yr=/^Q([1-4])[-\s](\d{4})$/i,br=/^(\d{4})$/,Sr=/^(\d{4})(0[1-9]|1[0-2])$/,_r=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/,Ar=/^(\D+?)[\s\-/.,']*((?:19|20)\d{2})$/u,Cr=/^((?:19|20)\d{2})[\s\-/.,']+(\D+)$/u;function Ue(t,e,n){let i=te(t);if(!i)return 0;if(i==="sept")return 9;for(let a of e&&!/^en\b/i.test(e)?["en",e]:["en"]){let l=_e(a)[i];if(l!==void 0)return l+1}let r=n?.get(i);if(r!==void 0)return r+1;let s=oe(t);if(s.length>0){if(s.every(o=>o.month===s[0].month))return s[0].month+1;let a=Qe(String(e??"").split(/[-_]/)[0])?.code,l=s.find(o=>o.lang===a);if(l)return l.month+1}return 0}function xr(t){let e=pe(t).filter(i=>i.yearDigits===4);if(e.length===0||e.some(i=>i.lang==="en"))return null;let n=e[0];return e.some(i=>i.grain!=="quarter"||i.n!==n.n||i.year!==n.year)?null:j(n.year,(n.n-1)*3+1,1)}function j(t,e,n,i=0,r=0,s=0){if(!(t>=1&&e>=1&&e<=12&&n>=1&&n<=31))return null;let a=Date.UTC(t,e-1,n,i,r,s);if(!Number.isFinite(a))return null;let l=o=>o<10?"0"+o:String(o);return{ms:a,y:t,m:e,d:n,iso:`${t}-${l(e)}-${l(n)}`}}function wr(t,e){let n=[],i="";for(let o=0;o<e.length;o++){if(e[o]!=="%"){i+=e[o].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++o]){case"Y":n.push("Y"),i+="(\\d{4})";break;case"m":n.push("m"),i+="(\\d{1,2})";break;case"d":n.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let r=new RegExp("^"+i+"$").exec(t);if(!r)return null;let s=0,a=1,l=1;return n.forEach((o,d)=>{let u=+r[d+1];o==="Y"?s=u:o==="m"?a=u:l=u}),s?j(s,a,l):null}function X(t,e,n,i){let r=(t??"").trim();if(r==="")return null;if(e){let o=wr(r,e);return o||null}let s=gr.exec(r);if(s)return j(+s[1],+s[2],+s[3],+(s[4]??0),+(s[5]??0),+(s[6]??0));if(s=hr.exec(r),s)return j(+s[1],(+s[2]-1)*3+1,1);if(s=yr.exec(r),s)return j(+s[2],(+s[1]-1)*3+1,1);if(s=pr.exec(r),s&&+s[2]>=1&&+s[2]<=12)return j(+s[1],+s[2],1);if(s=_r.exec(r),s)return j(+s[1],+s[2],+s[3]);if(s=Sr.exec(r),s)return j(+s[1],+s[2],1);if(s=br.exec(r),s){let o=+s[1];return o>=1900&&o<=2100?j(o,1,1):null}let a=xr(r);if(a)return a;if(s=Ar.exec(r),s){let o=Ue(s[1],n,i);if(o)return j(+s[2],o,1)}if(s=Cr.exec(r),s){let o=Ue(s[2],n,i);if(o)return j(+s[1],o,1)}let l=ie(r);if(l){let o="month"in l?l.month:Ue(l.word,n,i);if(o)return j(l.year,o,1)}return null}function qt(t){let e=new Date(t).getUTCDay();return e>=1&&e<=5}function Zt(t,e){if(e<=t)return 0;let n=Math.round((e-t)/ne),i=Math.floor(n/7),r=i*5,s=t+i*7*ne;for(;s<e;)qt(s)&&r++,s+=ne;return r}function Mr(t){if(t.length===0)return 0;let e=[...t].sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Tr(t){return t>0?t<.95?"hour":t<=1.05?"day":t>=6.5&&t<=7.5?"week":t>=27&&t<=31.5?"month":t>=88&&t<=93?"quarter":t>=362&&t<=368?"year":"irregular":"irregular"}function le(t,e,n,i){switch(n){case"year":return e.y-t.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(t.y*4+Math.floor((t.m-1)/3));case"month":return e.y*12+e.m-(t.y*12+t.m);case"week":return Math.round((e.ms-t.ms)/(7*ne));case"weekday":return Zt(t.ms,e.ms);case"day":return Math.round((e.ms-t.ms)/ne);default:return i>0?Math.round((e.ms-t.ms)/i):0}}function Qt(t,e){return He(t,e)?.cadence??null}function He(t,e){let n=e?.gapFactor??dr,i=0,r=0,s=new Map,a=Array.from(t),l;if(!e?.pattern){let g=[];for(let S of a){if(S==null||S==="")continue;let y=ie(String(S));y&&"word"in y&&g.push(y.word)}g.length>0&&(l=Ae(g,e?.locale)??void 0)}for(let g of a){if(g==null||g==="")continue;i++;let S=X(String(g),e?.pattern,e?.locale,l);S&&(r++,s.set(S.ms,S))}let o=[...s.values()].sort((g,S)=>g.ms-S.ms);if(o.length<fr||i>0&&r/i<.8)return null;let d=o[o.length-1].ms-o[0].ms;if(d<=0)return null;let u=[];for(let g=1;g<o.length;g++)u.push(o[g].ms-o[g-1].ms);let f=Mr(u);if(!(f>0))return null;let m=Tr(f/ne);m==="day"&&d>=7*ne&&o.every(g=>qt(g.ms))&&Zt(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(m="weekday");let h=m==="irregular"?o.length:le(o[0],o[o.length-1],m,f)+1,w=1,x=1,A=[],p=o[0],b=1;for(let g=1;g<o.length;g++){let S=le(o[g-1],o[g],m,f);S>w&&(w=S),m!=="irregular"&&S>n?(x++,A.push({from:p.iso,to:o[g-1].iso,points:b}),p=o[g],b=1):b++}A.push({from:p.iso,to:o[o.length-1].iso,points:b});let _={grain:m,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:x,largestGapUnits:w,gapFactor:n};return e?.includeBounds&&A.length<=mr&&(_.runBounds=A),{cadence:_,points:o,stepMs:f}}var vr=8,Rr=.5,Ir=200,Nr=new Set(["category","categories","subcategory","type","types","kind","class","classes","classification","segment","segments","tier","status","priority","severity","grade","level","band","bucket","group","channel","method","mode","stage","phase","period","shift","gender","sex","result","outcome","reason","flag","genre","sector","source"]),Er=["category","classification","segment","status","priority","severity","channel"],kr=new Set(["UUID","EMAIL_LIKE","URL_LIKE","PHONE_LIKE","NUMERIC_ID","HEX_ID","OPAQUE_ID_ALPHANUMERIC","DATE_STR","BOOLEAN"]);function Dr(t){let e=ee(t);if(e.length===0)return!1;let n=e[e.length-1];return Nr.has(n)?!0:Er.some(i=>n.length>i.length&&n.endsWith(i))}function Or(t){if(t.isMeasure)return"measure";if(t.isTemporal||t.isDatePart||t.isReassembledDate)return"temporal";let e=Array.from(t.values).filter(n=>n!==""&&n!==null&&n!==void 0);return e.length<2||e.length>Ir?"cardinality":t.rows>0&&e.length>=t.rows?"row-identity":t.isBinaryFlag?"flag":he(e,t.locale)!==null?"ordinal":t.identifierNamed||t.dataType==="String"&&kr.has(Se(e))?"identifier":!t.geoKind&&Dr(t.name)?"attribute":"entity"}function tn(t){let e=-1,n=1/0,i=!1;return t.forEach((r,s)=>{if(Or(r)!=="entity")return;let a=new Set(Array.from(r.values).filter(o=>o!=="")).size,l=!!r.geoKind;(a<n||a===n&&l&&!i)&&(e=s,n=a,i=l)}),e}var Jt=t=>t<10?"0"+t:String(t);function en(t,e){switch(e){case"year":return`${t.y}-01-01`;case"quarter":return`${t.y}-${Jt(Math.floor((t.m-1)/3)*3+1)}-01`;case"month":return`${t.y}-${Jt(t.m)}-01`;case"hour":return new Date(t.ms).toISOString().replace(/\.\d{3}Z$/,"Z");default:return t.iso}}function nn(t){let{periods:e,series:n}=t,i=Math.min(e.length,n.length),r=new Set;for(let S=0;S<i;S++)e[S]&&r.add(e[S]);let s=He(r,{pattern:t.pattern,locale:t.locale});if(!s)return null;let a=s.cadence.grain;if(a==="irregular")return null;let l=s.points[0],o=le(l,s.points[s.points.length-1],a,s.stepMs)+1;if(o!==s.cadence.expectedPoints)return null;let d=new Map;for(let S of r){let y=X(S,t.pattern,t.locale);if(!y)continue;let C=le(l,y,a,s.stepMs);C>=0&&C<o&&d.set(S,{idx:C,stamp:y})}let u=new Map;for(let S=0;S<i;S++){let y=n[S];if(!y)continue;let C=d.get(e[S]);if(!C)continue;let M=u.get(y);M||(M={seen:new Set,lo:C.idx,hi:C.idx,loStamp:C.stamp,hiStamp:C.stamp,order:u.size},u.set(y,M)),M.seen.add(C.idx),C.idx<M.lo&&(M.lo=C.idx,M.loStamp=C.stamp),C.idx>M.hi&&(M.hi=C.idx,M.hiStamp=C.stamp)}if(u.size<2)return null;let f=0;for(let S of u.values())f+=S.seen.size;if(f/(u.size*o)<(t.minFill??Rr))return null;let m=[],h=new Set,w=0,x=0,A=0,p=0,b=0,_=1;for(let[S,y]of u){for(let z of y.seen)h.add(z);if(y.seen.size>=o)continue;let C=[...y.seen].sort((z,q)=>z-q),M=1;for(let z=1;z<C.length;z++)M=Math.max(M,C[z]-C[z-1]);let W={key:S,acc:y,coverage:y.seen.size/o,before:y.lo,after:o-1-y.hi,interior:y.hi-y.lo+1-y.seen.size,gap:M};m.push(W),W.before>0&&w++,W.after>0&&x++,W.interior>0&&A++,p=Math.max(p,W.before),b=Math.max(b,W.after),_=Math.max(_,M)}if(m.length===0)return null;m.sort((S,y)=>S.coverage-y.coverage||S.acc.order-y.acc.order);let g=m.slice(0,t.maxListed??vr);return{seriesColumn:t.seriesColumn,grain:a,periods:o,seriesCount:u.size,incompleteSeries:m.length,lateStarts:w,earlyEnds:x,withHoles:A,columnWideMissing:o-h.size,maxMissingBefore:p,maxMissingAfter:b,largestGap:_,series:g.map(S=>{let y={};return t.includeNames&&(y.name=S.key),t.includeDates&&(y.first=en(S.acc.loStamp,a),y.last=en(S.acc.hiStamp,a)),y.missingBefore=S.before,y.missingAfter=S.after,y.missingInterior=S.interior,y.largestGap=S.gap,y.coverage=Math.round(S.coverage*1e3)/1e3,y}),more:m.length-g.length}}var Ie=6;function ue(t){let e=t.slice().sort((i,r)=>i-r),n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}function Pr(t){let e=t.length;if(e<Ie)return null;let n=t[0],i=t[0],r=0;for(let g of t)g<n&&(n=g),g>i&&(i=g),r+=g;if(n===i)return null;let s=ue(t.map(Math.abs));if(s===0)return null;let a=[];for(let g=1;g<e;g++)a.push(t[g]-t[g-1]);let l=ue(a.map(Math.abs))/s,o=(e-1)/2,d=r/e,u=0,f=0,m=0;for(let g=0;g<e;g++)u+=(g-o)*(t[g]-d),f+=(g-o)*(g-o),m+=(t[g]-d)*(t[g]-d);m/=e;let h=u/f,w=d-h*o,x=t.map((g,S)=>g-(w+h*S)),A=x.reduce((g,S)=>g+S,0)/e,p=0,b=0;for(let g=0;g<e;g++)p+=(x[g]-A)*(x[g]-A),g>0&&(b+=(x[g]-x[g-1])*(x[g]-x[g-1]));return p/=e,b/=e-1,{vnDetrended:p<=m*1e-12?2:b/p,relStep:l}}function Ye(t){let{stamps:e,series:n,values:i}=t,r=Math.min(e.length,i.length),s=new Map;for(let d=0;d<r;d++){let u=e[d],f=i[d];if(u===null||f===null||!Number.isFinite(f))continue;let m="";if(n&&(m=n[d]??"",m===""))continue;let h=s.get(m);h||s.set(m,h=new Map),h.set(u,(h.get(u)??0)+f)}let a=[],l=[],o=[];for(let d of s.values()){let u=[...d.entries()].sort((m,h)=>m[0]-h[0]).map(m=>m[1]),f=Pr(u);f&&(a.push(f.vnDetrended),l.push(f.relStep),o.push(u.length))}return a.length===0?null:{series:a.length,points:Math.round(ue(o)),vnDetrended:Math.round(ue(a)*1e3)/1e3,relStep:Math.round(ue(l)*1e4)/1e4}}function ns(t){let e=t.times.map(n=>X(n,t.pattern,t.locale)?.ms??null);return Ye({stamps:e,series:t.series,values:t.values})}var Lr=5e5,Fr=8,zr=4,Wr=5,je=1,Xe=2,$r=4,Br=8;function Gr(t,e,n){let[i,r]=[...t];if(e.isTemporal){let s=X(i,e.temporalTextPattern,n),a=X(r,e.temporalTextPattern,n);if(s&&a&&s.ms!==a.ms)return s.ms<a.ms?{a:i,b:r,setOrder:"temporal"}:{a:r,b:i,setOrder:"temporal"}}return i<r?{a:i,b:r,setOrder:"none"}:{a:r,b:i,setOrder:"none"}}function Kr(t,e,n){let{rows:i,text:r,locale:s}=t,a=Gr(n.values,n,s),l=new Uint8Array(i.length),o=0;for(let d=0;d<i.length;d++){let u=r(i[d][e]);u===a.a?l[d]=1:u===a.b?l[d]=2:o++}return{code:l,blankRows:o,setOrder:a.setOrder}}function Vr(t,e){let{rows:n,text:i}=t,r=new Int32Array(n.length),s=new Map;for(let a=0;a<n.length;a++){let l=i(n[a][e]);if(l===""){r[a]=-1;continue}let o=s.get(l);o===void 0&&(o=s.size,s.set(l,o)),r[a]=o}return{ids:r,dict:s}}function Ur(t,e,n){let i=new Uint8Array(n);for(let s=0;s<t.length;s++){let a=e[s];if(a===0)continue;let l=t[s];if(l<0)continue;let o=i[l];i[l]=o&a?o|a<<2:o|a}let r={keysA:0,keysB:0,keysBoth:0,dupA:0,dupB:0};for(let s=0;s<n;s++){let a=i[s];a&je&&r.keysA++,a&Xe&&r.keysB++,(a&(je|Xe))===(je|Xe)&&r.keysBoth++,a&$r&&r.dupA++,a&Br&&r.dupB++}return r}function Hr(t,e){let n=(t.dupA+t.dupB)*(e.keysA+e.keysB),i=(e.dupA+e.dupB)*(t.keysA+t.keysB);return n<i||n===i&&t.keysBoth>e.keysBoth}var rn=t=>t==null||typeof t=="string"&&t.trim()==="";function Yr(t,e,n){if(t===e)return!0;let i=rn(t),r=rn(e);return i||r?i&&r:typeof t=="number"&&typeof e=="number"?!1:t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():n(t).trim()===n(e).trim()}function sn(t){let{rows:e,columns:n}=t,i=e.length;if(i<2||i>Lr)return null;let r=n.map((y,C)=>({c:y,i:C})).filter(({c:y})=>!y.isMeasure&&!y.isTemporal&&!y.isDatePart&&y.distinct>=Wr).sort((y,C)=>(C.c.identifierNamed?1:0)-(y.c.identifierNamed?1:0)||C.c.distinct-y.c.distinct||y.i-C.i).slice(0,Fr),s=n.map((y,C)=>({c:y,i:C})).filter(({c:y})=>!y.isMeasure&&y.values!==null&&y.values.size===2).slice(0,zr);if(r.length===0||s.length===0)return null;let a=s.map(({c:y,i:C})=>Kr(t,C,y)),l=null;for(let{i:y}of r){let C=Vr(t,y);for(let M=0;M<s.length;M++){if(s[M].i===y)continue;let W=Ur(C.ids,a[M].code,C.dict.size);W.keysBoth<1||(!l||Hr(W,l.tally))&&(l={tally:W,keyIdx:y,setNo:M,ids:C.ids,dict:C.dict})}}if(!l)return null;let{ids:o,dict:d,tally:u}=l,f=a[l.setNo],m=s[l.setNo].i,h=d.size,w=new Int32Array(h).fill(-1),x=new Int32Array(h).fill(-1);for(let y=0;y<i;y++){let C=f.code[y],M=o[y];C===0||M<0||(C===1?w[M]<0&&(w[M]=y):x[M]<0&&(x[M]=y))}let A=[];for(let y=0;y<n.length;y++)y!==l.keyIdx&&y!==m&&A.push(y);let p=0;for(let y=0;y<h;y++){let C=w[y],M=x[y];if(C<0||M<0)continue;let W=e[C],z=e[M],q=!0;for(let J of A)if(!Yr(W[J],z[J],t.text)){q=!1;break}q&&p++}let b=p===u.keysBoth?100:p===0?0:Math.min(99,Math.max(1,Math.round(p/u.keysBoth*100))),_=new Map,g=new Map;for(let[y,C]of d){let M=w[C]>=0,W=x[C]>=0;if(!M&&!W)continue;let z=mt(y);ft(z)&&(M&&_.set(z,(_.get(z)??0)+1),W&&g.set(z,(g.get(z)??0)+1))}let S=y=>{let C=0;for(let M of y.values())M>=2&&(C+=M);return C};return{key:l.keyIdx,discriminator:m,pairing:{form:"long",key:n[l.keyIdx].name,discriminator:n[m].name,keysA:u.keysA,keysB:u.keysB,keysBoth:u.keysBoth,duplicateKeysA:u.dupA,duplicateKeysB:u.dupB,identicalPct:b,discriminatorBlankRows:f.blankRows,looseCollisionsA:S(_),looseCollisionsB:S(g),setOrder:f.setOrder}}}var jr=t=>t==="Integer"||t==="Decimal";function Xr(t){let e=[],n=[];return t.forEach((i,r)=>{if(i.twoValues){if(i.isBinaryFlag){e.push(r);return}i.isMeasure||i.isTemporal||i.isDatePart||i.identifierNamed||n.push(r)}}),[...e,...n].slice(0,6)}function qr(t,e){let n=[];for(let i=0;i<t.length&&n.length<12;i++){let r=t[i];e.has(i)||!jr(r.dataType)||r.isTemporal||r.isDatePart||r.identifierNamed||r.distinct<3||n.push(i)}return n}function on(t){let e=new Map,{rows:n,columns:i,text:r}=t;if(n.length===0||n.length>(t.maxRows??5e5))return e;let s=Xr(i);if(s.length===0)return e;let a=qr(i,new Set(s));if(a.length===0)return e;let l=s.map(o=>{let[d,u]=i[o].twoValues,f=new Uint8Array(n.length);for(let m=0;m<n.length;m++){let h=r(n[m][o]);f[m]=h===d?1:h===u?2:0}return f});for(let o of a){let d=new Float64Array(n.length),u=0;for(let b=0;b<n.length;b++){let _=n[b][o],g=_==null||_===""?NaN:typeof _=="number"?_:parseFloat(_);d[b]=g,g===g&&g!==1/0&&g!==-1/0&&u++}if(u<2)continue;let f=new Float64Array(u);for(let b=0,_=0;b<n.length;b++){let g=d[b];g===g&&g!==1/0&&g!==-1/0&&(f[_++]=g)}f.sort();let m=new Float64Array(u),h=0;for(let b=0;b<u;b++)(b===0||f[b]!==f[b-1])&&(m[h++]=f[b]);let w=new Int32Array(n.length).fill(-1);for(let b=0;b<n.length;b++){let _=d[b];if(!(_===_&&_!==1/0&&_!==-1/0))continue;let g=0,S=h-1;for(;g<S;){let y=g+S>>>1;m[y]<_?g=y+1:S=y}w[b]=g}let x=[],A=new Int32Array(h),p=new Int32Array(h);for(let b=0;b<s.length;b++){let _=l[b];A.fill(0),p.fill(0);let g=0,S=0;for(let Y=0;Y<n.length;Y++){let U=w[Y];U<0||(_[Y]===1?(A[U]++,g++):_[Y]===2&&(p[U]++,S++))}if(g===0||S===0)continue;let y=g<=S,C=y?g:S,M=y?S:g,W=y?A:p,z=y?p:A,q=0,J=0,ce=0;for(let Y=0;Y<h;Y++){let U=W[Y],c=z[Y];q+=U*(J+.5*c),J+=c,U+c>=2&&(ce+=U+c)}x.push({outcome:i[s[b]].name,aucMinorityHigh:Math.round(q/(C*M)*1e4)/1e4,nMinority:C,nMajority:M,ties:ce})}x.length>0&&e.set(o,x)}return e}var ln=12,Zr=100,Qr=.3,Jr=.9,ei=120,ti=1900,ni=2100,ri=0,ii=20,si=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ne(t){if(!t)return!1;let e=ee(t);return e.length===0?!1:si.has(e[e.length-1])?!0:Ht(t)!==null}var oi=new Set(["year","yr","fy"]),ai=t=>ee(t).some(e=>oi.has(e))||dt(t)!==null,li=/^(?:(?:19|20)\d{2}(?:[-/ ]?(?:q[1-4]|w(?:0?[1-9]|[1-4]\d|5[0-3])|(?:0?[1-9]|1[0-2])))?|q[1-4][-/ ](?:19|20)\d{2}|(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*[-/ ]?(?:19|20)?\d{2})$/i;function qe(t){if(!Number.isInteger(t)||t<190001||t>210012)return!1;let e=t%100;return e>=1&&e<=12}function Ze(t){if(!Number.isInteger(t)||t<19000101||t>21001231)return!1;let e=Math.floor(t/100)%100,n=t%100;return e>=1&&e<=12&&n>=1&&n<=31}var ui=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ci=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,di=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function dn(t,e){let n=[],i=0,r=mi(t,e,n,()=>{i++});if(r)return r;if(i>0||n.length<2)return null;let s=Nt(n,{locale:e,floor:.8});return!s||!s.pattern||s.form==="named"?null:{pattern:s.pattern,orderFrom:s.orderFrom==="shape"?s.order==="ymd"?"iso":"shape":s.orderFrom}}function mi(t,e,n,i){let r=0,s=0,a=0,l=0,o=0,d="",u=0,f="",m=0,h=0,w=0,x=0,A=!1;for(let y of t){if(y==null)continue;let C=String(y).trim();if(C==="")continue;r++,n.push(C);let M;if(M=ui.exec(C)){i();let W=+M[2],z=+M[3];W>=1&&W<=12&&z>=1&&z<=31&&(s++,M[4]!==void 0&&a++,M[6]!==void 0&&l++)}else if(M=ci.exec(C)){i();let W=+M[3],z=+M[4];W>=1&&W<=12&&z>=1&&z<=31&&(d&&d!==M[2]&&(A=!0),d=M[2],o++)}else if(M=di.exec(C)){i();let W=+M[1],z=+M[3];W>=1&&W<=31&&z>=1&&z<=31&&(W<=12||z<=12)&&(f&&f!==M[2]&&(A=!0),f=M[2],u++,W>12&&w++,z>12&&x++,M[5]!==void 0&&m++,M[7]!==void 0&&h++)}if(r>=200)break}if(r<2||(s+o+u)/r<.8||(s>0?1:0)+(o>0?1:0)+(u>0?1:0)!==1||A)return null;if(s>0)return a===s?{pattern:l===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${d}%m${d}%d`,orderFrom:"iso"};if(w>0&&x>0)return null;let _,g;w>0?(_=!0,g="values"):x>0?(_=!1,g="values"):f==="."?(_=!0,g="shape"):(_=!We(e),g="locale");let S=_?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return m===u?{pattern:S+(h===u?" %H:%M:%S":" %H:%M"),orderFrom:g}:{pattern:S,orderFrom:g}}function fi(t,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(t))return!1;let n=t.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let i=te(n);return i.length>0&&e[i]!==void 0}function gi(t,e){let n=new Map,i=new Map;for(let l of t){let o=ie(l);if(!o||"month"in o)continue;let d=oe(o.word),u=d.some(m=>m.lang==="en"),f=te(o.word);for(let m of new Set(d.map(h=>h.lang)))m!=="en"&&(n.has(m)||(n.set(m,new Set),i.set(m,new Set)),n.get(m).add(f),u||i.get(m).add(f))}let r=[...n.keys()].filter(l=>n.get(l).size>=3&&i.get(l).size>=1),s=0,a=new Map(r.map(l=>[l,0]));for(let l of e){let o=ie(l);if(!o)continue;if("month"in o){s++;continue}let d=oe(o.word);if(d.length===0)continue;let u=d.some(f=>f.lang==="en");for(let f of r)(u||d.some(m=>m.lang===f))&&a.set(f,a.get(f)+1)}return s+Math.max(0,...a.values())}var pi=/(?:19|20)[0-9]{2}/;function hi(t){let e=new Map,n=0;for(let r of t){if(!pi.test(re(r)))continue;let s=new Set(pe(r).filter(a=>a.yearDigits===4&&(a.grain==="quarter"||a.grain==="week")).map(a=>a.lang));if(s.size!==0){if(s.has("en")){n++;continue}for(let a of s)e.set(a,(e.get(a)??0)+1)}}let i=0;for(let r of e.values())i=Math.max(i,r);return i>0?i+n:0}function yi(t){let{dataType:e,name:n,isMeasure:i,distinctCount:r}=t;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let s=t.minNum,a=t.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let o=s>=1900&&a<=2100;if(o&&r>=2&&ai(n)||o&&r>=3&&r===a-s+1)return!0;let d=qe(s)&&qe(a),u=Ze(s)&&Ze(a);if(d||u){if(!t.sampleValues)return!0;let f=0,m=0;for(let h of t.sampleValues){if(h==null||h==="")continue;f++;let w=Number(String(h).trim());if(Number.isFinite(w)&&(d?qe(w):Ze(w))&&m++,f>=60)break}if(f>=2&&m===f)return!0}return!1}if(t.sampleValues){let s=t.locale?_e(t.locale):null,a=0,l=0,o=[],d=[];for(let u of t.sampleValues){if(u==null||u==="")continue;a++;let f=String(u).trim();if(o.push(f),li.test(f)||fi(f,s)?l++:d.push(f),a>=60)break}if(a>=2&&l/a>=.8||a>=2&&(l+hi(d)+gi(o,d))/a>=.8||dn(o,t.locale)!==null)return!0}return!1}function bi(t){let e=Q((t||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Ft(t)}function Si(t){let{rows:e,measureColIdx:n,measureName:i,candidateDims:r,minNum:s,maxNum:a,discourageAgg:l}=t,o=100,d=.01,u="";for(let m of r){if(m.distinct<2||m.distinct>o)continue;let h=r.filter(b=>b.idx!==m.idx).map(b=>b.idx),w=new Map;for(let b of e){let _=b[n];if(typeof _!="number"||!Number.isFinite(_))continue;let g=h.length?h.map(y=>String(b[y])).join(u):"",S=w.get(g);S||(S={sum:0,cset:new Set},w.set(g,S)),S.sum+=_,S.cset.add(String(b[m.idx]))}let x=0,A=0,p=0;for(let b of w.values())b.cset.size<2||(p++,Math.abs(b.sum-100)<=100*d?x++:Math.abs(b.sum-1)<=1*d&&A++);if(p>=2&&(x/p>=.9||A/p>=.9))return{additivity:"part_of_whole",partOfWholeDim:m.name}}if(l)return{additivity:"intensive_rate"};let f=bi(i);return f==="avg"||f==="min"||f==="max"?{additivity:"intensive_rate"}:f==="count"?{additivity:"additive"}:f==="sum"?{additivity:"unknown"}:s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&s>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function mn(t){let{dataType:e,isMeasure:n,name:i,distinct:r,nonblank:s,prec:a,maxval:l,minval:o}=t,d=l-o+1,u=d>0?r/d:1,f=s>0?r/s:0,m=e==="Decimal"||a>0;return!n&&Ne(i)?"Categorical":u>=Jr&&!(t.ordinalNeedsWholeNumbers&&a>0)&&(gt(i)&&r<=ei||o>=ti&&l<=ni||o>=ri&&l<=ii)?"Ordinal":n?"Continuous":!m&&Number.isFinite(d)&&r>ln&&r===s&&d===r?"Categorical":r>ln&&(m||r>=Zr||f>=Qr)?"Continuous":"Categorical"}function un(t,e,n){return!t||t.isMeasure||e||t.dataType!=="Integer"&&t.dataType!=="Decimal"?!1:mn({dataType:t.dataType,isMeasure:!1,name:t.name,distinct:n.distinct,nonblank:n.nonblank,prec:n.prec,maxval:typeof n.maxval=="number"?n.maxval:0,minval:typeof n.minval=="number"?n.minval:0,ordinalNeedsWholeNumbers:!0})==="Continuous"}function _i(t){let e=null;for(let n=0;n<t.length;n++){let i=t[n];if(typeof i!="string"||i.length===0)continue;let r=i.trim();r.length!==i.length&&(e||(e=t.slice()),e[n]=r)}return e||t}var cn=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;_generationColumns=[];_generationColumnsSig="[]";_declaredDimensions=new WeakSet;_inferredMeasureFlags=null;_preStatsFields=null;_statsAddedKeys=null;dedupRows=!0;emitLegacyAggAliases=!1;deriveProvinces=!0;dateCellsAreLocalWallClock=!1;wallClockColumnIndexes(){let e=new Set;if(!this.dateCellsAreLocalWallClock||!this._cols)return e;for(let n=0;n<this._cols.length;n++){let i=this._cols[n];!i||!/date|time/i.test(String(i.dataType??""))||ut(this._rows.map(r=>r[n]))&&e.add(n)}return e}STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}inferredMeasureFlags(){if(this._inferredMeasureFlags)return this._inferredMeasureFlags;let e=this._cols.map(n=>!!(n&&n.isMeasure));return this._cols.forEach((n,i)=>{if(!n||n.isMeasure||this._declaredDimensions.has(n)||n.dataType!=="Integer"&&n.dataType!=="Decimal")return;let r=new Set,s=0,a=0,l=null,o=null;for(let d of this._rows){let u=d[i],f=this.STR(u);if(f!=""&&(r.add(f),s++,(l===null||u<l)&&(l=u),(o===null||u>o)&&(o=u),n.dataType=="Decimal")){let m=this.getPrecision(u);m>a&&(a=m)}}e[i]=un(n,!1,{distinct:r.size,nonblank:s,prec:a,minval:l,maxval:o})}),Object.freeze(e),this._inferredMeasureFlags=e,e}declareDimensions(e){this._inferredMeasureFlags=null;for(let n of e)n&&this._declaredDimensions.add(n)}wholeDayIso(e){return lt(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,n){if(this._computedStatsForLevel==e)return this._cols;this._preStatsFields&&this._statsAddedKeys&&this._preStatsFields.length===this._cols.length?this._cols.forEach((c,T)=>{let E=this._preStatsFields[T];if(!(!c||!E)){for(let k of this._statsAddedKeys[T]??[])delete c[k];for(let k of Object.keys(E))c[k]=E[k]}}):this._preStatsFields=this._cols.map(c=>c?{...c}:null);let i=this._cols.map(c=>new Set(c?Object.keys(c):[])),r=0,s=parseInt(e),a=this.wallClockColumnIndexes(),l=[],o=[],d=[];for(let c of this._cols){let T=new Map,E=[],k=0,v=0,O=0,F=null,P=null,D=null,G=!1,K=!0,I=!0,N=null,V=!1,L=a.has(r);for(let R of this._rows){let $=R[r],B=L&&$ instanceof Date?ge($):$,H=this.STR(B);if(H!=""){if(k+=H.length,T.set(H,(T.get(H)||0)+1),v++,c.dataType=="Integer"||c.dataType=="Decimal"||c.dataType=="DateTime")if((F===null||B<F)&&(F=B),(P===null||B>P)&&(P=B),c.dataType=="Integer"||c.dataType=="Decimal"){if(D===null?D=B:D+=B,c.dataType=="Decimal"){let Z=this.getPrecision(B);Z>O&&(O=Z)}E.push(B)}else G=G||this.hasTimeComponent(B);V&&(B<N?K=!1:B>N&&(I=!1)),N=B,V=!0}}if(v>=3&&(K&&!I?c.sortedDirection="asc":I&&!K?c.sortedDirection="desc":c.sortedDirection="none"),v>0&&T.size>0&&!c.isMeasure){let R=0,$=Number.MAX_SAFE_INTEGER;for(let B of T.values())B>R&&(R=B),B<$&&($=B);if(c.modalShare=R/v,c.minGroupCount=$===Number.MAX_SAFE_INTEGER?null:$,T.size===2){let B=[...T.keys()].map(de=>st(de).trim().toLowerCase()).sort(),Z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(de=>B[0]===de[0]&&B[1]===de[1]),fn=/^(is|has)[_\p{L}\p{N}]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/iu.test(c.name);(Z||fn)&&(c.isBinaryFlag=!0)}}else c.isMeasure&&(c.dataType==="Integer"||c.dataType==="Decimal")&&T.size===2&&T.has("0")&&T.has("1")&&(c.isBinaryFlag=!0);if(c.dataType=="DateTime"&&(c.dateWithTime=G,G&&ct(L?this._rows.map(R=>R[r]instanceof Date?ge(R[r]):R[r]):this._rows.map(R=>R[r]))?c.timeOfDayOnly=!0:delete c.timeOfDayOnly),c.isTemporal=yi({dataType:c.dataType,name:c.name,isMeasure:c.isMeasure,distinctCount:T.size,minNum:typeof F=="number"?F:null,maxNum:typeof P=="number"?P:null,sampleValues:T.keys(),locale:n}),c.isTemporal&&c.dataType==="String"&&!c.isMeasure){let R=dn(T.keys(),n);R&&(c.temporalTextPattern=R.pattern)}if(c.timeOfDayOnly)delete c.temporalCadence;else if(c.isTemporal&&!c.isMeasure){let R=Qt(T.keys(),{includeBounds:s>=20,pattern:c.temporalTextPattern,locale:n});R&&(c.temporalCadence=R)}this.updateColumnStats10(s,c,v,T,O,P,F),this.updateColumnStats20(s,E,v,D,c,k,G,F,P,O,T,n),un(c,this._declaredDimensions.has(c),{distinct:T.size,nonblank:v,prec:O,minval:F,maxval:P})&&(c.isMeasure=!0,c.valueNature="Continuous",c.geoKind=void 0,c.geoMatchPct=void 0,c.geoAmbiguous=void 0,c.dominantGeoRegion=void 0,c.dominantGeoRegionPct=void 0,c.geoRegionCount=void 0),l[r]=c.isMeasure||T.size>2e3?null:new Set(T.keys()),o[r]=T.size,d[r]=T.size===2?[...T.keys()].sort():null,r++}vt(this._cols,this._rows,{cities:this.deriveProvinces}).forEach((c,T)=>{let E=this._cols[T];c.kind&&(E.geoKind=c.kind,E.geoMatchPct=c.matchPct,c.ambiguous&&(E.geoAmbiguous=!0)),c.rollupPct!==void 0&&(E.admin1RollupPct=c.rollupPct),c.regionCount!==void 0&&(E.admin1RegionCount=c.regionCount),c.countryCount!==void 0&&(E.admin1CountryCount=c.countryCount),c.dominantRegion&&(E.dominantGeoRegion=c.dominantRegion,E.dominantGeoRegionPct=c.dominantRegionPct)});let u=this.getGeoExtent();if(u&&u.dominantFrame&&this._geoExtentLatIdx>=0){let c=this._cols[this._geoExtentLatIdx];c.geoKind||(c.dominantGeoRegion=u.dominantFrame,c.dominantGeoRegionPct=u.dominantFramePct,this.deriveProvinces&&(c.admin1RollupPct=u.dominantFramePct))}let f=[];this._cols.forEach((c,T)=>{c.isMeasure||f.push({idx:T,distinct:c.distinctCount??0,name:c.name})}),this._cols.forEach((c,T)=>{if(!c.isMeasure)return;let E=typeof c.lowValue=="number"?c.lowValue:null,k=typeof c.highValue=="number"?c.highValue:null,v=Si({rows:this._rows,measureColIdx:T,measureName:c.name,candidateDims:f,minNum:E,maxNum:k,discourageAgg:!!c.discourageAggregationAcrossGroups});c.additivity=v.additivity,v.partOfWholeDim&&(c.partOfWholeDim=v.partOfWholeDim)});let m=50,h=4,w=f.filter(c=>c.distinct>=2&&c.distinct<=m);this._cols.forEach((c,T)=>{if(!c.isMeasure)return;let E=[];for(let I of this._rows){let N=I[T];if(N==null||N==="")continue;let V=typeof N=="number"?N:parseFloat(N);isNaN(V)||E.push(V)}if(E.length===0)return;let k=[...E].sort((I,N)=>I-N);if(k[0]===k[k.length-1])c.relativeDispersion=0;else if(k.length>=h){let I=fe(k,.5),N=fe(k,.1),V=fe(k,.9);c.relativeDispersion=Math.abs(I)>1e-9?Math.round((V-N)/Math.abs(I)*1e3)/1e3:void 0}else c.relativeDispersion=void 0;let v=[];for(let I of w){let N=new Set;for(let V of this._rows){let L=V[T];L==null||L===""||N.add(this.STR(V[I.idx])+"")}v.push({otherColumn:I.name,nonBlankGroupCount:N.size})}v.length>0&&(c.nonBlankGroups=v);let O=0;for(let I of E)O+=I;O/=E.length;let F=0;for(let I of E)F+=(I-O)*(I-O);if(F<=1e-12)return;let P=[],D=[],G=I=>{if(I.length<4)return NaN;let N=[...I].sort((L,R)=>L-R),V=L=>N[Math.min(N.length-1,Math.max(0,Math.floor(L*(N.length-1))))];return V(.75)-V(.25)},K=G(E);for(let I of w){let N=new Map;for(let R of this._rows){let $=R[T];if($==null||$==="")continue;let B=typeof $=="number"?$:parseFloat($);if(isNaN(B))continue;let H=this.STR(R[I.idx])+"",Z=N.get(H);Z?(Z.s+=B,Z.n++,Z.vals.push(B)):N.set(H,{s:B,n:1,vals:[B]})}let V=0;for(let R of N.values()){let $=R.s/R.n;V+=R.n*($-O)*($-O)}P.push({otherColumn:I.name,eta2:Math.round(V/F*1e4)/1e4});let L=[];for(let R of N.values()){let $=G(R.vals);isNaN($)||L.push($)}if(L.length>=2&&isFinite(K)&&K>1e-9){let R=(Math.max(...L)-Math.min(...L))/K;D.push({otherColumn:I.name,spreadRatio:Math.round(R*1e4)/1e4})}}P.length>0&&(c.groupDiscrimination=P),D.length>0&&(c.spreadDiscrimination=D)});let x=.97,A=.8,p=8,b=5,_=this._cols.map((c,T)=>({c,i:T})).filter(c=>c.c.isMeasure);for(let c=0;c<_.length;c++)for(let T=c+1;T<_.length;T++){let E=_[c].i,k=_[T].i,v=0,O=0,F=0,P=0,D=0,G=0;for(let L of this._rows){let R=L[E],$=L[k];if(R==null||R===""||$===null||$===void 0||$==="")continue;let B=typeof R=="number"?R:parseFloat(R),H=typeof $=="number"?$:parseFloat($);isNaN(B)||isNaN(H)||(v++,O+=B,F+=H,P+=B*B,D+=H*H,G+=B*H)}if(v<b)continue;let K=v*P-O*O,I=v*D-F*F;if(K<=1e-12||I<=1e-12)continue;let N=(v*G-O*F)/Math.sqrt(K*I),V=Math.min(1,Math.round(Math.abs(N)*1e3)/1e3);for(let L of[_[c].c,_[T].c])(L.maxAbsMeasureCorrelation===void 0||V>L.maxAbsMeasureCorrelation)&&(L.maxAbsMeasureCorrelation=V);if(Math.abs(N)>=x){let L=_[c].c,R=_[T].c;L.collinearWithMeasures||(L.collinearWithMeasures=[]),R.collinearWithMeasures||(R.collinearWithMeasures=[]),L.collinearWithMeasures.push(R.name),R.collinearWithMeasures.push(L.name)}else if(Math.abs(N)>=A){let L=_[c].c,R=_[T].c,$=Math.round(N*1e3)/1e3;L.correlatedWithMeasures||(L.correlatedWithMeasures=[]),R.correlatedWithMeasures||(R.correlatedWithMeasures=[]),L.correlatedWithMeasures.push({otherColumn:R.name,r:$}),R.correlatedWithMeasures.push({otherColumn:L.name,r:$})}}for(let{c}of _)c.correlatedWithMeasures&&(c.correlatedWithMeasures.sort((T,E)=>Math.abs(E.r)-Math.abs(T.r)||(T.otherColumn<E.otherColumn?-1:1)),c.correlatedWithMeasures.length=Math.min(c.correlatedWithMeasures.length,p));for(let c=0;c<this._cols.length;c++){let T=l[c];if(!T||T.size===0)continue;let E=[];for(let k=0;k<this._cols.length;k++){if(k===c)continue;let v=l[k];if(!v||v.size===0)continue;let O=0;for(let P of T)v.has(P)&&O++;let F=Math.round(O/T.size*100);F>0&&E.push({otherColumn:this._cols[k].name,percentShared:F})}E.length>0&&(this._cols[c].sharedValueRatioWithOthers=E)}let g=50,S=[];for(let c=0;c<this._cols.length;c++){let T=l[c];T&&T.size>=2&&T.size<=g&&S.push(c)}if(S.length>=2){let c=new Map,T=(k,v)=>k+":"+v;for(let k=0;k<S.length;k++)for(let v=k+1;v<S.length;v++)c.set(T(S[k],S[v]),new Map);for(let k of this._rows)for(let v=0;v<S.length;v++){let O=this.STR(k[S[v]])+"";for(let F=v+1;F<S.length;F++){let P=""+this.STR(k[S[F]]),D=c.get(T(S[v],S[F])),G=O+""+P;D.set(G,(D.get(G)??0)+1)}}let E=new Map;for(let k=0;k<S.length;k++)for(let v=k+1;v<S.length;v++){let O=S[k],F=S[v],P=l[O].size,D=l[F].size,G=c.get(T(O,F)),K=G.size,I=0;for(let R of G.values())(I===0||R<I)&&(I=R);let N=Math.round(K/(P*D)*100),V=K===P,L=K===D;if((this._cols[O].categoricalPairStats||=[]).push({otherColumn:this._cols[F].name,fillPct:N,determinesOther:V,minCellCount:I,distinctCombinations:K}),(this._cols[F].categoricalPairStats||=[]).push({otherColumn:this._cols[O].name,fillPct:N,determinesOther:L,minCellCount:I,distinctCombinations:K}),V&&P>D){let R=E.get(O);(!R||D<R.card)&&E.set(O,{name:this._cols[F].name,card:D,ratio:D/P})}if(L&&D>P){let R=E.get(F);(!R||P<R.card)&&E.set(F,{name:this._cols[O].name,card:P,ratio:P/D})}}for(let[k,v]of E)this._cols[k].primaryParentColumn=v.name,this._cols[k].nestingRatio=Math.round(v.ratio*100)/100}let y=6,C=this._rows.length;for(let c=0;c<this._cols.length;c++){let T=this._cols[c];if(T.isMeasure||T.primaryParentColumn)continue;let E=T.distinctCount??0;if(E<=g||C>0&&E>=C)continue;let k=[];for(let v=0;v<this._cols.length;v++){if(v===c)continue;let O=this._cols[v];if(O.isMeasure)continue;let F=O.distinctCount??0;F<2||F>=E||k.push(v)}k.sort((v,O)=>(this._cols[v].distinctCount??0)-(this._cols[O].distinctCount??0));for(let v of k.slice(0,y)){let O=new Map,F=!0;for(let D of this._rows){let G=this.STR(D[c])+"",K=this.STR(D[v])+"",I=O.get(G);if(I===void 0)O.set(G,K);else if(I!==K){F=!1;break}}if(!F)continue;let P=this._cols[v].distinctCount??0;T.primaryParentColumn=this._cols[v].name,T.nestingRatio=Math.round(P/E*100)/100;break}}let M=.01,W=.05,z=.95,q=8,J=8,ce=6,Y=500,U=[];for(let c=0;c<this._cols.length&&U.length<J;c++){let T=this._cols[c].dataType;(T==="Double"||T==="Integer"||T==="Decimal")&&U.push(c)}if(U.length>=3&&this._rows.length>=q){let c=Math.min(this._rows.length,Y),T=U.map(P=>{let D=[];for(let I=0;I<c;I++){let N=this._rows[I][P],V=typeof N=="number"?N:parseFloat(String(N).replace(/,/g,""));if(N==null||N===""||!isFinite(V))return null;D.push(V)}let G=D[0],K=!1;for(let I of D)if(I!==G){K=!0;break}return K?D:null}),E=U.map((P,D)=>D).filter(P=>T[P]!==null),k=P=>{let D=P.slice().sort((K,I)=>K-I),G=D.length>>1;return D.length%2?D[G]:(D[G-1]+D[G])/2},v=null,O=[],F=P=>{if(O.length>=3){let D=O.map(N=>T[N]),G=D[0].length,K=new Array(G);for(let N=0;N<G;N++){let V=0;for(let L of D)V+=L[N];K[N]=V}let I=k(K);if(I>0){let N=0;for(let L of K)Math.abs(L-I)<=I*M&&N++;let V=N/G;if(V>=z){let L=1;for(let R of D){let $=k(R)/I;$<L&&(L=$)}L>=W&&(!v||O.length>v.cols.length)&&(v={cols:O.slice(),total:I,matched:V})}}}if(!(O.length>=ce))for(let D=P;D<E.length;D++)O.push(E[D]),F(D+1),O.pop()};if(F(0),v){let P=v,G={columns:P.cols.map(K=>this._cols[U[K]].name),total:Math.round(P.total*1e3)/1e3,matchedPct:Math.round(P.matched*100)/100};for(let K of P.cols)this._cols[U[K]].constantSumGroup=G}}return this.applyTwoSetPairing(n,l),this.applyScoreSeparation(o,d),this.applySeriesCompleteness(s,n,l),this.applyMeasurePersistence(n,l),this._statsAddedKeys=this._cols.map((c,T)=>c?Object.keys(c).filter(E=>!i[T].has(E)):[]),this._computedStatsForLevel=e,this._cols}applyTwoSetPairing(e,n){for(let r of this._cols)r.twoSetPairing!==void 0&&delete r.twoSetPairing;let i=sn({rows:this._rows,columns:this._cols.map((r,s)=>{let a=n[s];return{name:r.name,values:a,distinct:a?a.size:r.distinctCount??0,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ne(r.name),temporalTextPattern:r.temporalTextPattern}}),text:r=>this.STR(r),locale:e});i&&(this._cols[i.key].twoSetPairing=i.pairing,this._cols[i.discriminator].twoSetPairing=i.pairing)}applyScoreSeparation(e,n){for(let r of this._cols)r.scoreSeparation!==void 0&&delete r.scoreSeparation;let i=on({rows:this._rows,columns:this._cols.map((r,s)=>({name:r.name,dataType:r.dataType,isMeasure:!!r.isMeasure,isTemporal:!!r.isTemporal,isDatePart:!!r.isDatePart,identifierNamed:Ne(r.name),isBinaryFlag:!!r.isBinaryFlag,distinct:e[s]??0,twoValues:n[s]??null})),text:r=>this.STR(r)});for(let[r,s]of i)this._cols[r].scoreSeparation=s}applySeriesCompleteness(e,n,i){for(let d of this._cols)d.seriesCompleteness!==void 0&&delete d.seriesCompleteness;let r=this._cols.map((d,u)=>({c:d,i:u})).filter(({c:d})=>d.isTemporal&&!d.isMeasure&&d.temporalCadence&&d.temporalCadence.grain!=="irregular");if(r.length===0)return;let s=this.seriesKeyIndex(n,i);if(s<0)return;let a=this._cols[s],l=this._rows.map(d=>this.STR(d[s])),o=e>=20&&(a.dataType!=="String"||Array.isArray(a.safeDistinctValues));for(let{c:d,i:u}of r){let f=nn({periods:this._rows.map(m=>this.STR(m[u])),series:l,seriesColumn:a.name,pattern:d.temporalTextPattern,locale:n,includeDates:e>=20,includeNames:o});f&&(d.seriesCompleteness=f)}}seriesKeyIndex(e,n){let i=[],r=[];this._cols.forEach((a,l)=>{let o=n[l];o&&(i.push(l),r.push({name:a.name,dataType:a.dataType,isMeasure:!!a.isMeasure,isTemporal:!!a.isTemporal,isDatePart:!!a.isDatePart,isReassembledDate:!!a.isReassembledDate,isBinaryFlag:!!a.isBinaryFlag,geoKind:a.geoKind,identifierNamed:Ne(a.name),values:o,rows:this._rows.length,locale:e}))});let s=tn(r);return s<0?-1:i[s]}applyMeasurePersistence(e,n){for(let o of this._cols)o.persistence!==void 0&&delete o.persistence;let i=[];if(this._cols.forEach((o,d)=>{o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal"||o.dataType==="Double")&&i.push(d)}),i.length===0||this._rows.length<Ie)return;let r=-1,s=[];for(let o=0;o<this._cols.length&&r<0;o++){let d=this._cols[o];if(!d.isTemporal||d.isMeasure||d.isDatePart)continue;let u=this._rows.map(f=>X(this.STR(f[o]),d.temporalTextPattern,e)?.ms??null);new Set(u.filter(f=>f!==null)).size<Ie||(r=o,s=u)}if(r<0)return;let a=this.seriesKeyIndex(e,n),l=a>=0?this._rows.map(o=>this.STR(o[a])):void 0;for(let o of i){let d=this._rows.map(f=>{let m=f[o];if(m==null||m==="")return null;let h=typeof m=="number"?m:parseFloat(String(m).replace(/,/g,""));return Number.isFinite(h)?h:null}),u=Ye({stamps:s,series:l,values:d});u&&(this._cols[o].persistence={timeColumn:this._cols[r].name,...a>=0?{seriesColumn:this._cols[a].name}:{},...u})}}updateColumnStats20(e,n,i,r,s,a,l,o,d,u,f,m){if(e>=20){let h=[...n].sort((A,p)=>A-p),w=Math.floor(h.length/2);if(i>0&&r!=null?s.avgValue=s.dataType=="Integer"?Math.round(r/i):r/i:s.avgValue=null,i>0&&(s.avgLength=a/i),this._rows.length>0){let A=p=>{let b=p instanceof Date?p:typeof p=="string"?ke(p)??new Date(p):new Date(p),_=this.wholeDayIso(b);return _?_+"T00:00:00.000Z":isNaN(b.getTime())?p:b.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!o?s.lowValue=o:s.lowValue=A(o),s.dataType!="DateTime"||l||!d?s.highValue=d:s.highValue=A(d),s.medianValue=h.length===0?null:h.length%2===0?s.dataType=="Integer"?Math.round((h[w-1]+h[w])/2):(h[w-1]+h[w])/2:h[w],s.numericPrecision=u}if(h.length>0){let A=i>0&&r!=null?r/i:s.avgValue??0,p=h.length,b=0,_=0;for(let y of h){let C=y-A;b+=C*C,_+=C*C*C}let g=b/p,S=Math.sqrt(g);s.skewness=g===0?0:_/p/(S*S*S),s.stdDev=Math.sqrt(g)}r!==null&&(s.sum=r);let x=Array.from(f.entries()).sort((A,p)=>p[1]-A[1]);if(s.topCategories=x.slice(0,10).map(A=>A[1]),!s.isMeasure&&x.length>0&&(s.dataType!=="String"&&(s.topCategoryValues=x.slice(0,5).map(A=>A[0])),e>=20)){let A=x.map(b=>b[0]),p=he(A,m);if(p!==null)s.ordinalPattern=p.pattern,s.orderedDomain=p.orderedDomain;else if(s.dataType==="String"){let b=pt(A);b!==null&&(s.safeDistinctValues=b)}}if(h.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let A=p=>h[Math.floor((h.length-1)*p)];s.quantiles={p05:A(.05),p25:A(.25),p75:A(.75),p95:A(.95)}}}if(!s.isMeasure&&s.dataType==="String"&&f.size>0){let h=Array.from(f.entries()).sort((A,p)=>p[1]-A[1]).map(A=>A[0]);s.formatSignature=Se(h);let w=i>0?a/i:void 0,x=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!x.test(s.formatSignature)&&(w===void 0||w>=3)&&(s.isFreeText=!0)}if(!s.isMeasure&&f.size>0){let h=Array.from(f.entries()).sort((x,A)=>A[1]-x[1]),w=Ct(h.map(x=>x[0]),s.name,m);if(w!==null&&(s.geoKind=w.geoKind,s.geoMatchPct=w.geoMatchPct,w.geoAmbiguous&&(s.geoAmbiguous=!0),w.geoKind.indexOf("country")===0)){let x=bt(h);x&&(s.dominantGeoRegion=x.dominantGeoRegion,s.dominantGeoRegionPct=x.dominantGeoRegionPct,s.geoRegionCount=x.regionCount,x.middleEastPct>0&&(s.middleEastPct=x.middleEastPct))}}}updateColumnStats10(e,n,i,r,s,a,l){let o=this._rows.length-i;e>=10&&(n.blankCount=o),n.distinctCount=r.size+(o!=0?1:0),n.valueNature="Categorical",i>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=mn({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:r.size,nonblank:i,prec:s,maxval:a,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal"))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,r)=>{i.isMeasure||e.push(r)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let i of this._rows)n.add(JSON.stringify(e.map(r=>i[r])));return this._leafCardinality=n.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=a=>Je(a,{camel:!0}),n=-1,i=-1,r=-1;if(this._cols.forEach((a,l)=>{let o=e(a.name),d=a.dataType==="Integer"||a.dataType==="Decimal";d&&n<0&&o.some(u=>u==="lat"||u==="latitude")?n=l:d&&i<0&&o.some(u=>u==="lon"||u==="lng"||u==="long"||u==="longitude")&&(i=l),r<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(r=l)}),n<0||i<0){let a=(d,u)=>{let f=0;for(let m of this._rows){let h=m[d];if(h==null||h==="")continue;let w=Number(h);if(!Number.isFinite(w)||w<-u||w>u)return!1;f++}return f>0},l=-1,o=-1;if(this._cols.forEach((d,u)=>{if(!(d.dataType==="Integer"||d.dataType==="Decimal"))return;let f=e(d.name),m=f.some(h=>h==="lat"||h==="latitude")?"lat":f.some(h=>h==="lon"||h==="lng"||h==="long"||h==="longitude")?"lon":Et(f);m==="lat"&&l<0&&a(u,90)?l=u:m==="lon"&&o<0&&a(u,180)&&(o=u)}),l<0||o<0)return null;n=l,i=o}this._geoExtentLatIdx=n;let s=[];for(let a of this._rows){let l=a[n],o=a[i],d=l==null||l===""?null:Number(l),u=o==null||o===""?null:Number(o);s.push({lat:d,lon:u,country:r>=0&&ye(this.STR(a[r]))?this.STR(a[r]):null})}return this._geoExtent=yt(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;_geoExtentLatIdx=-1;obfuscateString(e){return Xt(e,at)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(n=>{let i={};this._cols.forEach((r,s)=>{i[r.name]=n[s],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(i,r.hostName)&&(i[r.hostName]=n[s])});for(let[r,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=n[r]);return i})}async getCSVAsync(e){let n=[],i=e?25:1e7,r=e?4e3:1e7,s=new Map,a=this.wallClockColumnIndexes();for(let o of this._rows){let d={};for(let u=0;u<this._cols.length;u++){let f=this._cols[u],m=o[u];if(this.STR(m)!=""){if(e&&f.dataType=="String")if(s.has(m))m=s.get(m);else{let h=this.obfuscateString(m);s.set(m,h),m=h}else if(f.dataType=="DateTime"&&!f.dateWithTime){let h=m instanceof Date?m:typeof m=="string"?ke(m)??new Date(m):new Date(m);m=(this.wholeDayIso(h)??h.toISOString().slice(0,10))+"T00:00:00.000Z"}else a.has(u)&&m instanceof Date&&(m=ge(m));r-=this.STR(m).length}else m=null;d[u]=m,--r}if(n.push(d),--i,i<=0||r<=0)break}return await an.unparse(n,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return an.unparse([this._cols.map((n,i)=>{if(this.emitLegacyAggAliases&&n.hostName)return this.STR(n.hostName);let r=e.get(i);return this.STR(r&&r.headerName?r.alias:n.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(n=>n==null?null:this.STR(n)),this._englishAliases=new Map}setGenerationColumns(e){let n=(e??[]).filter(r=>!!r&&typeof r.n=="string"&&r.n!==""&&typeof r.q=="string"&&r.q!=="").map(r=>({n:r.n,q:r.q})),i=JSON.stringify(n);i!==this._generationColumnsSig&&(this._generationColumns=n,this._generationColumnsSig=i,this._englishAliases=new Map)}aliasesForCode(e){let n=Ve(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())n.push({name:i.name,alias:i.alias,reason:i.reason});return n}armAliasesForCode(e){return this.emitLegacyAggAliases=Ve(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let n of this.liveEnglishAliases().values())e.push({name:n.name,alias:n.alias,reason:n.reason});return e}legacyAliases(){let e=[];for(let n of this._cols)n&&n.hostName&&n.hostName!==n.name&&e.push({name:this.STR(n.name),alias:this.STR(n.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let n=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return n;let i=String(e),r=new Set;for(let l of this._cols)l&&(r.add(this.STR(l.name)),l.hostName&&r.add(this.STR(l.hostName)));let s=new Map,a=new Set;for(let l=0;l<this._cols.length;l++){if(!this._cols[l])continue;let o=this._hostQueryNames[l],d=$t(o,this._cols[l].name,this._cols[l].dataType)?[]:Wt(o),u=this.STR(this._cols[l].name),f=[];if(o){for(let h of this._generationColumns)if(h.q===o)for(let w of[h.n,Ke(h.n)])w&&w!==u&&!d.includes(w)&&!f.includes(w)&&f.push(w)}let m=[...d,...f].filter(h=>!r.has(h)&&ae(i,h));m.length===1&&(s.set(m[0],[...s.get(m[0])??[],l]),f.includes(m[0])&&a.add(m[0]))}for(let[l,o]of s){if(o.length!==1)continue;let d=this.STR(this._cols[o[0]].name);n.set(o[0],{name:d,alias:l,headerName:!ae(i,d),reason:a.has(l)?"stored-query-name":"english-implicit-agg"})}return n}liveEnglishAliases(){let e=new Map;for(let[n,i]of this._englishAliases){let r=this._cols?this._cols[n]:null;r&&this.STR(r.name)===i.name&&e.set(n,i)}return e}addRow(e,n){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let r=ot(i);if(this._rowHashes.has(r))return!1;this._rowHashes.add(r)}return this._rows.push(_i(e)),this.invalidateStats(),this._origIndices.push(n??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}invalidateStats(){this._computedStatsForLevel=null,this._geoExtentComputed=!1,this._geoExtent=null,this._geoExtentLatIdx=-1,this._leafCardinality=null,this._inferredMeasureFlags=null}reset(){this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,this._inferredMeasureFlags=null,this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null,this._hostQueryNames=[],this._englishAliases=new Map,this._generationColumns=[],this._generationColumnsSig="[]"}setColumns(e){if(this.invalidateStats(),this._preStatsFields=null,this._statsAddedKeys=null,this._inferredMeasureFlags=null,this._cols=e,!e||e.length===0)return;let n=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let r=this.STR(i.name),s=Ke(r);!s||s===r||n.has(s)||(n.delete(r),n.add(s),i.hostName=r,i.name=s)}}};export{gn as a,pn as b,Mi as c,Ti as d,vt as e,Nt as f,Rn as g,In as h,Et as i,kn as j,Dn as k,On as l,Pn as m,Te as n,Vn as o,Ke as p,Ve as q,Wt as r,Gt as s,Yn as t,Vt as u,Ut as v,Pi as w,Li as x,Fi as y,qn as z,Zn as A,Qn as B,Ht as C,ae as D,cr as E,Vi as F,dr as G,mr as H,X as I,Qt as J,vr as K,Rr as L,Ir as M,Or as N,tn as O,nn as P,ns as Q,Ne as R,dn as S,yi as T,bi as U,Si as V,mn as W,un as X,_i as Y,cn as Z};