@bicharts/shape-core 0.5.86 → 0.5.87
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-6NQENOVB.mjs +2 -0
- package/dist/chunk-6W2GOB6U.mjs +2 -0
- package/dist/{chunk-RYRSAP64.mjs → chunk-KSG5NPJB.mjs} +1 -1
- package/dist/{chunk-ZCCCL7P2.mjs → chunk-NOC2K3R2.mjs} +1 -1
- package/dist/{chunk-KNCUJNVB.mjs → chunk-RC567DAC.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/ordinalDetector.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/indexedText.d.ts +6 -18
- package/dist/types/util.d.ts +32 -0
- package/dist/util.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-GLLNTEEM.mjs +0 -2
- package/dist/chunk-RBHJL2XA.mjs +0 -2
|
@@ -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
|
+
function s(t){return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(n=>n.length>0):[]}function c(t){return t!=null?t.toString():""}function a(t){if(!t)return 0;let n=0xcbf29ce484222325n,e=0x100000001b3n,r=n;for(let o=0;o<t.length;o++)r^=BigInt(t.charCodeAt(o)),r=r*e&0xFFFFFFFFFFFFFFFFn;return Number(r&0x1FFFFFFFFFFFFFn)}function g(){let t=typeof globalThis<"u"?globalThis:{};if(t.crypto&&typeof t.crypto.getRandomValues=="function"){let n=new Uint32Array(1);return t.crypto.getRandomValues(n),n[0]/4294967296}return Math.floor(Date.now()%4294967295)/4294967296}function f(t){return!!t&&t.isRefusal===!0}function p(t){let n=Date.parse(t);if(isNaN(n))return null;let e=new Date(n);if(F.test(t)||i.test(t.trim())||l.test(t))return e;let r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())),o=e.getFullYear();return o>=0&&o<100&&r.setUTCFullYear(o),r}function u(t){return!(t instanceof Date)||isNaN(t.getTime())?null:t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0?"utc":t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0&&t.getMilliseconds()===0?"local":null}function T(t){let n=u(t);if(!n)return null;let e=t;if(n==="utc")return e.toISOString().slice(0,10);let r=o=>(o<10?"0":"")+o;return`${e.getFullYear()}-${r(e.getMonth()+1)}-${r(e.getDate())}`}var F=/^\s*\d{4}(-\d{2}(-\d{2})?)?\s*$/,i=/(?:Z|[+-]\d{2}:?\d{2})$/i,l=/\b(?:GMT|UTC)\b/i;export{s as a,c as b,a as c,g as d,f as e,p as f,u as g,T as h};
|
|
@@ -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 gt}from"./chunk-QEH7WTLB.mjs";import{a as ht,b as pt}from"./chunk-2LR73DNS.mjs";import{c as dt}from"./chunk-RC567DAC.mjs";import{b as mt,f as ft}from"./chunk-E6SVTFAW.mjs";import{a as ut,b as lt,c as ct}from"./chunk-NOC2K3R2.mjs";import{a as $,b as rt,c as ot,d as Z,f as tt,h as at}from"./chunk-6NQENOVB.mjs";var Ot=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Lt=[7,72,-172,-52];function bt(n,t,e){return n>=e[0]&&n<=e[1]&&t>=e[2]&&t<=e[3]}function J(n,t){if(!n.length)return NaN;if(n.length===1)return n[0];let e=(n.length-1)*t,r=Math.floor(e),o=Math.ceil(e);return r===o?n[r]:n[r]+(n[o]-n[r])*(e-r)}var Y=n=>Math.round(n*10)/10;function _t(n,t=3){let e=[],r=[],o=0,s=0;for(let l of n){let c=l?.lat,f=l?.lon;if(typeof c!="number"||typeof f!="number"||!isFinite(c)||!isFinite(f)||c<-90||c>90||f<-180||f>180)continue;e.push(c),r.push(f);let M=l?.country?String(l.country).trim().toUpperCase():"",d=M?Q(M):null;d?((M==="US"||M==="USA")&&o++,d==="north-america"&&s++):(Ot.some(O=>bt(c,f,O))&&o++,bt(c,f,Lt)&&s++)}let a=e.length;return a<t?null:(e.sort((l,c)=>l-c),r.sort((l,c)=>l-c),{pctUsa:Y(o/a*100),pctNa:Y(s/a*100),latP5:Y(J(e,.05)),latP95:Y(J(e,.95)),lonP5:Y(J(r,.05)),lonP95:Y(J(r,.95)),n:a})}var yt={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},j=(()=>{let n=new Map;for(let t of Object.keys(yt))for(let e of yt[t].split(/\s+/))e&&n.set(e,t);return n})();function Pt(n){for(let[t,e]of n){let r=j.get(t);r&&!j.has(e)&&j.set(e,r)}}Pt(mt);function Q(n){if(!n)return null;let t=String(n).trim().toUpperCase();if(!t)return null;let e=j.get(t);if(e)return e;let r=ft(String(n));return r?j.get(r)??null:null}function ye(n,t=2){return et(n.map(e=>[e,1]),t)}function et(n,t=2){let e=new Map,r=0;for(let[a,l]of n){let c=Q(a);if(!c)continue;let f=typeof l=="number"&&isFinite(l)&&l>0?l:1;e.set(c,(e.get(c)??0)+f),r+=f}if(r<t||!e.size)return null;let o="europe",s=-1;for(let a of Array.from(e.keys()).sort()){let l=e.get(a);l>s&&(o=a,s=l)}return{dominantGeoRegion:o,dominantGeoRegionPct:Y(s/r*100),regionCount:e.size,n:r}}import xt from"papaparse";var Gt=["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"],Wt=["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"],Ft=["latitude","longitude"],Vt=["latitude","longitude"],Ct=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,kt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Bt=new RegExp("\\b("+Gt.join("|")+")\\b|("+Wt.join("|")+")$","i"),zt=new RegExp("\\b("+Ft.join("|")+")\\b|("+Vt.join("|")+")$","i");function Mt(n){return n?String(n).replace(Ct,"").trim():""}function Ut(n){return!!n&&Ct.test(String(n))}var Kt=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],St=new RegExp("^\\s*("+[...Kt].sort((n,t)=>t.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function At(n){if(n==null)return"";let t=String(n),e=St.exec(t);if(!e)return t;let r=l=>l.toLowerCase().replace(/\s+/g," ").trim(),o=r(e[1]),s=t.slice(e[0].length),a=0;for(;a<8;){let l=St.exec(s);if(!l||r(l[1])!==o)break;let c=s.slice(l[0].length);if(c.trim()==="")break;s=c,a++}return a===0?t:t.slice(0,e[0].length)+s}function Ce(n,t){if(!n||!t)return!1;let e=String(n);for(let r of t){let o=r?.hostName;if(o&&o!==r?.name&&e.includes(o))return!0}return!1}function Ht(n){let t=Mt(n);return t.length===0?"":t.replace(kt," ")}function Tt(n,t){if(!t)return!1;let e=Mt(t);return n.test(Ht(t))||n.test(e)||n.test($(e).join(" "))}function Nt(n){return Tt(zt,n)}function Yt(n){return Tt(Bt,n)||Nt(n)}var Rt=/int|double|decimal|single|float|number|currency|money/i;function Zt(n){let t=String(n?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||n?.isMeasure===!0||Rt.test(String(n?.dataType??""))?"Continuous":"Categorical"}function Xt(n){return n?.isMeasure===!0||Rt.test(String(n?.dataType??""))}function vt(n){let t=n??{},e=Zt(t);if(e!=="Continuous")return{nature:e,additivity:"unknown",basis:"role",suppressed:!1};if(Nt(t.name))return{nature:e,additivity:"positional",basis:"name",suppressed:!0};let r=String(t.additivity??"").trim().toLowerCase();if(!(r==="additive"&&Ut(t.name))){if(r==="additive")return{nature:e,additivity:"additive",basis:"measured",suppressed:!1};if(r==="part_of_whole")return{nature:e,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(r==="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}:Yt(t.name)?{nature:e,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:e,additivity:"additive",basis:"default",suppressed:!1}}function It(n){let t=vt(n),e=n??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Xt(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 Me(n){return It(n)[0]}function Ae(n,t){return It(n).indexOf(t)>=0}function Te(n,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let e=vt(n);return e.additivity==="additive"||e.additivity==="part_of_whole"||e.additivity==="unknown"}var $t=12,jt=100,qt=.3,Jt=.9,Qt=120,te=1900,ee=2100,ne=0,ie=20,se=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function re(n){if(!n)return!1;let t=$(n);return t.length===0?!1:se.has(t[t.length-1])}var oe=new Set(["year","yr","fy"]),ae=n=>$(n).some(t=>oe.has(t)),ue=/^(?:(?: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 nt(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let t=n%100;return t>=1&&t<=12}function it(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 le=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ce=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,me=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function fe(n){let t=(n||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function Et(n,t){let e=0,r=0,o=0,s=0,a=0,l="",c=0,f="",M=0,d=0,O=0,g=0,I=!1;for(let H of n){if(H==null)continue;let B=String(H).trim();if(B==="")continue;e++;let G;if(G=le.exec(B)){let V=+G[2],i=+G[3];V>=1&&V<=12&&i>=1&&i<=31&&(r++,G[4]!==void 0&&o++,G[6]!==void 0&&s++)}else if(G=ce.exec(B)){let V=+G[3],i=+G[4];V>=1&&V<=12&&i>=1&&i<=31&&(l&&l!==G[2]&&(I=!0),l=G[2],a++)}else if(G=me.exec(B)){let V=+G[1],i=+G[3];V>=1&&V<=31&&i>=1&&i<=31&&(V<=12||i<=12)&&(f&&f!==G[2]&&(I=!0),f=G[2],c++,V>12&&O++,i>12&&g++,G[5]!==void 0&&M++,G[7]!==void 0&&d++)}if(e>=200)break}if(e<2||(r+a+c)/e<.8||(r>0?1:0)+(a>0?1:0)+(c>0?1:0)!==1||I)return null;if(r>0)return o===r?{pattern:s===r?"%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(O>0&&g>0)return null;let A,N;O>0?(A=!0,N="values"):g>0?(A=!1,N="values"):(A=!fe(t),N="locale");let F=A?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return M===c?{pattern:F+(d===c?" %H:%M:%S":" %H:%M"),orderFrom:N}:{pattern:F,orderFrom:N}}function de(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 r=ht(e);return r.length>0&&t[r]!==void 0}function ge(n){let{dataType:t,name:e,isMeasure:r,distinctCount:o}=n;if(t==="DateTime")return!0;if(r)return!1;if(t==="Integer"||t==="Decimal"){let s=n.minNum,a=n.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let c=s>=1900&&a<=2100;if(c&&o>=2&&ae(e)||c&&o>=3&&o===a-s+1)return!0;let f=nt(s)&&nt(a),M=it(s)&&it(a);if(f||M){if(!n.sampleValues)return!0;let d=0,O=0;for(let g of n.sampleValues){if(g==null||g==="")continue;d++;let I=Number(String(g).trim());if(Number.isFinite(I)&&(f?nt(I):it(I))&&O++,d>=60)break}if(d>=2&&O===d)return!0}return!1}if(n.sampleValues){let s=n.locale?pt(n.locale):null,a=0,l=0,c=[];for(let f of n.sampleValues){if(f==null||f==="")continue;a++;let M=String(f).trim();if(c.push(M),(ue.test(M)||de(M,s))&&l++,a>=60)break}if(a>=2&&l/a>=.8||Et(c,n.locale)!==null)return!0}return!1}function he(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 pe(n){let{rows:t,measureColIdx:e,measureName:r,candidateDims:o,minNum:s,maxNum:a,discourageAgg:l}=n,c=100,f=.01,M="";for(let O of o){if(O.distinct<2||O.distinct>c)continue;let g=o.filter(N=>N.idx!==O.idx).map(N=>N.idx),I=new Map;for(let N of t){let F=N[e];if(typeof F!="number"||!Number.isFinite(F))continue;let H=g.length?g.map(G=>String(N[G])).join(M):"",B=I.get(H);B||(B={sum:0,cset:new Set},I.set(H,B)),B.sum+=F,B.cset.add(String(N[O.idx]))}let x=0,T=0,A=0;for(let N of I.values())N.cset.size<2||(A++,Math.abs(N.sum-100)<=100*f?x++:Math.abs(N.sum-1)<=1*f&&T++);if(A>=2&&(x/A>=.9||T/A>=.9))return{additivity:"part_of_whole",partOfWholeDim:O.name}}if(l)return{additivity:"intensive_rate"};let d=he(r);return d==="avg"||d==="min"||d==="max"?{additivity:"intensive_rate"}:d==="count"?{additivity:"additive"}:d==="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 wt(n){let{dataType:t,isMeasure:e,name:r,distinct:o,nonblank:s,prec:a,maxval:l,minval:c}=n,f=l-c+1,M=f>0?o/f:1,d=s>0?o/s:0,O=t==="Decimal"||a>0;return re(r)?"Categorical":M>=Jt&&(ut(r)&&o<=Qt||c>=te&&l<=ee||c>=ne&&l<=ie)?"Ordinal":e||o>$t&&(O||o>=jt||d>=qt)?"Continuous":"Categorical"}var Dt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(t){return t==null?"":t instanceof Date?this.wholeDayIso(t)??(isNaN(t.getTime())?"":t.toISOString()):t.toString()}getPrecision(t){if(!isFinite(t))return 0;let r=t.toString().split(".")[1];return r?r.length:0}getColumns(){return this._cols}wholeDayIso(t){return at(t)}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:this.wholeDayIso(t)===null}getColumnsWithStats(t,e){if(this._computedStatsForLevel==t)return this._cols;let r=0,o=parseInt(t),s=[];for(let i of this._cols){let m=new Map,D=[],p=0,u=0,y=0,S=null,b=null,h=null,E=!1,R=!0,w=!0,P=null,W=!1;for(let v of this._rows){let C=v[r],_=this.STR(C);if(_!=""){if(p+=_.length,m.set(_,(m.get(_)||0)+1),u++,i.dataType=="Integer"||i.dataType=="Decimal"||i.dataType=="DateTime")if((S===null||C<S)&&(S=C),(b===null||C>b)&&(b=C),i.dataType=="Integer"||i.dataType=="Decimal"){if(h===null?h=C:h+=C,i.dataType=="Decimal"){let L=this.getPrecision(C);L>y&&(y=L)}D.push(C)}else E=E||this.hasTimeComponent(C);W&&(C<P?R=!1:C>P&&(w=!1)),P=C,W=!0}}if(u>=3&&(R&&!w?i.sortedDirection="asc":w&&!R?i.sortedDirection="desc":i.sortedDirection="none"),u>0&&m.size>0&&!i.isMeasure){let v=0,C=Number.MAX_SAFE_INTEGER;for(let _ of m.values())_>v&&(v=_),_<C&&(C=_);if(i.modalShare=v/u,i.minGroupCount=C===Number.MAX_SAFE_INTEGER?null:C,m.size===2){let _=[...m.keys()].map(k=>rt(k).trim().toLowerCase()).sort(),U=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(k=>_[0]===k[0]&&_[1]===k[1]),z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(i.name);(U||z)&&(i.isBinaryFlag=!0)}}if(i.dataType=="DateTime"&&(i.dateWithTime=E),i.isTemporal=ge({dataType:i.dataType,name:i.name,isMeasure:i.isMeasure,distinctCount:m.size,minNum:typeof S=="number"?S:null,maxNum:typeof b=="number"?b:null,sampleValues:m.keys(),locale:e}),i.isTemporal&&i.dataType==="String"&&!i.isMeasure){let v=Et(m.keys(),e);v&&(i.temporalTextPattern=v.pattern)}this.updateColumnStats10(o,i,u,m,y,b,S),this.updateColumnStats20(o,D,u,h,i,p,E,S,b,y,m,e),!i.isMeasure&&(i.dataType==="Integer"||i.dataType==="Decimal")&&wt({dataType:i.dataType,isMeasure:!1,name:i.name,distinct:m.size,nonblank:u,prec:y,maxval:typeof b=="number"?b: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),s[r]=i.isMeasure||m.size>2e3?null:new Set(m.keys()),r++}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 D=typeof i.lowValue=="number"?i.lowValue:null,p=typeof i.highValue=="number"?i.highValue:null,u=pe({rows:this._rows,measureColIdx:m,measureName:i.name,candidateDims:a,minNum:D,maxNum:p,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 D=[];for(let _ of this._rows){let L=_[m];if(L==null||L==="")continue;let U=typeof L=="number"?L:parseFloat(L);isNaN(U)||D.push(U)}if(D.length===0)return;let p=[...D].sort((_,L)=>_-L),u=_=>p[Math.min(p.length-1,Math.max(0,Math.floor(_*(p.length-1))))],y=u(.5),S=u(.1),b=u(.9),h=Math.abs(y)>1e-9?Math.abs(y):Math.abs(p[p.length-1])>1e-9?Math.abs(p[p.length-1]):1;i.relativeDispersion=Math.round((b-S)/h*1e3)/1e3;let E=[];for(let _ of c){let L=new Set;for(let U of this._rows){let z=U[m];z==null||z===""||L.add(this.STR(U[_.idx])+"")}E.push({otherColumn:_.name,nonBlankGroupCount:L.size})}E.length>0&&(i.nonBlankGroups=E);let R=0;for(let _ of D)R+=_;R/=D.length;let w=0;for(let _ of D)w+=(_-R)*(_-R);if(w<=1e-12)return;let P=[],W=[],v=_=>{if(_.length<4)return NaN;let L=[..._].sort((z,k)=>z-k),U=z=>L[Math.min(L.length-1,Math.max(0,Math.floor(z*(L.length-1))))];return U(.75)-U(.25)},C=v(D);for(let _ of c){let L=new Map;for(let k of this._rows){let K=k[m];if(K==null||K==="")continue;let X=typeof K=="number"?K:parseFloat(K);if(isNaN(X))continue;let st=this.STR(k[_.idx])+"",q=L.get(st);q?(q.s+=X,q.n++,q.vals.push(X)):L.set(st,{s:X,n:1,vals:[X]})}let U=0;for(let k of L.values()){let K=k.s/k.n;U+=k.n*(K-R)*(K-R)}P.push({otherColumn:_.name,eta2:Math.round(U/w*1e4)/1e4});let z=[];for(let k of L.values()){let K=v(k.vals);isNaN(K)||z.push(K)}if(z.length>=2&&isFinite(C)&&C>1e-9){let k=(Math.max(...z)-Math.min(...z))/C;W.push({otherColumn:_.name,spreadRatio:Math.round(k*1e4)/1e4})}}P.length>0&&(i.groupDiscrimination=P),W.length>0&&(i.spreadDiscrimination=W)});let f=.97,M=5,d=this._cols.map((i,m)=>({c:i,i:m})).filter(i=>i.c.isMeasure);for(let i=0;i<d.length;i++)for(let m=i+1;m<d.length;m++){let D=d[i].i,p=d[m].i,u=0,y=0,S=0,b=0,h=0,E=0;for(let W of this._rows){let v=W[D],C=W[p];if(v==null||v===""||C===null||C===void 0||C==="")continue;let _=typeof v=="number"?v:parseFloat(v),L=typeof C=="number"?C:parseFloat(C);isNaN(_)||isNaN(L)||(u++,y+=_,S+=L,b+=_*_,h+=L*L,E+=_*L)}if(u<M)continue;let R=u*b-y*y,w=u*h-S*S;if(R<=1e-12||w<=1e-12)continue;let P=(u*E-y*S)/Math.sqrt(R*w);if(Math.abs(P)>=f){let W=d[i].c,v=d[m].c;W.collinearWithMeasures||(W.collinearWithMeasures=[]),v.collinearWithMeasures||(v.collinearWithMeasures=[]),W.collinearWithMeasures.push(v.name),v.collinearWithMeasures.push(W.name)}}for(let i=0;i<this._cols.length;i++){let m=s[i];if(!m||m.size===0)continue;let D=[];for(let p=0;p<this._cols.length;p++){if(p===i)continue;let u=s[p];if(!u||u.size===0)continue;let y=0;for(let b of m)u.has(b)&&y++;let S=Math.round(y/m.size*100);S>0&&D.push({otherColumn:this._cols[p].name,percentShared:S})}D.length>0&&(this._cols[i].sharedValueRatioWithOthers=D)}let O=50,g=[];for(let i=0;i<this._cols.length;i++){let m=s[i];m&&m.size>=2&&m.size<=O&&g.push(i)}if(g.length>=2){let i=new Map,m=(p,u)=>p+":"+u;for(let p=0;p<g.length;p++)for(let u=p+1;u<g.length;u++)i.set(m(g[p],g[u]),new Map);for(let p of this._rows)for(let u=0;u<g.length;u++){let y=this.STR(p[g[u]])+"";for(let S=u+1;S<g.length;S++){let b=""+this.STR(p[g[S]]),h=i.get(m(g[u],g[S])),E=y+""+b;h.set(E,(h.get(E)??0)+1)}}let D=new Map;for(let p=0;p<g.length;p++)for(let u=p+1;u<g.length;u++){let y=g[p],S=g[u],b=s[y].size,h=s[S].size,E=i.get(m(y,S)),R=E.size,w=0;for(let C of E.values())(w===0||C<w)&&(w=C);let P=Math.round(R/(b*h)*100),W=R===b,v=R===h;if((this._cols[y].categoricalPairStats||=[]).push({otherColumn:this._cols[S].name,fillPct:P,determinesOther:W,minCellCount:w,distinctCombinations:R}),(this._cols[S].categoricalPairStats||=[]).push({otherColumn:this._cols[y].name,fillPct:P,determinesOther:v,minCellCount:w,distinctCombinations:R}),W&&b>h){let C=D.get(y);(!C||h<C.card)&&D.set(y,{name:this._cols[S].name,card:h,ratio:h/b})}if(v&&h>b){let C=D.get(S);(!C||b<C.card)&&D.set(S,{name:this._cols[y].name,card:b,ratio:b/h})}}for(let[p,u]of D)this._cols[p].primaryParentColumn=u.name,this._cols[p].nestingRatio=Math.round(u.ratio*100)/100}let I=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 D=m.distinctCount??0;if(D<=O||x>0&&D>=x)continue;let p=[];for(let u=0;u<this._cols.length;u++){if(u===i)continue;let y=this._cols[u];if(y.isMeasure)continue;let S=y.distinctCount??0;S<2||S>=D||p.push(u)}p.sort((u,y)=>(this._cols[u].distinctCount??0)-(this._cols[y].distinctCount??0));for(let u of p.slice(0,I)){let y=new Map,S=!0;for(let h of this._rows){let E=this.STR(h[i])+"",R=this.STR(h[u])+"",w=y.get(E);if(w===void 0)y.set(E,R);else if(w!==R){S=!1;break}}if(!S)continue;let b=this._cols[u].distinctCount??0;m.primaryParentColumn=this._cols[u].name,m.nestingRatio=Math.round(b/D*100)/100;break}}let T=.01,A=.05,N=.95,F=8,H=8,B=6,G=500,V=[];for(let i=0;i<this._cols.length&&V.length<H;i++){let m=this._cols[i].dataType;(m==="Double"||m==="Integer"||m==="Decimal")&&V.push(i)}if(V.length>=3&&this._rows.length>=F){let i=Math.min(this._rows.length,G),m=V.map(b=>{let h=[];for(let w=0;w<i;w++){let P=this._rows[w][b],W=typeof P=="number"?P:parseFloat(String(P).replace(/,/g,""));if(P==null||P===""||!isFinite(W))return null;h.push(W)}let E=h[0],R=!1;for(let w of h)if(w!==E){R=!0;break}return R?h:null}),D=V.map((b,h)=>h).filter(b=>m[b]!==null),p=b=>{let h=b.slice().sort((R,w)=>R-w),E=h.length>>1;return h.length%2?h[E]:(h[E-1]+h[E])/2},u=null,y=[],S=b=>{if(y.length>=3){let h=y.map(P=>m[P]),E=h[0].length,R=new Array(E);for(let P=0;P<E;P++){let W=0;for(let v of h)W+=v[P];R[P]=W}let w=p(R);if(w>0){let P=0;for(let v of R)Math.abs(v-w)<=w*T&&P++;let W=P/E;if(W>=N){let v=1;for(let C of h){let _=p(C)/w;_<v&&(v=_)}v>=A&&(!u||y.length>u.cols.length)&&(u={cols:y.slice(),total:w,matched:W})}}}if(!(y.length>=B))for(let h=b;h<D.length;h++)y.push(D[h]),S(h+1),y.pop()};if(S(0),u){let b=u,E={columns:b.cols.map(R=>this._cols[V[R]].name),total:Math.round(b.total*1e3)/1e3,matchedPct:Math.round(b.matched*100)/100};for(let R of b.cols)this._cols[V[R]].constantSumGroup=E}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,e,r,o,s,a,l,c,f,M,d,O){if(t>=20){let g=[...e].sort((T,A)=>T-A),I=Math.floor(g.length/2);if(r>0&&o!=null?s.avgValue=s.dataType=="Integer"?Math.round(o/r):o/r:s.avgValue=null,r>0&&(s.avgLength=a/r),this._rows.length>0){let T=A=>{let N=A instanceof Date?A:typeof A=="string"?tt(A)??new Date(A):new Date(A),F=this.wholeDayIso(N);return F?F+"T00:00:00.000Z":isNaN(N.getTime())?A:N.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!c?s.lowValue=c:s.lowValue=T(c),s.dataType!="DateTime"||l||!f?s.highValue=f:s.highValue=T(f),s.medianValue=g.length===0?null:g.length%2===0?s.dataType=="Integer"?Math.round((g[I-1]+g[I])/2):(g[I-1]+g[I])/2:g[I],s.numericPrecision=M}if(g.length>0){let T=s.avgValue??0,A=g.length,N=0,F=0;for(let B of g){let G=B-T;N+=G*G,F+=G*G*G}let H=N/A;s.skewness=H===0?0:F/A/Math.pow(Math.sqrt(H),3),s.stdDev=Math.sqrt(H)}o!==null&&(s.sum=o);let x=Array.from(d.entries()).sort((T,A)=>A[1]-T[1]);if(s.topCategories=x.slice(0,10).map(T=>T[1]),!s.isMeasure&&x.length>0){if(s.dataType==="String"){let T=x.map(N=>N[0]);s.formatSignature=gt(T);let A=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!A.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=x.slice(0,5).map(T=>T[0]);if(t>=20){let T=x.map(N=>N[0]),A=ct(T,O);if(A!==null)s.ordinalPattern=A.pattern,s.orderedDomain=A.orderedDomain;else if(s.dataType==="String"){let N=lt(T);N!==null&&(s.safeDistinctValues=N)}}}if(g.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let T=A=>g[Math.floor((g.length-1)*A)];s.quantiles={p05:T(.05),p25:T(.25),p75:T(.75),p95:T(.95)}}}if(!s.isMeasure&&d.size>0){let g=Array.from(d.entries()).sort((x,T)=>T[1]-x[1]),I=dt(g.map(x=>x[0]),s.name,O);if(I!==null&&(s.geoKind=I.geoKind,s.geoMatchPct=I.geoMatchPct,I.geoAmbiguous&&(s.geoAmbiguous=!0),I.geoKind.indexOf("country")===0)){let x=et(g);x&&(s.dominantGeoRegion=x.dominantGeoRegion,s.dominantGeoRegionPct=x.dominantGeoRegionPct,s.geoRegionCount=x.regionCount)}}}updateColumnStats10(t,e,r,o,s,a,l){t>=10&&(e.blankCount=this._rows.length-r,e.distinctCount=o.size+(e.blankCount!=0?1:0),e.valueNature="Categorical",r>0&&(e.dataType==="Integer"||e.dataType==="Decimal"?e.valueNature=wt({dataType:e.dataType,isMeasure:!!e.isMeasure,name:e.name,distinct:o.size,nonblank:r,prec:s,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((r,o)=>{r.isMeasure||t.push(o)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let e=new Set;for(let r of this._rows)e.add(JSON.stringify(t.map(o=>r[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,r=-1,o=-1;if(this._cols.forEach((a,l)=>{let c=t(a.name),f=a.dataType==="Integer"||a.dataType==="Decimal";f&&e<0&&c.some(M=>M==="lat"||M==="latitude")?e=l:f&&r<0&&c.some(M=>M==="lon"||M==="lng"||M==="long"||M==="longitude")&&(r=l),o<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(o=l)}),e<0||r<0)return null;let s=[];for(let a of this._rows){let l=a[e],c=a[r],f=l==null||l===""?null:Number(l),M=c==null||c===""?null:Number(c);s.push({lat:f,lon:M,country:o>=0&&Q(this.STR(a[o]))?this.STR(a[o]):null})}return this._geoExtent=_t(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let e="abcdefghijklmnopqrstuvwxyz",r=()=>e[Math.floor(Z()*e.length)],o=()=>r().toUpperCase(),s=()=>Math.floor(Z()*10).toString(),a=I=>/[A-Z]/.test(I)?o():/[a-z]/.test(I)?r():/[0-9]/.test(I)?s():I,l=t.includes("@")&&t.includes("."),c=l?t.split("@"):[t],f=l?c[1]:"",M=f.endsWith(".com"),d=M?".com":"",O=M?f.slice(0,-4):f,g=I=>{let x="";for(let T of I)x+=a(T),/[a-zA-Z0-9]/.test(T)&&Z()<.2&&(x+=a(T));if(x.length>6){let T=Math.floor(Z()*Math.min(3,x.length-6));for(let A=0;A<T;A++){let N=0;for(;N<5;){let F=Math.floor(Z()*x.length);if(/[a-zA-Z0-9]/.test(x[F])){x=x.slice(0,F)+x.slice(F+1);break}N++}}}return x};if(l){let I=g(c[0]),x=g(O);return`${I}@${x}${d}`}else return g(t)}toObjectArray(){return this._rows.map(t=>{let e={};return this._cols.forEach((r,o)=>{e[r.name]=t[o],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(e,r.hostName)&&(e[r.hostName]=t[o])}),e})}async getCSVAsync(t){let e=[],r=t?25:1e7,o=t?4e3:1e7,s=new Map;for(let l of this._rows){let c={};for(let f=0;f<this._cols.length;f++){let M=this._cols[f],d=l[f];if(this.STR(d)!=""){if(t&&M.dataType=="String")if(s.has(d))d=s.get(d);else{let O=this.obfuscateString(d);s.set(d,O),d=O}else if(M.dataType=="DateTime"&&!M.dateWithTime){let O=d instanceof Date?d:typeof d=="string"?tt(d)??new Date(d):new Date(d);d=(this.wholeDayIso(O)??O.toISOString().slice(0,10))+"T00:00:00.000Z"}o-=this.STR(d).length}else d=null;c[f]=d,--o}if(e.push(c),--r,r<=0||o<=0)break}return await xt.unparse(e,{header:!1})}getCSVHeaderLine(){return xt.unparse([this._cols.map(t=>this.STR(this.emitLegacyAggAliases&&t.hostName?t.hostName:t.name))])}addRow(t,e){if(this.dedupRows){let r="";for(let s of t)r+=this.STR(s)+"~";let o=ot(r);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(r=>this.STR(r?.name)));for(let r of t){if(!r)continue;let o=this.STR(r.name),s=At(o);!s||s===o||e.has(s)||(e.delete(o),e.add(s),r.hostName=o,r.name=s)}}};export{_t as a,Pt as b,Q as c,ye as d,Gt as e,Wt as f,Ft as g,Vt as h,Mt as i,Ut as j,At as k,Ce as l,Nt as m,Yt as n,vt as o,It as p,Me as q,Ae as r,Te as s,re as t,Et as u,ge as v,he as w,pe as x,wt as y,Dt as z};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{t as b,z as S}from"./chunk-
|
|
2
|
+
import{t as b,z as S}from"./chunk-6W2GOB6U.mjs";import{f as w}from"./chunk-6NQENOVB.mjs";import R from"papaparse";var D=500,E=/^[+-]?\d{1,15}$/,T=/^[+-]?(\d{1,3}(,\d{3})*|\d+)(\.\d+)?([eE][+-]?\d+)?$/,L=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,I=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function x(t){let i=0,e=0,r=0,o=0;for(let a of t){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++,E.test(c)){i++,e++;continue}if(T.test(c)){e++;continue}if((L.test(c)||I.test(c))&&!isNaN(Date.parse(c))){r++;continue}}}return o===0?"String":r===o?"DateTime":i===o?"Integer":e===o?"Decimal":"String"}function M(t,i){if(t==null)return null;if(typeof t=="number")return i==="String"?String(t):t;if(t instanceof Date)return i==="DateTime"?t:t.toISOString();if(typeof t=="boolean")return String(t);let e=String(t).trim();if(e==="")return null;switch(i){case"Integer":return E.test(e)?parseInt(e,10):null;case"Decimal":return T.test(e)?parseFloat(e.replace(/,/g,"")):null;case"DateTime":return w(e);default:return e}}function A(t){let i=(t||"").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(t,i,e){if(t.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=t.length,o=t.map((n,s)=>n.dataType??x(i.slice(0,D).map(m=>m?.[s]))),a=new Set((e.measures??[]).map(n=>n.toLowerCase())),c=new Set((e.dimensions??[]).map(n=>n.toLowerCase())),d=new Set((e.nonAdditive??[]).map(n=>n.toLowerCase())),C=t.map((n,s)=>{let m=n.name.toLowerCase(),u=n.isMeasure??((o[s]==="Integer"||o[s]==="Decimal")&&!b(n.name));a.has(m)&&(u=!0),c.has(m)&&(u=!1);let h={name:n.name,dataType:o[s],isMeasure:u};return u&&d.has(m)&&(h.discourageAggregationAcrossGroups=!0),h}),l=new S;l.dedupRows=e.dedup!==!1,l.setColumns(C);for(let n=0;n<i.length;n++){let s=i[n];l.addRow(Array.from({length:r},(m,u)=>M(s?.[u],o[u])),n)}let y=l.getColumnsWithStats(e.privacyLevel??"20",e.locale??"en"),f=new Map(y.map(n=>[n.name,n]));t.forEach(n=>{let s=f.get(n.name);s&&(n.format&&(s.modelFormat=n.format),n.description&&(s.modelDesc=n.description))});for(let[n,s]of Object.entries(e.formats??{})){let m=f.get(n);m&&(m.modelFormat=s)}for(let[n,s]of Object.entries(e.descriptions??{})){let m=f.get(n);m&&(m.modelDesc=s)}for(let n of e.groupBy??[]){let s=f.get(n);s&&(s.isGrouping=!0)}return{columns:y,rows:l.toObjectArray(),totalRows:l.getRowCount(),index:l}}function p(t,i){return t.map(e=>Array.isArray(e)?e:i.map(r=>e[r]))}function k(t,i){let e=[],r=new Set,o=Math.min(t.length,Math.max(1,i));for(let a=0;a<o;a++){let c=t[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 _(t,i={}){switch(t.kind){case"csv":{let e=R.parse(t.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(!t.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return g(t.header.map(e=>({name:(e??"").trim()})),t.rows??[],i)}case"table":{if(!t.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let e=t.columns.map(r=>r.name);return g(t.columns,p(t.rows??[],e),i)}case"objects":{let e=t.rows??[],r=t.columns?.length?t.columns:k(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(!t.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let e=t.schema.map(r=>{let o=A(r.dataType);return{name:r.name,dataType:o,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(e,p(t.rows??[],e.map(r=>r.name)),i)}default:{let e=t;throw new Error(`ingest: unknown source kind '${e?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{A as a,_ as b};
|
|
@@ -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 h}from"./chunk-
|
|
2
|
+
import{a as h}from"./chunk-6NQENOVB.mjs";var w=[{name:"likert7_agreement",minMatches:5,canonical:["strongly disagree","disagree","slightly disagree","neutral","slightly agree","agree","strongly agree"]},{name:"likert5_agreement",minMatches:3,canonical:["strongly disagree","disagree","neutral","agree","strongly agree"]},{name:"likert3_agreement",minMatches:2,canonical:["disagree","neutral","agree"]},{name:"likert5_satisfaction",minMatches:3,canonical:["very dissatisfied","dissatisfied","neutral","satisfied","very satisfied"]},{name:"likert3_satisfaction",minMatches:2,canonical:["dissatisfied","neutral","satisfied"]},{name:"likert5_quality",minMatches:3,canonical:["poor","fair","good","very good","excellent"]},{name:"likert3_quality",minMatches:2,canonical:["poor","fair","good"]},{name:"frequency5",minMatches:3,canonical:["never","rarely","sometimes","often","always"]},{name:"intensity5",minMatches:3,canonical:["not at all","slightly","moderately","very","extremely"]},{name:"importance5",minMatches:3,canonical:["not important","slightly important","moderately important","very important","extremely important"]},{name:"severity_low_critical",minMatches:3,canonical:["low","medium","high","critical"]},{name:"severity_low_urgent",minMatches:3,canonical:["low","medium","high","urgent"]},{name:"severity_none_critical",minMatches:3,canonical:["none","mild","moderate","severe","critical"]},{name:"priority_p4_p1",minMatches:3,canonical:["p4","p3","p2","p1","p0"]},{name:"severity_trivial_blocker",minMatches:3,canonical:["trivial","minor","major","critical","blocker"]},{name:"severity_minor_severe",minMatches:3,canonical:["minor","moderate","major","severe"]},{name:"magnitude5_medium",minMatches:3,canonical:["very low","low","medium","high","very high"]},{name:"magnitude5_moderate",minMatches:3,canonical:["very low","low","moderate","high","very high"]},{name:"speed5",minMatches:3,canonical:["very slow","slow","moderate","fast","very fast"]},{name:"temperature6",minMatches:3,canonical:["freezing","cold","cool","mild","warm","hot"]},{name:"experience6",minMatches:3,canonical:["novice","beginner","intermediate","advanced","expert","master"]},{name:"tier_metal",minMatches:3,canonical:["bronze","silver","gold","platinum","diamond"]},{name:"tshirt_letter_sizes",minMatches:4,canonical:["xxs","xs","s","m","l","xl","xxl","xxxl"]},{name:"tshirt_word_sizes",minMatches:3,canonical:["extra small","small","medium","large","extra large"]},{name:"nps_bands",minMatches:2,canonical:["detractor","passive","promoter"]},{name:"likelihood5",minMatches:3,canonical:["very unlikely","unlikely","neutral","likely","very likely"]},{name:"education",minMatches:3,canonical:["none","primary","secondary","bachelors","masters","doctoral"]},{name:"grades_a_to_f",minMatches:3,canonical:["a","b","c","d","f"]},{name:"grades_a_to_f_plusminus",minMatches:4,canonical:["a+","a","a-","b+","b","b-","c+","c","c-","d+","d","d-","f"]}],_={seldom:"rarely",infrequently:"rarely","hardly ever":"rarely",occasionally:"sometimes",periodically:"sometimes","now and then":"sometimes",frequently:"often",frequent:"often",regularly:"often",commonly:"often",usually:"often",constantly:"always","every time":"always","all the time":"always",consistently:"always",continually:"always",bad:"poor",weak:"poor",subpar:"poor",mediocre:"fair",passable:"fair","so so":"fair",decent:"good",solid:"good",outstanding:"excellent",superb:"excellent",exceptional:"excellent",stellar:"excellent",unsatisfied:"dissatisfied",unhappy:"dissatisfied",displeased:"dissatisfied",happy:"satisfied",content:"satisfied",pleased:"satisfied",delighted:"very satisfied","highly satisfied":"very satisfied","extremely satisfied":"very satisfied","highly dissatisfied":"very dissatisfied","extremely dissatisfied":"very dissatisfied",neither:"neutral",undecided:"neutral","no opinion":"neutral","neither agree nor disagree":"neutral","completely agree":"strongly agree","totally agree":"strongly agree","completely disagree":"strongly disagree","totally disagree":"strongly disagree","highly unlikely":"very unlikely","extremely unlikely":"very unlikely","highly likely":"very likely","extremely likely":"very likely","almost certain":"very likely",bachelor:"bachelors","bachelor's":"bachelors",undergraduate:"bachelors","bachelor degree":"bachelors","master's":"masters",graduate:"masters","master degree":"masters",doctorate:"doctoral",phd:"doctoral"},v=(()=>{let n=new Set;for(let e of w)for(let a of e.canonical)n.add(u(a));return n})(),k=(()=>{let n=new Map;for(let[e,a]of Object.entries(_)){let t=u(e);v.has(t)||n.has(t)||n.set(t,u(a))}return n})();function y(n){return k.get(n)??n}var x=new Set(["hour","hr","day","dow","dom","weekday","week","wk","woy","month","mth","quarter","qtr","year","yr","semester","trimester","decade","period","fiscal","fy","rank","level","lvl","tier","grade","band","decile","percentile","quartile","quintile","score","rating","stars","step","stage","phase","round","wave","episode","chapter","age","cohort","generation","seniority","position","sequence","seq","priority"]);function j(n){if(!n)return!1;for(let e of h(n))if(x.has(e))return!0;return!1}function u(n){return n.toLowerCase().replace(/[-_]+/g," ").replace(/\s+/g," ").trim()}function f(n){let e=new Map;for(let[a,t]of n)for(let r of a)e.set(u(r),t);return e}var b=[{name:"weekday_mon_sun",minMatches:4,dict:f([[["monday","mon"],0],[["tuesday","tue","tues"],1],[["wednesday","wed","weds"],2],[["thursday","thu","thur","thurs","thr"],3],[["friday","fri"],4],[["saturday","sat"],5],[["sunday","sun"],6]])},{name:"month_jan_dec",minMatches:4,dict:f([[["january","jan"],0],[["february","feb"],1],[["march","mar"],2],[["april","apr"],3],[["may"],4],[["june","jun"],5],[["july","jul"],6],[["august","aug"],7],[["september","sep","sept"],8],[["october","oct"],9],[["november","nov"],10],[["december","dec"],11]])},{name:"quarter_q1_q4",minMatches:3,dict:f([[["q1","qtr 1","qtr1","quarter 1","q 1"],0],[["q2","qtr 2","qtr2","quarter 2","q 2"],1],[["q3","qtr 3","qtr3","quarter 3","q 3"],2],[["q4","qtr 4","qtr4","quarter 4","q 4"],3]])}],p={};function q(n){let e=n||"";if(!e)return{weekday:new Map,month:new Map};let a=p[e];if(a)return a;let t=new Map,r=new Map,i=(d,c,l)=>{let m=u(c);m&&d.set(m,l);let s=u(c.replace(/\./g,""));s&&s!==m&&d.set(s,l)};try{let d=new Intl.DateTimeFormat(e,{weekday:"long"}),c=new Intl.DateTimeFormat(e,{weekday:"short"});for(let s=0;s<7;++s){let g=new Date(Date.UTC(2024,0,1+s));i(t,d.format(g),s),i(t,c.format(g),s)}let l=new Intl.DateTimeFormat(e,{month:"long"}),m=new Intl.DateTimeFormat(e,{month:"short"});for(let s=0;s<12;++s){let g=new Date(Date.UTC(2020,s,15));i(r,l.format(g),s),i(r,m.format(g),s)}}catch{}let o={weekday:t,month:r};return p[e]=o,o}function M(n,e){if(e.size===0)return n;let a=new Map(n);for(let[t,r]of e)a.has(t)||a.set(t,r);return a}function S(n,e){let a=q(e);for(let t of b){let r=t.name==="weekday_mon_sun"?M(t.dict,a.weekday):t.name==="month_jan_dec"?M(t.dict,a.month):t.dict,i=!0,o=new Map;for(let[c,l]of n){let m=r.get(c);if(m===void 0){i=!1;break}o.has(m)||o.set(m,l)}if(!i||o.size<t.minMatches)continue;let d=[...o.entries()].sort((c,l)=>c[0]-l[0]).map(c=>c[1]);return{pattern:t.name,orderedDomain:d}}return null}function D(n){let e=new Map;for(let a of n){if(a==null)continue;let t=String(a);if(t.length===0)continue;let r=u(t);e.has(r)||e.set(r,t)}return e}var N=15,C=10,O=(()=>{let n=["xxs","xs","s","sm","small","m","med","medium","l","lg","large","xl","xlarge","xxl","xxxl","2xl","3xl","4xl","y","n","yes","no","t","f","true","false","na","n/a","n a","none","null","unknown","other","all","both","low","medium","med","high","very low","very high","minimal","critical","urgent"],e=new Set(n.map(u));for(let a of b)for(let t of a.dict.keys())e.add(t);return e})();function T(n){let e=n.trim();return e.length===0||e.length>C||(e.match(/\p{L}/gu)||[]).length>1?!1:/\p{Nd}/u.test(e)}function A(n){let e=n.trim();return e.length===1&&/[\p{L}\p{Nd}]/u.test(e)}function E(n){if(!n||n.length===0)return null;let e=new Set,a=[];for(let t of n){if(t==null)continue;let r=String(t);if(e.has(r))continue;let i=u(r);if(!(i===""||O.has(i)||T(r)||A(r))||(e.add(r),a.push(r),a.length>N))return null}return a.length>0?a:null}function F(n,e){if(!n||n.length<2)return null;let a=D(n);if(a.size<2)return null;let t=new Map;for(let[i,o]of a){let d=y(i);t.has(d)||t.set(d,o)}let r=null;for(let i of w){let o=[];for(let m of i.canonical){let s=t.get(m);s!==void 0&&o.push(s)}if(o.length<i.minMatches)continue;let d=new Set(i.canonical),c=!0;for(let m of a.keys())if(!d.has(y(m))){c=!1;break}if(!c)continue;let l;r===null||o.length>r.matched||o.length===r.matched&&i.canonical.length<r.pattern.canonical.length?l=!0:l=!1,l&&(r={pattern:i,matched:o.length,orderedDomain:o})}return r?{pattern:r.pattern.name,orderedDomain:r.orderedDomain}:S(a,e)}export{j as a,E as b,F as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a as 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-
|
|
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-6NQENOVB.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};
|
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-RC567DAC.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-6NQENOVB.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
|
|
2
|
+
import{a as te,b as ee}from"./chunk-UQU75XXR.mjs";import{a as Jt,b as Qt}from"./chunk-KSG5NPJB.mjs";import{a as Tt,b as Rt,c as It,d as bt,e as kt,f as Lt,g as Nt,h as wt,i as Ot,j as Et,k as zt,l as Gt,m as $t,n as Dt,o as Ft,p as Bt,q as Kt,r as Ht,s as Vt,t as Wt,u as qt,v as Zt,w as Ut,x as Xt,y as jt,z as Yt}from"./chunk-6W2GOB6U.mjs";import{a as vt}from"./chunk-QEH7WTLB.mjs";import{a as Mt,b as _t}from"./chunk-2LR73DNS.mjs";import{a as V,b as W,c as Ct,d as At,e as xt,f as St}from"./chunk-RC567DAC.mjs";import{a as T,f as R,g as y,h as I,i as w,j as ct,k as ut,l as H,m,n as ft,o as pt,p as mt,q as b,r as gt,s as dt,t as yt,u as ht,v as O,w as Pt}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as st,b as at,c as lt}from"./chunk-NOC2K3R2.mjs";import{a as J,b as Q,c as tt,d as et,e as nt,f as ot,g as it,h as rt}from"./chunk-6NQENOVB.mjs";var E=2,U=400;function G(r){return!!R(r)}function C(r){let n=new Set;for(let e of r){if(e==null)continue;let s=T(String(e));if(!I(s)&&!n.has(s)&&(n.add(s),n.size>=U))break}return Array.from(n)}function P(r){let n=C(r);if(n.length===0||$(r)<95)return!1;let e=n.filter(c=>G(c)&&!m(c)).length,s=n.filter(c=>!G(c)&&!!m(c)).length;return e>=1&&e>=s}function q(r,n){if(!m(r))return!1;let e=R(r);return e?n==="world"?!0:H.has(e):!1}function $(r){let n=C(r);if(n.length===0)return 0;let e=0;for(let s of n)G(s)&&e++;return Math.round(e/n.length*1e3)/10}function v(r){let n=C(r);if(n.length===0)return 0;let e=0;for(let s of n)m(s)&&e++;return Math.round(e/n.length*1e3)/10}function F(r){let n=new Set;for(let e of r){if(e==null)continue;let s=String(e).trim();if(!I(T(s))&&!n.has(s)&&(n.add(s),n.size>=U))break}return Array.from(n)}function D(r){let n=F(r);if(n.length===0)return 0;let e=0;for(let s of n)b(s).length>0&&e++;return Math.round(e/n.length*1e3)/10}function Z(r,n){return W(n,V)?!0:F(r).some(e=>/^\d{5}(-\d{4})?$/.test(e.replace(/\.0+$/,"")))}function ne(r,n){let e=C(r);if(e.length===0)return 0;let s=0;for(let c of e)O(c,n)&&s++;return Math.round(s/e.length*1e3)/10}function z(r,n){let e=0;for(let s of C(r))n(s)&&e++;return e}function oe(r,n){let e=0;for(let s of F(r))n(s)&&e++;return e}function ie(r,n,e,s,c){let A=[],u=[],o={},M={},_=new Set(r),l=t=>n.map(i=>i[t]);for(let t of["city","country"]){let i=e?.[t];i&&_.has(i)&&(o[t]=i)}let X=new Set(c??r);for(let t of["lat","lon"]){let i=e?.[t];i&&X.has(i)&&(o[t]=i)}let g=e?.zip;if(g&&_.has(g)){let t=l(g),i=D(t);i<95?u.push(`zip=${g} (only ${i}% of values read as ZIPs)`):Z(t,g)?o.zip=g:u.push(`zip=${g} (all values are 3-4 digits with nothing to say they are postal)`)}let p=e?.state;if(p&&_.has(p)){let t=l(p),i=C(t);i.length>0&&i.every(a=>q(a,s))?u.push(`state=${p} (every value is "CA", which is both Canada and California)`):P(t)?(u.push(`state=${p} (every value is a country, not a state)`),o.country||(o.country=p)):v(t)<95?u.push(`state=${p} (only ${v(t)}% of values are states/provinces)`):o.state=p}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(P(a))continue;let f=v(a);if(f<95)continue;let N=z(a,S=>!!m(S)),Y=z(a,S=>!!m(S)&&!q(S,s));N<E&&Y<1||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.state=t.name,d.add(t.name),A.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)&&!(oe(i,f=>b(f).length>0)<E)){o.zip=t,d.add(t),A.push(`zip=${t} (${a}% ZIP codes)`);break}}let h=o.country;if(!h||!P(l(h))){let t=null;for(let i of x){if(d.has(i)||!P(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)`),M.country=h),o.country=t.name,d.add(t.name),A.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=ne(a,s);f<w||z(a,N=>O(N,s))<E||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.city=t.name,A.push(`city=${t.name} (${t.pct}% known cities)`))}let B=o.country?l(o.country):[],k=!!o.country&&P(B),j=k?new Set(B.map(t=>R(t==null?null:String(t))).filter(Boolean)).size:0,K=k&&j>=2,L=!!(o.lat&&o.lon)&&n.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(k?`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:A,refused:u,...Object.keys(M).length?{labelFallback:M}:{}}}export{w as CITY_ROLE_MATCH_PCT,et as GET_RANDOM,Lt as INTENSIVE_SUFFIX_TOKENS,kt as INTENSIVE_WORD_TOKENS,Yt as IndexedText,wt as POSITIONAL_SUFFIX_TOKENS,Nt as POSITIONAL_WORD_TOKENS,te as PREVIEW_OMITTED_FIELDS,y as ROLE_MATCH_PCT,tt as SIMPLE_STRING_HASH,Q as STR,v as admin1MatchPct,Bt as allowedAggregations,St as buildGeoIsoColumn,yt as buildGeoPointColumns,Pt as cityMatchPct,ht as cityTagsFor,Xt as classifyAdditivity,Ft as classifyForAggregation,jt as classifyNumericValueNature,Zt as classifyTemporal,Gt as codeNeedsLegacyAggNames,zt as collapseRepeatedAggPrefix,It as countryRegion,Kt as defaultAggregation,vt as detectFormatSignature,Ct as detectGeo,lt as detectOrdinalDomain,qt as detectTextDatePattern,Jt as engineTypeForSqlType,Et as hasDefaultAggPrefix,Ut as hostAggHint,Qt as ingest,Ht as isAggregationAllowed,I as isBlankLike,ut as isCityTableLoaded,nt as isDeterministicRefusal,gt as isGeoPointAmbiguity,Wt as isIdentifierName,xt as isJoinGeoKind,st as isOrdinalFriendlyName,P as looksLikeCountryColumn,_t as monthLookupFor,Dt as nameLooksIntensiveRate,$t as nameLooksPositional,J as nameWords,ft as normalizeCountry,Mt as normalizeMonthKey,T as normalizePlaceName,mt as normalizeZip5,ot as parseDateStable,ee as payloadPreview,ct as registerCityTable,Rt as registerIso3Regions,m as resolveAdmin1,dt as resolveGeoPoint,ie as resolvePointRoles,at as safeDistinctValuesToShip,Vt as shareOfTotalIsHonest,Ot as stripHostAggPrefix,bt as summarizeCountryRegions,Tt as summarizeGeoExtent,At as toGeoIso,it as wholeDayFrame,rt as wholeDayIso,D as zipMatchPct,b as zipPrefixCandidates,pt 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-6W2GOB6U.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-RC567DAC.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-NOC2K3R2.mjs";import"./chunk-6NQENOVB.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-KSG5NPJB.mjs";import"./chunk-6W2GOB6U.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-RC567DAC.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-NOC2K3R2.mjs";import"./chunk-6NQENOVB.mjs";export{a as engineTypeForSqlType,b as ingest};
|
package/dist/ordinalDetector.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{a,b,c}from"./chunk-
|
|
2
|
+
import{a,b,c}from"./chunk-NOC2K3R2.mjs";import"./chunk-6NQENOVB.mjs";export{c as detectOrdinalDomain,a as isOrdinalFriendlyName,b as safeDistinctValuesToShip};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHi
|
|
|
9
9
|
export { ROLE_MATCH_PCT, CITY_ROLE_MATCH_PCT, isBlankLike } from "./matchQuality";
|
|
10
10
|
export { detectOrdinalDomain, safeDistinctValuesToShip, isOrdinalFriendlyName } from "./ordinalDetector";
|
|
11
11
|
export { detectFormatSignature } from "./formatDetector";
|
|
12
|
-
export { parseDateStable } from "./util";
|
|
12
|
+
export { parseDateStable, wholeDayFrame, wholeDayIso } from "./util";
|
|
13
13
|
export { detectGeo, toGeoIso, buildGeoIsoColumn, isJoinGeoKind } from "./geoDetector";
|
|
14
14
|
export type { GeoKind, GeoDetectionResult, GeoIsoColumn } from "./geoDetector";
|
|
15
15
|
export { summarizeGeoExtent, summarizeCountryRegions, countryRegion, registerIso3Regions } from "./geoExtent";
|
|
@@ -104,24 +104,12 @@ export declare class IndexedText implements IValueCollection {
|
|
|
104
104
|
* The calendar day a WHOLE-DAY Date stands for, as "YYYY-MM-DD" - or null when the Date
|
|
105
105
|
* carries a real time of day.
|
|
106
106
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* Continuous - a picker input - and the day printed one earlier than the cell showed.
|
|
114
|
-
*
|
|
115
|
-
* WHY BOTH FRAMES. A Date is whole-day if it is midnight in EITHER UTC or local time,
|
|
116
|
-
* because both kinds exist in the wild: the sources above build UTC midnight, while a
|
|
117
|
-
* Date parsed from a timezone-less ISO datetime (Power BI's host hands those over) is
|
|
118
|
-
* LOCAL midnight. Reading only UTC would have fixed Excel by breaking the visual. The day
|
|
119
|
-
* is then taken from the frame the Date is midnight in, which is the day the author meant.
|
|
120
|
-
*
|
|
121
|
-
* THE RESIDUAL EDGE, stated rather than hidden: a genuine timestamp that happens to fall
|
|
122
|
-
* exactly on the local-vs-UTC offset (17:00 PDT is 00:00Z) reads as a whole day. The
|
|
123
|
-
* column-level flag is an OR over every value, so a column is only misread if EVERY value
|
|
124
|
-
* sits on that exact minute - a dataset that is, for every practical purpose, a date column.
|
|
107
|
+
* THE RULE ITSELF NOW LIVES IN `util.wholeDayIso`, and this is a thin delegate rather than a
|
|
108
|
+
* second copy (2026-09-09). It moved because chart-host's selection card has to answer the
|
|
109
|
+
* same question - which clock does this Date print on - to render a date the way its source
|
|
110
|
+
* renders it, and a rule this subtle kept in two places disagrees the first time either is
|
|
111
|
+
* touched. The delegate stays so this class's own call sites, and the reasoning attached to
|
|
112
|
+
* them, do not have to change.
|
|
125
113
|
*/
|
|
126
114
|
private wholeDayIso;
|
|
127
115
|
private hasTimeComponent;
|
package/dist/types/util.d.ts
CHANGED
|
@@ -62,3 +62,35 @@ export declare function isDeterministicRefusal(r: {
|
|
|
62
62
|
* is the very bug this file is closing.
|
|
63
63
|
*/
|
|
64
64
|
export declare function parseDateStable(s: string): Date | null;
|
|
65
|
+
/**
|
|
66
|
+
* WHICH CLOCK IS THIS DATE MIDNIGHT ON - "utc", "local", or null when it carries a time of day.
|
|
67
|
+
*
|
|
68
|
+
* THIS IS THE ONE PLACE A DATE IS ALLOWED TO BECOME A DAY, and it exists because the code that
|
|
69
|
+
* came before asked `getHours()` - LOCAL time - of Dates that had been built in UTC. The Excel
|
|
70
|
+
* add-in converts a serial with `Date.UTC(1899,11,30)+days`; an ISO text date parses to UTC
|
|
71
|
+
* midnight; the visual's date-unshredder builds `Date.UTC(y,m,d)`. On any machine west of
|
|
72
|
+
* Greenwich every one of those read as 16:00 or 17:00 the PREVIOUS day, so `dateWithTime` was
|
|
73
|
+
* true for every date column, `valueNature` flipped from Ordinal to Continuous - a picker input -
|
|
74
|
+
* and the day printed one earlier than the cell showed.
|
|
75
|
+
*
|
|
76
|
+
* WHY BOTH FRAMES. A Date is whole-day if it is midnight in EITHER UTC or local time, because
|
|
77
|
+
* both kinds exist in the wild: the sources above build UTC midnight, while a Date parsed from a
|
|
78
|
+
* timezone-less ISO datetime (Power BI's host hands those over) is LOCAL midnight. Reading only
|
|
79
|
+
* UTC would have fixed Excel by breaking the visual. The day is then taken from the frame the
|
|
80
|
+
* Date is midnight in, which is the day the author meant.
|
|
81
|
+
*
|
|
82
|
+
* THE RESIDUAL EDGE, stated rather than hidden: a genuine timestamp that happens to fall exactly
|
|
83
|
+
* on the local-vs-UTC offset (17:00 PDT is 00:00Z) reads as a whole day. Every column-level flag
|
|
84
|
+
* built on this is an OR over every value, so a column is only misread if EVERY value sits on
|
|
85
|
+
* that exact minute - a dataset that is, for every practical purpose, a date column.
|
|
86
|
+
*
|
|
87
|
+
* EXPORTED because two packages need the same answer and must not each keep their own. The
|
|
88
|
+
* profiler asks it to decide what a column IS; chart-host's selection card asks it to decide
|
|
89
|
+
* which clock to PRINT. Two copies of a rule this subtle disagree the first time either is
|
|
90
|
+
* touched, and the disagreement surfaces as a day-off date in one host only.
|
|
91
|
+
*/
|
|
92
|
+
export declare function wholeDayFrame(date: any): "utc" | "local" | null;
|
|
93
|
+
/** The calendar day a WHOLE-DAY Date stands for, as "YYYY-MM-DD" - or null when it carries a
|
|
94
|
+
* real time of day. The day is read from the frame `wholeDayFrame` names, which is the whole
|
|
95
|
+
* point: the same Date has to print the same day on every machine. */
|
|
96
|
+
export declare function wholeDayIso(date: any): string | null;
|
package/dist/util.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,g,h}from"./chunk-6NQENOVB.mjs";export{d as GET_RANDOM,c as SIMPLE_STRING_HASH,b as STR,e as isDeterministicRefusal,a as nameWords,f as parseDateStable,g as wholeDayFrame,h as wholeDayIso};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.87",
|
|
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-GLLNTEEM.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
|
-
function s(t){return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(n=>n.length>0):[]}function l(t){return t!=null?t.toString():""}function a(t){if(!t)return 0;let n=0xcbf29ce484222325n,e=0x100000001b3n,F=n;for(let r=0;r<t.length;r++)F^=BigInt(t.charCodeAt(r)),F=F*e&0xFFFFFFFFFFFFFFFFn;return Number(F&0x1FFFFFFFFFFFFFn)}function c(){let t=typeof globalThis<"u"?globalThis:{};if(t.crypto&&typeof t.crypto.getRandomValues=="function"){let n=new Uint32Array(1);return t.crypto.getRandomValues(n),n[0]/4294967296}return Math.floor(Date.now()%4294967295)/4294967296}function f(t){return!!t&&t.isRefusal===!0}function g(t){let n=Date.parse(t);if(isNaN(n))return null;let e=new Date(n);if(o.test(t)||i.test(t.trim())||u.test(t))return e;let F=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())),r=e.getFullYear();return r>=0&&r<100&&F.setUTCFullYear(r),F}var o=/^\s*\d{4}(-\d{2}(-\d{2})?)?\s*$/,i=/(?:Z|[+-]\d{2}:?\d{2})$/i,u=/\b(?:GMT|UTC)\b/i;export{s as a,l as b,a as c,c as d,f as e,g as f};
|
package/dist/chunk-RBHJL2XA.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 dt}from"./chunk-QEH7WTLB.mjs";import{a as gt,b as ht}from"./chunk-2LR73DNS.mjs";import{c as ft}from"./chunk-KNCUJNVB.mjs";import{b as ct,f as mt}from"./chunk-E6SVTFAW.mjs";import{a as at,b as ut,c as lt}from"./chunk-ZCCCL7P2.mjs";import{a as X,b as rt,c as ot,d as Z,f as tt}from"./chunk-GLLNTEEM.mjs";var Et=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Ot=[7,72,-172,-52];function pt(n,t,e){return n>=e[0]&&n<=e[1]&&t>=e[2]&&t<=e[3]}function J(n,t){if(!n.length)return NaN;if(n.length===1)return n[0];let e=(n.length-1)*t,r=Math.floor(e),o=Math.ceil(e);return r===o?n[r]:n[r]+(n[o]-n[r])*(e-r)}var Y=n=>Math.round(n*10)/10;function yt(n,t=3){let e=[],r=[],o=0,s=0;for(let l of n){let c=l?.lat,f=l?.lon;if(typeof c!="number"||typeof f!="number"||!isFinite(c)||!isFinite(f)||c<-90||c>90||f<-180||f>180)continue;e.push(c),r.push(f);let M=l?.country?String(l.country).trim().toUpperCase():"",d=M?Q(M):null;d?((M==="US"||M==="USA")&&o++,d==="north-america"&&s++):(Et.some(O=>pt(c,f,O))&&o++,pt(c,f,Ot)&&s++)}let a=e.length;return a<t?null:(e.sort((l,c)=>l-c),r.sort((l,c)=>l-c),{pctUsa:Y(o/a*100),pctNa:Y(s/a*100),latP5:Y(J(e,.05)),latP95:Y(J(e,.95)),lonP5:Y(J(r,.05)),lonP95:Y(J(r,.95)),n:a})}var bt={"north-america":"AG AI AW BB BL BM BQ BS BZ CA CR CU CW DM DO GD GL GP GT HN HT JM KN KY LC MF MQ MS MX NI PA PM PR SV SX TC TT US VC VG VI","south-america":"AR BO BR CL CO EC FK GF GY PE PY SR UY VE",europe:"AD AL AT AX BA BE BG BY CH CY CZ DE DK EE ES FI FO FR GB GG GI GR HR HU IE IM IS IT JE LI LT LU LV MC MD ME MK MT NL NO PL PT RO RS RU SE SI SJ SK SM UA VA",africa:"AO BF BI BJ BW CD CF CG CI CM CV DJ DZ EG EH ER ET GA GH GM GN GQ GW KE KM LR LS LY MA MG ML MR MU MW MZ NA NE NG RE RW SC SD SH SL SN SO SS ST SZ TD TG TN TZ UG YT ZA ZM ZW",asia:"AE AF AM AZ BD BH BN BT CC CN CX GE HK ID IL IN IO IQ IR JO JP KG KH KP KR KW KZ LA LB LK MM MN MO MV MY NP OM PH PK PS QA SA SG SY TH TJ TL TM TR TW UZ VN YE",oceania:"AS AU CK FJ FM GU KI MH MP NC NF NR NU NZ PF PG PN PW SB TK TO TV UM VU WF WS",antarctica:"AQ BV GS HM TF"},j=(()=>{let n=new Map;for(let t of Object.keys(bt))for(let e of bt[t].split(/\s+/))e&&n.set(e,t);return n})();function Lt(n){for(let[t,e]of n){let r=j.get(t);r&&!j.has(e)&&j.set(e,r)}}Lt(ct);function Q(n){if(!n)return null;let t=String(n).trim().toUpperCase();if(!t)return null;let e=j.get(t);if(e)return e;let r=mt(String(n));return r?j.get(r)??null:null}function be(n,t=2){return et(n.map(e=>[e,1]),t)}function et(n,t=2){let e=new Map,r=0;for(let[a,l]of n){let c=Q(a);if(!c)continue;let f=typeof l=="number"&&isFinite(l)&&l>0?l:1;e.set(c,(e.get(c)??0)+f),r+=f}if(r<t||!e.size)return null;let o="europe",s=-1;for(let a of Array.from(e.keys()).sort()){let l=e.get(a);l>s&&(o=a,s=l)}return{dominantGeoRegion:o,dominantGeoRegionPct:Y(s/r*100),regionCount:e.size,n:r}}import It from"papaparse";var Pt=["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"],Gt=["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"],Wt=["latitude","longitude"],Ft=["latitude","longitude"],St=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,Vt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,kt=new RegExp("\\b("+Pt.join("|")+")\\b|("+Gt.join("|")+")$","i"),Ut=new RegExp("\\b("+Wt.join("|")+")\\b|("+Ft.join("|")+")$","i");function Ct(n){return n?String(n).replace(St,"").trim():""}function Bt(n){return!!n&&St.test(String(n))}var zt=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],_t=new RegExp("^\\s*("+[...zt].sort((n,t)=>t.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Mt(n){if(n==null)return"";let t=String(n),e=_t.exec(t);if(!e)return t;let r=l=>l.toLowerCase().replace(/\s+/g," ").trim(),o=r(e[1]),s=t.slice(e[0].length),a=0;for(;a<8;){let l=_t.exec(s);if(!l||r(l[1])!==o)break;let c=s.slice(l[0].length);if(c.trim()==="")break;s=c,a++}return a===0?t:t.slice(0,e[0].length)+s}function Se(n,t){if(!n||!t)return!1;let e=String(n);for(let r of t){let o=r?.hostName;if(o&&o!==r?.name&&e.includes(o))return!0}return!1}function Ht(n){let t=Ct(n);return t.length===0?"":t.replace(Vt," ")}function At(n,t){if(!t)return!1;let e=Ct(t);return n.test(Ht(t))||n.test(e)||n.test(X(e).join(" "))}function Tt(n){return At(Ut,n)}function Kt(n){return At(kt,n)||Tt(n)}var Nt=/int|double|decimal|single|float|number|currency|money/i;function Yt(n){let t=String(n?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||n?.isMeasure===!0||Nt.test(String(n?.dataType??""))?"Continuous":"Categorical"}function Zt(n){return n?.isMeasure===!0||Nt.test(String(n?.dataType??""))}function Rt(n){let t=n??{},e=Yt(t);if(e!=="Continuous")return{nature:e,additivity:"unknown",basis:"role",suppressed:!1};if(Tt(t.name))return{nature:e,additivity:"positional",basis:"name",suppressed:!0};let r=String(t.additivity??"").trim().toLowerCase();if(!(r==="additive"&&Bt(t.name))){if(r==="additive")return{nature:e,additivity:"additive",basis:"measured",suppressed:!1};if(r==="part_of_whole")return{nature:e,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(r==="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}:Kt(t.name)?{nature:e,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:e,additivity:"additive",basis:"default",suppressed:!1}}function vt(n){let t=Rt(n),e=n??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Zt(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 Ce(n){return vt(n)[0]}function Me(n,t){return vt(n).indexOf(t)>=0}function Ae(n,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let e=Rt(n);return e.additivity==="additive"||e.additivity==="part_of_whole"||e.additivity==="unknown"}var $t=12,Xt=100,jt=.3,qt=.9,Jt=120,Qt=1900,te=2100,ee=0,ne=20,ie=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function se(n){if(!n)return!1;let t=X(n);return t.length===0?!1:ie.has(t[t.length-1])}var re=new Set(["year","yr","fy"]),oe=n=>X(n).some(t=>re.has(t)),ae=/^(?:(?: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 nt(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let t=n%100;return t>=1&&t<=12}function it(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 ue=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,le=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,ce=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function me(n){let t=(n||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function Dt(n,t){let e=0,r=0,o=0,s=0,a=0,l="",c=0,f="",M=0,d=0,O=0,g=0,I=!1;for(let K of n){if(K==null)continue;let U=String(K).trim();if(U==="")continue;e++;let G;if(G=ue.exec(U)){let V=+G[2],i=+G[3];V>=1&&V<=12&&i>=1&&i<=31&&(r++,G[4]!==void 0&&o++,G[6]!==void 0&&s++)}else if(G=le.exec(U)){let V=+G[3],i=+G[4];V>=1&&V<=12&&i>=1&&i<=31&&(l&&l!==G[2]&&(I=!0),l=G[2],a++)}else if(G=ce.exec(U)){let V=+G[1],i=+G[3];V>=1&&V<=31&&i>=1&&i<=31&&(V<=12||i<=12)&&(f&&f!==G[2]&&(I=!0),f=G[2],c++,V>12&&O++,i>12&&g++,G[5]!==void 0&&M++,G[7]!==void 0&&d++)}if(e>=200)break}if(e<2||(r+a+c)/e<.8||(r>0?1:0)+(a>0?1:0)+(c>0?1:0)!==1||I)return null;if(r>0)return o===r?{pattern:s===r?"%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(O>0&&g>0)return null;let A,N;O>0?(A=!0,N="values"):g>0?(A=!1,N="values"):(A=!me(t),N="locale");let F=A?`%d${f}%m${f}%Y`:`%m${f}%d${f}%Y`;return M===c?{pattern:F+(d===c?" %H:%M:%S":" %H:%M"),orderFrom:N}:{pattern:F,orderFrom:N}}function fe(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 r=gt(e);return r.length>0&&t[r]!==void 0}function de(n){let{dataType:t,name:e,isMeasure:r,distinctCount:o}=n;if(t==="DateTime")return!0;if(r)return!1;if(t==="Integer"||t==="Decimal"){let s=n.minNum,a=n.maxNum;if(!(s!=null&&a!=null&&Number.isFinite(s)&&Number.isFinite(a)&&Number.isInteger(s)&&Number.isInteger(a)&&a>=s))return!1;let c=s>=1900&&a<=2100;if(c&&o>=2&&oe(e)||c&&o>=3&&o===a-s+1)return!0;let f=nt(s)&&nt(a),M=it(s)&&it(a);if(f||M){if(!n.sampleValues)return!0;let d=0,O=0;for(let g of n.sampleValues){if(g==null||g==="")continue;d++;let I=Number(String(g).trim());if(Number.isFinite(I)&&(f?nt(I):it(I))&&O++,d>=60)break}if(d>=2&&O===d)return!0}return!1}if(n.sampleValues){let s=n.locale?ht(n.locale):null,a=0,l=0,c=[];for(let f of n.sampleValues){if(f==null||f==="")continue;a++;let M=String(f).trim();if(c.push(M),(ae.test(M)||fe(M,s))&&l++,a>=60)break}if(a>=2&&l/a>=.8||Dt(c,n.locale)!==null)return!0}return!1}function ge(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 he(n){let{rows:t,measureColIdx:e,measureName:r,candidateDims:o,minNum:s,maxNum:a,discourageAgg:l}=n,c=100,f=.01,M="";for(let O of o){if(O.distinct<2||O.distinct>c)continue;let g=o.filter(N=>N.idx!==O.idx).map(N=>N.idx),I=new Map;for(let N of t){let F=N[e];if(typeof F!="number"||!Number.isFinite(F))continue;let K=g.length?g.map(G=>String(N[G])).join(M):"",U=I.get(K);U||(U={sum:0,cset:new Set},I.set(K,U)),U.sum+=F,U.cset.add(String(N[O.idx]))}let x=0,T=0,A=0;for(let N of I.values())N.cset.size<2||(A++,Math.abs(N.sum-100)<=100*f?x++:Math.abs(N.sum-1)<=1*f&&T++);if(A>=2&&(x/A>=.9||T/A>=.9))return{additivity:"part_of_whole",partOfWholeDim:O.name}}if(l)return{additivity:"intensive_rate"};let d=ge(r);return d==="avg"||d==="min"||d==="max"?{additivity:"intensive_rate"}:d==="count"?{additivity:"additive"}:d==="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 xt(n){let{dataType:t,isMeasure:e,name:r,distinct:o,nonblank:s,prec:a,maxval:l,minval:c}=n,f=l-c+1,M=f>0?o/f:1,d=s>0?o/s:0,O=t==="Decimal"||a>0;return se(r)?"Categorical":M>=qt&&(at(r)&&o<=Jt||c>=Qt&&l<=te||c>=ee&&l<=ne)?"Ordinal":e||o>$t&&(O||o>=Xt||d>=jt)?"Continuous":"Categorical"}var wt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(t){return t==null?"":t instanceof Date?this.wholeDayIso(t)??(isNaN(t.getTime())?"":t.toISOString()):t.toString()}getPrecision(t){if(!isFinite(t))return 0;let r=t.toString().split(".")[1];return r?r.length:0}getColumns(){return this._cols}wholeDayIso(t){if(!(t instanceof Date)||isNaN(t.getTime()))return null;let e=r=>(r<10?"0":"")+r;return t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0&&t.getUTCMilliseconds()===0?t.toISOString().slice(0,10):t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0&&t.getMilliseconds()===0?`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`:null}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:this.wholeDayIso(t)===null}getColumnsWithStats(t,e){if(this._computedStatsForLevel==t)return this._cols;let r=0,o=parseInt(t),s=[];for(let i of this._cols){let m=new Map,D=[],p=0,u=0,y=0,S=null,b=null,h=null,E=!1,R=!0,w=!0,P=null,W=!1;for(let v of this._rows){let C=v[r],_=this.STR(C);if(_!=""){if(p+=_.length,m.set(_,(m.get(_)||0)+1),u++,i.dataType=="Integer"||i.dataType=="Decimal"||i.dataType=="DateTime")if((S===null||C<S)&&(S=C),(b===null||C>b)&&(b=C),i.dataType=="Integer"||i.dataType=="Decimal"){if(h===null?h=C:h+=C,i.dataType=="Decimal"){let L=this.getPrecision(C);L>y&&(y=L)}D.push(C)}else E=E||this.hasTimeComponent(C);W&&(C<P?R=!1:C>P&&(w=!1)),P=C,W=!0}}if(u>=3&&(R&&!w?i.sortedDirection="asc":w&&!R?i.sortedDirection="desc":i.sortedDirection="none"),u>0&&m.size>0&&!i.isMeasure){let v=0,C=Number.MAX_SAFE_INTEGER;for(let _ of m.values())_>v&&(v=_),_<C&&(C=_);if(i.modalShare=v/u,i.minGroupCount=C===Number.MAX_SAFE_INTEGER?null:C,m.size===2){let _=[...m.keys()].map(k=>rt(k).trim().toLowerCase()).sort(),z=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(k=>_[0]===k[0]&&_[1]===k[1]),B=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(i.name);(z||B)&&(i.isBinaryFlag=!0)}}if(i.dataType=="DateTime"&&(i.dateWithTime=E),i.isTemporal=de({dataType:i.dataType,name:i.name,isMeasure:i.isMeasure,distinctCount:m.size,minNum:typeof S=="number"?S:null,maxNum:typeof b=="number"?b:null,sampleValues:m.keys(),locale:e}),i.isTemporal&&i.dataType==="String"&&!i.isMeasure){let v=Dt(m.keys(),e);v&&(i.temporalTextPattern=v.pattern)}this.updateColumnStats10(o,i,u,m,y,b,S),this.updateColumnStats20(o,D,u,h,i,p,E,S,b,y,m,e),!i.isMeasure&&(i.dataType==="Integer"||i.dataType==="Decimal")&&xt({dataType:i.dataType,isMeasure:!1,name:i.name,distinct:m.size,nonblank:u,prec:y,maxval:typeof b=="number"?b: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),s[r]=i.isMeasure||m.size>2e3?null:new Set(m.keys()),r++}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 D=typeof i.lowValue=="number"?i.lowValue:null,p=typeof i.highValue=="number"?i.highValue:null,u=he({rows:this._rows,measureColIdx:m,measureName:i.name,candidateDims:a,minNum:D,maxNum:p,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 D=[];for(let _ of this._rows){let L=_[m];if(L==null||L==="")continue;let z=typeof L=="number"?L:parseFloat(L);isNaN(z)||D.push(z)}if(D.length===0)return;let p=[...D].sort((_,L)=>_-L),u=_=>p[Math.min(p.length-1,Math.max(0,Math.floor(_*(p.length-1))))],y=u(.5),S=u(.1),b=u(.9),h=Math.abs(y)>1e-9?Math.abs(y):Math.abs(p[p.length-1])>1e-9?Math.abs(p[p.length-1]):1;i.relativeDispersion=Math.round((b-S)/h*1e3)/1e3;let E=[];for(let _ of c){let L=new Set;for(let z of this._rows){let B=z[m];B==null||B===""||L.add(this.STR(z[_.idx])+"")}E.push({otherColumn:_.name,nonBlankGroupCount:L.size})}E.length>0&&(i.nonBlankGroups=E);let R=0;for(let _ of D)R+=_;R/=D.length;let w=0;for(let _ of D)w+=(_-R)*(_-R);if(w<=1e-12)return;let P=[],W=[],v=_=>{if(_.length<4)return NaN;let L=[..._].sort((B,k)=>B-k),z=B=>L[Math.min(L.length-1,Math.max(0,Math.floor(B*(L.length-1))))];return z(.75)-z(.25)},C=v(D);for(let _ of c){let L=new Map;for(let k of this._rows){let H=k[m];if(H==null||H==="")continue;let $=typeof H=="number"?H:parseFloat(H);if(isNaN($))continue;let st=this.STR(k[_.idx])+"",q=L.get(st);q?(q.s+=$,q.n++,q.vals.push($)):L.set(st,{s:$,n:1,vals:[$]})}let z=0;for(let k of L.values()){let H=k.s/k.n;z+=k.n*(H-R)*(H-R)}P.push({otherColumn:_.name,eta2:Math.round(z/w*1e4)/1e4});let B=[];for(let k of L.values()){let H=v(k.vals);isNaN(H)||B.push(H)}if(B.length>=2&&isFinite(C)&&C>1e-9){let k=(Math.max(...B)-Math.min(...B))/C;W.push({otherColumn:_.name,spreadRatio:Math.round(k*1e4)/1e4})}}P.length>0&&(i.groupDiscrimination=P),W.length>0&&(i.spreadDiscrimination=W)});let f=.97,M=5,d=this._cols.map((i,m)=>({c:i,i:m})).filter(i=>i.c.isMeasure);for(let i=0;i<d.length;i++)for(let m=i+1;m<d.length;m++){let D=d[i].i,p=d[m].i,u=0,y=0,S=0,b=0,h=0,E=0;for(let W of this._rows){let v=W[D],C=W[p];if(v==null||v===""||C===null||C===void 0||C==="")continue;let _=typeof v=="number"?v:parseFloat(v),L=typeof C=="number"?C:parseFloat(C);isNaN(_)||isNaN(L)||(u++,y+=_,S+=L,b+=_*_,h+=L*L,E+=_*L)}if(u<M)continue;let R=u*b-y*y,w=u*h-S*S;if(R<=1e-12||w<=1e-12)continue;let P=(u*E-y*S)/Math.sqrt(R*w);if(Math.abs(P)>=f){let W=d[i].c,v=d[m].c;W.collinearWithMeasures||(W.collinearWithMeasures=[]),v.collinearWithMeasures||(v.collinearWithMeasures=[]),W.collinearWithMeasures.push(v.name),v.collinearWithMeasures.push(W.name)}}for(let i=0;i<this._cols.length;i++){let m=s[i];if(!m||m.size===0)continue;let D=[];for(let p=0;p<this._cols.length;p++){if(p===i)continue;let u=s[p];if(!u||u.size===0)continue;let y=0;for(let b of m)u.has(b)&&y++;let S=Math.round(y/m.size*100);S>0&&D.push({otherColumn:this._cols[p].name,percentShared:S})}D.length>0&&(this._cols[i].sharedValueRatioWithOthers=D)}let O=50,g=[];for(let i=0;i<this._cols.length;i++){let m=s[i];m&&m.size>=2&&m.size<=O&&g.push(i)}if(g.length>=2){let i=new Map,m=(p,u)=>p+":"+u;for(let p=0;p<g.length;p++)for(let u=p+1;u<g.length;u++)i.set(m(g[p],g[u]),new Map);for(let p of this._rows)for(let u=0;u<g.length;u++){let y=this.STR(p[g[u]])+"";for(let S=u+1;S<g.length;S++){let b=""+this.STR(p[g[S]]),h=i.get(m(g[u],g[S])),E=y+""+b;h.set(E,(h.get(E)??0)+1)}}let D=new Map;for(let p=0;p<g.length;p++)for(let u=p+1;u<g.length;u++){let y=g[p],S=g[u],b=s[y].size,h=s[S].size,E=i.get(m(y,S)),R=E.size,w=0;for(let C of E.values())(w===0||C<w)&&(w=C);let P=Math.round(R/(b*h)*100),W=R===b,v=R===h;if((this._cols[y].categoricalPairStats||=[]).push({otherColumn:this._cols[S].name,fillPct:P,determinesOther:W,minCellCount:w,distinctCombinations:R}),(this._cols[S].categoricalPairStats||=[]).push({otherColumn:this._cols[y].name,fillPct:P,determinesOther:v,minCellCount:w,distinctCombinations:R}),W&&b>h){let C=D.get(y);(!C||h<C.card)&&D.set(y,{name:this._cols[S].name,card:h,ratio:h/b})}if(v&&h>b){let C=D.get(S);(!C||b<C.card)&&D.set(S,{name:this._cols[y].name,card:b,ratio:b/h})}}for(let[p,u]of D)this._cols[p].primaryParentColumn=u.name,this._cols[p].nestingRatio=Math.round(u.ratio*100)/100}let I=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 D=m.distinctCount??0;if(D<=O||x>0&&D>=x)continue;let p=[];for(let u=0;u<this._cols.length;u++){if(u===i)continue;let y=this._cols[u];if(y.isMeasure)continue;let S=y.distinctCount??0;S<2||S>=D||p.push(u)}p.sort((u,y)=>(this._cols[u].distinctCount??0)-(this._cols[y].distinctCount??0));for(let u of p.slice(0,I)){let y=new Map,S=!0;for(let h of this._rows){let E=this.STR(h[i])+"",R=this.STR(h[u])+"",w=y.get(E);if(w===void 0)y.set(E,R);else if(w!==R){S=!1;break}}if(!S)continue;let b=this._cols[u].distinctCount??0;m.primaryParentColumn=this._cols[u].name,m.nestingRatio=Math.round(b/D*100)/100;break}}let T=.01,A=.05,N=.95,F=8,K=8,U=6,G=500,V=[];for(let i=0;i<this._cols.length&&V.length<K;i++){let m=this._cols[i].dataType;(m==="Double"||m==="Integer"||m==="Decimal")&&V.push(i)}if(V.length>=3&&this._rows.length>=F){let i=Math.min(this._rows.length,G),m=V.map(b=>{let h=[];for(let w=0;w<i;w++){let P=this._rows[w][b],W=typeof P=="number"?P:parseFloat(String(P).replace(/,/g,""));if(P==null||P===""||!isFinite(W))return null;h.push(W)}let E=h[0],R=!1;for(let w of h)if(w!==E){R=!0;break}return R?h:null}),D=V.map((b,h)=>h).filter(b=>m[b]!==null),p=b=>{let h=b.slice().sort((R,w)=>R-w),E=h.length>>1;return h.length%2?h[E]:(h[E-1]+h[E])/2},u=null,y=[],S=b=>{if(y.length>=3){let h=y.map(P=>m[P]),E=h[0].length,R=new Array(E);for(let P=0;P<E;P++){let W=0;for(let v of h)W+=v[P];R[P]=W}let w=p(R);if(w>0){let P=0;for(let v of R)Math.abs(v-w)<=w*T&&P++;let W=P/E;if(W>=N){let v=1;for(let C of h){let _=p(C)/w;_<v&&(v=_)}v>=A&&(!u||y.length>u.cols.length)&&(u={cols:y.slice(),total:w,matched:W})}}}if(!(y.length>=U))for(let h=b;h<D.length;h++)y.push(D[h]),S(h+1),y.pop()};if(S(0),u){let b=u,E={columns:b.cols.map(R=>this._cols[V[R]].name),total:Math.round(b.total*1e3)/1e3,matchedPct:Math.round(b.matched*100)/100};for(let R of b.cols)this._cols[V[R]].constantSumGroup=E}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,e,r,o,s,a,l,c,f,M,d,O){if(t>=20){let g=[...e].sort((T,A)=>T-A),I=Math.floor(g.length/2);if(r>0&&o!=null?s.avgValue=s.dataType=="Integer"?Math.round(o/r):o/r:s.avgValue=null,r>0&&(s.avgLength=a/r),this._rows.length>0){let T=A=>{let N=A instanceof Date?A:typeof A=="string"?tt(A)??new Date(A):new Date(A),F=this.wholeDayIso(N);return F?F+"T00:00:00.000Z":isNaN(N.getTime())?A:N.toISOString().slice(0,10)+"T00:00:00.000Z"};s.dataType!="DateTime"||l||!c?s.lowValue=c:s.lowValue=T(c),s.dataType!="DateTime"||l||!f?s.highValue=f:s.highValue=T(f),s.medianValue=g.length===0?null:g.length%2===0?s.dataType=="Integer"?Math.round((g[I-1]+g[I])/2):(g[I-1]+g[I])/2:g[I],s.numericPrecision=M}if(g.length>0){let T=s.avgValue??0,A=g.length,N=0,F=0;for(let U of g){let G=U-T;N+=G*G,F+=G*G*G}let K=N/A;s.skewness=K===0?0:F/A/Math.pow(Math.sqrt(K),3),s.stdDev=Math.sqrt(K)}o!==null&&(s.sum=o);let x=Array.from(d.entries()).sort((T,A)=>A[1]-T[1]);if(s.topCategories=x.slice(0,10).map(T=>T[1]),!s.isMeasure&&x.length>0){if(s.dataType==="String"){let T=x.map(N=>N[0]);s.formatSignature=dt(T);let A=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!A.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=x.slice(0,5).map(T=>T[0]);if(t>=20){let T=x.map(N=>N[0]),A=lt(T,O);if(A!==null)s.ordinalPattern=A.pattern,s.orderedDomain=A.orderedDomain;else if(s.dataType==="String"){let N=ut(T);N!==null&&(s.safeDistinctValues=N)}}}if(g.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let T=A=>g[Math.floor((g.length-1)*A)];s.quantiles={p05:T(.05),p25:T(.25),p75:T(.75),p95:T(.95)}}}if(!s.isMeasure&&d.size>0){let g=Array.from(d.entries()).sort((x,T)=>T[1]-x[1]),I=ft(g.map(x=>x[0]),s.name,O);if(I!==null&&(s.geoKind=I.geoKind,s.geoMatchPct=I.geoMatchPct,I.geoAmbiguous&&(s.geoAmbiguous=!0),I.geoKind.indexOf("country")===0)){let x=et(g);x&&(s.dominantGeoRegion=x.dominantGeoRegion,s.dominantGeoRegionPct=x.dominantGeoRegionPct,s.geoRegionCount=x.regionCount)}}}updateColumnStats10(t,e,r,o,s,a,l){t>=10&&(e.blankCount=this._rows.length-r,e.distinctCount=o.size+(e.blankCount!=0?1:0),e.valueNature="Categorical",r>0&&(e.dataType==="Integer"||e.dataType==="Decimal"?e.valueNature=xt({dataType:e.dataType,isMeasure:!!e.isMeasure,name:e.name,distinct:o.size,nonblank:r,prec:s,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((r,o)=>{r.isMeasure||t.push(o)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let e=new Set;for(let r of this._rows)e.add(JSON.stringify(t.map(o=>r[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,r=-1,o=-1;if(this._cols.forEach((a,l)=>{let c=t(a.name),f=a.dataType==="Integer"||a.dataType==="Decimal";f&&e<0&&c.some(M=>M==="lat"||M==="latitude")?e=l:f&&r<0&&c.some(M=>M==="lon"||M==="lng"||M==="long"||M==="longitude")&&(r=l),o<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(o=l)}),e<0||r<0)return null;let s=[];for(let a of this._rows){let l=a[e],c=a[r],f=l==null||l===""?null:Number(l),M=c==null||c===""?null:Number(c);s.push({lat:f,lon:M,country:o>=0&&Q(this.STR(a[o]))?this.STR(a[o]):null})}return this._geoExtent=yt(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let e="abcdefghijklmnopqrstuvwxyz",r=()=>e[Math.floor(Z()*e.length)],o=()=>r().toUpperCase(),s=()=>Math.floor(Z()*10).toString(),a=I=>/[A-Z]/.test(I)?o():/[a-z]/.test(I)?r():/[0-9]/.test(I)?s():I,l=t.includes("@")&&t.includes("."),c=l?t.split("@"):[t],f=l?c[1]:"",M=f.endsWith(".com"),d=M?".com":"",O=M?f.slice(0,-4):f,g=I=>{let x="";for(let T of I)x+=a(T),/[a-zA-Z0-9]/.test(T)&&Z()<.2&&(x+=a(T));if(x.length>6){let T=Math.floor(Z()*Math.min(3,x.length-6));for(let A=0;A<T;A++){let N=0;for(;N<5;){let F=Math.floor(Z()*x.length);if(/[a-zA-Z0-9]/.test(x[F])){x=x.slice(0,F)+x.slice(F+1);break}N++}}}return x};if(l){let I=g(c[0]),x=g(O);return`${I}@${x}${d}`}else return g(t)}toObjectArray(){return this._rows.map(t=>{let e={};return this._cols.forEach((r,o)=>{e[r.name]=t[o],this.emitLegacyAggAliases&&r.hostName&&r.hostName!==r.name&&!Object.prototype.hasOwnProperty.call(e,r.hostName)&&(e[r.hostName]=t[o])}),e})}async getCSVAsync(t){let e=[],r=t?25:1e7,o=t?4e3:1e7,s=new Map;for(let l of this._rows){let c={};for(let f=0;f<this._cols.length;f++){let M=this._cols[f],d=l[f];if(this.STR(d)!=""){if(t&&M.dataType=="String")if(s.has(d))d=s.get(d);else{let O=this.obfuscateString(d);s.set(d,O),d=O}else if(M.dataType=="DateTime"&&!M.dateWithTime){let O=d instanceof Date?d:typeof d=="string"?tt(d)??new Date(d):new Date(d);d=(this.wholeDayIso(O)??O.toISOString().slice(0,10))+"T00:00:00.000Z"}o-=this.STR(d).length}else d=null;c[f]=d,--o}if(e.push(c),--r,r<=0||o<=0)break}return await It.unparse(e,{header:!1})}getCSVHeaderLine(){return It.unparse([this._cols.map(t=>this.STR(this.emitLegacyAggAliases&&t.hostName?t.hostName:t.name))])}addRow(t,e){if(this.dedupRows){let r="";for(let s of t)r+=this.STR(s)+"~";let o=ot(r);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(r=>this.STR(r?.name)));for(let r of t){if(!r)continue;let o=this.STR(r.name),s=Mt(o);!s||s===o||e.has(s)||(e.delete(o),e.add(s),r.hostName=o,r.name=s)}}};export{yt as a,Lt as b,Q as c,be as d,Pt as e,Gt as f,Wt as g,Ft as h,Ct as i,Bt as j,Mt as k,Se as l,Tt as m,Kt as n,Rt as o,vt as p,Ce as q,Me as r,Ae as s,se as t,Dt as u,de as v,ge as w,he as x,xt as y,wt as z};
|