@bicharts/shape-core 0.6.121 → 0.6.124

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.
@@ -0,0 +1,2 @@
1
+ /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
+ import{R,Z as N,f as L}from"./chunk-J5EZ7BH7.mjs";import{a as h,c as x,d as A,e as I}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import k from"papaparse";var O=["#N/A","#NV","#N/D","#N/D!","#N/B","#\u041D/\u0414","#I/T","#PUUTTUU!","#SAKNAS!","#HI\xC1NYZIK","#NEN\xCD_K_DISPOZICI","#YOK","#GETTING_DATA"],j=new Set(O.map(e=>e.toUpperCase())),$=/^#[\p{Lu}\p{Nd}_/.¡¿]{1,24}[!?]$/u;function w(e){if(typeof e!="string")return!1;let o=e.trim();return o.length<2||o[0]!=="#"?!1:j.has(o.toUpperCase())||$.test(o)}var M=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,V=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function q(e,o=".",n=!1){if(n)return"DateTime";let r=0,a=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,a++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,a++;continue}if(I(m,o)){a++;continue}if((v.test(m)||V.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":a===l?"Decimal":"String"}function F(e,o){let n=r=>!!r&&o.some((a,i)=>a&&w(r[i]));return e.some(n)?e.map(r=>n(r)?r.map((a,i)=>o[i]&&w(a)?null:a):r):e}function U(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let a=String(e).trim();if(a==="")return null;switch(o){case"Integer":{let i=h(a);return P.test(i)?parseInt(i,10):null}case"Decimal":return A(a,n);case"DateTime":return r?r.read(a):C(a);default:return a}}function G(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*W(e,o){for(let n of e)yield n?.[o]}function p(e,o,n){if(e.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=e.length;o=F(o,e.map(t=>t.dataType===void 0));let a=e.map((t,s)=>o.slice(0,M).map(u=>u?.[s])),i=a.map(t=>x(t,n.locale)),l=e.map((t,s)=>t.dataType===void 0||t.dataType==="DateTime"?L(W(o,s),{locale:n.locale??"en"}):null),c=e.map((t,s)=>t.dataType??q(a[s],i[s],l[s]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),D=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),_=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),S=e.map((t,s)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[s]==="Integer"||c[s]==="Decimal")&&!R(t.name));m.has(u)&&(f=!0),D.has(u)&&(f=!1);let E={name:t.name,dataType:c[s],isMeasure:f};return f&&_.has(u)&&(E.discourageAggregationAcrossGroups=!0),E}),d=new N;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(S),d.declareDimensions(S.filter((t,s)=>D.has(e[s].name.toLowerCase())));for(let t=0;t<o.length;t++){let s=o[t];d.addRow(Array.from({length:r},(u,f)=>U(s?.[f],c[f],i[f],l[f])),t)}let g=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),T=new Map(g.map(t=>[t.name,t]));e.forEach(t=>{let s=T.get(t.name);s&&(t.format&&(s.modelFormat=t.format),t.description&&(s.modelDesc=t.description))});let y=t=>{let s=T.get(t);if(s)return[s];let u=t.toLowerCase();return g.filter(f=>f.name.toLowerCase()===u)};for(let[t,s]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=s;for(let[t,s]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=s;for(let t of n.groupBy??[])for(let s of y(t))s.isGrouping=!0;return{columns:g,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function b(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function B(e,o){let n=[],r=new Set,a=Math.min(e.length,Math.max(1,o));for(let i=0;i<a;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function K(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],a=0;return k.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(a,l);a=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...k.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function ee(e,o={}){switch(e.kind){case"csv":{let n=K(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let a=r[0].map(i=>(i??"").trim());return p(a.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return p(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return p(e.columns,b(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:B(n,o.columnScanLimit??M).map(a=>({name:a}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return p(r,b(n,r.map(a=>a.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let a=G(r.dataType);return{name:r.name,dataType:a,isMeasure:r.isMeasure,format:r.format,description:r.description}});return p(n,b(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{O as a,w as b,G as c,K as d,ee as e};
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 Sr,b as Rr}from"./chunk-HIVICMC5.mjs";import{a as xr,b as M,c as wr,d as k,e as E,f as _r,g as J,h as Z}from"./chunk-4J7WPYLM.mjs";import{a as br,b as Er,c as Tr}from"./chunk-WNUCHG24.mjs";import{A as jn,B as Qn,C as Yn,D as Xn,E as Jn,F as Zn,G as er,H as tr,I as nr,J as rr,K as or,L as ir,M as sr,N as ar,O as lr,P as ur,Q as cr,R as dr,S as fr,T as mr,U as pr,V as gr,W as yr,X as hr,Z as Cr,a as hn,b as Cn,c as bn,d as En,e as Tn,g as An,h as Ln,i as vn,j as Pn,k as Mn,l as In,m as Nn,n as Fn,o as kn,p as Dn,q as Gn,r as Un,s as Wn,t as Vn,u as qn,v as Hn,w as Kn,x as zn,y as $n,z as Bn}from"./chunk-J5EZ7BH7.mjs";import{a as Sn}from"./chunk-U3H6UBOO.mjs";import{b as Rn,c as xn,d as wn,f as _n,g as On}from"./chunk-TZ74QIKA.mjs";import{a as fe,c as me,e as mn,f as pn,g as gn,h as yn}from"./chunk-YDYFP2T4.mjs";import{A as Y,B as nn,C as rn,D as de,E as I,F as on,G as sn,H as an,I as V,J as ln,K as un,L as cn,M as dn,N as X,O as fn,a as P,b as G,c as j,d as U,j as W,k as qt,l as Ht,m as Kt,n as zt,o as $t,q as Bt,r as jt,s as Q,t as Qt,u as Yt,v as Xt,w as Jt,x as Zt,y as en,z as tn}from"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import{a as Rt,b as xt,c as wt,d as _t,e as Ot,f as At,g as Lt,h as vt,i as Pt,j as Mt,k as It,l as Nt,m as Ut,n as Wt,o as Vt}from"./chunk-3ZAS32F5.mjs";import{b as Ft,c as kt,d as Dt,e as Gt}from"./chunk-5HI6TVMM.mjs";import{A as Ct,B as bt,C as Et,D as Tt,E as St,a as je,b as Qe,c as Ye,d as Xe,e as Je,f as Ze,g as et,h as tt,i as nt,j as rt,k as ot,l as it,m as st,n as at,o as lt,q as B,r as ut,s as ct,t as dt,u as ft,v as mt,w as pt,x as gt,y as yt,z as ht}from"./chunk-CZJ7M6A5.mjs";import{a as qe,b as He,c as Ke,d as ze,e as $e,f as $,g as Be}from"./chunk-WC4JINEZ.mjs";var ee=2,ye=400;function ne(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let r=U(String(n));if(!G(r)&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||re(e)<95)return!1;let n=t.filter(a=>ne(a)&&!I(a)).length,r=t.filter(a=>!ne(a)&&!!I(a)).length;return n>=1&&n>=r}function pe(e,t){if(!I(e))return!1;let n=W(e);return n?t==="world"?!0:de.has(n):!1}function re(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)ne(r)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){return I(e)?!0:Q()?Y(e).status!=="unmatched"||Y(e.trim().replace(/\s+/g,"-")).status!=="unmatched":!1}function q(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)oe(r)&&n++;return Math.round(n/t.length*1e3)/10}function se(e){let t=new Set;for(let n of e){if(n==null)continue;let r=String(n).trim();if(!G(U(r))&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function ie(e){let t=se(e);if(t.length===0)return 0;let n=0;for(let r of t)V(r).length>0&&n++;return Math.round(n/t.length*1e3)/10}function ge(e,t){return me(t,fe)?!0:se(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Or(e,t){let n=F(e);if(n.length===0)return 0;let r=0;for(let a of n)X(a,t)&&r++;return Math.round(r/n.length*1e3)/10}function te(e,t){let n=0;for(let r of F(e))t(r)&&n++;return n}function Ar(e,t){let n=0;for(let r of se(e))t(r)&&n++;return n}function Lr(e,t,n,r,a){let l=[],u=[],i={},C={},y=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&y.has(d)&&(i[s]=d)}let m=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&m.has(d)&&(i[s]=d)}let p=n?.zip;if(p&&y.has(p)){let s=h(p),d=ie(s);d<95?u.push(`zip=${p} (only ${d}% of values read as ZIPs)`):ge(s,p)?i.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&y.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>pe(S,r))?u.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(u.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):q(s)<95?u.push(`state=${c} (only ${q(s)}% of values are states/provinces)`):i.state=c}let g=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!g.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=h(d);if(N(S))continue;let O=q(S);if(O<95)continue;let z=te(S,oe),Ve=te(S,ce=>oe(ce)&&!pe(ce,r));z<ee&&Ve<1||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.state=s.name,g.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(g.has(s))continue;let d=h(s),S=ie(d);if(!(S<95)&&ge(d,s)&&!(Ar(d,O=>V(O).length>0)<ee)){i.zip=s,g.add(s),l.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(h(T))){let s=null;for(let d of b){if(g.has(d)||!N(h(d)))continue;let S=re(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(u.push(`country=${T} (only ${re(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.country=T),i.country=s.name,g.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(g.has(d))continue;let S=h(d),O=Or(S,r);O<j||te(S,z=>X(z,r))<ee||(!s||O>s.pct)&&(s={name:d,pct:O})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?h(i.country):[],R=!!i.country&&N(L),v=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&v>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&u.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&u.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:l,refused:u,...Object.keys(C).length?{labelFallback:C}:{}}}var o=(e,...t)=>({part:e,langs:Object.freeze(t)}),ae=Object.freeze({jaar:o("year","nl"),kwartaal:o("quarter","nl"),maand:o("month","nl"),dag:o("day","nl","sv","da","nb"),jahr:o("year","de"),quartal:o("quarter","de"),monat:o("month","de"),tag:o("day","de"),ann\u00E9e:o("year","fr"),mois:o("month","fr"),jour:o("day","fr"),trimestre:o("quarter","fr","es","pt","it"),a\u00F1o:o("year","es"),mes:o("month","es"),d\u00EDa:o("day","es"),ano:o("year","pt"),m\u00EAs:o("month","pt"),dia:o("day","pt"),anno:o("year","it"),mese:o("month","it"),giorno:o("day","it"),\u0433\u043E\u0434:o("year","ru"),\u043C\u0435\u0441\u044F\u0446:o("month","ru"),\u0440\u0456\u043A:o("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:o("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:o("quarter","ru","uk"),\u0434\u0435\u043D\u044C:o("day","ru","uk"),rok:o("year","pl","cs","sk"),kwarta\u0142:o("quarter","pl"),miesi\u0105c:o("month","pl"),dzie\u0144:o("day","pl"),\u010Dtvrtlet\u00ED:o("quarter","cs"),m\u011Bs\u00EDc:o("month","cs"),den:o("day","cs"),\u0161tvr\u0165rok:o("quarter","sk"),mesiac:o("month","sk"),de\u0148:o("day","sk"),\u00E5r:o("year","sv","da","nb"),kvartal:o("quarter","sv","da","nb"),m\u00E5nad:o("month","sv"),m\u00E5ned:o("month","da","nb"),vuosi:o("year","fi"),vuosinelj\u00E4nnes:o("quarter","fi"),kuukausi:o("month","fi"),p\u00E4iv\u00E4:o("day","fi"),\u00E9v:o("year","hu"),negyed\u00E9v:o("quarter","hu"),h\u00F3nap:o("month","hu"),nap:o("day","hu"),y\u0131l:o("year","tr"),\u00E7eyrek:o("quarter","tr"),ay:o("month","tr"),g\u00FCn:o("day","tr"),\u03AD\u03C4\u03BF\u03C2:o("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:o("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:o("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:o("day","el"),an:o("year","ro"),trimestru:o("quarter","ro"),lun\u0103:o("month","ro"),zi:o("day","ro"),godina:o("year","hr"),tromjese\u010Dje:o("quarter","hr"),mjesec:o("month","hr"),dan:o("day","hr"),\u5E74:o("year","ja","zh"),\u56DB\u534A\u671F:o("quarter","ja"),\u5B63\u5EA6:o("quarter","zh"),\u6708:o("month","ja","zh"),\u65E5:o("day","ja","zh"),\uC5F0\uB3C4:o("year","ko"),\uBD84\uAE30:o("quarter","ko"),\uC6D4:o("month","ko"),\uC77C:o("day","ko"),tahun:o("year","id"),kuartal:o("quarter","id"),triwulan:o("quarter","id"),bulan:o("month","id"),hari:o("day","id"),n\u0103m:o("year","vi"),qu\u00FD:o("quarter","vi"),th\u00E1ng:o("month","vi"),ng\u00E0y:o("day","vi"),\u0E1B\u0E35:o("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:o("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:o("month","th"),\u0E27\u0E31\u0E19:o("day","th"),\u0627\u0644\u0633\u0646\u0629:o("year","ar"),\u0633\u0646\u0629:o("year","ar"),\u0627\u0644\u0639\u0627\u0645:o("year","ar"),\u0639\u0627\u0645:o("year","ar"),\u0627\u0644\u0631\u0628\u0639:o("quarter","ar"),\u0631\u0628\u0639:o("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":o("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:o("month","ar"),\u0634\u0647\u0631:o("month","ar"),\u0627\u0644\u064A\u0648\u0645:o("day","ar"),\u064A\u0648\u0645:o("day","ar"),\u05E9\u05E0\u05D4:o("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:o("quarter","he"),\u05D7\u05D5\u05D3\u05E9:o("month","he"),\u05D9\u05D5\u05DD:o("day","he"),\u0935\u0930\u094D\u0937:o("year","hi"),\u0938\u093E\u0932:o("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:o("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:o("month","hi"),\u092E\u093E\u0939:o("month","hi"),\u0926\u093F\u0928:o("day","hi"),\u0633\u0627\u0644:o("year","fa"),\u0645\u0627\u0647:o("month","fa"),\u0631\u0648\u0632:o("day","fa")}),vr=Object.freeze(Array.from(new Set(Object.values(ae).flatMap(e=>e.langs)))),he=Object.freeze(["fa","ar","he","th"]),Ce=1900,be=2100;function Pr(e,t){let n=[],r=$(t);try{r&&n.push(e.toLocaleLowerCase(r.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function Mr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let r of Pr(n,t)){let a=ae[r];if(a&&a.langs.includes(t))return a.part}return null}function Ir(e,t){return he.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=Ce&&t<=be:!0}var Nr=16e3;function Fr(e,t){if(!Array.isArray(e))return"";let n=[];for(let a of e){let l=typeof a?.n=="string"?a.n:"";l!==""&&n.push({n:l,q:typeof a?.q=="string"?a.q:""})}if(n.length===0)return"";let r=JSON.stringify({v:1,l:typeof t=="string"?t:"",c:n});return r.length>16e3?"":r}function kr(e){if(typeof e!="string"||e===""||e.length>16e3)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.v!==1||!Array.isArray(t.c))return null;let n=[];for(let r of t.c){if(!r||typeof r.n!="string"||r.n==="")return null;n.push({n:r.n,q:typeof r.q=="string"?r.q:""})}return n.length===0?null:{v:1,l:typeof t.l=="string"?t.l:"",c:n}}function Dr(e,t){if(!e)return!1;let n=e.l.trim().toLowerCase(),r=String(t??"").trim().toLowerCase();return n===""||r===""||n!==r}function Gr(e,t){if(!t||t.c.length===0)return[];let n=new Set(t.c.map(r=>r.n));return e.filter(r=>!n.has(r))}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ur=/\b(?:columns|cols|column)\b/i;function H(e,t){let n=Math.max(0,t-240),r=e.slice(n,t),a=r.lastIndexOf(";");return a>=0&&(r=r.slice(a+1)),Ur.test(r)}function Te(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Se(e,t,n){let r=Ee(t),a=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${r}\2`,"g"),l=new RegExp(String.raw`\.name\s*===?\s*(['"])${r}\1`,"g"),u=0,i;for(;(i=l.exec(e))!==null;)H(e,i.index)&&u++;let C=0;for(;(i=a.exec(e))!==null;){let y=i.index+i[0].lastIndexOf(".name");if(!H(e,y))continue;C++;let h=Ee(i[1]);if(!n(h))return!1}return C>0&&C===u}function Wr(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var Re=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function Vr(e,t){if(!e)return[];let n=new Set(t);for(let i of Re)n.add(i);let r=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,l;for(;(l=a.exec(e))!==null;)H(e,l.index)&&r.add(l[2]);if(r.size===0)return[];let u=[];return r.forEach(i=>{n.has(i)||Te(e,i)||u.push(i)}),u}function qr(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(r=>r.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let r of e.aliasesForCode(t))n.push(r.alias);return n}function xe(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function Hr(e,t,n){let r=xe(e,t);if(r===null||r<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,l=r>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let u=l.split("{n}").join(String(r)).split("{fields}").join(r===1?"field":"fields"),i=we(n);return i.length===0?u:u+" "+i.join(" ")}function we(e){if(!e||e.length===0)return[];let t=[],n=new Map,r=new Map;for(let l of e){let u=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(u!==""&&(n.has(u)||(t.push(u),n.set(u,0)),l.isDatePart===!0&&n.set(u,n.get(u)+1),l.isReassembledDate===!0&&!r.has(u))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",y=i!==""?i:C;y!==""&&r.set(u,y)}}let a=[];for(let l of t){let u=r.get(l),i=n.get(l)??0;!u||i===0||a.push(`'${u}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}var f=e=>e==null?"":String(e),A=e=>e===!0,le=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},_e=e=>{let t=le(e);return t!==null&&t>0?t:null},Kr=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Oe(e,t){let n={};for(let[r,a]of Kr){let l=f(E(e,t+a));l&&(n[r]=l)}return n}function zr(e){return Array.isArray(e)?e.map(t=>({code:f(E(t,"code")),severity:f(E(t,"severity")),text:f(E(t,"text"))})).filter(t=>t.text!==""):[]}function $r(e){let t=m=>E(e,m),n=t("retryAfterSeconds"),r=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),l=Oe(e,"point"),u=Oe(e,"destPoint");Object.keys(u).length&&(l.dest=u);let i=t("retryable"),C=t("isPollFinal"),y=_e(t("chartMinWidth")),h=_e(t("chartMinHeight"));return{errorMessage:f(t("errorMessage")),errorCode:f(t("errorCode")),refusalCode:f(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:zr(t("notices")),freemiumStatusCode:f(t("freemiumStatusCode")),code:f(t("code")),language:f(t("language")),version:Number(t("version")??0),codeSummary:f(t("codeSummary")),chartName:f(t("chartName")??t("chartType")),finalChartName:f(t("finalChartName")),warningMessage:f(t("warningMessage")),outputHash:f(t("outputHash")),validatorToken:f(t("validatorToken")),editCodeKey:f(t("editCodeKey")),signedLLMRequestID:f(t("signedLLMRequestID")),userReply:f(t("userReply")),userReplyOutcome:f(t("userReplyOutcome")),improvementSuggestion:f(t("improvementSuggestion")),geoColumn:f(t("geoColumn")),geoKind:f(t("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:le(t("creditBalanceBefore")),creditCost:le(t("creditCost")),isServiceError:A(t("isServiceError")),isRateLimited:A(t("isRateLimited")),suppressSelectionGlyph:A(t("suppressSelectionGlyph")),isRefusal:A(t("isRefusal")),isVersionNotFound:A(t("isVersionNotFound")),isGenerationCancelled:A(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:f(t("servedCorrelationId")),...typeof C=="boolean"?{isPollFinal:C}:{},...f(t("pollOutcome"))!==""?{pollOutcome:f(t("pollOutcome"))}:{},...y!==null?{chartMinWidth:y}:{},...h!==null?{chartMinHeight:h}:{},...typeof r=="boolean"?{overrideThumbnailUpload:r}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}var Le=["app","table","map","kpi"];function ve(e){return typeof e=="string"&&Le.includes(e)?e:void 0}var Ae=e=>e==null?void 0:Number(e),D=e=>f(e)||void 0;function Br(e){let t=E(e,"charts"),n=E(e,"refused"),r=Array.isArray(t)?t.map(l=>{let u=C=>E(l,C),i=u("recommended");return{name:f(u("chartTypeName")??u("name")),description:f(u("description")??u("chartDesc")),rank:Ae(u("rank")),score:Ae(u("score")),renderer:D(u("renderer")),language:D(u("language")),isPreview:A(u("isPreview")),kind:ve(u("kind")),alsoWorthALook:A(u("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:D(u("viaProjection")),viaProjectionKey:D(u("viaProjectionKey")),detailNote:D(u("detailNote"))}}).filter(l=>l.name):null,a=Array.isArray(n)?n.map(l=>({name:f(E(l,"chartTypeName")??E(l,"name")),reason:f(E(l,"reason")),reasonCode:f(E(l,"reasonCode")),isVeto:A(E(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:f(E(e,"errorMessage")),errorCode:f(E(e,"errorCode")),charts:r,refused:a,noFitSummary:f(E(e,"noFitSummary"))}}function jr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var Pe=["working","analyze","generate","refine","review"];function Qr(e,t){let n=String(e??"").trim().toLowerCase();if(Pe.includes(n))return n;let r=String(t??"").toLowerCase();return r.includes("analyz")?"analyze":r.includes("generat")?"generate":r.includes("refin")?"refine":r.includes("review")?"review":null}var Yr="FREEMIUM_ATTEMPT_SPENT",Xr="CLIENT_SECRET_MISMATCH",Jr="FREEMIUM_COLUMN_CAP",Zr="OAUTH_TOKEN_EXPIRED",eo="OAUTH_SIGNED_OUT";function to(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function no(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,r=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function ro(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function oo(e){let t=0;for(let n of e){if(n.isMeasure)continue;let r=n.distinctCount;typeof r=="number"&&r>t&&(t=r)}return t}function Me(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,r=(e.codeVersion??0)>0?e.codeVersion:null,a=n??r??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function io(e){let t=e.fetchCorrelationId!=null,r=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=Me({genNew:r,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),l=e.fetchArmedAtMs,u=t&&typeof l=="number"&&Number.isSafeInteger(l)&&l>0?l:void 0,i=e.fetchCutAtMs,C=t&&typeof i=="number"&&Number.isSafeInteger(i)&&i>0?i:void 0,y=t?so(e.fetchCause):"";return{genNew:r,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...u!==void 0?{fetchArmedAtMs:u}:{},...C!==void 0?{fetchCutAtMs:C}:{},...y?{fetchCause:y}:{}}}function so(e){if(typeof e!="string")return"";let t=e.replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,120);return/[\ud800-\udbff]$/.test(t)&&(t=t.slice(0,-1)),t.trimEnd()}function ao(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function lo(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function uo(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function co(e,t,n){let r=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...r(t)?{rowsWithheld:t}:{},...r(n)?{rowsFilteredOut:n}:{}}}var fo={fit:"Best fit",variety:"Something different"};function Ie(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function mo(e){let t=Ie(e);return t?{qualifyOrder:t}:{}}function Ne(e,t){return e!=null&&t!=null&&e!==t}function po(e,t){return e?Ne(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var go=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Fe(e){let t=String(e??"").trim().toLowerCase();return go[t]??t}function ke(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Fe(n.dataType)]);return t}function yo(e){return B(ke(e))}var ho=2,Co=3,bo=4,Eo=64,To=8e3,So=6e4,Ro=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),xo=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function wo(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function _o(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Oo(){let e=new Set,t=new Set;return{firstDraw(n,r){if(!n)return!1;let a=`${n}|${r}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function Ao(e){return!!e&&!e.includes("|")&&!e.includes(",")}function ue(e,t,n,r){let a=`${e},${t}|${n}`;return r?`${a}|${Math.max(0,Math.round(r.count))}|${r.nonce}`:a}function Lo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,y=m=>{try{t.onFailure?.(m)}catch{}},h=async(m,p,c,g)=>{let b;try{let T=await a.post(p,c,g,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){y({channel:m,stage:"post",status:null,error:T});return}(b<200||b>299)&&y({channel:m,stage:"status",status:b,error:null})};return{async sendClientMessage(m){let p,c,g;try{p=`${C()}${u}/LogClientMsg/?nocache=${l.now()}`,c=M(m),g=k(c,r)}catch(b){y({channel:"client-message",stage:"build",status:null,error:b});return}await h("client-message",p,c,{"Content-Type":"text/plain","X-Signature":g})},async countEvent(m,p,c){let g,b;try{g=`${C()}${u}/eventlog`,b=ue(m,t.clientVersion,p,c)}catch(T){y({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",g,b,{"Content-Type":"text/plain"})}}}var De=2**31-1;function Ge(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function vo(e){return typeof e=="number"&&e>0&&e<=De?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${De} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Po(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,r=t.credentials??"omit";return{async post(a,l,u,i){let C=i.timeoutMs,y=vo(C);if(y)throw y;let h=new AbortController,m=!1,p=setTimeout(()=>{m=!0,h.abort(Ge(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let g=!1,b=()=>{g||(g=!0,clearTimeout(p),i.signal?.removeEventListener("abort",c))},T=_=>m?Ge(C):_,L;try{L=await n(a,{method:"POST",body:l,headers:u,credentials:r,signal:h.signal})}catch(_){throw b(),T(_)}let R=J(L),v=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...v,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...v,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ue=300;function We(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var Mo="/LLMChart/",Io="/LLMChart/qualify",No="/VisionReview/",Fo="/LLMChart/sample",ko="/RefundGenerate/",Do=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",K=async e=>JSON.parse(await e.text());function Go(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Uo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=m=>t.nocache?t.nocache(m):String(l.now());async function y(m,p,c,g,b){let T=`${i()}${u}${p}?nocache=${C(m)}`,L={"Content-Type":"text/plain","X-Signature":k(c,r)},R=g.signal??void 0,v=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Do(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,L,R?{timeoutMs:g.timeoutMs,signal:R}:{timeoutMs:g.timeoutMs})}catch(w){return v(!1,w)}if(x.status<200||x.status>299){let w="";if(g.readErrorBody===!1)Go(x);else try{w=(await x.text()).slice(0,Ue)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return v(!0,w)}}function h(m,p){if(!p||typeof p.timeoutMs!="number"||!Number.isFinite(p.timeoutMs)||p.timeoutMs<=0)throw new TypeError(`The ${m} call needs a positive deadline in milliseconds`);return p}return{async generate(m,p){let c=h("generate",p),g=c.onStage??void 0;return y("generate",Mo,M(m),c,b=>Z(b,g))},async qualify(m,p){let c=h("qualify",p),g=c.route??Io;if(typeof g!="string"||!g.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return y("qualify",g,M(m),c,K)},async review(m,p){let c=h("review",p),g=JSON.stringify(m);if(typeof g!="string")throw new TypeError("The review wire did not serialize to JSON");return y("review",No,g,c,K)},async sample(m,p){let c=h("sample",p);return y("sample",Fo,M(m),c,K)},async refund(m,p,c){let g=h("refund",p);if(typeof m!="string"||m.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let b=We(c),T=b?{CorrelationID:m.trim(),Reason:b}:{CorrelationID:m.trim()};return y("refund",ko,JSON.stringify(T),g,K)}}}export{hn as ADMIN1_MATCH_PCT,Cn as ADMIN1_MATCH_PCT_NAMED,j as CITY_ROLE_MATCH_PCT,Xt as CITY_TIE_RATIO,Ro as CLIENT_EVENT_KINDS,Xr as CLIENT_SECRET_MISMATCH,et as COMPOUND_MIN_STEM,Rt as CYCLE_MEMBERS,wt as CYCLE_WORDS,be as DATE_LEVEL_GREGORIAN_YEAR_MAX,Ce as DATE_LEVEL_GREGORIAN_YEAR_MIN,vr as DATE_LEVEL_LANGUAGES,ae as DATE_LEVEL_NAMES,he as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,er as DEFAULT_GAP_FACTOR,dt as DEFAULT_TEMPERATURE,xo as DRAW_REASONS,Yr as FREEMIUM_ATTEMPT_SPENT,Jr as FREEMIUM_COLUMN_CAP,Nr as GENERATION_COLUMNS_MAX_CHARS,ut as GET_RANDOM,nt as GLUED_STEM_MIN,ot as HANGUL_MIN_STEM,Re as HOST_SYNTHETIC_COLUMNS,Ue as HTTP_BODY_START_CHARS,jn as IDENTIFIER_HEAD_INITIAL,Qn as IDENTIFIER_UNFOLDED,Bn as IDENTIFIER_WORDS,Mn as INTENSIVE_SUFFIX_TOKENS,Pn as INTENSIVE_WORD_TOKENS,Cr as IndexedText,An as LATITUDE_WORDS,Ln as LONGITUDE_WORDS,kt as LOOSE_KEY_MIN_LENGTH,Gt as LooseIndex,tr as MAX_RUN_BOUNDS,eo as OAUTH_SIGNED_OUT,Zr as OAUTH_TOKEN_EXPIRED,vt as PERIOD_CODE_FORMS,Lt as PERIOD_CODE_MEMBERS,Pt as PERIOD_ORDINALS,Mt as PERIOD_UNFOLDED,Nn as POSITIONAL_SUFFIX_TOKENS,In as POSITIONAL_WORD_TOKENS,Sr as PREVIEW_OMITTED_FIELDS,Pe as PROGRESS_STAGE_IDS,Le as QUALIFY_KINDS,fo as QUALIFY_ORDER_LABELS,qt as REGION_FRAME_WINDOWS,P as ROLE_MATCH_PCT,or as SERIES_COMPLETENESS_MAX_LISTED,ir as SERIES_COMPLETENESS_MIN_FILL,sr as SERIES_KEY_MAX_DISTINCT,bo as SEV_ERROR,ho as SEV_INFO,Eo as SEV_USER_PRESENTED,Co as SEV_WARNING,B as SIMPLE_STRING_HASH,lt as STR,st as SUBSTRING_MIN,qe as SUPPORTED_LANGUAGES,He as SUPPORTED_LANGUAGE_CODES,So as TELEMETRY_TIMEOUT_DEV_MS,To as TELEMETRY_TIMEOUT_MS,$e as VOCABULARY_LANGUAGE_CODES,ze as VOCABULARY_ONLY_LANGUAGES,xt as YEAR_WORDS,Zt as admin1CodesForName,Q as admin1LookupRegistered,q as admin1MatchPct,Hn as allowedAggregations,Tt as anchorLocalWallClockDates,to as answerIsRetryable,yn as buildGeoIsoColumn,cn as buildGeoPointColumns,En as buildProvinceIsoColumn,_t as calendarWordIn,ao as capabilityFields,fn as cityMatchPct,dn as cityTagsFor,gr as classifyAdditivity,_o as classifyDraw,qn as classifyForAggregation,yr as classifyNumericValueNature,mr as classifyTemporal,Qt as clearAdmin1LookupForTests,Gn as codeNeedsLegacyAggNames,Xn as codeReadsColumn,Jn as codeReadsColumnsByRoleOrPosition,Dn as collapseRepeatedAggPrefix,Gr as columnsNeverGeneratedOn,Zn as columnsTheCodeReads,vn as coordinateAxisOfWords,Yt as countryIso2,zt as countryRegion,Oo as createDrawLedger,Uo as createGenerateClient,Lo as createTelemetryClient,no as credentialFields,co as dataCompletenessFields,Mr as dateLevelPart,Ir as dateLevelYearAdmits,St as datesAreTimeOfDayOnly,bt as datesCarryTimeOfDay,Rn as decimalSeparatorOf,Kn as defaultAggregation,xn as detectDecimalSeparator,Sn as detectFormatSignature,mn as detectGeo,Vt as detectOrdinalDomain,fr as detectTextDatePattern,wo as drawLocation,M as encodePayload,br as engineTypeForSqlType,Un as englishImplicitAggNames,ue as eventLogLine,io as fetchFields,Po as fetchTransport,je as foldName,Hr as freemiumColumnCapRefusal,xe as freemiumColumnsOverCap,we as freemiumDateHierarchyClauses,Dr as generationColumnsAnswerInLocale,rt as gluedPrefixStems,qr as guardColumnNames,xr as gzipWireText,it as hangulWordEndsWith,kn as hasDefaultAggPrefix,Je as hasUnsegmentedScript,pr as hostAggHint,Bt as inMiddleEast,Tr as ingest,zn as isAggregationAllowed,G as isBlankLike,rn as isCityTableLoaded,H as isColumnContextRef,ct as isDeterministicRefusal,Ao as isEventLogCode,ln as isGeoPointAmbiguity,dr as isIdentifierName,gn as isJoinGeoKind,tn as isKnownProvinceId,_r as isNdjsonContentType,Ut as isOrdinalFriendlyName,Dt as isUsableLooseKey,wr as keyedSigner,uo as leafCardinalityField,yt as localMidnightDateColumns,gt as localMidnightToUtcDay,Et as localWallClockDateColumns,At as localizedCycleIn,Yn as localizedIdentifierWordIn,Ot as localizedYearWordIn,N as looksLikeCountryColumn,Ft as looseNameKey,at as matchNameToken,oo as maxNonMeasureCardinality,Tn as measureAdmin1Columns,rr as measureCadence,cr as measurePersistence,ur as measureSeriesCompleteness,k as messageSignature,Vr as missingHardColumnRefs,On as monthLookupFor,Ye as nameLetterRuns,Vn as nameLooksIntensiveRate,Wn as nameLooksPositional,Te as nameProbeIsGuarded,Wr as nameProbeKeepsDrawing,Qe as nameWords,on as normalizeCountry,ht as normalizeLocalMidnightDates,_n as normalizeMonthKey,U as normalizePlaceName,an as normalizeZip5,po as offeredShortlistFor,Er as parseCsvRows,ft as parseDateStable,$r as parseGenerateResponse,kr as parseGenerationColumns,wn as parseNumberText,Br as parseQualifyResponse,jr as parseReviewVerdict,nr as parseTemporalPoint,Rr as payloadPreview,Nt as periodCodeSeries,lr as pickSeriesColumn,Qr as progressStageOf,hr as promotesToMeasure,en as provinceIdForAdmin1Code,bn as provinceIdForRow,ve as qualifyKindOf,mo as qualifyOrderField,Ie as qualifyOrderOf,Z as readGenerateStream,Xe as readName,It as readPeriodCode,E as readWireField,We as refundReasonCode,jt as registerAdmin1Lookup,nn as registerCityTable,Kt as registerIso3Regions,I as resolveAdmin1,Jt as resolveCityAdmin1,Me as resolveFetchVersion,un as resolveGeoPoint,Be as resolveLanguage,Lr as resolvePointRoles,lo as retryFields,Wt as safeDistinctValuesToShip,ke as schemaIdentity,yo as schemaIdentityKey,Fe as schemaTypeFamily,Fr as serializeGenerationColumns,ar as seriesKeyVerdict,$n as shareOfTotalIsHonest,Ne as shortlistIsStale,Fn as stripHostAggPrefix,$t as summarizeCountryRegions,Ht as summarizeGeoExtent,Ke as supportedLanguage,pn as toGeoIso,Ze as unsegmentedRuns,Ct as utcWallClock,ro as viewportFields,$ as vocabularyLanguage,mt as wholeDayFrame,pt as wholeDayIso,J as wireResponseFromFetch,tt as wordEndsWith,ie as zipMatchPct,V as zipPrefixCandidates,sn as zipToPrefix3};
2
+ import{a as xr,b as wr}from"./chunk-HIVICMC5.mjs";import{a as _r,b as M,c as Ar,d as k,e as E,f as Or,g as J,h as Z}from"./chunk-4J7WPYLM.mjs";import{a as br,b as Er,c as Tr,d as Sr,e as Rr}from"./chunk-O6HX7LOP.mjs";import{A as jn,B as Qn,C as Yn,D as Xn,E as Jn,F as Zn,G as er,H as tr,I as nr,J as rr,K as or,L as ir,M as sr,N as ar,O as lr,P as ur,Q as cr,R as dr,S as fr,T as mr,U as pr,V as gr,W as yr,X as hr,Z as Cr,a as hn,b as Cn,c as bn,d as En,e as Tn,g as On,h as Ln,i as vn,j as Pn,k as Mn,l as In,m as Nn,n as Fn,o as kn,p as Dn,q as Gn,r as Un,s as Wn,t as Vn,u as qn,v as Hn,w as Kn,x as zn,y as $n,z as Bn}from"./chunk-J5EZ7BH7.mjs";import{a as Sn}from"./chunk-U3H6UBOO.mjs";import{b as Rn,c as xn,d as wn,f as _n,g as An}from"./chunk-TZ74QIKA.mjs";import{a as fe,c as me,e as mn,f as pn,g as gn,h as yn}from"./chunk-YDYFP2T4.mjs";import{A as Y,B as nn,C as rn,D as de,E as I,F as on,G as sn,H as an,I as V,J as ln,K as un,L as cn,M as dn,N as X,O as fn,a as P,b as G,c as j,d as U,j as W,k as qt,l as Ht,m as Kt,n as zt,o as $t,q as Bt,r as jt,s as Q,t as Qt,u as Yt,v as Xt,w as Jt,x as Zt,y as en,z as tn}from"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import{a as Rt,b as xt,c as wt,d as _t,e as At,f as Ot,g as Lt,h as vt,i as Pt,j as Mt,k as It,l as Nt,m as Ut,n as Wt,o as Vt}from"./chunk-3ZAS32F5.mjs";import{b as Ft,c as kt,d as Dt,e as Gt}from"./chunk-5HI6TVMM.mjs";import{A as Ct,B as bt,C as Et,D as Tt,E as St,a as je,b as Qe,c as Ye,d as Xe,e as Je,f as Ze,g as et,h as tt,i as nt,j as rt,k as ot,l as it,m as st,n as at,o as lt,q as B,r as ut,s as ct,t as dt,u as ft,v as mt,w as pt,x as gt,y as yt,z as ht}from"./chunk-CZJ7M6A5.mjs";import{a as qe,b as He,c as Ke,d as ze,e as $e,f as $,g as Be}from"./chunk-WC4JINEZ.mjs";var ee=2,ye=400;function ne(e){return!!W(e)}function F(e){let t=new Set;for(let n of e){if(n==null)continue;let r=U(String(n));if(!G(r)&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function N(e){let t=F(e);if(t.length===0||re(e)<95)return!1;let n=t.filter(a=>ne(a)&&!I(a)).length,r=t.filter(a=>!ne(a)&&!!I(a)).length;return n>=1&&n>=r}function pe(e,t){if(!I(e))return!1;let n=W(e);return n?t==="world"?!0:de.has(n):!1}function re(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)ne(r)&&n++;return Math.round(n/t.length*1e3)/10}function oe(e){return I(e)?!0:Q()?Y(e).status!=="unmatched"||Y(e.trim().replace(/\s+/g,"-")).status!=="unmatched":!1}function q(e){let t=F(e);if(t.length===0)return 0;let n=0;for(let r of t)oe(r)&&n++;return Math.round(n/t.length*1e3)/10}function se(e){let t=new Set;for(let n of e){if(n==null)continue;let r=String(n).trim();if(!G(U(r))&&!t.has(r)&&(t.add(r),t.size>=ye))break}return Array.from(t)}function ie(e){let t=se(e);if(t.length===0)return 0;let n=0;for(let r of t)V(r).length>0&&n++;return Math.round(n/t.length*1e3)/10}function ge(e,t){return me(t,fe)?!0:se(e).some(n=>/^\d{5}(-\d{4})?$/.test(n.replace(/\.0+$/,"")))}function Lr(e,t){let n=F(e);if(n.length===0)return 0;let r=0;for(let a of n)X(a,t)&&r++;return Math.round(r/n.length*1e3)/10}function te(e,t){let n=0;for(let r of F(e))t(r)&&n++;return n}function vr(e,t){let n=0;for(let r of se(e))t(r)&&n++;return n}function Pr(e,t,n,r,a){let l=[],u=[],i={},C={},y=new Set(e),h=s=>t.map(d=>d[s]);for(let s of["city","country"]){let d=n?.[s];d&&y.has(d)&&(i[s]=d)}let m=new Set(a??e);for(let s of["lat","lon"]){let d=n?.[s];d&&m.has(d)&&(i[s]=d)}let p=n?.zip;if(p&&y.has(p)){let s=h(p),d=ie(s);d<95?u.push(`zip=${p} (only ${d}% of values read as ZIPs)`):ge(s,p)?i.zip=p:u.push(`zip=${p} (all values are 3-4 digits with nothing to say they are postal)`)}let c=n?.state;if(c&&y.has(c)){let s=h(c),d=F(s);d.length>0&&d.every(S=>pe(S,r))?u.push(`state=${c} (every value is "CA", which is both Canada and California)`):N(s)?(u.push(`state=${c} (every value is a country, not a state)`),i.country||(i.country=c)):q(s)<95?u.push(`state=${c} (only ${q(s)}% of values are states/provinces)`):i.state=c}let g=new Set(Object.values(i).filter(Boolean)),b=e.filter(s=>!g.has(s)&&!s.startsWith("__"));if(!i.state){let s=null;for(let d of b){let S=h(d);if(N(S))continue;let A=q(S);if(A<95)continue;let z=te(S,oe),Ve=te(S,ce=>oe(ce)&&!pe(ce,r));z<ee&&Ve<1||(!s||A>s.pct)&&(s={name:d,pct:A})}s&&(i.state=s.name,g.add(s.name),l.push(`state=${s.name} (${s.pct}% states/provinces)`))}if(!i.zip)for(let s of b){if(g.has(s))continue;let d=h(s),S=ie(d);if(!(S<95)&&ge(d,s)&&!(vr(d,A=>V(A).length>0)<ee)){i.zip=s,g.add(s),l.push(`zip=${s} (${S}% ZIP codes)`);break}}let T=i.country;if(!T||!N(h(T))){let s=null;for(let d of b){if(g.has(d)||!N(h(d)))continue;let S=re(h(d));(!s||S>s.pct)&&(s={name:d,pct:S})}s&&(T&&(u.push(`country=${T} (only ${re(h(T))}% of values are country identifiers; using ${s.name} instead)`),C.country=T),i.country=s.name,g.add(s.name),l.push(`country=${s.name}`))}if(!i.city){let s=null;for(let d of b){if(g.has(d))continue;let S=h(d),A=Lr(S,r);A<j||te(S,z=>X(z,r))<ee||(!s||A>s.pct)&&(s={name:d,pct:A})}s&&(i.city=s.name,l.push(`city=${s.name} (${s.pct}% known cities)`))}let L=i.country?h(i.country):[],R=!!i.country&&N(L),v=R?new Set(L.map(s=>W(s==null?null:String(s))).filter(Boolean)).size:0,x=R&&v>=2,w=!!(i.lat&&i.lon)&&t.some(s=>{let d=+String(s[i.lat]??"").trim(),S=+String(s[i.lon]??"").trim();return isFinite(d)&&isFinite(S)&&d>=-90&&d<=90&&S>=-180&&S<=180&&String(s[i.lat]??"").trim()!==""&&String(s[i.lon]??"").trim()!==""});return i.lat&&i.lon&&!w&&u.push(`lat/lon=${i.lat}/${i.lon} (no row holds a usable coordinate pair)`),i.country&&!x&&!(i.city||i.state||i.zip||w)&&u.push(R?`country=${i.country} (every row resolves to the same country - nothing to place apart)`:`country=${i.country} (values are not country identifiers)`),{bind:!!(i.city||i.state||i.zip||x||w)?i:null,backfilled:l,refused:u,...Object.keys(C).length?{labelFallback:C}:{}}}var o=(e,...t)=>({part:e,langs:Object.freeze(t)}),ae=Object.freeze({jaar:o("year","nl"),kwartaal:o("quarter","nl"),maand:o("month","nl"),dag:o("day","nl","sv","da","nb"),jahr:o("year","de"),quartal:o("quarter","de"),monat:o("month","de"),tag:o("day","de"),ann\u00E9e:o("year","fr"),mois:o("month","fr"),jour:o("day","fr"),trimestre:o("quarter","fr","es","pt","it"),a\u00F1o:o("year","es"),mes:o("month","es"),d\u00EDa:o("day","es"),ano:o("year","pt"),m\u00EAs:o("month","pt"),dia:o("day","pt"),anno:o("year","it"),mese:o("month","it"),giorno:o("day","it"),\u0433\u043E\u0434:o("year","ru"),\u043C\u0435\u0441\u044F\u0446:o("month","ru"),\u0440\u0456\u043A:o("year","uk"),\u043C\u0456\u0441\u044F\u0446\u044C:o("month","uk"),\u043A\u0432\u0430\u0440\u0442\u0430\u043B:o("quarter","ru","uk"),\u0434\u0435\u043D\u044C:o("day","ru","uk"),rok:o("year","pl","cs","sk"),kwarta\u0142:o("quarter","pl"),miesi\u0105c:o("month","pl"),dzie\u0144:o("day","pl"),\u010Dtvrtlet\u00ED:o("quarter","cs"),m\u011Bs\u00EDc:o("month","cs"),den:o("day","cs"),\u0161tvr\u0165rok:o("quarter","sk"),mesiac:o("month","sk"),de\u0148:o("day","sk"),\u00E5r:o("year","sv","da","nb"),kvartal:o("quarter","sv","da","nb"),m\u00E5nad:o("month","sv"),m\u00E5ned:o("month","da","nb"),vuosi:o("year","fi"),vuosinelj\u00E4nnes:o("quarter","fi"),kuukausi:o("month","fi"),p\u00E4iv\u00E4:o("day","fi"),\u00E9v:o("year","hu"),negyed\u00E9v:o("quarter","hu"),h\u00F3nap:o("month","hu"),nap:o("day","hu"),y\u0131l:o("year","tr"),\u00E7eyrek:o("quarter","tr"),ay:o("month","tr"),g\u00FCn:o("day","tr"),\u03AD\u03C4\u03BF\u03C2:o("year","el"),\u03C4\u03C1\u03AF\u03BC\u03B7\u03BD\u03BF:o("quarter","el"),\u03BC\u03AE\u03BD\u03B1\u03C2:o("month","el"),\u03B7\u03BC\u03AD\u03C1\u03B1:o("day","el"),an:o("year","ro"),trimestru:o("quarter","ro"),lun\u0103:o("month","ro"),zi:o("day","ro"),godina:o("year","hr"),tromjese\u010Dje:o("quarter","hr"),mjesec:o("month","hr"),dan:o("day","hr"),\u5E74:o("year","ja","zh"),\u56DB\u534A\u671F:o("quarter","ja"),\u5B63\u5EA6:o("quarter","zh"),\u6708:o("month","ja","zh"),\u65E5:o("day","ja","zh"),\uC5F0\uB3C4:o("year","ko"),\uBD84\uAE30:o("quarter","ko"),\uC6D4:o("month","ko"),\uC77C:o("day","ko"),tahun:o("year","id"),kuartal:o("quarter","id"),triwulan:o("quarter","id"),bulan:o("month","id"),hari:o("day","id"),n\u0103m:o("year","vi"),qu\u00FD:o("quarter","vi"),th\u00E1ng:o("month","vi"),ng\u00E0y:o("day","vi"),\u0E1B\u0E35:o("year","th"),\u0E44\u0E15\u0E23\u0E21\u0E32\u0E2A:o("quarter","th"),\u0E40\u0E14\u0E37\u0E2D\u0E19:o("month","th"),\u0E27\u0E31\u0E19:o("day","th"),\u0627\u0644\u0633\u0646\u0629:o("year","ar"),\u0633\u0646\u0629:o("year","ar"),\u0627\u0644\u0639\u0627\u0645:o("year","ar"),\u0639\u0627\u0645:o("year","ar"),\u0627\u0644\u0631\u0628\u0639:o("quarter","ar"),\u0631\u0628\u0639:o("quarter","ar"),"\u0631\u0628\u0639 \u0627\u0644\u0633\u0646\u0629":o("quarter","ar"),\u0627\u0644\u0634\u0647\u0631:o("month","ar"),\u0634\u0647\u0631:o("month","ar"),\u0627\u0644\u064A\u0648\u0645:o("day","ar"),\u064A\u0648\u0645:o("day","ar"),\u05E9\u05E0\u05D4:o("year","he"),\u05E8\u05D1\u05E2\u05D5\u05DF:o("quarter","he"),\u05D7\u05D5\u05D3\u05E9:o("month","he"),\u05D9\u05D5\u05DD:o("day","he"),\u0935\u0930\u094D\u0937:o("year","hi"),\u0938\u093E\u0932:o("year","hi"),\u0924\u093F\u092E\u093E\u0939\u0940:o("quarter","hi"),\u092E\u0939\u0940\u0928\u093E:o("month","hi"),\u092E\u093E\u0939:o("month","hi"),\u0926\u093F\u0928:o("day","hi"),\u0633\u0627\u0644:o("year","fa"),\u0645\u0627\u0647:o("month","fa"),\u0631\u0648\u0632:o("day","fa")}),Mr=Object.freeze(Array.from(new Set(Object.values(ae).flatMap(e=>e.langs)))),he=Object.freeze(["fa","ar","he","th"]),Ce=1900,be=2100;function Ir(e,t){let n=[],r=$(t);try{r&&n.push(e.toLocaleLowerCase(r.intl))}catch{}let a=e.toLowerCase();return n.includes(a)||n.push(a),n}function Nr(e,t){let n=String(e??"").trim().normalize("NFC");if(!n)return null;for(let r of Ir(n,t)){let a=ae[r];if(a&&a.langs.includes(t))return a.part}return null}function Fr(e,t){return he.includes(e)?typeof t=="number"&&Number.isFinite(t)&&t>=Ce&&t<=be:!0}var kr=16e3;function Dr(e,t){if(!Array.isArray(e))return"";let n=[];for(let a of e){let l=typeof a?.n=="string"?a.n:"";l!==""&&n.push({n:l,q:typeof a?.q=="string"?a.q:""})}if(n.length===0)return"";let r=JSON.stringify({v:1,l:typeof t=="string"?t:"",c:n});return r.length>16e3?"":r}function Gr(e){if(typeof e!="string"||e===""||e.length>16e3)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||t.v!==1||!Array.isArray(t.c))return null;let n=[];for(let r of t.c){if(!r||typeof r.n!="string"||r.n==="")return null;n.push({n:r.n,q:typeof r.q=="string"?r.q:""})}return n.length===0?null:{v:1,l:typeof t.l=="string"?t.l:"",c:n}}function Ur(e,t){if(!e)return!1;let n=e.l.trim().toLowerCase(),r=String(t??"").trim().toLowerCase();return n===""||r===""||n!==r}function Wr(e,t){if(!t||t.c.length===0)return[];let n=new Set(t.c.map(r=>r.n));return e.filter(r=>!n.has(r))}function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Vr=/\b(?:columns|cols|column)\b/i;function H(e,t){let n=Math.max(0,t-240),r=e.slice(n,t),a=r.lastIndexOf(";");return a>=0&&(r=r.slice(a+1)),Vr.test(r)}function Te(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|[!=]==?\s*-1)`).test(e))}function Se(e,t,n){let r=Ee(t),a=new RegExp(String.raw`(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*?\.name\s*===?\s*(['"])${r}\2`,"g"),l=new RegExp(String.raw`\.name\s*===?\s*(['"])${r}\1`,"g"),u=0,i;for(;(i=l.exec(e))!==null;)H(e,i.index)&&u++;let C=0;for(;(i=a.exec(e))!==null;){let y=i.index+i[0].lastIndexOf(".name");if(!H(e,y))continue;C++;let h=Ee(i[1]);if(!n(h))return!1}return C>0&&C===u}function qr(e,t){return Se(e,t,n=>new RegExp(String.raw`\b${n}\s*(?:>=\s*0|>\s*-1|!==?\s*-1)`).test(e)&&!new RegExp(String.raw`\b${n}\s*===?\s*-1`).test(e))}var Re=["__rowIdx__","__geoIso__","__geoLat__","__geoLon__","__geoPrecision__"];function Hr(e,t){if(!e)return[];let n=new Set(t);for(let i of Re)n.add(i);let r=new Set,a=/\.name\s*===?\s*(['"])([^'"]+)\1/g,l;for(;(l=a.exec(e))!==null;)H(e,l.index)&&r.add(l[2]);if(r.size===0)return[];let u=[];return r.forEach(i=>{n.has(i)||Te(e,i)||u.push(i)}),u}function Kr(e,t){if(!e)return[];let n=(e.getColumns()||[]).map(r=>r.name);if(!t||typeof e.aliasesForCode!="function")return n;for(let r of e.aliasesForCode(t))n.push(r.alias);return n}function xe(e,t){let n=t?.freemiumMaxShapeColumns;return typeof n!="number"||!isFinite(n)||n<1?null:!isFinite(e)||e<=n?0:Math.round(e-n)}function zr(e,t,n){let r=xe(e,t);if(r===null||r<=0)return null;let a=typeof t?.freemiumColumnCapPivot=="number"?t.freemiumColumnCapPivot:4,l=r>a?t?.freemiumColumnCapMessageMany:t?.freemiumColumnCapMessageFew;if(typeof l!="string"||l.trim().length===0)return null;let u=l.split("{n}").join(String(r)).split("{fields}").join(r===1?"field":"fields"),i=we(n);return i.length===0?u:u+" "+i.join(" ")}function we(e){if(!e||e.length===0)return[];let t=[],n=new Map,r=new Map;for(let l of e){let u=typeof l?.dateGroupId=="string"?l.dateGroupId.trim():"";if(u!==""&&(n.has(u)||(t.push(u),n.set(u,0)),l.isDatePart===!0&&n.set(u,n.get(u)+1),l.isReassembledDate===!0&&!r.has(u))){let i=typeof l.sourceField=="string"?l.sourceField.trim():"",C=typeof l.name=="string"?l.name.trim():"",y=i!==""?i:C;y!==""&&r.set(u,y)}}let a=[];for(let l of t){let u=r.get(l),i=n.get(l)??0;!u||i===0||a.push(`'${u}' is a date hierarchy and counts as ${i+1} fields - bind the date itself instead of its hierarchy.`)}return a}var f=e=>e==null?"":String(e),O=e=>e===!0,le=e=>{if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&e.trim()!==""){let t=Number(e);return Number.isFinite(t)?t:null}return null},_e=e=>{let t=le(e);return t!==null&&t>0?t:null},$r=[["city","CityColumn"],["state","StateColumn"],["zip","ZipColumn"],["lat","LatColumn"],["lon","LonColumn"],["country","CountryColumn"]];function Ae(e,t){let n={};for(let[r,a]of $r){let l=f(E(e,t+a));l&&(n[r]=l)}return n}function Br(e){return Array.isArray(e)?e.map(t=>({code:f(E(t,"code")),severity:f(E(t,"severity")),text:f(E(t,"text"))})).filter(t=>t.text!==""):[]}function jr(e){let t=m=>E(e,m),n=t("retryAfterSeconds"),r=t("overrideThumbnailUpload"),a=t("forceThumbnailUpload"),l=Ae(e,"point"),u=Ae(e,"destPoint");Object.keys(u).length&&(l.dest=u);let i=t("retryable"),C=t("isPollFinal"),y=_e(t("chartMinWidth")),h=_e(t("chartMinHeight"));return{errorMessage:f(t("errorMessage")),errorCode:f(t("errorCode")),refusalCode:f(t("refusalCode")),retryable:typeof i=="boolean"?i:null,notices:Br(t("notices")),freemiumStatusCode:f(t("freemiumStatusCode")),code:f(t("code")),language:f(t("language")),version:Number(t("version")??0),codeSummary:f(t("codeSummary")),chartName:f(t("chartName")??t("chartType")),finalChartName:f(t("finalChartName")),warningMessage:f(t("warningMessage")),outputHash:f(t("outputHash")),validatorToken:f(t("validatorToken")),editCodeKey:f(t("editCodeKey")),signedLLMRequestID:f(t("signedLLMRequestID")),userReply:f(t("userReply")),userReplyOutcome:f(t("userReplyOutcome")),improvementSuggestion:f(t("improvementSuggestion")),geoColumn:f(t("geoColumn")),geoKind:f(t("geoKind")),geoPointCols:Object.keys(l).length?l:null,creditBalanceBefore:le(t("creditBalanceBefore")),creditCost:le(t("creditCost")),isServiceError:O(t("isServiceError")),isRateLimited:O(t("isRateLimited")),suppressSelectionGlyph:O(t("suppressSelectionGlyph")),isRefusal:O(t("isRefusal")),isVersionNotFound:O(t("isVersionNotFound")),isGenerationCancelled:O(t("isGenerationCancelled")),retryAfterSeconds:typeof n=="number"&&Number.isFinite(n)?n:null,servedCorrelationId:f(t("servedCorrelationId")),...typeof C=="boolean"?{isPollFinal:C}:{},...f(t("pollOutcome"))!==""?{pollOutcome:f(t("pollOutcome"))}:{},...y!==null?{chartMinWidth:y}:{},...h!==null?{chartMinHeight:h}:{},...typeof r=="boolean"?{overrideThumbnailUpload:r}:{},...typeof a=="boolean"?{forceThumbnailUpload:a}:{}}}var Le=["app","table","map","kpi"];function ve(e){return typeof e=="string"&&Le.includes(e)?e:void 0}var Oe=e=>e==null?void 0:Number(e),D=e=>f(e)||void 0;function Qr(e){let t=E(e,"charts"),n=E(e,"refused"),r=Array.isArray(t)?t.map(l=>{let u=C=>E(l,C),i=u("recommended");return{name:f(u("chartTypeName")??u("name")),description:f(u("description")??u("chartDesc")),rank:Oe(u("rank")),score:Oe(u("score")),renderer:D(u("renderer")),language:D(u("language")),isPreview:O(u("isPreview")),kind:ve(u("kind")),alsoWorthALook:O(u("alsoWorthALook")),recommended:typeof i=="boolean"?i:void 0,viaProjection:D(u("viaProjection")),viaProjectionKey:D(u("viaProjectionKey")),detailNote:D(u("detailNote"))}}).filter(l=>l.name):null,a=Array.isArray(n)?n.map(l=>({name:f(E(l,"chartTypeName")??E(l,"name")),reason:f(E(l,"reason")),reasonCode:f(E(l,"reasonCode")),isVeto:O(E(l,"isVeto"))})).filter(l=>l.name):[];return{errorMessage:f(E(e,"errorMessage")),errorCode:f(E(e,"errorCode")),charts:r,refused:a,noFitSummary:f(E(e,"noFitSummary"))}}function Yr(e){return!e||typeof e!="object"?null:{status:String(E(e,"status")??""),verdictReason:E(e,"verdictReason")??null,instruction:E(e,"instruction")??null,fix:E(e,"fix")??null,errorMessage:E(e,"errorMessage")??null,errorCode:E(e,"errorCode")??null}}var Pe=["working","analyze","generate","refine","review"];function Xr(e,t){let n=String(e??"").trim().toLowerCase();if(Pe.includes(n))return n;let r=String(t??"").toLowerCase();return r.includes("analyz")?"analyze":r.includes("generat")?"generate":r.includes("refin")?"refine":r.includes("review")?"review":null}var Jr="FREEMIUM_ATTEMPT_SPENT",Zr="CLIENT_SECRET_MISMATCH",eo="FREEMIUM_COLUMN_CAP",to="OAUTH_TOKEN_EXPIRED",no="OAUTH_SIGNED_OUT";function ro(e){let t=e?.retryable;return typeof t=="boolean"?t:null}function oo(e){let t=e.linkNonce?(e.linkNonce()??"").trim():null,n=t?null:e.accessToken?(e.accessToken()??"").trim():null,r=t||n?{licensee:"",licenseKey:"",secretKey:""}:e.triple();return{request:{licenseKey:r.licenseKey,licensee:r.licensee,secretKey:r.secretKey,freemiumKey:e.freemiumKey?.()??""},linkNonce:t,accessToken:n}}function io(e){let{width:t,height:n}=e.measure();return{request:{height:n,width:t},hints:{viewportWidth:t,viewportHeight:n}}}function so(e){let t=0;for(let n of e){if(n.isMeasure)continue;let r=n.distinctCount;typeof r=="number"&&r>t&&(t=r)}return t}function Me(e){if(e.recoveryFetchByCorrelation)return{version:null,fetchOnly:!0};if(e.recoveryFetchVersion!=null)return{version:e.recoveryFetchVersion,fetchOnly:!0};let t=e.settingVersion??null;if(e.genNew)return{version:t,fetchOnly:void 0};let n=(t??0)>0?t:null,r=(e.codeVersion??0)>0?e.codeVersion:null,a=n??r??t;return{version:a,fetchOnly:a!=null&&a>0?!0:void 0}}function ao(e){let t=e.fetchCorrelationId!=null,r=t||e.recoveryFetchVersion!=null?!1:e.genNew,a=Me({genNew:r,recoveryFetchVersion:e.recoveryFetchVersion,recoveryFetchByCorrelation:t,settingVersion:e.settingVersion,codeVersion:e.codeVersion}),l=e.fetchArmedAtMs,u=t&&typeof l=="number"&&Number.isSafeInteger(l)&&l>0?l:void 0,i=e.fetchCutAtMs,C=t&&typeof i=="number"&&Number.isSafeInteger(i)&&i>0?i:void 0,y=t?lo(e.fetchCause):"";return{genNew:r,version:a.version,fetchOnly:a.fetchOnly,fetchCorrelationId:e.fetchCorrelationId??void 0,...u!==void 0?{fetchArmedAtMs:u}:{},...C!==void 0?{fetchCutAtMs:C}:{},...y?{fetchCause:y}:{}}}function lo(e){if(typeof e!="string")return"";let t=e.replace(/[\u0000-\u001f\u007f]+/g," ").trim().slice(0,120);return/[\ud800-\udbff]$/.test(t)&&(t=t.slice(0,-1)),t.trimEnd()}function uo(e){let t=n=>e.renderers.has(n);return{supportsD3:t("D3"),supportsPlotly:t("PLOTLY"),supportsVega:t("VEGA")}}function co(e){let t=e.cap!=null&&e.budget>e.cap?e.cap:e.budget;return{triesLeft:e.triesLeft??t,maxTries:t}}function fo(e){return e&&e>0?{leafCardinality:Math.round(e)}:{}}function mo(e,t,n){let r=a=>typeof a=="number"&&Number.isInteger(a)&&a>0;return{...typeof e=="boolean"?{dataComplete:e}:{},...r(t)?{rowsWithheld:t}:{},...r(n)?{rowsFilteredOut:n}:{}}}var po={fit:"Best fit",variety:"Something different"};function Ie(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t==="fit"||t==="variety"?t:null}function go(e){let t=Ie(e);return t?{qualifyOrder:t}:{}}function Ne(e,t){return e!=null&&t!=null&&e!==t}function yo(e,t){return e?Ne(t.capturedFor,t.now)?{shortlist:void 0,stale:!0}:{shortlist:{...e,ageMs:t.atMs>0?Math.max(0,Math.round(t.nowMs-t.atMs)):void 0},stale:!1}:{shortlist:void 0,stale:!1}}var ho=Object.freeze({integer:"number",decimal:"number",double:"number",datetime:"date",date:"date",boolean:"boolean",string:"text"});function Fe(e){let t=String(e??"").trim().toLowerCase();return ho[t]??t}function ke(e){let t="";for(let n of e)t+=JSON.stringify([String(n.name??""),n.isMeasure?"M":"D",Fe(n.dataType)]);return t}function Co(e){return B(ke(e))}var bo=2,Eo=3,To=4,So=64,Ro=8e3,xo=6e4,wo=Object.freeze({RENDER_START:"render-start",RENDER_OK:"render-ok",RENDER_ERROR:"render-error",VIEW:"view",VIEW_VERDICT:"view-verdict",REDRAW:"redraw",INTERACT:"interact"}),_o=Object.freeze(["open","generate","version","rebind","data","sample","fix","resize","other"]);function Ao(e,t){return t?`${t};draw:${e}`:`draw:${e}`}function Oo(e){return e.hint?e.hint:e.generated?"generate":e.previous?e.outputHash!==e.previous.outputHash?"version":e.dataSignature!==e.previous.dataSignature?"data":e.viewport!==e.previous.viewport?"resize":"other":"open"}function Lo(){let e=new Set,t=new Set;return{firstDraw(n,r){if(!n)return!1;let a=`${n}|${r}`;return e.has(a)?!1:(e.add(a),!0)},firstInteract(n){return!n||t.has(n)?!1:(t.add(n),!0)}}}function vo(e){return!!e&&!e.includes("|")&&!e.includes(",")}function ue(e,t,n,r){let a=`${e},${t}|${n}`;return r?`${a}|${Math.max(0,Math.round(r.count))}|${r.nonce}`:a}function Po(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createTelemetryClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createTelemetryClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createTelemetryClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createTelemetryClient needs the service's base URL");if(typeof t.clientVersion!="string"||t.clientVersion==="")throw new TypeError("createTelemetryClient needs the client version");if(typeof t.timeoutMs!="number"||!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)throw new TypeError("createTelemetryClient needs a positive deadline in milliseconds");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=t.timeoutMs,C=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,y=m=>{try{t.onFailure?.(m)}catch{}},h=async(m,p,c,g)=>{let b;try{let T=await a.post(p,c,g,{timeoutMs:i});b=T.status;try{T.body?.cancel().catch(()=>{})}catch{}}catch(T){y({channel:m,stage:"post",status:null,error:T});return}(b<200||b>299)&&y({channel:m,stage:"status",status:b,error:null})};return{async sendClientMessage(m){let p,c,g;try{p=`${C()}${u}/LogClientMsg/?nocache=${l.now()}`,c=M(m),g=k(c,r)}catch(b){y({channel:"client-message",stage:"build",status:null,error:b});return}await h("client-message",p,c,{"Content-Type":"text/plain","X-Signature":g})},async countEvent(m,p,c){let g,b;try{g=`${C()}${u}/eventlog`,b=ue(m,t.clientVersion,p,c)}catch(T){y({channel:"event-count",stage:"build",status:null,error:T});return}await h("event-count",g,b,{"Content-Type":"text/plain"})}}}var De=2**31-1;function Ge(e){return Object.assign(new Error(`The request did not finish within ${e} ms.`),{name:"TimeoutError"})}function Mo(e){return typeof e=="number"&&e>0&&e<=De?null:new RangeError(`fetchTransport cannot keep a deadline of ${String(e)} ms: it must be a number of milliseconds above 0 and at most ${De} (about 24.8 days), the longest a timer can wait. Nothing was sent.`)}function Io(e,t={}){if(typeof e!="function")throw new TypeError("fetchTransport needs the host's fetch");let n=e,r=t.credentials??"omit";return{async post(a,l,u,i){let C=i.timeoutMs,y=Mo(C);if(y)throw y;let h=new AbortController,m=!1,p=setTimeout(()=>{m=!0,h.abort(Ge(C))},C),c=()=>h.abort(i.signal?.reason);i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c,{once:!0}));let g=!1,b=()=>{g||(g=!0,clearTimeout(p),i.signal?.removeEventListener("abort",c))},T=_=>m?Ge(C):_,L;try{L=await n(a,{method:"POST",body:l,headers:u,credentials:r,signal:h.signal})}catch(_){throw b(),T(_)}let R=J(L),v=R.statusText!==void 0?{statusText:R.statusText}:{};if(!R.body)return{status:R.status,...v,contentType:R.contentType,body:null,text:async()=>{try{return await R.text()}catch(_){throw T(_)}finally{b()}}};let x=R.body.getReader(),w=new ReadableStream({async pull(_){try{let s=await x.read();if(s.done){b(),_.close();return}_.enqueue(s.value)}catch(s){b(),_.error(T(s))}},cancel(_){return b(),x.cancel(_)}});return{status:R.status,...v,contentType:R.contentType,body:w,text:()=>new Response(w).text()}}}}var Ue=300;function We(e){return String(e??"").toLowerCase().replace(/[^a-z0-9-]/g,"").slice(0,40)}var No="/LLMChart/",Fo="/LLMChart/qualify",ko="/VisionReview/",Do="/LLMChart/sample",Go="/RefundGenerate/",Uo=e=>!!e&&typeof e=="object"&&e.name==="TimeoutError",K=async e=>JSON.parse(await e.text());function Wo(e){try{e.body?e.body.cancel().catch(()=>{}):e.text().catch(()=>{})}catch{}}function Vo(e,t){let n=e;if(!n||!n.signer||typeof n.signer.sign!="function")throw new TypeError("createGenerateClient needs the host's signer");if(!n.transport||typeof n.transport.post!="function")throw new TypeError("createGenerateClient needs the host's transport");if(!n.clock||typeof n.clock.now!="function")throw new TypeError("createGenerateClient needs the host's clock");if(!t||typeof t.baseUrl!="string"&&typeof t.baseUrl!="function")throw new TypeError("createGenerateClient needs the service's base URL");if(typeof t.baseUrl=="string"&&t.baseUrl==="")throw new TypeError("createGenerateClient needs the service's base URL");if(t.apiPath!==void 0&&typeof t.apiPath!="string")throw new TypeError("createGenerateClient's apiPath must be a string");if(t.nocache!==void 0&&t.nocache!==null&&typeof t.nocache!="function")throw new TypeError("createGenerateClient's nocache must be a function");let{signer:r,transport:a,clock:l}=n,u=t.apiPath??"/api",i=()=>typeof t.baseUrl=="function"?t.baseUrl():t.baseUrl,C=m=>t.nocache?t.nocache(m):String(l.now());async function y(m,p,c,g,b){let T=`${i()}${u}${p}?nocache=${C(m)}`,L={"Content-Type":"text/plain","X-Signature":k(c,r)},R=g.signal??void 0,v=(w,_)=>{let s=!!R?.aborted;return{kind:"transport",headersReceived:w,timedOut:!s&&Uo(_),cancelled:s,error:_}},x;try{x=await a.post(T,c,L,R?{timeoutMs:g.timeoutMs,signal:R}:{timeoutMs:g.timeoutMs})}catch(w){return v(!1,w)}if(x.status<200||x.status>299){let w="";if(g.readErrorBody===!1)Wo(x);else try{w=(await x.text()).slice(0,Ue)}catch{}return{kind:"http",status:x.status,statusText:x.statusText??"",bodyStart:w}}try{return{kind:"answer",status:x.status,value:await b(x)}}catch(w){return v(!0,w)}}function h(m,p){if(!p||typeof p.timeoutMs!="number"||!Number.isFinite(p.timeoutMs)||p.timeoutMs<=0)throw new TypeError(`The ${m} call needs a positive deadline in milliseconds`);return p}return{async generate(m,p){let c=h("generate",p),g=c.onStage??void 0;return y("generate",No,M(m),c,b=>Z(b,g))},async qualify(m,p){let c=h("qualify",p),g=c.route??Fo;if(typeof g!="string"||!g.startsWith("/"))throw new TypeError("The qualify route must start with '/'");return y("qualify",g,M(m),c,K)},async review(m,p){let c=h("review",p),g=JSON.stringify(m);if(typeof g!="string")throw new TypeError("The review wire did not serialize to JSON");return y("review",ko,g,c,K)},async sample(m,p){let c=h("sample",p);return y("sample",Do,M(m),c,K)},async refund(m,p,c){let g=h("refund",p);if(typeof m!="string"||m.trim()==="")throw new TypeError("A refund needs the generation's correlation id");let b=We(c),T=b?{CorrelationID:m.trim(),Reason:b}:{CorrelationID:m.trim()};return y("refund",Go,JSON.stringify(T),g,K)}}}export{hn as ADMIN1_MATCH_PCT,Cn as ADMIN1_MATCH_PCT_NAMED,j as CITY_ROLE_MATCH_PCT,Xt as CITY_TIE_RATIO,wo as CLIENT_EVENT_KINDS,Zr as CLIENT_SECRET_MISMATCH,et as COMPOUND_MIN_STEM,Rt as CYCLE_MEMBERS,wt as CYCLE_WORDS,be as DATE_LEVEL_GREGORIAN_YEAR_MAX,Ce as DATE_LEVEL_GREGORIAN_YEAR_MIN,Mr as DATE_LEVEL_LANGUAGES,ae as DATE_LEVEL_NAMES,he as DATE_LEVEL_NON_GREGORIAN_LANGUAGES,er as DEFAULT_GAP_FACTOR,dt as DEFAULT_TEMPERATURE,_o as DRAW_REASONS,Jr as FREEMIUM_ATTEMPT_SPENT,eo as FREEMIUM_COLUMN_CAP,kr as GENERATION_COLUMNS_MAX_CHARS,ut as GET_RANDOM,nt as GLUED_STEM_MIN,ot as HANGUL_MIN_STEM,Re as HOST_SYNTHETIC_COLUMNS,Ue as HTTP_BODY_START_CHARS,jn as IDENTIFIER_HEAD_INITIAL,Qn as IDENTIFIER_UNFOLDED,Bn as IDENTIFIER_WORDS,Mn as INTENSIVE_SUFFIX_TOKENS,Pn as INTENSIVE_WORD_TOKENS,Cr as IndexedText,On as LATITUDE_WORDS,Ln as LONGITUDE_WORDS,kt as LOOSE_KEY_MIN_LENGTH,Gt as LooseIndex,tr as MAX_RUN_BOUNDS,br as NOT_AVAILABLE,no as OAUTH_SIGNED_OUT,to as OAUTH_TOKEN_EXPIRED,vt as PERIOD_CODE_FORMS,Lt as PERIOD_CODE_MEMBERS,Pt as PERIOD_ORDINALS,Mt as PERIOD_UNFOLDED,Nn as POSITIONAL_SUFFIX_TOKENS,In as POSITIONAL_WORD_TOKENS,xr as PREVIEW_OMITTED_FIELDS,Pe as PROGRESS_STAGE_IDS,Le as QUALIFY_KINDS,po as QUALIFY_ORDER_LABELS,qt as REGION_FRAME_WINDOWS,P as ROLE_MATCH_PCT,or as SERIES_COMPLETENESS_MAX_LISTED,ir as SERIES_COMPLETENESS_MIN_FILL,sr as SERIES_KEY_MAX_DISTINCT,To as SEV_ERROR,bo as SEV_INFO,So as SEV_USER_PRESENTED,Eo as SEV_WARNING,B as SIMPLE_STRING_HASH,lt as STR,st as SUBSTRING_MIN,qe as SUPPORTED_LANGUAGES,He as SUPPORTED_LANGUAGE_CODES,xo as TELEMETRY_TIMEOUT_DEV_MS,Ro as TELEMETRY_TIMEOUT_MS,$e as VOCABULARY_LANGUAGE_CODES,ze as VOCABULARY_ONLY_LANGUAGES,xt as YEAR_WORDS,Zt as admin1CodesForName,Q as admin1LookupRegistered,q as admin1MatchPct,Hn as allowedAggregations,Tt as anchorLocalWallClockDates,ro as answerIsRetryable,yn as buildGeoIsoColumn,cn as buildGeoPointColumns,En as buildProvinceIsoColumn,_t as calendarWordIn,uo as capabilityFields,fn as cityMatchPct,dn as cityTagsFor,gr as classifyAdditivity,Oo as classifyDraw,qn as classifyForAggregation,yr as classifyNumericValueNature,mr as classifyTemporal,Qt as clearAdmin1LookupForTests,Gn as codeNeedsLegacyAggNames,Xn as codeReadsColumn,Jn as codeReadsColumnsByRoleOrPosition,Dn as collapseRepeatedAggPrefix,Wr as columnsNeverGeneratedOn,Zn as columnsTheCodeReads,vn as coordinateAxisOfWords,Yt as countryIso2,zt as countryRegion,Lo as createDrawLedger,Vo as createGenerateClient,Po as createTelemetryClient,oo as credentialFields,mo as dataCompletenessFields,Nr as dateLevelPart,Fr as dateLevelYearAdmits,St as datesAreTimeOfDayOnly,bt as datesCarryTimeOfDay,Rn as decimalSeparatorOf,Kn as defaultAggregation,xn as detectDecimalSeparator,Sn as detectFormatSignature,mn as detectGeo,Vt as detectOrdinalDomain,fr as detectTextDatePattern,Ao as drawLocation,M as encodePayload,Tr as engineTypeForSqlType,Un as englishImplicitAggNames,ue as eventLogLine,ao as fetchFields,Io as fetchTransport,je as foldName,zr as freemiumColumnCapRefusal,xe as freemiumColumnsOverCap,we as freemiumDateHierarchyClauses,Ur as generationColumnsAnswerInLocale,rt as gluedPrefixStems,Kr as guardColumnNames,_r as gzipWireText,it as hangulWordEndsWith,kn as hasDefaultAggPrefix,Je as hasUnsegmentedScript,pr as hostAggHint,Bt as inMiddleEast,Rr as ingest,zn as isAggregationAllowed,G as isBlankLike,rn as isCityTableLoaded,H as isColumnContextRef,ct as isDeterministicRefusal,vo as isEventLogCode,ln as isGeoPointAmbiguity,dr as isIdentifierName,gn as isJoinGeoKind,tn as isKnownProvinceId,Or as isNdjsonContentType,Ut as isOrdinalFriendlyName,Er as isSpreadsheetErrorText,Dt as isUsableLooseKey,Ar as keyedSigner,fo as leafCardinalityField,yt as localMidnightDateColumns,gt as localMidnightToUtcDay,Et as localWallClockDateColumns,Ot as localizedCycleIn,Yn as localizedIdentifierWordIn,At as localizedYearWordIn,N as looksLikeCountryColumn,Ft as looseNameKey,at as matchNameToken,so as maxNonMeasureCardinality,Tn as measureAdmin1Columns,rr as measureCadence,cr as measurePersistence,ur as measureSeriesCompleteness,k as messageSignature,Hr as missingHardColumnRefs,An as monthLookupFor,Ye as nameLetterRuns,Vn as nameLooksIntensiveRate,Wn as nameLooksPositional,Te as nameProbeIsGuarded,qr as nameProbeKeepsDrawing,Qe as nameWords,on as normalizeCountry,ht as normalizeLocalMidnightDates,_n as normalizeMonthKey,U as normalizePlaceName,an as normalizeZip5,yo as offeredShortlistFor,Sr as parseCsvRows,ft as parseDateStable,jr as parseGenerateResponse,Gr as parseGenerationColumns,wn as parseNumberText,Qr as parseQualifyResponse,Yr as parseReviewVerdict,nr as parseTemporalPoint,wr as payloadPreview,Nt as periodCodeSeries,lr as pickSeriesColumn,Xr as progressStageOf,hr as promotesToMeasure,en as provinceIdForAdmin1Code,bn as provinceIdForRow,ve as qualifyKindOf,go as qualifyOrderField,Ie as qualifyOrderOf,Z as readGenerateStream,Xe as readName,It as readPeriodCode,E as readWireField,We as refundReasonCode,jt as registerAdmin1Lookup,nn as registerCityTable,Kt as registerIso3Regions,I as resolveAdmin1,Jt as resolveCityAdmin1,Me as resolveFetchVersion,un as resolveGeoPoint,Be as resolveLanguage,Pr as resolvePointRoles,co as retryFields,Wt as safeDistinctValuesToShip,ke as schemaIdentity,Co as schemaIdentityKey,Fe as schemaTypeFamily,Dr as serializeGenerationColumns,ar as seriesKeyVerdict,$n as shareOfTotalIsHonest,Ne as shortlistIsStale,Fn as stripHostAggPrefix,$t as summarizeCountryRegions,Ht as summarizeGeoExtent,Ke as supportedLanguage,pn as toGeoIso,Ze as unsegmentedRuns,Ct as utcWallClock,io as viewportFields,$ as vocabularyLanguage,mt as wholeDayFrame,pt as wholeDayIso,J as wireResponseFromFetch,tt as wordEndsWith,ie as zipMatchPct,V as zipPrefixCandidates,sn as zipToPrefix3};
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,c}from"./chunk-WNUCHG24.mjs";import"./chunk-J5EZ7BH7.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
2
+ import{c as a,d as b,e as c}from"./chunk-O6HX7LOP.mjs";import"./chunk-J5EZ7BH7.mjs";import"./chunk-U3H6UBOO.mjs";import"./chunk-TZ74QIKA.mjs";import"./chunk-YDYFP2T4.mjs";import"./chunk-DTBXJVUG.mjs";import"./chunk-5MRZID36.mjs";import"./chunk-3ZAS32F5.mjs";import"./chunk-5HI6TVMM.mjs";import"./chunk-CZJ7M6A5.mjs";import"./chunk-WC4JINEZ.mjs";export{a as engineTypeForSqlType,c as ingest,b as parseCsvRows};
@@ -44,6 +44,7 @@ export { PERIOD_CODE_FORMS, PERIOD_ORDINALS, PERIOD_UNFOLDED, PERIOD_CODE_MEMBER
44
44
  export type { PeriodCodeGrain, PeriodCodeForms, PeriodCodeReading, PeriodCodeSeries } from "./vocab/periodCodes";
45
45
  export { IDENTIFIER_WORDS, IDENTIFIER_HEAD_INITIAL, IDENTIFIER_UNFOLDED, localizedIdentifierWordIn, } from "./vocab/identifierWords";
46
46
  export type { IdentifierWordHit } from "./vocab/identifierWords";
47
+ export { NOT_AVAILABLE, isSpreadsheetErrorText } from "./vocab/spreadsheetErrors";
47
48
  export { foldName, readName, matchNameToken, wordEndsWith, gluedPrefixStems, unsegmentedRuns, hasUnsegmentedScript, hangulWordEndsWith, nameLetterRuns, COMPOUND_MIN_STEM, GLUED_STEM_MIN, SUBSTRING_MIN, HANGUL_MIN_STEM, } from "./nameReader";
48
49
  export type { NameReading, NameTokenView } from "./nameReader";
49
50
  export { detectDecimalSeparator, decimalSeparatorOf, parseNumberText } from "./numberText";
@@ -0,0 +1,4 @@
1
+ /** "No value available" (`#N/A`), as each language's Excel writes it. Matched whole, case-insensitively. */
2
+ export declare const NOT_AVAILABLE: readonly string[];
3
+ /** True when a cell's whole text is a spreadsheet formula error, in any language (see the header). */
4
+ export declare function isSpreadsheetErrorText(v: unknown): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bicharts/shape-core",
3
- "version": "0.6.121",
3
+ "version": "0.6.124",
4
4
  "description": "Host-agnostic data-shape profiler: ingest a dataset's rows through IValueCollection.addRow and read back the measured shape as an LLMColumnWithValue[] payload — types, cardinality, temporal/ordinal detection, geographic region and point resolution, cross-column signals. MEASUREMENT only: the policy that decides what a measured shape means for chart selection lives server-side.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- /*! @bicharts/shape-core — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; US Census/TIGER (public domain). Full text: NOTICE in this package. */
2
- import{R as I,Z as A,f as R}from"./chunk-J5EZ7BH7.mjs";import{a as h,c as x,d as E,e as L}from"./chunk-TZ74QIKA.mjs";import{u as C}from"./chunk-CZJ7M6A5.mjs";import M from"papaparse";var k=500,P=/^[+-]?\d{1,15}$/,v=/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,N=/^\d{1,2}[\/\-.]\d{1,2}[\/\-.]\d{2,4}$/;function O(e,o=".",n=!1){if(n)return"DateTime";let r=0,s=0,i=0,l=0;for(let c of e){if(c==null)continue;if(typeof c=="number"){l++,s++,Number.isInteger(c)&&r++;continue}if(c instanceof Date){l++,i++;continue}if(typeof c=="boolean"){l++;continue}let m=String(c).trim();if(m!==""){if(l++,P.test(h(m))){r++,s++;continue}if(L(m,o)){s++;continue}if((v.test(m)||N.test(m))&&!isNaN(Date.parse(m))){i++;continue}}}return l===0?"String":i===l?"DateTime":r===l?"Integer":s===l?"Decimal":"String"}function _(e,o,n=".",r=null){if(e==null)return null;if(typeof e=="number")return o==="String"?String(e):e;if(e instanceof Date)return o==="DateTime"?e:e.toISOString();if(typeof e=="boolean")return String(e);let s=String(e).trim();if(s==="")return null;switch(o){case"Integer":{let i=h(s);return P.test(i)?parseInt(i,10):null}case"Decimal":return E(s,n);case"DateTime":return r?r.read(s):C(s);default:return s}}function $(e){let o=(e||"").toLowerCase().replace(/\(.*$/,"").trim();return/^(tinyint|smallint|int|integer|int2|int4|int8|bigint|serial|bigserial)$/.test(o)?"Integer":/^(decimal|numeric|money|smallmoney|float|real|double|double precision|number)$/.test(o)?"Decimal":/^(date|datetime|datetime2|smalldatetime|datetimeoffset|timestamp|timestamptz|time)$/.test(o)?"DateTime":(/^(bit|bool|boolean)$/.test(o),"String")}function*q(e,o){for(let n of e)yield n?.[o]}function g(e,o,n){if(e.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=e.length,s=e.map((t,a)=>o.slice(0,k).map(u=>u?.[a])),i=s.map(t=>x(t,n.locale)),l=e.map((t,a)=>t.dataType===void 0||t.dataType==="DateTime"?R(q(o,a),{locale:n.locale??"en"}):null),c=e.map((t,a)=>t.dataType??O(s[a],i[a],l[a]!==null)),m=new Set((n.measures??[]).map(t=>t.toLowerCase())),b=new Set((n.dimensions??[]).map(t=>t.toLowerCase())),j=new Set((n.nonAdditive??[]).map(t=>t.toLowerCase())),D=e.map((t,a)=>{let u=t.name.toLowerCase(),f=t.isMeasure??((c[a]==="Integer"||c[a]==="Decimal")&&!I(t.name));m.has(u)&&(f=!0),b.has(u)&&(f=!1);let T={name:t.name,dataType:c[a],isMeasure:f};return f&&j.has(u)&&(T.discourageAggregationAcrossGroups=!0),T}),d=new A;d.dedupRows=n.dedup!==!1,d.deriveProvinces=n.deriveProvinces!==!1,d.setColumns(D),d.declareDimensions(D.filter((t,a)=>b.has(e[a].name.toLowerCase())));for(let t=0;t<o.length;t++){let a=o[t];d.addRow(Array.from({length:r},(u,f)=>_(a?.[f],c[f],i[f],l[f])),t)}let p=d.getColumnsWithStats(n.privacyLevel??"20",n.locale??"en"),S=new Map(p.map(t=>[t.name,t]));e.forEach(t=>{let a=S.get(t.name);a&&(t.format&&(a.modelFormat=t.format),t.description&&(a.modelDesc=t.description))});let y=t=>{let a=S.get(t);if(a)return[a];let u=t.toLowerCase();return p.filter(f=>f.name.toLowerCase()===u)};for(let[t,a]of Object.entries(n.formats??{}))for(let u of y(t))u.modelFormat=a;for(let[t,a]of Object.entries(n.descriptions??{}))for(let u of y(t))u.modelDesc=a;for(let t of n.groupBy??[])for(let a of y(t))a.isGrouping=!0;return{columns:p,rows:d.toObjectArray(),totalRows:d.getRowCount(),index:d}}function w(e,o){return e.map(n=>Array.isArray(n)?n:o.map(r=>n[r]))}function F(e,o){let n=[],r=new Set,s=Math.min(e.length,Math.max(1,o));for(let i=0;i<s;i++){let l=e[i];if(!(!l||typeof l!="object"))for(let c of Object.keys(l))r.has(c)||(r.add(c),n.push(c))}return n}function V(e){let o=String(e??"").replace(/^\uFEFF/,""),n=[],r=[],s=0;return M.parse(o,{skipEmptyLines:!1,step:i=>{let l=i.meta.cursor,c=o.slice(s,l);s=l,i.errors?.length&&r.push(...i.errors);let m=i.data;m.length===1&&m[0]===""&&c.replace(/[\r\n]/g,"")===""||n.push(m)}}),!n.length&&!r.length&&r.push(...M.parse(o,{skipEmptyLines:!0}).errors),{rows:n,errors:r}}function Y(e,o={}){switch(e.kind){case"csv":{let n=V(e.text);if(n.errors.length&&n.rows.length===0)throw new Error(`ingest: CSV parse failed - ${n.errors[0].message}`);let r=n.rows;if(r.length<2)throw new Error("ingest: CSV needs a header line plus at least one data row.");let s=r[0].map(i=>(i??"").trim());return g(s.map(i=>({name:i})),r.slice(1),o)}case"grid":{if(!e.header?.length)throw new Error("ingest: 'grid' needs a non-empty header.");return g(e.header.map(n=>({name:(n??"").trim()})),e.rows??[],o)}case"table":{if(!e.columns?.length)throw new Error("ingest: 'table' needs at least one column descriptor.");let n=e.columns.map(r=>r.name);return g(e.columns,w(e.rows??[],n),o)}case"objects":{let n=e.rows??[],r=e.columns?.length?e.columns:F(n,o.columnScanLimit??k).map(s=>({name:s}));if(!r.length)throw new Error("ingest: 'objects' produced no columns - the rows array is empty or holds no object keys.");return g(r,w(n,r.map(s=>s.name)),o)}case"sql":{if(!e.schema?.length)throw new Error("ingest: 'sql' needs at least one schema column.");let n=e.schema.map(r=>{let s=$(r.dataType);return{name:r.name,dataType:s,isMeasure:r.isMeasure,format:r.format,description:r.description}});return g(n,w(e.rows??[],n.map(r=>r.name)),o)}default:{let n=e;throw new Error(`ingest: unknown source kind '${n?.kind}'. Expected one of: csv, grid, table, objects, sql.`)}}}export{$ as a,V as b,Y as c};