df-script 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -9
- package/dist/api.d.ts +3 -2
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +14 -7
- package/dist/columnExpressions/ExprBase.d.ts +26 -12
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +31 -2
- package/dist/columnExpressions/functions/element.d.ts +26 -1
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +38 -8
- package/dist/columnExpressions/index.d.ts +2 -1
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +336 -2
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +620 -10
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +567 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +658 -5
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +2 -0
- package/dist/constants.d.ts +11 -0
- package/dist/dataframe/dataframe.d.ts +933 -3
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +1 -0
- package/dist/dataframe/utils.d.ts +1 -0
- package/dist/datatypes/index.d.ts +3 -2
- package/dist/datatypes/types.d.ts +52 -7
- package/dist/exceptions/index.d.ts +23 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +51 -16
- package/dist/utils/{list.d.ts → array.d.ts} +68 -15
- package/dist/utils/binary.d.ts +3 -0
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +23 -54
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +15 -29
- package/dist/utils/object.d.ts +27 -0
- package/dist/utils/string.d.ts +15 -5
- package/package.json +18 -4
- package/dist/api.js +0 -26
- package/dist/bundle.min.js +0 -1
- package/dist/columnExpressions/ColumnExpr.js +0 -219
- package/dist/columnExpressions/ExprBase.js +0 -92
- package/dist/columnExpressions/constants.js +0 -7
- package/dist/columnExpressions/functions/all.js +0 -11
- package/dist/columnExpressions/functions/coalesce.js +0 -44
- package/dist/columnExpressions/functions/element.js +0 -11
- package/dist/columnExpressions/functions/exclude.js +0 -13
- package/dist/columnExpressions/functions/implode.js +0 -7
- package/dist/columnExpressions/functions/lit.js +0 -17
- package/dist/columnExpressions/functions/repeat.d.ts +0 -47
- package/dist/columnExpressions/functions/repeat.js +0 -131
- package/dist/columnExpressions/functions/seq_range.js +0 -91
- package/dist/columnExpressions/functions/when.js +0 -85
- package/dist/columnExpressions/index.js +0 -38
- package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
- package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
- package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
- package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/columnExpressions/mixins/ListExpr.js +0 -224
- package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
- package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
- package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
- package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
- package/dist/columnExpressions/mixins/StringExpr.js +0 -237
- package/dist/columnExpressions/mixins/StructExpr.js +0 -139
- package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
- package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
- package/dist/columnExpressions/types.js +0 -2
- package/dist/columnExpressions/utils.js +0 -45
- package/dist/dataframe/constants.js +0 -7
- package/dist/dataframe/dataframe.js +0 -990
- package/dist/dataframe/grouped/grouped.js +0 -114
- package/dist/dataframe/index.js +0 -20
- package/dist/dataframe/types.js +0 -2
- package/dist/dataframe/utils.js +0 -307
- package/dist/datatypes/DataType.js +0 -76
- package/dist/datatypes/index.js +0 -46
- package/dist/datatypes/types/Binary.d.ts +0 -9
- package/dist/datatypes/types/Binary.js +0 -18
- package/dist/datatypes/types/Boolean.d.ts +0 -9
- package/dist/datatypes/types/Boolean.js +0 -19
- package/dist/datatypes/types/Date.d.ts +0 -8
- package/dist/datatypes/types/Date.js +0 -21
- package/dist/datatypes/types/Datetime.d.ts +0 -8
- package/dist/datatypes/types/Datetime.js +0 -17
- package/dist/datatypes/types/Decimal.d.ts +0 -10
- package/dist/datatypes/types/Decimal.js +0 -28
- package/dist/datatypes/types/Duration.d.ts +0 -8
- package/dist/datatypes/types/Duration.js +0 -17
- package/dist/datatypes/types/Float32.d.ts +0 -8
- package/dist/datatypes/types/Float32.js +0 -17
- package/dist/datatypes/types/Float64.d.ts +0 -8
- package/dist/datatypes/types/Float64.js +0 -17
- package/dist/datatypes/types/Int16.d.ts +0 -8
- package/dist/datatypes/types/Int16.js +0 -17
- package/dist/datatypes/types/Int32.d.ts +0 -8
- package/dist/datatypes/types/Int32.js +0 -17
- package/dist/datatypes/types/Int64.d.ts +0 -8
- package/dist/datatypes/types/Int64.js +0 -17
- package/dist/datatypes/types/Int8.d.ts +0 -8
- package/dist/datatypes/types/Int8.js +0 -17
- package/dist/datatypes/types/List.d.ts +0 -10
- package/dist/datatypes/types/List.js +0 -31
- package/dist/datatypes/types/Null.d.ts +0 -9
- package/dist/datatypes/types/Null.js +0 -17
- package/dist/datatypes/types/Object.d.ts +0 -9
- package/dist/datatypes/types/Object.js +0 -17
- package/dist/datatypes/types/Struct.d.ts +0 -14
- package/dist/datatypes/types/Struct.js +0 -39
- package/dist/datatypes/types/Time.d.ts +0 -8
- package/dist/datatypes/types/Time.js +0 -29
- package/dist/datatypes/types/UInt16.d.ts +0 -8
- package/dist/datatypes/types/UInt16.js +0 -17
- package/dist/datatypes/types/UInt32.d.ts +0 -8
- package/dist/datatypes/types/UInt32.js +0 -17
- package/dist/datatypes/types/UInt64.d.ts +0 -8
- package/dist/datatypes/types/UInt64.js +0 -17
- package/dist/datatypes/types/UInt8.d.ts +0 -8
- package/dist/datatypes/types/UInt8.js +0 -17
- package/dist/datatypes/types/Utf8.d.ts +0 -10
- package/dist/datatypes/types/Utf8.js +0 -20
- package/dist/datatypes/types.js +0 -290
- package/dist/exceptions/index.js +0 -46
- package/dist/exceptions/utils.js +0 -28
- package/dist/functions/concat.js +0 -260
- package/dist/functions/index.js +0 -9
- package/dist/functions/read_csv.js +0 -53
- package/dist/functions/read_json.js +0 -21
- package/dist/functions/transpose.d.ts +0 -7
- package/dist/functions/transpose.js +0 -84
- package/dist/types.js +0 -2
- package/dist/utils/boolean.d.ts +0 -1
- package/dist/utils/boolean.js +0 -18
- package/dist/utils/csv.js +0 -313
- package/dist/utils/date.js +0 -348
- package/dist/utils/guards.d.ts +0 -12
- package/dist/utils/guards.js +0 -112
- package/dist/utils/index.js +0 -23
- package/dist/utils/json.js +0 -217
- package/dist/utils/list.js +0 -361
- package/dist/utils/number.js +0 -401
- package/dist/utils/string.js +0 -209
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var an=Object.defineProperty;var jr=Object.getOwnPropertyDescriptor;var Vr=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var er=(r,e)=>{for(var t in e)an(r,t,{get:e[t],enumerable:!0})},$r=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vr(e))!Br.call(r,o)&&o!==t&&an(r,o,{get:()=>e[o],enumerable:!(n=jr(e,o))||n.enumerable});return r};var tr=r=>$r(an({},"__esModule",{value:!0}),r);var q,ln,un,Pe,oe=O(()=>{"use strict";q="*",ln="*literal*",un="*coalesce*",Pe="*element*"});function Ee(r,e=null,{mode:t="both",returnStringOnNull:n=!1,maxScanStart:o=1,maxScanEnd:s=1,maxMatchesStart:i=1,maxMatchesEnd:a=1,trimFirst:u=!1,stringOptions:{literal:c=!1,caseInsensitive:l=!1}={}}={}){if(r==null)return n?"":null;let f=(w,D="both")=>D==="start"?w.trimStart():D==="end"?w.trimEnd():w.trim(),m=r;if(u&&e!=null&&(m=f(r,t)),e==null){let w=f(m,t);return n||w!==""?w:null}let p=e instanceof RegExp?w=>e.test(w):(()=>{let w=new Set(l?e.toLowerCase():e);return D=>w.has(l?D.toLowerCase():D)})(),h=m.length,y=new Uint8Array(h),S=c&&typeof e=="string"?({isStart:w,limit:D,maxMatches:k})=>{if(h===0||k===0)return;let W=e.length;if(W===0)return;let ce=l?m.toLowerCase():m,fe=l?e.toLowerCase():e,A=w?0:h-1,E=0,v=0;for(;A>=0&&A<h&&!(k!==null&&k>=0&&E>=k);){let M=w?A:A-W+1;if(!w&&M<0)break;let Y=w?ce.indexOf(fe,M):ce.lastIndexOf(fe,M);if(Y===-1)break;let ne=w?Y-A:A-(Y+W-1);if(v+=ne,D!==null&&D>=0&&v>=D)break;for(let Z=0;Z<W;Z++)y[Y+Z]=1;E++,A=w?Y+W:Y-1}}:({isStart:w,limit:D,maxMatches:k})=>{if(h===0||k===0)return;let W=w?0:h-1,ce=w?h:-1,fe=w?1:-1,A=!1,E=0,v=0;for(let M=W;M!==ce;M+=fe)if(p(m[M])){if(!A){if(D!==null&&D>=0&&v>=D||k!==null&&k>=0&&E>=k)break;A=!0,E++}y[M]=1}else A=!1,v++};(t==="both"||t==="start")&&S({isStart:!0,limit:o,maxMatches:i}),(t==="both"||t==="end")&&S({isStart:!1,limit:s,maxMatches:a});let _="";for(let w=0;w<h;w++)y[w]===0&&(_+=m[w]);return n||_!==""?_:null}function nr(r){return typeof r=="string"?r.trim().length===0:r instanceof String?r.valueOf().trim().length===0:!1}function $(r,{depth:e=0,maxDepth:t=50}={}){if(e>t)return"v:circular";if(r===null)return"v:null";if(r===void 0)return"v:undefined";if(r instanceof Date)return P(r)?`d:${r.getTime()}`:"d:invalid";if(L(r))return`u:${r.constructor.name}:${r.toString()}`;if(Array.isArray(r)){let n=r.length,o=new Array(n),s={depth:e+1,maxDepth:t};for(let i=0;i<n;i++)o[i]=$(r[i],s);return`a:[${o.join(",")}]`}if(r instanceof Set){let n=Array.from(r),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++)s[a]=$(n[a],i);return s.sort(),`set:[${s.join(",")}]`}if(r instanceof Map){let n=Array.from(r.keys()),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=n[a];s[a]=`${$(u,i)}:${$(r.get(u),i)}`}return s.sort(),`map:{${s.join(",")}}`}if(typeof r=="object"&&typeof r.toJSON=="function")return`j:${$(r.toJSON(),{depth:e+1,maxDepth:t})}`;if(_e(r)){let n=Object.keys(r).sort(),o=n.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=n[a];s[a]=`${u}:${$(r[u],i)}`}return`o:{${s.join(",")}}`}return r instanceof RegExp?`r:${r.toString()}`:typeof r=="function"?`f:${r.toString()}`:typeof r=="string"?`s:${r}`:typeof r=="symbol"?`y:${r.toString()}`:`${typeof r}:${r}`}var ht=O(()=>{"use strict";Oe();we()});function We(r){return r==null?[]:Array.isArray(r)?[...r]:L(r)?Array.from(r):[r]}function Re(r){let e=We(r),t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=String(e[o]);return n}function K(r,e,{mode:t="every",allowNulls:n=!1,allowEmpty:o=!0}={}){if(!T(r))return!1;let s=r.length;if(s===0)return o?t==="every":!1;let i=r,a;if(typeof e=="function")a=ir(e)?c=>c instanceof e:e;else switch(e){case"null":a=u=>u===null;break;case"undefined":a=u=>u===void 0;break;case"nullish":a=u=>u==null;break;case"any":a=()=>!0;break;case"date":a=P;break;case"object":a=G;break;case"plainObject":a=_e;break;case"number":a=te;break;default:a=u=>typeof u===e;break}if(n){let u=a;a=c=>c==null||u(c)}if(t==="every"){for(let u=0;u<s;u++)if(!a(i[u]))return!1;return!0}else{for(let u=0;u<s;u++)if(a(i[u]))return!0;return!1}}function yt(r,e=!1){if(!T(r))return[];let t=Array.from(r);return t.sort((n,o)=>n==null&&o==null?0:n==null?1:o==null?-1:n<o?e?1:-1:n>o?e?-1:1:0),t}function B(r){if(!T(r))return{...rr};let e=r.length;if(e===0)return{...rr};let t=null,n=null,o=0,s=0,i=0,a=0,u=0,c=0;for(let f=0;f<e;f++){let m=r[f];if(m==null){s++;continue}(t==null||m<t)&&(t=m),(n==null||m>n)&&(n=m);let p=X(m);if(p!==null){let h=i+p;Math.abs(i)>=Math.abs(p)?a+=i-h+p:a+=p-h+i,i=h,o++;let y=p-u;u+=y/o;let d=p-u;c+=y*d}}let l=o>1?c/(o-1):0;return{sum:o>0?i+a:null,count:o,min:t,max:n,mean:o>0?(i+a)/o:null,variance:l,std:Math.sqrt(l),nullCount:s,len:e,hasNulls:s>0,isNumeric:o>0&&o===e-s}}function Se(r,{strict:e=!1,keySelector:t}={}){let n=Array.from(r),o=new Map;if(e){let i=t??$,a=new Map,u=n.length;for(let l=0;l<u;l++){let f=n[l],m=i(f),p=a.get(m);p===void 0?a.set(m,{val:f,count:1}):p.count++}let c=[];for(let l of a.values())c.push(l.val);for(let l=0;l<u;l++){let f=n[l],m=i(f),p=a.get(m);o.set(f,p.count)}return{values:c,count:c.length,frequencies:o}}let s=n.length;for(let i=0;i<s;i++){let a=n[i];o.set(a,(o.get(a)??0)+1)}return{values:Array.from(o.keys()),count:o.size,frequencies:o}}function or(r,{step:e=1,offsetStart:t=0,offsetEnd:n,maxItemsGathered:o,null_on_oob:s=!0}={}){if(r==null)return null;if(o!==void 0&&o<=0)return[];if(e===0)throw new Error("Step size step cannot be zero");let i=r.length;if(i===0?t!==0:t>=i||t<-i){if(!s)throw new Error(`Start offset ${t} is out of bounds for list of length ${i}`);return null}let u=t<0?i+t:t,c=n!==void 0?n<0?i+n:n:e>0?i:-1,l=[];if(e>0)for(let f=u;f<c&&f<i&&!(f>=0&&(l.push(r[f]),o!==void 0&&l.length>=o));f+=e);else for(let f=u;f>c&&f>=0&&!(f<i&&(l.push(r[f]),o!==void 0&&l.length>=o));f+=e);return l}function sr(r,e=",",{ignoreNulls:t=!1,nullValue:n="",prefix:o="",suffix:s="",limit:i,truncationMarker:a="...",valueFormatter:u}={}){let c=r.length,l=[],f=i!==void 0?Math.max(0,i):c,m=!1;for(let p=0;p<c;p++){if(l.length>=f){m=!0;break}let h=r[p];h!=null?l.push(u?u(h,p):String(h)):t||l.push(n)}return o+l.join(e)+(m?a:"")+s}function De(r,e,t={}){let n=r.length,{mode:o="cumulative",step:s=1,coerce:i=y=>y,condition:a,reverse:u=!1,startIndex:c=u?n-1:0,endIndex:l=u?-1:n}=t,f=u?-1:1,m=c,p=l,h=(y,d)=>{(!a||a(r[y],y,r))&&(r[y]=i(d))};if(o==="constant"){let y=i(e);for(let d=m;u?d>p:d<p;d+=f)h(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;u?d>p:d<p;d+=f)h(d,s({index:y,initialValue:e,originalValue:r[d],absoluteIndex:d,targetArray:r})),y++}else for(let y=m;u?y>p:y<p;y+=f)h(y,e+y*s);else{let y=e,d=!0,g=0;for(let b=m;u?b>p:b<p;b+=f)d?(h(b,y),d=!1):(typeof s=="function"?y=s({prev:y,index:g,originalValue:r[b],absoluteIndex:b,targetArray:r}):y=y+s,h(b,y)),g++}}var rr,cn=O(()=>{"use strict";Oe();we();Fe();ht();rr={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function te(r,e){return typeof r!="number"?!1:e&&e.allowNonFiniteNumbers?!0:!Number.isNaN(r)&&Number.isFinite(r)}function X(r,e){if(r==null||typeof r=="symbol")return null;if(te(r,e))return r;if(typeof r=="boolean")return r?1:0;if(typeof r=="bigint"){let t=Number(r);return te(t,e)?t:null}if(r instanceof Date){let t=r.getTime();return te(t,e)?t:null}if(typeof r=="string"){let t=r.trim().replace(ar,"");if(t==="")return null;let n=Number(t);return Number.isNaN(n)?e?.allowNonFiniteNumbers&&t.toLowerCase()==="nan"?NaN:null:te(n,e)?n:null}return null}function lr({locale:r="en-US",accountingNegatives:e=!1,fallback:t="NaN",...n}={}){n.useGrouping===void 0&&(n.useGrouping=!1),n.maximumFractionDigits===void 0&&n.maximumSignificantDigits===void 0&&(n.maximumFractionDigits=20);let o=new Intl.NumberFormat(r,n);return s=>{if(typeof s=="bigint")return e&&s<0n?`(${o.format(-s)})`:o.format(s);let i=X(s,{allowNonFiniteNumbers:!0});return i===null||Number.isNaN(i)?t:Number.isFinite(i)?e&&i<0?`(${o.format(Math.abs(i))})`:o.format(i):e&&i===-1/0?"(Infinity)":String(i)}}function fn(r,{floatPrecision:e="Float64",allowNonFiniteNumbers:t=!0,floatScientific:n=!1}={}){let o=X(r,{allowNonFiniteNumbers:t});if(o===null&&n&&typeof r=="string"){let s=parseFloat(r);te(s,{allowNonFiniteNumbers:t})&&(o=s)}return o===null||(e==="Float32"&&(o=Math.fround(o)),!t&&!Number.isFinite(o))?null:o}function cr(r,e){if(!te(r)||!Number.isInteger(r))return!1;if(!e)return!0;let t=typeof e=="string"?ur[e]:e;return r>=t.min&&r<=t.max}function le(r,{range:e="Int32",coerce:t="truncate"}={}){let n=X(r);if(n===null)return null;let o=n;switch(t){case"round":o=Math.round(o);break;case"floor":o=Math.floor(o);break;case"ceil":o=Math.ceil(o);break;case"truncate":o=Math.trunc(o);break}let s=typeof e=="string"?ur[e]:e;return se(o,{min:s.min,max:s.max})}function Ne(r,{range:e="Int64",truncate:t=!1}={}){if(r==null||typeof r=="symbol")return null;let n=null;if(typeof r=="bigint")n=r;else if(typeof r=="boolean")n=r?1n:0n;else if(typeof r=="string"){let s=r.trim().replace(ar,"");if(s==="")return null;if(Kr.test(s)){if(!t&&s.includes("."))return null;let i=s.indexOf(".");n=BigInt(i!==-1?s.slice(0,i):s)}else{let i=X(s);if(i===null||!t&&!Number.isInteger(i))return null;n=BigInt(Math.trunc(i))}}else{let s=X(r);if(s===null||!t&&!Number.isInteger(s))return null;n=BigInt(Math.trunc(s))}let o=typeof e=="string"?qr[e]:e;return se(n,{min:o.min,max:o.max})}function Pr(r,e){let t=r-e,n=Math.pow(10,t)-Math.pow(10,-e);return n>0?n:null}function Wr(r,e){let t=r.toString();if(t.includes("e")){let n=Math.pow(10,e);return Math.round(r*n)/n}return+(Math.round(+(t+"e"+e))+"e-"+e)}function dt(r,{precision:e,scale:t}={}){let n=X(r);if(n===null)return null;let o=n;if(t!==void 0&&(o=Wr(o,t)),e!==void 0){let i=Pr(e,t??0);i!==null&&(o=se(o,{min:-i,max:i}))}return o}function se(r,{min:e=null,max:t=null,safe:n=!0}={}){if(e!==null&&t!==null&&e>t)return e;let o=r;return n&&typeof o=="number"&&(Number.isNaN(o)?o=e!==null?e:t!==null?t:r:o===1/0?o=t!==null?t:r:o===-1/0&&(o=e!==null?e:r)),e!==null&&o<e?e:t!==null&&o>t?t:o}function fr(r){let e=r|0;return function(){let t=e=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function mr(r){let e=r.length,t=0,n=new Float64Array(e);for(let s=0;s<e;s++){let i=r[s];typeof i=="number"&&!Number.isNaN(i)&&(n[t++]=i)}if(t===0)return null;let o=n.subarray(0,t);return o.sort(),o}function ve(r){let e=mr(r);if(!e)return null;let t=e.length,n=Math.floor(t/2);return t%2!==0?e[n]:(e[n-1]+e[n])/2}function gt(r,e){if(e<0||e>1)return null;let t=mr(r);if(!t)return null;let n=t.length,o=e*(n-1),s=Math.floor(o),i=Math.ceil(o);return s===i?t[s]:t[s]+(o-s)*(t[i]-t[s])}function bt(r){if(!T(r)||r.length===0)return null;let e=new Map,t=r.length,n=0,o=[];for(let s=0;s<t;s++){let i=r[s];if(i==null)continue;let a=(e.get(i)??0)+1;e.set(i,a),a>n?(n=a,o=[i]):a===n&&o.push(i)}return o.length===0?null:yt(o)}var ar,Kr,ur,qr,Fe=O(()=>{"use strict";Oe();cn();ar=/[,\s_]/g,Kr=/^[+-]?\d+(?:\.\d+)?$/;ur={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}};qr={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function dr(r,e="ms"){let t=r.getTime();switch(e){case"s":return Math.floor(t/mn);case"ms":return t;case"us":return t*_t;case"ns":return t*St}}function gr(r){let e=r.getUTCFullYear();return Math.floor((e-1)/100)+1}function br(r){let e=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-n.getTime())/He+1)/7)}function xr(r){let e=r.getUTCFullYear();return Math.floor((e-1)/1e3)+1}function pn(r,e,t=1){return new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth()+e,t,0,0,0,0))}function wr(r){let e=new Date(Date.UTC(r.getUTCFullYear(),0,1)),t=r.getTime()-e.getTime();return Math.floor(t/He)+1}function _r(r){return Math.floor(r.getUTCMonth()/3)+1}function Sr(r){let e=r instanceof Date?r.getUTCFullYear():r;return e%4===0&&e%100!==0||e%400===0}function P(r){return r instanceof Date&&!Number.isNaN(r.getTime())}function pr(r){let e=Math.abs(r);return e>=1e12?r:e<=1e10?r*1e3:r}function Ue(r,e,t){let n=e;n=n.replace(/%%/g,"\0"),n=n.replace(/%F/g,"%Y-%m-%d"),n=n.replace(/%T/g,"%H:%M:%S"),n=n.replace(/%R/g,"%H:%M"),n=n.replace(/%D/g,"%m/%d/%y");let o={get"%Y"(){return String(r.getUTCFullYear())},get"%y"(){return String(r.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(r.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(r.getUTCDate()).padStart(2,"0")},get"%e"(){return String(r.getUTCDate()).padStart(2," ")},get"%H"(){return String(r.getUTCHours()).padStart(2,"0")},get"%I"(){return String(r.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return r.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(r.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(r.getUTCSeconds()).padStart(2,"0")},get"%A"(){return r.toLocaleDateString(t,{weekday:"long",timeZone:"UTC"})},get"%a"(){return r.toLocaleDateString(t,{weekday:"short",timeZone:"UTC"})},get"%B"(){return r.toLocaleDateString(t,{month:"long",timeZone:"UTC"})},get"%b"(){return r.toLocaleDateString(t,{month:"short",timeZone:"UTC"})},get"%h"(){return r.toLocaleDateString(t,{month:"short",timeZone:"UTC"})},get"%j"(){let s=new Date(Date.UTC(r.getUTCFullYear(),0,1)),i=r.getTime()-s.getTime(),a=Math.floor(i/He)+1;return String(a).padStart(3,"0")},get"%u"(){return String(r.getUTCDay()||7)},get"%w"(){return String(r.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(r.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(r.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let s of Hr)n.includes(s)&&(n=n.replaceAll(s,o[s]));return n.replace(/\0/g,"%")}function Dr(r,e,t=!0){if(typeof r!="string"||typeof e!="string")return null;let n=[],o=1,s="",i=0;for(;i<e.length;){let g=e[i];if(g==="%")if(i+1<e.length){let b=e[i+1];if(b==="%")s+="%",i+=2;else if(e.slice(i,i+3)==="%ms")n.push({name:"ms",index:o++}),s+="(\\d{1,3})",i+=3;else{switch(b){case"Y":n.push({name:"year",index:o++}),s+="(\\d{4})";break;case"y":n.push({name:"year_short",index:o++}),s+="(\\d{2})";break;case"m":n.push({name:"month",index:o++}),s+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:o++}),s+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:o++}),s+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:o++}),s+="(\\d{1,2})";break;case"S":n.push({name:"second",index:o++}),s+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:o++}),s+="(\\d{1,6})";break;default:s+=g+b}i+=2}}else s+=g,i++;else"\\^$*+?.()|[]{}".indexOf(g)!==-1?s+="\\"+g:s+=g,i++}let a=new RegExp("^"+s+"$"),u=r.match(a);if(!u){if(t)return null;let g=new Date(r);return P(g)?g:null}let c=1970,l=1,f=1,m=0,p=0,h=0,y=0;for(let g of n){let b=u[g.index],S=parseInt(b,10);switch(g.name){case"year":c=S;break;case"year_short":c=S+(S>=69?1900:2e3);break;case"month":l=S;break;case"day":f=S;break;case"hour":m=S;break;case"minute":p=S;break;case"second":h=S;break;case"ms":y=parseInt(b.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(b.padEnd(6,"0").slice(0,3),10);break}}let d=new Date(Date.UTC(c,l-1,f,m,p,h,y));return P(d)?d:null}function Q(r){if(r instanceof Date)return P(r)?r:null;if(typeof r=="number"){let e=new Date(pr(r));return P(e)?e:null}if(typeof r=="bigint"){let e=new Date(pr(Number(r)));return P(e)?e:null}if(typeof r=="string"){if(nr(r))return null;let e=new Date(r);return P(e)?e:null}return null}var xt,wt,mn,hr,yr,He,_t,St,Hr,we=O(()=>{"use strict";Fe();ht();xt=/^\d{2}:\d{2}/,wt=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,mn=1e3,hr=6e4,yr=36e5,He=864e5,_t=1e3,St=1e6;Hr=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"]});function L(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function T(r){return Array.isArray(r)||L(r)}function G(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function _e(r){if(!G(r))return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}function ir(r){return typeof r!="function"?!1:/^class\s/.test(Function.prototype.toString.call(r))||r.prototype!==void 0&&r.prototype.constructor===r&&Object.getOwnPropertyDescriptor(r,"prototype")?.writable===!1}function Jr(r){if(r==null)return!1;if(r instanceof Uint8Array||typeof r=="string")return!0;if(Array.isArray(r)){let e=r.length;for(let t=0;t<e;t++)if(!cr(r[t],{min:-128,max:255}))return!1;return!0}return!!L(r)}function Cr(r){return Jr(r)?r instanceof Uint8Array?r:typeof r=="string"?new TextEncoder().encode(r):ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r):null}var Oe=O(()=>{"use strict";we();Fe()});function Tr(r,{format:e="json",allowPrimitives:t=!1,trimBeforeParse:n=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:i,skipLines:a}={},guard:u,onError:c,fallback:l=Je}={}){if(typeof r!="string")return l!==Je?l:r;let f=n?r.trim():r;if(f==="")return l!==Je?l:r;let m;try{if(e==="ndjson"){let p=[],h=0,y=0,d=0;hn.lastIndex=0;let g;for(;;){g=hn.exec(f);let b=g?f.substring(d,g.index):f.substring(d);g&&(d=hn.lastIndex);let S=b.trim();if(S!==""&&(h++,a===void 0||h>a))if(!t&&!Gr(S)){if(!s)throw new Error("NDJSON line is not wrapped and primitives are disallowed")}else try{if(p.push(JSON.parse(S,o)),y++,i!==void 0&&y>=i)break}catch(_){if(!s)throw _}if(!g)break}if(p.length===0)throw new Error("No valid NDJSON lines processed");m=p}else{if(!t&&!zr(f))throw new Error("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(f,o)}}catch(p){return c?.(p),l!==Je?l:r}return u&&!u(m)?(c?.(new Error("Parsed value failed guard validation")),l!==Je?l:r):m}function Ge(r={}){let e=r.bigintStrategy??"string",t=r.handleCircular?new WeakSet:null,o=Array.isArray(r.replacer)?r.replacer.map(String):null,s=i=>e==="number"&&i<=BigInt(Number.MAX_SAFE_INTEGER)&&i>=BigInt(Number.MIN_SAFE_INTEGER)?Number(i):i.toString();return function(a,u){let c=u;if(typeof r.replacer=="function")c=r.replacer.call(this,a,u);else if(o&&a!==""&&!Array.isArray(this)&&!o.includes(a))return;if(c===void 0)return;let l=c===u&&this!=null?this[a]:c;if(typeof r.onCustom=="function"){let f=r.onCustom.call(this,a,l);if(f!==l||f===void 0&&l!==void 0)return f}if(l!==null&&typeof l!="object"&&typeof l!="bigint")return c;if(t&&l!==null&&typeof l=="object"){if(a===""&&(t=new WeakSet),t.has(l))return r.onCircular?r.onCircular.call(this,a,l):"[Circular]";t.add(l)}return typeof l=="bigint"?r.voidBigIntReplacement?c:r.onBigInt?r.onBigInt(l):s(l):L(l)?r.voidTypedArrayReplacement?c:r.onTypedArray?r.onTypedArray(l):Array.from(l):l instanceof Set?r.voidSetReplacement?c:r.onSet?r.onSet(l):Array.from(l):l instanceof Map?r.voidMapReplacement?c:r.onMap?r.onMap(l):Array.from(l.entries()):l instanceof RegExp?r.voidRegExpReplacement?c:r.onRegExp?r.onRegExp(l):l.toString():P(l)?r.voidDateReplacement?c:r.onDate?r.onDate(l):r.formatDate?r.formatDate(l):l.toISOString():l instanceof Error?r.onError?r.onError(l):{name:l.name,message:l.message,stack:l.stack}:l instanceof URLSearchParams?r.onURLSearchParams?r.onURLSearchParams(l):l.toString():c}}var hn,Je,Gr,zr,Dt=O(()=>{"use strict";Oe();we();hn=/\r\n|\n|\r/g,Je=Symbol("no_fallback"),Gr=r=>{let e=r.length;if(e<2)return!1;let t=r[0],n=r[e-1];return t==="{"&&n==="}"||t==="["&&n==="]"},zr=r=>{let e=0,t=r.length;for(;e<t&&/\s/.test(r[e]);)e++;let n=t-1;for(;n>=e&&/\s/.test(r[n]);)n--;if(e>=n)return!1;let o=r[e],s=r[n];return o==="{"&&s==="}"||o==="["&&s==="]"}});var Ct=O(()=>{"use strict"});var H,Ce,ze,me,pe,Me,he,Le,Tt=O(()=>{"use strict";H=class r{matches(e){if(e==null)return!1;if(e instanceof r)return!!(this.equals(e)||this.name.startsWith("Decimal")&&e.name.startsWith("Decimal")&&e.precision===void 0&&e.scale===void 0);if(typeof e=="function"){if(e.prototype instanceof r)return this instanceof e;try{let t=e();if(t instanceof r)return this.constructor===t.constructor}catch{}}return!1}get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},Ce=class extends H{get isNumeric(){return!0}},ze=class extends Ce{get isInteger(){return!0}},me=class extends ze{get isSigned(){return!0}},pe=class extends ze{get isUnsigned(){return!0}},Me=class extends Ce{get isFloat(){return!0}},he=class extends H{get isTemporal(){return!0}},Le=class extends H{get isNested(){return!0}}});var At,yn,It,dn,kt,gn,Et,Ze,Ot,bn,Rt,xn,Ft,wn,Nt,_n,vt,Sn,Ut,Xe,Ye,Mt,Qe,Lt,je,jt,Dn,Vt,Cn,Bt,Tn,$t,An,Kt,et,qt,In,Pt,kn,Wt,En,Ht,On,Rn=O(()=>{"use strict";Tt();U();At=class extends me{name="Int8";coerce(e){return le(e,{range:"Int8"})}equals(e){return e.name==="Int8"}allocate(e){return new Int8Array(e)}},yn=new At,It=class extends me{name="Int16";coerce(e){return le(e,{range:"Int16"})}equals(e){return e.name==="Int16"}allocate(e){return new Int16Array(e)}},dn=new It,kt=class extends me{name="Int32";coerce(e){return le(e,{range:"Int32"})}equals(e){return e.name==="Int32"}allocate(e){return new Int32Array(e)}},gn=new kt,Et=class extends me{name="Int64";coerce(e){return Ne(e,{truncate:!0})}equals(e){return e.name==="Int64"}allocate(e){return new BigInt64Array(e)}},Ze=new Et,Ot=class extends pe{name="UInt8";coerce(e){return le(e,{range:"UInt8"})}equals(e){return e.name==="UInt8"}allocate(e){return new Uint8Array(e)}},bn=new Ot,Rt=class extends pe{name="UInt16";coerce(e){return le(e,{range:"UInt16"})}equals(e){return e.name==="UInt16"}allocate(e){return new Uint16Array(e)}},xn=new Rt,Ft=class extends pe{name="UInt32";coerce(e){return le(e,{range:"UInt32"})}equals(e){return e.name==="UInt32"}allocate(e){return new Uint32Array(e)}},wn=new Ft,Nt=class extends pe{name="UInt64";coerce(e){return Ne(e,{range:"UInt64"})}equals(e){return e.name==="UInt64"}allocate(e){return new BigUint64Array(e)}},_n=new Nt,vt=class extends Me{name="Float32";coerce(e){return fn(e,{floatPrecision:"Float32"})}equals(e){return e.name==="Float32"}allocate(e){return new Float32Array(e)}},Sn=new vt,Ut=class extends Me{name="Float64";coerce(e){return fn(e,{floatPrecision:"Float64"})}equals(e){return e.name==="Float64"}allocate(e){return new Float64Array(e)}},Xe=new Ut,Ye=class r extends Ce{constructor(t,n){super();this.precision=t;this.scale=n;this.name=t!==void 0&&n!==void 0?`Decimal(${t}, ${n})`:"Decimal"}precision;scale;name;coerce(t){return dt(t,{precision:this.precision,scale:this.scale})}equals(t){return t instanceof r&&this.precision===t.precision&&this.scale===t.scale}allocate(t){return new Array(t).fill(null)}},Mt=class extends H{name="Boolean";get isBoolean(){return!0}coerce(e){return e==null?null:!!e}equals(e){return e.name==="Boolean"}allocate(e){return new Array(e).fill(null)}},Qe=new Mt,Lt=class extends H{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(e){return e==null?null:String(e)}equals(e){return e.name==="Utf8"}allocate(e){return new Array(e).fill(null)}},je=new Lt,jt=class extends H{name="Binary";get isBinary(){return!0}coerce(e){return Cr(e)}equals(e){return e.name==="Binary"}allocate(e){return new Array(e).fill(null)}},Dn=new jt,Vt=class extends H{name="Null";get isNull(){return!0}coerce(e){return null}equals(e){return e.name==="Null"}allocate(e){return new Array(e).fill(null)}},Cn=new Vt,Bt=class extends H{name="Object";get isObject(){return!0}coerce(e){return e===void 0?null:e}equals(e){return e.name==="Object"}allocate(e){return new Array(e).fill(null)}},Tn=new Bt,$t=class extends he{name="Date";coerce(e){let t=Q(e);return t?(t.setUTCHours(0,0,0,0),t):null}equals(e){return e.name==="Date"}allocate(e){return new Array(e).fill(null)}},An=new $t,Kt=class extends he{name="Datetime";coerce(e){return Q(e)}equals(e){return e.name==="Datetime"}allocate(e){return new Array(e).fill(null)}},et=new Kt,qt=class extends he{name="Time";coerce(e){if(e==null)return null;if(typeof e=="string"){let n=e.trim();if(xt.test(n)){let o=new globalThis.Date(`1970-01-01T${n}${wt.test(n)?"":"Z"}`);if(P(o))return o.toISOString().split("T")[1].slice(0,12)}}let t=Q(e);return t?t.toISOString().split("T")[1].slice(0,12):null}equals(e){return e.name==="Time"}allocate(e){return new Array(e).fill(null)}},In=new qt,Pt=class extends he{name="Duration";coerce(e){return X(e)}equals(e){return e.name==="Duration"}allocate(e){return new Array(e).fill(null)}},kn=new Pt,Wt=class r extends Le{constructor(t){super();this.innerType=t}innerType;name="List";coerce(t){if(t==null)return null;let n=T(t)?Array.from(t):[t],o=n.length,s=new Array(o);for(let i=0;i<o;i++)s[i]=this.innerType.coerce(n[i]);return s}equals(t){return t instanceof r&&this.innerType.equals(t.innerType)}allocate(t){return new Array(t).fill(null)}},En=r=>new Wt(r),Ht=class r extends Le{constructor(t){super();this.fields=t}fields;name="Struct";coerce(t){if(!G(t))return null;let n={},o=globalThis.Object.keys(this.fields),s=o.length;for(let i=0;i<s;i++){let a=o[i],u=this.fields[a];n[a]=u.coerce(t[a])}return n}equals(t){if(!(t instanceof r))return!1;let n=globalThis.Object.keys(this.fields),o=globalThis.Object.keys(t.fields);if(n.length!==o.length)return!1;for(let s of n)if(!t.fields[s]||!this.fields[s].equals(t.fields[s]))return!1;return!0}allocate(t){return new Array(t).fill(null)}},On=r=>new Ht(r)});var R,ye=O(()=>{"use strict";Tt();Rn();Rn();Tt();R={Int8:yn,Int16:dn,Int32:gn,Int64:Ze,UInt8:bn,UInt16:xn,UInt32:wn,UInt64:_n,Float32:Sn,Float64:Xe,Decimal:(r,e)=>new Ye(r,e),Boolean:Qe,Utf8:je,Binary:Dn,Date:An,Datetime:et,Time:In,Duration:kn,Object:Tn,Null:Cn,List:En,Struct:On}});function Yr(r={}){let e=r.nullValue!==void 0?r.nullValue:"",t=lr(r.numericFormatOptions),n=r.replacerOptions||{},o=a=>r.datetimeFormat?Ue(a,r.datetimeFormat):r.dateFormat?Ue(a,r.dateFormat):r.timeFormat?Ue(a,r.timeFormat):a.toISOString(),s=Ge({formatDate:o,...n}),i=typeof n.onBigInt=="function";return a=>{if(a==null||typeof a=="symbol"||typeof a=="function")return{str:e,isNumeric:!1};if(typeof a=="bigint"&&!i&&!n.voidBigIntReplacement)return{str:t(a),isNumeric:!0};let u=s.call(null,"",a);return u==null||typeof u=="symbol"||typeof u=="function"?{str:e,isNumeric:!1}:typeof u=="string"?{str:u,isNumeric:!1}:typeof u=="number"||typeof u=="bigint"?{str:t(u),isNumeric:!0}:typeof u=="boolean"?{str:u?"true":"false",isNumeric:!1}:u instanceof Number?{str:t(u.valueOf()),isNumeric:!0}:u instanceof String?{str:u.valueOf(),isNumeric:!1}:u instanceof Boolean?{str:u.valueOf()?"true":"false",isNumeric:!1}:typeof u=="object"?{str:JSON.stringify(u,Ge({formatDate:o,...n})),isNumeric:!1}:{str:String(u),isNumeric:!1}}}function Gt(r,e,t={}){let{separator:n=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:i=`
|
|
2
|
-
`,quoteStyle:a="necessary",includeBom:
|
|
3
|
-
`)||
|
|
4
|
-
`&&m++):
|
|
5
|
-
`&&(h=!0),h?(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i),i=[],a="",c=!1,l=!1):(c=!0,l=!1,a+=p)}}return(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i)),s}function kr(r,e={}){let t=new Set(e.nullValues??["","NA","null","NaN"]),n=r.length,o=!0,s=!0,i=!0,a=!0,u=!1;for(let l=0;l<n;l++){let f=r[l].trim();if(!t.has(f)){if(u=!0,o){let m=f.toLowerCase();m!=="true"&&m!=="false"&&m!=="1"&&m!=="0"&&(o=!1)}if(i&&Ne(f,{truncate:!1})===null&&(i=!1),s&&X(f,{allowNonFiniteNumbers:!0})===null&&(s=!1),a&&Q(f)===null&&(a=!1),!o&&!s&&!i&&!a)break}}let c=new Array(n);if(!u||!o&&!s&&!i&&!a){for(let l=0;l<n;l++){let f=r[l];c[l]=t.has(f.trim())?null:f}return{type:je,values:c}}if(o){for(let l=0;l<n;l++){let f=r[l].trim();if(t.has(f))c[l]=null;else{let m=f.toLowerCase();c[l]=m==="true"||m==="1"}}return{type:Qe,values:c}}if(i){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:Ne(f,{truncate:!1})}return{type:Ze,values:c}}if(s){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:X(f,{allowNonFiniteNumbers:!0})}return{type:Xe,values:c}}if(a){for(let l=0;l<n;l++){let f=r[l].trim();c[l]=t.has(f)?null:Q(f)}return{type:et,values:c}}return{type:je,values:c}}var Er=O(()=>{"use strict";we();Dt();Fe();Ct();ye()});var U=O(()=>{"use strict";Oe();Fe();we();cn();ht();Dt();Er()});function J(r,e,t,n=""){if(!(r in e))throw new Te(r,`${t} "${r}" does not exist${n}`)}function zt(r,e){let t=Object.keys(r),n=t.length,o=e;for(let s=0;s<n;s++){let i=t[s],a=r[i],u=T(a)?a.length:0;if(o===void 0)o=u;else if(u!==o)throw new z(`Column height mismatch: Column "${i}" has length ${u}, but DataFrame height is ${o}`)}return o===void 0?0:o}var Or=O(()=>{"use strict";re();U()});var Ae,j,Te,Be,de,z,re=O(()=>{"use strict";Or();Ae=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},j=class extends Ae{},Te=class extends j{constructor(e,t){super(t||`Column "${e}" does not exist in the DataFrame.`)}},Be=class extends Ae{},de=class extends Ae{},z=class extends Ae{}});var x,F,ee=O(()=>{"use strict";oe();re();x=(r,e)=>{let t=r.constructor,n=r.colNames||r.colName||"",o=new t(n);return Object.assign(o,r),o.ops=e?[...r.ops,e]:[...r.ops],o},F=class r{ops=[];outputName="";isLiteral;literalValue;aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;evaluateWindow;_resolve(e,t,n){return e instanceof r?e.isLiteral&&e.ops.length===1?e.literalValue:e.evaluate(t,n):e}alias(e){let t=x(this);return t.outputName=e,t}cast(e){return x(this,t=>{let n=t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]=e.coerce(t[s]);return o})}debug(e){return x(this,t=>(console.log(`[DEBUG] ${e?e+": ":""}`,t),t))}_getInitialValue(e,t){let n=this.colName;if(n&&n!=="*"&&!n.startsWith("*")&&!(n in e))throw new Te(n);return n&&n!=="*"?e[n]||new Array(t).fill(null):new Array(t).fill(null)}evaluate(e,t){let n=this._getInitialValue(e,t),o=this.ops,s=o.length;for(let i=0;i<s;i++)n=o[i](n,e);return n}evaluatePre(e,t,n){let o=this._getInitialValue(t,n),s=this.ops,i=e!==void 0?e:s.length;for(let a=0;a<i;a++)o=s[a](o,t);return o}evaluatePost(e,t,n){let o=this.ops,s=e!==void 0?e:o.length,i=t;for(let a=s;a<o.length;a++)i=o[a](i,n);return i}}});function Zr(r,e,t){let n=new Map,o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];typeof a=="string"?(J(a,r,"Partition key"," in the DataFrame."),s[i]=r[a]):s[i]=a.evaluate(r,e)}if(o===1){let i=s[0];for(let a=0;a<e;a++){let u=i[a],c=u==null?"":$(u),l=n.get(c);l===void 0&&(l=[],n.set(c,l)),l.push(a)}return n}for(let i=0;i<e;i++){let a=new Array(o);for(let l=0;l<o;l++){let f=s[l][i];a[l]=f==null?"":$(f)}let u=a.join("\0"),c=n.get(u);c===void 0&&(c=[],n.set(u,c)),c.push(i)}return n}function Fn(r,e,t){let n=new Array(t);if(t===0)return n;let o=r.partitionBy||[],s=Zr(e,t,o),i=r.evaluatePre(r.partitionOpsIndex,e,t);for(let a of s.values()){let u=a.length,c=new Array(u);for(let l=0;l<u;l++)c[l]=i[a[l]];if(r.evaluateWindow){for(let l=0;l<u;l++)n[a[l]]=r.evaluateWindow(c,a,l);continue}if(r.aggFn){let l=r.aggFn(c);for(let f=0;f<u;f++)n[a[f]]=l;continue}for(let l=0;l<u;l++)n[a[l]]=i[a[l]]}return r.evaluatePost(r.partitionOpsIndex,n,e)}function Nn(r){if(!Array.isArray(r)||r.length===0)return{columns:{},height:0};let e=r.length,t=new Set;for(let s=0;s<e;s++){let i=r[s];if(G(i)){let a=Object.keys(i);for(let u=0;u<a.length;u++)t.add(a[u])}}let n=Array.from(t),o={};for(let s=0;s<n.length;s++)o[n[s]]=new Array(e);for(let s=0;s<e;s++){let i=r[s]||{};for(let a=0;a<n.length;a++){let u=n[a],c=i[u];o[u][s]=c===void 0?null:c}}return{columns:o,height:e}}function vn(r,e){let t=Object.keys(r),n=new Array(e);for(let o=0;o<e;o++){let s={};for(let i=0;i<t.length;i++){let a=t[i],u=r[a][o];s[a]=u===void 0?null:u}n[o]=s}return n}function Xr(r,e,t){let n={};for(let o=0;o<t.length;o++){let s=t[o],i=r[s][e];n[s]=i===void 0?null:i}return n}function ue(r){if(r.length===0)return R.Utf8;let e=!0,t=!0,n=!0,o=!0,s=!0,i=!0,a=!0,u=!0,c=!1,l=!1,f=[];for(let m=0;m<r.length;m++){let p=r[m];if(p!=null){if(l=!0,p instanceof Uint8Array||(a=!1),!T(p)||p instanceof Uint8Array)i=!1;else{let h=p,y=h.length;for(let d=0;d<y;d++)f.push(h[d])}p instanceof Date&&(c=!0),typeof p!="boolean"&&(e=!1),typeof p!="bigint"&&(o=!1),typeof p!="number"?(n=!1,t=!1):Number.isInteger(p)||(t=!1),!(p instanceof Date)&&(typeof p!="string"||isNaN(Date.parse(p)))&&(s=!1),(!G(p)||p instanceof Date||p instanceof Uint8Array||Array.isArray(p))&&(u=!1)}}if(!l)return R.Utf8;if(a)return R.Binary;if(i){let m=ue(f);return R.List(m)}if(e)return R.Boolean;if(o)return R.Int64;if(n&&!t)return R.Float64;if(n&&t){let m=!0;for(let p=0;p<r.length;p++){let h=r[p];if(h!=null&&(h<-2147483648||h>2147483647)){m=!1;break}}return m?R.Int32:R.Float64}return s&&c?R.Datetime:u?R.Object:R.Utf8}function $e(r,e){let t=Object.keys(r),n=t.length,o=e.length,s={};for(let i=0;i<n;i++){let a=t[i],u=r[a],c=L(u)?new u.constructor(o):new Array(o);for(let l=0;l<o;l++)c[l]=u[e[l]];s[a]=c}return s}function Ie(r,e,t){let n=e.length;if(n===1){let s=r[e[0]][t];return s==null?"":$(s)}let o=new Array(n);for(let s=0;s<n;s++){let i=r[e[s]][t];o[s]=i==null?"":$(i)}return o.join("\0")}function ge(r,e,t){let n=e.allocate?e.allocate(t):new Array(t);if(L(n)){let s=n;for(let i=0;i<t;i++){let a=e.coerce(r[i]);if(a==null){let u=new Array(t);for(let c=0;c<i;c++)u[c]=s[c];u[i]=null;for(let c=i+1;c<t;c++)u[c]=e.coerce(r[c]);return u}s[i]=a}}else for(let s=0;s<t;s++)n[s]=e.coerce(r[s]);return n}function Un(r,e){if(r)if(typeof r=="string")require("fs").writeFileSync(r,e,"utf8");else if(typeof r=="object"&&typeof r.write=="function")r.write(e);else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}var tt=O(()=>{"use strict";ye();Ct();U();re()});function nt(r,e,t){return r.isWindow?Fn(r,e,t):r.evaluate(e,t)}var C,V,be=O(()=>{"use strict";U();tt();C=r=>e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++){let s=e[o];n[o]=s==null?null:r(s)}return n},V=(r,e,t)=>(n,o)=>{let s=n.length,i=r._resolve(e,o,s),a=new Array(s);if(T(i))for(let u=0;u<s;u++){let c=n[u],l=i[u];a[u]=c==null||l==null?null:t(c,l)}else for(let u=0;u<s;u++){let c=n[u];a[u]=c==null||i==null?null:t(c,i)}return a}});var rt,Mn=O(()=>{"use strict";ee();be();U();rt=class extends F{abs(){return x(this,C(e=>Math.abs(e)))}acos(){return x(this,C(e=>e<-1||e>1?null:Math.acos(e)))}acosh(){return x(this,C(e=>e<1?null:Math.acosh(e)))}add(e){return x(this,V(this,e,(t,n)=>t+n))}asin(){return x(this,C(e=>e<-1||e>1?null:Math.asin(e)))}asinh(){return x(this,C(Math.asinh))}atan(){return x(this,C(Math.atan))}atanh(){return x(this,C(e=>e<=-1||e>=1?null:Math.atanh(e)))}cbrt(){return x(this,C(Math.cbrt))}ceil(){return x(this,C(Math.ceil))}clip(e=null,t=null){return x(this,C(n=>se(n,{min:e,max:t})))}cos(){return x(this,C(Math.cos))}cosh(){return x(this,C(Math.cosh))}degrees(){return x(this,C(e=>e*(180/Math.PI)))}div(e){return x(this,V(this,e,(t,n)=>n===0?null:t/n))}exp(){return x(this,C(Math.exp))}expm1(){return x(this,C(Math.expm1))}floor(){return x(this,C(Math.floor))}floordiv(e){return x(this,V(this,e,(t,n)=>n===0?null:Math.floor(t/n)))}hypot(e){return x(this,V(this,e,(t,n)=>Math.hypot(t,n)))}log(e=Math.E){return x(this,C(t=>t<=0?null:e===Math.E?Math.log(t):Math.log(t)/Math.log(e)))}log1p(){return x(this,C(e=>e<=-1?null:Math.log1p(e)))}mod(e){return x(this,V(this,e,(t,n)=>n===0?null:t%n))}mul(e){return x(this,V(this,e,(t,n)=>t*n))}negate(){return x(this,C(e=>-e))}pow(e){return x(this,V(this,e,(t,n)=>Math.pow(t,n)))}radians(){return x(this,C(e=>e*(Math.PI/180)))}rand(e,{min:t=0,max:n=1,integer:o=!1}={}){return x(this,s=>{let i=s.length,a=new Float64Array(i),u=e!==void 0?fr(e):Math.random,c=n-t;for(let l=0;l<i;l++){let f=u();a[l]=o?Math.floor(f*(c+1))+t:f*c+t}return a})}round(e=0){let t=Math.pow(10,e);return x(this,C(n=>Math.round(n*t)/t))}sign(){return x(this,C(Math.sign))}sin(){return x(this,C(Math.sin))}sinh(){return x(this,C(Math.sinh))}sqrt(){return x(this,C(e=>e<0?null:Math.sqrt(e)))}sub(e){return x(this,V(this,e,(t,n)=>t-n))}tan(){return x(this,C(Math.tan))}tanh(){return x(this,C(Math.tanh))}trunc(){return x(this,C(Math.trunc))}}});var ot,Ln=O(()=>{"use strict";ee();be();U();ot=class extends F{and(e){return x(this,(t,n)=>{let o=t.length,s=this._resolve(e,n,o),i=T(s),a=new Array(o);for(let u=0;u<o;u++){let c=t[u],l=i?s[u]:s;c===!1||l===!1?a[u]=!1:c==null||l==null?a[u]=null:a[u]=!0}return a})}not(){return x(this,C(e=>!e))}or(e){return x(this,(t,n)=>{let o=t.length,s=this._resolve(e,n,o),i=T(s),a=new Array(o);for(let u=0;u<o;u++){let c=t[u],l=i?s[u]:s;c===!0||l===!0?a[u]=!0:c==null||l==null?a[u]=null:a[u]=!1}return a})}xor(e){return x(this,V(this,e,(t,n)=>!!t!=!!n))}}});function Fr(r,e,t,n){let o=r.length,s=new Array(o);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(e,o);for(let a=0;a<o;a++){let u=r[a];if(u==null)s[a]=null;else{let c=i[a],l=new Set;if(T(c)){let m=c.length;for(let p=0;p<m;p++)l.add($(c[p]))}else l.add($(c));let f=l.has($(u));s[a]=n?!f:f}}}else{let i=T(t)?t:[],a=new Set,u=i.length;for(let c=0;c<u;c++)a.add($(i[c]));for(let c=0;c<o;c++){let l=r[c];if(l==null)s[c]=null;else{let f=a.has($(l));s[c]=n?!f:f}}}return s}function Nr(r,e){let{frequencies:t}=Se(r,{strict:!0}),n=r.length,o=new Array(n);for(let s=0;s<n;s++){let i=t.get(r[s])||0;o[s]=e?i>1:i===1}return o}function vr(r,e,t){let n=r.length,o=new Array(n);if(T(e))for(let s=0;s<n;s++){let i=r[s],a=e[s];i==null&&a==null?o[s]=!t:i==null||a==null?o[s]=t:o[s]=t?i!==a:i===a}else for(let s=0;s<n;s++){let i=r[s];i==null&&e==null?o[s]=!t:i==null||e==null?o[s]=t:o[s]=t?i!==e:i===e}return o}var st,jn=O(()=>{"use strict";ee();be();U();st=class extends F{between(e,t,n="both"){return x(this,(o,s)=>{let i=o.length,a=this._resolve(e,s,i),u=this._resolve(t,s,i),c=new Array(i),l=T(a),f=T(u);for(let m=0;m<i;m++){let p=o[m],h=l?a[m]:a,y=f?u[m]:u;if(p==null||h==null||y==null)c[m]=null;else{let d=n==="both"||n==="left"?p>=h:p>h,g=n==="both"||n==="right"?p<=y:p<y;c[m]=d&&g}}return c})}eq(e){return x(this,V(this,e,(t,n)=>t===n))}eq_missing(e){return x(this,(t,n)=>{let o=this._resolve(e,n,t.length);return vr(t,o,!1)})}ge(e){return x(this,V(this,e,(t,n)=>t>=n))}gt(e){return x(this,V(this,e,(t,n)=>t>n))}has_nulls(){return this._deriveAgg(e=>{for(let t=0;t<e.length;t++)if(e[t]==null)return!0;return!1})}is_close(e,{abs_tol:t=1e-8,rel_tol:n=1e-8,nans_equal:o=!1}={}){return x(this,(s,i)=>{let a=s.length,u=this._resolve(e,i,a),c=T(u),l=new Array(a);for(let f=0;f<a;f++){let m=s[f],p=c?u[f]:u;if(m==null||p==null)l[f]=null;else if(te(m)&&te(p)){let h=Math.abs(m-p),y=Math.max(n*Math.max(Math.abs(m),Math.abs(p)),t);l[f]=h<=y}else Number.isNaN(m)&&Number.isNaN(p)?l[f]=o:l[f]=m===p}return l})}is_duplicated(){return x(this,e=>Nr(e,!0))}is_empty({ignoreNulls:e=!1}={}){return x(this,C(t=>typeof t=="string"?t.length===0:T(t)?e?K(t,"nullish",{mode:"every"}):t.length===0:null))}is_finite(){return x(this,C(Number.isFinite))}is_in(e){return x(this,(t,n)=>Fr(t,n,e,!1))}is_infinite(){return x(this,C(e=>e===1/0||e===-1/0))}is_nan(){return x(this,C(Number.isNaN))}is_not_nan(){return x(this,C(e=>!Number.isNaN(e)))}is_not_null(){return x(this,e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=e[o]!=null;return n})}is_null(){return x(this,e=>{let t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=e[o]==null;return n})}is_unique(){return x(this,e=>Nr(e,!1))}le(e){return x(this,V(this,e,(t,n)=>t<=n))}lt(e){return x(this,V(this,e,(t,n)=>t<n))}ne(e){return x(this,V(this,e,(t,n)=>t!==n))}ne_missing(e){return x(this,(t,n)=>{let o=this._resolve(e,n,t.length);return vr(t,o,!0)})}not_in(e){return x(this,(t,n)=>Fr(t,n,e,!0))}}});var Yt,it,Vn=O(()=>{"use strict";ee();be();U();Yt=class{constructor(e){this.expr=e}expr;_deriveString(e){return x(this.expr,C(t=>e(String(t))))}_patternGuard(e,t){return e==null?x(this.expr,n=>new Array(n.length).fill(null)):t()}concat(e){return x(this.expr,V(this.expr,e,(t,n)=>String(t)+String(n)))}contains(e){return this._patternGuard(e,()=>this._deriveString(t=>e instanceof RegExp?e.test(t):t.includes(e)))}count_matches(e){return this._patternGuard(e,()=>this._deriveString(t=>{if(e instanceof RegExp){let n=e.global?e:new RegExp(e.source,e.flags+"g"),o=t.match(n);return o?o.length:0}else{let n=0,o=t.indexOf(e);for(;o!==-1;)n++,o=t.indexOf(e,o+e.length);return n}}))}decode_uri_component(){return this._deriveString(e=>{try{return decodeURIComponent(e)}catch{return e}})}encode_uri_component(){return this._deriveString(e=>{try{return encodeURIComponent(e)}catch{return e}})}ends_with(e){return this._deriveString(t=>t.endsWith(e))}explode(){return this._deriveString(e=>e.split(""))}extract(e,t=0){return this._patternGuard(e,()=>this._deriveString(n=>{let o=n.match(e);return o&&o[t]!==void 0?o[t]:null}))}len(){return this.len_chars()}len_bytes(){return this._deriveString(e=>new TextEncoder().encode(e).length)}len_chars(){return this._deriveString(e=>e.length)}lower(){return this._deriveString(e=>e.toLowerCase())}lpad(e,t=" "){return this._deriveString(n=>n.padStart(e,t))}pad_end(e,t=" "){return this.rpad(e,t)}pad_start(e,t=" "){return this.lpad(e,t)}replace(e,t){return this._patternGuard(e,()=>this._deriveString(n=>n.replace(e,t)))}replace_all(e,t){return this._patternGuard(e,()=>this._deriveString(n=>{if(e instanceof RegExp){let o=e.global?e:new RegExp(e.source,e.flags+"g");return n.replace(o,t)}return n.replaceAll(e,t)}))}reverse(){return this._deriveString(e=>e.split("").reverse().join(""))}rpad(e,t=" "){return this._deriveString(n=>n.padEnd(e,t))}slice(e,t){return this._deriveString(n=>{let o=e<0?n.length+e:e,s=t!==void 0?o+t:void 0;return n.slice(o,s)})}slice_str(e,t){return this.slice(e,t)}split(e){return this._deriveString(t=>t.split(e))}starts_with(e){return this._deriveString(t=>t.startsWith(e))}strip_chars(e,t){return this._deriveString(n=>Ee(n,e,{mode:"both",...t}))}strip_chars_end(e,t){return this._deriveString(n=>Ee(n,e,{mode:"end",...t}))}strip_chars_start(e,t){return this._deriveString(n=>Ee(n,e,{mode:"start",...t}))}strip_prefix(e){return this._deriveString(t=>Ee(t,e,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(e){return this._deriveString(t=>Ee(t,e,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(e,t=!0){return this._deriveString(n=>Dr(n,e,t))}to_date(){return this._deriveString(e=>{let t=Q(e);if(!t)return null;let n=new Date(t);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(Q)}to_decimal(e,t){return this._deriveString(n=>dt(n,{precision:e,scale:t}))}to_integer(){return this._deriveString(e=>le(e))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(e=>{let t=Q(e);if(t)return t.toISOString().split("T")[1].slice(0,12);let n=e.trim();if(xt.test(n)){let o=new Date(`1970-01-01T${n}${wt.test(n)?"":"Z"}`);if(P(o))return o.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(e=>e.replace(/\b\w/g,t=>t.toUpperCase()))}to_uppercase(){return this.upper()}trim(){return this.strip_chars()}trim_end(){return this.strip_chars_end()}trim_start(){return this.strip_chars_start()}upper(){return this._deriveString(e=>e.toUpperCase())}zfill(e){return this._deriveString(t=>t.padStart(e,"0"))}},it=class extends F{get str(){return new Yt(this)}}});var at,Bn=O(()=>{"use strict";ee();re();U();at=class extends F{_deriveAgg(e){let t=x(this);return t.aggFn=e,t.groupingOpsIndex=this.ops.length,t.partitionOpsIndex=this.ops.length,t}all(){return this._deriveAgg(e=>K(e,t=>!!t,{mode:"every"}))}all_null(){return this._deriveAgg(e=>K(e,"nullish",{mode:"every"}))}any(){return this._deriveAgg(e=>K(e,t=>!!t,{mode:"some"}))}any_null(){return this._deriveAgg(e=>K(e,"nullish",{mode:"some"}))}avg(){return this._deriveAgg(e=>B(e).mean)}count(e={}){return e.includeNulls?this._deriveAgg(t=>t.length):this._deriveAgg(t=>B(t).count)}first(){return this._deriveAgg(e=>e[0]??null)}implode(){return this._deriveAgg(e=>e)}last(){return this._deriveAgg(e=>e[e.length-1]??null)}max(){return this._deriveAgg(e=>B(e).max)}mean(){return this.avg()}median(){return this._deriveAgg(e=>ve(e))}min(){return this._deriveAgg(e=>B(e).min)}mode(){return this._deriveAgg(e=>bt(e))}n_unique(e={}){return this._deriveAgg(t=>Se(t,e).count)}quantile(e){if(e<0||e>1)throw new de("Quantile q must be between 0 and 1");return this._deriveAgg(t=>gt(t,e))}std(){return this._deriveAgg(e=>B(e).std)}sum(){return this._deriveAgg(e=>B(e).sum)}}});function $n(r,e,t={}){if(e==null)return null;let n=r;if(t.ignoreNulls){n=[];let a=r.length;for(let u=0;u<a;u++)r[u]!=null&&n.push(r[u])}t.dense&&(n=Array.from(new Set(n)));let o=[...n].sort((a,u)=>a-u),s=new Map,i=o.length;for(let a=0;a<i;a++){let u=o[a];s.has(u)||s.set(u,a+1)}return s.get(e)??null}var lt,Kn=O(()=>{"use strict";ee();U();lt=class extends F{partitionBy=this.partitionBy||null;_window(e){let t=x(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=e,t}_rolling(e,t){return this._window(function(n,o,s){let i=Math.max(0,s-e+1),a=s+1,u=n.slice(i,a);return t(u)})}_cum(e,t,n,o){return this._window(function(s,i,a){let u=t,c=!1,l=e?a:0,f=e?s.length-1:a;for(let m=l;m<=f;m++){let p=s[m];p!=null&&(u=n(u,p),c=!0)}return o?o(u,c):u})}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(e=!1){return this._cum(e,0,t=>t+1)}cum_max(e=!1){return this._cum(e,null,(t,n)=>t===null||n>t?n:t)}cum_min(e=!1){return this._cum(e,null,(t,n)=>t===null||n<t?n:t)}cum_prod(e=!1){return this._cum(e,1,(t,n)=>t*n,(t,n)=>n?t:null)}cum_sum(e=!1){return this._cum(e,0,(t,n)=>t+n)}dense_rank(){return this._window(function(e,t,n){return $n(e,e[n],{dense:!0})})}lag(e=1,t=null){return this._window(function(n,o,s){let i=t;return s-e>=0&&(i=n[s-e]),i})}lead(e=1,t=null){return this._window(function(n,o,s){let i=t;return s+e<n.length&&(i=n[s+e]),i})}over(e){let t=x(this),n=Array.isArray(e)?e:[e];return t.partitionBy=n,t}rank(){return this._window(function(e,t,n){return $n(e,e[n])})}rolling_max(e){return this._rolling(e,t=>B(t).max)}rolling_mean(e){return this._rolling(e,t=>B(t).mean)}rolling_median(e){return this._rolling(e,t=>ve(t))}rolling_min(e){return this._rolling(e,t=>B(t).min)}rolling_quantile(e,t){return this._rolling(t,n=>gt(n,e))}rolling_rank(e){return this._rolling(e,t=>$n(t,t[t.length-1],{ignoreNulls:!0}))}rolling_std(e){return this._rolling(e,t=>B(t).std)}rolling_sum(e){return this._rolling(e,t=>B(t).sum)}row_number(){let e=this._window(function(t,n,o){return o+1});return e.outputName="row_number",e}}});var Zt,ut,qn=O(()=>{"use strict";ee();be();U();Zt=class{constructor(e){this.expr=e}expr;_deriveDate(e){return x(this.expr,C(t=>{let n=Q(t);return n?e(n):null}))}_deriveDuration(e){return x(this.expr,C(t=>typeof t=="number"?e(t):null))}century(){return this._deriveDate(gr)}date(){return this._deriveDate(e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())))}datetime(){return this._deriveDate(e=>e)}day(){return this._deriveDate(e=>e.getUTCDate())}epoch(e="ms"){return this._deriveDate(t=>dr(t,e))}hour(){return this._deriveDate(e=>e.getUTCHours())}is_leap_year(){return this._deriveDate(Sr)}microsecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*_t)}millennium(){return this._deriveDate(xr)}millisecond(){return this._deriveDate(e=>e.getUTCMilliseconds())}minute(){return this._deriveDate(e=>e.getUTCMinutes())}month(){return this._deriveDate(e=>e.getUTCMonth()+1)}month_end(){return this._deriveDate(e=>pn(e,1,0))}month_start(){return this._deriveDate(e=>pn(e,0,1))}nanosecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*St)}ordinal_day(){return this._deriveDate(wr)}quarter(){return this._deriveDate(_r)}second(){return this._deriveDate(e=>e.getUTCSeconds())}strftime(e,t){return this._deriveDate(n=>Ue(n,e,t))}time(){return this._deriveDate(e=>e.toISOString().split("T")[1].slice(0,12))}timestamp(e="ms"){return this.epoch(e)}to_string(e,t){return this.strftime(e,t)}total_days(){return this._deriveDuration(e=>e/He)}total_hours(){return this._deriveDuration(e=>e/yr)}total_microseconds(){return this._deriveDuration(e=>e*_t)}total_milliseconds(){return this._deriveDuration(e=>e)}total_minutes(){return this._deriveDuration(e=>e/hr)}total_nanoseconds(){return this._deriveDuration(e=>e*St)}total_seconds(){return this._deriveDuration(e=>e/mn)}week(){return this._deriveDate(br)}weekday(){return this._deriveDate(e=>e.getUTCDay()||7)}year(){return this._deriveDate(e=>e.getUTCFullYear())}},ut=class extends F{get dt(){return new Zt(this)}}});var Xt,ct,Pn=O(()=>{"use strict";ee();be();U();re();oe();Xt=class{constructor(e){this.expr=e}expr;_deriveList(e){return x(this.expr,C(t=>T(t)?e(t):null))}all(){return this._deriveList(e=>K(e,t=>!!t,{mode:"every"}))}any(){return this._deriveList(e=>K(e,t=>!!t,{mode:"some"}))}contains(e){return this._deriveList(t=>t.includes(e))}contains_all(e){return this._deriveList(t=>K(e,n=>t.includes(n),{mode:"every"}))}contains_any(e){return this._deriveList(t=>K(e,n=>t.includes(n),{mode:"some"}))}count_matches(e){return this._deriveList(t=>{let n=0,o=t.length;for(let s=0;s<o;s++)t[s]===e&&n++;return n})}drop_nulls(){return this._deriveList(e=>{let t=e.length,n=[];for(let o=0;o<t;o++)e[o]!=null&&n.push(e[o]);return n})}explode({empty_as_null:e=!0,keep_nulls:t=!0}={}){return x(this.expr,n=>{let o=n.length,s=0;for(let c=0;c<o;c++){let l=n[c];if(T(l)){s+=l.length||(e?1:0);continue}if(l!=null){s+=1;continue}t&&(s+=1)}let i=new Array(s),a=new Int32Array(s),u=0;for(let c=0;c<o;c++){let l=n[c];if(T(l)){let f=l.length;if(f>0){for(let m=0;m<f;m++)a[u]=c,i[u++]=l[m];continue}e&&(a[u]=c,i[u++]=null);continue}if(l!=null){a[u]=c,i[u++]=l;continue}t&&(a[u]=c,i[u++]=null)}return i.rowMap=a,i})}first(e=!0){return this.get(0,e)}gather(e,t=!0){return this._deriveList(n=>{let o=n.length,s=T(e)?e:[e],i=s.length,a=new Array(i);for(let u=0;u<i;u++){let c=s[u],l=n.at(c);if(l===void 0&&!t)throw new de(`Index ${c} is out of bounds for list of length ${o}`);a[u]=l??null}return a})}gather_every(e={}){return this._deriveList(t=>or(t,e))}get(e,t=!0){return this._deriveList(n=>{let o=n.at(e);if(o===void 0&&!t)throw new de(`Index ${e} is out of bounds for list of length ${n.length}`);return o??null})}join(e=",",t={}){return this._deriveList(n=>sr(n,e,t))}last(e=!0){return this.get(-1,e)}len(){return this.lengths()}lengths(){return this._deriveList(e=>e.length)}max(){return this._deriveList(e=>B(e).max)}mean(){return this._deriveList(e=>B(e).mean)}median(){return this._deriveList(e=>ve(e))}min(){return this._deriveList(e=>B(e).min)}mode(){return this._deriveList(e=>bt(e))}n_unique(e={}){return this._deriveList(t=>Se(t,e).count)}reverse(){return this._deriveList(e=>e.slice().reverse())}slice(e,t){return this._deriveList(n=>{let o=n.length,s=e<0?Math.max(0,o+e):e,i=t!==void 0?s+t:o;return n.slice(s,i)})}sort(e=!1){return this._deriveList(t=>yt(t,e))}sum(){return this._deriveList(e=>B(e).sum)}unique(e={}){return this._deriveList(t=>Se(t,e).values)}eval(e){return x(this.expr,(t,n)=>{let o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];if(!T(a)){s[i]=null;continue}let u=a.length,c={...n,[Pe]:a};if(e.aggFn!=null&&(e.partitionBy==null||e.partitionBy.length===0)){let f=e.groupingOpsIndex!==void 0?e.groupingOpsIndex:e.ops.length,m=e.evaluatePre(f,c,u),p=e.aggFn(Array.from(m));s[i]=e.evaluatePost(f,[p],c)}else s[i]=nt(e,c,u)}return s})}},ct=class extends F{get list(){return new Xt(this)}}});var Qt,Ur=O(()=>{"use strict";ee();U();Qt=class extends F{fill_null({value:e=void 0,strategy:t=void 0,limit:n=void 0}={}){return x(this,(o,s)=>{let i=o.length,a=Array.from(o);if(t!==void 0)if(t==="zero"||t==="one"||t==="min"||t==="max"||t==="mean"){let u;t==="zero"?u=0:t==="one"?u=1:u=B(o)[t],De(a,u,{mode:"constant",condition:c=>c==null})}else if(t==="forward"||t==="backward"){let u=t==="forward",c=null,l=0;De(a,null,{mode:"independent",reverse:!u,step:({originalValue:f})=>f!=null?(c=f,l=0,f):c!==null&&(n===void 0||l<n)?(l++,c):null})}else throw new Error(`Unsupported fill_null strategy: "${t}"`);else{let u=this._resolve(e,s,i),c=T(u);De(a,null,{mode:"independent",step:({index:l,originalValue:f})=>f??(c?u[l]:u)})}return a})}reverse(){return x(this,e=>e.slice().reverse())}}});var Mr={};er(Mr,{ColumnExpr:()=>I,resolveColumnSelectors:()=>xe});function Qr(r,e){for(let t of e)for(let n of Object.getOwnPropertyNames(t.prototype))n!=="constructor"&&Object.defineProperty(r.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))}function eo(r,e,t,n){if(!(r instanceof I)){if(r&&typeof r=="object"&&"evaluate"in r&&!r.colName){let o=[];for(let s=0;s<e.length;s++)t.has(e[s])||o.push(e[s]);return o}return null}if(r.colNames&&r.colNames.length>0)return r.colNames;if(r.colName==="*"){let o=new Set(r.excludedCols),s=[];for(let i=0;i<e.length;i++){let a=e[i];!o.has(a)&&!t.has(a)&&s.push(a)}return s}if(r.targetType||r.targetTypes&&r.targetTypes.length>0){if(!n)throw new Error("Cannot resolve DataType column selector without DataFrame schema.");let o=[];for(let s=0;s<e.length;s++){let i=e[s];if(t.has(i))continue;let a=n[i];if(a){if(r.targetType)a.matches(r.targetType)&&o.push(i);else if(r.targetTypes){for(let u=0;u<r.targetTypes.length;u++)if(a.matches(r.targetTypes[u])){o.push(i);break}}}}return o}return null}function xe(r,e,t,n,o){let s=[],i=t?new Set(t):new Set;for(let a=0;a<r.length;a++){let u=r[a];if(typeof u=="string"){s.push(new I(u));continue}if(u&&typeof u=="object"&&u.isUnnest){let l=[],f=u.colName;if(n&&f&&n[f]&&n[f].name==="Struct"&&(l=Object.keys(n[f].fields)),l.length===0&&o){let h=Object.keys(o)[0],y=h?o[h].length:0,d=u.baseExpr.evaluate(o,y),g=d.length;for(let b=0;b<g;b++){let S=d[b];if(S!=null&&typeof S=="object"){l=Object.keys(S);break}}}let m=l.length;if(m>0){for(let p=0;p<m;p++){let h=l[p],y=u.baseExpr.struct.field(h);s.push(y)}continue}}let c=eo(u,e,i,n);if(c!==null)for(let l=0;l<c.length;l++){let f=new I(c[l]);f.ops=[...u.ops||[]],f.aggFn=u.aggFn,f.partitionOpsIndex=u.partitionOpsIndex,f.groupingOpsIndex=u.groupingOpsIndex,f.partitionBy=u.partitionBy,u.evaluateWindow&&(f.evaluateWindow=u.evaluateWindow),u.outputName&&u.outputName!=="*"&&(f.outputName=u.outputName),s.push(f)}else s.push(u)}return s}var I,ie=O(()=>{"use strict";ee();Mn();jn();Bn();Kn();Vn();Ln();qn();Pn();Wn();Ur();U();ye();oe();I=class r extends F{colName;colNames;excludedCols=[];targetType;targetTypes;static isColExpr(e){if(!G(e))return!1;try{return"evaluate"in e&&typeof e.evaluate=="function"}catch{return!1}}static toColExpr(e){if(e==null)throw new Error("Column reference cannot be null or undefined.");return r.isColExpr(e)?e:new r(e)}constructor(e){super(),Array.isArray(e)?e.some(n=>n instanceof H||typeof n=="function")?(this.targetTypes=e,this.colName="",this.outputName=""):(this.colNames=e.map(String),this.colName="",this.outputName=""):e instanceof H||typeof e=="function"?(this.targetType=e,this.colName="",this.outputName=""):(this.colName=String(e),this.outputName=this.colName)}};Qr(I,[rt,st,at,lt,it,ot,ut,ct,ft,Qt])});function Lr(r){if(r==null)throw new Error("Column reference cannot be null or undefined.");return en||(en=(ie(),tr(Mr)).ColumnExpr),en.isColExpr(r)?r:new en(r)}var en,tn,ft,Wn=O(()=>{"use strict";ee();en=null;tn=class{constructor(e){this.expr=e;return new Proxy(this,{get(t,n,o){return n in t?Reflect.get(t,n,o):typeof n=="string"?t.field(n):Reflect.get(t,n,o)}})}expr;field(e){return x(this.expr,t=>{let n=t.length,o=new Array(n);for(let s=0;s<n;s++){let i=t[s];o[s]=i!=null&&typeof i=="object"?i[e]:null}return o}).alias(e)}rename_fields(e){return x(this.expr,t=>{let n=t.length,o=new Array(n),s=Object.keys(e),i=s.length;for(let a=0;a<n;a++){let u=t[a];if(u==null||typeof u!="object"){o[a]=null;continue}let c={},l=Object.keys(u),f=l.length;for(let m=0;m<f;m++){let p=l[m];c[p]=u[p]}for(let m=0;m<i;m++){let p=s[m];if(p in c){let h=e[p];c[h]=c[p],delete c[p]}}o[a]=c}return o})}with_fields(e){return x(this.expr,(t,n)=>{let o=t.length,s=new Array(o),i=[];if(Array.isArray(e)){let c=e.length;for(let l=0;l<c;l++){let f=e[l],m=Lr(f),p=m.outputName||m.colName;if(!p)throw new Error("Expressions passed to struct.with_fields must have a name/alias.");i.push({name:p,expr:m})}}else if(e&&typeof e=="object"){let c=Object.keys(e),l=c.length;for(let f=0;f<l;f++){let m=c[f],p=Lr(e[m]);i.push({name:m,expr:p})}}let a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=i[c].expr.evaluate(n,o);for(let c=0;c<o;c++){let l=t[c];if(l==null||typeof l!="object"){s[c]=null;continue}let f={},m=Object.keys(l),p=m.length;for(let h=0;h<p;h++){let y=m[h];f[y]=l[y]}for(let h=0;h<a;h++)f[i[h].name]=u[h][c];s[c]=f}return s})}unnest(){let e=x(this.expr);return e.isUnnest=!0,e.baseExpr=this.expr,e}},ft=class extends F{get struct(){return new tn(this)}}});var oo={};er(oo,{$df:()=>ro,ALL_COLUMNS_MARKER:()=>q,AggregationExpr:()=>at,ArithmeticExpr:()=>rt,Binary:()=>Dn,BinaryType:()=>jt,Boolean:()=>Qe,BooleanType:()=>Mt,COALESCE_MARKER:()=>un,ColumnExpr:()=>I,ColumnNotFoundError:()=>Te,ComparisonExpr:()=>st,ComputeError:()=>de,DFScriptError:()=>Ae,DataFrame:()=>N,DataFrameError:()=>j,DataType:()=>H,DataTypeRegistry:()=>R,Date:()=>An,DateTimeExprNamespace:()=>Zt,DateType:()=>$t,Datetime:()=>et,DatetimeType:()=>Kt,DecimalType:()=>Ye,Duration:()=>kn,DurationType:()=>Pt,ELEMENT_MARKER:()=>Pe,ExprBase:()=>F,Float32:()=>Sn,Float32Type:()=>vt,Float64:()=>Xe,Float64Type:()=>Ut,FloatDataType:()=>Me,GroupedData:()=>pt,Int16:()=>dn,Int16Type:()=>It,Int32:()=>gn,Int32Type:()=>kt,Int64:()=>Ze,Int64Type:()=>Et,Int8:()=>yn,Int8Type:()=>At,IntegerDataType:()=>ze,LITERAL_MARKER:()=>ln,List:()=>En,ListExpr:()=>ct,ListExprNamespace:()=>Xt,ListType:()=>Wt,LogicalExpr:()=>ot,NestedDataType:()=>Le,Null:()=>Cn,NullType:()=>Vt,NumericDataType:()=>Ce,Object:()=>Tn,ObjectType:()=>Bt,SchemaError:()=>Be,ShapeError:()=>z,SignedIntegerType:()=>me,StringExpr:()=>it,StringExprNamespace:()=>Yt,Struct:()=>On,StructExpr:()=>ft,StructExprNamespace:()=>tn,StructType:()=>Ht,TemporalDataType:()=>he,TemporalExpr:()=>ut,Time:()=>In,TimeType:()=>qt,UInt16:()=>xn,UInt16Type:()=>Rt,UInt32:()=>wn,UInt32Type:()=>Ft,UInt64:()=>_n,UInt64Type:()=>Nt,UInt8:()=>bn,UInt8Type:()=>Ot,UnsignedIntegerType:()=>pe,Utf8:()=>je,Utf8Type:()=>Lt,When:()=>rn,WhenThen:()=>mt,WhenThenChain:()=>nn,WindowExpr:()=>lt,all:()=>Ke,assertColumnExists:()=>J,assertHeight:()=>zt,coalesce:()=>Gn,coerceColumn:()=>ge,columnsToRows:()=>vn,computeRowHash:()=>Ie,concat:()=>qe,derive:()=>x,element:()=>Zn,evaluateExpression:()=>nt,exclude:()=>Jn,gatherColumnsByIndices:()=>$e,getRowFromColumns:()=>Xr,implode:()=>Yn,inferColumnType:()=>ue,kleeneBinary:()=>V,kleeneUnary:()=>C,lit:()=>Hn,read_csv:()=>sn,read_json:()=>on,resolveColumnSelectors:()=>xe,resolveWindowExpr:()=>Fn,rowsToColumns:()=>Nn,seq_range:()=>ke,when:()=>zn,writeStringToFileOrStream:()=>Un});module.exports=tr(oo);oe();ee();Mn();Ln();jn();Vn();Bn();Kn();qn();Pn();Wn();ie();ie();oe();re();U();function ke(r,e={strict:!0}){let t=e,n=new I(ln);return n.literalValue=r,t.name&&(n.outputName=t.name),n.ops.push(o=>{let s=o.length,i=(w,D)=>w===void 0?D:se(w<0?s+w:w,{min:0,max:s}),a=i(t.startIndex,0),u=i(t.endIndex,s),c=Math.max(0,u-a),l=t.n!==void 0?t.n:c,f=t.strict!==!1;if(f){if(l!==s)throw new z(`Column height mismatch: seq_range length ${l} does not match DataFrame height ${s}`)}else{let w=t.pad??!1,D=t.truncate??!1;if(w&&!D&&l>c)throw new z(`Cannot pad seq_range output: specified length ${l} starting at index ${a} exceeds slice width ${c} (requires truncation).`);if(D&&!w&&l<c)throw new z(`Cannot truncate seq_range output: specified length ${l} starting at index ${a} is less than slice width ${c} (requires padding).`)}let m=s,p=!!t.dtype,h=t.mode||"cumulative",y=t.step!==void 0?t.step:1,d=p?w=>t.dtype.coerce(w):w=>w;if(f){let w=t.dtype?.allocate?t.dtype.allocate(m):new Array(m);return De(w,r,{mode:h,step:y,coerce:d,startIndex:0,endIndex:m}),w}let g=Math.min(a+l,u),b=t.padValue!==void 0?t.padValue:null,S=d(b);if(h==="constant"&&a===0&&g===m&&!t.dtype){let w=new Array(m);for(let D=0;D<m;D++)w[D]=r;return w}let _=new Array(m);return _.fill(S),De(_,r,{mode:h,step:y,coerce:d,startIndex:a,endIndex:g}),_}),n}function Hn(r,e){let t=ke(r,{strict:!0,mode:"constant",dtype:e?.dtype,name:e?.name});return t.isLiteral=!0,t}ie();oe();function Ke(){return new I("*")}ie();oe();function Jn(r){let e=new I("*");return e.excludedCols=Array.isArray(r)?r:[r],e}ie();U();oe();function Gn(...r){let e=r.length===1&&Array.isArray(r[0])?r[0]:r,t=new I(un);return t.ops.push((n,o)=>{let s=n.length,i=l=>I.isColExpr(l)?l.evaluate(o,s):typeof l=="string"?o[l]||new Array(s).fill(null):l,a=e.length,u=new Array(a);for(let l=0;l<a;l++)u[l]=i(e[l]);let c=new Array(s);for(let l=0;l<s;l++){let f=null;for(let m=0;m<a;m++){let p=u[m],h=T(p)?p[l]:p;if(h!=null){f=h;break}}c[l]=f}return c}),t}ie();U();var nn=class{predicates;values;constructor(e,t){this.predicates=e,this.values=t}then(e){return new mt(this.predicates,this.values.concat(e))}},rn=class{predicates;constructor(e){this.predicates=[e]}then(e){return new mt(this.predicates,[e])}},mt=class r extends I{predicates;values;otherwiseValue;constructor(e,t,n=null){super(typeof e=="string"?e:"*when*"),this.predicates=Array.isArray(e)?e:[],this.values=t||[],this.otherwiseValue=n,this.ops.push((o,s)=>{let i=o.length,a=p=>I.isColExpr(p)?p.evaluate(s,i):typeof p=="string"&&p in s?s[p]:p,u=this.predicates.length,c=new Array(u),l=new Array(u);for(let p=0;p<u;p++)c[p]=a(this.predicates[p]),l[p]=a(this.values[p]);let f=a(this.otherwiseValue),m=new Array(i);for(let p=0;p<i;p++){let h=!1;for(let y=0;y<u;y++)if((T(c[y])?c[y][p]:c[y])===!0){m[p]=T(l[y])?l[y][p]:l[y],h=!0;break}h||(m[p]=T(f)?f[p]:f)}return m})}when(e){return new nn(this.predicates.concat(e),this.values)}otherwise(e){return new r(this.predicates,this.values,e)}};function zn(r){return new rn(r)}ie();function Yn(r){return I.toColExpr(r).implode()}ie();oe();function Zn(){return new I(Pe)}be();tt();var pt=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(e,t,n,o,s,i){this.groups=e,this.keys=t,this.allKeys=n,this.parentColumns=o,this.parentHeight=s,this.parentSchema=i}to_dataframe(){let e=this.keys.length,t=new Array(e);for(let a=0;a<e;a++)t[a]=String(this.keys[a]);let n=this.groups.size,o={};for(let a=0;a<t.length;a++)o[t[a]]=new Array(n);let s=0;for(let a of this.groups.values()){if(a.length===0)continue;let u=a[0];for(let c=0;c<t.length;c++){let l=t[c],f=this.parentColumns[l][u];o[l][s]=f===void 0?null:f}s++}let i={};for(let a of t)i[a]=this.parentSchema[a];return N._createDirect(o,i,s)}agg(...e){let t=this.allKeys.length,n=new Array(t);for(let f=0;f<t;f++)n[f]=String(this.allKeys[f]);let o=this.keys.length,s=new Array(o);for(let f=0;f<o;f++)s[f]=String(this.keys[f]);let i=xe(e.flat(),n,s,this.parentSchema,this.parentColumns),a=this.groups.size,u={};for(let f=0;f<s.length;f++)u[s[f]]=new Array(a);let c=0;for(let f of this.groups.values()){if(f.length===0)continue;let m=f[0];for(let p=0;p<s.length;p++){let h=s[p],y=this.parentColumns[h][m];u[h][c]=y===void 0?null:y}c++}for(let f=0;f<i.length;f++){let m=i[f],p=m.outputName||m.colName||"*";if(!m.aggFn)u[p]=m.evaluate(u,a);else{let h=m.evaluatePre(m.groupingOpsIndex,this.parentColumns,this.parentHeight),y=new Array(a),d=0;for(let g of this.groups.values()){if(g.length===0)continue;let b=new Array(g.length);for(let S=0;S<g.length;S++)b[S]=h[g[S]];y[d]=m.aggFn(b),d++}u[p]=m.evaluatePost(m.groupingOpsIndex,y,u)}}let l={};for(let f of s)l[f]=this.parentSchema[f];for(let f of i){let m=f.outputName||f.colName||"*";l[m]=ue(u[m])}return N._createDirect(u,l,c)}};Ct();Dt();ye();U();re();ye();U();re();function to(r,e,t){if(r==null)throw new j(`Invalid input to ${e} at index ${t}: item cannot be null or undefined.`);if(r instanceof N)return[r];if(_e(r))return[new N(r)];if(T(r)){if(K(r,N,{mode:"every"}))return r;if(K(r,"plainObject",{mode:"every"}))return[new N(r)];let n=K(r,N,{mode:"some"});for(let o=0;o<r.length;o++)if(n?!(r[o]instanceof N):!_e(r[o]))throw new j(n?`Invalid input to ${e} at index ${t}, sub-index ${o}: nested array must contain only DataFrame instances.`:`Invalid input to ${e} at index ${t}, row ${o}: rows must be plain objects.`)}throw new j(`Invalid input to ${e} at index ${t}: expected DataFrame, row array, or column dictionary.`)}function qe(r,{how:e="vertical",horizontal:t}={}){if(r==null)throw new j("Invalid input to concat: rawItems cannot be null or undefined.");let n=Array.isArray(r)?r:[r],o=[];for(let i=0;i<n.length;i++)o.push(...to(n[i],"concat",i));let s=t?.strict??!0;if(o.length===0)return N._createDirect({},{},0);if(o.length===1&&e!=="horizontal")return o[0];switch(e){case"vertical":{let i=[];for(let h=0;h<o.length;h++)o[h].height>0&&i.push(o[h]);if(i.length===0)return N._createDirect({},{},0);let a=i[0],u=Object.keys(a._columns);for(let h=0;h<o.length;h++){let y=o[h];if(y.height===0)continue;let d=Object.keys(y._columns);if(u.length!==d.length)throw new j(`[Strict Vertical] Column count mismatch at index ${h}.`);for(let g=0;g<u.length;g++){if(u[g]!==d[g])throw new j(`[Strict Vertical] Schema mismatch at position ${g} in DF ${h}. Expected column "${u[g]}", but found "${d[g]}".`);let b=a.schema[u[g]],S=y.schema[u[g]];if(b&&S&&!b.equals(S))throw new Be(`[Strict Type Check] Schema type mismatch for column "${u[g]}": expected ${b.name}, found ${S.name}.`)}}let c=0;for(let h of o)c+=h.height;let l={},f=o.length;for(let h=0;h<f;h++)if(o[h].height>0){l=o[h].schema;break}Object.keys(l).length===0&&f>0&&(l=o[0].schema);let m={};for(let h of u){let y=l[h],d=!1;for(let b of o){let S=b._columns[h];if(!S){d=!0;break}if(!L(S)){for(let _=0;_<S.length;_++)if(S[_]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(c):new Array(c).fill(null);d&&L(g)&&(g=new Array(c).fill(null)),m[h]=g}let p=0;for(let h of o){let y=h.height;if(y!==0){for(let d of u){let g=h._columns[d]||new Array(y).fill(null),b=m[d];if(L(b)&&L(g))b.set(g,p);else{let S=b;for(let _=0;_<y;_++)S[p+_]=g[_]}}p+=y}}return N._createDirect(m,l,c)}case"horizontal":{let i=o[0].height;for(let l=1;l<o.length;l++)o[l].height>i&&(i=o[l].height);let a=new Set;for(let l=0;l<o.length;l++){let f=o[l];if(s&&f.height!==i)throw new z(`[Horizontal] Row count mismatch at index ${l}. Expected ${i}, got ${f.height}. Set strict=false to allow padding.`);for(let m of Object.keys(f._columns)){if(a.has(m))throw new j(`[Horizontal] Duplicate column name "${m}" detected. Horizontal concat requires unique names.`);a.add(m)}}let u={},c={};for(let l of o){let f=l.height;Object.assign(c,l.schema);let m=Object.keys(l._columns),p=m.length;for(let h=0;h<p;h++){let y=m[h],d=l._columns[y];if(f===i)u[y]=L(d)?Array.from(d):d;else{let g=new Array(i);for(let b=0;b<f;b++)g[b]=d[b];for(let b=f;b<i;b++)g[b]=null;u[y]=g}}}return N._createDirect(u,c,i)}case"diagonal":{let i=new Set;for(let m of o)for(let p of Object.keys(m._columns))i.add(p);let a=Array.from(i),u=0;for(let m=0;m<o.length;m++)u+=o[m].height;let c={};for(let m of a){let p=null;for(let h of o){let y=h.schema[m];if(y){if(p===null)p=y;else if(!p.equals(y))throw new Be(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${p.name}, found ${y.name}.`)}}c[m]=p||R.Utf8}let l={};for(let m=0;m<a.length;m++)l[a[m]]=new Array(u).fill(null);let f=0;for(let m=0;m<o.length;m++){let p=o[m],h=p.height;if(h!==0){for(let y=0;y<a.length;y++){let d=a[y],g=l[d],b=p._columns[d];if(b!==void 0)if(L(b)&&L(g))g.set(b,f);else{let S=g;for(let _=0;_<h;_++)S[f+_]=b[_]}else{let S=g;for(let _=0;_<h;_++)S[f+_]=null}}f+=h}}return N._createDirect(l,c,u)}}}tt();var N=class r{_columns;_height;_schema={};static _createDirect(e,t,n){zt(e,n);let o=Object.create(r.prototype);return o._columns=e,o._schema=t,o._height=n,o}constructor(e,t,n){if(Array.isArray(e)){let{columns:o,height:s}=Nn(e);this._columns=o,this._height=s,t?this.applySchema(t):this.inferSchema();return}if(G(e)){this._columns=e,this._height=zt(e,n),t?this.applySchema(t):this.inferSchema();return}this._columns={},this._height=0,t?this.applySchema(t):this._schema={}}inferSchema(){let e={},t=Object.keys(this._columns),n=t.length;for(let o=0;o<n;o++){let s=t[o];e[s]=ue(this._columns[s])}this.applySchema(e)}applySchema(e){this._schema=e;let t=Object.keys(e),n={};for(let o of t){let s=e[o],i=this._columns[o];n[o]=i?ge(i,s,this._height):ge(new Array(this._height).fill(null),s,this._height)}this._columns=n}get columns(){return Object.keys(this._columns)}concat(e,t={}){let n=K(e,r,{mode:"every",allowEmpty:!1})?e:[e];return qe([this,...n],t)}drop(...e){let t=new Set(e.flat()),n={},o={};for(let s of Object.keys(this._columns))t.has(s)||(n[s]=this._columns[s],o[s]=this._schema[s]);return r._createDirect(n,o,this._height)}drop_nulls(e){return this._height===0?this:this.filter(e?new I(e).is_not_null():Ke().is_not_null())}get dtypes(){let e=Object.keys(this._columns),t=e.length,n=new Array(t);for(let o=0;o<t;o++)n[o]=this._schema[e[o]];return n}explode(e,t){let n=I.toColExpr(e),o=n.colNames||[n.colName||n.outputName],s=new Set,i=o.length;for(let l=0;l<i;l++){let f=o[l];if(!f)throw new j("Expression passed to explode must have a column name.");J(f,this._columns,"Explode column"),s.add(f)}let a=Object.keys(this._columns),u=[],c=a.length;for(let l=0;l<c;l++){let f=a[l];u.push(s.has(f)?new I(f).list.explode(t):new I(f))}return this.select(...u)}fill_null(e={}){return this._height===0?this:this.with_columns(Ke().fill_null(e))}filter(...e){if(this._height===0)return r._createDirect({},this._schema,0);let t=this._height,n=Object.keys(this._columns),o=n.length,s=[],i=[],a=[],u=e.length;for(let d=0;d<u;d++){let g=e[d];typeof g=="function"?i.push(g):a.push(g)}let c=xe(a,n,void 0,this._schema,this._columns),l=c.length;for(let d=0;d<l;d++)s.push(c[d].evaluate(this._columns,t));let f=[],m=0,p=null;if(i.length>0){let d=this._columns;p={};for(let g=0;g<o;g++){let b=n[g],S=d[b];Object.defineProperty(p,b,{get(){let _=S[m];return _===void 0?null:_},enumerable:!0,configurable:!0})}}for(let d=0;d<t;d++){let g=!0;for(let b=0;b<s.length;b++)if(!s[b][d]){g=!1;break}if(g){if(p){m=d;for(let b=0;b<i.length;b++)if(!i[b](p)){g=!1;break}}g&&f.push(d)}}let h=$e(this._columns,f),y=f.length;return r._createDirect(h,this._schema,y)}get_schema(){return this._schema}groupby(e){let t=We(e),n=new Map,o=this._height,s=Re(e);for(let a=0;a<s.length;a++)J(s[a],this._columns,"Grouping key");for(let a=0;a<o;a++){let u=Ie(this._columns,s,a),c=n.get(u);c===void 0&&n.set(u,c=[]),c.push(a)}let i=Object.keys(this._columns);return new pt(n,t,i,this._columns,this._height,this._schema)}head(e=10){return this.limit(e,{offset:0,from:"start"})}get height(){return this._height}hstack(e,t={}){return this.concat(e,{how:"horizontal",horizontal:t})}insert_column(e,t,n){let o=I.toColExpr(n).alias(t),s=Object.keys(this._columns),i=s.length,a=[];for(let c=0;c<i;c++){let l=s[c];l!==t&&a.push(l)}let u=Math.max(0,Math.min(e,a.length));return a.splice(u,0,o),this.select(...a)}item(e,t){let n=this._height,o=Object.keys(this._columns),s=o.length;if(e===void 0&&t===void 0){if(n!==1||s!==1)throw new Error("DataFrame.item() can only be called without arguments if the shape is (1, 1).");return this._columns[o[0]][0]}if(e===void 0||t===void 0)throw new Error("DataFrame.item() requires both row and column to be specified if not empty.");if(e<0||e>=n)throw new Error(`Row index ${e} is out of bounds for DataFrame height ${n}.`);let i;if(typeof t=="number"){if(t<0||t>=s)throw new Error(`Column index ${t} is out of bounds for DataFrame width ${s}.`);i=o[t]}else if(i=t,this._columns[i]===void 0)throw new Error(`Column "${i}" does not exist.`);return this._columns[i][e]}*iter_columns(){let e=Object.keys(this._columns),t=e.length,n=this._columns;for(let o=0;o<t;o++)yield n[e[o]]}*iter_rows({named:e=!1}={}){let t=Object.keys(this._columns),n=t.length,o=this._columns,s=this._height,i=new Array(n);for(let a=0;a<n;a++)i[a]=o[t[a]];if(e)for(let a=0;a<s;a++){let u={};for(let c=0;c<n;c++)u[t[c]]=i[c][a];yield u}else for(let a=0;a<s;a++){let u=new Array(n);for(let c=0;c<n;c++)u[c]=i[c][a];yield u}}join(e){let{other:t,on:n,how:o="inner",suffixes:s=["","_right"]}=e,i=Re(n);for(let A=0;A<i.length;A++){let E=i[A];J(E,this._columns,"Join key"," in the left DataFrame."),J(E,t._columns,"Join key"," in the right DataFrame.")}let[a,u]=s,c=Object.keys(this._columns),l=Object.keys(t._columns),f=new Set(i),m=c.length,p=l.length,h=(A,E)=>{let v=i.length;for(let M=0;M<v;M++)if(A[i[M]][E]==null)return null;return Ie(A,i,E)},y=new Map,d=t._height,g=t._columns;for(let A=0;A<d;A++){let E=h(g,A);if(E===null)continue;let v=y.get(E);v===void 0&&(v=[],y.set(E,v)),v.push(A)}let b=this._height,S=this._columns,_=[],w=[],D=o==="outer"||o==="right",k=D?new Set:null;for(let A=0;A<b;A++){let E=h(S,A),v=E===null?void 0:y.get(E);if(v===void 0)(o==="left"||o==="outer")&&(_.push(A),w.push(null));else for(let M=0;M<v.length;M++){let Y=v[M];D&&k.add(Y),_.push(A),w.push(Y)}}if(D)for(let A=0;A<d;A++)k.has(A)||(_.push(-1),w.push(A));let W=_.length,ce={},fe={};for(let A=0;A<m;A++){let E=c[A],v=E in t._columns&&!f.has(E)?`${E}${a}`:E,M=this._columns[E],Y=f.has(E),ne=new Array(W);if(Y){let Z=t._columns[E];for(let ae=0;ae<W;ae++){let Xn=_[ae];if(Xn!==-1)ne[ae]=M[Xn];else{let Qn=w[ae];ne[ae]=Qn!==null?Z[Qn]:null}}}else for(let Z=0;Z<W;Z++){let ae=_[Z];ne[Z]=ae!==-1?M[ae]:null}ce[v]=ne,this._schema[E]&&(fe[v]=this._schema[E])}for(let A=0;A<p;A++){let E=l[A];if(!f.has(E)){let v=E in this._columns?`${E}${u}`:E,M=t._columns[E],Y=new Array(W);for(let ne=0;ne<W;ne++){let Z=w[ne];Y[ne]=Z!==null?M[Z]:null}ce[v]=Y,t._schema[E]&&(fe[v]=t._schema[E])}}return r._createDirect(ce,fe,W)}limit(e,{offset:t=0,from:n="start"}={}){let o=this._height,s=se(Math.floor(e),{min:0,max:o}),i=se(Math.floor(t),{min:0,max:o}),a=i,u=Math.min(i+s,o);n==="end"&&(u=o-i,a=Math.max(u-s,0));let c=u-a,l={},f=Object.keys(this._columns),m=f.length;for(let p=0;p<m;p++){let h=f[p];l[h]=this._columns[h].slice(a,u)}return r._createDirect(l,this._schema,c)}pivot(e){if(this._height===0)return r._createDirect({},{},0);let{index:t,columns:n,values:o}=e,s=Re(t),i=s.length;for(let w=0;w<i;w++)J(s[w],this._columns,"Pivot index key");let a=String(n),u=String(o);J(a,this._columns,"Pivot column key"),J(u,this._columns,"Pivot values key");let c=new Map,l=[],f=new Set,m=this._height,p=this._columns[a],h=this._columns[u];for(let w=0;w<m;w++){let D=Ie(this._columns,s,w);f.add(String(p[w])),c.get(D)===void 0&&(c.set(D,c.size),l.push(w))}let y=c.size,d={},g={};for(let w=0;w<i;w++){let D=s[w];d[D]=this._columns[D],this._schema[D]&&(g[D]=this._schema[D])}let b=$e(d,l),S=Array.from(f),_=this._schema[u]||R.Utf8;for(let w=0;w<S.length;w++){let D=S[w];b[D]=new Array(y).fill(null),g[D]=_}for(let w=0;w<m;w++){let D=Ie(this._columns,s,w),k=c.get(D),W=String(p[w]);b[W][k]=h[w]}return r._createDirect(b,g,y)}rename(e){let t=e||{},n={},o={},s=Object.keys(this._columns);for(let a of s){let u=t[a]||a;n[u]=this._columns[a],o[u]=this._schema[a]}if(Object.keys(n).length<s.length)throw new j("Rename collision: Multiple columns mapped to the same output name.");return r._createDirect(n,o,this._height)}reverse(){if(this._height===0)return this;let e={},t=Object.keys(this._columns),n=t.length;for(let o=0;o<n;o++){let s=t[o];e[s]=this._columns[s].slice().reverse()}return r._createDirect(e,this._schema,this._height)}get schema(){return this._schema}select(...e){let t=this._normalizeArgs(e),n=Object.keys(this._columns),o=xe(t,n,void 0,this._schema,this._columns),s=o.length;if(s===0)return r._createDirect({},{},this._height);let i={},a={},u=new Array(s),c=new Array(s),l=new Set,f=null;for(let h=0;h<s;h++){let y=o[h],d=y.outputName||y.colName||"*";if(l.has(d))throw new j(`Duplicate column selection: "${d}" is selected multiple times.`);l.add(d);let g=nt(y,this._columns,this._height);u[h]=g,c[h]=d;let b=g&&g.rowMap;if(b)if(f){let S=b.length;if(S!==f.length)throw new z(`Mismatched explode heights: Column "${d}" has length ${S}, but another exploded column has length ${f.length}`);for(let _=0;_<S;_++)if(b[_]!==f[_])throw new z(`Mismatched explode heights: Column "${d}" has mismatched row lengths compared to another exploded column.`)}else f=b}let m=f?f.length:this._height,p=s>0;for(let h=0;h<s;h++){let y=o[h],d=y.aggFn!=null&&(y.partitionBy==null||y.partitionBy.length===0),g=!!y.isLiteral;if(!d&&!g){p=!1;break}}for(let h=0;h<s;h++){let y=c[h],d=u[h],g=d,b=g&&g.rowMap,S=T(d)?d.length:0,_=f&&!b?this._height:m;if(S!==_)throw new z(`Column height mismatch: Column "${y}" has length ${S}, but expected ${_}`);if(f&&!b){let w=f.length;if(L(d)){let D=new g.constructor(w);for(let k=0;k<w;k++)D[k]=g[f[k]];d=D}else{let D=new Array(w);for(let k=0;k<w;k++)D[k]=g[f[k]];d=D}}u[h]=d}p&&(m=1);for(let h=0;h<s;h++){let y=o[h],d=c[h],g=u[h],b=y.colName||d,_=y instanceof I&&y.ops.length===0&&!y.isWindow&&!y.aggFn&&this._schema[b]||ue(g);a[d]=_,i[d]=ge(g,_,m)}return r._createDirect(i,a,m)}get shape(){return[this.height,this.width]}slice(e,t){let n=this._height,o=e<0?Math.max(n+e,0):Math.min(e,n),s=t===void 0?n:t<0?Math.max(n+t,0):Math.min(t,n),i=Math.max(s-o,0);return this.limit(i,{offset:o})}sort(e){if(!e||!e.by||this._height===0)return this;let{by:t,descending:n=!1,nullsLast:o=!0,custom:s}=e,i=We(t);for(let h=0;h<i.length;h++){let y=I.toColExpr(i[h]);y.colName&&J(y.colName,this._columns,"Sort key")}let a=Array.isArray(n)?n:new Array(i.length).fill(n),u=i.length,c=new Array(u);for(let h=0;h<u;h++){let y=i[h],d=a[h]?-1:1,g=s&&typeof y=="string"?s[y]:null,b=I.toColExpr(y).evaluate(this._columns,this._height);c[h]={values:b,isDesc:d,customComp:g}}let l=c.length,f=o?1:-1,m=new Array(this._height);for(let h=0;h<this._height;h++)m[h]=h;m.sort((h,y)=>{for(let d=0;d<l;d++){let{values:g,isDesc:b,customComp:S}=c[d],_=g[h],w=g[y];if(S){let k=S(_,w);if(k!==0)return k*b;continue}if(_==null||w==null){if(_===w)continue;return(_==null?1:-1)*f}if(_===w)continue;return(_<w?-1:1)*b}return 0});let p=$e(this._columns,m);return r._createDirect(p,this._schema,this._height)}tail(e=10){return this.limit(e,{offset:0,from:"end"})}to_dict(){return{...this._columns}}to_dicts(){return vn(this._columns,this._height)}to_list(e){if(this._height===0)return[];if(e==null)return new Array(this._height).fill(null);let n=I.toColExpr(e).evaluate(this._columns,this._height);return Array.isArray(n)?n:Array.from(n)}transpose({include_header:e=!1,header_name:t="column",column_names:n}={}){if(this._height===0){let l={},f={};return e&&(l[t]=ge([],R.Utf8,0),f[t]=R.Utf8),r._createDirect(l,f,0)}let o=this.columns;typeof n=="string"&&(J(n,this._columns,"column_names"),o=o.filter(l=>l!==n));let s=[];if(typeof n=="string"){let l=this._columns[n];s=new Array(this._height);for(let f=0;f<this._height;f++){let m=l[f];if(m==null)throw new j(`Transpose column_names column "${n}" contains null/undefined at index ${f}`);s[f]=String(m)}}else if(n!=null&&typeof n!="string"&&Symbol.iterator in Object(n)){let l=Array.from(n);if(l.length!==this._height)throw new j(`column_names length (${l.length}) must match the height of the DataFrame (${this._height})`);s=new Array(this._height);for(let f=0;f<this._height;f++)s[f]=String(l[f])}else{s=new Array(this._height);for(let l=0;l<this._height;l++)s[l]=`column_${l}`}let i=new Set;e&&i.add(t);for(let l=0;l<s.length;l++){let f=s[l];if(i.has(f))throw new j(`Duplicate column name in transposed DataFrame: "${f}"`);i.add(f)}let a=o.length,u={},c={};e&&(u[t]=ge(o,R.Utf8,a),c[t]=R.Utf8);for(let l=0;l<this._height;l++){let f=s[l],m=new Array(a);for(let h=0;h<a;h++)m[h]=this._columns[o[h]][l];let p=ue(m);u[f]=ge(m,p,a),c[f]=p}return r._createDirect(u,c,a)}unique(e){if(this._height===0)return r._createDirect({},this._schema,0);let t=We(e),n=t.length===0?Object.keys(this._columns):t.map(String);for(let c of n)J(c,this._columns,"Unique column key");let o=new Set,s=[],i=this._height;for(let c=0;c<i;c++){let l=Ie(this._columns,n,c);o.has(l)||(o.add(l),s.push(c))}let a=$e(this._columns,s),u=s.length;return r._createDirect(a,this._schema,u)}unpivot(e){let{idVars:t,valueVars:n,varName:o="variable",valueName:s="value"}=e,i=Re(t),a=Re(n),u=i.length,c=a.length;for(let h of i)J(h,this._columns,"Unpivot id variable key");for(let h of a)J(h,this._columns,"Unpivot value variable key");let l=this._height*c,f={};for(let h=0;h<u;h++)f[i[h]]=new Array(l);f[o]=new Array(l),f[s]=new Array(l);let m=0;for(let h=0;h<this._height;h++)for(let y=0;y<c;y++){let d=a[y];for(let g=0;g<u;g++){let b=i[g];f[b][m]=this._columns[b][h]}f[o][m]=d,f[s][m]=this._columns[d][h],m++}let p={};for(let h of i)p[h]=this._schema[h];return p[o]=R.Utf8,p[s]=ue(f[s]),r._createDirect(f,p,l)}vstack(e){return this.concat(e,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(e){let t=e.flat(),n=[];for(let o of t)if(typeof o=="string")n.push(new I(o));else if(I.isColExpr(o))n.push(o);else if(G(o)){let s=Object.keys(o),i=s.length;for(let a=0;a<i;a++){let u=s[a],c=o[u];if(I.isColExpr(c))n.push(c.alias(u));else{let l=new I(u);l.evaluate=(f,m)=>new Array(m).fill(c),n.push(l)}}}return n}with_columns(...e){if(e.length===0)return this;let t=this._normalizeArgs(e),n=Object.keys(this._columns),o=xe(t,n,void 0,this._schema,this._columns),s=o.length;if(s===0)return this;let i=new Map;for(let c=0;c<s;c++){let l=o[c],f=l.outputName||l.colName||"*";i.set(f,l)}let a=[],u=n.length;for(let c=0;c<u;c++){let l=n[c];a.push(i.get(l)||new I(l)),i.delete(l)}for(let c of i.values())a.push(c);return this.select(...a)}with_row_index(e="index",t=0){let n=ke(t,{mode:"independent",dtype:R.UInt32,step:1}),o=this.insert_column(0,e,n);return o._schema[e]=R.UInt32,o}write_json(e,{format:t="json",replacerOptions:n}={}){if(t!=="json"&&t!=="ndjson")throw new TypeError(`Unsupported JSON format: "${t}". Expected "json" or "ndjson".`);let o=n?.replacer===null?void 0:Ge(n),s;if(t==="ndjson"){let i=this.to_dicts(),a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=JSON.stringify(i[c],o);s=u.join(`
|
|
6
|
-
`)}else s=JSON.stringify(this.
|
|
1
|
+
"use strict";var xn=Object.defineProperty;var Bo=Object.getOwnPropertyDescriptor;var $o=Object.getOwnPropertyNames;var Ko=Object.prototype.hasOwnProperty;var R=(n,t)=>()=>(n&&(t=n(n=0)),t);var wr=(n,t)=>{for(var e in t)xn(n,e,{get:t[e],enumerable:!0})},qo=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Ko.call(n,o)&&o!==e&&xn(n,o,{get:()=>t[o],enumerable:!(r=Bo(t,o))||r.enumerable});return n};var Sr=n=>qo(xn({},"__esModule",{value:!0}),n);var et,wn,Sn,jt,Tn,_t=R(()=>{"use strict";et="*",wn="*literal*",Sn="*coalesce*",jt="*element*",Tn="*struct*"});function B(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function It(n){if(!B(n))return!1;let t=Object.getPrototypeOf(n);if(t===null)return!0;let e=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e!="function"?!1:Function.prototype.toString.call(e)===us}function Nr(n){if(typeof n!="function")return!1;let t="";try{t=Function.prototype.toString.call(n)}catch{return!1}if(/^class[\s{]/.test(t))return!0;if(n===Symbol||n===BigInt)return!1;let e=Object.getOwnPropertyDescriptor(n,"prototype");return e&&!e.writable?t.includes("[native code]"):!1}function ut(n,t,e,r){if(!B(n))return!1;if(!(Symbol.toStringTag in n))return Object.prototype.toString.call(n)===t;if(!e)return!1;try{return e.call(n,r),!0}catch{return!1}}function M(n){return ut(n,Wo,Cn)&&Cn?!Number.isNaN(Cn.call(n)):!1}function bt(n){return ut(n,Go,ss)}function Ce(n){return ut(n,zo,is)}function De(n){return ut(n,Ho,as)}function jr(n){return ut(n,Yo,ls,"key")}function _r(n){return B(n)?Symbol.toStringTag in n?n instanceof Error:Object.prototype.toString.call(n)===Jo:!1}function Dr(n){return ut(n,Er,Dn)}function Ar(n){return ut(n,Rr,An)}function Or(n){return ut(n,Ur,On)}function kr(n){return ut(n,Fr,Jt)}function Ir(n){return ut(n,Mr,Yt)}function it(n){if(!B(n))return n;switch(Object.prototype.toString.call(n)){case Rr:if(Ar(n))try{return An.call(n)}catch{}break;case Er:if(Dr(n))try{return Dn.call(n)}catch{}break;case Ur:if(Or(n))try{return On.call(n)}catch{}break;case Fr:if(kr(n)&&Jt)try{return Jt.call(n)}catch{}break;case Mr:if(Ir(n)&&Yt)try{return Yt.call(n)}catch{}break}if(Symbol.toStringTag in n){if(Ar(n))try{return An.call(n)}catch{}else if(Dr(n))try{return Dn.call(n)}catch{}else if(Or(n))try{return On.call(n)}catch{}else if(kr(n)&&Jt)try{return Jt.call(n)}catch{}else if(Ir(n)&&Yt)try{return Yt.call(n)}catch{}}if(typeof n.valueOf=="function"&&n.valueOf!==Object.prototype.valueOf)try{let e=n.valueOf();if(typeof e!="object"||e===null)return e}catch{}return n}var Wo,Go,zo,Ho,Jo,Yo,Er,Rr,Ur,Fr,Mr,Xo,Zo,Tr,Cr,Qo,ts,es,ns,rs,os,ss,is,as,Cn,ls,Dn,An,On,Jt,Yt,us,xt=R(()=>{"use strict";Wo="[object Date]",Go="[object RegExp]",zo="[object Set]",Ho="[object Map]",Jo="[object Error]",Yo="[object URLSearchParams]",Er="[object String]",Rr="[object Number]",Ur="[object Boolean]",Fr="[object BigInt]",Mr="[object Symbol]",Xo=typeof Date=="function"?Date.prototype:void 0,Zo=Object.getPrototypeOf(/./),Tr=typeof Set=="function"?Set.prototype:void 0,Cr=typeof Map=="function"?Map.prototype:void 0,Qo=typeof URLSearchParams=="function"?URLSearchParams.prototype:void 0,ts=Object.getPrototypeOf(""),es=Object.getPrototypeOf(0),ns=Object.getPrototypeOf(!0),rs=typeof BigInt=="function"?BigInt.prototype:void 0,os=typeof Symbol=="function"?Symbol.prototype:void 0,ss=Object.getOwnPropertyDescriptor(Zo,"source")?.get,is=Tr?Object.getOwnPropertyDescriptor(Tr,"size")?.get:void 0,as=Cr?Object.getOwnPropertyDescriptor(Cr,"size")?.get:void 0,Cn=Xo?.valueOf,ls=Qo?.has,Dn=ts.valueOf,An=es.valueOf,On=ns.valueOf,Jt=rs?.valueOf,Yt=os?.valueOf,us=Function.prototype.toString.call(Object)});function z(n,t){return typeof n!="number"?!1:Number.isNaN(n)?t?.allowNaN??t?.allowNonFiniteNumbers??!1:Number.isFinite(n)?!0:t?.allowNonFiniteNumbers??!1}function vr(n){for(let t=1;t<n.length;t++)if(n[t].length!==3)return!1;return!0}function $r(n,t){if(cs.test(n))return null;let e=n.trim();if(e==="")return null;e.startsWith("(")&&e.endsWith(")")&&(e="-"+e.slice(1,-1).trim());let r=e[e.length-1];(r==="-"||r==="+")&&e.length>1&&(e=r+e.slice(0,-1).trim()),t||(e=e.replace(fs,""));let o=e.includes("."),s=e.includes(",");if(o&&s){let i=e.lastIndexOf("."),a=e.lastIndexOf(","),l=a>i,c=l?".":",",u=l?a:i,f=e.slice(0,u).split(c);return f.length>1&&!vr(f)||f[0].replace(Lr,"").length>3?null:l?e.replace(Vr,"").replace(Ae,"."):e.replace(Ae,"")}if(s||o){let i=s?",":".",a=e.split(i);if(a.length>2||i===","&&a.length===2&&a[1].length===3){let l=a[0].replace(Lr,"").length;if(l===0){if(i===","||a.length>2)return null}else return l>3?null:vr(a)?e.replace(s?Ae:Vr,""):null}if(s)return e.replace(Ae,".")}return e}function K(n,{allowNonFiniteNumbers:t=!1,strictNumericString:e=!1,floatScientific:r=!0}={}){if(n==null||typeof n=="symbol")return null;switch(n=it(n),typeof n){case"number":return z(n,{allowNonFiniteNumbers:t})?n:null;case"boolean":return n?1:0;case"bigint":{let o=Number(n);return z(o,{allowNonFiniteNumbers:t})?o:null}case"object":{if(M(n)){let o=n.getTime();return z(o,{allowNonFiniteNumbers:t})?o:null}return null}case"string":{let o=$r(n,e);if(o===null)return null;if(t){let a=o.toLowerCase();if(a==="nan"||a==="-nan"||a==="+nan")return NaN;if(a==="infinity"||a==="+infinity")return 1/0;if(a==="-infinity")return-1/0}if(Br.test(o)&&!r||!Pr.test(o))return null;let i=Number(o);return z(i,{allowNonFiniteNumbers:t})?i:null}default:return null}}function Kr({locale:n="en-US",accountingNegatives:t=!1,fallback:e="NaN",formatNonFinite:r=!1,...o}={}){o.useGrouping===void 0&&(o.useGrouping=!1),o.maximumFractionDigits===void 0&&o.maximumSignificantDigits===void 0&&(o.maximumFractionDigits=20),t&&(o.currencySign="accounting",o.style===void 0&&(o.style="decimal"));let s=new Intl.NumberFormat(n,o);return i=>{if(typeof i=="bigint")return t&&i<0n?`(${s.format(-i)})`:s.format(i);let a=K(i,{allowNonFiniteNumbers:!0});return a===null||Number.isNaN(a)?e:Number.isFinite(a)?t&&a<0?`(${s.format(Math.abs(a))})`:s.format(a):r?e:t&&a===-1/0?`(${s.format(1/0)})`:String(a)}}function kn(n,{floatPrecision:t="Float64",allowNonFiniteNumbers:e=!0,floatScientific:r=!0,strictNumericString:o=!1}={}){let s=K(n,{allowNonFiniteNumbers:e,floatScientific:r,strictNumericString:o});return s===null||(t==="Float32"&&(s=Math.fround(s)),!z(s,{allowNonFiniteNumbers:e}))?null:s}function Wr(n,{range:t="Int32"}={}){if(!z(n)||!Number.isInteger(n))return!1;let e=typeof t=="string"?qr[t]:t;return n>=e.min&&n<=e.max}function pt(n,{range:t="Int32",coerce:e="truncate"}={}){let r=K(n);if(r===null)return null;switch(e){case"round":r=Math.round(r);break;case"floor":r=Math.floor(r);break;case"ceil":r=Math.ceil(r);break;case"truncate":r=Math.trunc(r);break}let o=typeof t=="string"?qr[t]:t;return ct(r,{min:o.min,max:o.max})}function vt(n,{range:t="Int64",truncate:e=!1}={}){if(n==null||typeof n=="symbol")return null;n=it(n);let r=null;if(typeof n=="bigint")r=n;else if(typeof n=="string"){let s=$r(n,!1);if(s===null||!Pr.test(s))return null;if(Br.test(s)){let i=Number(s);if(!Number.isFinite(i)||!e&&!Number.isInteger(i))return null;r=BigInt(Math.trunc(i))}else{let i=s.indexOf(".");if(i!==-1){if(!e&&/[^0]/.test(s.slice(i+1)))return null;s=s.slice(0,i)}try{r=BigInt(s)}catch{return null}}}else{let s=K(n);if(s===null||!e&&!Number.isInteger(s))return null;r=BigInt(Math.trunc(s))}let o=typeof t=="string"?ms[t]:t;return ct(r,{min:o.min,max:o.max})}function ps(n,t){let e=n-t;if(e<0||t<0)return null;if(e>15)return Number.H;let r=Math.min(t,16),o=Math.pow(10,e)-Math.pow(10,-r);return o>0?o:null}function In(n,t){let e=n.toString();if(e.includes("e")){let r=Math.pow(10,t);return Math.round(n*r)/r}return+(Math.round(+(e+"e"+t))+"e"+-t)}function Oe(n,{precision:t,scale:e}={}){let r=K(n);if(r===null)return null;let o=r;if(e!==void 0&&(o=In(o,e)),t!==void 0){let i=ps(t,e??0);i!==null&&(o=ct(o,{min:-i,max:i}))}return o}function ct(n,t){if(!t)return n;let{min:e=null,max:r=null,safe:o=!0}=t;if(e!==null&&r!==null&&e>r)return e;let s=n;if(o&&typeof s=="number"){if(Number.isNaN(s))return e!==null?e:r!==null?r:n;if(s===1/0)return r!==null?r:n;if(s===-1/0)return e!==null?e:n}return e!==null&&s<e?e:r!==null&&s>r?r:s}function Gr(n){let t=n|0;return function(){let e=t=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var Pr,cs,fs,Br,Lr,Vr,Ae,qr,ms,Xt=R(()=>{"use strict";xt();Pr=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,cs=/0[xobXOB]/,fs=/[\s_]/g,Br=/[eE]/;Lr=/^[+-]/,Vr=/\./g,Ae=/,/g;qr={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}};ms={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function L(n){if(!ArrayBuffer.isView(n))return!1;if(zr)return zr.call(n)!==void 0;let t=Object.prototype.toString.call(n);return t!=="[object DataView]"&&t.endsWith("Array]")}function O(n){return Array.isArray(n)||L(n)}function Zt(n){return n==null?[]:Array.isArray(n)?[...n]:L(n)?Array.from(n):[n]}function Lt(n){let t=Zt(n),e=t.length,r=new Array(e);for(let o=0;o<e;o++)r[o]=String(t[o]);return r}function ke(n,t,e){let r=n.length,o=t<-r||t>=r;if(o&&!e)throw new at(`Index ${t} is out of bounds for array of length ${r}`);return o?null:n.at(t)??null}function H(n,t,{mode:e="every",allowNulls:r=!1,allowEmpty:o=!0}={}){if(!O(n))return!1;let s=n.length;if(s===0)return o?e==="every":!1;let i=n,a;if(typeof t=="function")a=Nr(t)?c=>c instanceof t:t;else switch(t){case"null":a=l=>l===null;break;case"undefined":a=l=>l===void 0;break;case"nullish":a=l=>l==null;break;case"any":a=()=>!0;break;case"date":a=M;break;case"object":a=B;break;case"plainObject":a=It;break;case"number":a=z;break;default:a=l=>typeof l===t;break}if(r){let l=a;a=c=>c==null||l(c)}if(e==="every"){for(let l=0;l<s;l++)if(!a(i[l]))return!1;return!0}else{for(let l=0;l<s;l++)if(a(i[l]))return!0;return!1}}function Qt(n,{descending:t=!1,nullsLast:e=!0}={}){if(!O(n))return[];let r=n,o=r.length;if(o===0)return[];if(L(n)){let f=r.slice().sort();return t&&f.reverse(),Array.from(f)}let s=[],i=[],a=!0,l=!0,c=!0;for(let f=0;f<o;f++){let m=r[f];if(m==null)i.push(m);else if(s.push(m),c){let h=typeof m;h!=="number"&&(a=!1),h!=="string"&&(l=!1),!a&&!l&&(c=!1)}}return s.length>1&&(a?s.sort(t?(f,m)=>m-f:(f,m)=>f-m):l?s.sort(t?(f,m)=>m.localeCompare(f):(f,m)=>f.localeCompare(m)):s.sort((f,m)=>{let h=typeof f,p=typeof m;if(h!==p){let y=h<p?-1:1;return t?-y:y}return f<m?t?1:-1:f>m?t?-1:1:0})),i.length===0?s:e?s.concat(i):i.concat(s)}function N(n){if(!O(n))return Hr;let t=n.length;if(t===0)return Hr;let e=null,r=null,o=null,s=null,i=0,a=0,l=0,c=0,u=0,f=0;for(let h=0;h<t;h++){let p=n[h];if(p==null||typeof p=="number"&&!z(p,{allowNonFiniteNumbers:!0,allowNaN:!1})){a++;continue}(e==null||p<e)&&(e=p,o=h),(r==null||p>r)&&(r=p,s=h);let y=K(p);if(y!==null){let d=l+y;Math.abs(l)>=Math.abs(y)?c+=l-d+y:c+=y-d+l,l=d,i++;let g=y-u;u+=g/i;let b=y-u;f+=g*b}}let m=i>1?f/(i-1):0;return{sum:i>0?l+c:null,count:i,min:e,max:r,minIdx:o,maxIdx:s,mean:i>0?(l+c)/i:null,variance:m,std:Math.sqrt(m),nullCount:a,len:t,hasNulls:a>0,isNumeric:i>0&&i===t-a}}function wt(n,{strict:t=!1,keySelector:e}={}){let r=Array.from(n),o=new Map;if(t){let i=e??W,a=new Map,l=r.length;for(let u=0;u<l;u++){let f=r[u],m=i(f),h=a.get(m);h===void 0?a.set(m,{val:f,count:1}):h.count++}let c=[];for(let u of a.values())c.push(u.val);for(let u=0;u<l;u++){let f=r[u],m=i(f),h=a.get(m);o.set(f,h.count)}return{values:c,count:c.length,frequencies:o}}let s=r.length;for(let i=0;i<s;i++){let a=r[i];o.set(a,(o.get(a)??0)+1)}return{values:Array.from(o.keys()),count:o.size,frequencies:o}}function Yr(n,{step:t=1,offsetStart:e=0,offsetEnd:r,maxItemsGathered:o,ut:s=!0}={}){if(n==null)return null;if(o!==void 0&&o<=0)return[];if(t===0)throw new Error("Step size step cannot be zero");let i=n.length;if(i===0?e!==0:e>=i||e<-i){if(!s)throw new Error(`Start offset ${e} is out of bounds for array of length ${i}`);return null}let l=e<0?i+e:e,c=r!==void 0?r<0?i+r:r:t>0?i:-1,u=[];if(t>0)for(let f=l;f<c&&f<i&&!(f>=0&&(u.push(n[f]),o!==void 0&&u.length>=o));f+=t);else for(let f=l;f>c&&f>=0&&!(f<i&&(u.push(n[f]),o!==void 0&&u.length>=o));f+=t);return u}function Xr(n,t=",",{ignoreNulls:e=!1,nullValue:r="",prefix:o="",suffix:s="",limit:i,truncationMarker:a="...",valueFormatter:l}={}){let c=n.length,u=[],f=i!==void 0?Math.max(0,i):c,m=!1;for(let h=0;h<c;h++){if(u.length>=f){m=!0;break}let p=n[h];p!=null?u.push(l?l(p,h):String(p)):e||u.push(r)}return o+u.join(t)+(m?a:"")+s}function Et(n,t,e={}){let r=n.length,{mode:o="cumulative",step:s=1,coerce:i=y=>y,condition:a,reverse:l=!1,startIndex:c=l?r-1:0,endIndex:u=l?-1:r}=e,f=l?-1:1,m=c,h=u,p=(y,d)=>{(!a||a(n[y],y,n))&&(n[y]=i(d))};if(o==="constant"){let y=i(t);for(let d=m;l?d>h:d<h;d+=f)p(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;l?d>h:d<h;d+=f)p(d,s({index:y,initialValue:t,originalValue:n[d],absoluteIndex:d,targetArray:n})),y++}else for(let y=m;l?y>h:y<h;y+=f)p(y,t+y*s);else{let y=t,d=!0,g=0;for(let b=m;l?b>h:b<h;b+=f)d?(p(b,y),d=!1):(typeof s=="function"?y=s({prev:y,index:g,originalValue:n[b],absoluteIndex:b,targetArray:n}):y=y+s,p(b,y)),g++}}function Zr(n){let t=n.length,e=0,r=new Float64Array(t);for(let s=0;s<t;s++){let i=n[s],a=K(i,{allowNonFiniteNumbers:!0});a!==null&&z(a,{allowNonFiniteNumbers:!0,allowNaN:!1})&&(r[e++]=a)}if(e===0)return null;let o=r.subarray(0,e);return o.sort(),o}function Vt(n){let t=Zr(n);if(!t)return null;let e=t.length,r=Math.floor(e/2);return e%2!==0?t[r]:(t[r-1]+t[r])/2}function Ie(n,t){if(t<0||t>1)return null;let e=Zr(n);if(!e)return null;let r=e.length,o=t*(r-1),s=Math.floor(o),i=Math.ceil(o);return s===i?e[s]:e[s]+(o-s)*(e[i]-e[s])}function Ee(n){if(!O(n)||n.length===0)return null;let t=new Map,e=n.length,r=0,o=[];for(let s=0;s<e;s++){let i=n[s];if(i==null||typeof i=="number"&&!z(i,{allowNonFiniteNumbers:!0,allowNaN:!1}))continue;let a=(t.get(i)??0)+1;t.set(i,a),a>r?(r=a,o=[i]):a===r&&o.push(i)}return o.length===0?null:Qt(o)}function Qr(n,t){let e=n.length;if(e===0)return[];let r=Math.trunc(t);if(isNaN(r)||r===0)return Array.isArray(n)?n.slice():Array.from(n);let o=Math.abs(r);if(o>=e)return new Array(e).fill(null);let s=new Array(e);if(r>0){s.fill(null,0,r);for(let i=r;i<e;i++){let a=n[i-r];s[i]=a??null}}else{let i=e-o;for(let a=0;a<i;a++){let l=n[a+o];s[a]=l??null}s.fill(null,i,e)}return s}function En(n){let t=n.length,e=0,r=0,o=0,s=0,i=0,a=0;for(let m=0;m<t;m++){let h=n[m];if(!h)continue;let p=K(h[0]),y=K(h[1]);if(p===null||y===null)continue;e++;let d=p-r;r+=d/e;let g=p-r,b=y-o;o+=b/e;let S=y-o;a+=d*S,s+=d*g,i+=b*S}if(e<2)return{covariance:null,correlation:null};let l=a/(e-1);if(s===0||i===0)return{covariance:l,correlation:null};let c=Math.sqrt(s*i);if(c===0||Number.isNaN(c))return{covariance:l,correlation:null};let u=a/c,f=Math.max(-1,Math.min(1,u));return{covariance:l,correlation:f}}function Jr(n){let t=n.length,e=new Int32Array(t);for(let s=0;s<t;s++)e[s]=s;e.sort((s,i)=>n[s]-n[i]);let r=new Float64Array(t),o=0;for(;o<t;){let s=o+1;for(;s<t&&n[e[s]]===n[e[o]];)s++;let i=(o+1+s)/2;for(let a=o;a<s;a++)r[e[a]]=i;o=s}return r}function hs(n,t,e){if(e<2)return null;let r=0,o=0,s=0,i=0,a=0;for(let u=0;u<e;u++){let f=n[u],m=t[u],h=f-r;r+=h/(u+1);let p=f-r,y=m-o;o+=y/(u+1);let d=m-o;a+=h*d,s+=h*p,i+=y*d}if(s===0||i===0)return null;let l=Math.sqrt(s*i);if(l===0||Number.isNaN(l))return null;let c=a/l;return Math.max(-1,Math.min(1,c))}function to(n){let t=n.length,e=new Float64Array(t),r=new Float64Array(t),o=0;for(let a=0;a<t;a++){let l=n[a];if(l){let c=K(l[0]),u=K(l[1]);c!==null&&u!==null&&(e[o]=c,r[o]=u,o++)}}if(o<2)return null;let s=Jr(e.subarray(0,o)),i=Jr(r.subarray(0,o));return hs(s,i,o)}function eo(n){let t=n.length,e=0,r=0;for(let o=0;o<t;o++){let s=n[o];if(!s)continue;let i=K(s[0]),a=K(s[1]);i===null||a===null||(e+=i*a,r++)}return r>0?e:null}function no(n){let t=n.length,e=0,r=0,o=0;for(let s=0;s<t;s++){let i=n[s];if(!i)continue;let a=K(i[0]),l=K(i[1]);a===null||l===null||(e+=a*l,r+=l,o++)}return o===0||Math.abs(r)<1e-12?null:e/r}var zr,Hr,te=R(()=>{"use strict";xt();Xt();Re();rt();zr=(()=>{try{let n=new Uint8Array(0),t=Object.getPrototypeOf(n),e=Object.getPrototypeOf(t),r=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.get;return r&&r.call(n)==="Uint8Array"?r:void 0}catch{return}})();Hr={sum:null,count:0,min:null,max:null,minIdx:null,maxIdx:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function ro(n){let t=it(n);return typeof t=="string"?t.trim().length===0:!1}function Ue(n){let t=it(n);if(t==null)return"";let e=String(t);return typeof RegExp.escape=="function"?RegExp.escape(e):e.replace(ys,"\\$&")}function Pt(n,t=null,e={}){if(n==null)return e.returnStringOnNull?"":null;let{mode:r="both",returnStringOnNull:o=!1,maxScanStart:s=1,maxScanEnd:i=1,maxMatchesStart:a=1,maxMatchesEnd:l=1,trimFirst:c=!1,stringOptions:u}=e,{literal:f=!1,caseInsensitive:m=!1}=u??{},h=(T,D="both")=>D==="start"?T.trimStart():D==="end"?T.trimEnd():T.trim(),p=n;if(c&&t!=null&&(p=h(n,r)),t==null){let T=h(p,r);return o||T!==""?T:null}let y=bt(t)?T=>{try{t.lastIndex=0}catch{}return t.test(T)}:(()=>{let T=new Set(m?t.toLowerCase():t);return D=>T.has(m?D.toLowerCase():D)})(),d=p.length;if(s===1&&a===1&&i===1&&l===1&&!f){let T=0,D=d;if(r==="both"||r==="start")for(;T<d&&y(p[T]);)T++;if(r==="both"||r==="end")for(;D>T&&y(p[D-1]);)D--;let v=T===0&&D===d?p:p.substring(T,D);return o||v!==""?v:null}let b=new Uint8Array(d),S=(T,D,v)=>{if(d===0||v===0)return;let mt=T?0:d-1,lt=T?d:-1,I=T?1:-1,E=!1,P=0,q=0;for(let Y=mt;Y!==lt;Y+=I)if(y(p[Y])){if(!E){if(D!==null&&D>=0&&q>=D||v!==null&&v>=0&&P>=v)break;E=!0,P++}b[Y]=1}else if(E=!1,q++,D!==null&&D>=0&&q>=D)break},w=(T,D,v,mt,lt)=>{if(d===0||lt===0||D===0)return;let I=v?0:d-1,E=0,P=0,q=m?p.toLowerCase():p;for(;I>=0&&I<d&&!(lt!==null&<>=0&&E>=lt);){let Y=v?I:I-D+1;if(!v&&Y<0)break;let X=v?q.indexOf(T,Y):q.lastIndexOf(T,Y);if(X===-1)break;let st=v?X-I:I-(X+D-1);if(P+=st,mt!==null&&mt>=0&&P>=mt)break;for(let nt=0;nt<D;nt++)b[X+nt]=1;E++,I=v?X+D:X-1}};if(r==="both"||r==="start")if(f&&typeof t=="string"){let T=m?t.toLowerCase():t;w(T,t.length,!0,s,a)}else S(!0,s,a);if(r==="both"||r==="end")if(f&&typeof t=="string"){let T=m?t.toLowerCase():t;w(T,t.length,!1,i,l)}else S(!1,i,l);let C="";for(let T=0;T<d;T++)b[T]===0&&(C+=p[T]);return o||C!==""?C:null}function W(n,{depth:t=0,maxDepth:e=50}={}){if(t>e)return"v:circular";if(n===null)return"v:null";if(n===void 0)return"v:undefined";if(M(n))return`d:${n.getTime()}`;if(L(n))return`u:${n.constructor.name}:${n.toString()}`;if(Array.isArray(n)){let r=n.length,o=new Array(r),s={depth:t+1,maxDepth:e};for(let i=0;i<r;i++)o[i]=W(n[i],s);return`a:[${o.join(",")}]`}if(Ce(n)){let r=Array.from(n),o=r.length,s=new Array(o),i={depth:t+1,maxDepth:e};for(let a=0;a<o;a++)s[a]=W(r[a],i);return s.sort(),`set:[${s.join(",")}]`}if(De(n)){let r=Array.from(n.keys()),o=r.length,s=new Array(o),i={depth:t+1,maxDepth:e};for(let a=0;a<o;a++){let l=r[a];s[a]=`${W(l,i)}:${W(n.get(l),i)}`}return s.sort(),`map:{${s.join(",")}}`}if(typeof n=="object"&&typeof n.toJSON=="function"){let r=n.toJSON();if(r!==n)return`j:${W(r,{depth:t+1,maxDepth:e})}`}if(It(n)){let r=Object.keys(n).sort(),o=r.length,s=new Array(o),i={depth:t+1,maxDepth:e};for(let a=0;a<o;a++){let l=r[a];s[a]=`${l}:${W(n[l],i)}`}return`o:{${s.join(",")}}`}return bt(n)?`r:${n.toString()}`:typeof n=="function"?`f:${n.toString()}`:typeof n=="string"?`s:${n}`:typeof n=="symbol"?`y:${n.toString()}`:`${typeof n}:${n}`}function xs(n){if(n==null)return[];let t=String(n);if(!t)return[];let r=t.normalize("NFC").replace(ds,"$1$2").match(gs)||[],o=[];for(let s=0;s<r.length;s++){let i=r[s];bs.has(i)||o.push(i)}return o}function ee(n,t){let e=xs(n),r=e.length;if(r===0)return"";let{format:o}=t;if(o==="camel"||o==="pascal"){let s="";for(let i=0;i<r;i++){let a=e[i];s+=i===0&&o==="camel"?a.toLowerCase():a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()}return s}if(o==="kebab"||o==="snake"){let s=o==="kebab"?"-":"_",i=new Array(r);for(let a=0;a<r;a++)i[a]=e[a].toLowerCase();return i.join(s)}return String(n)}var ys,ds,gs,bs,Re=R(()=>{"use strict";xt();te();ys=/[-\/\\^$*+?.()|\[\]{}]/g;ds=/(\p{L})['’](\p{L})/gu,gs=new RegExp(["\\p{Lu}+s(?!\\p{Ll})","\\p{Lu}+(?=\\p{Lu}\\p{Ll})","\\p{Lu}+\\p{Ll}*","\\p{Ll}+","\\p{N}+","\\p{L}+"].join("|"),"gu"),bs=new Set(["__proto__","proto","constructor","prototype"])});var Rn,Un,oo=R(()=>{"use strict";Rn=1000n,Un=1000000n});function Cs(n){let t=so.get(n);return t||(t=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),so.set(n,t)),t}function Ds(n,t){let e=`${n}_${t}`,r=io.get(e);return r||(r=new Intl.DateTimeFormat(n,{timeZoneName:"short",timeZone:t}),io.set(e,r)),r}function As(n){let t=ao.get(n);if(t===void 0){try{Intl.DateTimeFormat(void 0,{timeZone:n}),t=!0}catch{t=!1}ao.set(n,t)}return t}function ht(n){let t=!n||n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n;return As(t)?t:"UTC"}function tt(n,t=0,e=1,r=0,o=0,s=0,i=0){let a=new Date(0);return a.setUTCFullYear(n,t,e),a.setUTCHours(r,o,s,i),a}function Os(n,t,e){let r=[0,3,2,5,0,3,5,1,4,6,2,4],o=n;return t<3&&(o-=1),(o+Math.floor(o/4)-Math.floor(o/100)+Math.floor(o/400)+r[t-1]+e)%7}function ne(n,t){let e=ht(t);if(e.toUpperCase()==="UTC")return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),ms:n.getUTCMilliseconds(),dayOfWeek:n.getUTCDay()};let o=Cs(e).formatToParts(n),s="0",i="0",a="0",l="0",c="0",u="0",f="0";for(let b=0,S=o.length;b<S;b++){let w=o[b];switch(w.type){case"year":s=w.value;break;case"month":i=w.value;break;case"day":a=w.value;break;case"hour":l=w.value;break;case"minute":c=w.value;break;case"second":u=w.value;break;case"fractionalSecond":f=w.value;break}}let m=parseInt(s,10),h=parseInt(i,10),p=parseInt(a,10),y=parseInt(l,10);y===24&&(y=0);let d=Math.round(parseFloat("0."+f)*1e3)||0,g=Os(m,h,p);return{year:m,month:h,day:p,hour:y,minute:parseInt(c,10),second:parseInt(u,10),ms:d,dayOfWeek:g}}function Bt(n,t,e){if(t.toUpperCase()==="UTC")return 0;let r=ne(n,"UTC"),o=e||ne(n,t),s=tt(r.year,r.month-1,r.day,r.hour,r.minute,r.second,r.ms).getTime(),i=tt(o.year,o.month-1,o.day,o.hour,o.minute,o.second,o.ms).getTime();return Math.round((i-s)/6e4)}function lo(n,t){let e=n>=0?"+":"-",r=Math.abs(n),o=String(Math.floor(r/60)).padStart(2,"0"),s=String(r%60).padStart(2,"0");return t==="iso"?`${e}${o}:${s}`:`${e}${o}${s}`}function G(n,t){let e=it(n);if(e==null)return null;let r=null;if(M(e))r=e;else if(typeof e=="number"||typeof e=="bigint")r=new Date(ks(e));else if(typeof e=="string"){if(ro(e))return null;r=new Date(e)}if(!r||!M(r))return null;if(t?.dateOnly){let o=typeof e=="string",s=o&&Ts.test(e),i=o&&!s&&!co.test(e)?"local":"UTC",a=ne(r,i);return tt(a.year,a.month-1,a.day)}return r}function Me(n){let t=it(n);if(t==null)return null;let e=null;if(typeof t=="string"){let o=t.trim();if(Ss.test(o)){let s=co.test(o);e=G(`1970-01-01T${o}${s?"":"Z"}`)}}let r=e||G(t);return r?Rt(r,{format:"%H:%M:%S.%ms"}):null}function fo(n,t="ms"){let e=n.getTime();switch(t){case"s":return Math.floor(e/1e3);case"ms":return e;case"us":return BigInt(e)*Rn;case"ns":return BigInt(e)*Un}}function ks(n){if(typeof n=="bigint"){let e=n<0n?-n:n;return e<=30000000000n?Number(n)*1e3:e<=30000000000000n?Number(n):e<=30000000000000000n?Number(n/Rn):Number(n/Un)}let t=Math.abs(n);return t<=3e10?n*1e3:t<=3e13?n:t<=3e16?Math.floor(n/1e3):Math.floor(n/1e6)}function mo(n){if(!M(n))return null;let t=n.getUTCFullYear();return Math.floor((t-1)/100)+1}function jn(n,t={field:"week"}){if(!M(n))return null;let e=tt(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r=e.getUTCDay()||7;if(e.setUTCDate(e.getUTCDate()+4-r),t.field==="year")return e.getUTCFullYear();let o=tt(e.getUTCFullYear(),0,1),s=Math.round((e.getTime()-o.getTime())/864e5);return Math.floor(s/7)+1}function po(n){if(!M(n))return null;let t=n.getUTCFullYear();return Math.floor((t-1)/1e3)+1}function Ne(n,t,e=1){return M(n)?tt(n.getUTCFullYear(),n.getUTCMonth()+t,e):null}function _n(n){if(!M(n))return null;let t=tt(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()).getTime(),e=tt(n.getUTCFullYear(),0,1).getTime();return Math.floor((t-e)/864e5)+1}function ho(n){return M(n)?Math.floor(n.getUTCMonth()/3)+1:null}function vn(n){let t;if(M(n))t=n.getUTCFullYear();else if(z(n))t=n;else return!1;return t%4===0&&t%100!==0||t%400===0}function yo(n){return n.replace(/%[FTRD]/g,t=>Es[t]||t)}function Fn(n,t){return new Date(n.getTime()-t*60*1e3)}function Rs(n){let t=n.replace(":",""),e=t[0]==="+"?1:-1,r=parseInt(t.slice(1,3),10)||0,o=parseInt(t.slice(3,5),10)||0;return e*(r*60+o)}function Rt(n,{format:t,locale:e,timeZone:r="UTC"}){if(!M(n)||typeof t!="string")return"";let o=e&&e.trim()||Intl.DateTimeFormat().resolvedOptions().locale||"en-US",s=yo(t),i=null,a=()=>i??=ne(n,r);return s.replace(Fe,(l,c)=>{if(c==="%")return"%";let u=Ln[c];return u?u.format(n,o,r,a()):l})}function go(n,{format:t,strict:e=!0,defaultTimeZone:r="UTC"}){if(typeof n!="string"||typeof t!="string")return null;let o=yo(t),s=[],i="",a=0;Fe.lastIndex=0;let l;for(;(l=Fe.exec(o))!==null;){let y=o.slice(a,l.index);i+=Ue(y);let d=l[1];if(d==="%")i+="\\%";else{let g=Ln[d];g&&g.parseRegex?(s.push(g),i+=`(${g.parseRegex})`):i+=Ue(l[0])}a=Fe.lastIndex}i+=Ue(o.slice(a));let c=new RegExp("^\\s*"+i+"\\s*$"),u=n.match(c);if(!u)return e?null:G(n);let f={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0,offset:null},m=null,h=!1;for(let y=0;y<s.length;y++){let d=u[y+1],g=s[y],b=g.parseNormalize?g.parseNormalize(d):parseInt(d,10);g.key==="j"&&(h=!0),g.parseField==="ampm"?m=b:g.parseField==="offset"?f.offset=b:g.parseField&&(f[g.parseField]=b)}if(m&&(m==="PM"&&f.hour<12&&(f.hour+=12),m==="AM"&&f.hour===12&&(f.hour=0)),h){let y=vn(f.year)?366:365;if(f.day<1||f.day>y)return null;let d=tt(f.year,0,1);d.setUTCDate(f.day),f.month=d.getUTCMonth()+1,f.day=d.getUTCDate()}let p=tt(f.year,f.month-1,f.day,f.hour,f.minute,f.second,f.ms);if(!M(p)||p.getUTCFullYear()!==f.year||p.getUTCMonth()+1!==f.month||p.getUTCDate()!==f.day||p.getUTCHours()!==f.hour||p.getUTCMinutes()!==f.minute||p.getUTCSeconds()!==f.second||p.getUTCMilliseconds()!==f.ms)return null;if(f.offset)p=Fn(p,Rs(f.offset));else if(r.toUpperCase()!=="UTC"){let y=ht(r),d=Bt(p,y);p=Fn(p,d);let g=Bt(p,y);g!==d&&(p=Fn(p,g-d))}return M(p)?p:null}function Vn(n,t,{excludeWeekdays:e=[],holidays:r=[],roll:o}={}){if(!Wr(t))throw new at(`The offset parameter 'n' must be a whole integer. Received: ${t}`);if(7-e.length<=0)throw new at("All weekdays are excluded; cannot offset.");let i=new Set;if(r instanceof Set)for(let m of r){let h=new Date(m);e.includes(h.getUTCDay())||i.add(m)}else if(Array.isArray(r))for(let m=0;m<r.length;m++){let h=G(r[m]);if(!h||e.includes(h.getUTCDay()))continue;let p=tt(h.getUTCFullYear(),h.getUTCMonth(),h.getUTCDate());i.add(p.getTime())}let a=m=>e.includes(m.getUTCDay())?!0:i.has(m.getTime()),l=tt(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate());if(o&&a(l)){if(o==="raise")throw new at("Start date falls on an excluded day or holiday.");let m=o==="forward"?1:-1;for(;a(l);)l.setUTCDate(l.getUTCDate()+m)}if(t===0)return l;let c=t>0?1:-1,u=0,f=Math.abs(t);for(;u<f;)l.setUTCDate(l.getUTCDate()+c),a(l)||u++;return l}function Pn(n,t,e){let r=ht(t),o=e?.type??"total",s;if(o==="total")s=Bt(n,r);else{let a=ne(n,r),l=a.year,c=Bt(tt(l,0,1),r),u=Bt(tt(l,6,1),r),f=Math.min(c,u);o==="daylightSavingTime"?s=Bt(n,r,a)-f:s=f}switch(e?.format??"milliseconds"){case"minutes":return s;case"hours":return s/60;case"iso":return lo(s,"iso");case"basic":return lo(s,"basic");default:return s*6e4}}function bo(n,t={}){if(!M(n))return null;let e=t.excludeWeekdays??[0,6],r=n.getUTCDay();if(e.includes(r))return!1;let o=t.holidays;if(o){if(o instanceof Set){let s=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate());if(o.has(s))return!1}else if(Array.isArray(o)&&o.length>0){let s=new Set;for(let a=0;a<o.length;a++){let l=G(o[a]);l&&s.add(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))}let i=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate());if(s.has(i))return!1}}return!0}var Ss,co,Ts,so,io,ao,Ln,Is,Fe,Es,Bn=R(()=>{"use strict";Re();rt();xt();Xt();oo();Ss=/^\d{2}:\d{2}/,co=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,Ts=/^\d{4}-\d{2}-\d{2}$/,so=new Map;io=new Map;ao=new Map;Ln={Y:{key:"Y",format:(n,t,e,r)=>{let o=r.year;return o>=0?String(o).padStart(4,"0"):"-"+String(Math.abs(o)).padStart(4,"0")},parseRegex:"[+-]?\\d{4,}",parseField:"year"},y:{key:"y",format:(n,t,e,r)=>String(Math.abs(r.year)%100).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"year",parseNormalize:n=>{let t=parseInt(n,10);return t+(t>=69?1900:2e3)}},m:{key:"m",format:(n,t,e,r)=>String(r.month).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"month"},d:{key:"d",format:(n,t,e,r)=>String(r.day).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"day"},e:{key:"e",format:(n,t,e,r)=>String(r.day).padStart(2," "),parseRegex:"\\s?\\d{1,2}",parseField:"day"},H:{key:"H",format:(n,t,e,r)=>String(r.hour).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},I:{key:"I",format:(n,t,e,r)=>String(r.hour%12||12).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},p:{key:"p",format:(n,t,e,r)=>r.hour>=12?"PM":"AM",parseRegex:"AM|PM|am|pm",parseField:"ampm",parseNormalize:n=>n.toUpperCase()},M:{key:"M",format:(n,t,e,r)=>String(r.minute).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"minute"},S:{key:"S",format:(n,t,e,r)=>String(r.second).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"second"},A:{key:"A",format:(n,t,e)=>n.toLocaleDateString(t,{weekday:"long",timeZone:ht(e)})},a:{key:"a",format:(n,t,e)=>n.toLocaleDateString(t,{weekday:"short",timeZone:ht(e)})},B:{key:"B",format:(n,t,e)=>n.toLocaleDateString(t,{month:"long",timeZone:ht(e)})},b:{key:"b",format:(n,t,e)=>n.toLocaleDateString(t,{month:"short",timeZone:ht(e)})},h:{key:"h",format:(n,t,e)=>n.toLocaleDateString(t,{month:"short",timeZone:ht(e)})},j:{key:"j",format:(n,t,e,r)=>String(_n(tt(r.year,r.month-1,r.day))??1).padStart(3,"0"),parseRegex:"\\d{3}",parseField:"day",parseNormalize:n=>parseInt(n,10)},u:{key:"u",format:(n,t,e,r)=>String(r.dayOfWeek||7)},w:{key:"w",format:(n,t,e,r)=>String(r.dayOfWeek)},Z:{key:"Z",format:(n,t,e)=>{let r=ht(e);if(r.toUpperCase()==="UTC")return"UTC";let o=Ds(t,r).formatToParts(n);for(let s=0,i=o.length;s<i;s++)if(o[s].type==="timeZoneName")return o[s].value;return"UTC"}},z:{key:"z",format:(n,t,e)=>Pn(n,e,{format:"basic"}),parseRegex:"[+-]\\d{2}(?::?\\d{2})?",parseField:"offset",parseNormalize:n=>n.replace(":","")},ms:{key:"ms",format:(n,t,e,r)=>String(r.ms).padStart(3,"0"),parseRegex:"\\d{3}",parseField:"ms",parseNormalize:n=>parseInt(n,10)},f:{key:"f",format:(n,t,e,r)=>String(r.ms).padStart(3,"0").padEnd(6,"0"),parseRegex:"\\d{1,9}",parseField:"ms",parseNormalize:n=>parseInt(n.padEnd(6,"0").slice(0,3),10)}},Is=Object.keys(Ln).concat("%").sort((n,t)=>t.length-n.length),Fe=new RegExp("%("+Is.join("|")+")","g"),Es={"%F":"%Y-%m-%d","%T":"%H:%M:%S","%R":"%H:%M","%D":"%m/%d/%y"}});function xo(n,{format:t="json",allowPrimitives:e=!1,trimBeforeParse:r=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:i,skipLines:a}={},guard:l,onError:c,fallback:u=re}={}){if(typeof n!="string")return u!==re?u:n;let f=r?n.trim():n;if(f==="")return u!==re?u:n;let m;try{if(t==="ndjson"){let h=[],p=0,y=0,d=0;$n.lastIndex=0;let g;for(;;){g=$n.exec(f);let b=g?f.substring(d,g.index):f.substring(d);g&&(d=$n.lastIndex);let S=b.trim();if(S!==""&&(p++,a===void 0||p>a))if(!e&&!Us(S)){if(!s)throw new Error("NDJSON line is not wrapped and primitives are disallowed")}else try{if(h.push(JSON.parse(S,o)),y++,i!==void 0&&y>=i)break}catch(w){if(!s)throw w}if(!g)break}if(h.length===0)throw new Error("No valid NDJSON lines processed");m=h}else{if(!e&&!Fs(f))throw new Error("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(f,o)}}catch(h){return c?.(h),u!==re?u:n}return l&&!l(m)?(c?.(new Error("Parsed value failed guard validation")),u!==re?u:n):m}function oe(n={}){let t=n.bigintStrategy??"string",e=n.handleCircular?new WeakSet:null,o=Array.isArray(n.replacer)?n.replacer.map(String):null,s=i=>t==="number"&&i<=BigInt(Number.H)&&i>=BigInt(Number.ct)?Number(i):i.toString();return function(a,l){let c=l;if(typeof n.replacer=="function")c=n.replacer.call(this,a,l);else if(o&&a!==""&&!Array.isArray(this)&&!o.includes(a))return;if(c===void 0)return;let u=c===l&&this!=null?this[a]:c;if(typeof n.onCustom=="function"){let f=n.onCustom.call(this,a,u);if(f!==u||f===void 0&&u!==void 0)return f}if(u!==null&&typeof u!="object"&&typeof u!="bigint")return c;if(e&&u!==null&&typeof u=="object"){if(a===""&&(e=new WeakSet),e.has(u))return n.onCircular?n.onCircular.call(this,a,u):"[Circular]";e.add(u)}return typeof u=="bigint"?n.voidBigIntReplacement?c:n.onBigInt?n.onBigInt(u):s(u):L(u)?n.voidTypedArrayReplacement?c:n.onTypedArray?n.onTypedArray(u):Array.from(u):Ce(u)?n.voidSetReplacement?c:n.onSet?n.onSet(u):Array.from(u):De(u)?n.voidMapReplacement?c:n.onMap?n.onMap(u):Array.from(u.entries()):bt(u)?n.voidRegExpReplacement?c:n.onRegExp?n.onRegExp(u):u.toString():M(u)?n.voidDateReplacement?c:n.onDate?n.onDate(u):n.formatDate?n.formatDate(u):u.toISOString():_r(u)?n.onError?n.onError(u):{name:u.name,message:u.message,stack:u.stack}:jr(u)?n.onURLSearchParams?n.onURLSearchParams(u):u.toString():c}}var $n,re,Us,Fs,je=R(()=>{"use strict";te();xt();$n=/\r\n|\n|\r/g,re=Symbol("no_fallback"),Us=n=>{let t=n.length;if(t<2)return!1;let e=n[0],r=n[t-1];return e==="{"&&r==="}"||e==="["&&r==="]"},Fs=n=>{let t=0,e=n.length;for(;t<e&&/\s/.test(n[t]);)t++;let r=e-1;for(;r>=t&&/\s/.test(n[r]);)r--;if(t>=r)return!1;let o=n[t],s=n[r];return o==="{"&&s==="}"||o==="["&&s==="]"}});var Z,Ut,se,St,Tt,$t,Ct,Kt,_e=R(()=>{"use strict";Z=class n{matches(t){if(t==null)return!1;if(t instanceof n)return!!(this.equals(t)||this.name.startsWith("Decimal")&&t.name.startsWith("Decimal")&&t.precision===void 0&&t.scale===void 0);if(typeof t=="function"){if(t.prototype instanceof n)return this instanceof t;try{let e=t();if(e instanceof n)return this.constructor===e.constructor}catch{}}return!1}get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},Ut=class extends Z{get isNumeric(){return!0}},se=class extends Ut{get isInteger(){return!0}},St=class extends se{get isSigned(){return!0}},Tt=class extends se{get isUnsigned(){return!0}},$t=class extends Ut{get isFloat(){return!0}},Ct=class extends Z{get isTemporal(){return!0}},Kt=class extends Z{get isNested(){return!0}}});var ve,Kn,Le,qn,Ve,Wn,Pe,ae,Be,Gn,$e,zn,Ke,Hn,qe,Jn,We,Yn,Ge,le,ie,ze,ue,He,qt,Je,Xn,Ye,Zn,Xe,Qn,Ze,tr,Qe,ce,tn,er,en,nr,nn,rr,rn,or,sr=R(()=>{"use strict";_e();$();ve=class extends St{name="Int8";coerce(t){return pt(t,{range:"Int8"})}equals(t){return t.name==="Int8"}allocate(t){return new Int8Array(t)}},Kn=new ve,Le=class extends St{name="Int16";coerce(t){return pt(t,{range:"Int16"})}equals(t){return t.name==="Int16"}allocate(t){return new Int16Array(t)}},qn=new Le,Ve=class extends St{name="Int32";coerce(t){return pt(t,{range:"Int32"})}equals(t){return t.name==="Int32"}allocate(t){return new Int32Array(t)}},Wn=new Ve,Pe=class extends St{name="Int64";coerce(t){return vt(t,{truncate:!0})}equals(t){return t.name==="Int64"}allocate(t){return new BigInt64Array(t)}},ae=new Pe,Be=class extends Tt{name="UInt8";coerce(t){return pt(t,{range:"UInt8"})}equals(t){return t.name==="UInt8"}allocate(t){return new Uint8Array(t)}},Gn=new Be,$e=class extends Tt{name="UInt16";coerce(t){return pt(t,{range:"UInt16"})}equals(t){return t.name==="UInt16"}allocate(t){return new Uint16Array(t)}},zn=new $e,Ke=class extends Tt{name="UInt32";coerce(t){return pt(t,{range:"UInt32"})}equals(t){return t.name==="UInt32"}allocate(t){return new Uint32Array(t)}},Hn=new Ke,qe=class extends Tt{name="UInt64";coerce(t){return vt(t,{range:"UInt64"})}equals(t){return t.name==="UInt64"}allocate(t){return new BigUint64Array(t)}},Jn=new qe,We=class extends $t{name="Float32";coerce(t){return kn(t,{floatPrecision:"Float32"})}equals(t){return t.name==="Float32"}allocate(t){return new Float32Array(t)}},Yn=new We,Ge=class extends $t{name="Float64";coerce(t){return kn(t,{floatPrecision:"Float64"})}equals(t){return t.name==="Float64"}allocate(t){return new Float64Array(t)}},le=new Ge,ie=class n extends Ut{constructor(e,r){super();this.precision=e;this.scale=r;this.name=e!==void 0&&r!==void 0?`Decimal(${e}, ${r})`:"Decimal"}precision;scale;name;coerce(e){return Oe(e,{precision:this.precision,scale:this.scale})}equals(e){return e instanceof n&&this.precision===e.precision&&this.scale===e.scale}allocate(e){return new Array(e).fill(null)}},ze=class extends Z{name="Boolean";get isBoolean(){return!0}coerce(t){return t==null?null:!!t}equals(t){return t.name==="Boolean"}allocate(t){return new Array(t).fill(null)}},ue=new ze,He=class extends Z{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(t){return t==null?null:String(t)}equals(t){return t.name==="Utf8"}allocate(t){return new Array(t).fill(null)}},qt=new He,Je=class extends Z{name="Binary";get isBinary(){return!0}coerce(t){return wo(t)}equals(t){return t.name==="Binary"}allocate(t){return new Array(t).fill(null)}},Xn=new Je,Ye=class extends Z{name="Null";get isNull(){return!0}coerce(t){return null}equals(t){return t.name==="Null"}allocate(t){return new Array(t).fill(null)}},Zn=new Ye,Xe=class extends Z{name="Object";get isObject(){return!0}coerce(t){return t===void 0?null:t}equals(t){return t.name==="Object"}allocate(t){return new Array(t).fill(null)}},Qn=new Xe,Ze=class extends Ct{name="Date";coerce(t){return G(t,{dateOnly:!0})}equals(t){return t.name==="Date"}allocate(t){return new Array(t).fill(null)}},tr=new Ze,Qe=class extends Ct{name="Datetime";coerce(t){return G(t)}equals(t){return t.name==="Datetime"}allocate(t){return new Array(t).fill(null)}},ce=new Qe,tn=class extends Ct{name="Time";coerce(t){return Me(t)}equals(t){return t.name==="Time"}allocate(t){return new Array(t).fill(null)}},er=new tn,en=class extends Ct{name="Duration";coerce(t){return K(t)}equals(t){return t.name==="Duration"}allocate(t){return new Array(t).fill(null)}},nr=new en,nn=class n extends Kt{constructor(e){super();this.innerType=e}innerType;name="Array";coerce(e){if(e==null)return null;let r=O(e)?Array.from(e):[e],o=r.length,s=new Array(o);for(let i=0;i<o;i++)s[i]=this.innerType.coerce(r[i]);return s}equals(e){return e instanceof n&&this.innerType.equals(e.innerType)}allocate(e){return new Array(e).fill(null)}},rr=n=>new nn(n),rn=class n extends Kt{constructor(e){super();this.fields=e}fields;name="Struct";coerce(e){if(!B(e))return null;let r={},o=Object.keys(this.fields),s=o.length;for(let i=0;i<s;i++){let a=o[i],l=this.fields[a];r[a]=l.coerce(e[a])}return r}equals(e){if(!(e instanceof n))return!1;let r=Object.keys(this.fields),o=Object.keys(e.fields);if(r.length!==o.length)return!1;for(let s=0;s<r.length;s++){let i=r[s];if(!this.fields[i].equals(e.fields[i]))return!1}return!0}allocate(e){return new Array(e).fill(null)}},or=n=>new rn(n)});var F,Dt=R(()=>{"use strict";_e();sr();sr();_e();F={Int8:Kn,Int16:qn,Int32:Wn,Int64:ae,UInt8:Gn,UInt16:zn,UInt32:Hn,UInt64:Jn,Float32:Yn,Float64:le,Decimal:(n,t)=>new ie(n,t),Boolean:ue,Utf8:qt,Binary:Xn,Date:tr,Datetime:ce,Time:er,Duration:nr,Object:Qn,Null:Zn,Array:rr,Struct:or}});function Ns(n={}){let t=n.nullValue!==void 0?n.nullValue:"",e=Kr(n.numericFormatOptions),r=n.replacerOptions||{},o=a=>n.datetimeFormat?Rt(a,{format:n.datetimeFormat}):n.dateFormat?Rt(a,{format:n.dateFormat}):n.timeFormat?Rt(a,{format:n.timeFormat}):a.toISOString(),s=oe({formatDate:o,...r}),i=typeof r.onBigInt=="function";return a=>{if(a==null||typeof a=="symbol"||typeof a=="function")return{str:t,isNumeric:!1};if(typeof a=="bigint"&&!i&&!r.voidBigIntReplacement)return{str:e(a),isNumeric:!0};let l=s.call(null,"",a),c=it(l);return c==null||typeof c=="symbol"||typeof c=="function"?{str:t,isNumeric:!1}:typeof c=="string"?{str:c,isNumeric:!1}:typeof c=="number"||typeof c=="bigint"?{str:e(c),isNumeric:!0}:typeof c=="boolean"?{str:c?"true":"false",isNumeric:!1}:typeof c=="object"?{str:JSON.stringify(c,oe({formatDate:o,...r})),isNumeric:!1}:{str:String(c),isNumeric:!1}}}function sn(n,t,e={}){let{separator:r=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:i=`
|
|
2
|
+
`,quoteStyle:a="necessary",includeBom:l=!1,onRow:c,...u}=e,f=Object.keys(n),m=f.length,h=[],p=!0,y=Ns(u),d=(b,S=!1)=>{let w,C=!1;if(S)w=String(b);else{let D=y(b);w=D.str,C=D.isNumeric}if(a==="never")return w;if(a==="always"){let D=w.split(o).join(o+o);return o+D+o}if(a==="non_numeric"&&!C&&b!=null){let D=w.split(o).join(o+o);return o+D+o}if(w.includes(r)||w.includes(o)||w.includes(`
|
|
3
|
+
`)||w.includes("\r")){let D=w.split(o).join(o+o);return o+D+o}return w},g=b=>{if(p){let S=l?"\uFEFF"+b:b;c?c(S):h.push(S),p=!1}else c?c(i+b):h.push(b)};if(s){let b=new Array(m);for(let S=0;S<m;S++)b[S]=d(f[S],!0);g(b.join(r))}for(let b=0;b<t;b++){let S=new Array(m);for(let w=0;w<m;w++)S[w]=d(n[f[w]][b],!1);g(S.join(r))}return c?l?"\uFEFF":"":h.join(i)}function So(n,t={}){let e=t.separator||",",r=t.quoteChar||'"',o=n;o.startsWith("\uFEFF")&&(o=o.substring("\uFEFF".length));let s=[],i=[],a="",l=!1,c=!1,u=!1,f=o.length;for(let m=0;m<f;m++){let h=o[m];if(l)c=!0,u=!1,h===r?m+1<f&&o[m+1]===r?(a+=r,m++):l=!1:a+=h;else if(h===r)c=!0,u=!1,l=!0;else if(h===e)i.push(a),a="",u=!0;else{let p=!1;h==="\r"?(p=!0,m+1<f&&o[m+1]===`
|
|
4
|
+
`&&m++):h===`
|
|
5
|
+
`&&(p=!0),p?(c||i.length>0||a!==""||u)&&(i.push(a),s.push(i),i=[],a="",c=!1,u=!1):(c=!0,u=!1,a+=h)}}return(c||i.length>0||a!==""||u)&&(i.push(a),s.push(i)),s}function To(n,t={}){let e=new Set(t.nullValues??["","NA","null","NaN"]),r=n.length,o=!0,s=!0,i=!0,a=!0,l=!1;for(let u=0;u<r;u++){let f=n[u].trim();if(!e.has(f)){if(l=!0,o){let m=f.toLowerCase();m!=="true"&&m!=="false"&&m!=="1"&&m!=="0"&&(o=!1)}if(i&&vt(f,{truncate:!1})===null&&(i=!1),s&&K(f,{allowNonFiniteNumbers:!0})===null&&(s=!1),a&&G(f)===null&&(a=!1),!o&&!s&&!i&&!a)break}}let c=new Array(r);if(!l||!o&&!s&&!i&&!a){for(let u=0;u<r;u++){let f=n[u];c[u]=e.has(f.trim())?null:f}return{type:qt,values:c}}if(o){for(let u=0;u<r;u++){let f=n[u].trim();if(e.has(f))c[u]=null;else{let m=f.toLowerCase();c[u]=m==="true"||m==="1"}}return{type:ue,values:c}}if(i){for(let u=0;u<r;u++){let f=n[u].trim();c[u]=e.has(f)?null:vt(f,{truncate:!1})}return{type:ae,values:c}}if(s){for(let u=0;u<r;u++){let f=n[u].trim();c[u]=e.has(f)?null:K(f,{allowNonFiniteNumbers:!0})}return{type:le,values:c}}if(a){for(let u=0;u<r;u++){let f=n[u].trim();c[u]=e.has(f)?null:G(f)}return{type:ce,values:c}}return{type:qt,values:c}}var Co=R(()=>{"use strict";Bn();je();Xt();Dt();xt()});function js(n){return n==null?!1:typeof n=="string"||L(n)?!0:Array.isArray(n)}function wo(n){return js(n)?Object.prototype.toString.call(n)==="[object Uint8Array]"?n:typeof n=="string"?new TextEncoder().encode(n):L(n)?new Uint8Array(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)):new Uint8Array(n):null}var Do=R(()=>{"use strict";te()});var $=R(()=>{"use strict";xt();Xt();Bn();te();Re();je();Co();Do()});function Q(n,t,e,r=""){if(!(n in t))throw new yt(n,`${e} "${n}" does not exist${r}`)}function an(n,t){let e=Object.keys(n),r=e.length,o=t;for(let s=0;s<r;s++){let i=e[s],a=n[i],l=O(a)?a.length:0;if(o===void 0)o=l;else if(l!==o)throw new J(`Column height mismatch: Column "${i}" has length ${l}, but DataFrame height is ${o}`)}return o===void 0?0:o}var Ao=R(()=>{"use strict";rt();$()});var Ft,V,yt,Wt,at,J,rt=R(()=>{"use strict";Ao();Ft=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},V=class extends Ft{},yt=class extends V{constructor(t,e){super(e||`Column "${t}" does not exist in the DataFrame.`)}},Wt=class extends Ft{},at=class extends Ft{},J=class extends Ft{}});function vs(n,t,e){let r=new Map,o=e.length,s=new Array(o);for(let i=0;i<o;i++){let a=e[i];typeof a=="string"?(Q(a,n,"Partition key"," in the DataFrame."),s[i]=n[a]):s[i]=a.evaluate(n,t)}if(o===1){let i=s[0];for(let a=0;a<t;a++){let l=i[a],c=l==null?"":W(l),u=r.get(c);u===void 0&&(u=[],r.set(c,u)),u.push(a)}return r}for(let i=0;i<t;i++){let a=new Array(o);for(let u=0;u<o;u++){let f=s[u][i];a[u]=f==null?"":W(f)}let l=a.join("\0"),c=r.get(l);c===void 0&&(c=[],r.set(l,c)),c.push(i)}return r}function ar(n,t,e){let r=new Array(e);if(e===0)return r;let o=n.p||[],s=vs(t,e,o),i=n.U(n.T,t,e);for(let a of s.values()){let l=a.length,c=new Array(l);for(let u=0;u<l;u++)c[u]=i[a[u]];if(n.b){for(let u=0;u<l;u++)r[a[u]]=n.b(c,a,u);continue}if(n.m){let u=n.m(c);for(let f=0;f<l;f++)r[a[f]]=u;continue}for(let u=0;u<l;u++)r[a[u]]=i[a[u]]}return n.v(n.T,r,t)}function lr(n){if(!Array.isArray(n)||n.length===0)return{columns:{},height:0};let t=n.length,e=new Set;for(let s=0;s<t;s++){let i=n[s];if(B(i)){let a=Object.keys(i);for(let l=0;l<a.length;l++)e.add(a[l])}}let r=Array.from(e),o={};for(let s=0;s<r.length;s++)o[r[s]]=new Array(t);for(let s=0;s<t;s++){let i=n[s]||{};for(let a=0;a<r.length;a++){let l=r[a],c=i[l];o[l][s]=c===void 0?null:c}}return{columns:o,height:t}}function ur(n,t){let e=Object.keys(n),r=new Array(t);for(let o=0;o<t;o++){let s={};for(let i=0;i<e.length;i++){let a=e[i],l=n[a][o];s[a]=l===void 0?null:l}r[o]=s}return r}function Ls(n,t,e){let r={};for(let o=0;o<e.length;o++){let s=e[o],i=n[s][t];r[s]=i===void 0?null:i}return r}function dt(n){if(n.length===0)return F.Utf8;let t=!0,e=!0,r=!0,o=!0,s=!0,i=!0,a=!0,l=!0,c=!1,u=!1,f=[];for(let m=0;m<n.length;m++){let h=n[m];if(h!=null){if(u=!0,h instanceof Uint8Array||(a=!1),!O(h)||h instanceof Uint8Array)i=!1;else{let p=h,y=p.length;for(let d=0;d<y;d++)f.push(p[d])}M(h)&&(c=!0),typeof h!="boolean"&&(t=!1),typeof h!="bigint"&&(o=!1),typeof h!="number"?(r=!1,e=!1):Number.isInteger(h)||(e=!1),!M(h)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(s=!1),(!B(h)||h instanceof Uint8Array)&&(l=!1)}}if(!u)return F.Utf8;if(a)return F.Binary;if(i){let m=dt(f);return F.Array(m)}if(t)return F.Boolean;if(o)return F.Int64;if(r&&!e)return F.Float64;if(r&&e){let m=!0;for(let h=0;h<n.length;h++){let p=n[h];if(p!=null&&(p<-2147483648||p>2147483647)){m=!1;break}}return m?F.Int32:F.Float64}return s&&c?F.Datetime:l?F.Object:F.Utf8}function Gt(n,t){let e=Object.keys(n),r=e.length,o=t.length,s={};for(let i=0;i<r;i++){let a=e[i],l=n[a],c=L(l)?new l.constructor(o):new Array(o);for(let u=0;u<o;u++)c[u]=l[t[u]];s[a]=c}return s}function Mt(n,t,e){let r=t.length;if(r===1){let s=n[t[0]][e];return s==null?"":W(s)}let o=new Array(r);for(let s=0;s<r;s++){let i=n[t[s]][e];o[s]=i==null?"":W(i)}return o.join("\0")}function At(n,t,e){let r=t.allocate?t.allocate(e):new Array(e);if(L(r)){let s=r;for(let i=0;i<e;i++){let a=t.coerce(n[i]);if(a==null){let l=new Array(e);for(let c=0;c<i;c++)l[c]=s[c];l[i]=null;for(let c=i+1;c<e;c++)l[c]=t.coerce(n[c]);return l}s[i]=a}}else for(let s=0;s<e;s++)r[s]=t.coerce(n[s]);return r}function cr(n,t){if(n)if(typeof n=="string"){if(typeof require!="function")throw new Error("File writing is not supported in this environment (missing require('fs')).");require("fs").writeFileSync(n,t,"utf8")}else if(B(n)&&typeof n.write=="function")n.write(t);else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}var ln=R(()=>{"use strict";Dt();$();rt()});function Ot(n,t,e){return n.P?ar(n,t,e):n.evaluate(t,e)}var A,U,gt=R(()=>{"use strict";$();ln();A=n=>t=>{let e=t.length,r=new Array(e);for(let o=0;o<e;o++){let s=t[o];r[o]=s==null?null:n(s)}return r},U=(n,t,e)=>(r,o)=>{let s=r.length,i=n.y(t,o,s),a=new Array(s);if(O(i))for(let l=0;l<s;l++){let c=r[l],u=i[l];a[l]=c==null||u==null?null:e(c,u)}else for(let l=0;l<s;l++){let c=r[l];a[l]=c==null||i==null?null:e(c,i)}return a}});var x,j,ot=R(()=>{"use strict";rt();gt();x=(n,t)=>{let e=n.constructor,r=n.C||n.u||"",o=new e(r);return Object.assign(o,n),o.c=t?[...n.c,t]:[...n.c],o},j=class n{c=[];f="";N;L;m=null;d;T;p=null;b;v(t,e,r){let o=this.c,s=t!==void 0?t:o.length,i=e;for(let a=s;a<o.length;a++)i=o[a](i,r);return i}U(t,e,r){let o=this.Y(e,r),s=this.c,i=t!==void 0?t:s.length;for(let a=0;a<i;a++)o=s[a](o,e);return o}Y(t,e){let r=this.u;if(r&&r!=="*"&&!r.startsWith("*")&&!(r in t))throw new yt(r);return(r&&r!=="*"?t[r]:null)||new Array(e).fill(null)}y(t,e,r){return t instanceof n?t.N&&t.c.length===1?t.L:Ot(t,e,r):t}alias(t){let e=x(this);return e.f=t,e}cast(t){return x(this,e=>{let r=e.length,o=new Array(r);for(let s=0;s<r;s++)o[s]=t.coerce(e[s]);return o})}debug(t){return x(this,e=>(console.log(`[DEBUG] ${t?t+": ":""}`,e),e))}evaluate(t,e){return this.U(void 0,t,e)}}});var fe,Oo=R(()=>{"use strict";ot();gt();$();fe=class extends j{abs(){return x(this,A(Math.abs))}acos(){return x(this,A(t=>t<-1||t>1?null:Math.acos(t)))}acosh(){return x(this,A(t=>t<1?null:Math.acosh(t)))}add(t){return x(this,U(this,t,(e,r)=>e+r))}asin(){return x(this,A(t=>t<-1||t>1?null:Math.asin(t)))}asinh(){return x(this,A(Math.asinh))}atan(){return x(this,A(Math.atan))}atan2(t){return x(this,U(this,t,Math.atan2))}atanh(){return x(this,A(t=>t<=-1||t>=1?null:Math.atanh(t)))}cbrt(){return x(this,A(Math.cbrt))}ceil(){return x(this,A(Math.ceil))}clip(t=null,e=null){return x(this,A(r=>ct(r,{min:t,max:e})))}copysign(t){return x(this,U(this,t,(e,r)=>Math.abs(e)*(r>=0?1:-1)))}cos(){return x(this,A(Math.cos))}cosh(){return x(this,A(Math.cosh))}degrees(){return x(this,A(t=>t*(180/Math.PI)))}div(t){return x(this,U(this,t,(e,r)=>r===0?null:e/r))}exp(){return x(this,A(Math.exp))}expm1(){return x(this,A(Math.expm1))}floor(){return x(this,A(Math.floor))}floordiv(t){return x(this,U(this,t,(e,r)=>r===0?null:Math.floor(e/r)))}hypot(t){return x(this,U(this,t,Math.hypot))}log(t=Math.E){return x(this,A(e=>e<=0?null:t===Math.E?Math.log(e):Math.log(e)/Math.log(t)))}log1p(){return x(this,A(t=>t<=-1?null:Math.log1p(t)))}mod(t){return x(this,U(this,t,(e,r)=>r===0?null:e%r))}mul(t){return x(this,U(this,t,(e,r)=>e*r))}negate(){return x(this,A(t=>-t))}pow(t){return x(this,U(this,t,Math.pow))}radians(){return x(this,A(t=>t*(Math.PI/180)))}rand(t,{min:e=0,max:r=1,integer:o=!1}={}){return x(this,s=>{let i=s.length,a=new Float64Array(i),l=t!==void 0?Gr(t):Math.random,c=r-e;for(let u=0;u<i;u++){let f=l();a[u]=o?Math.floor(f*(c+1))+e:f*c+e}return a})}round(t=0){return x(this,A(e=>In(e,t)))}ft(t){return x(this,A(e=>z(e)?Number(e.toPrecision(t)):e))}sign(){return x(this,A(Math.sign))}sin(){return x(this,A(Math.sin))}sinh(){return x(this,A(Math.sinh))}sqrt(){return x(this,A(t=>t<0?null:Math.sqrt(t)))}sub(t){return x(this,U(this,t,(e,r)=>e-r))}tan(){return x(this,A(Math.tan))}tanh(){return x(this,A(Math.tanh))}trunc(){return x(this,A(Math.trunc))}}});var me,ko=R(()=>{"use strict";ot();gt();$();me=class extends j{and(t){return x(this,(e,r)=>{let o=e.length,s=this.y(t,r,o),i=O(s),a=new Array(o);for(let l=0;l<o;l++){let c=e[l],u=i?s[l]:s;c===!1||u===!1?a[l]=!1:c==null||u==null?a[l]=null:a[l]=!0}return a})}not(){return x(this,A(t=>!t))}or(t){return x(this,(e,r)=>{let o=e.length,s=this.y(t,r,o),i=O(s),a=new Array(o);for(let l=0;l<o;l++){let c=e[l],u=i?s[l]:s;c===!0||u===!0?a[l]=!0:c==null||u==null?a[l]=null:a[l]=!1}return a})}xor(t){return x(this,U(this,t,(e,r)=>!!e!=!!r))}}});function Io(n,t,e,r){let o=n.length,s=new Array(o);if(e&&typeof e=="object"&&"evaluate"in e){let i=e.evaluate(t,o);for(let a=0;a<o;a++){let l=n[a];if(l==null)s[a]=null;else{let c=i[a],u=new Set;if(O(c)){let m=c.length;for(let h=0;h<m;h++)u.add(W(c[h]))}else u.add(W(c));let f=u.has(W(l));s[a]=r?!f:f}}}else{let i=O(e)?e:[],a=new Set,l=i.length;for(let c=0;c<l;c++)a.add(W(i[c]));for(let c=0;c<o;c++){let u=n[c];if(u==null)s[c]=null;else{let f=a.has(W(u));s[c]=r?!f:f}}}return s}function Eo(n,t){let{frequencies:e}=wt(n,{strict:!0}),r=n.length,o=new Array(r);for(let s=0;s<r;s++){let i=e.get(n[s])||0;o[s]=t?i>1:i===1}return o}function Ro(n,t,e){let r=n.length,o=new Array(r);if(O(t))for(let s=0;s<r;s++){let i=n[s],a=t[s];i==null&&a==null?o[s]=!e:i==null||a==null?o[s]=e:o[s]=e?i!==a:i===a}else for(let s=0;s<r;s++){let i=n[s];i==null&&t==null?o[s]=!e:i==null||t==null?o[s]=e:o[s]=e?i!==t:i===t}return o}var pe,Uo=R(()=>{"use strict";ot();gt();$();pe=class extends j{between(t,e,r="both"){return x(this,(o,s)=>{let i=o.length,a=this.y(t,s,i),l=this.y(e,s,i),c=new Array(i),u=O(a),f=O(l);for(let m=0;m<i;m++){let h=o[m],p=u?a[m]:a,y=f?l[m]:l;if(h==null||p==null||y==null)c[m]=null;else{let d=r==="both"||r==="left"?h>=p:h>p,g=r==="both"||r==="right"?h<=y:h<y;c[m]=d&&g}}return c})}eq(t){return x(this,U(this,t,(e,r)=>e===r))}mt(t){return x(this,(e,r)=>{let o=this.y(t,r,e.length);return Ro(e,o,!1)})}ge(t){return x(this,U(this,t,(e,r)=>e>=r))}gt(t){return x(this,U(this,t,(e,r)=>e>r))}pt(){return this.l(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}ht(t,{yt:e=1e-8,bt:r=1e-8,xt:o=!1}={}){return x(this,(s,i)=>{let a=s.length,l=this.y(t,i,a),c=O(l),u=new Array(a);for(let f=0;f<a;f++){let m=s[f],h=c?l[f]:l;if(m==null||h==null)u[f]=null;else if(z(m)&&z(h)){let p=Math.abs(m-h),y=Math.max(r*Math.max(Math.abs(m),Math.abs(h)),e);u[f]=p<=y}else Number.isNaN(m)&&Number.isNaN(h)?u[f]=o:u[f]=m===h}return u})}wt(){return x(this,t=>Eo(t,!0))}St({ignoreNulls:t=!1}={}){return x(this,A(e=>typeof e=="string"?e.length===0:O(e)?t?H(e,"nullish",{mode:"every"}):e.length===0:null))}Tt(){return x(this,A(Number.isFinite))}Ct(t){return x(this,(e,r)=>Io(e,r,t,!1))}Dt(){return x(this,A(t=>t===1/0||t===-1/0))}At(){return x(this,A(Number.isNaN))}Ot(){return x(this,A(t=>!Number.isNaN(t)))}B(){return x(this,t=>{let e=t.length,r=new Array(e);for(let o=0;o<e;o++)r[o]=t[o]!=null;return r})}kt(){return x(this,t=>{let e=t.length,r=new Array(e);for(let o=0;o<e;o++)r[o]=t[o]==null;return r})}Et(){return x(this,t=>Eo(t,!1))}le(t){return x(this,U(this,t,(e,r)=>e<=r))}lt(t){return x(this,U(this,t,(e,r)=>e<r))}ne(t){return x(this,U(this,t,(e,r)=>e!==r))}It(t){return x(this,(e,r)=>{let o=this.y(t,r,e.length);return Ro(e,o,!0)})}Rt(t){return x(this,(e,r)=>Io(e,r,t,!0))}}});var un,he,Fo=R(()=>{"use strict";ot();gt();$();un=class{constructor(t){this.expr=t}expr;r(t){return x(this.expr,A(e=>t(String(e))))}O(t,e){return t==null?x(this.expr,r=>new Array(r.length).fill(null)):e()}concat(t){return x(this.expr,U(this.expr,t,(e,r)=>String(e)+String(r)))}contains(t){return this.O(t,()=>this.r(e=>bt(t)?t.test(e):e.includes(t)))}X(t){return this.O(t,()=>this.r(e=>{if(bt(t)){let r=t.global?t:new RegExp(t.source,t.flags+"g"),o=e.match(r);return o?o.length:0}else{let r=0,o=e.indexOf(t);for(;o!==-1;)r++,o=e.indexOf(t,o+t.length);return r}}))}Ft(){return this.r(t=>{try{return decodeURIComponent(t)}catch{return t}})}Ut(){return this.r(t=>{try{return encodeURIComponent(t)}catch{return t}})}Nt(t){return this.r(e=>e.endsWith(t))}explode(){return this.r(t=>t.split(""))}extract(t,e=0){return this.O(t,()=>this.r(r=>{let o=r.match(t);return o&&o[e]!==void 0?o[e]:null}))}len(){return this.Z()}Mt(){return this.r(t=>new TextEncoder().encode(t).length)}Z(){return this.r(t=>t.length)}lower(){return this.r(t=>t.toLowerCase())}lpad(t,e=" "){return this.r(r=>r.padStart(t,e))}jt(t,e=" "){return this.rpad(t,e)}_t(t,e=" "){return this.lpad(t,e)}replace(t,e){return this.O(t,()=>this.r(r=>r.replace(t,e)))}vt(t,e){return this.O(t,()=>this.r(r=>r.replaceAll(t,e)))}reverse(){return this.r(t=>t.split("").reverse().join(""))}rpad(t,e=" "){return this.r(r=>r.padEnd(t,e))}slice(t,e){return this.r(r=>{let o=t<0?r.length+t:t,s=e!==void 0?o+e:void 0;return r.slice(o,s)})}split(t){return this.r(e=>e.split(t))}Lt(t){return this.r(e=>e.startsWith(t))}Q(t,e){return this.r(r=>Pt(r,t,{mode:"both",...e}))}tt(t,e){return this.r(r=>Pt(r,t,{mode:"end",...e}))}et(t,e){return this.r(r=>Pt(r,t,{mode:"start",...e}))}Vt(t){return this.r(e=>Pt(e,t,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}Pt(t){return this.r(e=>Pt(e,t,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(t){return this.r(e=>go(e,t))}Bt(){return this.r(t=>ee(t,{format:"camel"}))}$t(){return this.r(t=>G(t,{dateOnly:!0}))}Kt(){return this.r(G)}qt(t,e){return this.r(r=>Oe(r,{precision:t,scale:e}))}Jt(){return this.r(t=>pt(t))}Wt(){return this.r(t=>ee(t,{format:"kebab"}))}Gt(){return this.lower()}zt(){return this.r(t=>ee(t,{format:"pascal"}))}Ht(){return this.r(t=>ee(t,{format:"snake"}))}Yt(){return this.r(Me)}Xt(){return this.r(t=>t.replace(/\b\w/g,e=>e.toUpperCase()))}Zt(){return this.upper()}trim(){return this.Q()}Qt(){return this.tt()}te(){return this.et()}upper(){return this.r(t=>t.toUpperCase())}zfill(t){return this.r(e=>e.padStart(t,"0"))}},he=class extends j{get str(){return new un(this)}}});var ye,Mo=R(()=>{"use strict";ot();gt();rt();$();ye=class extends j{l(t){let e=x(this);return e.m=t,e.d=this.c.length,e.T=this.c.length,e}k(t,e){return x(this,U(this,t,(r,o)=>[r,o])).l(e)}all(){return this.l(t=>H(t,e=>!!e,{mode:"every"}))}ee(){return this.l(t=>H(t,"nullish",{mode:"every"}))}any(){return this.l(t=>H(t,e=>!!e,{mode:"some"}))}re(){return this.l(t=>H(t,"nullish",{mode:"some"}))}avg(){return this.l(t=>N(t).mean)}corr(t){return this.k(t,e=>En(e)?.correlation??null)}count(t={}){return t.includeNulls?this.l(e=>e.length):this.l(e=>N(e).count)}cov(t){return this.k(t,e=>En(e)?.covariance??null)}dot(t){return this.k(t,e=>eo(e))}first(){return this.l(t=>t[0]??null)}implode(){return this.l(t=>t)}last(){return this.l(t=>t[t.length-1]??null)}max(){return this.l(t=>N(t).max)}mean(){return this.avg()}median(){return this.l(t=>Vt(t))}min(){return this.l(t=>N(t).min)}mode(){return this.l(t=>Ee(t))}nt(t={}){return this.l(e=>wt(e,t).count)}oe(){return this.l(t=>N(t).nullCount)}quantile(t){if(t<0||t>1)throw new at("Quantile q must be between 0 and 1");return this.l(e=>Ie(e,t))}se(t){return this.k(t,e=>to(e))}std(){return this.l(t=>N(t).std)}sum(){return this.l(t=>N(t).sum)}ie(t){return this.k(t,e=>no(e))}}});function fr(n,t,e={}){if(t==null)return null;let r=e.dense?"_denseRankCache":"_rankCache",o=n[r];if(!o){let s=n;if(e.ignoreNulls){s=[];let l=n.length;for(let c=0;c<l;c++)n[c]!=null&&s.push(n[c])}e.dense&&(s=Array.from(new Set(s)));let i=Qt(s);o=new Map;let a=i.length;for(let l=0;l<a;l++){let c=i[l];o.has(c)||o.set(c,l+1)}n[r]=o}return o.get(t)??null}var de,No=R(()=>{"use strict";ot();$();de=class extends j{p=this.p||null;x(t){let e=x(this);return e.T=this.c.length,e.d=this.c.length,e.b=t,e}g(t,e){return this.x(function(r,o,s){let i=Math.max(0,s-t+1),a=s+1,l=r.slice(i,a);return e(l)})}I(t,e,r,o){return this.x(function(s,i,a){let l=e,c=!1,u=t?a:0,f=t?s.length-1:a;for(let m=u;m<=f;m++){let h=s[m];h!=null&&(l=r(l,h),c=!0)}return o?o(l,c):l})}get P(){return this.p!==null||this.b!==void 0||this.m!==null}ae(t=!1){return this.I(t,0,e=>e+1)}ue(t=!1){return this.I(t,null,(e,r)=>e===null||r>e?r:e)}ce(t=!1){return this.I(t,null,(e,r)=>e===null||r<e?r:e)}fe(t=!1){return this.I(t,1,(e,r)=>e*r,(e,r)=>r?e:null)}me(t=!1){return this.I(t,0,(e,r)=>e+r)}pe(){return this.x(function(t,e,r){return fr(t,t[r],{dense:!0})})}lag(t=1,e=null){return this.x(function(r,o,s){let i=e;return s-t>=0&&(i=r[s-t]),i})}lead(t=1,e=null){return this.x(function(r,o,s){let i=e;return s+t<r.length&&(i=r[s+t]),i})}over(t){let e=x(this),r=Array.isArray(t)?t:[t];return e.p=r,e}rank(){return this.x(function(t,e,r){return fr(t,t[r])})}he(t){return this.g(t,e=>N(e).max)}ye(t){return this.g(t,e=>N(e).mean)}de(t){return this.g(t,e=>Vt(e))}be(t){return this.g(t,e=>N(e).min)}xe(t,e){return this.g(e,r=>Ie(r,t))}we(t){return this.g(t,e=>fr(e,e[e.length-1],{ignoreNulls:!0}))}Se(t){return this.g(t,e=>N(e).std)}Te(t){return this.g(t,e=>N(e).sum)}Ce(){let t=this.x(function(e,r,o){return o+1});return t.f="row_number",t}}});var cn,ge,jo=R(()=>{"use strict";ot();gt();$();cn=class{constructor(t){this.expr=t}expr;i(t){return x(this.expr,A(e=>{let r=G(e);return r?t(r):null}))}w(t){return x(this.expr,A(e=>typeof e=="number"?t(e):null))}century(){return this.i(mo)}date(){return this.i(t=>new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())))}day(){return this.i(t=>t.getUTCDate())}De(){return this.i(t=>{let e=Ne(t,1,0);return e?e.getUTCDate():null})}epoch(t="ms"){return this.i(e=>fo(e,t))}hour(){return this.i(t=>t.getUTCHours())}Ae(t={}){return this.i(e=>bo(e,t))}Oe(){return this.i(vn)}rt(){return this.i(t=>jn(t,{field:"week"}))}ke(){return this.i(t=>jn(t,{field:"year"}))}microsecond(){return this.i(t=>t.getUTCMilliseconds()*1e3)}millennium(){return this.i(po)}millisecond(){return this.i(t=>t.getUTCMilliseconds())}minute(){return this.i(t=>t.getUTCMinutes())}month(){return this.i(t=>t.getUTCMonth()+1)}Ee(){return this.i(t=>Ne(t,1,0))}Ie(){return this.i(t=>Ne(t,0,1))}nanosecond(){return this.i(t=>t.getUTCMilliseconds()*1e6)}Re(t,{excludeWeekdays:e=[0,6],...r}={}){let o={excludeWeekdays:e,...r};return x(this.expr,U(this.expr,t,(s,i)=>{let a=G(s);return a?Vn(a,i,o):null}))}Fe(t,e={}){return x(this.expr,U(this.expr,t,(r,o)=>{let s=G(r);return s?Vn(s,o,e):null}))}Ue(){return this.i(_n)}quarter(){return this.i(ho)}second(){return this.i(t=>t.getUTCSeconds())}strftime(t){return this.i(e=>Rt(e,t))}time(){return this.i(t=>t.toISOString().split("T")[1].slice(0,12))}timestamp(t="ms"){return this.epoch(t)}Ne(t){return this.strftime(t)}Me(){return this.w(t=>t/864e5)}je(){return this.w(t=>t/36e5)}_e(){return this.w(t=>t*1e3)}ve(){return this.w(t=>t)}Le(){return this.w(t=>t/6e4)}Ve(){return this.w(t=>t*1e6)}Pe(){return this.w(t=>t/1e3)}Be(t,e={}){return x(this.expr,A(r=>{let o=G(r);return o?Pn(o,t,e):null}))}week(){return this.rt()}weekday(){return this.i(t=>t.getUTCDay()||7)}year(){return this.i(t=>t.getUTCFullYear())}},ge=class extends j{get dt(){return new cn(this)}}});var fn,be,_o=R(()=>{"use strict";ot();gt();$();_t();fn=class{constructor(t){this.expr=t}expr;s(t){return x(this.expr,A(e=>O(e)?t(e):null))}all(){return this.s(t=>H(t,e=>!!e,{mode:"every"}))}any(){return this.s(t=>H(t,e=>!!e,{mode:"some"}))}contains(t){return this.s(e=>e.includes(t))}$e(t){return this.s(e=>H(t,r=>e.includes(r),{mode:"every"}))}Ke(t){return this.s(e=>H(t,r=>e.includes(r),{mode:"some"}))}X(t,e={}){return this.s(r=>wt(r,e).frequencies.get(t)??0)}filter(t){return x(this.expr,(e,r)=>{let o=e.length,s=new Array(o),i=Object.create(r);for(let a=0;a<o;a++){let l=e[a];if(!O(l)){s[a]=null;continue}let c=l.length;i[jt]=l;let u=Ot(t,i,c),f=[];if(O(u)){let m=Math.min(c,u.length);for(let h=0;h<m;h++)u[h]&&f.push(l[h])}else if(u)for(let m=0;m<c;m++)f.push(l[m]);s[a]=f}return s})}explode({qe:t=!0,Je:e=!0}={}){return x(this.expr,r=>{let o=r.length,s=0;for(let c=0;c<o;c++){let u=r[c];if(O(u)){s+=u.length||(t?1:0);continue}if(u!=null){s+=1;continue}e&&(s+=1)}let i=new Array(s),a=new Int32Array(s),l=0;for(let c=0;c<o;c++){let u=r[c];if(O(u)){let f=u.length;if(f>0){for(let m=0;m<f;m++)a[l]=c,i[l++]=u[m];continue}t&&(a[l]=c,i[l++]=null);continue}if(u!=null){a[l]=c,i[l++]=u;continue}e&&(a[l]=c,i[l++]=null)}return i.rowMap=a,i})}first(t=!0){return this.get(0,t)}gather(t,e=!0){return this.s(r=>{let o=typeof t=="number"?[t]:t,s=o.length,i=new Array(s);for(let a=0;a<s;a++)i[a]=ke(r,o[a],e);return i})}We(t={}){return this.s(e=>Yr(e,t))}get(t,e=!0){return this.s(r=>ke(r,t,e))}join(t=",",e={}){return this.s(r=>Xr(r,t,e))}last(t=!0){return this.get(-1,t)}len(){return this.lengths()}lengths(){return this.s(t=>t.length)}max(){return this.s(t=>N(t).max)}Ge(){return this.s(t=>N(t).maxIdx)}mean(){return this.s(t=>N(t).mean)}median(){return this.s(t=>Vt(t))}min(){return this.s(t=>N(t).min)}ze(){return this.s(t=>N(t).minIdx)}mode(){return this.s(t=>Ee(t))}nt(t={}){return this.s(e=>wt(e,t).count)}reverse(){return this.s(t=>t.slice().reverse())}shift(t=1){return this.s(e=>Qr(e,t))}slice(t,e){return this.s(r=>r.slice(t,e))}splice(t,e,...r){return this.s(o=>{let s=[...o];return s.splice(t,e??s.length,...r),s})}sort(t){return this.s(e=>Qt(e,t))}std(){return this.s(t=>N(t).std)}sum(){return this.s(t=>N(t).sum)}He({Ye:t,fields:e}={}){return x(this.expr,r=>{let o=r.length,s=new Array(o),i=0;if(Array.isArray(e))i=e.length;else if(typeof t=="number")i=t;else for(let l=0;l<o;l++){let c=r[l];O(c)&&c.length>i&&(i=c.length)}if(i===0)throw new Error("to_struct cannot be evaluated: struct width is 0. Provide an upper_bound, non-empty fields names, or non-empty lists.");let a=new Array(i);for(let l=0;l<i;l++)typeof e=="function"?a[l]=e(l):a[l]=(Array.isArray(e)?e[l]:null)??`field_${l}`;for(let l=0;l<o;l++){let c=r[l];if(!O(c)){s[l]=null;continue}let u={};for(let f=0;f<i;f++)u[a[f]]=ke(c,f,!0);s[l]=u}return s})}unique(t={}){return this.s(e=>wt(e,t).values)}variance(){return this.s(t=>N(t).variance)}eval(t){return x(this.expr,(e,r)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){let a=e[i];if(!O(a)){s[i]=null;continue}let l=a.length,c={...r,[jt]:a};if(t.m!=null&&(t.p==null||t.p.length===0)){let f=t.d!==void 0?t.d:t.c.length,m=t.U(f,c,l),h=t.m(Array.from(m));s[i]=t.v(f,[h],c)}else s[i]=Ot(t,c,l)}return s})}},be=class extends j{get arr(){return new fn(this)}}});var mn,vo=R(()=>{"use strict";ot();$();mn=class extends j{$({value:t=void 0,strategy:e=void 0,limit:r=void 0}={}){return x(this,(o,s)=>{let i=o.length,a=Array.from(o);if(e!==void 0)if(e==="zero"||e==="one"||e==="min"||e==="max"||e==="mean"){let l;e==="zero"?l=0:e==="one"?l=1:l=N(o)[e],Et(a,l,{mode:"constant",condition:c=>c==null})}else if(e==="forward"||e==="backward"){let l=e==="forward",c=null,u=0;Et(a,null,{mode:"independent",reverse:!l,step:({originalValue:f})=>f!=null?(c=f,u=0,f):c!==null&&(r===void 0||u<r)?(u++,c):null})}else throw new Error(`Unsupported fill_null strategy: "${e}"`);else{let l=this.y(t,s,i),c=O(l);Et(a,null,{mode:"independent",step:({index:u,originalValue:f})=>f??(c?l[u]:l)})}return a})}reverse(){return x(this,t=>t.slice().reverse())}}});var Lo={};wr(Lo,{ColumnExpr:()=>k,resolveColumnSelectors:()=>kt});function Bs(n,t){for(let e of t)for(let r of Object.getOwnPropertyNames(e.prototype))r!=="constructor"&&Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))}function $s(n,t,e,r){if(!(n instanceof k)){if(B(n)&&"evaluate"in n&&!n.u){let o=[];for(let s=0;s<t.length;s++)e.has(t[s])||o.push(t[s]);return o}return null}if(n.C&&n.C.length>0)return n.C;if(n.u==="*"){let o=new Set(n.K),s=[];for(let i=0;i<t.length;i++){let a=t[i];!o.has(a)&&!e.has(a)&&s.push(a)}return s}if(n.M||n.D&&n.D.length>0){if(!r)throw new Error("Cannot resolve DataType column selector without DataFrame schema.");let o=[];for(let s=0;s<t.length;s++){let i=t[s];if(e.has(i))continue;let a=r[i];if(a){if(n.M)a.matches(n.M)&&o.push(i);else if(n.D){for(let l=0;l<n.D.length;l++)if(a.matches(n.D[l])){o.push(i);break}}}}return o}return null}function kt(n,t,e,r,o){let s=[],i=e?new Set(e):new Set;for(let a=0;a<n.length;a++){let l=n[a];if(typeof l=="string"){s.push(new k(l));continue}if(B(l)&&l.isUnnest){let u=[],f=l.u;if(typeof f=="string"&&r&&r[f]&&r[f].name==="Struct"&&(u=Object.keys(r[f].fields)),u.length===0&&o){let p=Object.keys(o)[0],y=p?o[p].length:0,d=l.baseExpr.evaluate(o,y),g=d.length;for(let b=0;b<g;b++){let S=d[b];if(S!=null&&typeof S=="object"){u=Object.keys(S);break}}}let m=u.length;if(m>0){for(let h=0;h<m;h++){let p=u[h],y=l.baseExpr.struct.field(p);s.push(y)}continue}}let c=$s(l,t,i,r);if(c!==null)for(let u=0;u<c.length;u++){let f=new k(c[u]);f.c=[...l.c||[]],f.m=l.m,f.T=l.T,f.d=l.d,f.p=l.p,l.b&&(f.b=l.b),l.f&&l.f!=="*"&&(f.f=l.f),s.push(f)}else s.push(l)}return s}var k,ft=R(()=>{"use strict";ot();Oo();Uo();Mo();No();Fo();ko();jo();_o();Vo();vo();$();Dt();k=class n extends j{u="";C;K=[];M;D;static isColExpr(t){if(!B(t))return!1;try{return"evaluate"in t&&typeof t.evaluate=="function"}catch{return!1}}static toColExpr(t){if(t==null)throw new Error("Column reference cannot be null or undefined.");return n.isColExpr(t)?t:new n(t)}constructor(t){super(),Array.isArray(t)?t.some(r=>r instanceof Z||typeof r=="function")?this.D=t:this.C=t.map(String):t instanceof Z||typeof t=="function"?this.M=t:(this.u=String(t),this.f=this.u)}};Bs(k,[fe,pe,ye,de,he,me,ge,be,xe,mn])});function Po(n){if(n==null)throw new Error("Column reference cannot be null or undefined.");return pn||(pn=(ft(),Sr(Lo)).ColumnExpr),pn.isColExpr(n)?n:new pn(n)}var pn,hn,xe,Vo=R(()=>{"use strict";ot();pn=null;hn=class{constructor(t){this.expr=t;return new Proxy(this,{get(e,r,o){return r in e?Reflect.get(e,r,o):typeof r=="string"?e.field(r):Reflect.get(e,r,o)}})}expr;field(t){return x(this.expr,e=>{let r=e.length,o=new Array(r);for(let s=0;s<r;s++){let i=e[s];o[s]=i!=null&&typeof i=="object"?i[t]:null}return o}).alias(t)}Xe(t){return x(this.expr,e=>{let r=e.length,o=new Array(r),s=Object.keys(t),i=s.length;for(let a=0;a<r;a++){let l=e[a];if(l==null||typeof l!="object"){o[a]=null;continue}let c={},u=Object.keys(l),f=u.length;for(let m=0;m<f;m++){let h=u[m];c[h]=l[h]}for(let m=0;m<i;m++){let h=s[m];if(h in c){let p=t[h];c[p]=c[h],delete c[h]}}o[a]=c}return o})}ot(t){return x(this.expr,(e,r)=>{let o=e.length,s=new Array(o),i=[];if(Array.isArray(t)){let c=t.length;for(let u=0;u<c;u++){let f=t[u],m=Po(f),h=m.f||m.u;if(!h)throw new Error("Expressions passed to struct.with_fields must have a name/alias.");i.push({name:h,expr:m})}}else if(t&&typeof t=="object"){let c=Object.keys(t),u=c.length;for(let f=0;f<u;f++){let m=c[f],h=Po(t[m]);i.push({name:m,expr:h})}}let a=i.length,l=new Array(a);for(let c=0;c<a;c++)l[c]=i[c].expr.evaluate(r,o);for(let c=0;c<o;c++){let u=e[c];if(u==null||typeof u!="object"){s[c]=null;continue}let f={},m=Object.keys(u),h=m.length;for(let p=0;p<h;p++){let y=m[p];f[y]=u[y]}for(let p=0;p<a;p++)f[i[p].name]=l[p][c];s[c]=f}return s})}unnest(){let t=x(this.expr);return t.isUnnest=!0,t.baseExpr=this.expr,t}},xe=class extends j{get struct(){return new hn(this)}}});var Gs={};wr(Gs,{$df:()=>Ws,ALL_COLUMNS_MARKER:()=>et,AggregationExpr:()=>ye,ArithmeticExpr:()=>fe,Array:()=>rr,ArrayDataType:()=>rr,ArrayExpr:()=>be,ArrayExprNamespace:()=>fn,ArrayType:()=>nn,Binary:()=>Xn,BinaryType:()=>Je,Boolean:()=>ue,BooleanDataType:()=>ue,BooleanType:()=>ze,COALESCE_MARKER:()=>Sn,ColumnExpr:()=>k,ColumnNotFoundError:()=>yt,ComparisonExpr:()=>pe,ComputeError:()=>at,DFScriptError:()=>Ft,DataFrame:()=>_,DataFrameError:()=>V,DataType:()=>Z,DataTypeRegistry:()=>F,Date:()=>tr,DateDataType:()=>tr,DateTimeExprNamespace:()=>cn,DateType:()=>Ze,Datetime:()=>ce,DatetimeType:()=>Qe,DecimalType:()=>ie,Duration:()=>nr,DurationType:()=>en,ELEMENT_MARKER:()=>jt,ExprBase:()=>j,Float32:()=>Yn,Float32Type:()=>We,Float64:()=>le,Float64Type:()=>Ge,FloatDataType:()=>$t,GroupedData:()=>Te,Int16:()=>qn,Int16Type:()=>Le,Int32:()=>Wn,Int32Type:()=>Ve,Int64:()=>ae,Int64Type:()=>Pe,Int8:()=>Kn,Int8Type:()=>ve,IntegerDataType:()=>se,LITERAL_MARKER:()=>wn,LogicalExpr:()=>me,NestedDataType:()=>Kt,Null:()=>Zn,NullType:()=>Ye,NumericDataType:()=>Ut,Object:()=>Qn,ObjectDataType:()=>Qn,ObjectType:()=>Xe,STRUCT_MARKER:()=>Tn,SchemaError:()=>Wt,ShapeError:()=>J,SignedIntegerType:()=>St,StringExpr:()=>he,StringExprNamespace:()=>un,Struct:()=>or,StructExpr:()=>xe,StructExprNamespace:()=>hn,StructType:()=>rn,TemporalDataType:()=>Ct,TemporalExpr:()=>ge,Time:()=>er,TimeType:()=>tn,UInt16:()=>zn,UInt16Type:()=>$e,UInt32:()=>Hn,UInt32Type:()=>Ke,UInt64:()=>Jn,UInt64Type:()=>qe,UInt8:()=>Gn,UInt8Type:()=>Be,UnsignedIntegerType:()=>Tt,Utf8:()=>qt,Utf8Type:()=>He,When:()=>dn,WhenThen:()=>Se,WhenThenChain:()=>yn,WindowExpr:()=>de,all:()=>zt,assertColumnExists:()=>Q,assertHeight:()=>an,coalesce:()=>pr,coerceColumn:()=>At,columnsToRows:()=>ur,computeRowHash:()=>Mt,concat:()=>Ht,derive:()=>x,element:()=>dr,evaluateExpression:()=>Ot,exclude:()=>mr,gatherColumnsByIndices:()=>Gt,getRowFromColumns:()=>Ls,implode:()=>yr,inferColumnType:()=>dt,kleeneBinary:()=>U,kleeneUnary:()=>A,lit:()=>we,read_csv:()=>bn,read_json:()=>gn,resolveColumnSelectors:()=>kt,resolveWindowExpr:()=>ar,rowsToColumns:()=>lr,seq_range:()=>Nt,struct:()=>gr,when:()=>hr,writeStringToFileOrStream:()=>cr});module.exports=Sr(Gs);ft();_t();rt();$();function Nt(n,t={strict:!0}){let e=t,r=new k(wn);return r.L=n,e.name&&(r.f=e.name),r.c.push(o=>{let s=o.length,i=(C,T)=>C===void 0?T:ct(C<0?s+C:C,{min:0,max:s}),a=i(e.startIndex,0),l=i(e.endIndex,s),c=Math.max(0,l-a),u=e.n!==void 0?e.n:c,f=e.strict!==!1;if(f){if(u!==s)throw new J(`Column height mismatch: seq_range length ${u} does not match DataFrame height ${s}`)}else{let C=e.pad??!1,T=e.truncate??!1;if(C&&!T&&u>c)throw new J(`Cannot pad seq_range output: specified length ${u} starting at index ${a} exceeds slice width ${c} (requires truncation).`);if(T&&!C&&u<c)throw new J(`Cannot truncate seq_range output: specified length ${u} starting at index ${a} is less than slice width ${c} (requires padding).`)}let m=s,h=!!e.dtype,p=e.mode||"cumulative",y=e.step!==void 0?e.step:1,d=h?C=>e.dtype.coerce(C):C=>C;if(f){let C=e.dtype?.allocate?e.dtype.allocate(m):new Array(m);return Et(C,n,{mode:p,step:y,coerce:d,startIndex:0,endIndex:m}),C}let g=Math.min(a+u,l),b=e.padValue!==void 0?e.padValue:null,S=d(b);if(p==="constant"&&a===0&&g===m&&!e.dtype){let C=new Array(m);for(let T=0;T<m;T++)C[T]=n;return C}let w=new Array(m);return w.fill(S),Et(w,n,{mode:p,step:y,coerce:d,startIndex:a,endIndex:g}),w}),r}function we(n,t){let e=Nt(n,{strict:!0,mode:"constant",dtype:t?.dtype,name:t?.name});return e.N=!0,e}ft();function zt(){return new k("*")}ft();function mr(n){let t=new k("*");return t.K=Array.isArray(n)?n:[n],t}ft();$();_t();function pr(...n){let t=n.length===1&&Array.isArray(n[0])?n[0]:n,e=new k(Sn);return e.c.push((r,o)=>{let s=r.length,i=u=>k.isColExpr(u)?u.evaluate(o,s):typeof u=="string"?o[u]||new Array(s).fill(null):u,a=t.length,l=new Array(a);for(let u=0;u<a;u++)l[u]=i(t[u]);let c=new Array(s);for(let u=0;u<s;u++){let f=null;for(let m=0;m<a;m++){let h=l[m],p=O(h)?h[u]:h;if(p!=null){f=p;break}}c[u]=f}return c}),e}ft();$();var yn=class{h;S;constructor(t,e){this.h=t,this.S=e}then(t){return new Se(this.h,this.S.concat(t))}},dn=class{h;constructor(t){this.h=[t]}then(t){return new Se(this.h,[t])}},Se=class n extends k{h;S;q;constructor(t,e,r=null){super(typeof t=="string"?t:"*when*"),this.h=Array.isArray(t)?t:[],this.S=e||[],this.q=r,this.c.push((o,s)=>{let i=o.length,a=h=>k.isColExpr(h)?h.evaluate(s,i):typeof h=="string"&&h in s?s[h]:h,l=this.h.length,c=new Array(l),u=new Array(l);for(let h=0;h<l;h++)c[h]=a(this.h[h]),u[h]=a(this.S[h]);let f=a(this.q),m=new Array(i);for(let h=0;h<i;h++){let p=!1;for(let y=0;y<l;y++)if((O(c[y])?c[y][h]:c[y])===!0){m[h]=O(u[y])?u[y][h]:u[y],p=!0;break}p||(m[h]=O(f)?f[h]:f)}return m})}when(t){return new yn(this.h.concat(t),this.S)}otherwise(t){return new n(this.h,this.S,t)}};function hr(n){return new dn(n)}ft();function yr(n){return k.toColExpr(n).implode()}ft();_t();function dr(){return new k(jt)}ft();_t();function gr(n,...t){let e;Array.isArray(n)||n&&typeof n=="object"&&!k.isColExpr(n)?e=n:e=[n,...t];let r=we({}).struct.ot(e);return delete r.N,delete r.L,r.u=Tn,r.alias("struct")}ln();var Te=class{A;R;V;F;J;j;constructor(t,e,r,o,s,i){this.A=t,this.R=e,this.V=r,this.F=o,this.J=s,this.j=i}Ze(){let t=this.R.length,e=new Array(t);for(let a=0;a<t;a++)e[a]=String(this.R[a]);let r=this.A.size,o={};for(let a=0;a<e.length;a++)o[e[a]]=new Array(r);let s=0;for(let a of this.A.values()){if(a.length===0)continue;let l=a[0];for(let c=0;c<e.length;c++){let u=e[c],f=this.F[u][l];o[u][s]=f===void 0?null:f}s++}let i={};for(let a of e)i[a]=this.j[a];return _.a(o,i,s)}agg(...t){let e=this.V.length,r=new Array(e);for(let f=0;f<e;f++)r[f]=String(this.V[f]);let o=this.R.length,s=new Array(o);for(let f=0;f<o;f++)s[f]=String(this.R[f]);let i=kt(t.flat(),r,s,this.j,this.F),a=this.A.size,l={};for(let f=0;f<s.length;f++)l[s[f]]=new Array(a);let c=0;for(let f of this.A.values()){if(f.length===0)continue;let m=f[0];for(let h=0;h<s.length;h++){let p=s[h],y=this.F[p][m];l[p][c]=y===void 0?null:y}c++}for(let f=0;f<i.length;f++){let m=i[f],h=m.f||m.u||"*";if(!m.m)l[h]=m.evaluate(l,a);else{let p=m.U(m.d,this.F,this.J),y=new Array(a),d=0;for(let g of this.A.values()){if(g.length===0)continue;let b=new Array(g.length);for(let S=0;S<g.length;S++)b[S]=p[g[S]];y[d]=m.m(b),d++}l[h]=m.v(m.d,y,l)}}let u={};for(let f of s)u[f]=this.j[f];for(let f of i){let m=f.f||f.u||"*";u[m]=dt(l[m])}return _.a(l,u,c)}};je();Dt();$();rt();Dt();$();rt();function Ks(n,t,e){if(n==null)throw new V(`Invalid input to ${t} at index ${e}: item cannot be null or undefined.`);if(n instanceof _)return[n];if(It(n))return[new _(n)];if(O(n)){if(H(n,_,{mode:"every"}))return n;if(H(n,"plainObject",{mode:"every"}))return[new _(n)];let r=H(n,_,{mode:"some"});for(let o=0;o<n.length;o++)if(r?!(n[o]instanceof _):!It(n[o]))throw new V(r?`Invalid input to ${t} at index ${e}, sub-index ${o}: nested array must contain only DataFrame instances.`:`Invalid input to ${t} at index ${e}, row ${o}: rows must be plain objects.`)}throw new V(`Invalid input to ${t} at index ${e}: expected DataFrame, row array, or column dictionary.`)}function Ht(n,{how:t="vertical",horizontal:e}={}){if(n==null)throw new V("Invalid input to concat: rawItems cannot be null or undefined.");let r=Array.isArray(n)?n:[n],o=[];for(let i=0;i<r.length;i++)o.push(...Ks(r[i],"concat",i));let s=e?.strict??!0;if(o.length===0)return _.a({},{},0);if(o.length===1&&t!=="horizontal")return o[0];switch(t){case"vertical":{let i=[];for(let p=0;p<o.length;p++)o[p].height>0&&i.push(o[p]);if(i.length===0)return _.a({},{},0);let a=i[0],l=Object.keys(a.t);for(let p=0;p<o.length;p++){let y=o[p];if(y.height===0)continue;let d=Object.keys(y.t);if(l.length!==d.length)throw new V(`[Strict Vertical] Column count mismatch at index ${p}.`);for(let g=0;g<l.length;g++){if(l[g]!==d[g])throw new V(`[Strict Vertical] Schema mismatch at position ${g} in DF ${p}. Expected column "${l[g]}", but found "${d[g]}".`);let b=a.schema[l[g]],S=y.schema[l[g]];if(b&&S&&!b.equals(S))throw new Wt(`[Strict Type Check] Schema type mismatch for column "${l[g]}": expected ${b.name}, found ${S.name}.`)}}let c=0;for(let p of o)c+=p.height;let u={},f=o.length;for(let p=0;p<f;p++)if(o[p].height>0){u=o[p].schema;break}Object.keys(u).length===0&&f>0&&(u=o[0].schema);let m={};for(let p of l){let y=u[p],d=!1;for(let b of o){let S=b.t[p];if(!S){d=!0;break}if(!L(S)){for(let w=0;w<S.length;w++)if(S[w]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(c):new Array(c).fill(null);d&&L(g)&&(g=new Array(c).fill(null)),m[p]=g}let h=0;for(let p of o){let y=p.height;if(y!==0){for(let d of l){let g=p.t[d]||new Array(y).fill(null),b=m[d];if(L(b)&&L(g))b.set(g,h);else{let S=b;for(let w=0;w<y;w++)S[h+w]=g[w]}}h+=y}}return _.a(m,u,c)}case"horizontal":{let i=o[0].height;for(let u=1;u<o.length;u++)o[u].height>i&&(i=o[u].height);let a=new Set;for(let u=0;u<o.length;u++){let f=o[u];if(s&&f.height!==i)throw new J(`[Horizontal] Row count mismatch at index ${u}. Expected ${i}, got ${f.height}. Set strict=false to allow padding.`);for(let m of Object.keys(f.t)){if(a.has(m))throw new V(`[Horizontal] Duplicate column name "${m}" detected. Horizontal concat requires unique names.`);a.add(m)}}let l={},c={};for(let u of o){let f=u.height;Object.assign(c,u.schema);let m=Object.keys(u.t),h=m.length;for(let p=0;p<h;p++){let y=m[p],d=u.t[y];if(f===i)l[y]=L(d)?Array.from(d):d;else{let g=new Array(i);for(let b=0;b<f;b++)g[b]=d[b];for(let b=f;b<i;b++)g[b]=null;l[y]=g}}}return _.a(l,c,i)}case"diagonal":{let i=new Set;for(let m of o)for(let h of Object.keys(m.t))i.add(h);let a=Array.from(i),l=0;for(let m=0;m<o.length;m++)l+=o[m].height;let c={};for(let m of a){let h=null;for(let p of o){let y=p.schema[m];if(y){if(h===null)h=y;else if(!h.equals(y))throw new Wt(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${h.name}, found ${y.name}.`)}}c[m]=h||F.Utf8}let u={};for(let m=0;m<a.length;m++)u[a[m]]=new Array(l).fill(null);let f=0;for(let m=0;m<o.length;m++){let h=o[m],p=h.height;if(p!==0){for(let y=0;y<a.length;y++){let d=a[y],g=u[d],b=h.t[d];if(b!==void 0)if(L(b)&&L(g))g.set(b,f);else{let S=g;for(let w=0;w<p;w++)S[f+w]=b[w]}else{let S=g;for(let w=0;w<p;w++)S[f+w]=null}}f+=p}}return _.a(u,c,l)}}}ln();var _=class n{t;e;o={};static a(t,e,r){an(t,r);let o=Object.create(n.prototype);return o.t=t,o.o=e,o.e=r,o}constructor(t,e,r){if(Array.isArray(t)){let{columns:o,height:s}=lr(t);this.t=o,this.e=s,e?this._(e):this.W();return}if(B(t)){this.t=t,this.e=an(t,r),e?this._(e):this.W();return}this.t={},this.e=0,e?this._(e):this.o={}}W(){let t={},e=Object.keys(this.t),r=e.length;for(let o=0;o<r;o++){let s=e[o];t[s]=dt(this.t[s])}this._(t)}_(t){this.o=t;let e=Object.keys(t),r={};for(let o of e){let s=t[o],i=this.t[o];r[o]=i?At(i,s,this.e):At(new Array(this.e).fill(null),s,this.e)}this.t=r}get columns(){return Object.keys(this.t)}concat(t,e={}){let r=H(t,n,{mode:"every",allowEmpty:!1})?t:[t];return Ht([this,...r],e)}drop(...t){let e=new Set(t.flat()),r={},o={};for(let s of Object.keys(this.t))e.has(s)||(r[s]=this.t[s],o[s]=this.o[s]);return n.a(r,o,this.e)}Qe(t){return this.e===0?this:this.filter(t?new k(t).B():zt().B())}get dtypes(){let t=Object.keys(this.t),e=t.length,r=new Array(e);for(let o=0;o<e;o++)r[o]=this.o[t[o]];return r}explode(t,e){let r=k.toColExpr(t),o=r.C||[r.u||r.f],s=new Set,i=o.length;for(let u=0;u<i;u++){let f=o[u];if(!f)throw new V("Expression passed to explode must have a column name.");Q(f,this.t,"Explode column"),s.add(f)}let a=Object.keys(this.t),l=[],c=a.length;for(let u=0;u<c;u++){let f=a[u];l.push(s.has(f)?new k(f).arr.explode(e):new k(f))}return this.select(...l)}$(t={}){return this.e===0?this:this.st(zt().$(t))}filter(...t){if(this.e===0)return n.a({},this.o,0);let e=this.e,r=Object.keys(this.t),o=r.length,s=[],i=[],a=[],l=t.length;for(let d=0;d<l;d++){let g=t[d];typeof g=="function"?i.push(g):a.push(g)}let c=kt(a,r,void 0,this.o,this.t),u=c.length;for(let d=0;d<u;d++)s.push(c[d].evaluate(this.t,e));let f=[],m=0,h=null;if(i.length>0){let d=this.t;h={};for(let g=0;g<o;g++){let b=r[g],S=d[b];Object.defineProperty(h,b,{get(){let w=S[m];return w===void 0?null:w},enumerable:!0,configurable:!0})}}for(let d=0;d<e;d++){let g=!0;for(let b=0;b<s.length;b++)if(!s[b][d]){g=!1;break}if(g){if(h){m=d;for(let b=0;b<i.length;b++)if(!i[b](h)){g=!1;break}}g&&f.push(d)}}let p=Gt(this.t,f),y=f.length;return n.a(p,this.o,y)}tn(){return this.o}groupby(t){let e=Zt(t),r=new Map,o=this.e,s=Lt(t);for(let a=0;a<s.length;a++)Q(s[a],this.t,"Grouping key");for(let a=0;a<o;a++){let l=Mt(this.t,s,a),c=r.get(l);c===void 0&&r.set(l,c=[]),c.push(a)}let i=Object.keys(this.t);return new Te(r,e,i,this.t,this.e,this.o)}head(t=10){return this.limit(t,{offset:0,from:"start"})}get height(){return this.e}hstack(t,e={}){return this.concat(t,{how:"horizontal",horizontal:e})}it(t,e,r){let o=k.toColExpr(r).alias(e),s=Object.keys(this.t),i=s.length,a=[];for(let c=0;c<i;c++){let u=s[c];u!==e&&a.push(u)}let l=Math.max(0,Math.min(t,a.length));return a.splice(l,0,o),this.select(...a)}item(t,e){let r=this.e,o=Object.keys(this.t),s=o.length;if(t===void 0&&e===void 0){if(r!==1||s!==1)throw new V("DataFrame.item() can only be called without arguments if the shape is (1, 1).");return this.t[o[0]][0]}if(t===void 0||e===void 0)throw new V("DataFrame.item() requires both row and column to be specified if not empty.");if(t<0||t>=r)throw new J(`Row index ${t} is out of bounds for DataFrame height ${r}.`);let i;if(typeof e=="number"){if(e<0||e>=s)throw new J(`Column index ${e} is out of bounds for DataFrame width ${s}.`);i=o[e]}else if(i=e,this.t[i]===void 0)throw new yt(i);return this.t[i][t]}*en(){let t=Object.keys(this.t),e=t.length,r=this.t;for(let o=0;o<e;o++)yield r[t[o]]}*nn({named:t=!1}={}){let e=Object.keys(this.t),r=e.length,o=this.t,s=this.e,i=new Array(r);for(let a=0;a<r;a++)i[a]=o[e[a]];if(t)for(let a=0;a<s;a++){let l={};for(let c=0;c<r;c++)l[e[c]]=i[c][a];yield l}else for(let a=0;a<s;a++){let l=new Array(r);for(let c=0;c<r;c++)l[c]=i[c][a];yield l}}join(t){let{other:e,on:r,how:o="inner",suffixes:s=["","_right"]}=t,i=Lt(r);for(let I=0;I<i.length;I++){let E=i[I];Q(E,this.t,"Join key"," in the left DataFrame."),Q(E,e.t,"Join key"," in the right DataFrame.")}let[a,l]=s,c=Object.keys(this.t),u=Object.keys(e.t),f=new Set(i),m=c.length,h=u.length,p=(I,E)=>{let P=i.length;for(let q=0;q<P;q++)if(I[i[q]][E]==null)return null;return Mt(I,i,E)},y=new Map,d=e.e,g=e.t;for(let I=0;I<d;I++){let E=p(g,I);if(E===null)continue;let P=y.get(E);P===void 0&&(P=[],y.set(E,P)),P.push(I)}let b=this.e,S=this.t,w=[],C=[],T=o==="outer"||o==="right",D=T?new Set:null;for(let I=0;I<b;I++){let E=p(S,I),P=E===null?void 0:y.get(E);if(P===void 0)(o==="left"||o==="outer")&&(w.push(I),C.push(null));else for(let q=0;q<P.length;q++){let Y=P[q];T&&D.add(Y),w.push(I),C.push(Y)}}if(T)for(let I=0;I<d;I++)D.has(I)||(w.push(-1),C.push(I));let v=w.length,mt={},lt={};for(let I=0;I<m;I++){let E=c[I],P=E in e.t&&!f.has(E)?`${E}${a}`:E,q=this.t[E],Y=f.has(E),X=new Array(v);if(Y){let st=e.t[E];for(let nt=0;nt<v;nt++){let br=w[nt];if(br!==-1)X[nt]=q[br];else{let xr=C[nt];X[nt]=xr!==null?st[xr]:null}}}else for(let st=0;st<v;st++){let nt=w[st];X[st]=nt!==-1?q[nt]:null}mt[P]=X,this.o[E]&&(lt[P]=this.o[E])}for(let I=0;I<h;I++){let E=u[I];if(!f.has(E)){let P=E in this.t?`${E}${l}`:E,q=e.t[E],Y=new Array(v);for(let X=0;X<v;X++){let st=C[X];Y[X]=st!==null?q[st]:null}mt[P]=Y,e.o[E]&&(lt[P]=e.o[E])}}return n.a(mt,lt,v)}limit(t,{offset:e=0,from:r="start"}={}){let o=this.e,s=ct(Math.floor(t),{min:0,max:o}),i=ct(Math.floor(e),{min:0,max:o}),a=i,l=Math.min(i+s,o);r==="end"&&(l=o-i,a=Math.max(l-s,0));let c=l-a,u={},f=Object.keys(this.t),m=f.length;for(let h=0;h<m;h++){let p=f[h];u[p]=this.t[p].slice(a,l)}return n.a(u,this.o,c)}pivot(t){if(this.e===0)return n.a({},{},0);let{index:e,columns:r,values:o}=t,s=Lt(e),i=s.length;for(let C=0;C<i;C++)Q(s[C],this.t,"Pivot index key");let a=String(r),l=String(o);Q(a,this.t,"Pivot column key"),Q(l,this.t,"Pivot values key");let c=new Map,u=[],f=new Set,m=this.e,h=this.t[a],p=this.t[l];for(let C=0;C<m;C++){let T=Mt(this.t,s,C);f.add(String(h[C])),c.get(T)===void 0&&(c.set(T,c.size),u.push(C))}let y=c.size,d={},g={};for(let C=0;C<i;C++){let T=s[C];d[T]=this.t[T],this.o[T]&&(g[T]=this.o[T])}let b=Gt(d,u),S=Array.from(f),w=this.o[l]||F.Utf8;for(let C=0;C<S.length;C++){let T=S[C];b[T]=new Array(y).fill(null),g[T]=w}for(let C=0;C<m;C++){let T=Mt(this.t,s,C),D=c.get(T),v=String(h[C]);b[v][D]=p[C]}return n.a(b,g,y)}rename(t){let e=t||{},r={},o={},s=Object.keys(this.t);for(let a of s){let l=e[a]||a;r[l]=this.t[a],o[l]=this.o[a]}if(Object.keys(r).length<s.length)throw new V("Rename collision: Multiple columns mapped to the same output name.");return n.a(r,o,this.e)}reverse(){if(this.e===0)return this;let t={},e=Object.keys(this.t),r=e.length;for(let o=0;o<r;o++){let s=e[o];t[s]=this.t[s].slice().reverse()}return n.a(t,this.o,this.e)}get schema(){return this.o}select(...t){let e=this.G(t),r=Object.keys(this.t),o=kt(e,r,void 0,this.o,this.t),s=o.length;if(s===0)return n.a({},{},this.e);let i={},a={},l=new Array(s),c=new Array(s),u=new Set,f=null;for(let p=0;p<s;p++){let y=o[p],d=y.f||y.u||"*";if(u.has(d))throw new V(`Duplicate column selection: "${d}" is selected multiple times.`);u.add(d);let g=Ot(y,this.t,this.e);l[p]=g,c[p]=d;let b=g&&g.rowMap;if(b)if(f){let S=b.length;if(S!==f.length)throw new J(`Mismatched explode heights: Column "${d}" has length ${S}, but another exploded column has length ${f.length}`);for(let w=0;w<S;w++)if(b[w]!==f[w])throw new J(`Mismatched explode heights: Column "${d}" has mismatched row lengths compared to another exploded column.`)}else f=b}let m=f?f.length:this.e,h=s>0;for(let p=0;p<s;p++){let y=o[p],d=y.m!=null&&(y.p==null||y.p.length===0),g=!!y.N;if(!d&&!g){h=!1;break}}for(let p=0;p<s;p++){let y=c[p],d=l[p],g=d,b=g&&g.rowMap,S=O(d)?d.length:0,w=f&&!b?this.e:m;if(S!==w)throw new J(`Column height mismatch: Column "${y}" has length ${S}, but expected ${w}`);if(f&&!b){let C=f.length;if(L(d)){let T=new g.constructor(C);for(let D=0;D<C;D++)T[D]=g[f[D]];d=T}else{let T=new Array(C);for(let D=0;D<C;D++)T[D]=g[f[D]];d=T}}l[p]=d}h&&(m=1);for(let p=0;p<s;p++){let y=o[p],d=c[p],g=l[p],b=y.u||d,w=y instanceof k&&y.c.length===0&&!y.P&&!y.m&&this.o[b]||dt(g);a[d]=w,i[d]=At(g,w,m)}return n.a(i,a,m)}get shape(){return[this.height,this.width]}slice(t,e){let r=this.e,o=t<0?Math.max(r+t,0):Math.min(t,r),s=e===void 0?r:e<0?Math.max(r+e,0):Math.min(e,r),i=Math.max(s-o,0);return this.limit(i,{offset:o})}sort(t){if(!t||!t.by||this.e===0)return this;let{by:e,descending:r=!1,nullsLast:o=!0,custom:s}=t,i=Zt(e);for(let p=0;p<i.length;p++){let y=k.toColExpr(i[p]);y.u&&Q(y.u,this.t,"Sort key")}let a=Array.isArray(r)?r:new Array(i.length).fill(r),l=i.length,c=new Array(l);for(let p=0;p<l;p++){let y=i[p],d=a[p]?-1:1,g=s&&typeof y=="string"?s[y]:null,b=k.toColExpr(y).evaluate(this.t,this.e);c[p]={values:b,isDesc:d,customComp:g}}let u=c.length,f=o?1:-1,m=new Array(this.e);for(let p=0;p<this.e;p++)m[p]=p;m.sort((p,y)=>{for(let d=0;d<u;d++){let{values:g,isDesc:b,customComp:S}=c[d],w=g[p],C=g[y];if(S){let D=S(w,C);if(D!==0)return D*b;continue}if(w==null||C==null){if(w===C)continue;return(w==null?1:-1)*f}if(w===C)continue;return(w<C?-1:1)*b}return 0});let h=Gt(this.t,m);return n.a(h,this.o,this.e)}tail(t=10){return this.limit(t,{offset:0,from:"end"})}rn(){return{...this.t}}z(){return ur(this.t,this.e)}sn(t){if(this.e===0)return[];if(t==null)return new Array(this.e).fill(null);let r=k.toColExpr(t).evaluate(this.t,this.e);return Array.isArray(r)?r:Array.from(r)}transpose({an:t=!1,ln:e="column",un:r}={}){if(this.e===0){let u={},f={};return t&&(u[e]=At([],F.Utf8,0),f[e]=F.Utf8),n.a(u,f,0)}let o=this.columns;typeof r=="string"&&(Q(r,this.t,"column_names"),o=o.filter(u=>u!==r));let s=[];if(typeof r=="string"){let u=this.t[r];s=new Array(this.e);for(let f=0;f<this.e;f++){let m=u[f];if(m==null)throw new V(`Transpose column_names column "${r}" contains null/undefined at index ${f}`);s[f]=String(m)}}else if(r!=null&&typeof r!="string"&&Symbol.iterator in Object(r)){let u=Array.from(r);if(u.length!==this.e)throw new V(`column_names length (${u.length}) must match the height of the DataFrame (${this.e})`);s=new Array(this.e);for(let f=0;f<this.e;f++)s[f]=String(u[f])}else{s=new Array(this.e);for(let u=0;u<this.e;u++)s[u]=`column_${u}`}let i=new Set;t&&i.add(e);for(let u=0;u<s.length;u++){let f=s[u];if(i.has(f))throw new V(`Duplicate column name in transposed DataFrame: "${f}"`);i.add(f)}let a=o.length,l={},c={};t&&(l[e]=At(o,F.Utf8,a),c[e]=F.Utf8);for(let u=0;u<this.e;u++){let f=s[u],m=new Array(a);for(let p=0;p<a;p++)m[p]=this.t[o[p]][u];let h=dt(m);l[f]=At(m,h,a),c[f]=h}return n.a(l,c,a)}unique(t){if(this.e===0)return n.a({},this.o,0);let e=Zt(t),r=e.length===0?Object.keys(this.t):e.map(String);for(let c of r)Q(c,this.t,"Unique column key");let o=new Set,s=[],i=this.e;for(let c=0;c<i;c++){let u=Mt(this.t,r,c);o.has(u)||(o.add(u),s.push(c))}let a=Gt(this.t,s),l=s.length;return n.a(a,this.o,l)}unpivot(t){let{idVars:e,valueVars:r,varName:o="variable",valueName:s="value"}=t,i=Lt(e),a=Lt(r),l=i.length,c=a.length;for(let p of i)Q(p,this.t,"Unpivot id variable key");for(let p of a)Q(p,this.t,"Unpivot value variable key");let u=this.e*c,f={};for(let p=0;p<l;p++)f[i[p]]=new Array(u);f[o]=new Array(u),f[s]=new Array(u);let m=0;for(let p=0;p<this.e;p++)for(let y=0;y<c;y++){let d=a[y];for(let g=0;g<l;g++){let b=i[g];f[b][m]=this.t[b][p]}f[o][m]=d,f[s][m]=this.t[d][p],m++}let h={};for(let p of i)h[p]=this.o[p];return h[o]=F.Utf8,h[s]=dt(f[s]),n.a(f,h,u)}vstack(t){return this.concat(t,{how:"vertical"})}get width(){return Object.keys(this.t).length}G(t){let e=t.flat(),r=[];for(let o of e)if(typeof o=="string")r.push(new k(o));else if(k.isColExpr(o))r.push(o);else if(B(o)){let s=Object.keys(o),i=s.length;for(let a=0;a<i;a++){let l=s[a],c=o[l];if(k.isColExpr(c))r.push(c.alias(l));else{let u=new k(l);u.evaluate=(f,m)=>new Array(m).fill(c),r.push(u)}}}return r}st(...t){if(t.length===0)return this;let e=this.G(t),r=Object.keys(this.t),o=kt(e,r,void 0,this.o,this.t),s=o.length;if(s===0)return this;let i=new Map;for(let c=0;c<s;c++){let u=o[c],f=u.f||u.u||"*";i.set(f,u)}let a=[],l=r.length;for(let c=0;c<l;c++){let u=r[c];a.push(i.get(u)||new k(u)),i.delete(u)}for(let c of i.values())a.push(c);return this.select(...a)}cn(t="index",e=0){let r=Nt(e,{mode:"independent",dtype:F.UInt32,step:1}),o=this.it(0,t,r);return o.o[t]=F.UInt32,o}fn(t,{format:e="json",replacerOptions:r}={}){if(e!=="json"&&e!=="ndjson")throw new TypeError(`Unsupported JSON format: "${e}". Expected "json" or "ndjson".`);let o=r?.replacer===null?void 0:oe(r),s;if(e==="ndjson"){let i=this.z(),a=i.length,l=new Array(a);for(let c=0;c<a;c++)l[c]=JSON.stringify(i[c],o);s=l.join(`
|
|
6
|
+
`)}else s=JSON.stringify(this.z(),o);return cr(t,s),s}mn(t,e={}){if(t){if(typeof t=="string"){if(typeof require!="function")throw new Error("File writing is not supported in this environment (missing require('fs')).");let r=require("fs"),o=r.openSync(t,"w");try{sn(this.t,this.e,{...e,onRow:s=>{r.writeSync(o,s,null,"utf8")}})}finally{r.closeSync(o)}}else if(B(t)&&typeof t.write=="function")sn(this.t,this.e,{...e,onRow:r=>{t.write(r)}});else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.");return""}return sn(this.t,this.e,e)}};Dt();$();rt();function gn(n,{format:t="json",trimBeforeParse:e=!0,schema:r,...o}={}){let s=xo(n,{format:t,trimBeforeParse:e,...o});if(s===n)throw new V(`Invalid JSON input: must be a valid, non-empty JSON ${t} string.`);let i=Array.isArray(s)?s:B(s)?[s]:[];return new _(i,r)}$();function bn(n,t={}){let{hasHeader:e=!0,schema:r,inferSchema:o=!0}=t,s=So(n,t);if(s.length===0)return new _({});let i,a;e?(i=s[0],a=s.slice(1)):(i=s[0].map((m,h)=>`column_${h}`),a=s);let l=i.length,c=a.length,u={};for(let m=0;m<l;m++){let h=i[m],p=new Array(c);for(let y=0;y<c;y++)p[y]=a[y][m]!==void 0?a[y][m]:"";u[h]=p}let f={};for(let m=0;m<l;m++){let h=i[m],p=u[h];if(r&&r[h])f[h]=p;else if(o){let{values:y}=To(p,t);f[h]=y}else f[h]=p}return new _(f,r)}function qs(n,t){return new _(n,t)}var Ws={data:qs,col:n=>new k(n),all:zt,exclude:mr,coalesce:pr,concat:Ht,pn:gn,hn:bn,lit:we,when:hr,implode:yr,yn:Nt,element:dr,struct:gr,DataType:F};Dt();rt();0&&(module.exports={$df,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Array,ArrayDataType,ArrayExpr,ArrayExprNamespace,ArrayType,Binary,BinaryType,Boolean,BooleanDataType,BooleanType,COALESCE_MARKER,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateDataType,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ELEMENT_MARKER,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,LITERAL_MARKER,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectDataType,ObjectType,STRUCT_MARKER,SchemaError,ShapeError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructExpr,StructExprNamespace,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,all,assertColumnExists,assertHeight,coalesce,coerceColumn,columnsToRows,computeRowHash,concat,derive,element,evaluateExpression,exclude,gatherColumnsByIndices,getRowFromColumns,implode,inferColumnType,kleeneBinary,kleeneUnary,lit,read_csv,read_json,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,seq_range,struct,when,writeStringToFileOrStream});
|