@bicharts/shape-core 0.5.64 → 0.5.66
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-AQ3TKTPQ.mjs → chunk-3I3WKQBB.mjs} +1 -1
- package/dist/chunk-66777OZH.mjs +2 -0
- package/dist/index.mjs +1 -1
- package/dist/indexedText.mjs +1 -1
- package/dist/ingest.mjs +1 -1
- package/dist/types/aggregation.d.ts +30 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/indexedText.d.ts +34 -0
- package/dist/types/models.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-GQJJUIZ7.mjs +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{
|
|
2
|
+
import{t as w,z as b}from"./chunk-66777OZH.mjs";import C from"papaparse";var D=500,S=/^[+-]?\d{1,15}$/,E=/^[+-]?(\d{1,3}(,\d{3})*|\d+)(\.\d+)?([eE][+-]?\d+)?$/,R=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,L=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function I(n){let i=0,e=0,r=0,o=0;for(let a of n){if(a==null)continue;if(typeof a=="number"){o++,e++,Number.isInteger(a)&&i++;continue}if(a instanceof Date){o++,r++;continue}if(typeof a=="boolean"){o++;continue}let c=String(a).trim();if(c!==""){if(o++,S.test(c)){i++,e++;continue}if(E.test(c)){e++;continue}if((R.test(c)||L.test(c))&&!isNaN(Date.parse(c))){r++;continue}}}return o===0?"String":r/o>.9?"DateTime":i===o?"Integer":e===o?"Decimal":"String"}function x(n,i){if(n==null)return null;if(typeof n=="number")return i==="String"?String(n):n;if(n instanceof Date)return i==="DateTime"?n:n.toISOString();if(typeof n=="boolean")return String(n);let e=String(n).trim();if(e==="")return null;switch(i){case"Integer":return S.test(e)?parseInt(e,10):null;case"Decimal":return E.test(e)?parseFloat(e.replace(/,/g,"")):null;case"DateTime":{let r=Date.parse(e);return isNaN(r)?null:new Date(r)}default:return e}}function M(n){let i=(n||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(i)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(i)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(i)?"DateTime":(/^(bit|bool|boolean)$/.test(i),"String")}function g(n,i,e){if(n.length===0)throw new Error("ingest: no columns were resolved from the source. Supply column descriptors, or use a source shape that carries them (grid/table/objects/sql).");let r=n.length,o=n.map((t,s)=>t.dataType??I(i.slice(0,D).map(l=>l?.[s]))),a=new Set((e.measures??[]).map(t=>t.toLowerCase())),c=new Set((e.dimensions??[]).map(t=>t.toLowerCase())),d=new Set((e.nonAdditive??[]).map(t=>t.toLowerCase())),T=n.map((t,s)=>{let l=t.name.toLowerCase(),u=t.isMeasure??((o[s]==="Integer"||o[s]==="Decimal")&&!w(t.name));a.has(l)&&(u=!0),c.has(l)&&(u=!1);let h={name:t.name,dataType:o[s],isMeasure:u};return u&&d.has(l)&&(h.discourageAggregationAcrossGroups=!0),h}),m=new b;m.dedupRows=e.dedup!==!1,m.setColumns(T);for(let t=0;t<i.length;t++){let s=i[t];m.addRow(Array.from({length:r},(l,u)=>x(s?.[u],o[u])),t)}let y=m.getColumnsWithStats(e.privacyLevel??"20",e.locale??"en"),f=new Map(y.map(t=>[t.name,t]));n.forEach(t=>{let s=f.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});for(let[t,s]of Object.entries(e.formats??{})){let l=f.get(t);l&&(l.modelFormat=s)}for(let[t,s]of Object.entries(e.descriptions??{})){let l=f.get(t);l&&(l.modelDesc=s)}for(let t of e.groupBy??[]){let s=f.get(t);s&&(s.isGrouping=!0)}return{columns:y,rows:m.toObjectArray(),totalRows:m.getRowCount(),index:m}}function p(n,i){return n.map(e=>Array.isArray(e)?e:i.map(r=>e[r]))}function A(n,i){let e=[],r=new Set,o=Math.min(n.length,Math.max(1,i));for(let a=0;a<o;a++){let c=n[a];if(!(!c||typeof c!="object"))for(let d of Object.keys(c))r.has(d)||(r.add(d),e.push(d))}return e}function $(n,i={}){switch(n.kind){case"csv":{let e=C.parse(n.text,{skipEmptyLines:!0});if(e.errors?.length&&e.data.length===0)throw new Error(`ingest: CSV parse failed - ${e.errors[0].message}`);let r=e.data;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let o=r[0].map(a=>(a??"").trim());return g(o.map(a=>({name:a})),r.slice(1),i)}case"grid":{if(!n.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return g(n.header.map(e=>({name:(e??"").trim()})),n.rows??[],i)}case"table":{if(!n.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let e=n.columns.map(r=>r.name);return g(n.columns,p(n.rows??[],e),i)}case"objects":{let e=n.rows??[],r=n.columns?.length?n.columns:A(e,i.columnScanLimit??D).map(o=>({name:o}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return g(r,p(e,r.map(o=>o.name)),i)}case"sql":{if(!n.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let e=n.schema.map(r=>{let o=M(r.dataType);return{name:r.name,dataType:o,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(e,p(n.rows??[],e.map(r=>r.name)),i)}default:{let e=n;throw new Error(`ingest: unknown source kind '${e?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{M as a,$ as b};
|
|
@@ -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 ut}from"./chunk-QEH7WTLB.mjs";import{a as lt,b as ct}from"./chunk-2LR73DNS.mjs";import{a as mt,b as ft,c as Y}from"./chunk-KQVI7FDN.mjs";import{c as at}from"./chunk-SAASSIJ7.mjs";import{b as st,f as ot}from"./chunk-E6SVTFAW.mjs";import{a as nt,b as it,c as rt}from"./chunk-WBEROMBG.mjs";var xt=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],wt=[7,72,-172,-52];function dt(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,s=Math.floor(e),o=Math.ceil(e);return s===o?n[s]:n[s]+(n[o]-n[s])*(e-s)}var K=n=>Math.round(n*10)/10;function pt(n,t=3){let e=[],s=[],o=0,r=0;for(let l of n){let c=l?.lat,d=l?.lon;if(typeof c!="number"||typeof d!="number"||!isFinite(c)||!isFinite(d)||c<-90||c>90||d<-180||d>180)continue;e.push(c),s.push(d);let M=l?.country?String(l.country).trim().toUpperCase():"",b=M?q(M):null;b?((M==="US"||M==="USA")&&o++,b==="north-america"&&r++):(xt.some(L=>dt(c,d,L))&&o++,dt(c,d,wt)&&r++)}let a=e.length;return a<t?null:(e.sort((l,c)=>l-c),s.sort((l,c)=>l-c),{pctUsa:K(o/a*100),pctNa:K(r/a*100),latP5:K(j(e,.05)),latP95:K(j(e,.95)),lonP5:K(j(s,.05)),lonP95:K(j(s,.95)),n:a})}var gt={"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"},X=(()=>{let n=new Map;for(let t of Object.keys(gt))for(let e of gt[t].split(/\s+/))e&&n.set(e,t);return n})();function Et(n){for(let[t,e]of n){let s=X.get(t);s&&!X.has(e)&&X.set(e,s)}}Et(st);function q(n){if(!n)return null;let t=String(n).trim().toUpperCase();if(!t)return null;let e=X.get(t);if(e)return e;let s=ot(String(n));return s?X.get(s)??null:null}function de(n,t=2){return J(n.map(e=>[e,1]),t)}function J(n,t=2){let e=new Map,s=0;for(let[a,l]of n){let c=q(a);if(!c)continue;let d=typeof l=="number"&&isFinite(l)&&l>0?l:1;e.set(c,(e.get(c)??0)+d),s+=d}if(s<t||!e.size)return null;let o="europe",r=-1;for(let a of Array.from(e.keys()).sort()){let l=e.get(a);l>r&&(o=a,r=l)}return{dominantGeoRegion:o,dominantGeoRegionPct:K(r/s*100),regionCount:e.size,n:s}}import Rt from"papaparse";var Dt=["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"],Ot=["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"],Lt=["latitude","longitude"],Pt=["latitude","longitude"],bt=/^\s*(sum|count|count\s+distinct|distinct\s+count)\s+of\s+/i,Gt=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Ft=new RegExp("\\b("+Dt.join("|")+")\\b|("+Ot.join("|")+")$","i"),Wt=new RegExp("\\b("+Lt.join("|")+")\\b|("+Pt.join("|")+")$","i");function yt(n){return n?String(n).replace(bt,"").trim():""}function Vt(n){return!!n&&bt.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"],ht=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 _t(n){if(n==null)return"";let t=String(n),e=ht.exec(t);if(!e)return t;let s=l=>l.toLowerCase().replace(/\s+/g," ").trim(),o=s(e[1]),r=t.slice(e[0].length),a=0;for(;a<8;){let l=ht.exec(r);if(!l||s(l[1])!==o)break;let c=r.slice(l[0].length);if(c.trim()==="")break;r=c,a++}return a===0?t:t.slice(0,e[0].length)+r}function pe(n,t){if(!n||!t)return!1;let e=String(n);for(let s of t){let o=s?.hostName;if(o&&o!==s?.name&&e.includes(o))return!0}return!1}function zt(n){let t=yt(n);return t.length===0?"":t.replace(Gt," ")}function St(n,t){return t?n.test(zt(t))||n.test(yt(t)):!1}function Ct(n){return St(Wt,n)}function Ut(n){return St(Ft,n)||Ct(n)}var Mt=/int|double|decimal|single|float|number|currency|money/i;function Bt(n){let t=String(n?.valueNature??"").trim().toLowerCase();return t==="categorical"?"Categorical":t==="ordinal"?"Ordinal":t==="continuous"||n?.isMeasure===!0||Mt.test(String(n?.dataType??""))?"Continuous":"Categorical"}function Ht(n){return n?.isMeasure===!0||Mt.test(String(n?.dataType??""))}function At(n){let t=n??{},e=Bt(t);if(e!=="Continuous")return{nature:e,additivity:"unknown",basis:"role",suppressed:!1};if(Ct(t.name))return{nature:e,additivity:"positional",basis:"name",suppressed:!0};let s=String(t.additivity??"").trim().toLowerCase();if(!(s==="additive"&&Vt(t.name))){if(s==="additive")return{nature:e,additivity:"additive",basis:"measured",suppressed:!1};if(s==="part_of_whole")return{nature:e,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(s==="intensive_rate")return{nature:e,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return t.discourageAggregationAcrossGroups===!0?{nature:e,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:Ut(t.name)?{nature:e,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:e,additivity:"additive",basis:"default",suppressed:!1}}function Tt(n){let t=At(n),e=n??{};if(t.nature==="Categorical")return["first","distinctcount","count"];if(t.nature==="Ordinal")return Ht(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 he(n){return Tt(n)[0]}function be(n,t){return Tt(n).indexOf(t)>=0}function ye(n,t){if(t!=="sum"&&t!=="count")return!1;if(t==="count")return!0;let e=At(n);return e.additivity==="additive"||e.additivity==="part_of_whole"||e.additivity==="unknown"}var Kt=12,Yt=100,Zt=.3,Xt=.9,$t=120,jt=1900,qt=2100,Jt=0,Qt=20,te=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function ee(n){if(!n)return!1;let t=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(e=>e.length>0);return t.length===0?!1:te.has(t[t.length-1])}var ne=/\b(year|yr|fy|fiscal\s*year|calendar\s*year)\b/i,ie=/^(?:(?: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 Q(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let t=n%100;return t>=1&&t<=12}function tt(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 re=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,se=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,oe=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function ae(n){let t=(n||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function It(n,t){let e=0,s=0,o=0,r=0,a=0,l="",c=0,d="",M=0,b=0,L=0,g=0,R=!1;for(let B of n){if(B==null)continue;let z=String(B).trim();if(z==="")continue;e++;let P;if(P=re.exec(z)){let F=+P[2],i=+P[3];F>=1&&F<=12&&i>=1&&i<=31&&(s++,P[4]!==void 0&&o++,P[6]!==void 0&&r++)}else if(P=se.exec(z)){let F=+P[3],i=+P[4];F>=1&&F<=12&&i>=1&&i<=31&&(l&&l!==P[2]&&(R=!0),l=P[2],a++)}else if(P=oe.exec(z)){let F=+P[1],i=+P[3];F>=1&&F<=31&&i>=1&&i<=31&&(F<=12||i<=12)&&(d&&d!==P[2]&&(R=!0),d=P[2],c++,F>12&&L++,i>12&&g++,P[5]!==void 0&&M++,P[7]!==void 0&&b++)}if(e>=200)break}if(e<2||(s+a+c)/e<.8||(s>0?1:0)+(a>0?1:0)+(c>0?1:0)!==1||R)return null;if(s>0)return o===s?{pattern:r===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(a>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(L>0&&g>0)return null;let D,x;L>0?(D=!0,x="values"):g>0?(D=!1,x="values"):(D=!ae(t),x="locale");let k=D?`%d${d}%m${d}%Y`:`%m${d}%d${d}%Y`;return M===c?{pattern:k+(b===c?" %H:%M:%S":" %H:%M"),orderFrom:x}:{pattern:k,orderFrom:x}}function ue(n,t){if(!t||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let e=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!e)return!1;let s=lt(e);return s.length>0&&t[s]!==void 0}function le(n){let{dataType:t,name:e,isMeasure:s,distinctCount:o}=n;if(t==="DateTime")return!0;if(s)return!1;if(t==="Integer"||t==="Decimal"){let r=n.minNum,a=n.maxNum;if(!(r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&Number.isInteger(r)&&Number.isInteger(a)&&a>=r))return!1;let c=r>=1900&&a<=2100;if(c&&o>=2&&ne.test(e)||c&&o>=3&&o===a-r+1)return!0;let d=Q(r)&&Q(a),M=tt(r)&&tt(a);if(d||M){if(!n.sampleValues)return!0;let b=0,L=0;for(let g of n.sampleValues){if(g==null||g==="")continue;b++;let R=Number(String(g).trim());if(Number.isFinite(R)&&(d?Q(R):tt(R))&&L++,b>=60)break}if(b>=2&&L===b)return!0}return!1}if(n.sampleValues){let r=n.locale?ct(n.locale):null,a=0,l=0,c=[];for(let d of n.sampleValues){if(d==null||d==="")continue;a++;let M=String(d).trim();if(c.push(M),(ie.test(M)||ue(M,r))&&l++,a>=60)break}if(a>=2&&l/a>=.8||It(c,n.locale)!==null)return!0}return!1}function ce(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 me(n){let{rows:t,measureColIdx:e,measureName:s,candidateDims:o,minNum:r,maxNum:a,discourageAgg:l}=n,c=100,d=.01,M="";for(let L of o){if(L.distinct<2||L.distinct>c)continue;let g=o.filter(x=>x.idx!==L.idx).map(x=>x.idx),R=new Map;for(let x of t){let k=x[e];if(typeof k!="number"||!Number.isFinite(k))continue;let B=g.length?g.map(P=>String(x[P])).join(M):"",z=R.get(B);z||(z={sum:0,cset:new Set},R.set(B,z)),z.sum+=k,z.cset.add(String(x[L.idx]))}let N=0,v=0,D=0;for(let x of R.values())x.cset.size<2||(D++,Math.abs(x.sum-100)<=100*d?N++:Math.abs(x.sum-1)<=1*d&&v++);if(D>=2&&(N/D>=.9||v/D>=.9))return{additivity:"part_of_whole",partOfWholeDim:L.name}}if(l)return{additivity:"intensive_rate"};let b=ce(s);return b==="avg"||b==="min"||b==="max"?{additivity:"intensive_rate"}:b==="count"?{additivity:"additive"}:b==="sum"?{additivity:"unknown"}:r!=null&&a!=null&&Number.isFinite(r)&&Number.isFinite(a)&&r>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function Nt(n){let{dataType:t,isMeasure:e,name:s,distinct:o,nonblank:r,prec:a,maxval:l,minval:c}=n,d=l-c+1,M=d>0?o/d:1,b=r>0?o/r:0,L=t==="Decimal"||a>0;return ee(s)?"Categorical":M>=Xt&&(nt(s)&&o<=$t||c>=jt&&l<=qt||c>=Jt&&l<=Qt)?"Ordinal":e||o>Kt&&(L||o>=Yt||b>=Zt)?"Continuous":"Categorical"}var vt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(t){return t==null?"":t.toString()}getPrecision(t){if(!isFinite(t))return 0;let s=t.toString().split(".")[1];return s?s.length:0}getColumns(){return this._cols}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:t.getHours()!==0||t.getMinutes()!==0||t.getSeconds()!==0||t.getMilliseconds()!==0}getColumnsWithStats(t,e){if(this._computedStatsForLevel==t)return this._cols;let s=0,o=parseInt(t),r=[];for(let i of this._cols){let m=new Map,w=[],h=0,u=0,_=0,S=null,y=null,p=null,T=!1,E=!0,I=!0,O=null,G=!1;for(let A of this._rows){let f=A[s],C=this.STR(f);if(C!=""){if(h+=C.length,m.set(C,(m.get(C)||0)+1),u++,i.dataType=="Integer"||i.dataType=="Decimal"||i.dataType=="DateTime")if((S===null||f<S)&&(S=f),(y===null||f>y)&&(y=f),i.dataType=="Integer"||i.dataType=="Decimal"){if(p===null?p=f:p+=f,i.dataType=="Decimal"){let W=this.getPrecision(f);W>_&&(_=W)}w.push(f)}else T=T||this.hasTimeComponent(f);G&&(f<O?E=!1:f>O&&(I=!1)),O=f,G=!0}}if(u>=3&&(E&&!I?i.sortedDirection="asc":I&&!E?i.sortedDirection="desc":i.sortedDirection="none"),u>0&&m.size>0&&!i.isMeasure){let A=0,f=Number.MAX_SAFE_INTEGER;for(let C of m.values())C>A&&(A=C),C<f&&(f=C);if(i.modalShare=A/u,i.minGroupCount=f===Number.MAX_SAFE_INTEGER?null:f,m.size===2){let C=[...m.keys()].map(V=>mt(V).trim().toLowerCase()).sort(),H=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(V=>C[0]===V[0]&&C[1]===V[1]),U=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(i.name);(H||U)&&(i.isBinaryFlag=!0)}}if(i.dataType=="DateTime"&&(i.dateWithTime=T),i.isTemporal=le({dataType:i.dataType,name:i.name,isMeasure:i.isMeasure,distinctCount:m.size,minNum:typeof S=="number"?S:null,maxNum:typeof y=="number"?y:null,sampleValues:m.keys(),locale:e}),i.isTemporal&&i.dataType==="String"&&!i.isMeasure){let A=It(m.keys(),e);A&&(i.temporalTextPattern=A.pattern)}this.updateColumnStats10(o,i,u,m,_,y,S),this.updateColumnStats20(o,w,u,p,i,h,T,S,y,_,m,e),!i.isMeasure&&(i.dataType==="Integer"||i.dataType==="Decimal")&&Nt({dataType:i.dataType,isMeasure:!1,name:i.name,distinct:m.size,nonblank:u,prec:_,maxval:typeof y=="number"?y:0,minval:typeof S=="number"?S:0})==="Continuous"&&(i.isMeasure=!0,i.geoKind=void 0,i.geoMatchPct=void 0,i.geoAmbiguous=void 0,i.dominantGeoRegion=void 0,i.dominantGeoRegionPct=void 0,i.geoRegionCount=void 0),r[s]=i.isMeasure||m.size>2e3?null:new Set(m.keys()),s++}let a=[];this._cols.forEach((i,m)=>{i.isMeasure||a.push({idx:m,distinct:i.distinctCount??0,name:i.name})}),this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let w=typeof i.lowValue=="number"?i.lowValue:null,h=typeof i.highValue=="number"?i.highValue:null,u=me({rows:this._rows,measureColIdx:m,measureName:i.name,candidateDims:a,minNum:w,maxNum:h,discourageAgg:!!i.discourageAggregationAcrossGroups});i.additivity=u.additivity,u.partOfWholeDim&&(i.partOfWholeDim=u.partOfWholeDim)});let l=50,c=a.filter(i=>i.distinct>=2&&i.distinct<=l);this._cols.forEach((i,m)=>{if(!i.isMeasure)return;let w=[];for(let f of this._rows){let C=f[m];if(C==null||C==="")continue;let W=typeof C=="number"?C:parseFloat(C);isNaN(W)||w.push(W)}if(w.length===0)return;let h=[...w].sort((f,C)=>f-C),u=f=>h[Math.min(h.length-1,Math.max(0,Math.floor(f*(h.length-1))))],_=u(.5),S=u(.1),y=u(.9),p=Math.abs(_)>1e-9?Math.abs(_):Math.abs(h[h.length-1])>1e-9?Math.abs(h[h.length-1]):1;i.relativeDispersion=Math.round((y-S)/p*1e3)/1e3;let T=0;for(let f of w)T+=f;T/=w.length;let E=0;for(let f of w)E+=(f-T)*(f-T);if(E<=1e-12)return;let I=[],O=[],G=f=>{if(f.length<4)return NaN;let C=[...f].sort((H,U)=>H-U),W=H=>C[Math.min(C.length-1,Math.max(0,Math.floor(H*(C.length-1))))];return W(.75)-W(.25)},A=G(w);for(let f of c){let C=new Map;for(let U of this._rows){let V=U[m];if(V==null||V==="")continue;let Z=typeof V=="number"?V:parseFloat(V);if(isNaN(Z))continue;let et=this.STR(U[f.idx])+"",$=C.get(et);$?($.s+=Z,$.n++,$.vals.push(Z)):C.set(et,{s:Z,n:1,vals:[Z]})}let W=0;for(let U of C.values()){let V=U.s/U.n;W+=U.n*(V-T)*(V-T)}I.push({otherColumn:f.name,eta2:Math.round(W/E*1e4)/1e4});let H=[];for(let U of C.values()){let V=G(U.vals);isNaN(V)||H.push(V)}if(H.length>=2&&isFinite(A)&&A>1e-9){let U=(Math.max(...H)-Math.min(...H))/A;O.push({otherColumn:f.name,spreadRatio:Math.round(U*1e4)/1e4})}}I.length>0&&(i.groupDiscrimination=I),O.length>0&&(i.spreadDiscrimination=O)});let d=.97,M=5,b=this._cols.map((i,m)=>({c:i,i:m})).filter(i=>i.c.isMeasure);for(let i=0;i<b.length;i++)for(let m=i+1;m<b.length;m++){let w=b[i].i,h=b[m].i,u=0,_=0,S=0,y=0,p=0,T=0;for(let G of this._rows){let A=G[w],f=G[h];if(A==null||A===""||f===null||f===void 0||f==="")continue;let C=typeof A=="number"?A:parseFloat(A),W=typeof f=="number"?f:parseFloat(f);isNaN(C)||isNaN(W)||(u++,_+=C,S+=W,y+=C*C,p+=W*W,T+=C*W)}if(u<M)continue;let E=u*y-_*_,I=u*p-S*S;if(E<=1e-12||I<=1e-12)continue;let O=(u*T-_*S)/Math.sqrt(E*I);if(Math.abs(O)>=d){let G=b[i].c,A=b[m].c;G.collinearWithMeasures||(G.collinearWithMeasures=[]),A.collinearWithMeasures||(A.collinearWithMeasures=[]),G.collinearWithMeasures.push(A.name),A.collinearWithMeasures.push(G.name)}}for(let i=0;i<this._cols.length;i++){let m=r[i];if(!m||m.size===0)continue;let w=[];for(let h=0;h<this._cols.length;h++){if(h===i)continue;let u=r[h];if(!u||u.size===0)continue;let _=0;for(let y of m)u.has(y)&&_++;let S=Math.round(_/m.size*100);S>0&&w.push({otherColumn:this._cols[h].name,percentShared:S})}w.length>0&&(this._cols[i].sharedValueRatioWithOthers=w)}let L=50,g=[];for(let i=0;i<this._cols.length;i++){let m=r[i];m&&m.size>=2&&m.size<=L&&g.push(i)}if(g.length>=2){let i=new Map,m=(h,u)=>h+":"+u;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++)i.set(m(g[h],g[u]),new Map);for(let h of this._rows)for(let u=0;u<g.length;u++){let _=this.STR(h[g[u]])+"";for(let S=u+1;S<g.length;S++){let y=""+this.STR(h[g[S]]),p=i.get(m(g[u],g[S])),T=_+""+y;p.set(T,(p.get(T)??0)+1)}}let w=new Map;for(let h=0;h<g.length;h++)for(let u=h+1;u<g.length;u++){let _=g[h],S=g[u],y=r[_].size,p=r[S].size,T=i.get(m(_,S)),E=T.size,I=0;for(let f of T.values())(I===0||f<I)&&(I=f);let O=Math.round(E/(y*p)*100),G=E===y,A=E===p;if((this._cols[_].categoricalPairStats||=[]).push({otherColumn:this._cols[S].name,fillPct:O,determinesOther:G,minCellCount:I,distinctCombinations:E}),(this._cols[S].categoricalPairStats||=[]).push({otherColumn:this._cols[_].name,fillPct:O,determinesOther:A,minCellCount:I,distinctCombinations:E}),G&&y>p){let f=w.get(_);(!f||p<f.card)&&w.set(_,{name:this._cols[S].name,card:p,ratio:p/y})}if(A&&p>y){let f=w.get(S);(!f||y<f.card)&&w.set(S,{name:this._cols[_].name,card:y,ratio:y/p})}}for(let[h,u]of w)this._cols[h].primaryParentColumn=u.name,this._cols[h].nestingRatio=Math.round(u.ratio*100)/100}let R=6,N=this._rows.length;for(let i=0;i<this._cols.length;i++){let m=this._cols[i];if(m.isMeasure||m.primaryParentColumn)continue;let w=m.distinctCount??0;if(w<=L||N>0&&w>=N)continue;let h=[];for(let u=0;u<this._cols.length;u++){if(u===i)continue;let _=this._cols[u];if(_.isMeasure)continue;let S=_.distinctCount??0;S<2||S>=w||h.push(u)}h.sort((u,_)=>(this._cols[u].distinctCount??0)-(this._cols[_].distinctCount??0));for(let u of h.slice(0,R)){let _=new Map,S=!0;for(let p of this._rows){let T=this.STR(p[i])+"",E=this.STR(p[u])+"",I=_.get(T);if(I===void 0)_.set(T,E);else if(I!==E){S=!1;break}}if(!S)continue;let y=this._cols[u].distinctCount??0;m.primaryParentColumn=this._cols[u].name,m.nestingRatio=Math.round(y/w*100)/100;break}}let v=.01,D=.05,x=.95,k=8,B=8,z=6,P=500,F=[];for(let i=0;i<this._cols.length&&F.length<B;i++){let m=this._cols[i].dataType;(m==="Double"||m==="Integer"||m==="Decimal")&&F.push(i)}if(F.length>=3&&this._rows.length>=k){let i=Math.min(this._rows.length,P),m=F.map(y=>{let p=[];for(let I=0;I<i;I++){let O=this._rows[I][y],G=typeof O=="number"?O:parseFloat(String(O).replace(/,/g,""));if(O==null||O===""||!isFinite(G))return null;p.push(G)}let T=p[0],E=!1;for(let I of p)if(I!==T){E=!0;break}return E?p:null}),w=F.map((y,p)=>p).filter(y=>m[y]!==null),h=y=>{let p=y.slice().sort((E,I)=>E-I),T=p.length>>1;return p.length%2?p[T]:(p[T-1]+p[T])/2},u=null,_=[],S=y=>{if(_.length>=3){let p=_.map(O=>m[O]),T=p[0].length,E=new Array(T);for(let O=0;O<T;O++){let G=0;for(let A of p)G+=A[O];E[O]=G}let I=h(E);if(I>0){let O=0;for(let A of E)Math.abs(A-I)<=I*v&&O++;let G=O/T;if(G>=x){let A=1;for(let f of p){let C=h(f)/I;C<A&&(A=C)}A>=D&&(!u||_.length>u.cols.length)&&(u={cols:_.slice(),total:I,matched:G})}}}if(!(_.length>=z))for(let p=y;p<w.length;p++)_.push(w[p]),S(p+1),_.pop()};if(S(0),u){let y=u,T={columns:y.cols.map(E=>this._cols[F[E]].name),total:Math.round(y.total*1e3)/1e3,matchedPct:Math.round(y.matched*100)/100};for(let E of y.cols)this._cols[F[E]].constantSumGroup=T}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,e,s,o,r,a,l,c,d,M,b,L){if(t>=20){let g=[...e].sort((v,D)=>v-D),R=Math.floor(g.length/2);if(s>0&&o!=null?r.avgValue=r.dataType=="Integer"?Math.round(o/s):o/s:r.avgValue=null,s>0&&(r.avgLength=a/s),this._rows.length>0&&(r.dataType!="DateTime"||l||!c?r.lowValue=c:r.lowValue=new Date(c).toISOString().slice(0,10)+"T00:00:00.000Z",r.dataType!="DateTime"||l||!d?r.highValue=d:r.highValue=new Date(d).toISOString().slice(0,10)+"T00:00:00.000Z",r.medianValue=g.length===0?null:g.length%2===0?r.dataType=="Integer"?Math.round((g[R-1]+g[R])/2):(g[R-1]+g[R])/2:g[R],r.numericPrecision=M),g.length>0){let v=r.avgValue??0,D=g.length,x=0,k=0;for(let z of g){let P=z-v;x+=P*P,k+=P*P*P}let B=x/D;r.skewness=B===0?0:k/D/Math.pow(Math.sqrt(B),3),r.stdDev=Math.sqrt(B)}o!==null&&(r.sum=o);let N=Array.from(b.entries()).sort((v,D)=>D[1]-v[1]);if(r.topCategories=N.slice(0,10).map(v=>v[1]),!r.isMeasure&&N.length>0){if(r.dataType==="String"){let v=N.map(x=>x[0]);r.formatSignature=ut(v);let D=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!D.test(r.formatSignature)&&(r.avgLength===void 0||r.avgLength>=3)&&(r.isFreeText=!0)}else r.topCategoryValues=N.slice(0,5).map(v=>v[0]);if(t>=20){let v=N.map(x=>x[0]),D=rt(v,L);if(D!==null)r.ordinalPattern=D.pattern,r.orderedDomain=D.orderedDomain;else if(r.dataType==="String"){let x=it(v);x!==null&&(r.safeDistinctValues=x)}}}if(g.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let v=D=>g[Math.floor((g.length-1)*D)];r.quantiles={p05:v(.05),p25:v(.25),p75:v(.75),p95:v(.95)}}}if(!r.isMeasure&&b.size>0){let g=Array.from(b.entries()).sort((N,v)=>v[1]-N[1]),R=at(g.map(N=>N[0]),r.name,L);if(R!==null&&(r.geoKind=R.geoKind,r.geoMatchPct=R.geoMatchPct,R.geoAmbiguous&&(r.geoAmbiguous=!0),R.geoKind.indexOf("country")===0)){let N=J(g);N&&(r.dominantGeoRegion=N.dominantGeoRegion,r.dominantGeoRegionPct=N.dominantGeoRegionPct,r.geoRegionCount=N.regionCount)}}}updateColumnStats10(t,e,s,o,r,a,l){t>=10&&(e.blankCount=this._rows.length-s,e.distinctCount=o.size+(e.blankCount!=0?1:0),e.valueNature="Categorical",s>0&&(e.dataType==="Integer"||e.dataType==="Decimal"?e.valueNature=Nt({dataType:e.dataType,isMeasure:!!e.isMeasure,name:e.name,distinct:o.size,nonblank:s,prec:r,maxval:a,minval:l}):e.dataType==="DateTime"&&(e.valueNature=e.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let t=[];if(this._cols.forEach((s,o)=>{s.isMeasure||t.push(o)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let e=new Set;for(let s of this._rows)e.add(JSON.stringify(t.map(o=>s[o])));return this._leafCardinality=e.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let t=a=>String(a||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),e=-1,s=-1,o=-1;if(this._cols.forEach((a,l)=>{let c=t(a.name),d=a.dataType==="Integer"||a.dataType==="Decimal";d&&e<0&&c.some(M=>M==="lat"||M==="latitude")?e=l:d&&s<0&&c.some(M=>M==="lon"||M==="lng"||M==="long"||M==="longitude")&&(s=l),o<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(o=l)}),e<0||s<0)return null;let r=[];for(let a of this._rows){let l=a[e],c=a[s],d=l==null||l===""?null:Number(l),M=c==null||c===""?null:Number(c);r.push({lat:d,lon:M,country:o>=0&&q(this.STR(a[o]))?this.STR(a[o]):null})}return this._geoExtent=pt(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let e="abcdefghijklmnopqrstuvwxyz",s=()=>e[Math.floor(Y()*e.length)],o=()=>s().toUpperCase(),r=()=>Math.floor(Y()*10).toString(),a=R=>/[A-Z]/.test(R)?o():/[a-z]/.test(R)?s():/[0-9]/.test(R)?r():R,l=t.includes("@")&&t.includes("."),c=l?t.split("@"):[t],d=l?c[1]:"",M=d.endsWith(".com"),b=M?".com":"",L=M?d.slice(0,-4):d,g=R=>{let N="";for(let v of R)N+=a(v),/[a-zA-Z0-9]/.test(v)&&Y()<.2&&(N+=a(v));if(N.length>6){let v=Math.floor(Y()*Math.min(3,N.length-6));for(let D=0;D<v;D++){let x=0;for(;x<5;){let k=Math.floor(Y()*N.length);if(/[a-zA-Z0-9]/.test(N[k])){N=N.slice(0,k)+N.slice(k+1);break}x++}}}return N};if(l){let R=g(c[0]),N=g(L);return`${R}@${N}${b}`}else return g(t)}toObjectArray(){return this._rows.map(t=>{let e={};return this._cols.forEach((s,o)=>{e[s.name]=t[o],this.emitLegacyAggAliases&&s.hostName&&s.hostName!==s.name&&!Object.prototype.hasOwnProperty.call(e,s.hostName)&&(e[s.hostName]=t[o])}),e})}async getCSVAsync(t){let e=[],s=t?25:1e7,o=t?4e3:1e7,r=new Map;for(let l of this._rows){let c={};for(let d=0;d<this._cols.length;d++){let M=this._cols[d],b=l[d];if(this.STR(b)!=""){if(t&&M.dataType=="String")if(r.has(b))b=r.get(b);else{let L=this.obfuscateString(b);r.set(b,L),b=L}else M.dataType=="DateTime"&&!M.dateWithTime&&(b=new Date(b).toISOString().slice(0,10)+"T00:00:00.000Z");o-=this.STR(b).length}else b=null;c[d]=b,--o}if(e.push(c),--s,s<=0||o<=0)break}return await Rt.unparse(e,{header:!1})}getCSVHeaderLine(){return Rt.unparse([this._cols.map(t=>this.STR(t.name))])}addRow(t,e){if(this.dedupRows){let s="";for(let r of t)s+=this.STR(r)+"~";let o=ft(s);if(this._rowHashes.has(o))return!1;this._rowHashes.add(o)}return this._rows.push(t),this._origIndices.push(e??-1),!0}getOriginalRowIndex(t){return t<0||t>=this._origIndices.length?-1:this._origIndices[t]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null}setColumns(t){if(this._cols=t,!t||t.length===0)return;let e=new Set(t.map(s=>this.STR(s?.name)));for(let s of t){if(!s)continue;let o=this.STR(s.name),r=_t(o);!r||r===o||e.has(r)||(e.delete(o),e.add(r),s.hostName=o,s.name=r)}}};export{pt as a,Et as b,q as c,de as d,Dt as e,Ot as f,Lt as g,Pt as h,yt as i,Vt as j,_t as k,pe as l,Ct as m,Ut as n,At as o,Tt as p,he as q,be as r,ye as s,ee as t,It as u,le as v,ce as w,me as x,Nt as y,vt as z};
|
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 Wt,b as Xt}from"./chunk-3I3WKQBB.mjs";import{a as dt,b as yt,c as ht,d as Ct,e as It,f as Mt,g as vt,h as kt,i as _t,j as Lt,k as Nt,l as Ot,m as wt,n as zt,o as Gt,p as Et,q as $t,r as Dt,s as Ft,t as Bt,u as Kt,v as Ht,w as Vt,x as qt,y as Zt,z as Ut}from"./chunk-66777OZH.mjs";import{a as At}from"./chunk-QEH7WTLB.mjs";import{a as Pt,b as xt}from"./chunk-2LR73DNS.mjs";import{a as St,b as Tt,c as Rt,d as bt}from"./chunk-KQVI7FDN.mjs";import{a as V,b as q,c as ft,d as gt,e as mt,f as pt}from"./chunk-SAASSIJ7.mjs";import{a as T,f as R,g as y,h as b,i as O,j as nt,k as et,l as H,m,n as ot,o as it,p as rt,q as I,r as st,s as at,t as lt,u as ct,v as w,w as ut}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as J,b as Q,c as tt}from"./chunk-WBEROMBG.mjs";var z=2,W=400;function E(r){return!!R(r)}function A(r){let e=new Set;for(let n of r){if(n==null)continue;let s=T(String(n));if(!b(s)&&!e.has(s)&&(e.add(s),e.size>=W))break}return Array.from(e)}function C(r){let e=A(r);if(e.length===0||$(r)<95)return!1;let n=e.filter(c=>E(c)&&!m(c)).length,s=e.filter(c=>!E(c)&&!!m(c)).length;return n>=1&&n>=s}function Z(r,e){if(!m(r))return!1;let n=R(r);return n?e==="world"?!0:H.has(n):!1}function $(r){let e=A(r);if(e.length===0)return 0;let n=0;for(let s of e)E(s)&&n++;return Math.round(n/e.length*1e3)/10}function M(r){let e=A(r);if(e.length===0)return 0;let n=0;for(let s of e)m(s)&&n++;return Math.round(n/e.length*1e3)/10}function F(r){let e=new Set;for(let n of r){if(n==null)continue;let s=String(n).trim();if(!b(T(s))&&!e.has(s)&&(e.add(s),e.size>=W))break}return Array.from(e)}function D(r){let e=F(r);if(e.length===0)return 0;let n=0;for(let s of e)I(s).length>0&&n++;return Math.round(n/e.length*1e3)/10}function U(r,e){return q(e,V)?!0:F(r).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function jt(r,e){let n=A(r);if(n.length===0)return 0;let s=0;for(let c of n)w(c,e)&&s++;return Math.round(s/n.length*1e3)/10}function G(r,e){let n=0;for(let s of A(r))e(s)&&n++;return n}function Yt(r,e){let n=0;for(let s of F(r))e(s)&&n++;return n}function Jt(r,e,n,s,c){let P=[],u=[],o={},v={},k=new Set(r),l=t=>e.map(i=>i[t]);for(let t of["city","country"]){let i=n?.[t];i&&k.has(i)&&(o[t]=i)}let X=new Set(c??r);for(let t of["lat","lon"]){let i=n?.[t];i&&X.has(i)&&(o[t]=i)}let p=n?.zip;if(p&&k.has(p)){let t=l(p),i=D(t);i<95?u.push(`zip=${p} (only ${i}% of values read as ZIPs)`):U(t,p)?o.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let g=n?.state;if(g&&k.has(g)){let t=l(g),i=A(t);i.length>0&&i.every(a=>Z(a,s))?u.push(`state=${g} (every value is "CA", which is both Canada and California)`):C(t)?(u.push(`state=${g} (every value is a country, not a state)`),o.country||(o.country=g)):M(t)<95?u.push(`state=${g} (only ${M(t)}% of values are states/provinces)`):o.state=g}let d=new Set(Object.values(o).filter(Boolean)),x=r.filter(t=>!d.has(t)&&!t.startsWith("__"));if(!o.state){let t=null;for(let i of x){let a=l(i);if(C(a))continue;let f=M(a);if(f<95)continue;let N=G(a,S=>!!m(S)),Y=G(a,S=>!!m(S)&&!Z(S,s));N<z&&Y<1||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.state=t.name,d.add(t.name),P.push(`state=${t.name} (${t.pct}% states/provinces)`))}if(!o.zip)for(let t of x){if(d.has(t))continue;let i=l(t),a=D(i);if(!(a<95)&&U(i,t)&&!(Yt(i,f=>I(f).length>0)<z)){o.zip=t,d.add(t),P.push(`zip=${t} (${a}% ZIP codes)`);break}}let h=o.country;if(!h||!C(l(h))){let t=null;for(let i of x){if(d.has(i)||!C(l(i)))continue;let a=$(l(i));(!t||a>t.pct)&&(t={name:i,pct:a})}t&&(h&&(u.push(`country=${h} (only ${$(l(h))}% of values are country identifiers; using ${t.name} instead)`),v.country=h),o.country=t.name,d.add(t.name),P.push(`country=${t.name}`))}if(!o.city){let t=null;for(let i of x){if(d.has(i))continue;let a=l(i),f=jt(a,s);f<O||G(a,N=>w(N,s))<z||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.city=t.name,P.push(`city=${t.name} (${t.pct}% known cities)`))}let B=o.country?l(o.country):[],_=!!o.country&&C(B),j=_?new Set(B.map(t=>R(t==null?null:String(t))).filter(Boolean)).size:0,K=_&&j>=2,L=!!(o.lat&&o.lon)&&e.some(t=>{let i=+String(t[o.lat]??"").trim(),a=+String(t[o.lon]??"").trim();return isFinite(i)&&isFinite(a)&&i>=-90&&i<=90&&a>=-180&&a<=180&&String(t[o.lat]??"").trim()!==""&&String(t[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!L&&u.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||L)&&u.push(_?`country=${o.country} (every row resolves to the same country - nothing to place apart)`:`country=${o.country} (values are not country identifiers)`),{bind:!!(o.city||o.state||o.zip||K||L)?o:null,backfilled:P,refused:u,...Object.keys(v).length?{labelFallback:v}:{}}}export{O as CITY_ROLE_MATCH_PCT,Rt as GET_RANDOM,Mt as INTENSIVE_SUFFIX_TOKENS,It as INTENSIVE_WORD_TOKENS,Ut as IndexedText,kt as POSITIONAL_SUFFIX_TOKENS,vt as POSITIONAL_WORD_TOKENS,y as ROLE_MATCH_PCT,Tt as SIMPLE_STRING_HASH,St as STR,M as admin1MatchPct,Et as allowedAggregations,pt as buildGeoIsoColumn,lt as buildGeoPointColumns,ut as cityMatchPct,ct as cityTagsFor,qt as classifyAdditivity,Gt as classifyForAggregation,Zt as classifyNumericValueNature,Ht as classifyTemporal,Ot as codeNeedsLegacyAggNames,Nt as collapseRepeatedAggPrefix,ht as countryRegion,$t as defaultAggregation,At as detectFormatSignature,ft as detectGeo,tt as detectOrdinalDomain,Kt as detectTextDatePattern,Wt as engineTypeForSqlType,Lt as hasDefaultAggPrefix,Vt as hostAggHint,Xt as ingest,Dt as isAggregationAllowed,b as isBlankLike,et as isCityTableLoaded,bt as isDeterministicRefusal,st as isGeoPointAmbiguity,Bt as isIdentifierName,mt as isJoinGeoKind,J as isOrdinalFriendlyName,C as looksLikeCountryColumn,xt as monthLookupFor,zt as nameLooksIntensiveRate,wt as nameLooksPositional,ot as normalizeCountry,Pt as normalizeMonthKey,T as normalizePlaceName,rt as normalizeZip5,nt as registerCityTable,yt as registerIso3Regions,m as resolveAdmin1,at as resolveGeoPoint,Jt as resolvePointRoles,Q as safeDistinctValuesToShip,Ft as shareOfTotalIsHonest,_t as stripHostAggPrefix,Ct as summarizeCountryRegions,dt as summarizeGeoExtent,gt as toGeoIso,D as zipMatchPct,I as zipPrefixCandidates,it as zipToPrefix3};
|
package/dist/indexedText.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
|
|
2
|
-
import{
|
|
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-66777OZH.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-KQVI7FDN.mjs";import"./chunk-SAASSIJ7.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-WBEROMBG.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-3I3WKQBB.mjs";import"./chunk-66777OZH.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-KQVI7FDN.mjs";import"./chunk-SAASSIJ7.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-WBEROMBG.mjs";export{a as engineTypeForSqlType,b as ingest};
|
|
@@ -68,6 +68,36 @@ export declare function stripHostAggPrefix(name: string | null | undefined): str
|
|
|
68
68
|
/** True when the name carries a DEFAULT aggregation prefix — the one Power BI applies without
|
|
69
69
|
* anyone choosing it, which is why a resulting "additive" verdict is not conclusive. */
|
|
70
70
|
export declare function hasDefaultAggPrefix(name: string | null | undefined): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* `Sum of Sum of Revenue` -> `Sum of Revenue`. Any number of repeats of the SAME label collapse
|
|
73
|
+
* to one; a different label, or no label at all, is returned untouched.
|
|
74
|
+
*
|
|
75
|
+
* Case and spacing are compared loosely (a host writing `Sum of sum of X` is one host writing
|
|
76
|
+
* the same word twice) but the SURVIVING text is the caller's own first prefix, never a
|
|
77
|
+
* canonicalised one: this removes a duplication, it does not restyle a name.
|
|
78
|
+
*/
|
|
79
|
+
export declare function collapseRepeatedAggPrefix(name: string | null | undefined): string;
|
|
80
|
+
/**
|
|
81
|
+
* THE OTHER HALF OF THE RENAME, and the reason it is safe to ship. Code generated before the
|
|
82
|
+
* collapse existed reads the host's ORIGINAL key - `row["Sum of Sum of Revenue"]` - and a
|
|
83
|
+
* cached chart re-renders that stored code against a freshly measured dataset. Renaming the key
|
|
84
|
+
* under it would draw an empty chart, silently, on a report nobody touched.
|
|
85
|
+
*
|
|
86
|
+
* So a host asks this before it renders, and sets `IndexedText.emitLegacyAggAliases` from the
|
|
87
|
+
* answer: does this particular code still name a column the way the host did, when the engine
|
|
88
|
+
* has since renamed it? Only then does the dataset carry the extra key.
|
|
89
|
+
*
|
|
90
|
+
* Measured before it was written (2026-09-04) rather than assumed: across shipped generations
|
|
91
|
+
* about 3% were handed a doubled name, and most of those hold stored code that REFERENCES it,
|
|
92
|
+
* including charts real people still open. A plain-substring test over the code is exactly the
|
|
93
|
+
* right instrument: it is what "this code will index that key" means, it cannot false-negative,
|
|
94
|
+
* and its false positives (the name inside a comment or a title string) cost one harmless extra
|
|
95
|
+
* key on a chart that is already in the affected population.
|
|
96
|
+
*/
|
|
97
|
+
export declare function codeNeedsLegacyAggNames(code: string | null | undefined, cols: ReadonlyArray<{
|
|
98
|
+
name?: string;
|
|
99
|
+
hostName?: string;
|
|
100
|
+
} | null | undefined> | null | undefined): boolean;
|
|
71
101
|
/** Does this column NAME read as a coordinate? */
|
|
72
102
|
export declare function nameLooksPositional(name: string | null | undefined): boolean;
|
|
73
103
|
/** Does this column NAME read as an intensive rate — a quantity a SUM would corrupt?
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { IndexedText } from "./indexedText";
|
|
|
2
2
|
export type { IValueCollection } from "./indexedText";
|
|
3
3
|
export { classifyTemporal, detectTextDatePattern, classifyAdditivity, classifyNumericValueNature, hostAggHint, isIdentifierName, } from "./indexedText";
|
|
4
4
|
export type { TextDateDetection } from "./indexedText";
|
|
5
|
-
export { classifyForAggregation, allowedAggregations, defaultAggregation, isAggregationAllowed, shareOfTotalIsHonest, nameLooksIntensiveRate, nameLooksPositional, stripHostAggPrefix, hasDefaultAggPrefix, INTENSIVE_WORD_TOKENS, INTENSIVE_SUFFIX_TOKENS, POSITIONAL_WORD_TOKENS, POSITIONAL_SUFFIX_TOKENS, } from "./aggregation";
|
|
5
|
+
export { classifyForAggregation, allowedAggregations, defaultAggregation, isAggregationAllowed, shareOfTotalIsHonest, nameLooksIntensiveRate, nameLooksPositional, stripHostAggPrefix, hasDefaultAggPrefix, collapseRepeatedAggPrefix, codeNeedsLegacyAggNames, INTENSIVE_WORD_TOKENS, INTENSIVE_SUFFIX_TOKENS, POSITIONAL_WORD_TOKENS, POSITIONAL_SUFFIX_TOKENS, } from "./aggregation";
|
|
6
6
|
export type { AggKind, AggAdditivity, AggBasis, AggNature, AggregationClass, AggregationColumn, } from "./aggregation";
|
|
7
7
|
export type { LLMColumnWithValue } from "./models";
|
|
8
8
|
export type { LLMRequestModifier, SimpleColumn, VegaRendererPayload, LLMClientHints, LLMRequestCode, LLMQualifyResult, LLMRequestCodeResult, GetLicenseStatusResult, } from "./models";
|
|
@@ -82,6 +82,20 @@ export declare class IndexedText implements IValueCollection {
|
|
|
82
82
|
* callers construct IndexedText with no arguments and are unaffected.
|
|
83
83
|
*/
|
|
84
84
|
dedupRows: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* ALSO key each row by the host's ORIGINAL column name, for columns the doubled-prefix
|
|
87
|
+
* collapse renamed (see setColumns). OFF by default, and it must stay off for anything
|
|
88
|
+
* freshly generated: the shape carries only the collapsed name, so new code asks for that,
|
|
89
|
+
* and a second key would show up as a duplicate column in anything that walks the row (a
|
|
90
|
+
* pandas DataFrame built from the dataset, most obviously).
|
|
91
|
+
*
|
|
92
|
+
* A host turns it on for ONE reason — it is about to re-render code that was generated
|
|
93
|
+
* BEFORE the collapse existed and that therefore reads `row["Sum of Sum of Revenue"]`.
|
|
94
|
+
* `codeNeedsLegacyAggNames` answers that question from the code text, and charts in exactly
|
|
95
|
+
* that state were measured to exist before this shipped (2026-09-04). Self-retiring:
|
|
96
|
+
* regenerating any one of them stops the flag ever being set for it again.
|
|
97
|
+
*/
|
|
98
|
+
emitLegacyAggAliases: boolean;
|
|
85
99
|
private STR;
|
|
86
100
|
private getPrecision;
|
|
87
101
|
getColumns(): LLMColumnWithValue[];
|
|
@@ -110,5 +124,25 @@ export declare class IndexedText implements IValueCollection {
|
|
|
110
124
|
addRow(colvals: any[], originalIdx?: number): boolean;
|
|
111
125
|
getOriginalRowIndex(i: number): number;
|
|
112
126
|
reset(): void;
|
|
127
|
+
/**
|
|
128
|
+
* THE ONE PLACE A COLUMN NAME ENTERS THE ENGINE, which is why the doubled-aggregation-prefix
|
|
129
|
+
* collapse lives here (2026-09-04). Every host reaches the profiler through this method -
|
|
130
|
+
* the visual's buildIndex, ingest's decoders, the MCP client - so a rule applied here is
|
|
131
|
+
* applied on every surface with no host edit at all.
|
|
132
|
+
*
|
|
133
|
+
* IT HAS TO BE THIS SEAM AND NOT THE SHAPE. The name is not a label, it is a KEY: the same
|
|
134
|
+
* list feeds the shape the server gates on, the prompt the model reads, and `toObjectArray`
|
|
135
|
+
* / `getCSVAsync`, whose keys the generated code indexes by. Collapsing it anywhere later
|
|
136
|
+
* would rename the column in the prompt and leave the data holding the old key, and the
|
|
137
|
+
* chart would draw nothing. Renaming here keeps all four in step by construction.
|
|
138
|
+
*
|
|
139
|
+
* A COLLISION IS LEFT ALONE. Bind `Sum of Revenue` as a dimension and Sum() it as a measure
|
|
140
|
+
* and the host hands us `Sum of Revenue` and `Sum of Sum of Revenue`; collapsing the second
|
|
141
|
+
* onto the first would silently merge two columns into one key and drop a column's data.
|
|
142
|
+
* The host's name wins in that case - an ugly name is a far smaller harm than a lost column.
|
|
143
|
+
*
|
|
144
|
+
* Idempotent (a collapsed name has nothing left to collapse), so the matrix-recovery path's
|
|
145
|
+
* repeated setColumns calls are safe.
|
|
146
|
+
*/
|
|
113
147
|
setColumns(cols: LLMColumnWithValue[]): void;
|
|
114
148
|
}
|
package/dist/types/models.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/shape-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.66",
|
|
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-GQJJUIZ7.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 ut}from"./chunk-QEH7WTLB.mjs";import{a as lt,b as ct}from"./chunk-2LR73DNS.mjs";import{a as mt,b as ft,c as Y}from"./chunk-KQVI7FDN.mjs";import{c as at}from"./chunk-SAASSIJ7.mjs";import{b as rt,f as ot}from"./chunk-E6SVTFAW.mjs";import{a as nt,b as it,c as st}from"./chunk-WBEROMBG.mjs";var _t=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],St=[7,72,-172,-52];function dt(r,t,n){return r>=n[0]&&r<=n[1]&&t>=n[2]&&t<=n[3]}function q(r,t){if(!r.length)return NaN;if(r.length===1)return r[0];let n=(r.length-1)*t,s=Math.floor(n),u=Math.ceil(n);return s===u?r[s]:r[s]+(r[u]-r[s])*(n-s)}var K=r=>Math.round(r*10)/10;function gt(r,t=3){let n=[],s=[],u=0,i=0;for(let l of r){let f=l?.lat,d=l?.lon;if(typeof f!="number"||typeof d!="number"||!isFinite(f)||!isFinite(d)||f<-90||f>90||d<-180||d>180)continue;n.push(f),s.push(d);let C=l?.country?String(l.country).trim().toUpperCase():"",b=C?j(C):null;b?((C==="US"||C==="USA")&&u++,b==="north-america"&&i++):(_t.some(P=>dt(f,d,P))&&u++,dt(f,d,St)&&i++)}let a=n.length;return a<t?null:(n.sort((l,f)=>l-f),s.sort((l,f)=>l-f),{pctUsa:K(u/a*100),pctNa:K(i/a*100),latP5:K(q(n,.05)),latP95:K(q(n,.95)),lonP5:K(q(s,.05)),lonP95:K(q(s,.95)),n:a})}var ht={"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"},X=(()=>{let r=new Map;for(let t of Object.keys(ht))for(let n of ht[t].split(/\s+/))n&&r.set(n,t);return r})();function Ct(r){for(let[t,n]of r){let s=X.get(t);s&&!X.has(n)&&X.set(n,s)}}Ct(rt);function j(r){if(!r)return null;let t=String(r).trim().toUpperCase();if(!t)return null;let n=X.get(t);if(n)return n;let s=ot(String(r));return s?X.get(s)??null:null}function Kt(r,t=2){return J(r.map(n=>[n,1]),t)}function J(r,t=2){let n=new Map,s=0;for(let[a,l]of r){let f=j(a);if(!f)continue;let d=typeof l=="number"&&isFinite(l)&&l>0?l:1;n.set(f,(n.get(f)??0)+d),s+=d}if(s<t||!n.size)return null;let u="europe",i=-1;for(let a of Array.from(n.keys()).sort()){let l=n.get(a);l>i&&(u=a,i=l)}return{dominantGeoRegion:u,dominantGeoRegionPct:K(i/s*100),regionCount:n.size,n:s}}import pt from"papaparse";var Tt=12,Rt=100,Nt=.3,It=.9,At=120,wt=1900,Dt=2100,vt=0,Et=20,xt=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Lt(r){if(!r)return!1;let t=r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(n=>n.length>0);return t.length===0?!1:xt.has(t[t.length-1])}var Pt=/\b(year|yr|fy|fiscal\s*year|calendar\s*year)\b/i,Ot=/^(?:(?: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 Q(r){if(!Number.isInteger(r)||r<190001||r>210012)return!1;let t=r%100;return t>=1&&t<=12}function tt(r){if(!Number.isInteger(r)||r<19000101||r>21001231)return!1;let t=Math.floor(r/100)%100,n=r%100;return t>=1&&t<=12&&n>=1&&n<=31}var Gt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Wt=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Vt=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Ft(r){let t=(r||"").toLowerCase();return t==="en-us"||t==="en"||t.startsWith("en-us-")||t==="en-ph"||t==="en-bz"}function Mt(r,t){let n=0,s=0,u=0,i=0,a=0,l="",f=0,d="",C=0,b=0,P=0,h=0,N=!1;for(let k of r){if(k==null)continue;let U=String(k).trim();if(U==="")continue;n++;let O;if(O=Gt.exec(U)){let W=+O[2],e=+O[3];W>=1&&W<=12&&e>=1&&e<=31&&(s++,O[4]!==void 0&&u++,O[6]!==void 0&&i++)}else if(O=Wt.exec(U)){let W=+O[3],e=+O[4];W>=1&&W<=12&&e>=1&&e<=31&&(l&&l!==O[2]&&(N=!0),l=O[2],a++)}else if(O=Vt.exec(U)){let W=+O[1],e=+O[3];W>=1&&W<=31&&e>=1&&e<=31&&(W<=12||e<=12)&&(d&&d!==O[2]&&(N=!0),d=O[2],f++,W>12&&P++,e>12&&h++,O[5]!==void 0&&C++,O[7]!==void 0&&b++)}if(n>=200)break}if(n<2||(s+a+f)/n<.8||(s>0?1:0)+(a>0?1:0)+(f>0?1:0)!==1||N)return null;if(s>0)return u===s?{pattern:i===s?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(a>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(P>0&&h>0)return null;let x,D;P>0?(x=!0,D="values"):h>0?(x=!1,D="values"):(x=!Ft(t),D="locale");let B=x?`%d${d}%m${d}%Y`:`%m${d}%d${d}%Y`;return C===f?{pattern:B+(b===f?" %H:%M:%S":" %H:%M"),orderFrom:D}:{pattern:B,orderFrom:D}}function Bt(r,t){if(!t||!/\b(?:19|20)\d{2}\b/.test(r))return!1;let n=r.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!n)return!1;let s=lt(n);return s.length>0&&t[s]!==void 0}function Ut(r){let{dataType:t,name:n,isMeasure:s,distinctCount:u}=r;if(t==="DateTime")return!0;if(s)return!1;if(t==="Integer"||t==="Decimal"){let i=r.minNum,a=r.maxNum;if(!(i!=null&&a!=null&&Number.isFinite(i)&&Number.isFinite(a)&&Number.isInteger(i)&&Number.isInteger(a)&&a>=i))return!1;let f=i>=1900&&a<=2100;if(f&&u>=2&&Pt.test(n)||f&&u>=3&&u===a-i+1)return!0;let d=Q(i)&&Q(a),C=tt(i)&&tt(a);if(d||C){if(!r.sampleValues)return!0;let b=0,P=0;for(let h of r.sampleValues){if(h==null||h==="")continue;b++;let N=Number(String(h).trim());if(Number.isFinite(N)&&(d?Q(N):tt(N))&&P++,b>=60)break}if(b>=2&&P===b)return!0}return!1}if(r.sampleValues){let i=r.locale?ct(r.locale):null,a=0,l=0,f=[];for(let d of r.sampleValues){if(d==null||d==="")continue;a++;let C=String(d).trim();if(f.push(C),(Ot.test(C)||Bt(C,i))&&l++,a>=60)break}if(a>=2&&l/a>=.8||Mt(f,r.locale)!==null)return!0}return!1}function zt(r){let t=(r||"").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 kt(r){let{rows:t,measureColIdx:n,measureName:s,candidateDims:u,minNum:i,maxNum:a,discourageAgg:l}=r,f=100,d=.01,C="";for(let P of u){if(P.distinct<2||P.distinct>f)continue;let h=u.filter(D=>D.idx!==P.idx).map(D=>D.idx),N=new Map;for(let D of t){let B=D[n];if(typeof B!="number"||!Number.isFinite(B))continue;let k=h.length?h.map(O=>String(D[O])).join(C):"",U=N.get(k);U||(U={sum:0,cset:new Set},N.set(k,U)),U.sum+=B,U.cset.add(String(D[P.idx]))}let I=0,A=0,x=0;for(let D of N.values())D.cset.size<2||(x++,Math.abs(D.sum-100)<=100*d?I++:Math.abs(D.sum-1)<=1*d&&A++);if(x>=2&&(I/x>=.9||A/x>=.9))return{additivity:"part_of_whole",partOfWholeDim:P.name}}if(l)return{additivity:"intensive_rate"};let b=zt(s);return b==="avg"||b==="min"||b==="max"?{additivity:"intensive_rate"}:b==="count"?{additivity:"additive"}:b==="sum"?{additivity:"unknown"}:i!=null&&a!=null&&Number.isFinite(i)&&Number.isFinite(a)&&i>=0&&a<=1.0001&&a>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function bt(r){let{dataType:t,isMeasure:n,name:s,distinct:u,nonblank:i,prec:a,maxval:l,minval:f}=r,d=l-f+1,C=d>0?u/d:1,b=i>0?u/i:0,P=t==="Decimal"||a>0;return Lt(s)?"Categorical":C>=It&&(nt(s)&&u<=At||f>=wt&&l<=Dt||f>=vt&&l<=Et)?"Ordinal":n||u>Tt&&(P||u>=Rt||b>=Nt)?"Continuous":"Categorical"}var yt=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;STR(t){return t==null?"":t.toString()}getPrecision(t){if(!isFinite(t))return 0;let s=t.toString().split(".")[1];return s?s.length:0}getColumns(){return this._cols}hasTimeComponent(t){return!(t instanceof Date)||isNaN(t.getTime())?!1:t.getHours()!==0||t.getMinutes()!==0||t.getSeconds()!==0||t.getMilliseconds()!==0}getColumnsWithStats(t,n){if(this._computedStatsForLevel==t)return this._cols;let s=0,u=parseInt(t),i=[];for(let e of this._cols){let c=new Map,v=[],p=0,o=0,M=0,_=null,y=null,g=null,R=!1,E=!0,w=!0,L=null,G=!1;for(let T of this._rows){let m=T[s],S=this.STR(m);if(S!=""){if(p+=S.length,c.set(S,(c.get(S)||0)+1),o++,e.dataType=="Integer"||e.dataType=="Decimal"||e.dataType=="DateTime")if((_===null||m<_)&&(_=m),(y===null||m>y)&&(y=m),e.dataType=="Integer"||e.dataType=="Decimal"){if(g===null?g=m:g+=m,e.dataType=="Decimal"){let V=this.getPrecision(m);V>M&&(M=V)}v.push(m)}else R=R||this.hasTimeComponent(m);G&&(m<L?E=!1:m>L&&(w=!1)),L=m,G=!0}}if(o>=3&&(E&&!w?e.sortedDirection="asc":w&&!E?e.sortedDirection="desc":e.sortedDirection="none"),o>0&&c.size>0&&!e.isMeasure){let T=0,m=Number.MAX_SAFE_INTEGER;for(let S of c.values())S>T&&(T=S),S<m&&(m=S);if(e.modalShare=T/o,e.minGroupCount=m===Number.MAX_SAFE_INTEGER?null:m,c.size===2){let S=[...c.keys()].map(F=>mt(F).trim().toLowerCase()).sort(),H=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(F=>S[0]===F[0]&&S[1]===F[1]),z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(e.name);(H||z)&&(e.isBinaryFlag=!0)}}if(e.dataType=="DateTime"&&(e.dateWithTime=R),e.isTemporal=Ut({dataType:e.dataType,name:e.name,isMeasure:e.isMeasure,distinctCount:c.size,minNum:typeof _=="number"?_:null,maxNum:typeof y=="number"?y:null,sampleValues:c.keys(),locale:n}),e.isTemporal&&e.dataType==="String"&&!e.isMeasure){let T=Mt(c.keys(),n);T&&(e.temporalTextPattern=T.pattern)}this.updateColumnStats10(u,e,o,c,M,y,_),this.updateColumnStats20(u,v,o,g,e,p,R,_,y,M,c,n),!e.isMeasure&&(e.dataType==="Integer"||e.dataType==="Decimal")&&bt({dataType:e.dataType,isMeasure:!1,name:e.name,distinct:c.size,nonblank:o,prec:M,maxval:typeof y=="number"?y:0,minval:typeof _=="number"?_:0})==="Continuous"&&(e.isMeasure=!0,e.geoKind=void 0,e.geoMatchPct=void 0,e.geoAmbiguous=void 0,e.dominantGeoRegion=void 0,e.dominantGeoRegionPct=void 0,e.geoRegionCount=void 0),i[s]=e.isMeasure||c.size>2e3?null:new Set(c.keys()),s++}let a=[];this._cols.forEach((e,c)=>{e.isMeasure||a.push({idx:c,distinct:e.distinctCount??0,name:e.name})}),this._cols.forEach((e,c)=>{if(!e.isMeasure)return;let v=typeof e.lowValue=="number"?e.lowValue:null,p=typeof e.highValue=="number"?e.highValue:null,o=kt({rows:this._rows,measureColIdx:c,measureName:e.name,candidateDims:a,minNum:v,maxNum:p,discourageAgg:!!e.discourageAggregationAcrossGroups});e.additivity=o.additivity,o.partOfWholeDim&&(e.partOfWholeDim=o.partOfWholeDim)});let l=50,f=a.filter(e=>e.distinct>=2&&e.distinct<=l);this._cols.forEach((e,c)=>{if(!e.isMeasure)return;let v=[];for(let m of this._rows){let S=m[c];if(S==null||S==="")continue;let V=typeof S=="number"?S:parseFloat(S);isNaN(V)||v.push(V)}if(v.length===0)return;let p=[...v].sort((m,S)=>m-S),o=m=>p[Math.min(p.length-1,Math.max(0,Math.floor(m*(p.length-1))))],M=o(.5),_=o(.1),y=o(.9),g=Math.abs(M)>1e-9?Math.abs(M):Math.abs(p[p.length-1])>1e-9?Math.abs(p[p.length-1]):1;e.relativeDispersion=Math.round((y-_)/g*1e3)/1e3;let R=0;for(let m of v)R+=m;R/=v.length;let E=0;for(let m of v)E+=(m-R)*(m-R);if(E<=1e-12)return;let w=[],L=[],G=m=>{if(m.length<4)return NaN;let S=[...m].sort((H,z)=>H-z),V=H=>S[Math.min(S.length-1,Math.max(0,Math.floor(H*(S.length-1))))];return V(.75)-V(.25)},T=G(v);for(let m of f){let S=new Map;for(let z of this._rows){let F=z[c];if(F==null||F==="")continue;let Z=typeof F=="number"?F:parseFloat(F);if(isNaN(Z))continue;let et=this.STR(z[m.idx])+"",$=S.get(et);$?($.s+=Z,$.n++,$.vals.push(Z)):S.set(et,{s:Z,n:1,vals:[Z]})}let V=0;for(let z of S.values()){let F=z.s/z.n;V+=z.n*(F-R)*(F-R)}w.push({otherColumn:m.name,eta2:Math.round(V/E*1e4)/1e4});let H=[];for(let z of S.values()){let F=G(z.vals);isNaN(F)||H.push(F)}if(H.length>=2&&isFinite(T)&&T>1e-9){let z=(Math.max(...H)-Math.min(...H))/T;L.push({otherColumn:m.name,spreadRatio:Math.round(z*1e4)/1e4})}}w.length>0&&(e.groupDiscrimination=w),L.length>0&&(e.spreadDiscrimination=L)});let d=.97,C=5,b=this._cols.map((e,c)=>({c:e,i:c})).filter(e=>e.c.isMeasure);for(let e=0;e<b.length;e++)for(let c=e+1;c<b.length;c++){let v=b[e].i,p=b[c].i,o=0,M=0,_=0,y=0,g=0,R=0;for(let G of this._rows){let T=G[v],m=G[p];if(T==null||T===""||m===null||m===void 0||m==="")continue;let S=typeof T=="number"?T:parseFloat(T),V=typeof m=="number"?m:parseFloat(m);isNaN(S)||isNaN(V)||(o++,M+=S,_+=V,y+=S*S,g+=V*V,R+=S*V)}if(o<C)continue;let E=o*y-M*M,w=o*g-_*_;if(E<=1e-12||w<=1e-12)continue;let L=(o*R-M*_)/Math.sqrt(E*w);if(Math.abs(L)>=d){let G=b[e].c,T=b[c].c;G.collinearWithMeasures||(G.collinearWithMeasures=[]),T.collinearWithMeasures||(T.collinearWithMeasures=[]),G.collinearWithMeasures.push(T.name),T.collinearWithMeasures.push(G.name)}}for(let e=0;e<this._cols.length;e++){let c=i[e];if(!c||c.size===0)continue;let v=[];for(let p=0;p<this._cols.length;p++){if(p===e)continue;let o=i[p];if(!o||o.size===0)continue;let M=0;for(let y of c)o.has(y)&&M++;let _=Math.round(M/c.size*100);_>0&&v.push({otherColumn:this._cols[p].name,percentShared:_})}v.length>0&&(this._cols[e].sharedValueRatioWithOthers=v)}let P=50,h=[];for(let e=0;e<this._cols.length;e++){let c=i[e];c&&c.size>=2&&c.size<=P&&h.push(e)}if(h.length>=2){let e=new Map,c=(p,o)=>p+":"+o;for(let p=0;p<h.length;p++)for(let o=p+1;o<h.length;o++)e.set(c(h[p],h[o]),new Map);for(let p of this._rows)for(let o=0;o<h.length;o++){let M=this.STR(p[h[o]])+"";for(let _=o+1;_<h.length;_++){let y=""+this.STR(p[h[_]]),g=e.get(c(h[o],h[_])),R=M+""+y;g.set(R,(g.get(R)??0)+1)}}let v=new Map;for(let p=0;p<h.length;p++)for(let o=p+1;o<h.length;o++){let M=h[p],_=h[o],y=i[M].size,g=i[_].size,R=e.get(c(M,_)),E=R.size,w=0;for(let m of R.values())(w===0||m<w)&&(w=m);let L=Math.round(E/(y*g)*100),G=E===y,T=E===g;if((this._cols[M].categoricalPairStats||=[]).push({otherColumn:this._cols[_].name,fillPct:L,determinesOther:G,minCellCount:w,distinctCombinations:E}),(this._cols[_].categoricalPairStats||=[]).push({otherColumn:this._cols[M].name,fillPct:L,determinesOther:T,minCellCount:w,distinctCombinations:E}),G&&y>g){let m=v.get(M);(!m||g<m.card)&&v.set(M,{name:this._cols[_].name,card:g,ratio:g/y})}if(T&&g>y){let m=v.get(_);(!m||y<m.card)&&v.set(_,{name:this._cols[M].name,card:y,ratio:y/g})}}for(let[p,o]of v)this._cols[p].primaryParentColumn=o.name,this._cols[p].nestingRatio=Math.round(o.ratio*100)/100}let N=6,I=this._rows.length;for(let e=0;e<this._cols.length;e++){let c=this._cols[e];if(c.isMeasure||c.primaryParentColumn)continue;let v=c.distinctCount??0;if(v<=P||I>0&&v>=I)continue;let p=[];for(let o=0;o<this._cols.length;o++){if(o===e)continue;let M=this._cols[o];if(M.isMeasure)continue;let _=M.distinctCount??0;_<2||_>=v||p.push(o)}p.sort((o,M)=>(this._cols[o].distinctCount??0)-(this._cols[M].distinctCount??0));for(let o of p.slice(0,N)){let M=new Map,_=!0;for(let g of this._rows){let R=this.STR(g[e])+"",E=this.STR(g[o])+"",w=M.get(R);if(w===void 0)M.set(R,E);else if(w!==E){_=!1;break}}if(!_)continue;let y=this._cols[o].distinctCount??0;c.primaryParentColumn=this._cols[o].name,c.nestingRatio=Math.round(y/v*100)/100;break}}let A=.01,x=.05,D=.95,B=8,k=8,U=6,O=500,W=[];for(let e=0;e<this._cols.length&&W.length<k;e++){let c=this._cols[e].dataType;(c==="Double"||c==="Integer"||c==="Decimal")&&W.push(e)}if(W.length>=3&&this._rows.length>=B){let e=Math.min(this._rows.length,O),c=W.map(y=>{let g=[];for(let w=0;w<e;w++){let L=this._rows[w][y],G=typeof L=="number"?L:parseFloat(String(L).replace(/,/g,""));if(L==null||L===""||!isFinite(G))return null;g.push(G)}let R=g[0],E=!1;for(let w of g)if(w!==R){E=!0;break}return E?g:null}),v=W.map((y,g)=>g).filter(y=>c[y]!==null),p=y=>{let g=y.slice().sort((E,w)=>E-w),R=g.length>>1;return g.length%2?g[R]:(g[R-1]+g[R])/2},o=null,M=[],_=y=>{if(M.length>=3){let g=M.map(L=>c[L]),R=g[0].length,E=new Array(R);for(let L=0;L<R;L++){let G=0;for(let T of g)G+=T[L];E[L]=G}let w=p(E);if(w>0){let L=0;for(let T of E)Math.abs(T-w)<=w*A&&L++;let G=L/R;if(G>=D){let T=1;for(let m of g){let S=p(m)/w;S<T&&(T=S)}T>=x&&(!o||M.length>o.cols.length)&&(o={cols:M.slice(),total:w,matched:G})}}}if(!(M.length>=U))for(let g=y;g<v.length;g++)M.push(v[g]),_(g+1),M.pop()};if(_(0),o){let y=o,R={columns:y.cols.map(E=>this._cols[W[E]].name),total:Math.round(y.total*1e3)/1e3,matchedPct:Math.round(y.matched*100)/100};for(let E of y.cols)this._cols[W[E]].constantSumGroup=R}}return this._computedStatsForLevel=t,this._cols}updateColumnStats20(t,n,s,u,i,a,l,f,d,C,b,P){if(t>=20){let h=[...n].sort((A,x)=>A-x),N=Math.floor(h.length/2);if(s>0&&u!=null?i.avgValue=i.dataType=="Integer"?Math.round(u/s):u/s:i.avgValue=null,s>0&&(i.avgLength=a/s),this._rows.length>0&&(i.dataType!="DateTime"||l||!f?i.lowValue=f:i.lowValue=new Date(f).toISOString().slice(0,10)+"T00:00:00.000Z",i.dataType!="DateTime"||l||!d?i.highValue=d:i.highValue=new Date(d).toISOString().slice(0,10)+"T00:00:00.000Z",i.medianValue=h.length===0?null:h.length%2===0?i.dataType=="Integer"?Math.round((h[N-1]+h[N])/2):(h[N-1]+h[N])/2:h[N],i.numericPrecision=C),h.length>0){let A=i.avgValue??0,x=h.length,D=0,B=0;for(let U of h){let O=U-A;D+=O*O,B+=O*O*O}let k=D/x;i.skewness=k===0?0:B/x/Math.pow(Math.sqrt(k),3),i.stdDev=Math.sqrt(k)}u!==null&&(i.sum=u);let I=Array.from(b.entries()).sort((A,x)=>x[1]-A[1]);if(i.topCategories=I.slice(0,10).map(A=>A[1]),!i.isMeasure&&I.length>0){if(i.dataType==="String"){let A=I.map(D=>D[0]);i.formatSignature=ut(A);let x=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;i.formatSignature&&!x.test(i.formatSignature)&&(i.avgLength===void 0||i.avgLength>=3)&&(i.isFreeText=!0)}else i.topCategoryValues=I.slice(0,5).map(A=>A[0]);if(t>=20){let A=I.map(D=>D[0]),x=st(A,P);if(x!==null)i.ordinalPattern=x.pattern,i.orderedDomain=x.orderedDomain;else if(i.dataType==="String"){let D=it(A);D!==null&&(i.safeDistinctValues=D)}}}if(h.length>=8&&(i.dataType==="Integer"||i.dataType==="Decimal")){let A=x=>h[Math.floor((h.length-1)*x)];i.quantiles={p05:A(.05),p25:A(.25),p75:A(.75),p95:A(.95)}}}if(!i.isMeasure&&b.size>0){let h=Array.from(b.entries()).sort((I,A)=>A[1]-I[1]),N=at(h.map(I=>I[0]),i.name,P);if(N!==null&&(i.geoKind=N.geoKind,i.geoMatchPct=N.geoMatchPct,N.geoAmbiguous&&(i.geoAmbiguous=!0),N.geoKind.indexOf("country")===0)){let I=J(h);I&&(i.dominantGeoRegion=I.dominantGeoRegion,i.dominantGeoRegionPct=I.dominantGeoRegionPct,i.geoRegionCount=I.regionCount)}}}updateColumnStats10(t,n,s,u,i,a,l){t>=10&&(n.blankCount=this._rows.length-s,n.distinctCount=u.size+(n.blankCount!=0?1:0),n.valueNature="Categorical",s>0&&(n.dataType==="Integer"||n.dataType==="Decimal"?n.valueNature=bt({dataType:n.dataType,isMeasure:!!n.isMeasure,name:n.name,distinct:u.size,nonblank:s,prec:i,maxval:a,minval:l}):n.dataType==="DateTime"&&(n.valueNature=n.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let t=[];if(this._cols.forEach((s,u)=>{s.isMeasure||t.push(u)}),t.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let n=new Set;for(let s of this._rows)n.add(JSON.stringify(t.map(u=>s[u])));return this._leafCardinality=n.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]+/),n=-1,s=-1,u=-1;if(this._cols.forEach((a,l)=>{let f=t(a.name),d=a.dataType==="Integer"||a.dataType==="Decimal";d&&n<0&&f.some(C=>C==="lat"||C==="latitude")?n=l:d&&s<0&&f.some(C=>C==="lon"||C==="lng"||C==="long"||C==="longitude")&&(s=l),u<0&&!a.isMeasure&&typeof a.geoKind=="string"&&a.geoKind.indexOf("country")===0&&(u=l)}),n<0||s<0)return null;let i=[];for(let a of this._rows){let l=a[n],f=a[s],d=l==null||l===""?null:Number(l),C=f==null||f===""?null:Number(f);i.push({lat:d,lon:C,country:u>=0&&j(this.STR(a[u]))?this.STR(a[u]):null})}return this._geoExtent=gt(i),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(t){let n="abcdefghijklmnopqrstuvwxyz",s=()=>n[Math.floor(Y()*n.length)],u=()=>s().toUpperCase(),i=()=>Math.floor(Y()*10).toString(),a=N=>/[A-Z]/.test(N)?u():/[a-z]/.test(N)?s():/[0-9]/.test(N)?i():N,l=t.includes("@")&&t.includes("."),f=l?t.split("@"):[t],d=l?f[1]:"",C=d.endsWith(".com"),b=C?".com":"",P=C?d.slice(0,-4):d,h=N=>{let I="";for(let A of N)I+=a(A),/[a-zA-Z0-9]/.test(A)&&Y()<.2&&(I+=a(A));if(I.length>6){let A=Math.floor(Y()*Math.min(3,I.length-6));for(let x=0;x<A;x++){let D=0;for(;D<5;){let B=Math.floor(Y()*I.length);if(/[a-zA-Z0-9]/.test(I[B])){I=I.slice(0,B)+I.slice(B+1);break}D++}}}return I};if(l){let N=h(f[0]),I=h(P);return`${N}@${I}${b}`}else return h(t)}toObjectArray(){return this._rows.map(t=>{let n={};return this._cols.forEach((s,u)=>{n[s.name]=t[u]}),n})}async getCSVAsync(t){let n=[],s=t?25:1e7,u=t?4e3:1e7,i=new Map;for(let l of this._rows){let f={};for(let d=0;d<this._cols.length;d++){let C=this._cols[d],b=l[d];if(this.STR(b)!=""){if(t&&C.dataType=="String")if(i.has(b))b=i.get(b);else{let P=this.obfuscateString(b);i.set(b,P),b=P}else C.dataType=="DateTime"&&!C.dateWithTime&&(b=new Date(b).toISOString().slice(0,10)+"T00:00:00.000Z");u-=this.STR(b).length}else b=null;f[d]=b,--u}if(n.push(f),--s,s<=0||u<=0)break}return await pt.unparse(n,{header:!1})}getCSVHeaderLine(){return pt.unparse([this._cols.map(t=>this.STR(t.name))])}addRow(t,n){if(this.dedupRows){let s="";for(let i of t)s+=this.STR(i)+"~";let u=ft(s);if(this._rowHashes.has(u))return!1;this._rowHashes.add(u)}return this._rows.push(t),this._origIndices.push(n??-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){this._cols=t}};export{gt as a,Ct as b,j as c,Kt as d,Lt as e,Mt as f,Ut as g,zt as h,kt as i,bt as j,yt as k};
|