@bicharts/shape-core 0.5.107 → 0.5.109

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.
@@ -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{D as S,x as b}from"./chunk-BZVL57QR.mjs";import{g as w}from"./chunk-GPX2G67N.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};
2
+ import{D as S,x as b}from"./chunk-SV3JH46V.mjs";import{h as w}from"./chunk-FUTSF2X5.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};
@@ -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 T(n){return n?n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(e=>e.length>0):[]}function y(n){return n!=null?n.toString():""}function D(n,e){if(!n.length)return NaN;if(n.length===1)return n[0];let t=(n.length-1)*e,r=Math.floor(t),o=Math.ceil(t);return r===o?n[r]:n[r]+(n[o]-n[r])*(t-r)}function m(n){if(!n)return 0;let e=0xcbf29ce484222325n,t=0x100000001b3n,r=e;for(let o=0;o<n.length;o++)r^=BigInt(n.charCodeAt(o)),r=r*t&0xFFFFFFFFFFFFFFFFn;return Number(r&0x1FFFFFFFFFFFFFn)}function d(){let n=typeof globalThis<"u"?globalThis:{};if(n.crypto&&typeof n.crypto.getRandomValues=="function"){let e=new Uint32Array(1);return n.crypto.getRandomValues(e),e[0]/4294967296}return Math.floor(Date.now()%4294967295)/4294967296}function h(n){return!!n&&n.isRefusal===!0}var x=30;function M(n){let e=Date.parse(n);if(isNaN(e))return null;let t=new Date(e);if(F.test(n)||g.test(n.trim())||p.test(n))return t;let r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())),o=t.getFullYear();return o>=0&&o<100&&r.setUTCFullYear(o),r}function a(n){return!(n instanceof Date)||isNaN(n.getTime())?null:n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0&&n.getUTCMilliseconds()===0?"utc":n.getHours()===0&&n.getMinutes()===0&&n.getSeconds()===0&&n.getMilliseconds()===0?"local":null}function R(n){let e=a(n);if(!e)return null;let t=n;if(e==="utc")return t.toISOString().slice(0,10);let r=o=>(o<10?"0":"")+o;return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}`}function c(n){let e=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate())),t=n.getFullYear();return t>=0&&t<100&&e.setUTCFullYear(t),e}function f(n,e){let t=[];for(let r of n){if(!r||!/date|time/i.test(String(r.dataType??"")))continue;let o=0,l=!0;for(let u of e){let i=u?u[r.name]:void 0;if(i==null||i==="")continue;if(!(i instanceof Date)){l=!1;break}let s=a(i);if(s===null){l=!1;break}s==="local"&&o++}l&&o>0&&t.push(r.name)}return t}function b(n,e){let t=f(n,e);return t.length===0?{rows:e,columns:t}:{rows:e.map(o=>{if(!o)return o;let l={...o};for(let u of t){let i=l[u];i instanceof Date&&a(i)==="local"&&(l[u]=c(i))}return l}),columns:t}}var F=/^\s*\d{4}(-\d{2}(-\d{2})?)?\s*$/,g=/(?:Z|[+-]\d{2}:?\d{2})$/i,p=/\b(?:GMT|UTC)\b/i;export{T as a,y as b,D as c,m as d,d as e,h as f,x as g,M as h,a as i,R as j,c as k,f as l,b as m};
@@ -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-GPX2G67N.mjs";var M=[{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"]}],v={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"},x=(()=>{let n=new Set;for(let e of M)for(let r of e.canonical)n.add(u(r));return n})(),q=(()=>{let n=new Map;for(let[e,r]of Object.entries(v)){let t=u(e);x.has(t)||n.has(t)||n.set(t,u(r))}return n})();function y(n){return q.get(n)??n}var D=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 F(n){if(!n)return!1;for(let e of h(n))if(D.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[r,t]of n)for(let a of r)e.set(u(a),t);return e}var w=[{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 S(n){let e=n||"";if(!e)return{weekday:new Map,month:new Map};let r=p[e];if(r)return r;let t=new Map,a=new Map,s=(i,l,m)=>{let d=u(l);d&&i.set(d,m);let c=u(l.replace(/\./g,""));c&&c!==d&&i.set(c,m)};try{let i=new Intl.DateTimeFormat(e,{weekday:"long"}),l=new Intl.DateTimeFormat(e,{weekday:"short"});for(let c=0;c<7;++c){let g=new Date(Date.UTC(2024,0,1+c));s(t,i.format(g),c),s(t,l.format(g),c)}let m=new Intl.DateTimeFormat(e,{month:"long"}),d=new Intl.DateTimeFormat(e,{month:"short"});for(let c=0;c<12;++c){let g=new Date(Date.UTC(2020,c,15));s(a,m.format(g),c),s(a,d.format(g),c)}}catch{}let o={weekday:t,month:a};return p[e]=o,o}function b(n,e){if(e.size===0)return n;let r=new Map(n);for(let[t,a]of e)r.has(t)||r.set(t,a);return r}function C(n,e){let r=S(e);for(let t of w){let a=t.name==="weekday_mon_sun"?b(t.dict,r.weekday):t.name==="month_jan_dec"?b(t.dict,r.month):t.dict,s=!0,o=new Map;for(let[l,m]of n){let d=a.get(l);if(d===void 0){s=!1;break}o.has(d)||o.set(d,m)}if(!s||o.size<t.minMatches)continue;let i=[...o.entries()].sort((l,m)=>l[0]-m[0]).map(l=>l[1]);return{pattern:t.name,orderedDomain:i}}return null}function _(n){let e=new Map;for(let r of n){if(r==null)continue;let t=String(r);if(t.length===0)continue;let a=u(t);e.has(a)||e.set(a,t)}return e}var O=15,N=10,R=(()=>{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 r of w)for(let t of r.dict.keys())e.add(t);return e})();function A(n){let e=n.trim();return e.length===0||e.length>N||(e.match(/\p{L}/gu)||[]).length>1?!1:/\p{Nd}/u.test(e)}function T(n){let e=n.trim();return e.length===1&&/[\p{L}\p{Nd}]/u.test(e)}function z(n){if(!n||n.length===0)return null;let e=new Set,r=[];for(let t of n){if(t==null)continue;let a=String(t);if(e.has(a))continue;let s=u(a);if(!(s===""||R.has(s)||A(a)||T(a))||(e.add(a),r.push(a),r.length>O))return null}return r.length>0?r:null}var L=/^(\p{L}{0,3}) ?([0-9]+)\s*[-–—:.)]\s*(.+)$/u;function I(n){let e=null,r=new Set,t=[];for(let a of n.values()){let s=L.exec(a.trim());if(!s)return null;let o=s[1].toLowerCase();if(e===null)e=o;else if(o!==e)return null;let i=Number(s[2]);if(r.has(i)||u(s[3])==="")return null;r.add(i),t.push({code:i,original:a,label:s[3]})}return t}function E(n,e){let r=k(_(n.map(i=>i.label)),e);if(r===null)return;if(r.orderedDomain.length!==n.length)return null;let t=new Map;for(let i of n)t.set(i.label,i);let a=r.orderedDomain.map(i=>t.get(i));if(a.some(i=>i===void 0))return null;let s=!0,o=!0;for(let i=1;i<a.length;++i)a[i].code<=a[i-1].code&&(s=!1),a[i].code>=a[i-1].code&&(o=!1);return!s&&!o?null:{pattern:r.pattern,orderedDomain:a.map(i=>i.original)}}function P(n,e){if(!n||n.length<2)return null;let r=_(n);if(r.size<2)return null;let t=I(r);if(t!==null){let a=E(t,e);if(a!==void 0)return a}return k(r,e)}function k(n,e){let r=new Map;for(let[a,s]of n){let o=y(a);r.has(o)||r.set(o,s)}let t=null;for(let a of M){let s=[];for(let m of a.canonical){let d=r.get(m);d!==void 0&&s.push(d)}if(s.length<a.minMatches)continue;let o=new Set(a.canonical),i=!0;for(let m of n.keys())if(!o.has(y(m))){i=!1;break}if(!i)continue;let l;t===null||s.length>t.matched||s.length===t.matched&&a.canonical.length<t.pattern.canonical.length?l=!0:l=!1,l&&(t={pattern:a,matched:s.length,orderedDomain:s})}return t?{pattern:t.pattern.name,orderedDomain:t.orderedDomain}:C(n,e)}export{F as a,z as b,P as c};
2
+ import{a as h}from"./chunk-FUTSF2X5.mjs";var M=[{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"]}],v={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"},x=(()=>{let n=new Set;for(let e of M)for(let r of e.canonical)n.add(u(r));return n})(),q=(()=>{let n=new Map;for(let[e,r]of Object.entries(v)){let t=u(e);x.has(t)||n.has(t)||n.set(t,u(r))}return n})();function y(n){return q.get(n)??n}var D=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 F(n){if(!n)return!1;for(let e of h(n))if(D.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[r,t]of n)for(let a of r)e.set(u(a),t);return e}var w=[{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 S(n){let e=n||"";if(!e)return{weekday:new Map,month:new Map};let r=p[e];if(r)return r;let t=new Map,a=new Map,s=(i,l,m)=>{let d=u(l);d&&i.set(d,m);let c=u(l.replace(/\./g,""));c&&c!==d&&i.set(c,m)};try{let i=new Intl.DateTimeFormat(e,{weekday:"long"}),l=new Intl.DateTimeFormat(e,{weekday:"short"});for(let c=0;c<7;++c){let g=new Date(Date.UTC(2024,0,1+c));s(t,i.format(g),c),s(t,l.format(g),c)}let m=new Intl.DateTimeFormat(e,{month:"long"}),d=new Intl.DateTimeFormat(e,{month:"short"});for(let c=0;c<12;++c){let g=new Date(Date.UTC(2020,c,15));s(a,m.format(g),c),s(a,d.format(g),c)}}catch{}let o={weekday:t,month:a};return p[e]=o,o}function b(n,e){if(e.size===0)return n;let r=new Map(n);for(let[t,a]of e)r.has(t)||r.set(t,a);return r}function C(n,e){let r=S(e);for(let t of w){let a=t.name==="weekday_mon_sun"?b(t.dict,r.weekday):t.name==="month_jan_dec"?b(t.dict,r.month):t.dict,s=!0,o=new Map;for(let[l,m]of n){let d=a.get(l);if(d===void 0){s=!1;break}o.has(d)||o.set(d,m)}if(!s||o.size<t.minMatches)continue;let i=[...o.entries()].sort((l,m)=>l[0]-m[0]).map(l=>l[1]);return{pattern:t.name,orderedDomain:i}}return null}function _(n){let e=new Map;for(let r of n){if(r==null)continue;let t=String(r);if(t.length===0)continue;let a=u(t);e.has(a)||e.set(a,t)}return e}var O=15,N=10,R=(()=>{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 r of w)for(let t of r.dict.keys())e.add(t);return e})();function A(n){let e=n.trim();return e.length===0||e.length>N||(e.match(/\p{L}/gu)||[]).length>1?!1:/\p{Nd}/u.test(e)}function T(n){let e=n.trim();return e.length===1&&/[\p{L}\p{Nd}]/u.test(e)}function z(n){if(!n||n.length===0)return null;let e=new Set,r=[];for(let t of n){if(t==null)continue;let a=String(t);if(e.has(a))continue;let s=u(a);if(!(s===""||R.has(s)||A(a)||T(a))||(e.add(a),r.push(a),r.length>O))return null}return r.length>0?r:null}var L=/^(\p{L}{0,3}) ?([0-9]+)\s*[-–—:.)]\s*(.+)$/u;function I(n){let e=null,r=new Set,t=[];for(let a of n.values()){let s=L.exec(a.trim());if(!s)return null;let o=s[1].toLowerCase();if(e===null)e=o;else if(o!==e)return null;let i=Number(s[2]);if(r.has(i)||u(s[3])==="")return null;r.add(i),t.push({code:i,original:a,label:s[3]})}return t}function E(n,e){let r=k(_(n.map(i=>i.label)),e);if(r===null)return;if(r.orderedDomain.length!==n.length)return null;let t=new Map;for(let i of n)t.set(i.label,i);let a=r.orderedDomain.map(i=>t.get(i));if(a.some(i=>i===void 0))return null;let s=!0,o=!0;for(let i=1;i<a.length;++i)a[i].code<=a[i-1].code&&(s=!1),a[i].code>=a[i-1].code&&(o=!1);return!s&&!o?null:{pattern:r.pattern,orderedDomain:a.map(i=>i.original)}}function P(n,e){if(!n||n.length<2)return null;let r=_(n);if(r.size<2)return null;let t=I(r);if(t!==null){let a=E(t,e);if(a!==void 0)return a}return k(r,e)}function k(n,e){let r=new Map;for(let[a,s]of n){let o=y(a);r.has(o)||r.set(o,s)}let t=null;for(let a of M){let s=[];for(let m of a.canonical){let d=r.get(m);d!==void 0&&s.push(d)}if(s.length<a.minMatches)continue;let o=new Set(a.canonical),i=!0;for(let m of n.keys())if(!o.has(y(m))){i=!1;break}if(!i)continue;let l;t===null||s.length>t.matched||s.length===t.matched&&a.canonical.length<t.pattern.canonical.length?l=!0:l=!1,l&&(t={pattern:a,matched:s.length,orderedDomain:s})}return t?{pattern:t.pattern.name,orderedDomain:t.orderedDomain}:C(n,e)}export{F as a,z as b,P 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-GPX2G67N.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)&&lt.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)&&lt.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};
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-FUTSF2X5.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)&&lt.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)&&lt.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};
@@ -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 pe}from"./chunk-QEH7WTLB.mjs";import{a as he,b as be}from"./chunk-2LR73DNS.mjs";import{c as ge}from"./chunk-OZEOA6ZE.mjs";import{b as de,f as fe}from"./chunk-E6SVTFAW.mjs";import{a as le,b as ce,c as me}from"./chunk-N3ZYRMZJ.mjs";import{a as j,b as oe,c as B,d as ae,e as X,h as te,j as ue}from"./chunk-FUTSF2X5.mjs";var ze=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Ue=[7,72,-172,-52];function ye(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var K=n=>Math.round(n*10)/10;function Se(n,e=3){let t=[],i=[],a=0,r=0;for(let l of n){let u=l?.lat,m=l?.lon;if(typeof u!="number"||typeof m!="number"||!isFinite(u)||!isFinite(m)||u<-90||u>90||m<-180||m>180)continue;t.push(u),i.push(m);let y=l?.country?String(l.country).trim().toUpperCase():"",C=y?ee(y):null;C?((y==="US"||y==="USA")&&a++,C==="north-america"&&r++):(ze.some(O=>ye(u,m,O))&&a++,ye(u,m,Ue)&&r++)}let o=t.length;return o<e?null:(t.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:K(a/o*100),pctNa:K(r/o*100),latP5:K(B(t,.05)),latP95:K(B(t,.95)),lonP5:K(B(i,.05)),lonP95:K(B(i,.95)),n:o})}var _e={"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"},q=(()=>{let n=new Map;for(let e of Object.keys(_e))for(let t of _e[e].split(/\s+/))t&&n.set(t,e);return n})();function Ve(n){for(let[e,t]of n){let i=q.get(e);i&&!q.has(t)&&q.set(t,i)}}Ve(de);function ee(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=q.get(e);if(t)return t;let i=fe(String(n));return i?q.get(i)??null:null}function Ft(n,e=2){return ne(n.map(t=>[t,1]),e)}function ne(n,e=2){let t=new Map,i=0;for(let[o,l]of n){let u=ee(o);if(!u)continue;let m=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(u,(t.get(u)??0)+m),i+=m}if(i<e||!t.size)return null;let a="europe",r=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>r&&(a=o,r=l)}return{dominantGeoRegion:a,dominantGeoRegionPct:K(r/i*100),regionCount:t.size,n:i}}import Pe from"papaparse";var Be=["rate","ratio","pct","percent","percentage","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","z[_-]?score","average","avg","mean","median","stddev","variance","gpa","percentile","quantile","efficiency","accuracy","probability","multiplier","coefficient","correlation","occupancy","age","bmi","temperature","density","pressure","humidity","ph","velocity","speed","elevation","altitude","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan"],Ye=["pct","percent","percentage","rate","ratio","rating","share","score","index","nps","csat","margin","yield","coverage","utilization","utilisation","gpa","percentile","quantile","bmi","density","pressure","humidity","velocity","efficiency","occupancy","latency","throughput","bandwidth","iops","ppm","ppb","dpmo","bps"],He=["latitude","longitude"],Ke=["latitude","longitude"];function $(n){return Array.from(n).map(e=>{let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===1?t:e}).join("")}var ie=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z"],Ce=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von"];function $e(n){return[...n].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ae=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+$e(ie)+")\\s+)","i"),Ze=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Xe=new RegExp("\\b("+Be.join("|")+")\\b|("+Ye.join("|")+")$","i"),je=new RegExp("\\b("+He.join("|")+")\\b|("+Ke.join("|")+")$","i");function Te(n){if(!n)return"";let e=String(n),t=Ae.exec($(e));return(t?e.slice(t[0].length):e).trim()}function qe(n){return!!n&&Ae.test($(String(n)))}var Qe=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Me=new RegExp("^\\s*("+[...Qe].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Re(n){if(n==null)return"";let e=String(n),t=Me.exec(e);if(!t)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),a=i(t[1]),r=e.slice(t[0].length),o=0;for(;o<8;){let l=Me.exec(r);if(!l||i(l[1])!==a)break;let u=r.slice(l[0].length);if(u.trim()==="")break;r=u,o++}return o===0?e:e.slice(0,t[0].length)+r}function Ut(n,e){if(!n||!e)return!1;let t=String(n);for(let i of e){let a=i?.hostName;if(a&&a!==i?.name&&t.includes(a))return!0}return!1}function Je(n){let e=Te(n);return e.length===0?"":e.replace(Ze," ")}function ve(n,e){if(!e)return!1;let t=Te(e);return n.test($(Je(e)))||n.test($(t))||n.test($(j(t).join(" ")))}function Ne(n){return ve(je,n)}function et(n){return ve(Xe,n)||Ne(n)}var xe=/int|double|decimal|single|float|number|currency|money/i;function tt(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||xe.test(String(n?.dataType??""))?"Continuous":"Categorical"}function nt(n){return n?.isMeasure===!0||xe.test(String(n?.dataType??""))}function Ie(n){let e=n??{},t=tt(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(Ne(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&qe(e.name))){if(i==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:et(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function Ee(n){let e=Ie(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return nt(t)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Vt(n){return Ee(n)[0]}function Bt(n,e){return Ee(n).indexOf(e)>=0}function Yt(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=Ie(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var Kt=5,$t=6;var it=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,rt=/^(\d{4})[-/](\d{1,2})$/,st=/^(\d{4})[-\s]?Q([1-4])$/i,ot=/^Q([1-4])[-\s](\d{4})$/i,at=/^(\d{4})$/,ut=/^(\d{4})(0[1-9]|1[0-2])$/,lt=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/;function Y(n,e,t,i=0,a=0,r=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,i,a,r);if(!Number.isFinite(o))return null;let l=u=>u<10?"0"+u:String(u);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function ct(n,e){let t=[],i="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){i+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){case"Y":t.push("Y"),i+="(\\d{4})";break;case"m":t.push("m"),i+="(\\d{1,2})";break;case"d":t.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let a=new RegExp("^"+i+"$").exec(n);if(!a)return null;let r=0,o=1,l=1;return t.forEach((u,m)=>{let y=+a[m+1];u==="Y"?r=y:u==="m"?o=y:l=y}),r?Y(r,o,l):null}function mt(n,e){let t=(n??"").trim();if(t==="")return null;if(e){let a=ct(t,e);return a||null}let i=it.exec(t);if(i)return Y(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=st.exec(t),i)return Y(+i[1],(+i[2]-1)*3+1,1);if(i=ot.exec(t),i)return Y(+i[2],(+i[1]-1)*3+1,1);if(i=rt.exec(t),i&&+i[2]>=1&&+i[2]<=12)return Y(+i[1],+i[2],1);if(i=lt.exec(t),i)return Y(+i[1],+i[2],+i[3]);if(i=ut.exec(t),i)return Y(+i[1],+i[2],1);if(i=at.exec(t),i){let a=+i[1];return a>=1900&&a<=2100?Y(a,1,1):null}return null}function De(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function Oe(n,e){if(e<=n)return 0;let t=Math.round((e-n)/864e5),i=Math.floor(t/7),a=i*5,r=n+i*7*864e5;for(;r<e;)De(r)&&a++,r+=864e5;return a}function dt(n){if(n.length===0)return 0;let e=[...n].sort((i,a)=>i-a),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function ft(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function we(n,e,t,i){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*864e5));case"weekday":return Oe(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/864e5);default:return i>0?Math.round((e.ms-n.ms)/i):0}}function Le(n,e){let t=e?.gapFactor??5,i=0,a=0,r=new Map;for(let f of n){if(f==null||f==="")continue;i++;let G=mt(String(f),e?.pattern);G&&(a++,r.set(G.ms,G))}let o=[...r.values()].sort((f,G)=>f.ms-G.ms);if(o.length<3||i>0&&a/i<.8)return null;let l=o[o.length-1].ms-o[0].ms;if(l<=0)return null;let u=[];for(let f=1;f<o.length;f++)u.push(o[f].ms-o[f-1].ms);let m=dt(u);if(!(m>0))return null;let y=ft(m/864e5);y==="day"&&l>=7*864e5&&o.every(f=>De(f.ms))&&Oe(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(y="weekday");let C=y==="irregular"?o.length:we(o[0],o[o.length-1],y,m)+1,O=1,E=1,A=[],I=o[0],g=1;for(let f=1;f<o.length;f++){let G=we(o[f-1],o[f],y,m);G>O&&(O=G),y!=="irregular"&&G>t?(E++,A.push({from:I.iso,to:o[f-1].iso,points:g}),I=o[f],g=1):g++}A.push({from:I.iso,to:o[o.length-1].iso,points:g});let x={grain:y,points:o.length,expectedPoints:Math.max(C,o.length),coveragePct:Math.round(o.length/Math.max(C,o.length)*1e3)/10,runs:E,largestGapUnits:O,gapFactor:t};return e?.includeBounds&&A.length<=6&&(x.runBounds=A),x}var gt=12,pt=100,ht=.3,bt=.9,yt=120,_t=1900,St=2100,Mt=0,Ct=20,At=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Tt(n){if(!n)return!1;let e=j(n);return e.length===0?!1:At.has(e[e.length-1])}var Rt=new Set(["year","yr","fy"]),vt=n=>j(n).some(e=>Rt.has(e)),Nt=/^(?:(?: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 re(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function se(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var xt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,It=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Et=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function wt(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function Fe(n,e){let t=0,i=0,a=0,r=0,o=0,l="",u=0,m="",y=0,C=0,O=0,E=0,A=!1;for(let V of n){if(V==null)continue;let W=String(V).trim();if(W==="")continue;t++;let k;if(k=xt.exec(W)){let z=+k[2],U=+k[3];z>=1&&z<=12&&U>=1&&U<=31&&(i++,k[4]!==void 0&&a++,k[6]!==void 0&&r++)}else if(k=It.exec(W)){let z=+k[3],U=+k[4];z>=1&&z<=12&&U>=1&&U<=31&&(l&&l!==k[2]&&(A=!0),l=k[2],o++)}else if(k=Et.exec(W)){let z=+k[1],U=+k[3];z>=1&&z<=31&&U>=1&&U<=31&&(z<=12||U<=12)&&(m&&m!==k[2]&&(A=!0),m=k[2],u++,z>12&&O++,U>12&&E++,k[5]!==void 0&&y++,k[7]!==void 0&&C++)}if(t>=200)break}if(t<2||(i+o+u)/t<.8||(i>0?1:0)+(o>0?1:0)+(u>0?1:0)!==1||A)return null;if(i>0)return a===i?{pattern:r===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(O>0&&E>0)return null;let x,f;O>0?(x=!0,f="values"):E>0?(x=!1,f="values"):(x=!wt(e),f="locale");let G=x?`%d${m}%m${m}%Y`:`%m${m}%d${m}%Y`;return y===u?{pattern:G+(C===u?" %H:%M:%S":" %H:%M"),orderFrom:f}:{pattern:G,orderFrom:f}}function Dt(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let i=he(t);return i.length>0&&e[i]!==void 0}function Ot(n){let{dataType:e,name:t,isMeasure:i,distinctCount:a}=n;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let r=n.minNum,o=n.maxNum;if(!(r!=null&&o!=null&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isInteger(r)&&Number.isInteger(o)&&o>=r))return!1;let u=r>=1900&&o<=2100;if(u&&a>=2&&vt(t)||u&&a>=3&&a===o-r+1)return!0;let m=re(r)&&re(o),y=se(r)&&se(o);if(m||y){if(!n.sampleValues)return!0;let C=0,O=0;for(let E of n.sampleValues){if(E==null||E==="")continue;C++;let A=Number(String(E).trim());if(Number.isFinite(A)&&(m?re(A):se(A))&&O++,C>=60)break}if(C>=2&&O===C)return!0}return!1}if(n.sampleValues){let r=n.locale?be(n.locale):null,o=0,l=0,u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;o++;let y=String(m).trim();if(u.push(y),(Nt.test(y)||Dt(y,r))&&l++,o>=60)break}if(o>=2&&l/o>=.8||Fe(u,n.locale)!==null)return!0}return!1}function Lt(n){let e=$((n||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":Ce.some(t=>e.startsWith(t+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":ie.some(t=>e.startsWith(t+" ")||e===t)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Pt(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:a,minNum:r,maxNum:o,discourageAgg:l}=n,u=100,m=.01,y="";for(let O of a){if(O.distinct<2||O.distinct>u)continue;let E=a.filter(f=>f.idx!==O.idx).map(f=>f.idx),A=new Map;for(let f of e){let G=f[t];if(typeof G!="number"||!Number.isFinite(G))continue;let V=E.length?E.map(k=>String(f[k])).join(y):"",W=A.get(V);W||(W={sum:0,cset:new Set},A.set(V,W)),W.sum+=G,W.cset.add(String(f[O.idx]))}let I=0,g=0,x=0;for(let f of A.values())f.cset.size<2||(x++,Math.abs(f.sum-100)<=100*m?I++:Math.abs(f.sum-1)<=1*m&&g++);if(x>=2&&(I/x>=.9||g/x>=.9))return{additivity:"part_of_whole",partOfWholeDim:O.name}}if(l)return{additivity:"intensive_rate"};let C=Lt(i);return C==="avg"||C==="min"||C==="max"?{additivity:"intensive_rate"}:C==="count"?{additivity:"additive"}:C==="sum"?{additivity:"unknown"}:r!=null&&o!=null&&Number.isFinite(r)&&Number.isFinite(o)&&r>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function Ge(n){let{dataType:e,isMeasure:t,name:i,distinct:a,nonblank:r,prec:o,maxval:l,minval:u}=n,m=l-u+1,y=m>0?a/m:1,C=r>0?a/r:0,O=e==="Decimal"||o>0;return Tt(i)?"Categorical":y>=bt&&(le(i)&&a<=yt||u>=_t&&l<=St||u>=Mt&&l<=Ct)?"Ordinal":t||a>gt&&(O||a>=pt||C>=ht)?"Continuous":"Categorical"}var ke=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}wholeDayIso(e){return ue(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let i=0,a=parseInt(e),r=[];for(let s of this._cols){let d=new Map,w=[],S=0,c=0,T=0,v=null,R=null,M=null,P=!1,L=!0,b=!0,_=null,N=!1;for(let p of this._rows){let h=p[i],D=this.STR(h);if(D!=""){if(S+=D.length,d.set(D,(d.get(D)||0)+1),c++,s.dataType=="Integer"||s.dataType=="Decimal"||s.dataType=="DateTime")if((v===null||h<v)&&(v=h),(R===null||h>R)&&(R=h),s.dataType=="Integer"||s.dataType=="Decimal"){if(M===null?M=h:M+=h,s.dataType=="Decimal"){let F=this.getPrecision(h);F>T&&(T=F)}w.push(h)}else P=P||this.hasTimeComponent(h);N&&(h<_?L=!1:h>_&&(b=!1)),_=h,N=!0}}if(c>=3&&(L&&!b?s.sortedDirection="asc":b&&!L?s.sortedDirection="desc":s.sortedDirection="none"),c>0&&d.size>0&&!s.isMeasure){let p=0,h=Number.MAX_SAFE_INTEGER;for(let D of d.values())D>p&&(p=D),D<h&&(h=D);if(s.modalShare=p/c,s.minGroupCount=h===Number.MAX_SAFE_INTEGER?null:h,d.size===2){let D=[...d.keys()].map(J=>oe(J).trim().toLowerCase()).sort(),Q=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(J=>D[0]===J[0]&&D[1]===J[1]),Z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(s.name);(Q||Z)&&(s.isBinaryFlag=!0)}}if(s.dataType=="DateTime"&&(s.dateWithTime=P),s.isTemporal=Ot({dataType:s.dataType,name:s.name,isMeasure:s.isMeasure,distinctCount:d.size,minNum:typeof v=="number"?v:null,maxNum:typeof R=="number"?R:null,sampleValues:d.keys(),locale:t}),s.isTemporal&&s.dataType==="String"&&!s.isMeasure){let p=Fe(d.keys(),t);p&&(s.temporalTextPattern=p.pattern)}if(s.isTemporal&&!s.isMeasure){let p=Le(d.keys(),{includeBounds:a>=20,pattern:s.temporalTextPattern});p&&(s.temporalCadence=p)}this.updateColumnStats10(a,s,c,d,T,R,v),this.updateColumnStats20(a,w,c,M,s,S,P,v,R,T,d,t),!s.isMeasure&&(s.dataType==="Integer"||s.dataType==="Decimal")&&Ge({dataType:s.dataType,isMeasure:!1,name:s.name,distinct:d.size,nonblank:c,prec:T,maxval:typeof R=="number"?R:0,minval:typeof v=="number"?v:0})==="Continuous"&&(s.isMeasure=!0,s.geoKind=void 0,s.geoMatchPct=void 0,s.geoAmbiguous=void 0,s.dominantGeoRegion=void 0,s.dominantGeoRegionPct=void 0,s.geoRegionCount=void 0),r[i]=s.isMeasure||d.size>2e3?null:new Set(d.keys()),i++}let o=[];this._cols.forEach((s,d)=>{s.isMeasure||o.push({idx:d,distinct:s.distinctCount??0,name:s.name})}),this._cols.forEach((s,d)=>{if(!s.isMeasure)return;let w=typeof s.lowValue=="number"?s.lowValue:null,S=typeof s.highValue=="number"?s.highValue:null,c=Pt({rows:this._rows,measureColIdx:d,measureName:s.name,candidateDims:o,minNum:w,maxNum:S,discourageAgg:!!s.discourageAggregationAcrossGroups});s.additivity=c.additivity,c.partOfWholeDim&&(s.partOfWholeDim=c.partOfWholeDim)});let l=50,u=4,m=o.filter(s=>s.distinct>=2&&s.distinct<=l);this._cols.forEach((s,d)=>{if(!s.isMeasure)return;let w=[];for(let b of this._rows){let _=b[d];if(_==null||_==="")continue;let N=typeof _=="number"?_:parseFloat(_);isNaN(N)||w.push(N)}if(w.length===0)return;let S=[...w].sort((b,_)=>b-_);if(S[0]===S[S.length-1])s.relativeDispersion=0;else if(S.length>=u){let b=B(S,.5),_=B(S,.1),N=B(S,.9),p=Math.abs(b)>1e-9?Math.abs(b):Math.abs(S[S.length-1])>1e-9?Math.abs(S[S.length-1]):1;s.relativeDispersion=Math.round((N-_)/p*1e3)/1e3}else s.relativeDispersion=void 0;let c=[];for(let b of m){let _=new Set;for(let N of this._rows){let p=N[d];p==null||p===""||_.add(this.STR(N[b.idx])+"")}c.push({otherColumn:b.name,nonBlankGroupCount:_.size})}c.length>0&&(s.nonBlankGroups=c);let T=0;for(let b of w)T+=b;T/=w.length;let v=0;for(let b of w)v+=(b-T)*(b-T);if(v<=1e-12)return;let R=[],M=[],P=b=>{if(b.length<4)return NaN;let _=[...b].sort((p,h)=>p-h),N=p=>_[Math.min(_.length-1,Math.max(0,Math.floor(p*(_.length-1))))];return N(.75)-N(.25)},L=P(w);for(let b of m){let _=new Map;for(let h of this._rows){let D=h[d];if(D==null||D==="")continue;let F=typeof D=="number"?D:parseFloat(D);if(isNaN(F))continue;let Q=this.STR(h[b.idx])+"",Z=_.get(Q);Z?(Z.s+=F,Z.n++,Z.vals.push(F)):_.set(Q,{s:F,n:1,vals:[F]})}let N=0;for(let h of _.values()){let D=h.s/h.n;N+=h.n*(D-T)*(D-T)}R.push({otherColumn:b.name,eta2:Math.round(N/v*1e4)/1e4});let p=[];for(let h of _.values()){let D=P(h.vals);isNaN(D)||p.push(D)}if(p.length>=2&&isFinite(L)&&L>1e-9){let h=(Math.max(...p)-Math.min(...p))/L;M.push({otherColumn:b.name,spreadRatio:Math.round(h*1e4)/1e4})}}R.length>0&&(s.groupDiscrimination=R),M.length>0&&(s.spreadDiscrimination=M)});let y=.97,C=.8,O=8,E=5,A=this._cols.map((s,d)=>({c:s,i:d})).filter(s=>s.c.isMeasure);for(let s=0;s<A.length;s++)for(let d=s+1;d<A.length;d++){let w=A[s].i,S=A[d].i,c=0,T=0,v=0,R=0,M=0,P=0;for(let N of this._rows){let p=N[w],h=N[S];if(p==null||p===""||h===null||h===void 0||h==="")continue;let D=typeof p=="number"?p:parseFloat(p),F=typeof h=="number"?h:parseFloat(h);isNaN(D)||isNaN(F)||(c++,T+=D,v+=F,R+=D*D,M+=F*F,P+=D*F)}if(c<E)continue;let L=c*R-T*T,b=c*M-v*v;if(L<=1e-12||b<=1e-12)continue;let _=(c*P-T*v)/Math.sqrt(L*b);if(Math.abs(_)>=y){let N=A[s].c,p=A[d].c;N.collinearWithMeasures||(N.collinearWithMeasures=[]),p.collinearWithMeasures||(p.collinearWithMeasures=[]),N.collinearWithMeasures.push(p.name),p.collinearWithMeasures.push(N.name)}else if(Math.abs(_)>=C){let N=A[s].c,p=A[d].c,h=Math.round(_*1e3)/1e3;N.correlatedWithMeasures||(N.correlatedWithMeasures=[]),p.correlatedWithMeasures||(p.correlatedWithMeasures=[]),N.correlatedWithMeasures.push({otherColumn:p.name,r:h}),p.correlatedWithMeasures.push({otherColumn:N.name,r:h})}}for(let{c:s}of A)s.correlatedWithMeasures&&(s.correlatedWithMeasures.sort((d,w)=>Math.abs(w.r)-Math.abs(d.r)||(d.otherColumn<w.otherColumn?-1:1)),s.correlatedWithMeasures.length=Math.min(s.correlatedWithMeasures.length,O));for(let s=0;s<this._cols.length;s++){let d=r[s];if(!d||d.size===0)continue;let w=[];for(let S=0;S<this._cols.length;S++){if(S===s)continue;let c=r[S];if(!c||c.size===0)continue;let T=0;for(let R of d)c.has(R)&&T++;let v=Math.round(T/d.size*100);v>0&&w.push({otherColumn:this._cols[S].name,percentShared:v})}w.length>0&&(this._cols[s].sharedValueRatioWithOthers=w)}let I=50,g=[];for(let s=0;s<this._cols.length;s++){let d=r[s];d&&d.size>=2&&d.size<=I&&g.push(s)}if(g.length>=2){let s=new Map,d=(S,c)=>S+":"+c;for(let S=0;S<g.length;S++)for(let c=S+1;c<g.length;c++)s.set(d(g[S],g[c]),new Map);for(let S of this._rows)for(let c=0;c<g.length;c++){let T=this.STR(S[g[c]])+"";for(let v=c+1;v<g.length;v++){let R=""+this.STR(S[g[v]]),M=s.get(d(g[c],g[v])),P=T+""+R;M.set(P,(M.get(P)??0)+1)}}let w=new Map;for(let S=0;S<g.length;S++)for(let c=S+1;c<g.length;c++){let T=g[S],v=g[c],R=r[T].size,M=r[v].size,P=s.get(d(T,v)),L=P.size,b=0;for(let h of P.values())(b===0||h<b)&&(b=h);let _=Math.round(L/(R*M)*100),N=L===R,p=L===M;if((this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[v].name,fillPct:_,determinesOther:N,minCellCount:b,distinctCombinations:L}),(this._cols[v].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:_,determinesOther:p,minCellCount:b,distinctCombinations:L}),N&&R>M){let h=w.get(T);(!h||M<h.card)&&w.set(T,{name:this._cols[v].name,card:M,ratio:M/R})}if(p&&M>R){let h=w.get(v);(!h||R<h.card)&&w.set(v,{name:this._cols[T].name,card:R,ratio:R/M})}}for(let[S,c]of w)this._cols[S].primaryParentColumn=c.name,this._cols[S].nestingRatio=Math.round(c.ratio*100)/100}let x=6,f=this._rows.length;for(let s=0;s<this._cols.length;s++){let d=this._cols[s];if(d.isMeasure||d.primaryParentColumn)continue;let w=d.distinctCount??0;if(w<=I||f>0&&w>=f)continue;let S=[];for(let c=0;c<this._cols.length;c++){if(c===s)continue;let T=this._cols[c];if(T.isMeasure)continue;let v=T.distinctCount??0;v<2||v>=w||S.push(c)}S.sort((c,T)=>(this._cols[c].distinctCount??0)-(this._cols[T].distinctCount??0));for(let c of S.slice(0,x)){let T=new Map,v=!0;for(let M of this._rows){let P=this.STR(M[s])+"",L=this.STR(M[c])+"",b=T.get(P);if(b===void 0)T.set(P,L);else if(b!==L){v=!1;break}}if(!v)continue;let R=this._cols[c].distinctCount??0;d.primaryParentColumn=this._cols[c].name,d.nestingRatio=Math.round(R/w*100)/100;break}}let G=.01,V=.05,W=.95,k=8,z=8,U=6,We=500,H=[];for(let s=0;s<this._cols.length&&H.length<z;s++){let d=this._cols[s].dataType;(d==="Double"||d==="Integer"||d==="Decimal")&&H.push(s)}if(H.length>=3&&this._rows.length>=k){let s=Math.min(this._rows.length,We),d=H.map(R=>{let M=[];for(let b=0;b<s;b++){let _=this._rows[b][R],N=typeof _=="number"?_:parseFloat(String(_).replace(/,/g,""));if(_==null||_===""||!isFinite(N))return null;M.push(N)}let P=M[0],L=!1;for(let b of M)if(b!==P){L=!0;break}return L?M:null}),w=H.map((R,M)=>M).filter(R=>d[R]!==null),S=R=>{let M=R.slice().sort((L,b)=>L-b),P=M.length>>1;return M.length%2?M[P]:(M[P-1]+M[P])/2},c=null,T=[],v=R=>{if(T.length>=3){let M=T.map(_=>d[_]),P=M[0].length,L=new Array(P);for(let _=0;_<P;_++){let N=0;for(let p of M)N+=p[_];L[_]=N}let b=S(L);if(b>0){let _=0;for(let p of L)Math.abs(p-b)<=b*G&&_++;let N=_/P;if(N>=W){let p=1;for(let h of M){let D=S(h)/b;D<p&&(p=D)}p>=V&&(!c||T.length>c.cols.length)&&(c={cols:T.slice(),total:b,matched:N})}}}if(!(T.length>=U))for(let M=R;M<w.length;M++)T.push(w[M]),v(M+1),T.pop()};if(v(0),c){let R=c,P={columns:R.cols.map(L=>this._cols[H[L]].name),total:Math.round(R.total*1e3)/1e3,matchedPct:Math.round(R.matched*100)/100};for(let L of R.cols)this._cols[H[L]].constantSumGroup=P}}return this._computedStatsForLevel=e,this._cols}updateColumnStats20(e,t,i,a,r,o,l,u,m,y,C,O){if(e>=20){let E=[...t].sort((g,x)=>g-x),A=Math.floor(E.length/2);if(i>0&&a!=null?r.avgValue=r.dataType=="Integer"?Math.round(a/i):a/i:r.avgValue=null,i>0&&(r.avgLength=o/i),this._rows.length>0){let g=x=>{let f=x instanceof Date?x:typeof x=="string"?te(x)??new Date(x):new Date(x),G=this.wholeDayIso(f);return G?G+"T00:00:00.000Z":isNaN(f.getTime())?x:f.toISOString().slice(0,10)+"T00:00:00.000Z"};r.dataType!="DateTime"||l||!u?r.lowValue=u:r.lowValue=g(u),r.dataType!="DateTime"||l||!m?r.highValue=m:r.highValue=g(m),r.medianValue=E.length===0?null:E.length%2===0?r.dataType=="Integer"?Math.round((E[A-1]+E[A])/2):(E[A-1]+E[A])/2:E[A],r.numericPrecision=y}if(E.length>0){let g=r.avgValue??0,x=E.length,f=0,G=0;for(let W of E){let k=W-g;f+=k*k,G+=k*k*k}let V=f/x;r.skewness=V===0?0:G/x/Math.pow(Math.sqrt(V),3),r.stdDev=Math.sqrt(V)}a!==null&&(r.sum=a);let I=Array.from(C.entries()).sort((g,x)=>x[1]-g[1]);if(r.topCategories=I.slice(0,10).map(g=>g[1]),!r.isMeasure&&I.length>0){if(r.dataType==="String"){let g=I.map(f=>f[0]);r.formatSignature=pe(g);let x=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!x.test(r.formatSignature)&&(r.avgLength===void 0||r.avgLength>=3)&&(r.isFreeText=!0)}else r.topCategoryValues=I.slice(0,5).map(g=>g[0]);if(e>=20){let g=I.map(f=>f[0]),x=me(g,O);if(x!==null)r.ordinalPattern=x.pattern,r.orderedDomain=x.orderedDomain;else if(r.dataType==="String"){let f=ce(g);f!==null&&(r.safeDistinctValues=f)}}}if(E.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let g=x=>E[Math.floor((E.length-1)*x)];r.quantiles={p05:g(.05),p25:g(.25),p75:g(.75),p95:g(.95)}}}if(!r.isMeasure&&C.size>0){let E=Array.from(C.entries()).sort((I,g)=>g[1]-I[1]),A=ge(E.map(I=>I[0]),r.name,O);if(A!==null&&(r.geoKind=A.geoKind,r.geoMatchPct=A.geoMatchPct,A.geoAmbiguous&&(r.geoAmbiguous=!0),A.geoKind.indexOf("country")===0)){let I=ne(E);I&&(r.dominantGeoRegion=I.dominantGeoRegion,r.dominantGeoRegionPct=I.dominantGeoRegionPct,r.geoRegionCount=I.regionCount)}}}updateColumnStats10(e,t,i,a,r,o,l){e>=10&&(t.blankCount=this._rows.length-i,t.distinctCount=a.size+(t.blankCount!=0?1:0),t.valueNature="Categorical",i>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=Ge({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:a.size,nonblank:i,prec:r,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,a)=>{i.isMeasure||e.push(a)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let t=new Set;for(let i of this._rows)t.add(JSON.stringify(e.map(a=>i[a])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>String(o||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),t=-1,i=-1,a=-1;if(this._cols.forEach((o,l)=>{let u=e(o.name),m=o.dataType==="Integer"||o.dataType==="Decimal";m&&t<0&&u.some(y=>y==="lat"||y==="latitude")?t=l:m&&i<0&&u.some(y=>y==="lon"||y==="lng"||y==="long"||y==="longitude")&&(i=l),a<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(a=l)}),t<0||i<0)return null;let r=[];for(let o of this._rows){let l=o[t],u=o[i],m=l==null||l===""?null:Number(l),y=u==null||u===""?null:Number(u);r.push({lat:m,lon:y,country:a>=0&&ee(this.STR(o[a]))?this.STR(o[a]):null})}return this._geoExtent=Se(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){let t="abcdefghijklmnopqrstuvwxyz",i=()=>t[Math.floor(X()*t.length)],a=()=>i().toUpperCase(),r=()=>Math.floor(X()*10).toString(),o=A=>/[A-Z]/.test(A)?a():/[a-z]/.test(A)?i():/[0-9]/.test(A)?r():A,l=e.includes("@")&&e.includes("."),u=l?e.split("@"):[e],m=l?u[1]:"",y=m.endsWith(".com"),C=y?".com":"",O=y?m.slice(0,-4):m,E=A=>{let I="";for(let g of A)I+=o(g),/[a-zA-Z0-9]/.test(g)&&X()<.2&&(I+=o(g));if(I.length>6){let g=Math.floor(X()*Math.min(3,I.length-6));for(let x=0;x<g;x++){let f=0;for(;f<5;){let G=Math.floor(X()*I.length);if(/[a-zA-Z0-9]/.test(I[G])){I=I.slice(0,G)+I.slice(G+1);break}f++}}}return I};if(l){let A=E(u[0]),I=E(O);return`${A}@${I}${C}`}else return E(e)}toObjectArray(){return this._rows.map(e=>{let t={};return this._cols.forEach((i,a)=>{t[i.name]=e[a],this.emitLegacyAggAliases&&i.hostName&&i.hostName!==i.name&&!Object.prototype.hasOwnProperty.call(t,i.hostName)&&(t[i.hostName]=e[a])}),t})}async getCSVAsync(e){let t=[],i=e?25:1e7,a=e?4e3:1e7,r=new Map;for(let l of this._rows){let u={};for(let m=0;m<this._cols.length;m++){let y=this._cols[m],C=l[m];if(this.STR(C)!=""){if(e&&y.dataType=="String")if(r.has(C))C=r.get(C);else{let O=this.obfuscateString(C);r.set(C,O),C=O}else if(y.dataType=="DateTime"&&!y.dateWithTime){let O=C instanceof Date?C:typeof C=="string"?te(C)??new Date(C):new Date(C);C=(this.wholeDayIso(O)??O.toISOString().slice(0,10))+"T00:00:00.000Z"}a-=this.STR(C).length}else C=null;u[m]=C,--a}if(t.push(u),--i,i<=0||a<=0)break}return await Pe.unparse(t,{header:!1})}getCSVHeaderLine(){return Pe.unparse([this._cols.map(e=>this.STR(this.emitLegacyAggAliases&&e.hostName?e.hostName:e.name))])}addRow(e,t){if(this.dedupRows){let i="";for(let r of e)i+=this.STR(r)+"~";let a=ae(i);if(this._rowHashes.has(a))return!1;this._rowHashes.add(a)}return this._rows.push(e),this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null}setColumns(e){if(this._cols=e,!e||e.length===0)return;let t=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let a=this.STR(i.name),r=Re(a);!r||r===a||t.has(r)||(t.delete(a),t.add(r),i.hostName=a,i.name=r)}}};export{Se as a,Ve as b,ee as c,Ft as d,Be as e,Ye as f,He as g,Ke as h,Te as i,qe as j,Re as k,Ut as l,Ne as m,et as n,Ie as o,Ee as p,Vt as q,Bt as r,Yt as s,Kt as t,$t as u,mt as v,Le as w,Tt as x,Fe as y,Ot as z,Lt as A,Pt as B,Ge as C,ke as D};
@@ -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-2AGC3A7S.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-GPX2G67N.mjs";export{a as ZIP_NAME_TOKENS,f as buildGeoIsoColumn,c as detectGeo,b as hasAnyToken,e as isJoinGeoKind,d as toGeoIso};
2
+ import{a,b,c,d,e,f}from"./chunk-OZEOA6ZE.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-FUTSF2X5.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 le,b as ce}from"./chunk-UQU75XXR.mjs";import{a as se,b as ae}from"./chunk-3KJGKU27.mjs";import{A as ne,B as oe,C as ie,D as re,a as Mt,b as _t,c as vt,d as Lt,e as wt,f as Ot,g as Dt,h as zt,i as Gt,j as $t,k as Ft,l as Bt,m as Kt,n as Ht,o as Ut,p as Vt,q as Wt,r as qt,s as Zt,t as Xt,u as jt,v as Yt,w as Jt,x as Qt,y as te,z as ee}from"./chunk-BZVL57QR.mjs";import{a as Nt}from"./chunk-QEH7WTLB.mjs";import{a as kt,b as Et}from"./chunk-2LR73DNS.mjs";import{a as U,b as V,c as Rt,d as St,e as It,f as bt}from"./chunk-2AGC3A7S.mjs";import{a as R,f as S,g as y,h as I,i as E,j as mt,k as dt,l as H,m,n as gt,o as yt,p as ht,q as b,r as Pt,s as At,t as Ct,u as Tt,v as w,w as xt}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as ut,b as ft,c as pt}from"./chunk-AIT35XBN.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,i as st,j as at,k as lt,l as ct}from"./chunk-GPX2G67N.mjs";var O=2,Z=400;function z(r){return!!S(r)}function A(r){let n=new Set;for(let e of r){if(e==null)continue;let s=R(String(e));if(!I(s)&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function P(r){let n=A(r);if(n.length===0||G(r)<95)return!1;let e=n.filter(c=>z(c)&&!m(c)).length,s=n.filter(c=>!z(c)&&!!m(c)).length;return e>=1&&e>=s}function W(r,n){if(!m(r))return!1;let e=S(r);return e?n==="world"?!0:H.has(e):!1}function G(r){let n=A(r);if(n.length===0)return 0;let e=0;for(let s of n)z(s)&&e++;return Math.round(e/n.length*1e3)/10}function M(r){let n=A(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(R(s))&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function $(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 q(r,n){return V(n,U)?!0:F(r).some(e=>/^\d{5}(-\d{4})?$/.test(e.replace(/\.0+$/,"")))}function ue(r,n){let e=A(r);if(e.length===0)return 0;let s=0;for(let c of e)w(c,n)&&s++;return Math.round(s/e.length*1e3)/10}function D(r,n){let e=0;for(let s of A(r))n(s)&&e++;return e}function fe(r,n){let e=0;for(let s of F(r))n(s)&&e++;return e}function pe(r,n,e,s,c){let C=[],u=[],o={},_={},v=new Set(r),l=t=>n.map(i=>i[t]);for(let t of["city","country"]){let i=e?.[t];i&&v.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 d=e?.zip;if(d&&v.has(d)){let t=l(d),i=$(t);i<95?u.push(`zip=${d} (only ${i}% of values read as ZIPs)`):q(t,d)?o.zip=d:u.push(`zip=${d} (all values are 3-4 digits with nothing to say they are postal)`)}let p=e?.state;if(p&&v.has(p)){let t=l(p),i=A(t);i.length>0&&i.every(a=>W(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)):M(t)<95?u.push(`state=${p} (only ${M(t)}% of values are states/provinces)`):o.state=p}let g=new Set(Object.values(o).filter(Boolean)),T=r.filter(t=>!g.has(t)&&!t.startsWith("__"));if(!o.state){let t=null;for(let i of T){let a=l(i);if(P(a))continue;let f=M(a);if(f<95)continue;let k=D(a,x=>!!m(x)),Y=D(a,x=>!!m(x)&&!W(x,s));k<O&&Y<1||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.state=t.name,g.add(t.name),C.push(`state=${t.name} (${t.pct}% states/provinces)`))}if(!o.zip)for(let t of T){if(g.has(t))continue;let i=l(t),a=$(i);if(!(a<95)&&q(i,t)&&!(fe(i,f=>b(f).length>0)<O)){o.zip=t,g.add(t),C.push(`zip=${t} (${a}% ZIP codes)`);break}}let h=o.country;if(!h||!P(l(h))){let t=null;for(let i of T){if(g.has(i)||!P(l(i)))continue;let a=G(l(i));(!t||a>t.pct)&&(t={name:i,pct:a})}t&&(h&&(u.push(`country=${h} (only ${G(l(h))}% of values are country identifiers; using ${t.name} instead)`),_.country=h),o.country=t.name,g.add(t.name),C.push(`country=${t.name}`))}if(!o.city){let t=null;for(let i of T){if(g.has(i))continue;let a=l(i),f=ue(a,s);f<E||D(a,k=>w(k,s))<O||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.city=t.name,C.push(`city=${t.name} (${t.pct}% known cities)`))}let B=o.country?l(o.country):[],L=!!o.country&&P(B),j=L?new Set(B.map(t=>S(t==null?null:String(t))).filter(Boolean)).size:0,K=L&&j>=2,N=!!(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&&!N&&u.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||N)&&u.push(L?`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||N)?o:null,backfilled:C,refused:u,...Object.keys(_).length?{labelFallback:_}:{}}}export{E as CITY_ROLE_MATCH_PCT,Xt as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,et as GET_RANDOM,Ot as INTENSIVE_SUFFIX_TOKENS,wt as INTENSIVE_WORD_TOKENS,re as IndexedText,jt as MAX_RUN_BOUNDS,zt as POSITIONAL_SUFFIX_TOKENS,Dt as POSITIONAL_WORD_TOKENS,le as PREVIEW_OMITTED_FIELDS,y as ROLE_MATCH_PCT,tt as SIMPLE_STRING_HASH,Q as STR,M as admin1MatchPct,Vt as allowedAggregations,bt as buildGeoIsoColumn,Ct as buildGeoPointColumns,xt as cityMatchPct,Tt as cityTagsFor,oe as classifyAdditivity,Ut as classifyForAggregation,ie as classifyNumericValueNature,ee as classifyTemporal,Bt as codeNeedsLegacyAggNames,Ft as collapseRepeatedAggPrefix,vt as countryRegion,Wt as defaultAggregation,Nt as detectFormatSignature,Rt as detectGeo,pt as detectOrdinalDomain,te as detectTextDatePattern,se as engineTypeForSqlType,$t as hasDefaultAggPrefix,ne as hostAggHint,ae as ingest,qt as isAggregationAllowed,I as isBlankLike,dt as isCityTableLoaded,nt as isDeterministicRefusal,Pt as isGeoPointAmbiguity,Qt as isIdentifierName,It as isJoinGeoKind,ut as isOrdinalFriendlyName,lt as localMidnightDateColumns,at as localMidnightToUtcDay,P as looksLikeCountryColumn,Jt as measureCadence,Et as monthLookupFor,Ht as nameLooksIntensiveRate,Kt as nameLooksPositional,J as nameWords,gt as normalizeCountry,ct as normalizeLocalMidnightDates,kt as normalizeMonthKey,R as normalizePlaceName,ht as normalizeZip5,it as parseDateStable,Yt as parseTemporalPoint,ce as payloadPreview,mt as registerCityTable,_t as registerIso3Regions,m as resolveAdmin1,At as resolveGeoPoint,pe as resolvePointRoles,ft as safeDistinctValuesToShip,Zt as shareOfTotalIsHonest,Gt as stripHostAggPrefix,Lt as summarizeCountryRegions,Mt as summarizeGeoExtent,St as toGeoIso,rt as wholeDayFrame,st as wholeDayIso,$ as zipMatchPct,b as zipPrefixCandidates,yt as zipToPrefix3};
2
+ import{a as le,b as ce}from"./chunk-UQU75XXR.mjs";import{a as se,b as ae}from"./chunk-3PMDGEN2.mjs";import{A as ne,B as oe,C as ie,D as re,a as Mt,b as _t,c as vt,d as Lt,e as wt,f as Ot,g as Dt,h as zt,i as Gt,j as $t,k as Ft,l as Bt,m as Kt,n as Ht,o as Ut,p as Vt,q as Wt,r as qt,s as Zt,t as Xt,u as jt,v as Yt,w as Jt,x as Qt,y as te,z as ee}from"./chunk-SV3JH46V.mjs";import{a as Nt}from"./chunk-QEH7WTLB.mjs";import{a as kt,b as Et}from"./chunk-2LR73DNS.mjs";import{a as U,b as V,c as Rt,d as St,e as It,f as bt}from"./chunk-OZEOA6ZE.mjs";import{a as R,f as S,g as y,h as I,i as E,j as mt,k as dt,l as H,m,n as gt,o as yt,p as ht,q as b,r as Pt,s as At,t as Ct,u as Tt,v as w,w as xt}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as ut,b as ft,c as pt}from"./chunk-N3ZYRMZJ.mjs";import{a as J,b as Q,d as tt,e as et,f as nt,g as ot,h as it,i as rt,j as st,k as at,l as lt,m as ct}from"./chunk-FUTSF2X5.mjs";var O=2,Z=400;function z(r){return!!S(r)}function A(r){let n=new Set;for(let e of r){if(e==null)continue;let s=R(String(e));if(!I(s)&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function P(r){let n=A(r);if(n.length===0||G(r)<95)return!1;let e=n.filter(c=>z(c)&&!m(c)).length,s=n.filter(c=>!z(c)&&!!m(c)).length;return e>=1&&e>=s}function W(r,n){if(!m(r))return!1;let e=S(r);return e?n==="world"?!0:H.has(e):!1}function G(r){let n=A(r);if(n.length===0)return 0;let e=0;for(let s of n)z(s)&&e++;return Math.round(e/n.length*1e3)/10}function M(r){let n=A(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(R(s))&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function $(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 q(r,n){return V(n,U)?!0:F(r).some(e=>/^\d{5}(-\d{4})?$/.test(e.replace(/\.0+$/,"")))}function ue(r,n){let e=A(r);if(e.length===0)return 0;let s=0;for(let c of e)w(c,n)&&s++;return Math.round(s/e.length*1e3)/10}function D(r,n){let e=0;for(let s of A(r))n(s)&&e++;return e}function fe(r,n){let e=0;for(let s of F(r))n(s)&&e++;return e}function pe(r,n,e,s,c){let C=[],u=[],o={},_={},v=new Set(r),l=t=>n.map(i=>i[t]);for(let t of["city","country"]){let i=e?.[t];i&&v.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 d=e?.zip;if(d&&v.has(d)){let t=l(d),i=$(t);i<95?u.push(`zip=${d} (only ${i}% of values read as ZIPs)`):q(t,d)?o.zip=d:u.push(`zip=${d} (all values are 3-4 digits with nothing to say they are postal)`)}let p=e?.state;if(p&&v.has(p)){let t=l(p),i=A(t);i.length>0&&i.every(a=>W(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)):M(t)<95?u.push(`state=${p} (only ${M(t)}% of values are states/provinces)`):o.state=p}let g=new Set(Object.values(o).filter(Boolean)),T=r.filter(t=>!g.has(t)&&!t.startsWith("__"));if(!o.state){let t=null;for(let i of T){let a=l(i);if(P(a))continue;let f=M(a);if(f<95)continue;let k=D(a,x=>!!m(x)),Y=D(a,x=>!!m(x)&&!W(x,s));k<O&&Y<1||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.state=t.name,g.add(t.name),C.push(`state=${t.name} (${t.pct}% states/provinces)`))}if(!o.zip)for(let t of T){if(g.has(t))continue;let i=l(t),a=$(i);if(!(a<95)&&q(i,t)&&!(fe(i,f=>b(f).length>0)<O)){o.zip=t,g.add(t),C.push(`zip=${t} (${a}% ZIP codes)`);break}}let h=o.country;if(!h||!P(l(h))){let t=null;for(let i of T){if(g.has(i)||!P(l(i)))continue;let a=G(l(i));(!t||a>t.pct)&&(t={name:i,pct:a})}t&&(h&&(u.push(`country=${h} (only ${G(l(h))}% of values are country identifiers; using ${t.name} instead)`),_.country=h),o.country=t.name,g.add(t.name),C.push(`country=${t.name}`))}if(!o.city){let t=null;for(let i of T){if(g.has(i))continue;let a=l(i),f=ue(a,s);f<E||D(a,k=>w(k,s))<O||(!t||f>t.pct)&&(t={name:i,pct:f})}t&&(o.city=t.name,C.push(`city=${t.name} (${t.pct}% known cities)`))}let B=o.country?l(o.country):[],L=!!o.country&&P(B),j=L?new Set(B.map(t=>S(t==null?null:String(t))).filter(Boolean)).size:0,K=L&&j>=2,N=!!(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&&!N&&u.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||N)&&u.push(L?`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||N)?o:null,backfilled:C,refused:u,...Object.keys(_).length?{labelFallback:_}:{}}}export{E as CITY_ROLE_MATCH_PCT,Xt as DEFAULT_GAP_FACTOR,ot as DEFAULT_TEMPERATURE,et as GET_RANDOM,Ot as INTENSIVE_SUFFIX_TOKENS,wt as INTENSIVE_WORD_TOKENS,re as IndexedText,jt as MAX_RUN_BOUNDS,zt as POSITIONAL_SUFFIX_TOKENS,Dt as POSITIONAL_WORD_TOKENS,le as PREVIEW_OMITTED_FIELDS,y as ROLE_MATCH_PCT,tt as SIMPLE_STRING_HASH,Q as STR,M as admin1MatchPct,Vt as allowedAggregations,bt as buildGeoIsoColumn,Ct as buildGeoPointColumns,xt as cityMatchPct,Tt as cityTagsFor,oe as classifyAdditivity,Ut as classifyForAggregation,ie as classifyNumericValueNature,ee as classifyTemporal,Bt as codeNeedsLegacyAggNames,Ft as collapseRepeatedAggPrefix,vt as countryRegion,Wt as defaultAggregation,Nt as detectFormatSignature,Rt as detectGeo,pt as detectOrdinalDomain,te as detectTextDatePattern,se as engineTypeForSqlType,$t as hasDefaultAggPrefix,ne as hostAggHint,ae as ingest,qt as isAggregationAllowed,I as isBlankLike,dt as isCityTableLoaded,nt as isDeterministicRefusal,Pt as isGeoPointAmbiguity,Qt as isIdentifierName,It as isJoinGeoKind,ut as isOrdinalFriendlyName,lt as localMidnightDateColumns,at as localMidnightToUtcDay,P as looksLikeCountryColumn,Jt as measureCadence,Et as monthLookupFor,Ht as nameLooksIntensiveRate,Kt as nameLooksPositional,J as nameWords,gt as normalizeCountry,ct as normalizeLocalMidnightDates,kt as normalizeMonthKey,R as normalizePlaceName,ht as normalizeZip5,it as parseDateStable,Yt as parseTemporalPoint,ce as payloadPreview,mt as registerCityTable,_t as registerIso3Regions,m as resolveAdmin1,At as resolveGeoPoint,pe as resolvePointRoles,ft as safeDistinctValuesToShip,Zt as shareOfTotalIsHonest,Gt as stripHostAggPrefix,Lt as summarizeCountryRegions,Mt as summarizeGeoExtent,St as toGeoIso,rt as wholeDayFrame,st as wholeDayIso,$ as zipMatchPct,b as zipPrefixCandidates,yt as zipToPrefix3};
@@ -1,2 +1,2 @@
1
1
  /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{A as d,B as e,C as f,D as g,x as a,y as b,z as c}from"./chunk-BZVL57QR.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-2AGC3A7S.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-AIT35XBN.mjs";import"./chunk-GPX2G67N.mjs";export{g as IndexedText,e as classifyAdditivity,f as classifyNumericValueNature,c as classifyTemporal,b as detectTextDatePattern,d as hostAggHint,a as isIdentifierName};
2
+ import{A as d,B as e,C as f,D as g,x as a,y as b,z as c}from"./chunk-SV3JH46V.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-OZEOA6ZE.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-N3ZYRMZJ.mjs";import"./chunk-FUTSF2X5.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-3KJGKU27.mjs";import"./chunk-BZVL57QR.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-2AGC3A7S.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-AIT35XBN.mjs";import"./chunk-GPX2G67N.mjs";export{a as engineTypeForSqlType,b as ingest};
2
+ import{a,b}from"./chunk-3PMDGEN2.mjs";import"./chunk-SV3JH46V.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-OZEOA6ZE.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-N3ZYRMZJ.mjs";import"./chunk-FUTSF2X5.mjs";export{a as engineTypeForSqlType,b as ingest};
@@ -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-AIT35XBN.mjs";import"./chunk-GPX2G67N.mjs";export{c as detectOrdinalDomain,a as isOrdinalFriendlyName,b as safeDistinctValuesToShip};
2
+ import{a,b,c}from"./chunk-N3ZYRMZJ.mjs";import"./chunk-FUTSF2X5.mjs";export{c as detectOrdinalDomain,a as isOrdinalFriendlyName,b as safeDistinctValuesToShip};
@@ -18,6 +18,9 @@
18
18
  export declare function nameWords(name: string): string[];
19
19
  /** Null/undefined-safe stringify. Mirrors Shared.STR. */
20
20
  export declare function STR(v: any): string;
21
+ /** Linear-interpolated quantile over an ascending-sorted array (NaN for an empty one). One definition for
22
+ * every statistic that needs a percentile, so two of them cannot disagree about where p10 sits. */
23
+ export declare function quantileSorted(sorted: number[], q: number): number;
21
24
  /** FNV-1a string hash masked to a JS-safe 53-bit integer. Mirrors
22
25
  * Shared.SIMPLE_STRING_HASH. Deterministic — safe for stable keys. */
23
26
  export declare function SIMPLE_STRING_HASH(str: string): number;
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,g,h,i,j,k,l}from"./chunk-GPX2G67N.mjs";export{f as DEFAULT_TEMPERATURE,d as GET_RANDOM,c as SIMPLE_STRING_HASH,b as STR,e as isDeterministicRefusal,k as localMidnightDateColumns,j as localMidnightToUtcDay,a as nameWords,l as normalizeLocalMidnightDates,g as parseDateStable,h as wholeDayFrame,i as wholeDayIso};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-FUTSF2X5.mjs";export{g as DEFAULT_TEMPERATURE,e as GET_RANDOM,d as SIMPLE_STRING_HASH,b as STR,f as isDeterministicRefusal,l as localMidnightDateColumns,k as localMidnightToUtcDay,a as nameWords,m as normalizeLocalMidnightDates,h as parseDateStable,c as quantileSorted,i as wholeDayFrame,j as wholeDayIso};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.5.107",
3
+ "version": "0.5.109",
4
4
  "description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{a as _e}from"./chunk-QEH7WTLB.mjs";import{a as Se,b as Me}from"./chunk-2LR73DNS.mjs";import{c as ye}from"./chunk-2AGC3A7S.mjs";import{b as he,f as be}from"./chunk-E6SVTFAW.mjs";import{a as fe,b as ge,c as pe}from"./chunk-AIT35XBN.mjs";import{a as J,b as ce,c as me,d as q,g as re,i as de}from"./chunk-GPX2G67N.mjs";var Ve=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],Ye=[7,72,-172,-52];function Ce(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}function ne(n,e){if(!n.length)return NaN;if(n.length===1)return n[0];let t=(n.length-1)*e,i=Math.floor(t),a=Math.ceil(t);return i===a?n[i]:n[i]+(n[a]-n[i])*(t-i)}var X=n=>Math.round(n*10)/10;function Te(n,e=3){let t=[],i=[],a=0,r=0;for(let l of n){let u=l?.lat,m=l?.lon;if(typeof u!="number"||typeof m!="number"||!isFinite(u)||!isFinite(m)||u<-90||u>90||m<-180||m>180)continue;t.push(u),i.push(m);let p=l?.country?String(l.country).trim().toUpperCase():"",h=p?ie(p):null;h?((p==="US"||p==="USA")&&a++,h==="north-america"&&r++):(Ve.some(E=>Ce(u,m,E))&&a++,Ce(u,m,Ye)&&r++)}let o=t.length;return o<e?null:(t.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:X(a/o*100),pctNa:X(r/o*100),latP5:X(ne(t,.05)),latP95:X(ne(t,.95)),lonP5:X(ne(i,.05)),lonP95:X(ne(i,.95)),n:o})}var Ae={"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"},ee=(()=>{let n=new Map;for(let e of Object.keys(Ae))for(let t of Ae[e].split(/\s+/))t&&n.set(t,e);return n})();function He(n){for(let[e,t]of n){let i=ee.get(e);i&&!ee.has(t)&&ee.set(t,i)}}He(he);function ie(n){if(!n)return null;let e=String(n).trim().toUpperCase();if(!e)return null;let t=ee.get(e);if(t)return t;let i=be(String(n));return i?ee.get(i)??null:null}function zt(n,e=2){return se(n.map(t=>[t,1]),e)}function se(n,e=2){let t=new Map,i=0;for(let[o,l]of n){let u=ie(o);if(!u)continue;let m=typeof l=="number"&&isFinite(l)&&l>0?l:1;t.set(u,(t.get(u)??0)+m),i+=m}if(i<e||!t.size)return null;let a="europe",r=-1;for(let o of Array.from(t.keys()).sort()){let l=t.get(o);l>r&&(a=o,r=l)}return{dominantGeoRegion:a,dominantGeoRegionPct:X(r/i*100),regionCount:t.size,n:i}}import We from"papaparse";var Ke=["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","ppm","ppb","dpmo","bps","temperatuur","temperatur","temperatura","teplota","lampotila","homerseklet","sicaklik","pression","presion","pressao","pressione","druck","tryck","tlak","paine","nyomas","presiune","humidite","humedad","umidade","umidita","feuchtigkeit","vochtigheid","kosteus","vlhkost","vitesse","velocidad","velocidade","velocita","geschwindigkeit","snelheid","hastighet","hastighed","rychlost","nopeus","sebesseg","brzina","predkosc","densite","densidad","densidade","densita","dichte","dichtheid","hustota","tiheys","gustoca","moyenne","mediane","promedio","mediana","gemiddelde","durchschnitt","mittelwert","genomsnitt","gennemsnit","gjennomsnitt","keskiarvo","atlag","ortalama","prosjek","srednia","prumer","priemer","medie","taux","tasa","taxa","tasso","verhaltnis","verhouding","aandeel","anteil","andel","osuus","podil","udzial","udio","pourcentage","porcentaje","percentual","prozent","procent","prosentti","szazalek","yuzde","participacion","participacao","pondere","omjer","arany","oran","rata","leeftijd","edad","idade","wiek","eletkor","varsta","puntuacion","pontuacao","punteggio","betyg","ocena","indice","indeks","wskaznik","puan"],$e=["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","ppm","ppb","dpmo","bps"],Ze=["latitude","longitude"],Xe=["latitude","longitude"];function j(n){return Array.from(n).map(e=>{let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===1?t:e}).join("")}var oe=["somme de","suma de","soma de","summe von","som van","somma di","summa av","sum av","sum af","soucet z","suma z","totaal van","total de","toplam","osszeg","nombre de","recuento de","contagem de","anzahl von","aantal van","conteggio di","antal av","lukumaara","pocet z"],ve=["moyenne de","promedio de","media de","media di","durchschnitt von","gemiddelde van","medelvarde av","genomsnitt av","gennemsnit af","keskiarvo","atlag","ortalama","prumer z","srednia z","medie de","minimum de","minimo de","minimo di","minimum von","maximum de","maximo de","massimo di","maximum von"];function je(n){return[...n].sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")}var Ne=new RegExp("^\\s*(?:(?:sum|count|count\\s+distinct|distinct\\s+count)\\s+of\\s+|(?:"+je(oe)+")\\s+)","i"),qe=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Qe=new RegExp("\\b("+Ke.join("|")+")\\b|("+$e.join("|")+")$","i"),Je=new RegExp("\\b("+Ze.join("|")+")\\b|("+Xe.join("|")+")$","i");function xe(n){if(!n)return"";let e=String(n),t=Ne.exec(j(e));return(t?e.slice(t[0].length):e).trim()}function et(n){return!!n&&Ne.test(j(String(n)))}var tt=["count (distinct)","count distinct","distinct count","standard deviation","average","variance","median","product","stddev","std dev","count","sum","avg","min","minimum","max","maximum","var"],Re=new RegExp("^\\s*("+[...tt].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function Ie(n){if(n==null)return"";let e=String(n),t=Re.exec(e);if(!t)return e;let i=l=>l.toLowerCase().replace(/\s+/g," ").trim(),a=i(t[1]),r=e.slice(t[0].length),o=0;for(;o<8;){let l=Re.exec(r);if(!l||i(l[1])!==a)break;let u=r.slice(l[0].length);if(u.trim()==="")break;r=u,o++}return o===0?e:e.slice(0,t[0].length)+r}function Vt(n,e){if(!n||!e)return!1;let t=String(n);for(let i of e){let a=i?.hostName;if(a&&a!==i?.name&&t.includes(a))return!0}return!1}function nt(n){let e=xe(n);return e.length===0?"":e.replace(qe," ")}function we(n,e){if(!e)return!1;let t=xe(e);return n.test(j(nt(e)))||n.test(j(t))||n.test(j(J(t).join(" ")))}function Ee(n){return we(Je,n)}function it(n){return we(Qe,n)||Ee(n)}var De=/int|double|decimal|single|float|number|currency|money/i;function rt(n){let e=String(n?.valueNature??"").trim().toLowerCase();return e==="categorical"?"Categorical":e==="ordinal"?"Ordinal":e==="continuous"||n?.isMeasure===!0||De.test(String(n?.dataType??""))?"Continuous":"Categorical"}function st(n){return n?.isMeasure===!0||De.test(String(n?.dataType??""))}function Oe(n){let e=n??{},t=rt(e);if(t!=="Continuous")return{nature:t,additivity:"unknown",basis:"role",suppressed:!1};if(Ee(e.name))return{nature:t,additivity:"positional",basis:"name",suppressed:!0};let i=String(e.additivity??"").trim().toLowerCase();if(!(i==="additive"&&et(e.name))){if(i==="additive")return{nature:t,additivity:"additive",basis:"measured",suppressed:!1};if(i==="part_of_whole")return{nature:t,additivity:"part_of_whole",basis:"measured",suppressed:!1};if(i==="intensive_rate")return{nature:t,additivity:"intensive_rate",basis:"measured",suppressed:!1}}return e.discourageAggregationAcrossGroups===!0?{nature:t,additivity:"intensive_rate",basis:"host-flag",suppressed:!1}:it(e.name)?{nature:t,additivity:"intensive_rate",basis:"name",suppressed:!1}:{nature:t,additivity:"additive",basis:"default",suppressed:!1}}function Le(n){let e=Oe(n),t=n??{};if(e.nature==="Categorical")return["first","distinctcount","count"];if(e.nature==="Ordinal")return st(t)?["median","average","min","max","first","distinctcount","count"]:["first","distinctcount","count"];switch(e.additivity){case"positional":return["min","max","count","distinctcount","first"];case"intensive_rate":return["average","median","min","max","count","distinctcount","first"];default:return["sum","average","median","min","max","count","distinctcount","first"]}}function Yt(n){return Le(n)[0]}function Ht(n,e){return Le(n).indexOf(e)>=0}function Kt(n,e){if(e!=="sum"&&e!=="count")return!1;if(e==="count")return!0;let t=Oe(n);return t.additivity==="additive"||t.additivity==="part_of_whole"||t.additivity==="unknown"}var Zt=5,Xt=6;var ot=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,at=/^(\d{4})[-/](\d{1,2})$/,ut=/^(\d{4})[-\s]?Q([1-4])$/i,lt=/^Q([1-4])[-\s](\d{4})$/i,ct=/^(\d{4})$/,mt=/^(\d{4})(0[1-9]|1[0-2])$/,dt=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/;function $(n,e,t,i=0,a=0,r=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let o=Date.UTC(n,e-1,t,i,a,r);if(!Number.isFinite(o))return null;let l=u=>u<10?"0"+u:String(u);return{ms:o,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function ft(n,e){let t=[],i="";for(let u=0;u<e.length;u++){if(e[u]!=="%"){i+=e[u].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");continue}switch(e[++u]){case"Y":t.push("Y"),i+="(\\d{4})";break;case"m":t.push("m"),i+="(\\d{1,2})";break;case"d":t.push("d"),i+="(\\d{1,2})";break;case"H":case"M":case"S":i+="\\d{1,2}";break;case"%":i+="%";break;default:return null}}let a=new RegExp("^"+i+"$").exec(n);if(!a)return null;let r=0,o=1,l=1;return t.forEach((u,m)=>{let p=+a[m+1];u==="Y"?r=p:u==="m"?o=p:l=p}),r?$(r,o,l):null}function gt(n,e){let t=(n??"").trim();if(t==="")return null;if(e){let a=ft(t,e);return a||null}let i=ot.exec(t);if(i)return $(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=ut.exec(t),i)return $(+i[1],(+i[2]-1)*3+1,1);if(i=lt.exec(t),i)return $(+i[2],(+i[1]-1)*3+1,1);if(i=at.exec(t),i&&+i[2]>=1&&+i[2]<=12)return $(+i[1],+i[2],1);if(i=dt.exec(t),i)return $(+i[1],+i[2],+i[3]);if(i=mt.exec(t),i)return $(+i[1],+i[2],1);if(i=ct.exec(t),i){let a=+i[1];return a>=1900&&a<=2100?$(a,1,1):null}return null}function Ge(n){let e=new Date(n).getUTCDay();return e>=1&&e<=5}function ke(n,e){if(e<=n)return 0;let t=Math.round((e-n)/864e5),i=Math.floor(t/7),a=i*5,r=n+i*7*864e5;for(;r<e;)Ge(r)&&a++,r+=864e5;return a}function pt(n){if(n.length===0)return 0;let e=[...n].sort((i,a)=>i-a),t=e.length>>1;return e.length%2?e[t]:(e[t-1]+e[t])/2}function ht(n){return n>0?n<.95?"hour":n<=1.05?"day":n>=6.5&&n<=7.5?"week":n>=27&&n<=31.5?"month":n>=88&&n<=93?"quarter":n>=362&&n<=368?"year":"irregular":"irregular"}function Pe(n,e,t,i){switch(t){case"year":return e.y-n.y;case"quarter":return e.y*4+Math.floor((e.m-1)/3)-(n.y*4+Math.floor((n.m-1)/3));case"month":return e.y*12+e.m-(n.y*12+n.m);case"week":return Math.round((e.ms-n.ms)/(7*864e5));case"weekday":return ke(n.ms,e.ms);case"day":return Math.round((e.ms-n.ms)/864e5);default:return i>0?Math.round((e.ms-n.ms)/i):0}}function Fe(n,e){let t=e?.gapFactor??5,i=0,a=0,r=new Map;for(let f of n){if(f==null||f==="")continue;i++;let k=gt(String(f),e?.pattern);k&&(a++,r.set(k.ms,k))}let o=[...r.values()].sort((f,k)=>f.ms-k.ms);if(o.length<3||i>0&&a/i<.8)return null;let l=o[o.length-1].ms-o[0].ms;if(l<=0)return null;let u=[];for(let f=1;f<o.length;f++)u.push(o[f].ms-o[f-1].ms);let m=pt(u);if(!(m>0))return null;let p=ht(m/864e5);p==="day"&&l>=7*864e5&&o.every(f=>Ge(f.ms))&&ke(o[0].ms,o[o.length-1].ms)+1>o.length*.5&&(p="weekday");let h=p==="irregular"?o.length:Pe(o[0],o[o.length-1],p,m)+1,E=1,y=1,x=[],g=o[0],R=1;for(let f=1;f<o.length;f++){let k=Pe(o[f-1],o[f],p,m);k>E&&(E=k),p!=="irregular"&&k>t?(y++,x.push({from:g.iso,to:o[f-1].iso,points:R}),g=o[f],R=1):R++}x.push({from:g.iso,to:o[o.length-1].iso,points:R});let v={grain:p,points:o.length,expectedPoints:Math.max(h,o.length),coveragePct:Math.round(o.length/Math.max(h,o.length)*1e3)/10,runs:y,largestGapUnits:E,gapFactor:t};return e?.includeBounds&&x.length<=6&&(v.runBounds=x),v}var bt=12,yt=100,_t=.3,St=.9,Mt=120,Ct=1900,At=2100,Tt=0,Rt=20,vt=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Nt(n){if(!n)return!1;let e=J(n);return e.length===0?!1:vt.has(e[e.length-1])}var xt=new Set(["year","yr","fy"]),It=n=>J(n).some(e=>xt.has(e)),wt=/^(?:(?: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 ae(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function ue(n){if(!Number.isInteger(n)||n<19000101||n>21001231)return!1;let e=Math.floor(n/100)%100,t=n%100;return e>=1&&e<=12&&t>=1&&t<=31}var Et=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Dt=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Ot=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function Lt(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function Be(n,e){let t=0,i=0,a=0,r=0,o=0,l="",u=0,m="",p=0,h=0,E=0,y=0,x=!1;for(let K of n){if(K==null)continue;let z=String(K).trim();if(z==="")continue;t++;let F;if(F=Et.exec(z)){let V=+F[2],Y=+F[3];V>=1&&V<=12&&Y>=1&&Y<=31&&(i++,F[4]!==void 0&&a++,F[6]!==void 0&&r++)}else if(F=Dt.exec(z)){let V=+F[3],Y=+F[4];V>=1&&V<=12&&Y>=1&&Y<=31&&(l&&l!==F[2]&&(x=!0),l=F[2],o++)}else if(F=Ot.exec(z)){let V=+F[1],Y=+F[3];V>=1&&V<=31&&Y>=1&&Y<=31&&(V<=12||Y<=12)&&(m&&m!==F[2]&&(x=!0),m=F[2],u++,V>12&&E++,Y>12&&y++,F[5]!==void 0&&p++,F[7]!==void 0&&h++)}if(t>=200)break}if(t<2||(i+o+u)/t<.8||(i>0?1:0)+(o>0?1:0)+(u>0?1:0)!==1||x)return null;if(i>0)return a===i?{pattern:r===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(o>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(E>0&&y>0)return null;let v,f;E>0?(v=!0,f="values"):y>0?(v=!1,f="values"):(v=!Lt(e),f="locale");let k=v?`%d${m}%m${m}%Y`:`%m${m}%d${m}%Y`;return p===u?{pattern:k+(h===u?" %H:%M:%S":" %H:%M"),orderFrom:f}:{pattern:k,orderFrom:f}}function Pt(n,e){if(!e||!/\b(?:19|20)\d{2}\b/.test(n))return!1;let t=n.replace(/\b(?:19|20)\d{2}\b/g,"").replace(/[-/.,]/g," ").trim();if(!t)return!1;let i=Se(t);return i.length>0&&e[i]!==void 0}function Gt(n){let{dataType:e,name:t,isMeasure:i,distinctCount:a}=n;if(e==="DateTime")return!0;if(i)return!1;if(e==="Integer"||e==="Decimal"){let r=n.minNum,o=n.maxNum;if(!(r!=null&&o!=null&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isInteger(r)&&Number.isInteger(o)&&o>=r))return!1;let u=r>=1900&&o<=2100;if(u&&a>=2&&It(t)||u&&a>=3&&a===o-r+1)return!0;let m=ae(r)&&ae(o),p=ue(r)&&ue(o);if(m||p){if(!n.sampleValues)return!0;let h=0,E=0;for(let y of n.sampleValues){if(y==null||y==="")continue;h++;let x=Number(String(y).trim());if(Number.isFinite(x)&&(m?ae(x):ue(x))&&E++,h>=60)break}if(h>=2&&E===h)return!0}return!1}if(n.sampleValues){let r=n.locale?Me(n.locale):null,o=0,l=0,u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;o++;let p=String(m).trim();if(u.push(p),(wt.test(p)||Pt(p,r))&&l++,o>=60)break}if(o>=2&&l/o>=.8||Be(u,n.locale)!==null)return!0}return!1}function kt(n){let e=j((n||"").trim().toLowerCase());return e.startsWith("sum ")||e.startsWith("total ")?"sum":e.startsWith("average ")||e.startsWith("avg. ")?"avg":e.startsWith("count ")||e.startsWith("distinct count ")||e.startsWith("count (distinct) ")?"count":e.startsWith("min ")||e.startsWith("minimum ")?"min":e.startsWith("max ")||e.startsWith("maximum ")?"max":ve.some(t=>e.startsWith(t+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":oe.some(t=>e.startsWith(t+" ")||e===t)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Ft(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:a,minNum:r,maxNum:o,discourageAgg:l}=n,u=100,m=.01,p="";for(let E of a){if(E.distinct<2||E.distinct>u)continue;let y=a.filter(f=>f.idx!==E.idx).map(f=>f.idx),x=new Map;for(let f of e){let k=f[t];if(typeof k!="number"||!Number.isFinite(k))continue;let K=y.length?y.map(F=>String(f[F])).join(p):"",z=x.get(K);z||(z={sum:0,cset:new Set},x.set(K,z)),z.sum+=k,z.cset.add(String(f[E.idx]))}let g=0,R=0,v=0;for(let f of x.values())f.cset.size<2||(v++,Math.abs(f.sum-100)<=100*m?g++:Math.abs(f.sum-1)<=1*m&&R++);if(v>=2&&(g/v>=.9||R/v>=.9))return{additivity:"part_of_whole",partOfWholeDim:E.name}}if(l)return{additivity:"intensive_rate"};let h=kt(i);return h==="avg"||h==="min"||h==="max"?{additivity:"intensive_rate"}:h==="count"?{additivity:"additive"}:h==="sum"?{additivity:"unknown"}:r!=null&&o!=null&&Number.isFinite(r)&&Number.isFinite(o)&&r>=0&&o<=1.0001&&o>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function ze(n){let{dataType:e,isMeasure:t,name:i,distinct:a,nonblank:r,prec:o,maxval:l,minval:u}=n,m=l-u+1,p=m>0?a/m:1,h=r>0?a/r:0,E=e==="Decimal"||o>0;return Nt(i)?"Categorical":p>=St&&(fe(i)&&a<=Mt||u>=Ct&&l<=At||u>=Tt&&l<=Rt)?"Ordinal":t||a>bt&&(E||a>=yt||h>=_t)?"Continuous":"Categorical"}var Ue=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;dedupRows=!0;emitLegacyAggAliases=!1;STR(e){return e==null?"":e instanceof Date?this.wholeDayIso(e)??(isNaN(e.getTime())?"":e.toISOString()):e.toString()}getPrecision(e){if(!isFinite(e))return 0;let i=e.toString().split(".")[1];return i?i.length:0}getColumns(){return this._cols}wholeDayIso(e){return de(e)}hasTimeComponent(e){return!(e instanceof Date)||isNaN(e.getTime())?!1:this.wholeDayIso(e)===null}getColumnsWithStats(e,t){if(this._computedStatsForLevel==e)return this._cols;let i=0,a=parseInt(e),r=[];for(let s of this._cols){let d=new Map,I=[],_=0,c=0,A=0,N=null,S=null,b=null,O=!1,w=!0,D=!0,L=null,P=!1;for(let M of this._rows){let C=M[i],T=this.STR(C);if(T!=""){if(_+=T.length,d.set(T,(d.get(T)||0)+1),c++,s.dataType=="Integer"||s.dataType=="Decimal"||s.dataType=="DateTime")if((N===null||C<N)&&(N=C),(S===null||C>S)&&(S=C),s.dataType=="Integer"||s.dataType=="Decimal"){if(b===null?b=C:b+=C,s.dataType=="Decimal"){let G=this.getPrecision(C);G>A&&(A=G)}I.push(C)}else O=O||this.hasTimeComponent(C);P&&(C<L?w=!1:C>L&&(D=!1)),L=C,P=!0}}if(c>=3&&(w&&!D?s.sortedDirection="asc":D&&!w?s.sortedDirection="desc":s.sortedDirection="none"),c>0&&d.size>0&&!s.isMeasure){let M=0,C=Number.MAX_SAFE_INTEGER;for(let T of d.values())T>M&&(M=T),T<C&&(C=T);if(s.modalShare=M/c,s.minGroupCount=C===Number.MAX_SAFE_INTEGER?null:C,d.size===2){let T=[...d.keys()].map(W=>ce(W).trim().toLowerCase()).sort(),B=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(W=>T[0]===W[0]&&T[1]===W[1]),U=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(s.name);(B||U)&&(s.isBinaryFlag=!0)}}if(s.dataType=="DateTime"&&(s.dateWithTime=O),s.isTemporal=Gt({dataType:s.dataType,name:s.name,isMeasure:s.isMeasure,distinctCount:d.size,minNum:typeof N=="number"?N:null,maxNum:typeof S=="number"?S:null,sampleValues:d.keys(),locale:t}),s.isTemporal&&s.dataType==="String"&&!s.isMeasure){let M=Be(d.keys(),t);M&&(s.temporalTextPattern=M.pattern)}if(s.isTemporal&&!s.isMeasure){let M=Fe(d.keys(),{includeBounds:a>=20,pattern:s.temporalTextPattern});M&&(s.temporalCadence=M)}this.updateColumnStats10(a,s,c,d,A,S,N),this.updateColumnStats20(a,I,c,b,s,_,O,N,S,A,d,t),!s.isMeasure&&(s.dataType==="Integer"||s.dataType==="Decimal")&&ze({dataType:s.dataType,isMeasure:!1,name:s.name,distinct:d.size,nonblank:c,prec:A,maxval:typeof S=="number"?S:0,minval:typeof N=="number"?N:0})==="Continuous"&&(s.isMeasure=!0,s.geoKind=void 0,s.geoMatchPct=void 0,s.geoAmbiguous=void 0,s.dominantGeoRegion=void 0,s.dominantGeoRegionPct=void 0,s.geoRegionCount=void 0),r[i]=s.isMeasure||d.size>2e3?null:new Set(d.keys()),i++}let o=[];this._cols.forEach((s,d)=>{s.isMeasure||o.push({idx:d,distinct:s.distinctCount??0,name:s.name})}),this._cols.forEach((s,d)=>{if(!s.isMeasure)return;let I=typeof s.lowValue=="number"?s.lowValue:null,_=typeof s.highValue=="number"?s.highValue:null,c=Ft({rows:this._rows,measureColIdx:d,measureName:s.name,candidateDims:o,minNum:I,maxNum:_,discourageAgg:!!s.discourageAggregationAcrossGroups});s.additivity=c.additivity,c.partOfWholeDim&&(s.partOfWholeDim=c.partOfWholeDim)});let l=50,u=o.filter(s=>s.distinct>=2&&s.distinct<=l);this._cols.forEach((s,d)=>{if(!s.isMeasure)return;let I=[];for(let T of this._rows){let G=T[d];if(G==null||G==="")continue;let B=typeof G=="number"?G:parseFloat(G);isNaN(B)||I.push(B)}if(I.length===0)return;let _=[...I].sort((T,G)=>T-G),c=T=>_[Math.min(_.length-1,Math.max(0,Math.floor(T*(_.length-1))))],A=c(.5),N=c(.1),S=c(.9),b=Math.abs(A)>1e-9?Math.abs(A):Math.abs(_[_.length-1])>1e-9?Math.abs(_[_.length-1]):1;s.relativeDispersion=Math.round((S-N)/b*1e3)/1e3;let O=[];for(let T of u){let G=new Set;for(let B of this._rows){let U=B[d];U==null||U===""||G.add(this.STR(B[T.idx])+"")}O.push({otherColumn:T.name,nonBlankGroupCount:G.size})}O.length>0&&(s.nonBlankGroups=O);let w=0;for(let T of I)w+=T;w/=I.length;let D=0;for(let T of I)D+=(T-w)*(T-w);if(D<=1e-12)return;let L=[],P=[],M=T=>{if(T.length<4)return NaN;let G=[...T].sort((U,W)=>U-W),B=U=>G[Math.min(G.length-1,Math.max(0,Math.floor(U*(G.length-1))))];return B(.75)-B(.25)},C=M(I);for(let T of u){let G=new Map;for(let W of this._rows){let H=W[d];if(H==null||H==="")continue;let Q=typeof H=="number"?H:parseFloat(H);if(isNaN(Q))continue;let le=this.STR(W[T.idx])+"",te=G.get(le);te?(te.s+=Q,te.n++,te.vals.push(Q)):G.set(le,{s:Q,n:1,vals:[Q]})}let B=0;for(let W of G.values()){let H=W.s/W.n;B+=W.n*(H-w)*(H-w)}L.push({otherColumn:T.name,eta2:Math.round(B/D*1e4)/1e4});let U=[];for(let W of G.values()){let H=M(W.vals);isNaN(H)||U.push(H)}if(U.length>=2&&isFinite(C)&&C>1e-9){let W=(Math.max(...U)-Math.min(...U))/C;P.push({otherColumn:T.name,spreadRatio:Math.round(W*1e4)/1e4})}}L.length>0&&(s.groupDiscrimination=L),P.length>0&&(s.spreadDiscrimination=P)});let m=.97,p=.8,h=8,E=5,y=this._cols.map((s,d)=>({c:s,i:d})).filter(s=>s.c.isMeasure);for(let s=0;s<y.length;s++)for(let d=s+1;d<y.length;d++){let I=y[s].i,_=y[d].i,c=0,A=0,N=0,S=0,b=0,O=0;for(let P of this._rows){let M=P[I],C=P[_];if(M==null||M===""||C===null||C===void 0||C==="")continue;let T=typeof M=="number"?M:parseFloat(M),G=typeof C=="number"?C:parseFloat(C);isNaN(T)||isNaN(G)||(c++,A+=T,N+=G,S+=T*T,b+=G*G,O+=T*G)}if(c<E)continue;let w=c*S-A*A,D=c*b-N*N;if(w<=1e-12||D<=1e-12)continue;let L=(c*O-A*N)/Math.sqrt(w*D);if(Math.abs(L)>=m){let P=y[s].c,M=y[d].c;P.collinearWithMeasures||(P.collinearWithMeasures=[]),M.collinearWithMeasures||(M.collinearWithMeasures=[]),P.collinearWithMeasures.push(M.name),M.collinearWithMeasures.push(P.name)}else if(Math.abs(L)>=p){let P=y[s].c,M=y[d].c,C=Math.round(L*1e3)/1e3;P.correlatedWithMeasures||(P.correlatedWithMeasures=[]),M.correlatedWithMeasures||(M.correlatedWithMeasures=[]),P.correlatedWithMeasures.push({otherColumn:M.name,r:C}),M.correlatedWithMeasures.push({otherColumn:P.name,r:C})}}for(let{c:s}of y)s.correlatedWithMeasures&&(s.correlatedWithMeasures.sort((d,I)=>Math.abs(I.r)-Math.abs(d.r)||(d.otherColumn<I.otherColumn?-1:1)),s.correlatedWithMeasures.length=Math.min(s.correlatedWithMeasures.length,h));for(let s=0;s<this._cols.length;s++){let d=r[s];if(!d||d.size===0)continue;let I=[];for(let _=0;_<this._cols.length;_++){if(_===s)continue;let c=r[_];if(!c||c.size===0)continue;let A=0;for(let S of d)c.has(S)&&A++;let N=Math.round(A/d.size*100);N>0&&I.push({otherColumn:this._cols[_].name,percentShared:N})}I.length>0&&(this._cols[s].sharedValueRatioWithOthers=I)}let x=50,g=[];for(let s=0;s<this._cols.length;s++){let d=r[s];d&&d.size>=2&&d.size<=x&&g.push(s)}if(g.length>=2){let s=new Map,d=(_,c)=>_+":"+c;for(let _=0;_<g.length;_++)for(let c=_+1;c<g.length;c++)s.set(d(g[_],g[c]),new Map);for(let _ of this._rows)for(let c=0;c<g.length;c++){let A=this.STR(_[g[c]])+"";for(let N=c+1;N<g.length;N++){let S=""+this.STR(_[g[N]]),b=s.get(d(g[c],g[N])),O=A+""+S;b.set(O,(b.get(O)??0)+1)}}let I=new Map;for(let _=0;_<g.length;_++)for(let c=_+1;c<g.length;c++){let A=g[_],N=g[c],S=r[A].size,b=r[N].size,O=s.get(d(A,N)),w=O.size,D=0;for(let C of O.values())(D===0||C<D)&&(D=C);let L=Math.round(w/(S*b)*100),P=w===S,M=w===b;if((this._cols[A].categoricalPairStats||=[]).push({otherColumn:this._cols[N].name,fillPct:L,determinesOther:P,minCellCount:D,distinctCombinations:w}),(this._cols[N].categoricalPairStats||=[]).push({otherColumn:this._cols[A].name,fillPct:L,determinesOther:M,minCellCount:D,distinctCombinations:w}),P&&S>b){let C=I.get(A);(!C||b<C.card)&&I.set(A,{name:this._cols[N].name,card:b,ratio:b/S})}if(M&&b>S){let C=I.get(N);(!C||S<C.card)&&I.set(N,{name:this._cols[A].name,card:S,ratio:S/b})}}for(let[_,c]of I)this._cols[_].primaryParentColumn=c.name,this._cols[_].nestingRatio=Math.round(c.ratio*100)/100}let R=6,v=this._rows.length;for(let s=0;s<this._cols.length;s++){let d=this._cols[s];if(d.isMeasure||d.primaryParentColumn)continue;let I=d.distinctCount??0;if(I<=x||v>0&&I>=v)continue;let _=[];for(let c=0;c<this._cols.length;c++){if(c===s)continue;let A=this._cols[c];if(A.isMeasure)continue;let N=A.distinctCount??0;N<2||N>=I||_.push(c)}_.sort((c,A)=>(this._cols[c].distinctCount??0)-(this._cols[A].distinctCount??0));for(let c of _.slice(0,R)){let A=new Map,N=!0;for(let b of this._rows){let O=this.STR(b[s])+"",w=this.STR(b[c])+"",D=A.get(O);if(D===void 0)A.set(O,w);else if(D!==w){N=!1;break}}if(!N)continue;let S=this._cols[c].distinctCount??0;d.primaryParentColumn=this._cols[c].name,d.nestingRatio=Math.round(S/I*100)/100;break}}let f=.01,k=.05,K=.95,z=8,F=8,V=6,Y=500,Z=[];for(let s=0;s<this._cols.length&&Z.length<F;s++){let d=this._cols[s].dataType;(d==="Double"||d==="Integer"||d==="Decimal")&&Z.push(s)}if(Z.length>=3&&this._rows.length>=z){let s=Math.min(this._rows.length,Y),d=Z.map(S=>{let b=[];for(let D=0;D<s;D++){let L=this._rows[D][S],P=typeof L=="number"?L:parseFloat(String(L).replace(/,/g,""));if(L==null||L===""||!isFinite(P))return null;b.push(P)}let O=b[0],w=!1;for(let D of b)if(D!==O){w=!0;break}return w?b:null}),I=Z.map((S,b)=>b).filter(S=>d[S]!==null),_=S=>{let b=S.slice().sort((w,D)=>w-D),O=b.length>>1;return b.length%2?b[O]:(b[O-1]+b[O])/2},c=null,A=[],N=S=>{if(A.length>=3){let b=A.map(L=>d[L]),O=b[0].length,w=new Array(O);for(let L=0;L<O;L++){let P=0;for(let M of b)P+=M[L];w[L]=P}let D=_(w);if(D>0){let L=0;for(let M of w)Math.abs(M-D)<=D*f&&L++;let P=L/O;if(P>=K){let M=1;for(let C of b){let T=_(C)/D;T<M&&(M=T)}M>=k&&(!c||A.length>c.cols.length)&&(c={cols:A.slice(),total:D,matched:P})}}}if(!(A.length>=V))for(let b=S;b<I.length;b++)A.push(I[b]),N(b+1),A.pop()};if(N(0),c){let S=c,O={columns:S.cols.map(w=>this._cols[Z[w]].name),total:Math.round(S.total*1e3)/1e3,matchedPct:Math.round(S.matched*100)/100};for(let w of S.cols)this._cols[Z[w]].constantSumGroup=O}}return this._computedStatsForLevel=e,this._cols}updateColumnStats20(e,t,i,a,r,o,l,u,m,p,h,E){if(e>=20){let y=[...t].sort((R,v)=>R-v),x=Math.floor(y.length/2);if(i>0&&a!=null?r.avgValue=r.dataType=="Integer"?Math.round(a/i):a/i:r.avgValue=null,i>0&&(r.avgLength=o/i),this._rows.length>0){let R=v=>{let f=v instanceof Date?v:typeof v=="string"?re(v)??new Date(v):new Date(v),k=this.wholeDayIso(f);return k?k+"T00:00:00.000Z":isNaN(f.getTime())?v:f.toISOString().slice(0,10)+"T00:00:00.000Z"};r.dataType!="DateTime"||l||!u?r.lowValue=u:r.lowValue=R(u),r.dataType!="DateTime"||l||!m?r.highValue=m:r.highValue=R(m),r.medianValue=y.length===0?null:y.length%2===0?r.dataType=="Integer"?Math.round((y[x-1]+y[x])/2):(y[x-1]+y[x])/2:y[x],r.numericPrecision=p}if(y.length>0){let R=r.avgValue??0,v=y.length,f=0,k=0;for(let z of y){let F=z-R;f+=F*F,k+=F*F*F}let K=f/v;r.skewness=K===0?0:k/v/Math.pow(Math.sqrt(K),3),r.stdDev=Math.sqrt(K)}a!==null&&(r.sum=a);let g=Array.from(h.entries()).sort((R,v)=>v[1]-R[1]);if(r.topCategories=g.slice(0,10).map(R=>R[1]),!r.isMeasure&&g.length>0){if(r.dataType==="String"){let R=g.map(f=>f[0]);r.formatSignature=_e(R);let v=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;r.formatSignature&&!v.test(r.formatSignature)&&(r.avgLength===void 0||r.avgLength>=3)&&(r.isFreeText=!0)}else r.topCategoryValues=g.slice(0,5).map(R=>R[0]);if(e>=20){let R=g.map(f=>f[0]),v=pe(R,E);if(v!==null)r.ordinalPattern=v.pattern,r.orderedDomain=v.orderedDomain;else if(r.dataType==="String"){let f=ge(R);f!==null&&(r.safeDistinctValues=f)}}}if(y.length>=8&&(r.dataType==="Integer"||r.dataType==="Decimal")){let R=v=>y[Math.floor((y.length-1)*v)];r.quantiles={p05:R(.05),p25:R(.25),p75:R(.75),p95:R(.95)}}}if(!r.isMeasure&&h.size>0){let y=Array.from(h.entries()).sort((g,R)=>R[1]-g[1]),x=ye(y.map(g=>g[0]),r.name,E);if(x!==null&&(r.geoKind=x.geoKind,r.geoMatchPct=x.geoMatchPct,x.geoAmbiguous&&(r.geoAmbiguous=!0),x.geoKind.indexOf("country")===0)){let g=se(y);g&&(r.dominantGeoRegion=g.dominantGeoRegion,r.dominantGeoRegionPct=g.dominantGeoRegionPct,r.geoRegionCount=g.regionCount)}}}updateColumnStats10(e,t,i,a,r,o,l){e>=10&&(t.blankCount=this._rows.length-i,t.distinctCount=a.size+(t.blankCount!=0?1:0),t.valueNature="Categorical",i>0&&(t.dataType==="Integer"||t.dataType==="Decimal"?t.valueNature=ze({dataType:t.dataType,isMeasure:!!t.isMeasure,name:t.name,distinct:a.size,nonblank:i,prec:r,maxval:o,minval:l}):t.dataType==="DateTime"&&(t.valueNature=t.dateWithTime?"Continuous":"Ordinal")))}getRowCount(){return this._rows.length}getLeafCardinality(){if(this._leafCardinality!==null)return this._leafCardinality;let e=[];if(this._cols.forEach((i,a)=>{i.isMeasure||e.push(a)}),e.length===0)return this._leafCardinality=this._rows.length,this._leafCardinality;let t=new Set;for(let i of this._rows)t.add(JSON.stringify(e.map(a=>i[a])));return this._leafCardinality=t.size,this._leafCardinality}_leafCardinality=null;getGeoExtent(){if(this._geoExtentComputed)return this._geoExtent;this._geoExtentComputed=!0,this._geoExtent=null;let e=o=>String(o||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),t=-1,i=-1,a=-1;if(this._cols.forEach((o,l)=>{let u=e(o.name),m=o.dataType==="Integer"||o.dataType==="Decimal";m&&t<0&&u.some(p=>p==="lat"||p==="latitude")?t=l:m&&i<0&&u.some(p=>p==="lon"||p==="lng"||p==="long"||p==="longitude")&&(i=l),a<0&&!o.isMeasure&&typeof o.geoKind=="string"&&o.geoKind.indexOf("country")===0&&(a=l)}),t<0||i<0)return null;let r=[];for(let o of this._rows){let l=o[t],u=o[i],m=l==null||l===""?null:Number(l),p=u==null||u===""?null:Number(u);r.push({lat:m,lon:p,country:a>=0&&ie(this.STR(o[a]))?this.STR(o[a]):null})}return this._geoExtent=Te(r),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){let t="abcdefghijklmnopqrstuvwxyz",i=()=>t[Math.floor(q()*t.length)],a=()=>i().toUpperCase(),r=()=>Math.floor(q()*10).toString(),o=x=>/[A-Z]/.test(x)?a():/[a-z]/.test(x)?i():/[0-9]/.test(x)?r():x,l=e.includes("@")&&e.includes("."),u=l?e.split("@"):[e],m=l?u[1]:"",p=m.endsWith(".com"),h=p?".com":"",E=p?m.slice(0,-4):m,y=x=>{let g="";for(let R of x)g+=o(R),/[a-zA-Z0-9]/.test(R)&&q()<.2&&(g+=o(R));if(g.length>6){let R=Math.floor(q()*Math.min(3,g.length-6));for(let v=0;v<R;v++){let f=0;for(;f<5;){let k=Math.floor(q()*g.length);if(/[a-zA-Z0-9]/.test(g[k])){g=g.slice(0,k)+g.slice(k+1);break}f++}}}return g};if(l){let x=y(u[0]),g=y(E);return`${x}@${g}${h}`}else return y(e)}toObjectArray(){return this._rows.map(e=>{let t={};return this._cols.forEach((i,a)=>{t[i.name]=e[a],this.emitLegacyAggAliases&&i.hostName&&i.hostName!==i.name&&!Object.prototype.hasOwnProperty.call(t,i.hostName)&&(t[i.hostName]=e[a])}),t})}async getCSVAsync(e){let t=[],i=e?25:1e7,a=e?4e3:1e7,r=new Map;for(let l of this._rows){let u={};for(let m=0;m<this._cols.length;m++){let p=this._cols[m],h=l[m];if(this.STR(h)!=""){if(e&&p.dataType=="String")if(r.has(h))h=r.get(h);else{let E=this.obfuscateString(h);r.set(h,E),h=E}else if(p.dataType=="DateTime"&&!p.dateWithTime){let E=h instanceof Date?h:typeof h=="string"?re(h)??new Date(h):new Date(h);h=(this.wholeDayIso(E)??E.toISOString().slice(0,10))+"T00:00:00.000Z"}a-=this.STR(h).length}else h=null;u[m]=h,--a}if(t.push(u),--i,i<=0||a<=0)break}return await We.unparse(t,{header:!1})}getCSVHeaderLine(){return We.unparse([this._cols.map(e=>this.STR(this.emitLegacyAggAliases&&e.hostName?e.hostName:e.name))])}addRow(e,t){if(this.dedupRows){let i="";for(let r of e)i+=this.STR(r)+"~";let a=me(i);if(this._rowHashes.has(a))return!1;this._rowHashes.add(a)}return this._rows.push(e),this._origIndices.push(t??-1),!0}getOriginalRowIndex(e){return e<0||e>=this._origIndices.length?-1:this._origIndices[e]}reset(){this._cols=[],this._rows=[],this._origIndices=[],this._rowHashes=new Set,this._leafCardinality=null}setColumns(e){if(this._cols=e,!e||e.length===0)return;let t=new Set(e.map(i=>this.STR(i?.name)));for(let i of e){if(!i)continue;let a=this.STR(i.name),r=Ie(a);!r||r===a||t.has(r)||(t.delete(a),t.add(r),i.hostName=a,i.name=r)}}};export{Te as a,He as b,ie as c,zt as d,Ke as e,$e as f,Ze as g,Xe as h,xe as i,et as j,Ie as k,Vt as l,Ee as m,it as n,Oe as o,Le as p,Yt as q,Ht as r,Kt as s,Zt as t,Xt as u,gt as v,Fe as w,Nt as x,Be as y,Gt as z,kt as A,Ft as B,ze as C,Ue as D};
@@ -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 T(t){return t?t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-./]+/g," ").toLowerCase().split(/\s+/).filter(e=>e.length>0):[]}function p(t){return t!=null?t.toString():""}function y(t){if(!t)return 0;let e=0xcbf29ce484222325n,n=0x100000001b3n,o=e;for(let r=0;r<t.length;r++)o^=BigInt(t.charCodeAt(r)),o=o*n&0xFFFFFFFFFFFFFFFFn;return Number(o&0x1FFFFFFFFFFFFFn)}function D(){let t=typeof globalThis<"u"?globalThis:{};if(t.crypto&&typeof t.crypto.getRandomValues=="function"){let e=new Uint32Array(1);return t.crypto.getRandomValues(e),e[0]/4294967296}return Math.floor(Date.now()%4294967295)/4294967296}function m(t){return!!t&&t.isRefusal===!0}var x=30;function R(t){let e=Date.parse(t);if(isNaN(e))return null;let n=new Date(e);if(f.test(t)||g.test(t.trim())||d.test(t))return n;let o=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds())),r=n.getFullYear();return r>=0&&r<100&&o.setUTCFullYear(r),o}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 M(t){let e=u(t);if(!e)return null;let n=t;if(e==="utc")return n.toISOString().slice(0,10);let o=r=>(r<10?"0":"")+r;return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())}`}function c(t){let e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())),n=t.getFullYear();return n>=0&&n<100&&e.setUTCFullYear(n),e}function F(t,e){let n=[];for(let o of t){if(!o||!/date|time/i.test(String(o.dataType??"")))continue;let r=0,l=!0;for(let s of e){let i=s?s[o.name]:void 0;if(i==null||i==="")continue;if(!(i instanceof Date)){l=!1;break}let a=u(i);if(a===null){l=!1;break}a==="local"&&r++}l&&r>0&&n.push(o.name)}return n}function h(t,e){let n=F(t,e);return n.length===0?{rows:e,columns:n}:{rows:e.map(r=>{if(!r)return r;let l={...r};for(let s of n){let i=l[s];i instanceof Date&&u(i)==="local"&&(l[s]=c(i))}return l}),columns:n}}var f=/^\s*\d{4}(-\d{2}(-\d{2})?)?\s*$/,g=/(?:Z|[+-]\d{2}:?\d{2})$/i,d=/\b(?:GMT|UTC)\b/i;export{T as a,p as b,y as c,D as d,m as e,x as f,R as g,u as h,M as i,c as j,F as k,h as l};