@bicharts/shape-core 0.5.80 → 0.5.82
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.
- package/dist/{chunk-QBGUZNRI.mjs → chunk-6ZU65KK6.mjs} +1 -1
- package/dist/chunk-7MHZMBRK.mjs +2 -0
- package/dist/{chunk-NDFEFK4Q.mjs → chunk-YOBLYTXI.mjs} +1 -1
- package/dist/geoDetector.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/indexedText.mjs +1 -1
- package/dist/ingest.mjs +1 -1
- package/dist/types/geoDetector.d.ts +7 -0
- package/dist/types/geoUsZip3Prefixes.generated.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-GFY6RNP7.mjs +0 -2
|
@@ -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 mt}from"./chunk-QEH7WTLB.mjs";import{a as ft,b as dt}from"./chunk-2LR73DNS.mjs";import{c as ct}from"./chunk-GFY6RNP7.mjs";import{b as ut,f as lt}from"./chunk-E6SVTFAW.mjs";import{a as st,b as ot,c as at}from"./chunk-NNUL5RKC.mjs";import{a as X,b as it,c as rt,d as Y}from"./chunk-U43WE7LN.mjs";var wt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Et=[7,72,-172,-52];function gt(n,t,e){return n>=e[0]&&n<=e[1]&&t>=e[2]&&t<=e[3]}function q(n,t){if(!n.length)return NaN;if(n.length===1)return n[0];let e=(n.length-1)*t,s=Math.floor(e),o=Math.ceil(e);return s===o?n[s]:n[s]+(n[o]-n[s])*(e-s)}var K=n=>Math.round(n*10)/10;function ht(n,t=3){let e=[],s=[],o=0,r=0;for(let l of n){let c=l?.lat,d=l?.lon;if(typeof c!="number"||typeof d!="number"||!isFinite(c)||!isFinite(d)||c<-90||c>90||d<-180||d>180)continue;e.push(c),s.push(d);let M=l?.country?String(l.country).trim().toUpperCase():"",b=M?J(M):null;b?((M==="US"||M==="USA")&&o++,b==="north-america"&&r++):(wt.some(L=>gt(c,d,L))&&o++,gt(c,d,Et)&&r++)}let a=e.length;return a<t?null:(e.sort((l,c)=>l-c),s.sort((l,c)=>l-c),{pctUsa:K(o/a*100),pctNa:K(r/a*100),latP5:K(q(e,.05)),latP95:K(q(e,.95)),lonP5:K(q(s,.05)),lonP95:K(q(s,.95)),n:a})}var pt={"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"},$=(()=>{let n=new Map;for(let t of Object.keys(pt))for(let e of pt[t].split(/\s+/))e&&n.set(e,t);return n})();function Dt(n){for(let[t,e]of n){let s=$.get(t);s&&!$.has(e)&&$.set(e,s)}}Dt(ut);function J(n){if(!n)return null;let t=String(n).trim().toUpperCase();if(!t)return null;let e=$.get(t);if(e)return e;let s=lt(String(n));return s?$.get(s)??null:null}function pe(n,t=2){return Q(n.map(e=>[e,1]),t)}function Q(n,t=2){let e=new Map,s=0;for(let[a,l]of n){let c=J(a);if(!c)continue;let d=typeof l=="number"&&isFinite(l)&&l>0?l:1;e.set(c,(e.get(c)??0)+d),s+=d}if(s<t||!e.size)return null;let o="europe",r=-1;for(let a of Array.from(e.keys()).sort()){let l=e.get(a);l>r&&(o=a,r=l)}return{dominantGeoRegion:o,dominantGeoRegionPct:K(r/s*100),regionCount:e.size,n:s}}import Rt from"papaparse";var Ot=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","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"],Lt=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops"],Pt=["latitude","longitude"],Gt=["latitude","longitude"],yt=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,Wt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Ft=new RegExp("\\b("+Ot.join("|")+")\\b|("+Lt.join("|")+")$","i"),Vt=new RegExp("\\b("+Pt.join("|")+")\\b|("+Gt.join("|")+")$","i");function _t(n){return n?String(n).replace(yt,"").trim():""}function kt(n){return!!n&&yt.test(String(n))}var Ut=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],bt=new RegExp("^\\s*("+[...Ut].sort((n,t)=>t.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function St(n){if(n==null)return"";let t=String(n),e=bt.exec(t);if(!e)return t;let s=l=>l.toLowerCase().replace(/\s+/g," ").trim(),o=s(e[1]),r=t.slice(e[0].length),a=0;for(;a<8;){let l=bt.exec(r);if(!l||s(l[1])!==o)break;let c=r.slice(l[0].length);if(c.trim()==="")break;r=c,a++}return a===0?t:t.slice(0,e[0].length)+r}function ye(n,t){if(!n||!t)return!1;let e=String(n);for(let s of t){let o=s?.hostName;if(o&&o!==s?.name&&e.includes(o))return!0}return!1}function zt(n){let t=_t(n);return t.length===0?"":t.replace(Wt," ")}function Ct(n,t){if(!t)return!1;let e=_t(t);return n.test(zt(t))||n.test(e)||n.test(X(e).join(" "))}function Mt(n){return Ct(Vt,n)}function Bt(n){return Ct(Ft,n)||Mt(n)}var At=/int|double|decimal|single|float|number|currency|money/i;function Ht(n){let t=String(n?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||n?.isMeasure===!0||At.test(String(n?.dataType??""))?"Continuous":"Categorical"}function Kt(n){return n?.isMeasure===!0||At.test(String(n?.dataType??""))}function Tt(n){let t=n??{},e=Ht(t);if(e!=="Continuous")return{nature:e,additivity:"unknown",basis:"role",suppressed:!1};if(Mt(t.name))return{nature:e,additivity:"positional",basis:"name",suppressed:!0};let s=String(t.additivity??"").trim().toLowerCase();if(!(s==="additive"&&kt(t.name))){if(s==="additive")return{nature:e,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:e,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="intensive_rate")return{nature:e,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return t.discourageAggregationAcrossGroups===!0?{nature:e,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Bt(t.name)?{nature:e,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:e,additivity:"additive",basis:"default",suppressed:!1}}function Nt(n){let t=Tt(n),e=n??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Kt(e)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(t.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 _e(n){return Nt(n)[0]}function Se(n,t){return Nt(n).indexOf(t)>=0}function Ce(n,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let e=Tt(n);return e.additivity==="additive"||e.additivity==="part_of_whole"||e.additivity==="unknown"}var Yt=12,Zt=100,Xt=.3,$t=.9,jt=120,qt=1900,Jt=2100,Qt=0,te=20,ee=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function ne(n){if(!n)return!1;let t=X(n);return t.length===0?!1:ee.has(t[t.length-1])}var ie=new Set(["year","yr","fy"]),re=n=>X(n).some(t=>ie.has(t)),se=/^(?:(?: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 tt(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let t=n%100;return t>=1&&t<=12}function et(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let t=Math.floor(n/100)%100,e=n%100;return t>=1&&t<=12&&e>=1&&e<=31}var oe=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ae=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ue=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function le(n){let t=(n||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function It(n,t){let e=0,s=0,o=0,r=0,a=0,l="",c=0,d="",M=0,b=0,L=0,g=0,v=!1;for(let B of n){if(B==null)continue;let U=String(B).trim();if(U==="")continue;e++;let P;if(P=oe.exec(U)){let W=+P[2],i=+P[3];W>=1&&W<=12&&i>=1&&i<=31&&(s++,P[4]!==void 0&&o++,P[6]!==void 0&&r++)}else if(P=ae.exec(U)){let W=+P[3],i=+P[4];W>=1&&W<=12&&i>=1&&i<=31&&(l&&l!==P[2]&&(v=!0),l=P[2],a++)}else if(P=ue.exec(U)){let W=+P[1],i=+P[3];W>=1&&W<=31&&i>=1&&i<=31&&(W<=12||i<=12)&&(d&&d!==P[2]&&(v=!0),d=P[2],c++,W>12&&L++,i>12&&g++,P[5]!==void 0&&M++,P[7]!==void 0&&b++)}if(e>=200)break}if(e<2||(s+a+c)/e<.8||(s>0?1:0)+(a>0?1:0)+(c>0?1:0)!==1||v)return null;if(s>0)return o===s?{pattern:r===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${l}%m${l}%d`,orderFrom:"iso"};if(L>0&&g>0)return null;let w,N;L>0?(w=!0,N="values"):g>0?(w=!1,N="values"):(w=!le(t),N="locale");let k=w?`%d${d}%m${d}%Y`:`%m${d}%d${d}%Y`;return M===c?{pattern:k+(b===c?" %H:%M:%S":" %H:%M"),orderFrom:N}:{pattern:k,orderFrom:N}}function ce(n,t){if(!t||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let e=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!e)return!1;let s=ft(e);return s.length>0&&t[s]!==void 0}function me(n){let{dataType:t,name:e,isMeasure:s,distinctCount:o}=n;if(t==="DateTime")return!0;if(s)return!1;if(t==="Integer"||t==="Decimal"){let r=n.minNum,a=n.maxNum;if(!(r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&Number.isInteger(r)&&Number.isInteger(a)&&a>=r))return!1;let c=r>=1900&&a<=2100;if(c&&o>=2&&re(e)||c&&o>=3&&o===a-r+1)return!0;let d=tt(r)&&tt(a),M=et(r)&&et(a);if(d||M){if(!n.sampleValues)return!0;let b=0,L=0;for(let g of n.sampleValues){if(g==null||g==="")continue;b++;let v=Number(String(g).trim());if(Number.isFinite(v)&&(d?tt(v):et(v))&&L++,b>=60)break}if(b>=2&&L===b)return!0}return!1}if(n.sampleValues){let r=n.locale?dt(n.locale):null,a=0,l=0,c=[];for(let d of n.sampleValues){if(d==null||d==="")continue;a++;let M=String(d).trim();if(c.push(M),(se.test(M)||ce(M,r))&&l++,a>=60)break}if(a>=2&&l/a>=.8||It(c,n.locale)!==null)return!0}return!1}function fe(n){let t=(n||"").trim().toLowerCase();return t.startsWith("sum ")||t.startsWith("total ")?"sum":t.startsWith("average ")||t.startsWith("avg. ")?"avg":t.startsWith("count ")||t.startsWith("distinct count ")||t.startsWith("count (distinct) ")?"count":t.startsWith("min ")||t.startsWith("minimum ")?"min":t.startsWith("max ")||t.startsWith("maximum ")?"max":null}function de(n){let{rows:t,measureColIdx:e,measureName:s,candidateDims:o,minNum:r,maxNum:a,discourageAgg:l}=n,c=100,d=.01,M="";for(let L of o){if(L.distinct<2||L.distinct>c)continue;let g=o.filter(N=>N.idx!==L.idx).map(N=>N.idx),v=new Map;for(let N of t){let k=N[e];if(typeof k!="number"||!Number.isFinite(k))continue;let B=g.length?g.map(P=>String(N[P])).join(M):"",U=v.get(B);U||(U={sum:0,cset:new Set},v.set(B,U)),U.sum+=k,U.cset.add(String(N[L.idx]))}let x=0,A=0,w=0;for(let N of v.values())N.cset.size<2||(w++,Math.abs(N.sum-100)<=100*d?x++:Math.abs(N.sum-1)<=1*d&&A++);if(w>=2&&(x/w>=.9||A/w>=.9))return{additivity:"part_of_whole",partOfWholeDim:L.name}}if(l)return{additivity:"intensive_rate"};let b=fe(s);return b==="avg"||b==="min"||b==="max"?{additivity:"intensive_rate"}:b==="count"?{additivity:"additive"}:b==="sum"?{additivity:"unknown"}:r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&r>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function vt(n){let{dataType:t,isMeasure:e,name:s,distinct:o,nonblank:r,prec:a,maxval:l,minval:c}=n,d=l-c+1,M=d>0?o/d:1,b=r>0?o/r:0,L=t==="Decimal"||a>0;return ne(s)?"Categorical":M>=$t&&(st(s)&&o<=jt||c>=qt&&l<=Jt||c>=Qt&&l<=te)?"Ordinal":e||o>Yt&&(L||o>=Zt||b>=Xt)?"Continuous":"Categorical"}var xt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(t){return t==null?"":t.toString()}getPrecision(t){if(!isFinite(t))return 0;let s=t.toString().split(".")[1];return s?s.length:0}getColumns(){return this._cols}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:t.getHours()!==0||t.getMinutes()!==0||t.getSeconds()!==0||t.getMilliseconds()!==0}getColumnsWithStats(t,e){if(this._computedStatsForLevel==t)return this._cols;let s=0,o=parseInt(t),r=[];for(let i of this._cols){let m=new Map,E=[],h=0,u=0,_=0,S=null,y=null,p=null,R=!1,D=!0,I=!0,O=null,G=!1;for(let T of this._rows){let f=T[s],C=this.STR(f);if(C!=""){if(h+=C.length,m.set(C,(m.get(C)||0)+1),u++,i.dataType=="Integer"||i.dataType=="Decimal"||i.dataType=="DateTime")if((S===null||f<S)&&(S=f),(y===null||f>y)&&(y=f),i.dataType=="Integer"||i.dataType=="Decimal"){if(p===null?p=f:p+=f,i.dataType=="Decimal"){let F=this.getPrecision(f);F>_&&(_=F)}E.push(f)}else R=R||this.hasTimeComponent(f);G&&(f<O?D=!1:f>O&&(I=!1)),O=f,G=!0}}if(u>=3&&(D&&!I?i.sortedDirection="asc":I&&!D?i.sortedDirection="desc":i.sortedDirection="none"),u>0&&m.size>0&&!i.isMeasure){let T=0,f=Number.MAX_SAFE_INTEGER;for(let C of m.values())C>T&&(T=C),C<f&&(f=C);if(i.modalShare=T/u,i.minGroupCount=f===Number.MAX_SAFE_INTEGER?null:f,m.size===2){let C=[...m.keys()].map(V=>it(V).trim().toLowerCase()).sort(),H=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(V=>C[0]===V[0]&&C[1]===V[1]),z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(i.name);(H||z)&&(i.isBinaryFlag=!0)}}if(i.dataType=="DateTime"&&(i.dateWithTime=R),i.isTemporal=me({dataType:i.dataType,name:i.name,isMeasure:i.isMeasure,distinctCount:m.size,minNum:typeof S=="number"?S:null,maxNum:typeof y=="number"?y:null,sampleValues:m.keys(),locale:e}),i.isTemporal&&i.dataType==="String"&&!i.isMeasure){let T=It(m.keys(),e);T&&(i.temporalTextPattern=T.pattern)}this.updateColumnStats10(o,i,u,m,_,y,S),this.updateColumnStats20(o,E,u,p,i,h,R,S,y,_,m,e),!i.isMeasure&&(i.dataType==="Integer"||i.dataType==="Decimal")&&vt({dataType:i.dataType,isMeasure:!1,name:i.name,distinct:m.size,nonblank:u,prec:_,maxval:typeof y=="number"?y:0,minval:typeof S=="number"?S:0})==="Continuous"&&(i.isMeasure=!0,i.geoKind=void 0,i.geoMatchPct=void 0,i.geoAmbiguous=void 0,i.dominantGeoRegion=void 0,i.dominantGeoRegionPct=void 0,i.geoRegionCount=void 0),r[s]=i.isMeasure||m.size>2e3?null:new Set(m.keys()),s++}let a=[];this._cols.forEach((i,m)=>{i.isMeasure||a.push({idx:m,distinct:i.distinctCount??0,name:i.name})}),this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let E=typeof i.lowValue=="number"?i.lowValue:null,h=typeof i.highValue=="number"?i.highValue:null,u=de({rows:this._rows,measureColIdx:m,measureName:i.name,candidateDims:a,minNum:E,maxNum:h,discourageAgg:!!i.discourageAggregationAcrossGroups});i.additivity=u.additivity,u.partOfWholeDim&&(i.partOfWholeDim=u.partOfWholeDim)});let l=50,c=a.filter(i=>i.distinct>=2&&i.distinct<=l);this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let E=[];for(let f of this._rows){let C=f[m];if(C==null||C==="")continue;let F=typeof C=="number"?C:parseFloat(C);isNaN(F)||E.push(F)}if(E.length===0)return;let h=[...E].sort((f,C)=>f-C),u=f=>h[Math.min(h.length-1,Math.max(0,Math.floor(f*(h.length-1))))],_=u(.5),S=u(.1),y=u(.9),p=Math.abs(_)>1e-9?Math.abs(_):Math.abs(h[h.length-1])>1e-9?Math.abs(h[h.length-1]):1;i.relativeDispersion=Math.round((y-S)/p*1e3)/1e3;let R=0;for(let f of E)R+=f;R/=E.length;let D=0;for(let f of E)D+=(f-R)*(f-R);if(D<=1e-12)return;let I=[],O=[],G=f=>{if(f.length<4)return NaN;let C=[...f].sort((H,z)=>H-z),F=H=>C[Math.min(C.length-1,Math.max(0,Math.floor(H*(C.length-1))))];return F(.75)-F(.25)},T=G(E);for(let f of c){let C=new Map;for(let z of this._rows){let V=z[m];if(V==null||V==="")continue;let Z=typeof V=="number"?V:parseFloat(V);if(isNaN(Z))continue;let nt=this.STR(z[f.idx])+"",j=C.get(nt);j?(j.s+=Z,j.n++,j.vals.push(Z)):C.set(nt,{s:Z,n:1,vals:[Z]})}let F=0;for(let z of C.values()){let V=z.s/z.n;F+=z.n*(V-R)*(V-R)}I.push({otherColumn:f.name,eta2:Math.round(F/D*1e4)/1e4});let H=[];for(let z of C.values()){let V=G(z.vals);isNaN(V)||H.push(V)}if(H.length>=2&&isFinite(T)&&T>1e-9){let z=(Math.max(...H)-Math.min(...H))/T;O.push({otherColumn:f.name,spreadRatio:Math.round(z*1e4)/1e4})}}I.length>0&&(i.groupDiscrimination=I),O.length>0&&(i.spreadDiscrimination=O)});let d=.97,M=5,b=this._cols.map((i,m)=>({c:i,i:m})).filter(i=>i.c.isMeasure);for(let i=0;i<b.length;i++)for(let m=i+1;m<b.length;m++){let E=b[i].i,h=b[m].i,u=0,_=0,S=0,y=0,p=0,R=0;for(let G of this._rows){let T=G[E],f=G[h];if(T==null||T===""||f===null||f===void 0||f==="")continue;let C=typeof T=="number"?T:parseFloat(T),F=typeof f=="number"?f:parseFloat(f);isNaN(C)||isNaN(F)||(u++,_+=C,S+=F,y+=C*C,p+=F*F,R+=C*F)}if(u<M)continue;let D=u*y-_*_,I=u*p-S*S;if(D<=1e-12||I<=1e-12)continue;let O=(u*R-_*S)/Math.sqrt(D*I);if(Math.abs(O)>=d){let G=b[i].c,T=b[m].c;G.collinearWithMeasures||(G.collinearWithMeasures=[]),T.collinearWithMeasures||(T.collinearWithMeasures=[]),G.collinearWithMeasures.push(T.name),T.collinearWithMeasures.push(G.name)}}for(let i=0;i<this._cols.length;i++){let m=r[i];if(!m||m.size===0)continue;let E=[];for(let h=0;h<this._cols.length;h++){if(h===i)continue;let u=r[h];if(!u||u.size===0)continue;let _=0;for(let y of m)u.has(y)&&_++;let S=Math.round(_/m.size*100);S>0&&E.push({otherColumn:this._cols[h].name,percentShared:S})}E.length>0&&(this._cols[i].sharedValueRatioWithOthers=E)}let L=50,g=[];for(let i=0;i<this._cols.length;i++){let m=r[i];m&&m.size>=2&&m.size<=L&&g.push(i)}if(g.length>=2){let i=new Map,m=(h,u)=>h+":"+u;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++)i.set(m(g[h],g[u]),new Map);for(let h of this._rows)for(let u=0;u<g.length;u++){let _=this.STR(h[g[u]])+"";for(let S=u+1;S<g.length;S++){let y=""+this.STR(h[g[S]]),p=i.get(m(g[u],g[S])),R=_+""+y;p.set(R,(p.get(R)??0)+1)}}let E=new Map;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++){let _=g[h],S=g[u],y=r[_].size,p=r[S].size,R=i.get(m(_,S)),D=R.size,I=0;for(let f of R.values())(I===0||f<I)&&(I=f);let O=Math.round(D/(y*p)*100),G=D===y,T=D===p;if((this._cols[_].categoricalPairStats||=[]).push({otherColumn:this._cols[S].name,fillPct:O,determinesOther:G,minCellCount:I,distinctCombinations:D}),(this._cols[S].categoricalPairStats||=[]).push({otherColumn:this._cols[_].name,fillPct:O,determinesOther:T,minCellCount:I,distinctCombinations:D}),G&&y>p){let f=E.get(_);(!f||p<f.card)&&E.set(_,{name:this._cols[S].name,card:p,ratio:p/y})}if(T&&p>y){let f=E.get(S);(!f||y<f.card)&&E.set(S,{name:this._cols[_].name,card:y,ratio:y/p})}}for(let[h,u]of E)this._cols[h].primaryParentColumn=u.name,this._cols[h].nestingRatio=Math.round(u.ratio*100)/100}let v=6,x=this._rows.length;for(let i=0;i<this._cols.length;i++){let m=this._cols[i];if(m.isMeasure||m.primaryParentColumn)continue;let E=m.distinctCount??0;if(E<=L||x>0&&E>=x)continue;let h=[];for(let u=0;u<this._cols.length;u++){if(u===i)continue;let _=this._cols[u];if(_.isMeasure)continue;let S=_.distinctCount??0;S<2||S>=E||h.push(u)}h.sort((u,_)=>(this._cols[u].distinctCount??0)-(this._cols[_].distinctCount??0));for(let u of h.slice(0,v)){let _=new Map,S=!0;for(let p of this._rows){let R=this.STR(p[i])+"",D=this.STR(p[u])+"",I=_.get(R);if(I===void 0)_.set(R,D);else if(I!==D){S=!1;break}}if(!S)continue;let y=this._cols[u].distinctCount??0;m.primaryParentColumn=this._cols[u].name,m.nestingRatio=Math.round(y/E*100)/100;break}}let A=.01,w=.05,N=.95,k=8,B=8,U=6,P=500,W=[];for(let i=0;i<this._cols.length&&W.length<B;i++){let m=this._cols[i].dataType;(m==="Double"||m==="Integer"||m==="Decimal")&&W.push(i)}if(W.length>=3&&this._rows.length>=k){let i=Math.min(this._rows.length,P),m=W.map(y=>{let p=[];for(let I=0;I<i;I++){let O=this._rows[I][y],G=typeof O=="number"?O:parseFloat(String(O).replace(/,/g,""));if(O==null||O===""||!isFinite(G))return null;p.push(G)}let R=p[0],D=!1;for(let I of p)if(I!==R){D=!0;break}return D?p:null}),E=W.map((y,p)=>p).filter(y=>m[y]!==null),h=y=>{let p=y.slice().sort((D,I)=>D-I),R=p.length>>1;return p.length%2?p[R]:(p[R-1]+p[R])/2},u=null,_=[],S=y=>{if(_.length>=3){let p=_.map(O=>m[O]),R=p[0].length,D=new Array(R);for(let O=0;O<R;O++){let G=0;for(let T of p)G+=T[O];D[O]=G}let I=h(D);if(I>0){let O=0;for(let T of D)Math.abs(T-I)<=I*A&&O++;let G=O/R;if(G>=N){let T=1;for(let f of p){let C=h(f)/I;C<T&&(T=C)}T>=w&&(!u||_.length>u.cols.length)&&(u={cols:_.slice(),total:I,matched:G})}}}if(!(_.length>=U))for(let p=y;p<E.length;p++)_.push(E[p]),S(p+1),_.pop()};if(S(0),u){let y=u,R={columns:y.cols.map(D=>this._cols[W[D]].name),total:Math.round(y.total*1e3)/1e3,matchedPct:Math.round(y.matched*100)/100};for(let D of y.cols)this._cols[W[D]].constantSumGroup=R}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,e,s,o,r,a,l,c,d,M,b,L){if(t>=20){let g=[...e].sort((A,w)=>A-w),v=Math.floor(g.length/2);if(s>0&&o!=null?r.avgValue=r.dataType=="Integer"?Math.round(o/s):o/s:r.avgValue=null,s>0&&(r.avgLength=a/s),this._rows.length>0){let A=w=>{let N=new Date(w);return isNaN(N.getTime())?w:N.toISOString().slice(0,10)+"T00:00:00.000Z"};r.dataType!="DateTime"||l||!c?r.lowValue=c:r.lowValue=A(c),r.dataType!="DateTime"||l||!d?r.highValue=d:r.highValue=A(d),r.medianValue=g.length===0?null:g.length%2===0?r.dataType=="Integer"?Math.round((g[v-1]+g[v])/2):(g[v-1]+g[v])/2:g[v],r.numericPrecision=M}if(g.length>0){let A=r.avgValue??0,w=g.length,N=0,k=0;for(let U of g){let P=U-A;N+=P*P,k+=P*P*P}let B=N/w;r.skewness=B===0?0:k/w/Math.pow(Math.sqrt(B),3),r.stdDev=Math.sqrt(B)}o!==null&&(r.sum=o);let x=Array.from(b.entries()).sort((A,w)=>w[1]-A[1]);if(r.topCategories=x.slice(0,10).map(A=>A[1]),!r.isMeasure&&x.length>0){if(r.dataType==="String"){let A=x.map(N=>N[0]);r.formatSignature=mt(A);let w=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!w.test(r.formatSignature)&&(r.avgLength===void 0||r.avgLength>=3)&&(r.isFreeText=!0)}else r.topCategoryValues=x.slice(0,5).map(A=>A[0]);if(t>=20){let A=x.map(N=>N[0]),w=at(A,L);if(w!==null)r.ordinalPattern=w.pattern,r.orderedDomain=w.orderedDomain;else if(r.dataType==="String"){let N=ot(A);N!==null&&(r.safeDistinctValues=N)}}}if(g.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let A=w=>g[Math.floor((g.length-1)*w)];r.quantiles={p05:A(.05),p25:A(.25),p75:A(.75),p95:A(.95)}}}if(!r.isMeasure&&b.size>0){let g=Array.from(b.entries()).sort((x,A)=>A[1]-x[1]),v=ct(g.map(x=>x[0]),r.name,L);if(v!==null&&(r.geoKind=v.geoKind,r.geoMatchPct=v.geoMatchPct,v.geoAmbiguous&&(r.geoAmbiguous=!0),v.geoKind.indexOf("country")===0)){let x=Q(g);x&&(r.dominantGeoRegion=x.dominantGeoRegion,r.dominantGeoRegionPct=x.dominantGeoRegionPct,r.geoRegionCount=x.regionCount)}}}updateColumnStats10(t,e,s,o,r,a,l){t>=10&&(e.blankCount=this._rows.length-s,e.distinctCount=o.size+(e.blankCount!=0?1:0),e.valueNature="Categorical",s>0&&(e.dataType==="Integer"||e.dataType==="Decimal"?e.valueNature=vt({dataType:e.dataType,isMeasure:!!e.isMeasure,name:e.name,distinct:o.size,nonblank:s,prec:r,maxval:a,minval:l}):e.dataType==="DateTime"&&(e.valueNature=e.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let t=[];if(this._cols.forEach((s,o)=>{s.isMeasure||t.push(o)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let e=new Set;for(let s of this._rows)e.add(JSON.stringify(t.map(o=>s[o])));return this._leafCardinality=e.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let t=a=>String(a||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),e=-1,s=-1,o=-1;if(this._cols.forEach((a,l)=>{let c=t(a.name),d=a.dataType==="Integer"||a.dataType==="Decimal";d&&e<0&&c.some(M=>M==="lat"||M==="latitude")?e=l:d&&s<0&&c.some(M=>M==="lon"||M==="lng"||M==="long"||M==="longitude")&&(s=l),o<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(o=l)}),e<0||s<0)return null;let r=[];for(let a of this._rows){let l=a[e],c=a[s],d=l==null||l===""?null:Number(l),M=c==null||c===""?null:Number(c);r.push({lat:d,lon:M,country:o>=0&&J(this.STR(a[o]))?this.STR(a[o]):null})}return this._geoExtent=ht(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let e="abcdefghijklmnopqrstuvwxyz",s=()=>e[Math.floor(Y()*e.length)],o=()=>s().toUpperCase(),r=()=>Math.floor(Y()*10).toString(),a=v=>/[A-Z]/.test(v)?o():/[a-z]/.test(v)?s():/[0-9]/.test(v)?r():v,l=t.includes("@")&&t.includes("."),c=l?t.split("@"):[t],d=l?c[1]:"",M=d.endsWith(".com"),b=M?".com":"",L=M?d.slice(0,-4):d,g=v=>{let x="";for(let A of v)x+=a(A),/[a-zA-Z0-9]/.test(A)&&Y()<.2&&(x+=a(A));if(x.length>6){let A=Math.floor(Y()*Math.min(3,x.length-6));for(let w=0;w<A;w++){let N=0;for(;N<5;){let k=Math.floor(Y()*x.length);if(/[a-zA-Z0-9]/.test(x[k])){x=x.slice(0,k)+x.slice(k+1);break}N++}}}return x};if(l){let v=g(c[0]),x=g(L);return`${v}@${x}${b}`}else return g(t)}toObjectArray(){return this._rows.map(t=>{let e={};return this._cols.forEach((s,o)=>{e[s.name]=t[o],this.emitLegacyAggAliases&&s.hostName&&s.hostName!==s.name&&!Object.prototype.hasOwnProperty.call(e,s.hostName)&&(e[s.hostName]=t[o])}),e})}async getCSVAsync(t){let e=[],s=t?25:1e7,o=t?4e3:1e7,r=new Map;for(let l of this._rows){let c={};for(let d=0;d<this._cols.length;d++){let M=this._cols[d],b=l[d];if(this.STR(b)!=""){if(t&&M.dataType=="String")if(r.has(b))b=r.get(b);else{let L=this.obfuscateString(b);r.set(b,L),b=L}else M.dataType=="DateTime"&&!M.dateWithTime&&(b=new Date(b).toISOString().slice(0,10)+"T00:00:00.000Z");o-=this.STR(b).length}else b=null;c[d]=b,--o}if(e.push(c),--s,s<=0||o<=0)break}return await Rt.unparse(e,{header:!1})}getCSVHeaderLine(){return Rt.unparse([this._cols.map(t=>this.STR(this.emitLegacyAggAliases&&t.hostName?t.hostName:t.name))])}addRow(t,e){if(this.dedupRows){let s="";for(let r of t)s+=this.STR(r)+"~";let o=rt(s);if(this._rowHashes.has(o))return!1;this._rowHashes.add(o)}return this._rows.push(t),this._origIndices.push(e??-1),!0}getOriginalRowIndex(t){return t<0||t>=this._origIndices.length?-1:this._origIndices[t]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null}setColumns(t){if(this._cols=t,!t||t.length===0)return;let e=new Set(t.map(s=>this.STR(s?.name)));for(let s of t){if(!s)continue;let o=this.STR(s.name),r=St(o);!r||r===o||e.has(r)||(e.delete(o),e.add(r),s.hostName=o,s.name=r)}}};export{ht as a,Dt as b,J as c,pe as d,Ot as e,Lt as f,Pt as g,Gt as h,_t as i,kt as j,St as k,ye as l,Mt as m,Bt as n,Tt as o,Nt as p,_e as q,Se as r,Ce as s,ne as t,It as u,me as v,fe as w,de as x,vt as y,xt as z};
|
|
2
|
+
import{a as mt}from"./chunk-QEH7WTLB.mjs";import{a as ft,b as dt}from"./chunk-2LR73DNS.mjs";import{c as ct}from"./chunk-7MHZMBRK.mjs";import{b as ut,f as lt}from"./chunk-E6SVTFAW.mjs";import{a as st,b as ot,c as at}from"./chunk-NNUL5RKC.mjs";import{a as X,b as it,c as rt,d as Y}from"./chunk-U43WE7LN.mjs";var wt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Et=[7,72,-172,-52];function gt(n,t,e){return n>=e[0]&&n<=e[1]&&t>=e[2]&&t<=e[3]}function q(n,t){if(!n.length)return NaN;if(n.length===1)return n[0];let e=(n.length-1)*t,s=Math.floor(e),o=Math.ceil(e);return s===o?n[s]:n[s]+(n[o]-n[s])*(e-s)}var K=n=>Math.round(n*10)/10;function ht(n,t=3){let e=[],s=[],o=0,r=0;for(let l of n){let c=l?.lat,d=l?.lon;if(typeof c!="number"||typeof d!="number"||!isFinite(c)||!isFinite(d)||c<-90||c>90||d<-180||d>180)continue;e.push(c),s.push(d);let M=l?.country?String(l.country).trim().toUpperCase():"",b=M?J(M):null;b?((M==="US"||M==="USA")&&o++,b==="north-america"&&r++):(wt.some(L=>gt(c,d,L))&&o++,gt(c,d,Et)&&r++)}let a=e.length;return a<t?null:(e.sort((l,c)=>l-c),s.sort((l,c)=>l-c),{pctUsa:K(o/a*100),pctNa:K(r/a*100),latP5:K(q(e,.05)),latP95:K(q(e,.95)),lonP5:K(q(s,.05)),lonP95:K(q(s,.95)),n:a})}var pt={"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"},$=(()=>{let n=new Map;for(let t of Object.keys(pt))for(let e of pt[t].split(/\s+/))e&&n.set(e,t);return n})();function Dt(n){for(let[t,e]of n){let s=$.get(t);s&&!$.has(e)&&$.set(e,s)}}Dt(ut);function J(n){if(!n)return null;let t=String(n).trim().toUpperCase();if(!t)return null;let e=$.get(t);if(e)return e;let s=lt(String(n));return s?$.get(s)??null:null}function pe(n,t=2){return Q(n.map(e=>[e,1]),t)}function Q(n,t=2){let e=new Map,s=0;for(let[a,l]of n){let c=J(a);if(!c)continue;let d=typeof l=="number"&&isFinite(l)&&l>0?l:1;e.set(c,(e.get(c)??0)+d),s+=d}if(s<t||!e.size)return null;let o="europe",r=-1;for(let a of Array.from(e.keys()).sort()){let l=e.get(a);l>r&&(o=a,r=l)}return{dominantGeoRegion:o,dominantGeoRegionPct:K(r/s*100),regionCount:e.size,n:s}}import Rt from"papaparse";var Ot=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","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"],Lt=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops"],Pt=["latitude","longitude"],Gt=["latitude","longitude"],yt=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,Wt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Ft=new RegExp("\\b("+Ot.join("|")+")\\b|("+Lt.join("|")+")$","i"),Vt=new RegExp("\\b("+Pt.join("|")+")\\b|("+Gt.join("|")+")$","i");function _t(n){return n?String(n).replace(yt,"").trim():""}function kt(n){return!!n&&yt.test(String(n))}var Ut=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],bt=new RegExp("^\\s*("+[...Ut].sort((n,t)=>t.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function St(n){if(n==null)return"";let t=String(n),e=bt.exec(t);if(!e)return t;let s=l=>l.toLowerCase().replace(/\s+/g," ").trim(),o=s(e[1]),r=t.slice(e[0].length),a=0;for(;a<8;){let l=bt.exec(r);if(!l||s(l[1])!==o)break;let c=r.slice(l[0].length);if(c.trim()==="")break;r=c,a++}return a===0?t:t.slice(0,e[0].length)+r}function ye(n,t){if(!n||!t)return!1;let e=String(n);for(let s of t){let o=s?.hostName;if(o&&o!==s?.name&&e.includes(o))return!0}return!1}function zt(n){let t=_t(n);return t.length===0?"":t.replace(Wt," ")}function Ct(n,t){if(!t)return!1;let e=_t(t);return n.test(zt(t))||n.test(e)||n.test(X(e).join(" "))}function Mt(n){return Ct(Vt,n)}function Bt(n){return Ct(Ft,n)||Mt(n)}var At=/int|double|decimal|single|float|number|currency|money/i;function Ht(n){let t=String(n?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||n?.isMeasure===!0||At.test(String(n?.dataType??""))?"Continuous":"Categorical"}function Kt(n){return n?.isMeasure===!0||At.test(String(n?.dataType??""))}function Tt(n){let t=n??{},e=Ht(t);if(e!=="Continuous")return{nature:e,additivity:"unknown",basis:"role",suppressed:!1};if(Mt(t.name))return{nature:e,additivity:"positional",basis:"name",suppressed:!0};let s=String(t.additivity??"").trim().toLowerCase();if(!(s==="additive"&&kt(t.name))){if(s==="additive")return{nature:e,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:e,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="intensive_rate")return{nature:e,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return t.discourageAggregationAcrossGroups===!0?{nature:e,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Bt(t.name)?{nature:e,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:e,additivity:"additive",basis:"default",suppressed:!1}}function Nt(n){let t=Tt(n),e=n??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Kt(e)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(t.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 _e(n){return Nt(n)[0]}function Se(n,t){return Nt(n).indexOf(t)>=0}function Ce(n,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let e=Tt(n);return e.additivity==="additive"||e.additivity==="part_of_whole"||e.additivity==="unknown"}var Yt=12,Zt=100,Xt=.3,$t=.9,jt=120,qt=1900,Jt=2100,Qt=0,te=20,ee=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function ne(n){if(!n)return!1;let t=X(n);return t.length===0?!1:ee.has(t[t.length-1])}var ie=new Set(["year","yr","fy"]),re=n=>X(n).some(t=>ie.has(t)),se=/^(?:(?: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 tt(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let t=n%100;return t>=1&&t<=12}function et(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let t=Math.floor(n/100)%100,e=n%100;return t>=1&&t<=12&&e>=1&&e<=31}var oe=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ae=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ue=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function le(n){let t=(n||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function It(n,t){let e=0,s=0,o=0,r=0,a=0,l="",c=0,d="",M=0,b=0,L=0,g=0,v=!1;for(let B of n){if(B==null)continue;let U=String(B).trim();if(U==="")continue;e++;let P;if(P=oe.exec(U)){let W=+P[2],i=+P[3];W>=1&&W<=12&&i>=1&&i<=31&&(s++,P[4]!==void 0&&o++,P[6]!==void 0&&r++)}else if(P=ae.exec(U)){let W=+P[3],i=+P[4];W>=1&&W<=12&&i>=1&&i<=31&&(l&&l!==P[2]&&(v=!0),l=P[2],a++)}else if(P=ue.exec(U)){let W=+P[1],i=+P[3];W>=1&&W<=31&&i>=1&&i<=31&&(W<=12||i<=12)&&(d&&d!==P[2]&&(v=!0),d=P[2],c++,W>12&&L++,i>12&&g++,P[5]!==void 0&&M++,P[7]!==void 0&&b++)}if(e>=200)break}if(e<2||(s+a+c)/e<.8||(s>0?1:0)+(a>0?1:0)+(c>0?1:0)!==1||v)return null;if(s>0)return o===s?{pattern:r===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${l}%m${l}%d`,orderFrom:"iso"};if(L>0&&g>0)return null;let w,N;L>0?(w=!0,N="values"):g>0?(w=!1,N="values"):(w=!le(t),N="locale");let k=w?`%d${d}%m${d}%Y`:`%m${d}%d${d}%Y`;return M===c?{pattern:k+(b===c?" %H:%M:%S":" %H:%M"),orderFrom:N}:{pattern:k,orderFrom:N}}function ce(n,t){if(!t||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let e=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!e)return!1;let s=ft(e);return s.length>0&&t[s]!==void 0}function me(n){let{dataType:t,name:e,isMeasure:s,distinctCount:o}=n;if(t==="DateTime")return!0;if(s)return!1;if(t==="Integer"||t==="Decimal"){let r=n.minNum,a=n.maxNum;if(!(r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&Number.isInteger(r)&&Number.isInteger(a)&&a>=r))return!1;let c=r>=1900&&a<=2100;if(c&&o>=2&&re(e)||c&&o>=3&&o===a-r+1)return!0;let d=tt(r)&&tt(a),M=et(r)&&et(a);if(d||M){if(!n.sampleValues)return!0;let b=0,L=0;for(let g of n.sampleValues){if(g==null||g==="")continue;b++;let v=Number(String(g).trim());if(Number.isFinite(v)&&(d?tt(v):et(v))&&L++,b>=60)break}if(b>=2&&L===b)return!0}return!1}if(n.sampleValues){let r=n.locale?dt(n.locale):null,a=0,l=0,c=[];for(let d of n.sampleValues){if(d==null||d==="")continue;a++;let M=String(d).trim();if(c.push(M),(se.test(M)||ce(M,r))&&l++,a>=60)break}if(a>=2&&l/a>=.8||It(c,n.locale)!==null)return!0}return!1}function fe(n){let t=(n||"").trim().toLowerCase();return t.startsWith("sum ")||t.startsWith("total ")?"sum":t.startsWith("average ")||t.startsWith("avg. ")?"avg":t.startsWith("count ")||t.startsWith("distinct count ")||t.startsWith("count (distinct) ")?"count":t.startsWith("min ")||t.startsWith("minimum ")?"min":t.startsWith("max ")||t.startsWith("maximum ")?"max":null}function de(n){let{rows:t,measureColIdx:e,measureName:s,candidateDims:o,minNum:r,maxNum:a,discourageAgg:l}=n,c=100,d=.01,M="";for(let L of o){if(L.distinct<2||L.distinct>c)continue;let g=o.filter(N=>N.idx!==L.idx).map(N=>N.idx),v=new Map;for(let N of t){let k=N[e];if(typeof k!="number"||!Number.isFinite(k))continue;let B=g.length?g.map(P=>String(N[P])).join(M):"",U=v.get(B);U||(U={sum:0,cset:new Set},v.set(B,U)),U.sum+=k,U.cset.add(String(N[L.idx]))}let x=0,A=0,w=0;for(let N of v.values())N.cset.size<2||(w++,Math.abs(N.sum-100)<=100*d?x++:Math.abs(N.sum-1)<=1*d&&A++);if(w>=2&&(x/w>=.9||A/w>=.9))return{additivity:"part_of_whole",partOfWholeDim:L.name}}if(l)return{additivity:"intensive_rate"};let b=fe(s);return b==="avg"||b==="min"||b==="max"?{additivity:"intensive_rate"}:b==="count"?{additivity:"additive"}:b==="sum"?{additivity:"unknown"}:r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&r>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function vt(n){let{dataType:t,isMeasure:e,name:s,distinct:o,nonblank:r,prec:a,maxval:l,minval:c}=n,d=l-c+1,M=d>0?o/d:1,b=r>0?o/r:0,L=t==="Decimal"||a>0;return ne(s)?"Categorical":M>=$t&&(st(s)&&o<=jt||c>=qt&&l<=Jt||c>=Qt&&l<=te)?"Ordinal":e||o>Yt&&(L||o>=Zt||b>=Xt)?"Continuous":"Categorical"}var xt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(t){return t==null?"":t.toString()}getPrecision(t){if(!isFinite(t))return 0;let s=t.toString().split(".")[1];return s?s.length:0}getColumns(){return this._cols}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:t.getHours()!==0||t.getMinutes()!==0||t.getSeconds()!==0||t.getMilliseconds()!==0}getColumnsWithStats(t,e){if(this._computedStatsForLevel==t)return this._cols;let s=0,o=parseInt(t),r=[];for(let i of this._cols){let m=new Map,E=[],h=0,u=0,_=0,S=null,y=null,p=null,R=!1,D=!0,I=!0,O=null,G=!1;for(let T of this._rows){let f=T[s],C=this.STR(f);if(C!=""){if(h+=C.length,m.set(C,(m.get(C)||0)+1),u++,i.dataType=="Integer"||i.dataType=="Decimal"||i.dataType=="DateTime")if((S===null||f<S)&&(S=f),(y===null||f>y)&&(y=f),i.dataType=="Integer"||i.dataType=="Decimal"){if(p===null?p=f:p+=f,i.dataType=="Decimal"){let F=this.getPrecision(f);F>_&&(_=F)}E.push(f)}else R=R||this.hasTimeComponent(f);G&&(f<O?D=!1:f>O&&(I=!1)),O=f,G=!0}}if(u>=3&&(D&&!I?i.sortedDirection="asc":I&&!D?i.sortedDirection="desc":i.sortedDirection="none"),u>0&&m.size>0&&!i.isMeasure){let T=0,f=Number.MAX_SAFE_INTEGER;for(let C of m.values())C>T&&(T=C),C<f&&(f=C);if(i.modalShare=T/u,i.minGroupCount=f===Number.MAX_SAFE_INTEGER?null:f,m.size===2){let C=[...m.keys()].map(V=>it(V).trim().toLowerCase()).sort(),H=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(V=>C[0]===V[0]&&C[1]===V[1]),z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(i.name);(H||z)&&(i.isBinaryFlag=!0)}}if(i.dataType=="DateTime"&&(i.dateWithTime=R),i.isTemporal=me({dataType:i.dataType,name:i.name,isMeasure:i.isMeasure,distinctCount:m.size,minNum:typeof S=="number"?S:null,maxNum:typeof y=="number"?y:null,sampleValues:m.keys(),locale:e}),i.isTemporal&&i.dataType==="String"&&!i.isMeasure){let T=It(m.keys(),e);T&&(i.temporalTextPattern=T.pattern)}this.updateColumnStats10(o,i,u,m,_,y,S),this.updateColumnStats20(o,E,u,p,i,h,R,S,y,_,m,e),!i.isMeasure&&(i.dataType==="Integer"||i.dataType==="Decimal")&&vt({dataType:i.dataType,isMeasure:!1,name:i.name,distinct:m.size,nonblank:u,prec:_,maxval:typeof y=="number"?y:0,minval:typeof S=="number"?S:0})==="Continuous"&&(i.isMeasure=!0,i.geoKind=void 0,i.geoMatchPct=void 0,i.geoAmbiguous=void 0,i.dominantGeoRegion=void 0,i.dominantGeoRegionPct=void 0,i.geoRegionCount=void 0),r[s]=i.isMeasure||m.size>2e3?null:new Set(m.keys()),s++}let a=[];this._cols.forEach((i,m)=>{i.isMeasure||a.push({idx:m,distinct:i.distinctCount??0,name:i.name})}),this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let E=typeof i.lowValue=="number"?i.lowValue:null,h=typeof i.highValue=="number"?i.highValue:null,u=de({rows:this._rows,measureColIdx:m,measureName:i.name,candidateDims:a,minNum:E,maxNum:h,discourageAgg:!!i.discourageAggregationAcrossGroups});i.additivity=u.additivity,u.partOfWholeDim&&(i.partOfWholeDim=u.partOfWholeDim)});let l=50,c=a.filter(i=>i.distinct>=2&&i.distinct<=l);this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let E=[];for(let f of this._rows){let C=f[m];if(C==null||C==="")continue;let F=typeof C=="number"?C:parseFloat(C);isNaN(F)||E.push(F)}if(E.length===0)return;let h=[...E].sort((f,C)=>f-C),u=f=>h[Math.min(h.length-1,Math.max(0,Math.floor(f*(h.length-1))))],_=u(.5),S=u(.1),y=u(.9),p=Math.abs(_)>1e-9?Math.abs(_):Math.abs(h[h.length-1])>1e-9?Math.abs(h[h.length-1]):1;i.relativeDispersion=Math.round((y-S)/p*1e3)/1e3;let R=0;for(let f of E)R+=f;R/=E.length;let D=0;for(let f of E)D+=(f-R)*(f-R);if(D<=1e-12)return;let I=[],O=[],G=f=>{if(f.length<4)return NaN;let C=[...f].sort((H,z)=>H-z),F=H=>C[Math.min(C.length-1,Math.max(0,Math.floor(H*(C.length-1))))];return F(.75)-F(.25)},T=G(E);for(let f of c){let C=new Map;for(let z of this._rows){let V=z[m];if(V==null||V==="")continue;let Z=typeof V=="number"?V:parseFloat(V);if(isNaN(Z))continue;let nt=this.STR(z[f.idx])+"",j=C.get(nt);j?(j.s+=Z,j.n++,j.vals.push(Z)):C.set(nt,{s:Z,n:1,vals:[Z]})}let F=0;for(let z of C.values()){let V=z.s/z.n;F+=z.n*(V-R)*(V-R)}I.push({otherColumn:f.name,eta2:Math.round(F/D*1e4)/1e4});let H=[];for(let z of C.values()){let V=G(z.vals);isNaN(V)||H.push(V)}if(H.length>=2&&isFinite(T)&&T>1e-9){let z=(Math.max(...H)-Math.min(...H))/T;O.push({otherColumn:f.name,spreadRatio:Math.round(z*1e4)/1e4})}}I.length>0&&(i.groupDiscrimination=I),O.length>0&&(i.spreadDiscrimination=O)});let d=.97,M=5,b=this._cols.map((i,m)=>({c:i,i:m})).filter(i=>i.c.isMeasure);for(let i=0;i<b.length;i++)for(let m=i+1;m<b.length;m++){let E=b[i].i,h=b[m].i,u=0,_=0,S=0,y=0,p=0,R=0;for(let G of this._rows){let T=G[E],f=G[h];if(T==null||T===""||f===null||f===void 0||f==="")continue;let C=typeof T=="number"?T:parseFloat(T),F=typeof f=="number"?f:parseFloat(f);isNaN(C)||isNaN(F)||(u++,_+=C,S+=F,y+=C*C,p+=F*F,R+=C*F)}if(u<M)continue;let D=u*y-_*_,I=u*p-S*S;if(D<=1e-12||I<=1e-12)continue;let O=(u*R-_*S)/Math.sqrt(D*I);if(Math.abs(O)>=d){let G=b[i].c,T=b[m].c;G.collinearWithMeasures||(G.collinearWithMeasures=[]),T.collinearWithMeasures||(T.collinearWithMeasures=[]),G.collinearWithMeasures.push(T.name),T.collinearWithMeasures.push(G.name)}}for(let i=0;i<this._cols.length;i++){let m=r[i];if(!m||m.size===0)continue;let E=[];for(let h=0;h<this._cols.length;h++){if(h===i)continue;let u=r[h];if(!u||u.size===0)continue;let _=0;for(let y of m)u.has(y)&&_++;let S=Math.round(_/m.size*100);S>0&&E.push({otherColumn:this._cols[h].name,percentShared:S})}E.length>0&&(this._cols[i].sharedValueRatioWithOthers=E)}let L=50,g=[];for(let i=0;i<this._cols.length;i++){let m=r[i];m&&m.size>=2&&m.size<=L&&g.push(i)}if(g.length>=2){let i=new Map,m=(h,u)=>h+":"+u;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++)i.set(m(g[h],g[u]),new Map);for(let h of this._rows)for(let u=0;u<g.length;u++){let _=this.STR(h[g[u]])+"";for(let S=u+1;S<g.length;S++){let y=""+this.STR(h[g[S]]),p=i.get(m(g[u],g[S])),R=_+""+y;p.set(R,(p.get(R)??0)+1)}}let E=new Map;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++){let _=g[h],S=g[u],y=r[_].size,p=r[S].size,R=i.get(m(_,S)),D=R.size,I=0;for(let f of R.values())(I===0||f<I)&&(I=f);let O=Math.round(D/(y*p)*100),G=D===y,T=D===p;if((this._cols[_].categoricalPairStats||=[]).push({otherColumn:this._cols[S].name,fillPct:O,determinesOther:G,minCellCount:I,distinctCombinations:D}),(this._cols[S].categoricalPairStats||=[]).push({otherColumn:this._cols[_].name,fillPct:O,determinesOther:T,minCellCount:I,distinctCombinations:D}),G&&y>p){let f=E.get(_);(!f||p<f.card)&&E.set(_,{name:this._cols[S].name,card:p,ratio:p/y})}if(T&&p>y){let f=E.get(S);(!f||y<f.card)&&E.set(S,{name:this._cols[_].name,card:y,ratio:y/p})}}for(let[h,u]of E)this._cols[h].primaryParentColumn=u.name,this._cols[h].nestingRatio=Math.round(u.ratio*100)/100}let v=6,x=this._rows.length;for(let i=0;i<this._cols.length;i++){let m=this._cols[i];if(m.isMeasure||m.primaryParentColumn)continue;let E=m.distinctCount??0;if(E<=L||x>0&&E>=x)continue;let h=[];for(let u=0;u<this._cols.length;u++){if(u===i)continue;let _=this._cols[u];if(_.isMeasure)continue;let S=_.distinctCount??0;S<2||S>=E||h.push(u)}h.sort((u,_)=>(this._cols[u].distinctCount??0)-(this._cols[_].distinctCount??0));for(let u of h.slice(0,v)){let _=new Map,S=!0;for(let p of this._rows){let R=this.STR(p[i])+"",D=this.STR(p[u])+"",I=_.get(R);if(I===void 0)_.set(R,D);else if(I!==D){S=!1;break}}if(!S)continue;let y=this._cols[u].distinctCount??0;m.primaryParentColumn=this._cols[u].name,m.nestingRatio=Math.round(y/E*100)/100;break}}let A=.01,w=.05,N=.95,k=8,B=8,U=6,P=500,W=[];for(let i=0;i<this._cols.length&&W.length<B;i++){let m=this._cols[i].dataType;(m==="Double"||m==="Integer"||m==="Decimal")&&W.push(i)}if(W.length>=3&&this._rows.length>=k){let i=Math.min(this._rows.length,P),m=W.map(y=>{let p=[];for(let I=0;I<i;I++){let O=this._rows[I][y],G=typeof O=="number"?O:parseFloat(String(O).replace(/,/g,""));if(O==null||O===""||!isFinite(G))return null;p.push(G)}let R=p[0],D=!1;for(let I of p)if(I!==R){D=!0;break}return D?p:null}),E=W.map((y,p)=>p).filter(y=>m[y]!==null),h=y=>{let p=y.slice().sort((D,I)=>D-I),R=p.length>>1;return p.length%2?p[R]:(p[R-1]+p[R])/2},u=null,_=[],S=y=>{if(_.length>=3){let p=_.map(O=>m[O]),R=p[0].length,D=new Array(R);for(let O=0;O<R;O++){let G=0;for(let T of p)G+=T[O];D[O]=G}let I=h(D);if(I>0){let O=0;for(let T of D)Math.abs(T-I)<=I*A&&O++;let G=O/R;if(G>=N){let T=1;for(let f of p){let C=h(f)/I;C<T&&(T=C)}T>=w&&(!u||_.length>u.cols.length)&&(u={cols:_.slice(),total:I,matched:G})}}}if(!(_.length>=U))for(let p=y;p<E.length;p++)_.push(E[p]),S(p+1),_.pop()};if(S(0),u){let y=u,R={columns:y.cols.map(D=>this._cols[W[D]].name),total:Math.round(y.total*1e3)/1e3,matchedPct:Math.round(y.matched*100)/100};for(let D of y.cols)this._cols[W[D]].constantSumGroup=R}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,e,s,o,r,a,l,c,d,M,b,L){if(t>=20){let g=[...e].sort((A,w)=>A-w),v=Math.floor(g.length/2);if(s>0&&o!=null?r.avgValue=r.dataType=="Integer"?Math.round(o/s):o/s:r.avgValue=null,s>0&&(r.avgLength=a/s),this._rows.length>0){let A=w=>{let N=new Date(w);return isNaN(N.getTime())?w:N.toISOString().slice(0,10)+"T00:00:00.000Z"};r.dataType!="DateTime"||l||!c?r.lowValue=c:r.lowValue=A(c),r.dataType!="DateTime"||l||!d?r.highValue=d:r.highValue=A(d),r.medianValue=g.length===0?null:g.length%2===0?r.dataType=="Integer"?Math.round((g[v-1]+g[v])/2):(g[v-1]+g[v])/2:g[v],r.numericPrecision=M}if(g.length>0){let A=r.avgValue??0,w=g.length,N=0,k=0;for(let U of g){let P=U-A;N+=P*P,k+=P*P*P}let B=N/w;r.skewness=B===0?0:k/w/Math.pow(Math.sqrt(B),3),r.stdDev=Math.sqrt(B)}o!==null&&(r.sum=o);let x=Array.from(b.entries()).sort((A,w)=>w[1]-A[1]);if(r.topCategories=x.slice(0,10).map(A=>A[1]),!r.isMeasure&&x.length>0){if(r.dataType==="String"){let A=x.map(N=>N[0]);r.formatSignature=mt(A);let w=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!w.test(r.formatSignature)&&(r.avgLength===void 0||r.avgLength>=3)&&(r.isFreeText=!0)}else r.topCategoryValues=x.slice(0,5).map(A=>A[0]);if(t>=20){let A=x.map(N=>N[0]),w=at(A,L);if(w!==null)r.ordinalPattern=w.pattern,r.orderedDomain=w.orderedDomain;else if(r.dataType==="String"){let N=ot(A);N!==null&&(r.safeDistinctValues=N)}}}if(g.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let A=w=>g[Math.floor((g.length-1)*w)];r.quantiles={p05:A(.05),p25:A(.25),p75:A(.75),p95:A(.95)}}}if(!r.isMeasure&&b.size>0){let g=Array.from(b.entries()).sort((x,A)=>A[1]-x[1]),v=ct(g.map(x=>x[0]),r.name,L);if(v!==null&&(r.geoKind=v.geoKind,r.geoMatchPct=v.geoMatchPct,v.geoAmbiguous&&(r.geoAmbiguous=!0),v.geoKind.indexOf("country")===0)){let x=Q(g);x&&(r.dominantGeoRegion=x.dominantGeoRegion,r.dominantGeoRegionPct=x.dominantGeoRegionPct,r.geoRegionCount=x.regionCount)}}}updateColumnStats10(t,e,s,o,r,a,l){t>=10&&(e.blankCount=this._rows.length-s,e.distinctCount=o.size+(e.blankCount!=0?1:0),e.valueNature="Categorical",s>0&&(e.dataType==="Integer"||e.dataType==="Decimal"?e.valueNature=vt({dataType:e.dataType,isMeasure:!!e.isMeasure,name:e.name,distinct:o.size,nonblank:s,prec:r,maxval:a,minval:l}):e.dataType==="DateTime"&&(e.valueNature=e.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let t=[];if(this._cols.forEach((s,o)=>{s.isMeasure||t.push(o)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let e=new Set;for(let s of this._rows)e.add(JSON.stringify(t.map(o=>s[o])));return this._leafCardinality=e.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let t=a=>String(a||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),e=-1,s=-1,o=-1;if(this._cols.forEach((a,l)=>{let c=t(a.name),d=a.dataType==="Integer"||a.dataType==="Decimal";d&&e<0&&c.some(M=>M==="lat"||M==="latitude")?e=l:d&&s<0&&c.some(M=>M==="lon"||M==="lng"||M==="long"||M==="longitude")&&(s=l),o<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(o=l)}),e<0||s<0)return null;let r=[];for(let a of this._rows){let l=a[e],c=a[s],d=l==null||l===""?null:Number(l),M=c==null||c===""?null:Number(c);r.push({lat:d,lon:M,country:o>=0&&J(this.STR(a[o]))?this.STR(a[o]):null})}return this._geoExtent=ht(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let e="abcdefghijklmnopqrstuvwxyz",s=()=>e[Math.floor(Y()*e.length)],o=()=>s().toUpperCase(),r=()=>Math.floor(Y()*10).toString(),a=v=>/[A-Z]/.test(v)?o():/[a-z]/.test(v)?s():/[0-9]/.test(v)?r():v,l=t.includes("@")&&t.includes("."),c=l?t.split("@"):[t],d=l?c[1]:"",M=d.endsWith(".com"),b=M?".com":"",L=M?d.slice(0,-4):d,g=v=>{let x="";for(let A of v)x+=a(A),/[a-zA-Z0-9]/.test(A)&&Y()<.2&&(x+=a(A));if(x.length>6){let A=Math.floor(Y()*Math.min(3,x.length-6));for(let w=0;w<A;w++){let N=0;for(;N<5;){let k=Math.floor(Y()*x.length);if(/[a-zA-Z0-9]/.test(x[k])){x=x.slice(0,k)+x.slice(k+1);break}N++}}}return x};if(l){let v=g(c[0]),x=g(L);return`${v}@${x}${b}`}else return g(t)}toObjectArray(){return this._rows.map(t=>{let e={};return this._cols.forEach((s,o)=>{e[s.name]=t[o],this.emitLegacyAggAliases&&s.hostName&&s.hostName!==s.name&&!Object.prototype.hasOwnProperty.call(e,s.hostName)&&(e[s.hostName]=t[o])}),e})}async getCSVAsync(t){let e=[],s=t?25:1e7,o=t?4e3:1e7,r=new Map;for(let l of this._rows){let c={};for(let d=0;d<this._cols.length;d++){let M=this._cols[d],b=l[d];if(this.STR(b)!=""){if(t&&M.dataType=="String")if(r.has(b))b=r.get(b);else{let L=this.obfuscateString(b);r.set(b,L),b=L}else M.dataType=="DateTime"&&!M.dateWithTime&&(b=new Date(b).toISOString().slice(0,10)+"T00:00:00.000Z");o-=this.STR(b).length}else b=null;c[d]=b,--o}if(e.push(c),--s,s<=0||o<=0)break}return await Rt.unparse(e,{header:!1})}getCSVHeaderLine(){return Rt.unparse([this._cols.map(t=>this.STR(this.emitLegacyAggAliases&&t.hostName?t.hostName:t.name))])}addRow(t,e){if(this.dedupRows){let s="";for(let r of t)s+=this.STR(r)+"~";let o=rt(s);if(this._rowHashes.has(o))return!1;this._rowHashes.add(o)}return this._rows.push(t),this._origIndices.push(e??-1),!0}getOriginalRowIndex(t){return t<0||t>=this._origIndices.length?-1:this._origIndices[t]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null}setColumns(t){if(this._cols=t,!t||t.length===0)return;let e=new Set(t.map(s=>this.STR(s?.name)));for(let s of t){if(!s)continue;let o=this.STR(s.name),r=St(o);!r||r===o||e.has(r)||(e.delete(o),e.add(r),s.hostName=o,s.name=r)}}};export{ht as a,Dt as b,J as c,pe as d,Ot as e,Lt as f,Pt as g,Gt as h,_t as i,kt as j,St as k,ye as l,Mt as m,Bt as n,Tt as o,Nt as p,_e as q,Se as r,Ce as s,ne as t,It as u,me as v,fe as w,de as x,vt as y,xt as z};
|
|
@@ -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 Q,c as tt,d as nt,e as et,f as W,g as st,h as ot,i as it,p as L,v as V}from"./chunk-E6SVTFAW.mjs";import{a as q}from"./chunk-U43WE7LN.mjs";var St="006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191193194195196197198199200201202203204205206207208209210211212214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310312313314315316317318319320321322323324325326327328329330331333334335336337338339341342344346347349350351352354355356357358359360361362363364365366367368369370371372373374376377378379380381382383384385386387388389390391392393394395396397398400401402403404405406407408409410411412413414415416417418420421422423424425426427430431432433434435436437438439440441442443444445446447448449450451452453454455456457458460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508510511512513514515516520521522523524525526527528530531532534535537538539540541542543544545546547548549550551553554556557558559560561562563564565566567570571572573574575576577580581582583584585586587588590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620622623624625626627628629630631633634635636637638639640641644645646647648650651652653654655656657658660661662664665666667668669670671672673674675676677678679680681683684685686687688689690691692693700701703704705706707708710711712713714716717718719720721722723724725726727728729730731734735736737738739740741743744745746747748749750751752753754755756757758759760761762763764765766767768769770772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816820821822823824825826827828829830831832833834835836837838840841843844845846847850851852853855856857859860863864865870871873874875877878879880881882883884890891893894895897898900902903904905906907908910911912913914915916917918919920921922923924925926927928930931932933934935936937939940941943944945946947948949950951952953954955956957958959960961967968969970971972973974975976977978979980981982983984985986988989990991992993994995996997998999",w=new Set(St.match(/.{3}/g)??[]);var at=[["AL","Alabama"],["AK","Alaska"],["AZ","Arizona"],["AR","Arkansas"],["CA","California"],["CO","Colorado"],["CT","Connecticut"],["DE","Delaware"],["FL","Florida"],["GA","Georgia"],["HI","Hawaii"],["ID","Idaho"],["IL","Illinois"],["IN","Indiana"],["IA","Iowa"],["KS","Kansas"],["KY","Kentucky"],["LA","Louisiana"],["ME","Maine"],["MD","Maryland"],["MA","Massachusetts"],["MI","Michigan"],["MN","Minnesota"],["MS","Mississippi"],["MO","Missouri"],["MT","Montana"],["NE","Nebraska"],["NV","Nevada"],["NH","New Hampshire"],["NJ","New Jersey"],["NM","New Mexico"],["NY","New York"],["NC","North Carolina"],["ND","North Dakota"],["OH","Ohio"],["OK","Oklahoma"],["OR","Oregon"],["PA","Pennsylvania"],["RI","Rhode Island"],["SC","South Carolina"],["SD","South Dakota"],["TN","Tennessee"],["TX","Texas"],["UT","Utah"],["VT","Vermont"],["VA","Virginia"],["WA","Washington"],["WV","West Virginia"],["WI","Wisconsin"],["WY","Wyoming"],["DC","District of Columbia"],["PR","Puerto Rico"],["GU","Guam"],["VI","U.S. Virgin Islands"],["AS","American Samoa"],["MP","Northern Mariana Islands"]],ct=new Set(at.map(n=>n[0])),yt={"Ala.":"AL","Alab.":"AL","Ariz.":"AZ","Ark.":"AR","Calif.":"CA","Cal.":"CA","Colo.":"CO","Col.":"CO","Conn.":"CT","Del.":"DE","Fla.":"FL","Flor.":"FL","Ga.":"GA","Ill.":"IL","Ind.":"IN","Kan.":"KS","Kans.":"KS","Ky.":"KY","La.":"LA","Md.":"MD","Mass.":"MA","Mich.":"MI","Minn.":"MN","Miss.":"MS","Mo.":"MO","Mont.":"MT","Neb.":"NE","Nebr.":"NE","Nev.":"NV","N.H.":"NH","N.J.":"NJ","N.M.":"NM","N.Mex.":"NM","N. Mex.":"NM","N.Y.":"NY","N.C.":"NC","N.D.":"ND","N.Dak.":"ND","N. Dak.":"ND","Okla.":"OK","Ore.":"OR","Oreg.":"OR","Pa.":"PA","Penn.":"PA","Penna.":"PA","R.I.":"RI","S.C.":"SC","S.D.":"SD","S.Dak.":"SD","S. Dak.":"SD","Tenn.":"TN","Tex.":"TX","Vt.":"VT","Va.":"VA","Wash.":"WA","W.Va.":"WV","W. Va.":"WV","Wis.":"WI","Wisc.":"WI","Wyo.":"WY","D.C.":"DC","Wash. D.C.":"DC","Wash., D.C.":"DC","P.R.":"PR","V.I.":"VI"},ut=(()=>{let n=new Map;for(let[s,i]of at)n.set(g(i),s);n.set(g("Washington DC"),"DC"),n.set(g("Washington D.C."),"DC"),n.set(g("US Virgin Islands"),"VI");for(let[s,i]of Object.entries(yt)){let r=g(s);r&&!n.has(r)&&n.set(r,i)}return n})(),lt=new Set(["01","02","04","05","06","08","09","10","11","12","13","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","44","45","46","47","48","49","50","51","53","54","55","56","60","66","69","72","78"]);function ft(n){return n.trim().toUpperCase()}function g(n){return Q(n)}var H=new Set(["country","countries","nation","nationality","iso","geo"]),U=new Set(["state","province","st"]),rt=new Set(["zip","zipcode","postal","postcode","plz"]),gt=new Set(["county","fips","borough","parish"]),ht=new Set(["city","cities","town","municipality","metro","location","place"]);function y(n,s){if(!n)return!1;for(let i of q(n))if(s.has(i))return!0;return!1}var Nt=95,At=5,Ct=6e4;function kt(n,s,i){if(!n||n.length===0)return null;let r=[],M=new Set;for(let t of n){if(t==null)continue;let e=String(t).trim();if(e.length===0||ot(g(e)))continue;let o=e.toLowerCase();if(!M.has(o)&&(M.add(o),r.push(e),r.length>Ct))return null}let h=r.length;if(h<2)return null;let N=r.map(ft),I=r.map(g),O=et(),d=0,p=0,m=0,T=0,D=0,l=0,_=0,x=0,Y=0,K=0,F=0,P=0,Z=t=>(L(t)??"").slice(0,3),$=0,J=0,E=0,X=y(s,rt);for(let t=0;t<h;++t){let e=N[t],o=I[t],u=r[t],S=tt.has(e),C=ct.has(e);nt.has(e)&&d++,S&&p++,C&&m++,S&&C&&$++;let G=O.has(o),R=ut.has(o);G&&T++,R&&D++,G&&R&&J++,W(u)&&K++,C&&R&&E++,/^\d{5}(-\d{4})?$/.test(u)||X&&/^\d{3,4}$/.test(u)?(l++,w.has(Z(u))&&P++):/^\d{4}$/.test(u)&&F++,/^\d{5}$/.test(u)&<.has(u.slice(0,2))&&_++,V(o)&&x++,V(o,"world")&&Y++}if(!X&&l>0){l+=F;for(let t of r)/^\d{4}$/.test(t)&&w.has(Z(t))&&P++}let B=t=>t/h*100,A=[],c=(t,e,o,u=!1)=>{let S=B(e),C=t==="city-name"||t==="city-name-world";S<(C?it:Nt)||e<2||u&&e<At&&!y(s,t==="country-name"?H:C?ht:U)||A.push({kind:t,matched:e,spec:o,pct:S})};c("country-iso3",d,6),c("country-name",T,5,!0),c("us-state-name",D,5,!0),c("us-zip5",l,4),c("us-county-fips",_,4),c("country-iso2",p,3),c("us-state-code",m,3);let dt=A.length;c("city-name",x,2,!0),A.length===dt&&c("city-name-world",Y,2,!0);let pt=m-E,mt=D-E;pt>0&&mt>0&&c("us-state-name",m+D-E,5,!0);let b=Math.max(d,p,T);if(K>b){let t=d===b?"country-iso3":T===b?"country-name":"country-iso2";c(t,K,t==="country-iso3"?6:t==="country-name"?5:3,t==="country-name")}if(A.length===0)return null;A.sort((t,e)=>e.pct-t.pct||e.spec-t.spec);let a=A[0],z=!1,v={"country-iso2":"us-state-code","us-state-code":"country-iso2","us-zip5":"us-county-fips","us-county-fips":"us-zip5","country-name":"us-state-name","us-state-name":"country-name"}[a.kind],k=A[1],j=v&&k&&k.kind===v&&Math.abs(a.pct-k.pct)<=15;if(a.kind==="country-iso2"||a.kind==="us-state-code"){let t=a.matched>0?$/a.matched:0,e=y(s,H),o=y(s,U);if(j||t>=.5){if(e&&!o)return f("country-iso2",p,!1);if(o&&!e)return f("us-state-code",m,!1);z=!0}}else if(a.kind==="us-zip5"||a.kind==="us-county-fips"){let t=_===l&&l===h,e=y(s,rt),o=y(s,gt);return o&&!e?f("us-county-fips",_,!1):e&&!o?f("us-zip5",l,!1):t?f("us-zip5",l,!0):f("us-zip5",l,!1)}else if(j&&(a.kind==="country-name"||a.kind==="us-state-name")){let t=a.matched>0?J/a.matched:0,e=y(s,H),o=y(s,U);if(e&&!o)return f("country-name",T,!1);if(o&&!e)return f("us-state-name",D,!1);t>=.5&&(z=!0)}return f(a.kind,a.matched,z);function f(t,e,o){let S={geoKind:t,geoMatchPct:Math.round(B(t==="us-zip5"?P:e)*10)/10};return o&&(S.geoAmbiguous=!0),S}}function Mt(n,s){if(n==null)return null;let i=String(n).trim();if(i.length===0)return null;switch(s){case"country-iso3":case"country-iso2":case"country-name":return W(i);case"us-state-code":case"us-state-name":{let r=ft(i);return ct.has(r)?r:ut.get(g(i))??null}case"us-zip5":return L(i);case"us-county-fips":return/^\d{5}$/.test(i)&<.has(i.slice(0,2))?i:null;default:return null}}function Gt(n){switch(n){case"country-iso3":case"country-iso2":case"country-name":case"us-state-code":case"us-state-name":case"us-zip5":case"us-county-fips":return!0;default:return!1}}function It(n,s){return s==="us-zip5"?w.has(n.slice(0,3)):!0}function Wt(n,s){let i=new Array(n.length),r=new Set,M=[],h=0;for(let N=0;N<n.length;++N){let I=Mt(n[N],s),O=I!==null&&It(I,s)?I:null;if(i[N]=O,O!==null)h++;else{let d=n[N];if(d!=null){let p=String(d).trim();if(p.length>0){let m=p.toLowerCase();r.has(m)||(r.add(m),M.push(p))}}}}return{iso:i,unmatched:M,matchedRows:h,totalRows:n.length}}export{rt as a,y as b,kt as c,Mt as d,Gt as e,Wt as f};
|
|
@@ -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{t as w,z as b}from"./chunk-
|
|
2
|
+
import{t as w,z as b}from"./chunk-6ZU65KK6.mjs";import C from"papaparse";var D=500,S=/^[+-]?\d{1,15}$/,E=/^[+-]?(\d{1,3}(,\d{3})*|\d+)(\.\d+)?([eE][+-]?\d+)?$/,R=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,L=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function I(n){let i=0,e=0,r=0,o=0;for(let a of n){if(a==null)continue;if(typeof a=="number"){o++,e++,Number.isInteger(a)&&i++;continue}if(a instanceof Date){o++,r++;continue}if(typeof a=="boolean"){o++;continue}let c=String(a).trim();if(c!==""){if(o++,S.test(c)){i++,e++;continue}if(E.test(c)){e++;continue}if((R.test(c)||L.test(c))&&!isNaN(Date.parse(c))){r++;continue}}}return o===0?"String":r===o?"DateTime":i===o?"Integer":e===o?"Decimal":"String"}function x(n,i){if(n==null)return null;if(typeof n=="number")return i==="String"?String(n):n;if(n instanceof Date)return i==="DateTime"?n:n.toISOString();if(typeof n=="boolean")return String(n);let e=String(n).trim();if(e==="")return null;switch(i){case"Integer":return S.test(e)?parseInt(e,10):null;case"Decimal":return E.test(e)?parseFloat(e.replace(/,/g,"")):null;case"DateTime":{let r=Date.parse(e);return isNaN(r)?null:new Date(r)}default:return e}}function M(n){let i=(n||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(i)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(i)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(i)?"DateTime":(/^(bit|bool|boolean)$/.test(i),"String")}function g(n,i,e){if(n.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=n.length,o=n.map((t,s)=>t.dataType??I(i.slice(0,D).map(l=>l?.[s]))),a=new Set((e.measures??[]).map(t=>t.toLowerCase())),c=new Set((e.dimensions??[]).map(t=>t.toLowerCase())),d=new Set((e.nonAdditive??[]).map(t=>t.toLowerCase())),T=n.map((t,s)=>{let l=t.name.toLowerCase(),u=t.isMeasure??((o[s]==="Integer"||o[s]==="Decimal")&&!w(t.name));a.has(l)&&(u=!0),c.has(l)&&(u=!1);let h={name:t.name,dataType:o[s],isMeasure:u};return u&&d.has(l)&&(h.discourageAggregationAcrossGroups=!0),h}),m=new b;m.dedupRows=e.dedup!==!1,m.setColumns(T);for(let t=0;t<i.length;t++){let s=i[t];m.addRow(Array.from({length:r},(l,u)=>x(s?.[u],o[u])),t)}let y=m.getColumnsWithStats(e.privacyLevel??"20",e.locale??"en"),f=new Map(y.map(t=>[t.name,t]));n.forEach(t=>{let s=f.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});for(let[t,s]of Object.entries(e.formats??{})){let l=f.get(t);l&&(l.modelFormat=s)}for(let[t,s]of Object.entries(e.descriptions??{})){let l=f.get(t);l&&(l.modelDesc=s)}for(let t of e.groupBy??[]){let s=f.get(t);s&&(s.isGrouping=!0)}return{columns:y,rows:m.toObjectArray(),totalRows:m.getRowCount(),index:m}}function p(n,i){return n.map(e=>Array.isArray(e)?e:i.map(r=>e[r]))}function A(n,i){let e=[],r=new Set,o=Math.min(n.length,Math.max(1,i));for(let a=0;a<o;a++){let c=n[a];if(!(!c||typeof c!="object"))for(let d of Object.keys(c))r.has(d)||(r.add(d),e.push(d))}return e}function $(n,i={}){switch(n.kind){case"csv":{let e=C.parse(n.text,{skipEmptyLines:!0});if(e.errors?.length&&e.data.length===0)throw new Error(`ingest: CSV parse failed - ${e.errors[0].message}`);let r=e.data;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let o=r[0].map(a=>(a??"").trim());return g(o.map(a=>({name:a})),r.slice(1),i)}case"grid":{if(!n.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return g(n.header.map(e=>({name:(e??"").trim()})),n.rows??[],i)}case"table":{if(!n.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let e=n.columns.map(r=>r.name);return g(n.columns,p(n.rows??[],e),i)}case"objects":{let e=n.rows??[],r=n.columns?.length?n.columns:A(e,i.columnScanLimit??D).map(o=>({name:o}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return g(r,p(e,r.map(o=>o.name)),i)}case"sql":{if(!n.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let e=n.schema.map(r=>{let o=M(r.dataType);return{name:r.name,dataType:o,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(e,p(n.rows??[],e.map(r=>r.name)),i)}default:{let e=n;throw new Error(`ingest: unknown source kind '${e?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{M as a,$ as b};
|
package/dist/geoDetector.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,d,e,f}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f}from"./chunk-7MHZMBRK.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-U43WE7LN.mjs";export{a as ZIP_NAME_TOKENS,f as buildGeoIsoColumn,c as detectGeo,b as hasAnyToken,e as isJoinGeoKind,d as toGeoIso};
|
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 Xt,b as jt}from"./chunk-
|
|
2
|
+
import{a as Xt,b as jt}from"./chunk-YOBLYTXI.mjs";import{a as Pt,b as xt,c as St,d as Tt,e as Mt,f as vt,g as kt,h as _t,i as Lt,j as Nt,k as Ot,l as wt,m as zt,n as Gt,o as Et,p as $t,q as Dt,r as Ft,s as Bt,t as Kt,u as Ht,v as Vt,w as qt,x as Wt,y as Zt,z as Ut}from"./chunk-6ZU65KK6.mjs";import{a as Rt}from"./chunk-QEH7WTLB.mjs";import{a as bt,b as It}from"./chunk-2LR73DNS.mjs";import{a as V,b as q,c as yt,d as ht,e as Ct,f as At}from"./chunk-7MHZMBRK.mjs";import{a as T,f as R,g as y,h as b,i as O,j as st,k as at,l as H,m,n as lt,o as ct,p as ut,q as I,r as ft,s as gt,t as mt,u as pt,v as w,w as dt}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as ot,b as it,c as rt}from"./chunk-NNUL5RKC.mjs";import{a as J,b as Q,c as tt,d as nt,e as et}from"./chunk-U43WE7LN.mjs";var z=2,U=400;function E(r){return!!R(r)}function A(r){let e=new Set;for(let n of r){if(n==null)continue;let s=T(String(n));if(!b(s)&&!e.has(s)&&(e.add(s),e.size>=U))break}return Array.from(e)}function C(r){let e=A(r);if(e.length===0||$(r)<95)return!1;let n=e.filter(c=>E(c)&&!m(c)).length,s=e.filter(c=>!E(c)&&!!m(c)).length;return n>=1&&n>=s}function W(r,e){if(!m(r))return!1;let n=R(r);return n?e==="world"?!0:H.has(n):!1}function $(r){let e=A(r);if(e.length===0)return 0;let n=0;for(let s of e)E(s)&&n++;return Math.round(n/e.length*1e3)/10}function M(r){let e=A(r);if(e.length===0)return 0;let n=0;for(let s of e)m(s)&&n++;return Math.round(n/e.length*1e3)/10}function F(r){let e=new Set;for(let n of r){if(n==null)continue;let s=String(n).trim();if(!b(T(s))&&!e.has(s)&&(e.add(s),e.size>=U))break}return Array.from(e)}function D(r){let e=F(r);if(e.length===0)return 0;let n=0;for(let s of e)I(s).length>0&&n++;return Math.round(n/e.length*1e3)/10}function Z(r,e){return q(e,V)?!0:F(r).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Yt(r,e){let n=A(r);if(n.length===0)return 0;let s=0;for(let c of n)w(c,e)&&s++;return Math.round(s/n.length*1e3)/10}function G(r,e){let n=0;for(let s of A(r))e(s)&&n++;return n}function Jt(r,e){let n=0;for(let s of F(r))e(s)&&n++;return n}function Qt(r,e,n,s,c){let P=[],u=[],o={},v={},k=new Set(r),l=t=>e.map(i=>i[t]);for(let t of["city","country"]){let i=n?.[t];i&&k.has(i)&&(o[t]=i)}let X=new Set(c??r);for(let t of["lat","lon"]){let i=n?.[t];i&&X.has(i)&&(o[t]=i)}let p=n?.zip;if(p&&k.has(p)){let t=l(p),i=D(t);i<95?u.push(`zip=${p} (only ${i}% of values read as ZIPs)`):Z(t,p)?o.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let g=n?.state;if(g&&k.has(g)){let t=l(g),i=A(t);i.length>0&&i.every(a=>W(a,s))?u.push(`state=${g} (every value is "CA", which is both Canada and California)`):C(t)?(u.push(`state=${g} (every value is a country, not a state)`),o.country||(o.country=g)):M(t)<95?u.push(`state=${g} (only ${M(t)}% of values are states/provinces)`):o.state=g}let d=new Set(Object.values(o).filter(Boolean)),x=r.filter(t=>!d.has(t)&&!t.startsWith("__"));if(!o.state){let t=null;for(let i of x){let a=l(i);if(C(a))continue;let f=M(a);if(f<95)continue;let N=G(a,S=>!!m(S)),Y=G(a,S=>!!m(S)&&!W(S,s));N<z&&Y<1||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.state=t.name,d.add(t.name),P.push(`state=${t.name} (${t.pct}% states/provinces)`))}if(!o.zip)for(let t of x){if(d.has(t))continue;let i=l(t),a=D(i);if(!(a<95)&&Z(i,t)&&!(Jt(i,f=>I(f).length>0)<z)){o.zip=t,d.add(t),P.push(`zip=${t} (${a}% ZIP codes)`);break}}let h=o.country;if(!h||!C(l(h))){let t=null;for(let i of x){if(d.has(i)||!C(l(i)))continue;let a=$(l(i));(!t||a>t.pct)&&(t={name:i,pct:a})}t&&(h&&(u.push(`country=${h} (only ${$(l(h))}% of values are country identifiers; using ${t.name} instead)`),v.country=h),o.country=t.name,d.add(t.name),P.push(`country=${t.name}`))}if(!o.city){let t=null;for(let i of x){if(d.has(i))continue;let a=l(i),f=Yt(a,s);f<O||G(a,N=>w(N,s))<z||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.city=t.name,P.push(`city=${t.name} (${t.pct}% known cities)`))}let B=o.country?l(o.country):[],_=!!o.country&&C(B),j=_?new Set(B.map(t=>R(t==null?null:String(t))).filter(Boolean)).size:0,K=_&&j>=2,L=!!(o.lat&&o.lon)&&e.some(t=>{let i=+String(t[o.lat]??"").trim(),a=+String(t[o.lon]??"").trim();return isFinite(i)&&isFinite(a)&&i>=-90&&i<=90&&a>=-180&&a<=180&&String(t[o.lat]??"").trim()!==""&&String(t[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!L&&u.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||L)&&u.push(_?`country=${o.country} (every row resolves to the same country - nothing to place apart)`:`country=${o.country} (values are not country identifiers)`),{bind:!!(o.city||o.state||o.zip||K||L)?o:null,backfilled:P,refused:u,...Object.keys(v).length?{labelFallback:v}:{}}}export{O as CITY_ROLE_MATCH_PCT,nt as GET_RANDOM,vt as INTENSIVE_SUFFIX_TOKENS,Mt as INTENSIVE_WORD_TOKENS,Ut as IndexedText,_t as POSITIONAL_SUFFIX_TOKENS,kt as POSITIONAL_WORD_TOKENS,y as ROLE_MATCH_PCT,tt as SIMPLE_STRING_HASH,Q as STR,M as admin1MatchPct,$t as allowedAggregations,At as buildGeoIsoColumn,mt as buildGeoPointColumns,dt as cityMatchPct,pt as cityTagsFor,Wt as classifyAdditivity,Et as classifyForAggregation,Zt as classifyNumericValueNature,Vt as classifyTemporal,wt as codeNeedsLegacyAggNames,Ot as collapseRepeatedAggPrefix,St as countryRegion,Dt as defaultAggregation,Rt as detectFormatSignature,yt as detectGeo,rt as detectOrdinalDomain,Ht as detectTextDatePattern,Xt as engineTypeForSqlType,Nt as hasDefaultAggPrefix,qt as hostAggHint,jt as ingest,Ft as isAggregationAllowed,b as isBlankLike,at as isCityTableLoaded,et as isDeterministicRefusal,ft as isGeoPointAmbiguity,Kt as isIdentifierName,Ct as isJoinGeoKind,ot as isOrdinalFriendlyName,C as looksLikeCountryColumn,It as monthLookupFor,Gt as nameLooksIntensiveRate,zt as nameLooksPositional,J as nameWords,lt as normalizeCountry,bt as normalizeMonthKey,T as normalizePlaceName,ut as normalizeZip5,st as registerCityTable,xt as registerIso3Regions,m as resolveAdmin1,gt as resolveGeoPoint,Qt as resolvePointRoles,it as safeDistinctValuesToShip,Bt as shareOfTotalIsHonest,Lt as stripHostAggPrefix,Tt as summarizeCountryRegions,Pt as summarizeGeoExtent,ht as toGeoIso,D as zipMatchPct,I as zipPrefixCandidates,ct as zipToPrefix3};
|
package/dist/indexedText.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{t as a,u as b,v as c,w as d,x as e,y as f,z as g}from"./chunk-
|
|
2
|
+
import{t as a,u as b,v as c,w as d,x as e,y as f,z as g}from"./chunk-6ZU65KK6.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-7MHZMBRK.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-NNUL5RKC.mjs";import"./chunk-U43WE7LN.mjs";export{g as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName};
|
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}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-YOBLYTXI.mjs";import"./chunk-6ZU65KK6.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-7MHZMBRK.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-NNUL5RKC.mjs";import"./chunk-U43WE7LN.mjs";export{a as engineTypeForSqlType,b as ingest};
|
|
@@ -31,5 +31,12 @@ export type GeoIsoColumn = {
|
|
|
31
31
|
* Build the aligned __geoIso__ column for a full column of values under a known
|
|
32
32
|
* geoKind. Pure — the visual appends `iso` beside __rowIdx__ and surfaces
|
|
33
33
|
* `unmatched` via options.geoUnmatched (Phase 1 §3a).
|
|
34
|
+
*
|
|
35
|
+
* MATCHED MEANS DRAWABLE HERE, not merely well-formed. This column IS the join, and its
|
|
36
|
+
* `unmatched` count is what the choropleth annotates, so a value that normalizes but has no
|
|
37
|
+
* region on the bundled basemap must land in `unmatched` - otherwise the row is reported matched,
|
|
38
|
+
* joins a feature id that does not exist, and vanishes from a chart whose own annotation says
|
|
39
|
+
* nothing is missing. That is the silent-drop failure this function's contract promises to handle
|
|
40
|
+
* deterministically, one step further along than it was looking.
|
|
34
41
|
*/
|
|
35
42
|
export declare function buildGeoIsoColumn(values: (string | null | undefined)[], geoKind: GeoKind): GeoIsoColumn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.82",
|
|
4
4
|
"description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
package/dist/chunk-GFY6RNP7.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a as v,c as B,d as j,e as q,f as G,g as Q,h as nn,i as tn,p as en,v as W}from"./chunk-E6SVTFAW.mjs";import{a as X}from"./chunk-U43WE7LN.mjs";var on=[["AL","Alabama"],["AK","Alaska"],["AZ","Arizona"],["AR","Arkansas"],["CA","California"],["CO","Colorado"],["CT","Connecticut"],["DE","Delaware"],["FL","Florida"],["GA","Georgia"],["HI","Hawaii"],["ID","Idaho"],["IL","Illinois"],["IN","Indiana"],["IA","Iowa"],["KS","Kansas"],["KY","Kentucky"],["LA","Louisiana"],["ME","Maine"],["MD","Maryland"],["MA","Massachusetts"],["MI","Michigan"],["MN","Minnesota"],["MS","Mississippi"],["MO","Missouri"],["MT","Montana"],["NE","Nebraska"],["NV","Nevada"],["NH","New Hampshire"],["NJ","New Jersey"],["NM","New Mexico"],["NY","New York"],["NC","North Carolina"],["ND","North Dakota"],["OH","Ohio"],["OK","Oklahoma"],["OR","Oregon"],["PA","Pennsylvania"],["RI","Rhode Island"],["SC","South Carolina"],["SD","South Dakota"],["TN","Tennessee"],["TX","Texas"],["UT","Utah"],["VT","Vermont"],["VA","Virginia"],["WA","Washington"],["WV","West Virginia"],["WI","Wisconsin"],["WY","Wyoming"],["DC","District of Columbia"],["PR","Puerto Rico"],["GU","Guam"],["VI","U.S. Virgin Islands"],["AS","American Samoa"],["MP","Northern Mariana Islands"]],rn=new Set(on.map(n=>n[0])),pn={"Ala.":"AL","Alab.":"AL","Ariz.":"AZ","Ark.":"AR","Calif.":"CA","Cal.":"CA","Colo.":"CO","Col.":"CO","Conn.":"CT","Del.":"DE","Fla.":"FL","Flor.":"FL","Ga.":"GA","Ill.":"IL","Ind.":"IN","Kan.":"KS","Kans.":"KS","Ky.":"KY","La.":"LA","Md.":"MD","Mass.":"MA","Mich.":"MI","Minn.":"MN","Miss.":"MS","Mo.":"MO","Mont.":"MT","Neb.":"NE","Nebr.":"NE","Nev.":"NV","N.H.":"NH","N.J.":"NJ","N.M.":"NM","N.Mex.":"NM","N. Mex.":"NM","N.Y.":"NY","N.C.":"NC","N.D.":"ND","N.Dak.":"ND","N. Dak.":"ND","Okla.":"OK","Ore.":"OR","Oreg.":"OR","Pa.":"PA","Penn.":"PA","Penna.":"PA","R.I.":"RI","S.C.":"SC","S.D.":"SD","S.Dak.":"SD","S. Dak.":"SD","Tenn.":"TN","Tex.":"TX","Vt.":"VT","Va.":"VA","Wash.":"WA","W.Va.":"WV","W. Va.":"WV","Wis.":"WI","Wisc.":"WI","Wyo.":"WY","D.C.":"DC","Wash. D.C.":"DC","Wash., D.C.":"DC","P.R.":"PR","V.I.":"VI"},an=(()=>{let n=new Map;for(let[o,i]of on)n.set(m(i),o);n.set(m("Washington DC"),"DC"),n.set(m("Washington D.C."),"DC"),n.set(m("US Virgin Islands"),"VI");for(let[o,i]of Object.entries(pn)){let r=m(o);r&&!n.has(r)&&n.set(r,i)}return n})(),cn=new Set(["01","02","04","05","06","08","09","10","11","12","13","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","44","45","46","47","48","49","50","51","53","54","55","56","60","66","69","72","78"]);function un(n){return n.trim().toUpperCase()}function m(n){return v(n)}var z=new Set(["country","countries","nation","nationality","iso","geo"]),L=new Set(["state","province","st"]),sn=new Set(["zip","zipcode","postal","postcode","plz"]),mn=new Set(["county","fips","borough","parish"]),yn=new Set(["city","cities","town","municipality","metro","location","place"]);function p(n,o){if(!n)return!1;for(let i of X(n))if(o.has(i))return!0;return!1}var Sn=95,Nn=5,gn=6e4;function Kn(n,o,i){if(!n||n.length===0)return null;let r=[],A=new Set;for(let t of n){if(t==null)continue;let e=String(t).trim();if(e.length===0||nn(m(e)))continue;let s=e.toLowerCase();if(!A.has(s)&&(A.add(s),r.push(e),r.length>gn))return null}let y=r.length;if(y<2)return null;let S=r.map(un),O=r.map(m),C=q(),d=0,N=0,M=0,I=0,T=0,l=0,_=0,V=0,H=0,R=0,U=0,x=0,Y=0,E=0,F=p(o,sn);for(let t=0;t<y;++t){let e=S[t],s=O[t],u=r[t],D=B.has(e),h=rn.has(e);j.has(e)&&d++,D&&N++,h&&M++,D&&h&&x++;let P=C.has(s),K=an.has(s);P&&I++,K&&T++,P&&K&&Y++,G(u)&&R++,h&&K&&E++,/^\d{5}(-\d{4})?$/.test(u)||F&&/^\d{3,4}$/.test(u)?l++:/^\d{4}$/.test(u)&&U++,/^\d{5}$/.test(u)&&cn.has(u.slice(0,2))&&_++,W(s)&&V++,W(s,"world")&&H++}!F&&l>0&&(l+=U);let J=t=>t/y*100,g=[],c=(t,e,s,u=!1)=>{let D=J(e),h=t==="city-name"||t==="city-name-world";D<(h?tn:Sn)||e<2||u&&e<Nn&&!p(o,t==="country-name"?z:h?yn:L)||g.push({kind:t,matched:e,spec:s,pct:D})};c("country-iso3",d,6),c("country-name",I,5,!0),c("us-state-name",T,5,!0),c("us-zip5",l,4),c("us-county-fips",_,4),c("country-iso2",N,3),c("us-state-code",M,3);let ln=g.length;c("city-name",V,2,!0),g.length===ln&&c("city-name-world",H,2,!0);let fn=M-E,dn=T-E;fn>0&&dn>0&&c("us-state-name",M+T-E,5,!0);let w=Math.max(d,N,I);if(R>w){let t=d===w?"country-iso3":I===w?"country-name":"country-iso2";c(t,R,t==="country-iso3"?6:t==="country-name"?5:3,t==="country-name")}if(g.length===0)return null;g.sort((t,e)=>e.pct-t.pct||e.spec-t.spec);let a=g[0],b=!1,$={"country-iso2":"us-state-code","us-state-code":"country-iso2","us-zip5":"us-county-fips","us-county-fips":"us-zip5","country-name":"us-state-name","us-state-name":"country-name"}[a.kind],k=g[1],Z=$&&k&&k.kind===$&&Math.abs(a.pct-k.pct)<=15;if(a.kind==="country-iso2"||a.kind==="us-state-code"){let t=a.matched>0?x/a.matched:0,e=p(o,z),s=p(o,L);if(Z||t>=.5){if(e&&!s)return f("country-iso2",N,!1);if(s&&!e)return f("us-state-code",M,!1);b=!0}}else if(a.kind==="us-zip5"||a.kind==="us-county-fips"){let t=_===l&&l===y,e=p(o,sn),s=p(o,mn);return s&&!e?f("us-county-fips",_,!1):e&&!s?f("us-zip5",l,!1):t?f("us-zip5",l,!0):f("us-zip5",l,!1)}else if(Z&&(a.kind==="country-name"||a.kind==="us-state-name")){let t=a.matched>0?Y/a.matched:0,e=p(o,z),s=p(o,L);if(e&&!s)return f("country-name",I,!1);if(s&&!e)return f("us-state-name",T,!1);t>=.5&&(b=!0)}return f(a.kind,a.matched,b);function f(t,e,s){let u={geoKind:t,geoMatchPct:Math.round(J(e)*10)/10};return s&&(u.geoAmbiguous=!0),u}}function hn(n,o){if(n==null)return null;let i=String(n).trim();if(i.length===0)return null;switch(o){case"country-iso3":case"country-iso2":case"country-name":return G(i);case"us-state-code":case"us-state-name":{let r=un(i);return rn.has(r)?r:an.get(m(i))??null}case"us-zip5":return en(i);case"us-county-fips":return/^\d{5}$/.test(i)&&cn.has(i.slice(0,2))?i:null;default:return null}}function Rn(n){switch(n){case"country-iso3":case"country-iso2":case"country-name":case"us-state-code":case"us-state-name":case"us-zip5":case"us-county-fips":return!0;default:return!1}}function wn(n,o){let i=new Array(n.length),r=new Set,A=[],y=0;for(let S=0;S<n.length;++S){let O=hn(n[S],o);if(i[S]=O,O!==null)y++;else{let C=n[S];if(C!=null){let d=String(C).trim();if(d.length>0){let N=d.toLowerCase();r.has(N)||(r.add(N),A.push(d))}}}}return{iso:i,unmatched:A,matchedRows:y,totalRows:n.length}}export{sn as a,p as b,Kn as c,hn as d,Rn as e,wn as f};
|