@bicharts/shape-core 0.5.117 → 0.5.119

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{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};
2
+ import{a as h}from"./chunk-FUTSF2X5.mjs";var b=[{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 t of b)for(let r of t.canonical)n.add(d(r));return n})(),q=(()=>{let n=new Map;for(let[t,r]of Object.entries(v)){let e=d(t);x.has(e)||n.has(e)||n.set(e,d(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 K(n){if(!n)return!1;for(let t of h(n))if(D.has(t))return!0;return!1}function d(n){return n.toLowerCase().replace(/[-_]+/g," ").replace(/\s+/g," ").trim()}function g(n){let t=new Map;for(let[r,e]of n)for(let a of r)t.set(d(a),e);return t}var _=[{name:"weekday_mon_sun",minMatches:4,dict:g([[["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:g([[["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:g([[["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 C(n){let t=n||"";if(!t)return{weekday:new Map,month:new Map};let r=p[t];if(r)return r;let e=new Map,a=new Map,i=(s,l,m)=>{let u=d(l);u&&s.set(u,m);let c=d(l.replace(/\./g,""));c&&c!==u&&s.set(c,m)};try{let s=new Intl.DateTimeFormat(t,{weekday:"long"}),l=new Intl.DateTimeFormat(t,{weekday:"short"});for(let c=0;c<7;++c){let f=new Date(Date.UTC(2024,0,1+c));i(e,s.format(f),c),i(e,l.format(f),c)}let m=new Intl.DateTimeFormat(t,{month:"long"}),u=new Intl.DateTimeFormat(t,{month:"short"});for(let c=0;c<12;++c){let f=new Date(Date.UTC(2020,c,15));i(a,m.format(f),c),i(a,u.format(f),c)}}catch{}let o={weekday:e,month:a};return p[t]=o,o}function M(n,t){if(t.size===0)return n;let r=new Map(n);for(let[e,a]of t)r.has(e)||r.set(e,a);return r}function N(n,t){let r=C(t);for(let e of _){let a=e.name==="weekday_mon_sun"?M(e.dict,r.weekday):e.name==="month_jan_dec"?M(e.dict,r.month):e.dict,i=!0,o=new Map;for(let[l,m]of n){let u=a.get(l);if(u===void 0){i=!1;break}o.has(u)||o.set(u,m)}if(!i||o.size<e.minMatches)continue;let s=[...o.entries()].sort((l,m)=>l[0]-m[0]).map(l=>l[1]);return{pattern:e.name,orderedDomain:s}}return null}function w(n){let t=new Map;for(let r of n){if(r==null)continue;let e=String(r);if(e.length===0)continue;let a=d(e);t.has(a)||t.set(a,e)}return t}var S=15,R=10,O=(()=>{let n=["xxs","xs","s","sm","small","m","med","medium","l","lg","large","xl","xlarge","xxl","xxxl","2xl","3xl","4xl","y","n","yes","no","t","f","true","false","na","n/a","n a","none","null","unknown","other","all","both","low","medium","med","high","very low","very high","minimal","critical","urgent"],t=new Set(n.map(d));for(let r of _)for(let e of r.dict.keys())t.add(e);return t})();function A(n){let t=n.trim();return t.length===0||t.length>R||(t.match(/\p{L}/gu)||[]).length>1?!1:/\p{Nd}/u.test(t)}function E(n){let t=n.trim();return t.length===1&&/[\p{L}\p{Nd}]/u.test(t)}function V(n){if(!n||n.length===0)return null;let t=new Set,r=[];for(let e of n){if(e==null)continue;let a=String(e);if(t.has(a))continue;let i=d(a);if(!(i===""||O.has(i)||A(a)||E(a))||(t.add(a),r.push(a),r.length>S))return null}return r.length>0?r:null}var I=/^(\p{L}{0,3}) ?([0-9]+)\s*[-–—:.)]\s*(.+)$/u;function T(n){let t=null,r=new Set,e=[];for(let a of n.values()){let i=I.exec(a.trim());if(!i)return null;let o=i[1].toLowerCase();if(t===null)t=o;else if(o!==t)return null;let s=Number(i[2]);if(r.has(s)||d(i[3])==="")return null;r.add(s),e.push({code:s,original:a,label:i[3]})}return e}function L(n,t){let r=k(w(n.map(s=>s.label)),t);if(r===null)return;if(r.orderedDomain.length!==n.length)return null;let e=new Map;for(let s of n)e.set(s.label,s);let a=r.orderedDomain.map(s=>e.get(s));if(a.some(s=>s===void 0))return null;let i=!0,o=!0;for(let s=1;s<a.length;++s)a[s].code<=a[s-1].code&&(i=!1),a[s].code>=a[s-1].code&&(o=!1);return!i&&!o?null:{pattern:r.pattern,orderedDomain:a.map(s=>s.original)}}function Y(n,t){if(!n||n.length<2)return null;let r=w(n);if(r.size<2)return null;let e=T(r);if(e!==null){let i=L(e,t);if(i!==void 0)return i}let a=k(r,t);return a!==null?a:e!==null?P(r):null}var F=/^([0-9]+)\s*(?:\.|\)|-)\s*([^\s\d].*)$/u,j=3,z=20;function P(n){if(n.size<j||n.size>z)return null;let t=new Set,r=[];for(let e of n.values()){let a=F.exec(e.trim());if(!a||d(a[2])==="")return null;let i=Number(a[1]);if(t.has(i))return null;t.add(i),r.push({n:i,original:e})}return r.sort((e,a)=>e.n-a.n),{pattern:"numeric_rank_prefix",orderedDomain:r.map(e=>e.original)}}function k(n,t){let r=new Map;for(let[a,i]of n){let o=y(a);r.has(o)||r.set(o,i)}let e=null;for(let a of b){let i=[];for(let m of a.canonical){let u=r.get(m);u!==void 0&&i.push(u)}if(i.length<a.minMatches)continue;let o=new Set(a.canonical),s=!0;for(let m of n.keys())if(!o.has(y(m))){s=!1;break}if(!s)continue;let l;e===null||i.length>e.matched||i.length===e.matched&&a.canonical.length<e.pattern.canonical.length?l=!0:l=!1,l&&(e={pattern:a,matched:i.length,orderedDomain:i})}return e?{pattern:e.pattern.name,orderedDomain:e.orderedDomain}:N(n,t)}export{K as a,V as b,Y 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 be}from"./chunk-QEH7WTLB.mjs";import{a as ye,b as _e}from"./chunk-2LR73DNS.mjs";import{c as pe}from"./chunk-OZEOA6ZE.mjs";import{b as ge,f as he}from"./chunk-E6SVTFAW.mjs";import{a as me,b as de,c as fe}from"./chunk-N3ZYRMZJ.mjs";import{a as X,b as ue,c as B,d as le,e as j,h as ne,j as ce}from"./chunk-FUTSF2X5.mjs";var Ye=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],He=[7,72,-172,-52];function Ae(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var $=n=>Math.round(n*10)/10;function Ce(n,e=3){let t=[],i=[],a=0,s=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?te(y):null;C?((y==="US"||y==="USA")&&a++,C==="north-america"&&s++):(Ye.some(O=>Ae(u,m,O))&&a++,Ae(u,m,He)&&s++)}let r=t.length;return r<e?null:(t.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:$(a/r*100),pctNa:$(s/r*100),latP5:$(B(t,.05)),latP95:$(B(t,.95)),lonP5:$(B(i,.05)),lonP95:$(B(i,.95)),n:r})}var Se={"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(Se))for(let t of Se[e].split(/\s+/))t&&n.set(t,e);return n})();function $e(n){for(let[e,t]of n){let i=Q.get(e);i&&!Q.has(t)&&Q.set(t,i)}}$e(ge);function te(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=he(String(n));return i?Q.get(i)??null:null}function Kt(n,e=2){return ie(n.map(t=>[t,1]),e)}function ie(n,e=2){let t=new Map,i=0;for(let[r,l]of n){let u=te(r);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",s=-1;for(let r of Array.from(t.keys()).sort()){let l=t.get(r);l>s&&(a=r,s=l)}return{dominantGeoRegion:a,dominantGeoRegionPct:$(s/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","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"],Ze=["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"],je=["latitude","longitude"],Xe=["latitude","longitude"];function K(n){return Array.from(n).map(e=>{let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===1?t:e}).join("")}var se=["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"],Re=["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 Qe(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+|(?:"+Qe(se)+")\\s+)","i"),qe=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Je=new RegExp("\\b("+Ke.join("|")+")\\b|("+Ze.join("|")+")$","i"),et=new RegExp("\\b("+je.join("|")+")\\b|("+Xe.join("|")+")$","i");function Te(n){if(!n)return"";let e=String(n),t=Ne.exec(K(e));return(t?e.slice(t[0].length):e).trim()}function tt(n){return!!n&&Ne.test(K(String(n)))}var nt=["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*("+[...nt].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function ve(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]),s=e.slice(t[0].length),r=0;for(;r<8;){let l=Me.exec(s);if(!l||i(l[1])!==a)break;let u=s.slice(l[0].length);if(u.trim()==="")break;s=u,r++}return r===0?e:e.slice(0,t[0].length)+s}function re(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}var xe={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},it=new RegExp("^("+Object.keys(xe).join("|")+")\\((.+)\\)$");function we(n){if(!n)return[];let e=it.exec(String(n).trim());if(!e)return[];let t=xe[e[1]],i=e[2],a=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let r=i.slice(s+1);if(r.trim()!=="")for(let l of t){let u=l+r;a.includes(u)||a.push(u)}}return a}function st(n){let e=Te(n);return e.length===0?"":e.replace(qe," ")}function Ie(n,e){if(!e)return!1;let t=Te(e);return n.test(K(st(e)))||n.test(K(t))||n.test(K(X(t).join(" ")))}function Ee(n){return Ie(et,n)}function rt(n){return Ie(Je,n)||Ee(n)}var De=/int|double|decimal|single|float|number|currency|money/i;function ot(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 at(n){return n?.isMeasure===!0||De.test(String(n?.dataType??""))}function Oe(n){let e=n??{},t=ot(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"&&tt(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}:rt(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 at(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 Xt(n){return Le(n)[0]}function Qt(n,e){return Le(n).indexOf(e)>=0}function qt(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 ut=/^[A-Za-z_$][A-Za-z0-9_$]*$/,lt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ct=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function q(n,e){if(!n||!e)return!1;let t=lt(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:ut.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function mt(n){return!!n&&ct.test(n)}function en(n,e,t){return n?mt(n)?[...e]:[...t,...e].some(i=>q(n,i))?e.filter(i=>q(n,i)):[...e]:[]}var nn=5,sn=6;var dt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ft=/^(\d{4})[-/](\d{1,2})$/,gt=/^(\d{4})[-\s]?Q([1-4])$/i,ht=/^Q([1-4])[-\s](\d{4})$/i,pt=/^(\d{4})$/,bt=/^(\d{4})(0[1-9]|1[0-2])$/,yt=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/;function Y(n,e,t,i=0,a=0,s=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let r=Date.UTC(n,e-1,t,i,a,s);if(!Number.isFinite(r))return null;let l=u=>u<10?"0"+u:String(u);return{ms:r,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function _t(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 s=0,r=1,l=1;return t.forEach((u,m)=>{let y=+a[m+1];u==="Y"?s=y:u==="m"?r=y:l=y}),s?Y(s,r,l):null}function At(n,e){let t=(n??"").trim();if(t==="")return null;if(e){let a=_t(t,e);return a||null}let i=dt.exec(t);if(i)return Y(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=gt.exec(t),i)return Y(+i[1],(+i[2]-1)*3+1,1);if(i=ht.exec(t),i)return Y(+i[2],(+i[1]-1)*3+1,1);if(i=ft.exec(t),i&&+i[2]>=1&&+i[2]<=12)return Y(+i[1],+i[2],1);if(i=yt.exec(t),i)return Y(+i[1],+i[2],+i[3]);if(i=bt.exec(t),i)return Y(+i[1],+i[2],1);if(i=pt.exec(t),i){let a=+i[1];return a>=1900&&a<=2100?Y(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,s=n+i*7*864e5;for(;s<e;)Ge(s)&&a++,s+=864e5;return a}function St(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 Ct(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,s=new Map;for(let f of n){if(f==null||f==="")continue;i++;let G=At(String(f),e?.pattern);G&&(a++,s.set(G.ms,G))}let r=[...s.values()].sort((f,G)=>f.ms-G.ms);if(r.length<3||i>0&&a/i<.8)return null;let l=r[r.length-1].ms-r[0].ms;if(l<=0)return null;let u=[];for(let f=1;f<r.length;f++)u.push(r[f].ms-r[f-1].ms);let m=St(u);if(!(m>0))return null;let y=Ct(m/864e5);y==="day"&&l>=7*864e5&&r.every(f=>Ge(f.ms))&&ke(r[0].ms,r[r.length-1].ms)+1>r.length*.5&&(y="weekday");let C=y==="irregular"?r.length:Pe(r[0],r[r.length-1],y,m)+1,O=1,I=1,M=[],w=r[0],g=1;for(let f=1;f<r.length;f++){let G=Pe(r[f-1],r[f],y,m);G>O&&(O=G),y!=="irregular"&&G>t?(I++,M.push({from:w.iso,to:r[f-1].iso,points:g}),w=r[f],g=1):g++}M.push({from:w.iso,to:r[r.length-1].iso,points:g});let x={grain:y,points:r.length,expectedPoints:Math.max(C,r.length),coveragePct:Math.round(r.length/Math.max(C,r.length)*1e3)/10,runs:I,largestGapUnits:O,gapFactor:t};return e?.includeBounds&&M.length<=6&&(x.runBounds=M),x}var Mt=12,Rt=100,Nt=.3,Tt=.9,vt=120,xt=1900,wt=2100,It=0,Et=20,Dt=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ot(n){if(!n)return!1;let e=X(n);return e.length===0?!1:Dt.has(e[e.length-1])}var Lt=new Set(["year","yr","fy"]),Pt=n=>X(n).some(e=>Lt.has(e)),Gt=/^(?:(?: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 oe(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function ae(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 kt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Ft=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Wt=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function zt(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function Ve(n,e){let t=0,i=0,a=0,s=0,r=0,l="",u=0,m="",y=0,C=0,O=0,I=0,M=!1;for(let V of n){if(V==null)continue;let W=String(V).trim();if(W==="")continue;t++;let k;if(k=kt.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&&s++)}else if(k=Ft.exec(W)){let z=+k[3],U=+k[4];z>=1&&z<=12&&U>=1&&U<=31&&(l&&l!==k[2]&&(M=!0),l=k[2],r++)}else if(k=Wt.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]&&(M=!0),m=k[2],u++,z>12&&O++,U>12&&I++,k[5]!==void 0&&y++,k[7]!==void 0&&C++)}if(t>=200)break}if(t<2||(i+r+u)/t<.8||(i>0?1:0)+(r>0?1:0)+(u>0?1:0)!==1||M)return null;if(i>0)return a===i?{pattern:s===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(r>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(O>0&&I>0)return null;let x,f;O>0?(x=!0,f="values"):I>0?(x=!1,f="values"):(x=!zt(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 Ut(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=ye(t);return i.length>0&&e[i]!==void 0}function Vt(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 s=n.minNum,r=n.maxNum;if(!(s!=null&&r!=null&&Number.isFinite(s)&&Number.isFinite(r)&&Number.isInteger(s)&&Number.isInteger(r)&&r>=s))return!1;let u=s>=1900&&r<=2100;if(u&&a>=2&&Pt(t)||u&&a>=3&&a===r-s+1)return!0;let m=oe(s)&&oe(r),y=ae(s)&&ae(r);if(m||y){if(!n.sampleValues)return!0;let C=0,O=0;for(let I of n.sampleValues){if(I==null||I==="")continue;C++;let M=Number(String(I).trim());if(Number.isFinite(M)&&(m?oe(M):ae(M))&&O++,C>=60)break}if(C>=2&&O===C)return!0}return!1}if(n.sampleValues){let s=n.locale?_e(n.locale):null,r=0,l=0,u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;r++;let y=String(m).trim();if(u.push(y),(Gt.test(y)||Ut(y,s))&&l++,r>=60)break}if(r>=2&&l/r>=.8||Ve(u,n.locale)!==null)return!0}return!1}function Bt(n){let e=K((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":Re.some(t=>e.startsWith(t+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":se.some(t=>e.startsWith(t+" ")||e===t)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Yt(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:a,minNum:s,maxNum:r,discourageAgg:l}=n,u=100,m=.01,y="";for(let O of a){if(O.distinct<2||O.distinct>u)continue;let I=a.filter(f=>f.idx!==O.idx).map(f=>f.idx),M=new Map;for(let f of e){let G=f[t];if(typeof G!="number"||!Number.isFinite(G))continue;let V=I.length?I.map(k=>String(f[k])).join(y):"",W=M.get(V);W||(W={sum:0,cset:new Set},M.set(V,W)),W.sum+=G,W.cset.add(String(f[O.idx]))}let w=0,g=0,x=0;for(let f of M.values())f.cset.size<2||(x++,Math.abs(f.sum-100)<=100*m?w++:Math.abs(f.sum-1)<=1*m&&g++);if(x>=2&&(w/x>=.9||g/x>=.9))return{additivity:"part_of_whole",partOfWholeDim:O.name}}if(l)return{additivity:"intensive_rate"};let C=Bt(i);return C==="avg"||C==="min"||C==="max"?{additivity:"intensive_rate"}:C==="count"?{additivity:"additive"}:C==="sum"?{additivity:"unknown"}:s!=null&&r!=null&&Number.isFinite(s)&&Number.isFinite(r)&&s>=0&&r<=1.0001&&r>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function ze(n){let{dataType:e,isMeasure:t,name:i,distinct:a,nonblank:s,prec:r,maxval:l,minval:u}=n,m=l-u+1,y=m>0?a/m:1,C=s>0?a/s:0,O=e==="Decimal"||r>0;return Ot(i)?"Categorical":y>=Tt&&(me(i)&&a<=vt||u>=xt&&l<=wt||u>=It&&l<=Et)?"Ordinal":t||a>Mt&&(O||a>=Rt||C>=Nt)?"Continuous":"Categorical"}var Ue=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;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 ce(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),s=[];for(let o of this._cols){let d=new Map,E=[],A=0,c=0,R=0,T=null,N=null,S=null,P=!1,L=!0,b=!0,_=null,v=!1;for(let h of this._rows){let p=h[i],D=this.STR(p);if(D!=""){if(A+=D.length,d.set(D,(d.get(D)||0)+1),c++,o.dataType=="Integer"||o.dataType=="Decimal"||o.dataType=="DateTime")if((T===null||p<T)&&(T=p),(N===null||p>N)&&(N=p),o.dataType=="Integer"||o.dataType=="Decimal"){if(S===null?S=p:S+=p,o.dataType=="Decimal"){let F=this.getPrecision(p);F>R&&(R=F)}E.push(p)}else P=P||this.hasTimeComponent(p);v&&(p<_?L=!1:p>_&&(b=!1)),_=p,v=!0}}if(c>=3&&(L&&!b?o.sortedDirection="asc":b&&!L?o.sortedDirection="desc":o.sortedDirection="none"),c>0&&d.size>0&&!o.isMeasure){let h=0,p=Number.MAX_SAFE_INTEGER;for(let D of d.values())D>h&&(h=D),D<p&&(p=D);if(o.modalShare=h/c,o.minGroupCount=p===Number.MAX_SAFE_INTEGER?null:p,d.size===2){let D=[...d.keys()].map(ee=>ue(ee).trim().toLowerCase()).sort(),J=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ee=>D[0]===ee[0]&&D[1]===ee[1]),Z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(o.name);(J||Z)&&(o.isBinaryFlag=!0)}}if(o.dataType=="DateTime"&&(o.dateWithTime=P),o.isTemporal=Vt({dataType:o.dataType,name:o.name,isMeasure:o.isMeasure,distinctCount:d.size,minNum:typeof T=="number"?T:null,maxNum:typeof N=="number"?N:null,sampleValues:d.keys(),locale:t}),o.isTemporal&&o.dataType==="String"&&!o.isMeasure){let h=Ve(d.keys(),t);h&&(o.temporalTextPattern=h.pattern)}if(o.isTemporal&&!o.isMeasure){let h=Fe(d.keys(),{includeBounds:a>=20,pattern:o.temporalTextPattern});h&&(o.temporalCadence=h)}this.updateColumnStats10(a,o,c,d,R,N,T),this.updateColumnStats20(a,E,c,S,o,A,P,T,N,R,d,t),!o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal")&&ze({dataType:o.dataType,isMeasure:!1,name:o.name,distinct:d.size,nonblank:c,prec:R,maxval:typeof N=="number"?N:0,minval:typeof T=="number"?T:0})==="Continuous"&&(o.isMeasure=!0,o.geoKind=void 0,o.geoMatchPct=void 0,o.geoAmbiguous=void 0,o.dominantGeoRegion=void 0,o.dominantGeoRegionPct=void 0,o.geoRegionCount=void 0),s[i]=o.isMeasure||d.size>2e3?null:new Set(d.keys()),i++}let r=[];this._cols.forEach((o,d)=>{o.isMeasure||r.push({idx:d,distinct:o.distinctCount??0,name:o.name})}),this._cols.forEach((o,d)=>{if(!o.isMeasure)return;let E=typeof o.lowValue=="number"?o.lowValue:null,A=typeof o.highValue=="number"?o.highValue:null,c=Yt({rows:this._rows,measureColIdx:d,measureName:o.name,candidateDims:r,minNum:E,maxNum:A,discourageAgg:!!o.discourageAggregationAcrossGroups});o.additivity=c.additivity,c.partOfWholeDim&&(o.partOfWholeDim=c.partOfWholeDim)});let l=50,u=4,m=r.filter(o=>o.distinct>=2&&o.distinct<=l);this._cols.forEach((o,d)=>{if(!o.isMeasure)return;let E=[];for(let b of this._rows){let _=b[d];if(_==null||_==="")continue;let v=typeof _=="number"?_:parseFloat(_);isNaN(v)||E.push(v)}if(E.length===0)return;let A=[...E].sort((b,_)=>b-_);if(A[0]===A[A.length-1])o.relativeDispersion=0;else if(A.length>=u){let b=B(A,.5),_=B(A,.1),v=B(A,.9),h=Math.abs(b)>1e-9?Math.abs(b):Math.abs(A[A.length-1])>1e-9?Math.abs(A[A.length-1]):1;o.relativeDispersion=Math.round((v-_)/h*1e3)/1e3}else o.relativeDispersion=void 0;let c=[];for(let b of m){let _=new Set;for(let v of this._rows){let h=v[d];h==null||h===""||_.add(this.STR(v[b.idx])+"")}c.push({otherColumn:b.name,nonBlankGroupCount:_.size})}c.length>0&&(o.nonBlankGroups=c);let R=0;for(let b of E)R+=b;R/=E.length;let T=0;for(let b of E)T+=(b-R)*(b-R);if(T<=1e-12)return;let N=[],S=[],P=b=>{if(b.length<4)return NaN;let _=[...b].sort((h,p)=>h-p),v=h=>_[Math.min(_.length-1,Math.max(0,Math.floor(h*(_.length-1))))];return v(.75)-v(.25)},L=P(E);for(let b of m){let _=new Map;for(let p of this._rows){let D=p[d];if(D==null||D==="")continue;let F=typeof D=="number"?D:parseFloat(D);if(isNaN(F))continue;let J=this.STR(p[b.idx])+"",Z=_.get(J);Z?(Z.s+=F,Z.n++,Z.vals.push(F)):_.set(J,{s:F,n:1,vals:[F]})}let v=0;for(let p of _.values()){let D=p.s/p.n;v+=p.n*(D-R)*(D-R)}N.push({otherColumn:b.name,eta2:Math.round(v/T*1e4)/1e4});let h=[];for(let p of _.values()){let D=P(p.vals);isNaN(D)||h.push(D)}if(h.length>=2&&isFinite(L)&&L>1e-9){let p=(Math.max(...h)-Math.min(...h))/L;S.push({otherColumn:b.name,spreadRatio:Math.round(p*1e4)/1e4})}}N.length>0&&(o.groupDiscrimination=N),S.length>0&&(o.spreadDiscrimination=S)});let y=.97,C=.8,O=8,I=5,M=this._cols.map((o,d)=>({c:o,i:d})).filter(o=>o.c.isMeasure);for(let o=0;o<M.length;o++)for(let d=o+1;d<M.length;d++){let E=M[o].i,A=M[d].i,c=0,R=0,T=0,N=0,S=0,P=0;for(let v of this._rows){let h=v[E],p=v[A];if(h==null||h===""||p===null||p===void 0||p==="")continue;let D=typeof h=="number"?h:parseFloat(h),F=typeof p=="number"?p:parseFloat(p);isNaN(D)||isNaN(F)||(c++,R+=D,T+=F,N+=D*D,S+=F*F,P+=D*F)}if(c<I)continue;let L=c*N-R*R,b=c*S-T*T;if(L<=1e-12||b<=1e-12)continue;let _=(c*P-R*T)/Math.sqrt(L*b);if(Math.abs(_)>=y){let v=M[o].c,h=M[d].c;v.collinearWithMeasures||(v.collinearWithMeasures=[]),h.collinearWithMeasures||(h.collinearWithMeasures=[]),v.collinearWithMeasures.push(h.name),h.collinearWithMeasures.push(v.name)}else if(Math.abs(_)>=C){let v=M[o].c,h=M[d].c,p=Math.round(_*1e3)/1e3;v.correlatedWithMeasures||(v.correlatedWithMeasures=[]),h.correlatedWithMeasures||(h.correlatedWithMeasures=[]),v.correlatedWithMeasures.push({otherColumn:h.name,r:p}),h.correlatedWithMeasures.push({otherColumn:v.name,r:p})}}for(let{c:o}of M)o.correlatedWithMeasures&&(o.correlatedWithMeasures.sort((d,E)=>Math.abs(E.r)-Math.abs(d.r)||(d.otherColumn<E.otherColumn?-1:1)),o.correlatedWithMeasures.length=Math.min(o.correlatedWithMeasures.length,O));for(let o=0;o<this._cols.length;o++){let d=s[o];if(!d||d.size===0)continue;let E=[];for(let A=0;A<this._cols.length;A++){if(A===o)continue;let c=s[A];if(!c||c.size===0)continue;let R=0;for(let N of d)c.has(N)&&R++;let T=Math.round(R/d.size*100);T>0&&E.push({otherColumn:this._cols[A].name,percentShared:T})}E.length>0&&(this._cols[o].sharedValueRatioWithOthers=E)}let w=50,g=[];for(let o=0;o<this._cols.length;o++){let d=s[o];d&&d.size>=2&&d.size<=w&&g.push(o)}if(g.length>=2){let o=new Map,d=(A,c)=>A+":"+c;for(let A=0;A<g.length;A++)for(let c=A+1;c<g.length;c++)o.set(d(g[A],g[c]),new Map);for(let A of this._rows)for(let c=0;c<g.length;c++){let R=this.STR(A[g[c]])+"";for(let T=c+1;T<g.length;T++){let N=""+this.STR(A[g[T]]),S=o.get(d(g[c],g[T])),P=R+""+N;S.set(P,(S.get(P)??0)+1)}}let E=new Map;for(let A=0;A<g.length;A++)for(let c=A+1;c<g.length;c++){let R=g[A],T=g[c],N=s[R].size,S=s[T].size,P=o.get(d(R,T)),L=P.size,b=0;for(let p of P.values())(b===0||p<b)&&(b=p);let _=Math.round(L/(N*S)*100),v=L===N,h=L===S;if((this._cols[R].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:_,determinesOther:v,minCellCount:b,distinctCombinations:L}),(this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[R].name,fillPct:_,determinesOther:h,minCellCount:b,distinctCombinations:L}),v&&N>S){let p=E.get(R);(!p||S<p.card)&&E.set(R,{name:this._cols[T].name,card:S,ratio:S/N})}if(h&&S>N){let p=E.get(T);(!p||N<p.card)&&E.set(T,{name:this._cols[R].name,card:N,ratio:N/S})}}for(let[A,c]of E)this._cols[A].primaryParentColumn=c.name,this._cols[A].nestingRatio=Math.round(c.ratio*100)/100}let x=6,f=this._rows.length;for(let o=0;o<this._cols.length;o++){let d=this._cols[o];if(d.isMeasure||d.primaryParentColumn)continue;let E=d.distinctCount??0;if(E<=w||f>0&&E>=f)continue;let A=[];for(let c=0;c<this._cols.length;c++){if(c===o)continue;let R=this._cols[c];if(R.isMeasure)continue;let T=R.distinctCount??0;T<2||T>=E||A.push(c)}A.sort((c,R)=>(this._cols[c].distinctCount??0)-(this._cols[R].distinctCount??0));for(let c of A.slice(0,x)){let R=new Map,T=!0;for(let S of this._rows){let P=this.STR(S[o])+"",L=this.STR(S[c])+"",b=R.get(P);if(b===void 0)R.set(P,L);else if(b!==L){T=!1;break}}if(!T)continue;let N=this._cols[c].distinctCount??0;d.primaryParentColumn=this._cols[c].name,d.nestingRatio=Math.round(N/E*100)/100;break}}let G=.01,V=.05,W=.95,k=8,z=8,U=6,Be=500,H=[];for(let o=0;o<this._cols.length&&H.length<z;o++){let d=this._cols[o].dataType;(d==="Double"||d==="Integer"||d==="Decimal")&&H.push(o)}if(H.length>=3&&this._rows.length>=k){let o=Math.min(this._rows.length,Be),d=H.map(N=>{let S=[];for(let b=0;b<o;b++){let _=this._rows[b][N],v=typeof _=="number"?_:parseFloat(String(_).replace(/,/g,""));if(_==null||_===""||!isFinite(v))return null;S.push(v)}let P=S[0],L=!1;for(let b of S)if(b!==P){L=!0;break}return L?S:null}),E=H.map((N,S)=>S).filter(N=>d[N]!==null),A=N=>{let S=N.slice().sort((L,b)=>L-b),P=S.length>>1;return S.length%2?S[P]:(S[P-1]+S[P])/2},c=null,R=[],T=N=>{if(R.length>=3){let S=R.map(_=>d[_]),P=S[0].length,L=new Array(P);for(let _=0;_<P;_++){let v=0;for(let h of S)v+=h[_];L[_]=v}let b=A(L);if(b>0){let _=0;for(let h of L)Math.abs(h-b)<=b*G&&_++;let v=_/P;if(v>=W){let h=1;for(let p of S){let D=A(p)/b;D<h&&(h=D)}h>=V&&(!c||R.length>c.cols.length)&&(c={cols:R.slice(),total:b,matched:v})}}}if(!(R.length>=U))for(let S=N;S<E.length;S++)R.push(E[S]),T(S+1),R.pop()};if(T(0),c){let N=c,P={columns:N.cols.map(L=>this._cols[H[L]].name),total:Math.round(N.total*1e3)/1e3,matchedPct:Math.round(N.matched*100)/100};for(let L of N.cols)this._cols[H[L]].constantSumGroup=P}}return this._computedStatsForLevel=e,this._cols}updateColumnStats20(e,t,i,a,s,r,l,u,m,y,C,O){if(e>=20){let I=[...t].sort((g,x)=>g-x),M=Math.floor(I.length/2);if(i>0&&a!=null?s.avgValue=s.dataType=="Integer"?Math.round(a/i):a/i:s.avgValue=null,i>0&&(s.avgLength=r/i),this._rows.length>0){let g=x=>{let f=x instanceof Date?x:typeof x=="string"?ne(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"};s.dataType!="DateTime"||l||!u?s.lowValue=u:s.lowValue=g(u),s.dataType!="DateTime"||l||!m?s.highValue=m:s.highValue=g(m),s.medianValue=I.length===0?null:I.length%2===0?s.dataType=="Integer"?Math.round((I[M-1]+I[M])/2):(I[M-1]+I[M])/2:I[M],s.numericPrecision=y}if(I.length>0){let g=s.avgValue??0,x=I.length,f=0,G=0;for(let W of I){let k=W-g;f+=k*k,G+=k*k*k}let V=f/x;s.skewness=V===0?0:G/x/Math.pow(Math.sqrt(V),3),s.stdDev=Math.sqrt(V)}a!==null&&(s.sum=a);let w=Array.from(C.entries()).sort((g,x)=>x[1]-g[1]);if(s.topCategories=w.slice(0,10).map(g=>g[1]),!s.isMeasure&&w.length>0){if(s.dataType==="String"){let g=w.map(f=>f[0]);s.formatSignature=be(g);let x=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!x.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=w.slice(0,5).map(g=>g[0]);if(e>=20){let g=w.map(f=>f[0]),x=fe(g,O);if(x!==null)s.ordinalPattern=x.pattern,s.orderedDomain=x.orderedDomain;else if(s.dataType==="String"){let f=de(g);f!==null&&(s.safeDistinctValues=f)}}}if(I.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let g=x=>I[Math.floor((I.length-1)*x)];s.quantiles={p05:g(.05),p25:g(.25),p75:g(.75),p95:g(.95)}}}if(!s.isMeasure&&C.size>0){let I=Array.from(C.entries()).sort((w,g)=>g[1]-w[1]),M=pe(I.map(w=>w[0]),s.name,O);if(M!==null&&(s.geoKind=M.geoKind,s.geoMatchPct=M.geoMatchPct,M.geoAmbiguous&&(s.geoAmbiguous=!0),M.geoKind.indexOf("country")===0)){let w=ie(I);w&&(s.dominantGeoRegion=w.dominantGeoRegion,s.dominantGeoRegionPct=w.dominantGeoRegionPct,s.geoRegionCount=w.regionCount)}}}updateColumnStats10(e,t,i,a,s,r,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:s,maxval:r,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=r=>String(r||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),t=-1,i=-1,a=-1;if(this._cols.forEach((r,l)=>{let u=e(r.name),m=r.dataType==="Integer"||r.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&&!r.isMeasure&&typeof r.geoKind=="string"&&r.geoKind.indexOf("country")===0&&(a=l)}),t<0||i<0)return null;let s=[];for(let r of this._rows){let l=r[t],u=r[i],m=l==null||l===""?null:Number(l),y=u==null||u===""?null:Number(u);s.push({lat:m,lon:y,country:a>=0&&te(this.STR(r[a]))?this.STR(r[a]):null})}return this._geoExtent=Ce(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){let t="abcdefghijklmnopqrstuvwxyz",i=()=>t[Math.floor(j()*t.length)],a=()=>i().toUpperCase(),s=()=>Math.floor(j()*10).toString(),r=M=>/[A-Z]/.test(M)?a():/[a-z]/.test(M)?i():/[0-9]/.test(M)?s():M,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,I=M=>{let w="";for(let g of M)w+=r(g),/[a-zA-Z0-9]/.test(g)&&j()<.2&&(w+=r(g));if(w.length>6){let g=Math.floor(j()*Math.min(3,w.length-6));for(let x=0;x<g;x++){let f=0;for(;f<5;){let G=Math.floor(j()*w.length);if(/[a-zA-Z0-9]/.test(w[G])){w=w.slice(0,G)+w.slice(G+1);break}f++}}}return w};if(l){let M=I(u[0]),w=I(O);return`${M}@${w}${C}`}else return I(e)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let i={};this._cols.forEach((a,s)=>{i[a.name]=t[s],this.emitLegacyAggAliases&&a.hostName&&a.hostName!==a.name&&!Object.prototype.hasOwnProperty.call(i,a.hostName)&&(i[a.hostName]=t[s])});for(let[a,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=t[a]);return i})}async getCSVAsync(e){let t=[],i=e?25:1e7,a=e?4e3:1e7,s=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(s.has(C))C=s.get(C);else{let O=this.obfuscateString(C);s.set(C,O),C=O}else if(y.dataType=="DateTime"&&!y.dateWithTime){let O=C instanceof Date?C:typeof C=="string"?ne(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 We.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return We.unparse([this._cols.map((t,i)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let a=e.get(i);return this.STR(a&&a.headerName?a.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=re(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())t.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return t}armAliasesForCode(e){return this.emitLegacyAggAliases=re(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let i=String(e),a=new Set;for(let r of this._cols)r&&(a.add(this.STR(r.name)),r.hostName&&a.add(this.STR(r.hostName)));let s=new Map;for(let r=0;r<this._cols.length;r++){if(!this._cols[r])continue;let l=we(this._hostQueryNames[r]).filter(u=>!a.has(u)&&q(i,u));l.length===1&&s.set(l[0],[...s.get(l[0])??[],r])}for(let[r,l]of s){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);t.set(l[0],{name:u,alias:r,headerName:!q(i,u)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,i]of this._englishAliases){let a=this._cols?this._cols[t]:null;a&&this.STR(a.name)===i.name&&e.set(t,i)}return e}addRow(e,t){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let a=le(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,this._hostQueryNames=[],this._englishAliases=new Map}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),s=ve(a);!s||s===a||t.has(s)||(t.delete(a),t.add(s),i.hostName=a,i.name=s)}}};export{Ce as a,$e as b,te as c,Kt as d,Ke as e,Ze as f,je as g,Xe as h,Te as i,tt as j,ve as k,re as l,we as m,Ee as n,rt as o,Oe as p,Le as q,Xt as r,Qt as s,qt as t,q as u,mt as v,en as w,nn as x,sn as y,At as z,Fe as A,Ot as B,Ve as C,Vt as D,Bt as E,Yt as F,ze as G,Ue as H};
2
+ import{a as be}from"./chunk-QEH7WTLB.mjs";import{a as ye,b as _e}from"./chunk-2LR73DNS.mjs";import{c as pe}from"./chunk-OZEOA6ZE.mjs";import{b as ge,f as he}from"./chunk-E6SVTFAW.mjs";import{a as me,b as de,c as fe}from"./chunk-DMLWYEQ2.mjs";import{a as X,b as ue,c as B,d as le,e as j,h as ne,j as ce}from"./chunk-FUTSF2X5.mjs";var Ye=[[24.4,49.4,-125,-66.9],[51.2,71.5,-168,-129.9],[18.9,22.3,-160.3,-154.8]],He=[7,72,-172,-52];function Ae(n,e,t){return n>=t[0]&&n<=t[1]&&e>=t[2]&&e<=t[3]}var $=n=>Math.round(n*10)/10;function Ce(n,e=3){let t=[],i=[],a=0,s=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():"",S=y?te(y):null;S?((y==="US"||y==="USA")&&a++,S==="north-america"&&s++):(Ye.some(O=>Ae(u,m,O))&&a++,Ae(u,m,He)&&s++)}let r=t.length;return r<e?null:(t.sort((l,u)=>l-u),i.sort((l,u)=>l-u),{pctUsa:$(a/r*100),pctNa:$(s/r*100),latP5:$(B(t,.05)),latP95:$(B(t,.95)),lonP5:$(B(i,.05)),lonP95:$(B(i,.95)),n:r})}var Se={"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(Se))for(let t of Se[e].split(/\s+/))t&&n.set(t,e);return n})();function $e(n){for(let[e,t]of n){let i=Q.get(e);i&&!Q.has(t)&&Q.set(t,i)}}$e(ge);function te(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=he(String(n));return i?Q.get(i)??null:null}function Kt(n,e=2){return ie(n.map(t=>[t,1]),e)}function ie(n,e=2){let t=new Map,i=0;for(let[r,l]of n){let u=te(r);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",s=-1;for(let r of Array.from(t.keys()).sort()){let l=t.get(r);l>s&&(a=r,s=l)}return{dominantGeoRegion:a,dominantGeoRegionPct:$(s/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","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"],Ze=["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"],je=["latitude","longitude"],Xe=["latitude","longitude"];function K(n){return Array.from(n).map(e=>{let t=e.normalize("NFD").replace(/[̀-ͯ]/g,"");return t.length===1?t:e}).join("")}var se=["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"],Re=["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 Qe(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+|(?:"+Qe(se)+")\\s+)","i"),qe=/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Za-z])(?=[0-9])|(?<=[0-9])(?=[A-Za-z])/g,Je=new RegExp("\\b("+Ke.join("|")+")\\b|("+Ze.join("|")+")$","i"),et=new RegExp("\\b("+je.join("|")+")\\b|("+Xe.join("|")+")$","i");function Te(n){if(!n)return"";let e=String(n),t=Ne.exec(K(e));return(t?e.slice(t[0].length):e).trim()}function tt(n){return!!n&&Ne.test(K(String(n)))}var nt=["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*("+[...nt].sort((n,e)=>e.length-n.length).map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s+")).join("|")+")\\s+of\\s+","i");function ve(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]),s=e.slice(t[0].length),r=0;for(;r<8;){let l=Me.exec(s);if(!l||i(l[1])!==a)break;let u=s.slice(l[0].length);if(u.trim()==="")break;s=u,r++}return r===0?e:e.slice(0,t[0].length)+s}function re(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}var xe={Sum:["Sum of "],Avg:["Average of "],Average:["Average of "],Count:["Count of "],CountNonNull:["Count of "],Min:["Min of ","First ","Earliest "],Max:["Max of ","Last ","Latest "],Median:["Median of "],StandardDeviation:["Standard deviation of "],Variance:["Variance of "]},it=new RegExp("^("+Object.keys(xe).join("|")+")\\((.+)\\)$");function we(n){if(!n)return[];let e=it.exec(String(n).trim());if(!e)return[];let t=xe[e[1]],i=e[2],a=[];for(let s=i.indexOf(".");s>=0;s=i.indexOf(".",s+1)){if(s===0)continue;let r=i.slice(s+1);if(r.trim()!=="")for(let l of t){let u=l+r;a.includes(u)||a.push(u)}}return a}function st(n){let e=Te(n);return e.length===0?"":e.replace(qe," ")}function Ie(n,e){if(!e)return!1;let t=Te(e);return n.test(K(st(e)))||n.test(K(t))||n.test(K(X(t).join(" ")))}function Ee(n){return Ie(et,n)}function rt(n){return Ie(Je,n)||Ee(n)}var De=/int|double|decimal|single|float|number|currency|money/i;function ot(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 at(n){return n?.isMeasure===!0||De.test(String(n?.dataType??""))}function Oe(n){let e=n??{},t=ot(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"&&tt(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}:rt(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 at(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 Xt(n){return Le(n)[0]}function Qt(n,e){return Le(n).indexOf(e)>=0}function qt(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 ut=/^[A-Za-z_$][A-Za-z0-9_$]*$/,lt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ct=new RegExp([String.raw`\bisMeasure\b`,String.raw`\bdataType\b`,String.raw`\bcolumns\s*\[\s*-?\d`,String.raw`\.iloc\s*\[[^\]]*,`,String.raw`\.iat\s*\[`,String.raw`\bselect_dtypes\b`,String.raw`\b_get_numeric_data\b`,String.raw`\bis_numeric_dtype\b`,String.raw`\bfor\s+\w+\s+in\s+(?:list\s*\(\s*)?df\.columns\b`,String.raw`\bdf\.columns\s*\.\s*(?:tolist|to_list|difference|drop)\b`,String.raw`\bdf\.dtypes\b`,String.raw`\bObject\s*\.\s*(?:keys|values|entries)\s*\(\s*(?:rows|data|df)?\s*\[\s*0\s*\]`,String.raw`\b(?:row|rw|r)\s*\[\s*\d+\s*\]`].join("|"));function q(n,e){if(!n||!e)return!1;let t=lt(e);return new RegExp("['\"`]"+t+"['\"`]").test(n)?!0:ut.test(e)&&new RegExp("\\."+t+"(?![A-Za-z0-9_$])").test(n)}function mt(n){return!!n&&ct.test(n)}function en(n,e,t){return n?mt(n)?[...e]:[...t,...e].some(i=>q(n,i))?e.filter(i=>q(n,i)):[...e]:[]}var nn=5,sn=6;var dt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,ft=/^(\d{4})[-/](\d{1,2})$/,gt=/^(\d{4})[-\s]?Q([1-4])$/i,ht=/^Q([1-4])[-\s](\d{4})$/i,pt=/^(\d{4})$/,bt=/^(\d{4})(0[1-9]|1[0-2])$/,yt=/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/;function Y(n,e,t,i=0,a=0,s=0){if(!(n>=1&&e>=1&&e<=12&&t>=1&&t<=31))return null;let r=Date.UTC(n,e-1,t,i,a,s);if(!Number.isFinite(r))return null;let l=u=>u<10?"0"+u:String(u);return{ms:r,y:n,m:e,d:t,iso:`${n}-${l(e)}-${l(t)}`}}function _t(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 s=0,r=1,l=1;return t.forEach((u,m)=>{let y=+a[m+1];u==="Y"?s=y:u==="m"?r=y:l=y}),s?Y(s,r,l):null}function At(n,e){let t=(n??"").trim();if(t==="")return null;if(e){let a=_t(t,e);return a||null}let i=dt.exec(t);if(i)return Y(+i[1],+i[2],+i[3],+(i[4]??0),+(i[5]??0),+(i[6]??0));if(i=gt.exec(t),i)return Y(+i[1],(+i[2]-1)*3+1,1);if(i=ht.exec(t),i)return Y(+i[2],(+i[1]-1)*3+1,1);if(i=ft.exec(t),i&&+i[2]>=1&&+i[2]<=12)return Y(+i[1],+i[2],1);if(i=yt.exec(t),i)return Y(+i[1],+i[2],+i[3]);if(i=bt.exec(t),i)return Y(+i[1],+i[2],1);if(i=pt.exec(t),i){let a=+i[1];return a>=1900&&a<=2100?Y(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,s=n+i*7*864e5;for(;s<e;)Ge(s)&&a++,s+=864e5;return a}function St(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 Ct(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,s=new Map;for(let f of n){if(f==null||f==="")continue;i++;let G=At(String(f),e?.pattern);G&&(a++,s.set(G.ms,G))}let r=[...s.values()].sort((f,G)=>f.ms-G.ms);if(r.length<3||i>0&&a/i<.8)return null;let l=r[r.length-1].ms-r[0].ms;if(l<=0)return null;let u=[];for(let f=1;f<r.length;f++)u.push(r[f].ms-r[f-1].ms);let m=St(u);if(!(m>0))return null;let y=Ct(m/864e5);y==="day"&&l>=7*864e5&&r.every(f=>Ge(f.ms))&&ke(r[0].ms,r[r.length-1].ms)+1>r.length*.5&&(y="weekday");let S=y==="irregular"?r.length:Pe(r[0],r[r.length-1],y,m)+1,O=1,I=1,C=[],w=r[0],g=1;for(let f=1;f<r.length;f++){let G=Pe(r[f-1],r[f],y,m);G>O&&(O=G),y!=="irregular"&&G>t?(I++,C.push({from:w.iso,to:r[f-1].iso,points:g}),w=r[f],g=1):g++}C.push({from:w.iso,to:r[r.length-1].iso,points:g});let x={grain:y,points:r.length,expectedPoints:Math.max(S,r.length),coveragePct:Math.round(r.length/Math.max(S,r.length)*1e3)/10,runs:I,largestGapUnits:O,gapFactor:t};return e?.includeBounds&&C.length<=6&&(x.runBounds=C),x}var Mt=12,Rt=100,Nt=.3,Tt=.9,vt=120,xt=1900,wt=2100,It=0,Et=20,Dt=new Set(["id","ids","uuid","guid","key","zip","zipcode","postal","postalcode","ssn","code","codes","sku","isbn","msisdn","imei"]);function Ot(n){if(!n)return!1;let e=X(n);return e.length===0?!1:Dt.has(e[e.length-1])}var Lt=new Set(["year","yr","fy"]),Pt=n=>X(n).some(e=>Lt.has(e)),Gt=/^(?:(?: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 oe(n){if(!Number.isInteger(n)||n<190001||n>210012)return!1;let e=n%100;return e>=1&&e<=12}function ae(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 kt=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?Z?)?$/,Ft=/^(\d{4})([\/.])(\d{1,2})\2(\d{1,2})$/,Wt=/^(\d{1,2})([\/.\-])(\d{1,2})\2(\d{4})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/;function zt(n){let e=(n||"").toLowerCase();return e==="en-us"||e==="en"||e.startsWith("en-us-")||e==="en-ph"||e==="en-bz"}function Ve(n,e){let t=0,i=0,a=0,s=0,r=0,l="",u=0,m="",y=0,S=0,O=0,I=0,C=!1;for(let V of n){if(V==null)continue;let W=String(V).trim();if(W==="")continue;t++;let k;if(k=kt.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&&s++)}else if(k=Ft.exec(W)){let z=+k[3],U=+k[4];z>=1&&z<=12&&U>=1&&U<=31&&(l&&l!==k[2]&&(C=!0),l=k[2],r++)}else if(k=Wt.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]&&(C=!0),m=k[2],u++,z>12&&O++,U>12&&I++,k[5]!==void 0&&y++,k[7]!==void 0&&S++)}if(t>=200)break}if(t<2||(i+r+u)/t<.8||(i>0?1:0)+(r>0?1:0)+(u>0?1:0)!==1||C)return null;if(i>0)return a===i?{pattern:s===i?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M",orderFrom:"iso"}:{pattern:"%Y-%m-%d",orderFrom:"iso"};if(r>0)return{pattern:`%Y${l}%m${l}%d`,orderFrom:"iso"};if(O>0&&I>0)return null;let x,f;O>0?(x=!0,f="values"):I>0?(x=!1,f="values"):(x=!zt(e),f="locale");let G=x?`%d${m}%m${m}%Y`:`%m${m}%d${m}%Y`;return y===u?{pattern:G+(S===u?" %H:%M:%S":" %H:%M"),orderFrom:f}:{pattern:G,orderFrom:f}}function Ut(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=ye(t);return i.length>0&&e[i]!==void 0}function Vt(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 s=n.minNum,r=n.maxNum;if(!(s!=null&&r!=null&&Number.isFinite(s)&&Number.isFinite(r)&&Number.isInteger(s)&&Number.isInteger(r)&&r>=s))return!1;let u=s>=1900&&r<=2100;if(u&&a>=2&&Pt(t)||u&&a>=3&&a===r-s+1)return!0;let m=oe(s)&&oe(r),y=ae(s)&&ae(r);if(m||y){if(!n.sampleValues)return!0;let S=0,O=0;for(let I of n.sampleValues){if(I==null||I==="")continue;S++;let C=Number(String(I).trim());if(Number.isFinite(C)&&(m?oe(C):ae(C))&&O++,S>=60)break}if(S>=2&&O===S)return!0}return!1}if(n.sampleValues){let s=n.locale?_e(n.locale):null,r=0,l=0,u=[];for(let m of n.sampleValues){if(m==null||m==="")continue;r++;let y=String(m).trim();if(u.push(y),(Gt.test(y)||Ut(y,s))&&l++,r>=60)break}if(r>=2&&l/r>=.8||Ve(u,n.locale)!==null)return!0}return!1}function Bt(n){let e=K((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":Re.some(t=>e.startsWith(t+" "))?/^(minimum|minimo)\b/.test(e)?"min":/^(maximum|maximo|massimo)\b/.test(e)?"max":"avg":se.some(t=>e.startsWith(t+" ")||e===t)?/^(nombre|recuento|contagem|anzahl|aantal|conteggio|antal|lukumaara|pocet)\b/.test(e)?"count":"sum":null}function Yt(n){let{rows:e,measureColIdx:t,measureName:i,candidateDims:a,minNum:s,maxNum:r,discourageAgg:l}=n,u=100,m=.01,y="";for(let O of a){if(O.distinct<2||O.distinct>u)continue;let I=a.filter(f=>f.idx!==O.idx).map(f=>f.idx),C=new Map;for(let f of e){let G=f[t];if(typeof G!="number"||!Number.isFinite(G))continue;let V=I.length?I.map(k=>String(f[k])).join(y):"",W=C.get(V);W||(W={sum:0,cset:new Set},C.set(V,W)),W.sum+=G,W.cset.add(String(f[O.idx]))}let w=0,g=0,x=0;for(let f of C.values())f.cset.size<2||(x++,Math.abs(f.sum-100)<=100*m?w++:Math.abs(f.sum-1)<=1*m&&g++);if(x>=2&&(w/x>=.9||g/x>=.9))return{additivity:"part_of_whole",partOfWholeDim:O.name}}if(l)return{additivity:"intensive_rate"};let S=Bt(i);return S==="avg"||S==="min"||S==="max"?{additivity:"intensive_rate"}:S==="count"?{additivity:"additive"}:S==="sum"?{additivity:"unknown"}:s!=null&&r!=null&&Number.isFinite(s)&&Number.isFinite(r)&&s>=0&&r<=1.0001&&r>0?{additivity:"intensive_rate"}:{additivity:"unknown"}}function ze(n){let{dataType:e,isMeasure:t,name:i,distinct:a,nonblank:s,prec:r,maxval:l,minval:u}=n,m=l-u+1,y=m>0?a/m:1,S=s>0?a/s:0,O=e==="Decimal"||r>0;return Ot(i)?"Categorical":y>=Tt&&(me(i)&&a<=vt||u>=xt&&l<=wt||u>=It&&l<=Et)?"Ordinal":t||a>Mt&&(O||a>=Rt||S>=Nt)?"Continuous":"Categorical"}var Ue=class{_computedStatsForLevel=null;_cols=[];_rows=[];_origIndices=[];_rowHashes=new Set;_hostQueryNames=[];_englishAliases=new Map;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 ce(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),s=[];for(let o of this._cols){let d=new Map,E=[],R=0,c=0,M=0,T=null,N=null,A=null,P=!1,L=!0,b=!0,_=null,v=!1;for(let h of this._rows){let p=h[i],D=this.STR(p);if(D!=""){if(R+=D.length,d.set(D,(d.get(D)||0)+1),c++,o.dataType=="Integer"||o.dataType=="Decimal"||o.dataType=="DateTime")if((T===null||p<T)&&(T=p),(N===null||p>N)&&(N=p),o.dataType=="Integer"||o.dataType=="Decimal"){if(A===null?A=p:A+=p,o.dataType=="Decimal"){let F=this.getPrecision(p);F>M&&(M=F)}E.push(p)}else P=P||this.hasTimeComponent(p);v&&(p<_?L=!1:p>_&&(b=!1)),_=p,v=!0}}if(c>=3&&(L&&!b?o.sortedDirection="asc":b&&!L?o.sortedDirection="desc":o.sortedDirection="none"),c>0&&d.size>0&&!o.isMeasure){let h=0,p=Number.MAX_SAFE_INTEGER;for(let D of d.values())D>h&&(h=D),D<p&&(p=D);if(o.modalShare=h/c,o.minGroupCount=p===Number.MAX_SAFE_INTEGER?null:p,d.size===2){let D=[...d.keys()].map(ee=>ue(ee).trim().toLowerCase()).sort(),J=[["false","true"],["no","yes"],["n","y"],["0","1"],["f","t"]].some(ee=>D[0]===ee[0]&&D[1]===ee[1]),Z=/^(is|has)[_a-z0-9]|(?:default|churn|fraud|approv|convert|active|cancel|delinquen|flag|paid|win|pass|fail)/i.test(o.name);(J||Z)&&(o.isBinaryFlag=!0)}}if(o.dataType=="DateTime"&&(o.dateWithTime=P),o.isTemporal=Vt({dataType:o.dataType,name:o.name,isMeasure:o.isMeasure,distinctCount:d.size,minNum:typeof T=="number"?T:null,maxNum:typeof N=="number"?N:null,sampleValues:d.keys(),locale:t}),o.isTemporal&&o.dataType==="String"&&!o.isMeasure){let h=Ve(d.keys(),t);h&&(o.temporalTextPattern=h.pattern)}if(o.isTemporal&&!o.isMeasure){let h=Fe(d.keys(),{includeBounds:a>=20,pattern:o.temporalTextPattern});h&&(o.temporalCadence=h)}this.updateColumnStats10(a,o,c,d,M,N,T),this.updateColumnStats20(a,E,c,A,o,R,P,T,N,M,d,t),!o.isMeasure&&(o.dataType==="Integer"||o.dataType==="Decimal")&&ze({dataType:o.dataType,isMeasure:!1,name:o.name,distinct:d.size,nonblank:c,prec:M,maxval:typeof N=="number"?N:0,minval:typeof T=="number"?T:0})==="Continuous"&&(o.isMeasure=!0,o.geoKind=void 0,o.geoMatchPct=void 0,o.geoAmbiguous=void 0,o.dominantGeoRegion=void 0,o.dominantGeoRegionPct=void 0,o.geoRegionCount=void 0),s[i]=o.isMeasure||d.size>2e3?null:new Set(d.keys()),i++}let r=[];this._cols.forEach((o,d)=>{o.isMeasure||r.push({idx:d,distinct:o.distinctCount??0,name:o.name})}),this._cols.forEach((o,d)=>{if(!o.isMeasure)return;let E=typeof o.lowValue=="number"?o.lowValue:null,R=typeof o.highValue=="number"?o.highValue:null,c=Yt({rows:this._rows,measureColIdx:d,measureName:o.name,candidateDims:r,minNum:E,maxNum:R,discourageAgg:!!o.discourageAggregationAcrossGroups});o.additivity=c.additivity,c.partOfWholeDim&&(o.partOfWholeDim=c.partOfWholeDim)});let l=50,u=4,m=r.filter(o=>o.distinct>=2&&o.distinct<=l);this._cols.forEach((o,d)=>{if(!o.isMeasure)return;let E=[];for(let b of this._rows){let _=b[d];if(_==null||_==="")continue;let v=typeof _=="number"?_:parseFloat(_);isNaN(v)||E.push(v)}if(E.length===0)return;let R=[...E].sort((b,_)=>b-_);if(R[0]===R[R.length-1])o.relativeDispersion=0;else if(R.length>=u){let b=B(R,.5),_=B(R,.1),v=B(R,.9);o.relativeDispersion=Math.abs(b)>1e-9?Math.round((v-_)/Math.abs(b)*1e3)/1e3:void 0}else o.relativeDispersion=void 0;let c=[];for(let b of m){let _=new Set;for(let v of this._rows){let h=v[d];h==null||h===""||_.add(this.STR(v[b.idx])+"")}c.push({otherColumn:b.name,nonBlankGroupCount:_.size})}c.length>0&&(o.nonBlankGroups=c);let M=0;for(let b of E)M+=b;M/=E.length;let T=0;for(let b of E)T+=(b-M)*(b-M);if(T<=1e-12)return;let N=[],A=[],P=b=>{if(b.length<4)return NaN;let _=[...b].sort((h,p)=>h-p),v=h=>_[Math.min(_.length-1,Math.max(0,Math.floor(h*(_.length-1))))];return v(.75)-v(.25)},L=P(E);for(let b of m){let _=new Map;for(let p of this._rows){let D=p[d];if(D==null||D==="")continue;let F=typeof D=="number"?D:parseFloat(D);if(isNaN(F))continue;let J=this.STR(p[b.idx])+"",Z=_.get(J);Z?(Z.s+=F,Z.n++,Z.vals.push(F)):_.set(J,{s:F,n:1,vals:[F]})}let v=0;for(let p of _.values()){let D=p.s/p.n;v+=p.n*(D-M)*(D-M)}N.push({otherColumn:b.name,eta2:Math.round(v/T*1e4)/1e4});let h=[];for(let p of _.values()){let D=P(p.vals);isNaN(D)||h.push(D)}if(h.length>=2&&isFinite(L)&&L>1e-9){let p=(Math.max(...h)-Math.min(...h))/L;A.push({otherColumn:b.name,spreadRatio:Math.round(p*1e4)/1e4})}}N.length>0&&(o.groupDiscrimination=N),A.length>0&&(o.spreadDiscrimination=A)});let y=.97,S=.8,O=8,I=5,C=this._cols.map((o,d)=>({c:o,i:d})).filter(o=>o.c.isMeasure);for(let o=0;o<C.length;o++)for(let d=o+1;d<C.length;d++){let E=C[o].i,R=C[d].i,c=0,M=0,T=0,N=0,A=0,P=0;for(let v of this._rows){let h=v[E],p=v[R];if(h==null||h===""||p===null||p===void 0||p==="")continue;let D=typeof h=="number"?h:parseFloat(h),F=typeof p=="number"?p:parseFloat(p);isNaN(D)||isNaN(F)||(c++,M+=D,T+=F,N+=D*D,A+=F*F,P+=D*F)}if(c<I)continue;let L=c*N-M*M,b=c*A-T*T;if(L<=1e-12||b<=1e-12)continue;let _=(c*P-M*T)/Math.sqrt(L*b);if(Math.abs(_)>=y){let v=C[o].c,h=C[d].c;v.collinearWithMeasures||(v.collinearWithMeasures=[]),h.collinearWithMeasures||(h.collinearWithMeasures=[]),v.collinearWithMeasures.push(h.name),h.collinearWithMeasures.push(v.name)}else if(Math.abs(_)>=S){let v=C[o].c,h=C[d].c,p=Math.round(_*1e3)/1e3;v.correlatedWithMeasures||(v.correlatedWithMeasures=[]),h.correlatedWithMeasures||(h.correlatedWithMeasures=[]),v.correlatedWithMeasures.push({otherColumn:h.name,r:p}),h.correlatedWithMeasures.push({otherColumn:v.name,r:p})}}for(let{c:o}of C)o.correlatedWithMeasures&&(o.correlatedWithMeasures.sort((d,E)=>Math.abs(E.r)-Math.abs(d.r)||(d.otherColumn<E.otherColumn?-1:1)),o.correlatedWithMeasures.length=Math.min(o.correlatedWithMeasures.length,O));for(let o=0;o<this._cols.length;o++){let d=s[o];if(!d||d.size===0)continue;let E=[];for(let R=0;R<this._cols.length;R++){if(R===o)continue;let c=s[R];if(!c||c.size===0)continue;let M=0;for(let N of d)c.has(N)&&M++;let T=Math.round(M/d.size*100);T>0&&E.push({otherColumn:this._cols[R].name,percentShared:T})}E.length>0&&(this._cols[o].sharedValueRatioWithOthers=E)}let w=50,g=[];for(let o=0;o<this._cols.length;o++){let d=s[o];d&&d.size>=2&&d.size<=w&&g.push(o)}if(g.length>=2){let o=new Map,d=(R,c)=>R+":"+c;for(let R=0;R<g.length;R++)for(let c=R+1;c<g.length;c++)o.set(d(g[R],g[c]),new Map);for(let R of this._rows)for(let c=0;c<g.length;c++){let M=this.STR(R[g[c]])+"";for(let T=c+1;T<g.length;T++){let N=""+this.STR(R[g[T]]),A=o.get(d(g[c],g[T])),P=M+""+N;A.set(P,(A.get(P)??0)+1)}}let E=new Map;for(let R=0;R<g.length;R++)for(let c=R+1;c<g.length;c++){let M=g[R],T=g[c],N=s[M].size,A=s[T].size,P=o.get(d(M,T)),L=P.size,b=0;for(let p of P.values())(b===0||p<b)&&(b=p);let _=Math.round(L/(N*A)*100),v=L===N,h=L===A;if((this._cols[M].categoricalPairStats||=[]).push({otherColumn:this._cols[T].name,fillPct:_,determinesOther:v,minCellCount:b,distinctCombinations:L}),(this._cols[T].categoricalPairStats||=[]).push({otherColumn:this._cols[M].name,fillPct:_,determinesOther:h,minCellCount:b,distinctCombinations:L}),v&&N>A){let p=E.get(M);(!p||A<p.card)&&E.set(M,{name:this._cols[T].name,card:A,ratio:A/N})}if(h&&A>N){let p=E.get(T);(!p||N<p.card)&&E.set(T,{name:this._cols[M].name,card:N,ratio:N/A})}}for(let[R,c]of E)this._cols[R].primaryParentColumn=c.name,this._cols[R].nestingRatio=Math.round(c.ratio*100)/100}let x=6,f=this._rows.length;for(let o=0;o<this._cols.length;o++){let d=this._cols[o];if(d.isMeasure||d.primaryParentColumn)continue;let E=d.distinctCount??0;if(E<=w||f>0&&E>=f)continue;let R=[];for(let c=0;c<this._cols.length;c++){if(c===o)continue;let M=this._cols[c];if(M.isMeasure)continue;let T=M.distinctCount??0;T<2||T>=E||R.push(c)}R.sort((c,M)=>(this._cols[c].distinctCount??0)-(this._cols[M].distinctCount??0));for(let c of R.slice(0,x)){let M=new Map,T=!0;for(let A of this._rows){let P=this.STR(A[o])+"",L=this.STR(A[c])+"",b=M.get(P);if(b===void 0)M.set(P,L);else if(b!==L){T=!1;break}}if(!T)continue;let N=this._cols[c].distinctCount??0;d.primaryParentColumn=this._cols[c].name,d.nestingRatio=Math.round(N/E*100)/100;break}}let G=.01,V=.05,W=.95,k=8,z=8,U=6,Be=500,H=[];for(let o=0;o<this._cols.length&&H.length<z;o++){let d=this._cols[o].dataType;(d==="Double"||d==="Integer"||d==="Decimal")&&H.push(o)}if(H.length>=3&&this._rows.length>=k){let o=Math.min(this._rows.length,Be),d=H.map(N=>{let A=[];for(let b=0;b<o;b++){let _=this._rows[b][N],v=typeof _=="number"?_:parseFloat(String(_).replace(/,/g,""));if(_==null||_===""||!isFinite(v))return null;A.push(v)}let P=A[0],L=!1;for(let b of A)if(b!==P){L=!0;break}return L?A:null}),E=H.map((N,A)=>A).filter(N=>d[N]!==null),R=N=>{let A=N.slice().sort((L,b)=>L-b),P=A.length>>1;return A.length%2?A[P]:(A[P-1]+A[P])/2},c=null,M=[],T=N=>{if(M.length>=3){let A=M.map(_=>d[_]),P=A[0].length,L=new Array(P);for(let _=0;_<P;_++){let v=0;for(let h of A)v+=h[_];L[_]=v}let b=R(L);if(b>0){let _=0;for(let h of L)Math.abs(h-b)<=b*G&&_++;let v=_/P;if(v>=W){let h=1;for(let p of A){let D=R(p)/b;D<h&&(h=D)}h>=V&&(!c||M.length>c.cols.length)&&(c={cols:M.slice(),total:b,matched:v})}}}if(!(M.length>=U))for(let A=N;A<E.length;A++)M.push(E[A]),T(A+1),M.pop()};if(T(0),c){let N=c,P={columns:N.cols.map(L=>this._cols[H[L]].name),total:Math.round(N.total*1e3)/1e3,matchedPct:Math.round(N.matched*100)/100};for(let L of N.cols)this._cols[H[L]].constantSumGroup=P}}return this._computedStatsForLevel=e,this._cols}updateColumnStats20(e,t,i,a,s,r,l,u,m,y,S,O){if(e>=20){let I=[...t].sort((g,x)=>g-x),C=Math.floor(I.length/2);if(i>0&&a!=null?s.avgValue=s.dataType=="Integer"?Math.round(a/i):a/i:s.avgValue=null,i>0&&(s.avgLength=r/i),this._rows.length>0){let g=x=>{let f=x instanceof Date?x:typeof x=="string"?ne(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"};s.dataType!="DateTime"||l||!u?s.lowValue=u:s.lowValue=g(u),s.dataType!="DateTime"||l||!m?s.highValue=m:s.highValue=g(m),s.medianValue=I.length===0?null:I.length%2===0?s.dataType=="Integer"?Math.round((I[C-1]+I[C])/2):(I[C-1]+I[C])/2:I[C],s.numericPrecision=y}if(I.length>0){let g=s.avgValue??0,x=I.length,f=0,G=0;for(let W of I){let k=W-g;f+=k*k,G+=k*k*k}let V=f/x;s.skewness=V===0?0:G/x/Math.pow(Math.sqrt(V),3),s.stdDev=Math.sqrt(V)}a!==null&&(s.sum=a);let w=Array.from(S.entries()).sort((g,x)=>x[1]-g[1]);if(s.topCategories=w.slice(0,10).map(g=>g[1]),!s.isMeasure&&w.length>0){if(s.dataType==="String"){let g=w.map(f=>f[0]);s.formatSignature=be(g);let x=/^(UUID|EMAIL_LIKE|URL_LIKE|PHONE_LIKE|NUMERIC_ID|HEX_ID|OPAQUE_ID_ALPHANUMERIC|DATE_STR|BOOLEAN)$/;s.formatSignature&&!x.test(s.formatSignature)&&(s.avgLength===void 0||s.avgLength>=3)&&(s.isFreeText=!0)}else s.topCategoryValues=w.slice(0,5).map(g=>g[0]);if(e>=20){let g=w.map(f=>f[0]),x=fe(g,O);if(x!==null)s.ordinalPattern=x.pattern,s.orderedDomain=x.orderedDomain;else if(s.dataType==="String"){let f=de(g);f!==null&&(s.safeDistinctValues=f)}}}if(I.length>=8&&(s.dataType==="Integer"||s.dataType==="Decimal")){let g=x=>I[Math.floor((I.length-1)*x)];s.quantiles={p05:g(.05),p25:g(.25),p75:g(.75),p95:g(.95)}}}if(!s.isMeasure&&S.size>0){let I=Array.from(S.entries()).sort((w,g)=>g[1]-w[1]),C=pe(I.map(w=>w[0]),s.name,O);if(C!==null&&(s.geoKind=C.geoKind,s.geoMatchPct=C.geoMatchPct,C.geoAmbiguous&&(s.geoAmbiguous=!0),C.geoKind.indexOf("country")===0)){let w=ie(I);w&&(s.dominantGeoRegion=w.dominantGeoRegion,s.dominantGeoRegionPct=w.dominantGeoRegionPct,s.geoRegionCount=w.regionCount)}}}updateColumnStats10(e,t,i,a,s,r,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:s,maxval:r,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=r=>String(r||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/),t=-1,i=-1,a=-1;if(this._cols.forEach((r,l)=>{let u=e(r.name),m=r.dataType==="Integer"||r.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&&!r.isMeasure&&typeof r.geoKind=="string"&&r.geoKind.indexOf("country")===0&&(a=l)}),t<0||i<0)return null;let s=[];for(let r of this._rows){let l=r[t],u=r[i],m=l==null||l===""?null:Number(l),y=u==null||u===""?null:Number(u);s.push({lat:m,lon:y,country:a>=0&&te(this.STR(r[a]))?this.STR(r[a]):null})}return this._geoExtent=Ce(s),this._geoExtent}_geoExtent=null;_geoExtentComputed=!1;obfuscateString(e){let t="abcdefghijklmnopqrstuvwxyz",i=()=>t[Math.floor(j()*t.length)],a=()=>i().toUpperCase(),s=()=>Math.floor(j()*10).toString(),r=C=>/[A-Z]/.test(C)?a():/[a-z]/.test(C)?i():/[0-9]/.test(C)?s():C,l=e.includes("@")&&e.includes("."),u=l?e.split("@"):[e],m=l?u[1]:"",y=m.endsWith(".com"),S=y?".com":"",O=y?m.slice(0,-4):m,I=C=>{let w="";for(let g of C)w+=r(g),/[a-zA-Z0-9]/.test(g)&&j()<.2&&(w+=r(g));if(w.length>6){let g=Math.floor(j()*Math.min(3,w.length-6));for(let x=0;x<g;x++){let f=0;for(;f<5;){let G=Math.floor(j()*w.length);if(/[a-zA-Z0-9]/.test(w[G])){w=w.slice(0,G)+w.slice(G+1);break}f++}}}return w};if(l){let C=I(u[0]),w=I(O);return`${C}@${w}${S}`}else return I(e)}toObjectArray(){let e=this.liveEnglishAliases();return this._rows.map(t=>{let i={};this._cols.forEach((a,s)=>{i[a.name]=t[s],this.emitLegacyAggAliases&&a.hostName&&a.hostName!==a.name&&!Object.prototype.hasOwnProperty.call(i,a.hostName)&&(i[a.hostName]=t[s])});for(let[a,s]of e)Object.prototype.hasOwnProperty.call(i,s.alias)||(i[s.alias]=t[a]);return i})}async getCSVAsync(e){let t=[],i=e?25:1e7,a=e?4e3:1e7,s=new Map;for(let l of this._rows){let u={};for(let m=0;m<this._cols.length;m++){let y=this._cols[m],S=l[m];if(this.STR(S)!=""){if(e&&y.dataType=="String")if(s.has(S))S=s.get(S);else{let O=this.obfuscateString(S);s.set(S,O),S=O}else if(y.dataType=="DateTime"&&!y.dateWithTime){let O=S instanceof Date?S:typeof S=="string"?ne(S)??new Date(S):new Date(S);S=(this.wholeDayIso(O)??O.toISOString().slice(0,10))+"T00:00:00.000Z"}a-=this.STR(S).length}else S=null;u[m]=S,--a}if(t.push(u),--i,i<=0||a<=0)break}return await We.unparse(t,{header:!1})}getCSVHeaderLine(){let e=this.liveEnglishAliases();return We.unparse([this._cols.map((t,i)=>{if(this.emitLegacyAggAliases&&t.hostName)return this.STR(t.hostName);let a=e.get(i);return this.STR(a&&a.headerName?a.alias:t.name)})])}setHostQueryNames(e){this._hostQueryNames=(e??[]).map(t=>t==null?null:this.STR(t)),this._englishAliases=new Map}aliasesForCode(e){let t=re(e,this._cols)?this.legacyAliases():[];for(let i of this.englishAliasesFor(e).values())t.push({name:i.name,alias:i.alias,reason:"english-implicit-agg"});return t}armAliasesForCode(e){return this.emitLegacyAggAliases=re(e,this._cols),this._englishAliases=this.englishAliasesFor(e),this.getArmedAliases()}getArmedAliases(){let e=this.emitLegacyAggAliases?this.legacyAliases():[];for(let t of this.liveEnglishAliases().values())e.push({name:t.name,alias:t.alias,reason:"english-implicit-agg"});return e}legacyAliases(){let e=[];for(let t of this._cols)t&&t.hostName&&t.hostName!==t.name&&e.push({name:this.STR(t.name),alias:this.STR(t.hostName),reason:"doubled-agg-prefix"});return e}englishAliasesFor(e){let t=new Map;if(!e||this._hostQueryNames.length===0||!this._cols||this._cols.length===0)return t;let i=String(e),a=new Set;for(let r of this._cols)r&&(a.add(this.STR(r.name)),r.hostName&&a.add(this.STR(r.hostName)));let s=new Map;for(let r=0;r<this._cols.length;r++){if(!this._cols[r])continue;let l=we(this._hostQueryNames[r]).filter(u=>!a.has(u)&&q(i,u));l.length===1&&s.set(l[0],[...s.get(l[0])??[],r])}for(let[r,l]of s){if(l.length!==1)continue;let u=this.STR(this._cols[l[0]].name);t.set(l[0],{name:u,alias:r,headerName:!q(i,u)})}return t}liveEnglishAliases(){let e=new Map;for(let[t,i]of this._englishAliases){let a=this._cols?this._cols[t]:null;a&&this.STR(a.name)===i.name&&e.set(t,i)}return e}addRow(e,t){if(this.dedupRows){let i="";for(let s of e)i+=this.STR(s)+"~";let a=le(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,this._hostQueryNames=[],this._englishAliases=new Map}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),s=ve(a);!s||s===a||t.has(s)||(t.delete(a),t.add(s),i.hostName=a,i.name=s)}}};export{Ce as a,$e as b,te as c,Kt as d,Ke as e,Ze as f,je as g,Xe as h,Te as i,tt as j,ve as k,re as l,we as m,Ee as n,rt as o,Oe as p,Le as q,Xt as r,Qt as s,qt as t,q as u,mt as v,en as w,nn as x,sn as y,At as z,Fe as A,Ot as B,Ve as C,Vt as D,Bt as E,Yt as F,ze as G,Ue as H};
@@ -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{B as b,H as S}from"./chunk-RS7LNZD7.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};
2
+ import{B as b,H as S}from"./chunk-NY26PXWD.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};
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 pt,b as dt}from"./chunk-UQU75XXR.mjs";import{a as ft,b as mt}from"./chunk-QVD2YGH2.mjs";import{A as ot,B as it,C as rt,D as st,E as at,F as lt,G as ut,H as ct,a as Ie,b as _e,c as Le,d as Ne,e as Ee,f as De,g as Fe,h as Ge,i as ze,j as $e,k as Be,l as Ke,m as He,n as Ue,o as Ve,p as We,q as qe,r as Ze,s as je,t as Xe,u as Ye,v as Je,w as Qe,x as et,y as tt,z as nt}from"./chunk-RS7LNZD7.mjs";import{a as ke}from"./chunk-QEH7WTLB.mjs";import{a as Oe,b as we}from"./chunk-2LR73DNS.mjs";import{a as U,b as V,c as Te,d as Me,e as be,f as ve}from"./chunk-OZEOA6ZE.mjs";import{a as S,f as T,g as y,h as M,i as O,j as de,k as ge,l as H,m as p,n as ye,o as Ce,p as he,q as b,r as Pe,s as xe,t as Ae,u as Re,v as w,w as Se}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as fe,b as me,c as pe}from"./chunk-N3ZYRMZJ.mjs";import{a as Q,b as ee,d as te,e as ne,f as oe,g as ie,h as re,i as se,j as ae,k as le,l as ue,m as ce}from"./chunk-FUTSF2X5.mjs";var E=2,Z=400;function F(i){return!!T(i)}function P(i){let n=new Set;for(let t of i){if(t==null)continue;let s=S(String(t));if(!M(s)&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function h(i){let n=P(i);if(n.length===0||G(i)<95)return!1;let t=n.filter(l=>F(l)&&!p(l)).length,s=n.filter(l=>!F(l)&&!!p(l)).length;return t>=1&&t>=s}function W(i,n){if(!p(i))return!1;let t=T(i);return t?n==="world"?!0:H.has(t):!1}function G(i){let n=P(i);if(n.length===0)return 0;let t=0;for(let s of n)F(s)&&t++;return Math.round(t/n.length*1e3)/10}function v(i){let n=P(i);if(n.length===0)return 0;let t=0;for(let s of n)p(s)&&t++;return Math.round(t/n.length*1e3)/10}function $(i){let n=new Set;for(let t of i){if(t==null)continue;let s=String(t).trim();if(!M(S(s))&&!n.has(s)&&(n.add(s),n.size>=Z))break}return Array.from(n)}function z(i){let n=$(i);if(n.length===0)return 0;let t=0;for(let s of n)b(s).length>0&&t++;return Math.round(t/n.length*1e3)/10}function q(i,n){return V(n,U)?!0:$(i).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function gt(i,n){let t=P(i);if(t.length===0)return 0;let s=0;for(let l of t)w(l,n)&&s++;return Math.round(s/t.length*1e3)/10}function D(i,n){let t=0;for(let s of P(i))n(s)&&t++;return t}function yt(i,n){let t=0;for(let s of $(i))n(s)&&t++;return t}function Ct(i,n,t,s,l){let x=[],c=[],o={},I={},_=new Set(i),u=e=>n.map(r=>r[e]);for(let e of["city","country"]){let r=t?.[e];r&&_.has(r)&&(o[e]=r)}let X=new Set(l??i);for(let e of["lat","lon"]){let r=t?.[e];r&&X.has(r)&&(o[e]=r)}let d=t?.zip;if(d&&_.has(d)){let e=u(d),r=z(e);r<95?c.push(`zip=${d} (only ${r}% of values read as ZIPs)`):q(e,d)?o.zip=d:c.push(`zip=${d} (all values are 3-4 digits with nothing to say they are postal)`)}let m=t?.state;if(m&&_.has(m)){let e=u(m),r=P(e);r.length>0&&r.every(a=>W(a,s))?c.push(`state=${m} (every value is "CA", which is both Canada and California)`):h(e)?(c.push(`state=${m} (every value is a country, not a state)`),o.country||(o.country=m)):v(e)<95?c.push(`state=${m} (only ${v(e)}% of values are states/provinces)`):o.state=m}let g=new Set(Object.values(o).filter(Boolean)),A=i.filter(e=>!g.has(e)&&!e.startsWith("__"));if(!o.state){let e=null;for(let r of A){let a=u(r);if(h(a))continue;let f=v(a);if(f<95)continue;let k=D(a,R=>!!p(R)),J=D(a,R=>!!p(R)&&!W(R,s));k<E&&J<1||(!e||f>e.pct)&&(e={name:r,pct:f})}e&&(o.state=e.name,g.add(e.name),x.push(`state=${e.name} (${e.pct}% states/provinces)`))}if(!o.zip)for(let e of A){if(g.has(e))continue;let r=u(e),a=z(r);if(!(a<95)&&q(r,e)&&!(yt(r,f=>b(f).length>0)<E)){o.zip=e,g.add(e),x.push(`zip=${e} (${a}% ZIP codes)`);break}}let C=o.country;if(!C||!h(u(C))){let e=null;for(let r of A){if(g.has(r)||!h(u(r)))continue;let a=G(u(r));(!e||a>e.pct)&&(e={name:r,pct:a})}e&&(C&&(c.push(`country=${C} (only ${G(u(C))}% of values are country identifiers; using ${e.name} instead)`),I.country=C),o.country=e.name,g.add(e.name),x.push(`country=${e.name}`))}if(!o.city){let e=null;for(let r of A){if(g.has(r))continue;let a=u(r),f=gt(a,s);f<O||D(a,k=>w(k,s))<E||(!e||f>e.pct)&&(e={name:r,pct:f})}e&&(o.city=e.name,x.push(`city=${e.name} (${e.pct}% known cities)`))}let B=o.country?u(o.country):[],L=!!o.country&&h(B),Y=L?new Set(B.map(e=>T(e==null?null:String(e))).filter(Boolean)).size:0,K=L&&Y>=2,N=!!(o.lat&&o.lon)&&n.some(e=>{let r=+String(e[o.lat]??"").trim(),a=+String(e[o.lon]??"").trim();return isFinite(r)&&isFinite(a)&&r>=-90&&r<=90&&a>=-180&&a<=180&&String(e[o.lat]??"").trim()!==""&&String(e[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!N&&c.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!K&&!(o.city||o.state||o.zip||N)&&c.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:x,refused:c,...Object.keys(I).length?{labelFallback:I}:{}}}function j(i,n){let t=n?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(i)||i<=t?0:Math.round(i-t)}function ht(i,n){let t=j(i,n);if(t===null||t<=0)return null;let s=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,l=t>s?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;return typeof l!="string"||l.trim().length===0?null:l.split("{n}").join(String(t)).split("{fields}").join(t===1?"field":"fields")}export{O as CITY_ROLE_MATCH_PCT,et as DEFAULT_GAP_FACTOR,ie as DEFAULT_TEMPERATURE,ne as GET_RANDOM,De as INTENSIVE_SUFFIX_TOKENS,Ee as INTENSIVE_WORD_TOKENS,ct as IndexedText,tt as MAX_RUN_BOUNDS,Ge as POSITIONAL_SUFFIX_TOKENS,Fe as POSITIONAL_WORD_TOKENS,pt as PREVIEW_OMITTED_FIELDS,y as ROLE_MATCH_PCT,te as SIMPLE_STRING_HASH,ee as STR,v as admin1MatchPct,qe as allowedAggregations,ve as buildGeoIsoColumn,Ae as buildGeoPointColumns,Se as cityMatchPct,Re as cityTagsFor,lt as classifyAdditivity,We as classifyForAggregation,ut as classifyNumericValueNature,st as classifyTemporal,Ke as codeNeedsLegacyAggNames,Ye as codeReadsColumn,Je as codeReadsColumnsByRoleOrPosition,Be as collapseRepeatedAggPrefix,Qe as columnsTheCodeReads,Le as countryRegion,Ze as defaultAggregation,ke as detectFormatSignature,Te as detectGeo,pe as detectOrdinalDomain,rt as detectTextDatePattern,ft as engineTypeForSqlType,He as englishImplicitAggNames,ht as freemiumColumnCapRefusal,j as freemiumColumnsOverCap,$e as hasDefaultAggPrefix,at as hostAggHint,mt as ingest,je as isAggregationAllowed,M as isBlankLike,ge as isCityTableLoaded,oe as isDeterministicRefusal,Pe as isGeoPointAmbiguity,it as isIdentifierName,be as isJoinGeoKind,fe as isOrdinalFriendlyName,ue as localMidnightDateColumns,le as localMidnightToUtcDay,h as looksLikeCountryColumn,ot as measureCadence,we as monthLookupFor,Ve as nameLooksIntensiveRate,Ue as nameLooksPositional,Q as nameWords,ye as normalizeCountry,ce as normalizeLocalMidnightDates,Oe as normalizeMonthKey,S as normalizePlaceName,he as normalizeZip5,re as parseDateStable,nt as parseTemporalPoint,dt as payloadPreview,de as registerCityTable,_e as registerIso3Regions,p as resolveAdmin1,xe as resolveGeoPoint,Ct as resolvePointRoles,me as safeDistinctValuesToShip,Xe as shareOfTotalIsHonest,ze as stripHostAggPrefix,Ne as summarizeCountryRegions,Ie as summarizeGeoExtent,Me as toGeoIso,se as wholeDayFrame,ae as wholeDayIso,z as zipMatchPct,b as zipPrefixCandidates,Ce as zipToPrefix3};
2
+ import{a as dt,b as gt}from"./chunk-UQU75XXR.mjs";import{a as mt,b as pt}from"./chunk-VB5S5EYS.mjs";import{A as it,B as rt,C as st,D as at,E as lt,F as ut,G as ct,H as ft,a as _e,b as De,c as Le,d as we,e as ke,f as Oe,g as Ee,h as ze,i as $e,j as Be,k as He,l as Ke,m as Ue,n as Ve,o as We,p as je,q as qe,r as Ze,s as Xe,t as Ye,u as Je,v as Qe,w as et,x as tt,y as nt,z as ot}from"./chunk-NY26PXWD.mjs";import{a as Ne}from"./chunk-QEH7WTLB.mjs";import{a as Fe,b as Ge}from"./chunk-2LR73DNS.mjs";import{a as U,b as V,c as be,d as Me,e as Ie,f as ve}from"./chunk-OZEOA6ZE.mjs";import{a as b,f as M,g as C,h as I,i as N,j as ge,k as ye,l as K,m as d,n as Ce,o as he,p as Pe,q as v,r as xe,s as Ae,t as Re,u as Se,v as F,w as Te}from"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import{a as me,b as pe,c as de}from"./chunk-DMLWYEQ2.mjs";import{a as ee,b as te,d as ne,e as oe,f as ie,g as re,h as se,i as ae,j as le,k as ue,l as ce,m as fe}from"./chunk-FUTSF2X5.mjs";var G=2,q=400;function O(i){return!!M(i)}function A(i){let n=new Set;for(let t of i){if(t==null)continue;let r=b(String(t));if(!I(r)&&!n.has(r)&&(n.add(r),n.size>=q))break}return Array.from(n)}function x(i){let n=A(i);if(n.length===0||E(i)<95)return!1;let t=n.filter(c=>O(c)&&!d(c)).length,r=n.filter(c=>!O(c)&&!!d(c)).length;return t>=1&&t>=r}function W(i,n){if(!d(i))return!1;let t=M(i);return t?n==="world"?!0:K.has(t):!1}function E(i){let n=A(i);if(n.length===0)return 0;let t=0;for(let r of n)O(r)&&t++;return Math.round(t/n.length*1e3)/10}function _(i){let n=A(i);if(n.length===0)return 0;let t=0;for(let r of n)d(r)&&t++;return Math.round(t/n.length*1e3)/10}function $(i){let n=new Set;for(let t of i){if(t==null)continue;let r=String(t).trim();if(!I(b(r))&&!n.has(r)&&(n.add(r),n.size>=q))break}return Array.from(n)}function z(i){let n=$(i);if(n.length===0)return 0;let t=0;for(let r of n)v(r).length>0&&t++;return Math.round(t/n.length*1e3)/10}function j(i,n){return V(n,U)?!0:$(i).some(t=>/^\d{5}(-\d{4})?$/.test(t.replace(/\.0+$/,"")))}function yt(i,n){let t=A(i);if(t.length===0)return 0;let r=0;for(let c of t)F(c,n)&&r++;return Math.round(r/t.length*1e3)/10}function k(i,n){let t=0;for(let r of A(i))n(r)&&t++;return t}function Ct(i,n){let t=0;for(let r of $(i))n(r)&&t++;return t}function ht(i,n,t,r,c){let l=[],a=[],o={},R={},h=new Set(i),f=e=>n.map(s=>s[e]);for(let e of["city","country"]){let s=t?.[e];s&&h.has(s)&&(o[e]=s)}let Y=new Set(c??i);for(let e of["lat","lon"]){let s=t?.[e];s&&Y.has(s)&&(o[e]=s)}let g=t?.zip;if(g&&h.has(g)){let e=f(g),s=z(e);s<95?a.push(`zip=${g} (only ${s}% of values read as ZIPs)`):j(e,g)?o.zip=g:a.push(`zip=${g} (all values are 3-4 digits with nothing to say they are postal)`)}let p=t?.state;if(p&&h.has(p)){let e=f(p),s=A(e);s.length>0&&s.every(u=>W(u,r))?a.push(`state=${p} (every value is "CA", which is both Canada and California)`):x(e)?(a.push(`state=${p} (every value is a country, not a state)`),o.country||(o.country=p)):_(e)<95?a.push(`state=${p} (only ${_(e)}% of values are states/provinces)`):o.state=p}let y=new Set(Object.values(o).filter(Boolean)),S=i.filter(e=>!y.has(e)&&!e.startsWith("__"));if(!o.state){let e=null;for(let s of S){let u=f(s);if(x(u))continue;let m=_(u);if(m<95)continue;let w=k(u,T=>!!d(T)),Q=k(u,T=>!!d(T)&&!W(T,r));w<G&&Q<1||(!e||m>e.pct)&&(e={name:s,pct:m})}e&&(o.state=e.name,y.add(e.name),l.push(`state=${e.name} (${e.pct}% states/provinces)`))}if(!o.zip)for(let e of S){if(y.has(e))continue;let s=f(e),u=z(s);if(!(u<95)&&j(s,e)&&!(Ct(s,m=>v(m).length>0)<G)){o.zip=e,y.add(e),l.push(`zip=${e} (${u}% ZIP codes)`);break}}let P=o.country;if(!P||!x(f(P))){let e=null;for(let s of S){if(y.has(s)||!x(f(s)))continue;let u=E(f(s));(!e||u>e.pct)&&(e={name:s,pct:u})}e&&(P&&(a.push(`country=${P} (only ${E(f(P))}% of values are country identifiers; using ${e.name} instead)`),R.country=P),o.country=e.name,y.add(e.name),l.push(`country=${e.name}`))}if(!o.city){let e=null;for(let s of S){if(y.has(s))continue;let u=f(s),m=yt(u,r);m<N||k(u,w=>F(w,r))<G||(!e||m>e.pct)&&(e={name:s,pct:m})}e&&(o.city=e.name,l.push(`city=${e.name} (${e.pct}% known cities)`))}let B=o.country?f(o.country):[],D=!!o.country&&x(B),J=D?new Set(B.map(e=>M(e==null?null:String(e))).filter(Boolean)).size:0,H=D&&J>=2,L=!!(o.lat&&o.lon)&&n.some(e=>{let s=+String(e[o.lat]??"").trim(),u=+String(e[o.lon]??"").trim();return isFinite(s)&&isFinite(u)&&s>=-90&&s<=90&&u>=-180&&u<=180&&String(e[o.lat]??"").trim()!==""&&String(e[o.lon]??"").trim()!==""});return o.lat&&o.lon&&!L&&a.push(`lat/lon=${o.lat}/${o.lon} (no row holds a usable coordinate pair)`),o.country&&!H&&!(o.city||o.state||o.zip||L)&&a.push(D?`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||H||L)?o:null,backfilled:l,refused:a,...Object.keys(R).length?{labelFallback:R}:{}}}function Z(i,n){let t=n?.freemiumMaxShapeColumns;return typeof t!="number"||!isFinite(t)||t<1?null:!isFinite(i)||i<=t?0:Math.round(i-t)}function Pt(i,n,t){let r=Z(i,n);if(r===null||r<=0)return null;let c=typeof n?.freemiumColumnCapPivot=="number"?n.freemiumColumnCapPivot:4,l=r>c?n?.freemiumColumnCapMessageMany:n?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let a=l.split("{n}").join(String(r)).split("{fields}").join(r===1?"field":"fields"),o=X(t);return o.length===0?a:a+" "+o.join(" ")}function X(i){if(!i||i.length===0)return[];let n=[],t=new Map,r=new Map;for(let l of i){let a=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(a!==""&&(t.has(a)||(n.push(a),t.set(a,0)),l.isDatePart===!0&&t.set(a,t.get(a)+1),l.isReassembledDate===!0&&!r.has(a))){let o=typeof l.sourceField=="string"?l.sourceField.trim():"",R=typeof l.name=="string"?l.name.trim():"",h=o!==""?o:R;h!==""&&r.set(a,h)}}let c=[];for(let l of n){let a=r.get(l),o=t.get(l)??0;!a||o===0||c.push(`'${a}' is a date hierarchy and counts as ${o+1} fields - bind the date itself instead of its hierarchy.`)}return c}export{N as CITY_ROLE_MATCH_PCT,tt as DEFAULT_GAP_FACTOR,re as DEFAULT_TEMPERATURE,oe as GET_RANDOM,Oe as INTENSIVE_SUFFIX_TOKENS,ke as INTENSIVE_WORD_TOKENS,ft as IndexedText,nt as MAX_RUN_BOUNDS,ze as POSITIONAL_SUFFIX_TOKENS,Ee as POSITIONAL_WORD_TOKENS,dt as PREVIEW_OMITTED_FIELDS,C as ROLE_MATCH_PCT,ne as SIMPLE_STRING_HASH,te as STR,_ as admin1MatchPct,qe as allowedAggregations,ve as buildGeoIsoColumn,Re as buildGeoPointColumns,Te as cityMatchPct,Se as cityTagsFor,ut as classifyAdditivity,je as classifyForAggregation,ct as classifyNumericValueNature,at as classifyTemporal,Ke as codeNeedsLegacyAggNames,Je as codeReadsColumn,Qe as codeReadsColumnsByRoleOrPosition,He as collapseRepeatedAggPrefix,et as columnsTheCodeReads,Le as countryRegion,Ze as defaultAggregation,Ne as detectFormatSignature,be as detectGeo,de as detectOrdinalDomain,st as detectTextDatePattern,mt as engineTypeForSqlType,Ue as englishImplicitAggNames,Pt as freemiumColumnCapRefusal,Z as freemiumColumnsOverCap,X as freemiumDateHierarchyClauses,Be as hasDefaultAggPrefix,lt as hostAggHint,pt as ingest,Xe as isAggregationAllowed,I as isBlankLike,ye as isCityTableLoaded,ie as isDeterministicRefusal,xe as isGeoPointAmbiguity,rt as isIdentifierName,Ie as isJoinGeoKind,me as isOrdinalFriendlyName,ce as localMidnightDateColumns,ue as localMidnightToUtcDay,x as looksLikeCountryColumn,it as measureCadence,Ge as monthLookupFor,We as nameLooksIntensiveRate,Ve as nameLooksPositional,ee as nameWords,Ce as normalizeCountry,fe as normalizeLocalMidnightDates,Fe as normalizeMonthKey,b as normalizePlaceName,Pe as normalizeZip5,se as parseDateStable,ot as parseTemporalPoint,gt as payloadPreview,ge as registerCityTable,De as registerIso3Regions,d as resolveAdmin1,Ae as resolveGeoPoint,ht as resolvePointRoles,pe as safeDistinctValuesToShip,Ye as shareOfTotalIsHonest,$e as stripHostAggPrefix,we as summarizeCountryRegions,_e as summarizeGeoExtent,Me as toGeoIso,ae as wholeDayFrame,le as wholeDayIso,z as zipMatchPct,v as zipPrefixCandidates,he 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{B as a,C as b,D as c,E as d,F as e,G as f,H as g}from"./chunk-RS7LNZD7.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};
2
+ import{B as a,C as b,D as c,E as d,F as e,G as f,H as g}from"./chunk-NY26PXWD.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-OZEOA6ZE.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-DMLWYEQ2.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-QVD2YGH2.mjs";import"./chunk-RS7LNZD7.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};
2
+ import{a,b}from"./chunk-VB5S5EYS.mjs";import"./chunk-NY26PXWD.mjs";import"./chunk-QEH7WTLB.mjs";import"./chunk-2LR73DNS.mjs";import"./chunk-OZEOA6ZE.mjs";import"./chunk-E6SVTFAW.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-DMLWYEQ2.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-N3ZYRMZJ.mjs";import"./chunk-FUTSF2X5.mjs";export{c as detectOrdinalDomain,a as isOrdinalFriendlyName,b as safeDistinctValuesToShip};
2
+ import{a,b,c}from"./chunk-DMLWYEQ2.mjs";import"./chunk-FUTSF2X5.mjs";export{c as detectOrdinalDomain,a as isOrdinalFriendlyName,b as safeDistinctValuesToShip};
@@ -60,4 +60,32 @@ export declare function freemiumColumnsOverCap(shapeColumnCount: number, status:
60
60
  * depends on the reader's count. It is English-only, like every other plural in this codebase, and
61
61
  * belongs to item 543's catalogue work rather than to this one.
62
62
  */
63
- export declare function freemiumColumnCapRefusal(shapeColumnCount: number, status: FreemiumColumnCapStatus | null | undefined): string | null;
63
+ export declare function freemiumColumnCapRefusal(shapeColumnCount: number, status: FreemiumColumnCapStatus | null | undefined, shape?: readonly FreemiumDateGroupColumn[] | null): string | null;
64
+ /** The fields of a bound shape column the date-hierarchy clause reads. A partial, so a host can
65
+ * pass whatever column type it holds. */
66
+ export type FreemiumDateGroupColumn = {
67
+ name?: string;
68
+ isDatePart?: boolean;
69
+ isReassembledDate?: boolean;
70
+ dateGroupId?: string;
71
+ sourceField?: string;
72
+ };
73
+ /**
74
+ * A DATE HIERARCHY COUNTS AS SEVERAL FIELDS, AND THE REFUSAL SAYS SO (2026-09-23).
75
+ *
76
+ * When a host reassembles a shredded date hierarchy (Year / Quarter / Month / Day) it keeps the
77
+ * levels and adds the reassembled date, so one hierarchy in the reader's field well is five entries
78
+ * in the shape the cap counts. The count is right for the cap's purpose - every one of them is a
79
+ * described column - but a reader with six fields in their field well who is told to remove two
80
+ * has no way to see that the date hierarchies are what cost them. Binding the date itself instead
81
+ * of its hierarchy frees all but one of those slots without losing a field.
82
+ *
83
+ * So each date group in the shape adds one clause naming it, in the order the groups first appear.
84
+ * `{n}` is the group's levels plus the reassembled date; the name is the source field the date was
85
+ * reassembled from when the host knows it, else the reassembled column's own name. A group with no
86
+ * reassembled column is not a hierarchy this knows how to name, and adds nothing.
87
+ *
88
+ * THE LITERAL IS PINNED ON BOTH SIDES. The server composes the same clause for a request whose
89
+ * shape carries a source field, so a reader is told the same sentence whichever side answers.
90
+ */
91
+ export declare function freemiumDateHierarchyClauses(shape: readonly FreemiumDateGroupColumn[] | null | undefined): string[];
@@ -28,5 +28,5 @@ export type { DataSource, IngestOptions, IngestResult, ColumnDescriptor, SqlColu
28
28
  export { payloadPreview, PREVIEW_OMITTED_FIELDS } from "./payloadPreview";
29
29
  export type { PayloadPreviewOptions } from "./payloadPreview";
30
30
  export { codeReadsColumn, codeReadsColumnsByRoleOrPosition, columnsTheCodeReads } from "./codeColumnReads";
31
- export { freemiumColumnsOverCap, freemiumColumnCapRefusal } from "./freemiumCaps";
32
- export type { FreemiumColumnCapStatus } from "./freemiumCaps";
31
+ export { freemiumColumnsOverCap, freemiumColumnCapRefusal, freemiumDateHierarchyClauses } from "./freemiumCaps";
32
+ export type { FreemiumColumnCapStatus, FreemiumDateGroupColumn } from "./freemiumCaps";
@@ -58,6 +58,7 @@ export type LLMColumnWithValue = {
58
58
  isDatePart?: boolean;
59
59
  isReassembledDate?: boolean;
60
60
  dateGroupId?: string;
61
+ sourceField?: string;
61
62
  temporalCadence?: TemporalCadence;
62
63
  sharedValueRatioWithOthers?: {
63
64
  otherColumn: string;
@@ -294,6 +295,7 @@ export type LLMRequestCodeResult = {
294
295
  isRateLimited?: boolean;
295
296
  retryAfterSeconds?: number;
296
297
  isVersionNotFound?: boolean;
298
+ isGenerationCancelled?: boolean;
297
299
  servedCorrelationId?: string;
298
300
  creditBalanceBefore: number;
299
301
  creditCost: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.5.117",
3
+ "version": "0.5.119",
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",