df-script 1.4.0 → 1.6.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.
Files changed (142) hide show
  1. package/README.md +203 -38
  2. package/dist/api.d.ts +16 -8
  3. package/dist/columnExpressions/ColumnExpr.d.ts +26 -364
  4. package/dist/columnExpressions/ExprBase.d.ts +8 -11
  5. package/dist/columnExpressions/constants.d.ts +2 -0
  6. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  7. package/dist/columnExpressions/functions/element.d.ts +5 -0
  8. package/dist/columnExpressions/functions/implode.d.ts +3 -0
  9. package/dist/columnExpressions/functions/lit.d.ts +3 -1
  10. package/dist/columnExpressions/functions/seq_range.d.ts +31 -0
  11. package/dist/columnExpressions/functions/when.d.ts +2 -2
  12. package/dist/columnExpressions/index.d.ts +6 -3
  13. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +25 -50
  14. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +43 -67
  15. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
  16. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +31 -60
  17. package/dist/columnExpressions/mixins/ListExpr.d.ts +16 -40
  18. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +7 -33
  19. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +6 -31
  20. package/dist/columnExpressions/mixins/StringExpr.d.ts +7 -32
  21. package/dist/columnExpressions/mixins/StructExpr.d.ts +16 -0
  22. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +4 -30
  23. package/dist/columnExpressions/mixins/WindowExpr.d.ts +27 -49
  24. package/dist/columnExpressions/types.d.ts +1 -0
  25. package/dist/columnExpressions/utils.d.ts +4 -0
  26. package/dist/constants.d.ts +11 -0
  27. package/dist/dataframe/constants.d.ts +3 -0
  28. package/dist/dataframe/dataframe.d.ts +28 -11
  29. package/dist/dataframe/grouped/grouped.d.ts +2 -3
  30. package/dist/dataframe/types.d.ts +65 -1
  31. package/dist/dataframe/utils.d.ts +11 -3
  32. package/dist/datatypes/DataType.d.ts +2 -1
  33. package/dist/datatypes/index.d.ts +4 -3
  34. package/dist/datatypes/types.d.ts +42 -41
  35. package/dist/exceptions/index.d.ts +2 -0
  36. package/dist/exceptions/utils.d.ts +1 -0
  37. package/dist/functions/concat.d.ts +1 -2
  38. package/dist/functions/index.d.ts +3 -1
  39. package/dist/functions/read_csv.d.ts +8 -0
  40. package/dist/functions/read_json.d.ts +10 -0
  41. package/dist/index.js +6 -1
  42. package/dist/types.d.ts +34 -6
  43. package/dist/utils/array.d.ts +217 -0
  44. package/dist/utils/binary.d.ts +3 -0
  45. package/dist/utils/csv.d.ts +77 -0
  46. package/dist/utils/date.d.ts +21 -35
  47. package/dist/utils/guards.d.ts +11 -12
  48. package/dist/utils/index.d.ts +5 -2
  49. package/dist/utils/json.d.ts +120 -2
  50. package/dist/utils/list.d.ts +196 -2
  51. package/dist/utils/number.d.ts +47 -29
  52. package/dist/utils/object.d.ts +26 -0
  53. package/dist/utils/string.d.ts +7 -4
  54. package/package.json +6 -2
  55. package/dist/api.js +0 -18
  56. package/dist/bundle.min.js +0 -1
  57. package/dist/columnExpressions/ColumnExpr.js +0 -23
  58. package/dist/columnExpressions/ExprBase.js +0 -133
  59. package/dist/columnExpressions/constants.js +0 -5
  60. package/dist/columnExpressions/functions/all.js +0 -11
  61. package/dist/columnExpressions/functions/coalesce.js +0 -40
  62. package/dist/columnExpressions/functions/exclude.js +0 -13
  63. package/dist/columnExpressions/functions/lit.js +0 -22
  64. package/dist/columnExpressions/functions/when.js +0 -81
  65. package/dist/columnExpressions/index.js +0 -81
  66. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -172
  67. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -143
  68. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -389
  69. package/dist/columnExpressions/mixins/ListExpr.js +0 -248
  70. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -54
  71. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -35
  72. package/dist/columnExpressions/mixins/StringExpr.js +0 -249
  73. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -127
  74. package/dist/columnExpressions/mixins/WindowExpr.js +0 -281
  75. package/dist/columnExpressions/types.js +0 -2
  76. package/dist/dataframe/constants.js +0 -4
  77. package/dist/dataframe/dataframe.js +0 -749
  78. package/dist/dataframe/grouped/grouped.js +0 -113
  79. package/dist/dataframe/index.js +0 -20
  80. package/dist/dataframe/types.js +0 -2
  81. package/dist/dataframe/utils.js +0 -215
  82. package/dist/datatypes/DataType.js +0 -47
  83. package/dist/datatypes/index.js +0 -46
  84. package/dist/datatypes/types/Binary.d.ts +0 -9
  85. package/dist/datatypes/types/Binary.js +0 -18
  86. package/dist/datatypes/types/Boolean.d.ts +0 -9
  87. package/dist/datatypes/types/Boolean.js +0 -19
  88. package/dist/datatypes/types/Date.d.ts +0 -8
  89. package/dist/datatypes/types/Date.js +0 -21
  90. package/dist/datatypes/types/Datetime.d.ts +0 -8
  91. package/dist/datatypes/types/Datetime.js +0 -17
  92. package/dist/datatypes/types/Decimal.d.ts +0 -10
  93. package/dist/datatypes/types/Decimal.js +0 -28
  94. package/dist/datatypes/types/Duration.d.ts +0 -8
  95. package/dist/datatypes/types/Duration.js +0 -17
  96. package/dist/datatypes/types/Float32.d.ts +0 -8
  97. package/dist/datatypes/types/Float32.js +0 -17
  98. package/dist/datatypes/types/Float64.d.ts +0 -8
  99. package/dist/datatypes/types/Float64.js +0 -17
  100. package/dist/datatypes/types/Int16.d.ts +0 -8
  101. package/dist/datatypes/types/Int16.js +0 -17
  102. package/dist/datatypes/types/Int32.d.ts +0 -8
  103. package/dist/datatypes/types/Int32.js +0 -17
  104. package/dist/datatypes/types/Int64.d.ts +0 -8
  105. package/dist/datatypes/types/Int64.js +0 -17
  106. package/dist/datatypes/types/Int8.d.ts +0 -8
  107. package/dist/datatypes/types/Int8.js +0 -17
  108. package/dist/datatypes/types/List.d.ts +0 -10
  109. package/dist/datatypes/types/List.js +0 -31
  110. package/dist/datatypes/types/Null.d.ts +0 -9
  111. package/dist/datatypes/types/Null.js +0 -17
  112. package/dist/datatypes/types/Object.d.ts +0 -9
  113. package/dist/datatypes/types/Object.js +0 -17
  114. package/dist/datatypes/types/Struct.d.ts +0 -14
  115. package/dist/datatypes/types/Struct.js +0 -39
  116. package/dist/datatypes/types/Time.d.ts +0 -8
  117. package/dist/datatypes/types/Time.js +0 -29
  118. package/dist/datatypes/types/UInt16.d.ts +0 -8
  119. package/dist/datatypes/types/UInt16.js +0 -17
  120. package/dist/datatypes/types/UInt32.d.ts +0 -8
  121. package/dist/datatypes/types/UInt32.js +0 -17
  122. package/dist/datatypes/types/UInt64.d.ts +0 -8
  123. package/dist/datatypes/types/UInt64.js +0 -17
  124. package/dist/datatypes/types/UInt8.d.ts +0 -8
  125. package/dist/datatypes/types/UInt8.js +0 -17
  126. package/dist/datatypes/types/Utf8.d.ts +0 -10
  127. package/dist/datatypes/types/Utf8.js +0 -20
  128. package/dist/datatypes/types.js +0 -286
  129. package/dist/exceptions/index.js +0 -43
  130. package/dist/exceptions/utils.js +0 -9
  131. package/dist/functions/concat.js +0 -248
  132. package/dist/functions/index.js +0 -17
  133. package/dist/types.js +0 -2
  134. package/dist/utils/boolean.d.ts +0 -1
  135. package/dist/utils/boolean.js +0 -18
  136. package/dist/utils/date.js +0 -349
  137. package/dist/utils/guards.js +0 -143
  138. package/dist/utils/index.js +0 -21
  139. package/dist/utils/json.js +0 -33
  140. package/dist/utils/list.js +0 -128
  141. package/dist/utils/number.js +0 -223
  142. package/dist/utils/string.js +0 -120
package/dist/index.js CHANGED
@@ -1 +1,6 @@
1
- "use strict";var oe=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var _n=Object.prototype.hasOwnProperty;var Tn=(s,t)=>{for(var e in t)oe(s,e,{get:t[e],enumerable:!0})},Dn=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wn(t))!_n.call(s,r)&&r!==e&&oe(s,r,{get:()=>t[r],enumerable:!(n=bn(t,r))||n.enumerable});return s};var An=s=>Dn(oe({},"__esModule",{value:!0}),s);var Rn={};Tn(Rn,{$tbl:()=>On,ALL_COLUMNS_MARKER:()=>B,AggregationExpr:()=>pe,ArithmeticExpr:()=>fe,Binary:()=>Le,BinaryType:()=>Yt,Boolean:()=>Fe,BooleanType:()=>Gt,ColumnExpr:()=>k,ColumnNotFoundError:()=>wt,ComparisonExpr:()=>me,ComputeError:()=>et,DFScriptError:()=>ct,DataFrame:()=>F,DataFrameError:()=>V,DataType:()=>z,DataTypeRegistry:()=>L,Date:()=>Ve,DateTimeExprNamespace:()=>Ut,DateType:()=>Jt,Datetime:()=>Ke,DatetimeType:()=>Qt,DecimalType:()=>Dt,Duration:()=>Pe,DurationType:()=>ee,ExprBase:()=>bt,Float32:()=>Ue,Float32Type:()=>qt,Float64:()=>Me,Float64Type:()=>Ht,FloatDataType:()=>mt,GroupedData:()=>Ct,Int16:()=>Ie,Int16Type:()=>jt,Int32:()=>Se,Int32Type:()=>Bt,Int64:()=>ke,Int64Type:()=>Vt,Int8:()=>Ce,Int8Type:()=>Lt,IntegerDataType:()=>Tt,LITERAL_MARKER:()=>he,List:()=>We,ListExpr:()=>be,ListExprNamespace:()=>Mt,ListType:()=>ne,LogicalExpr:()=>de,NestedDataType:()=>pt,Null:()=>je,NullType:()=>Zt,NumericDataType:()=>lt,Object:()=>Be,ObjectType:()=>Xt,SchemaError:()=>ht,SignedIntegerType:()=>ot,StringExpr:()=>ye,StringExprNamespace:()=>Rt,Struct:()=>qe,StructType:()=>re,TemporalDataType:()=>at,TemporalExpr:()=>xe,Time:()=>$e,TimeType:()=>te,UInt16:()=>ve,UInt16Type:()=>$t,UInt32:()=>Oe,UInt32Type:()=>Pt,UInt64:()=>Re,UInt64Type:()=>Wt,UInt8:()=>Ee,UInt8Type:()=>Kt,UnsignedIntegerType:()=>it,Utf8:()=>Ne,Utf8Type:()=>zt,When:()=>Nt,WhenThen:()=>_t,WhenThenChain:()=>Ft,WindowExpr:()=>ge,all:()=>_e,assertColumnExists:()=>W,coalesce:()=>De,columnsToRows:()=>Ge,concat:()=>It,derive:()=>g,exclude:()=>Te,gatherColumnsByIndices:()=>At,getRowFromColumns:()=>vn,inferColumnType:()=>nt,kleeneBinary:()=>U,kleeneUnary:()=>w,lit:()=>we,normalizeToDataFrames:()=>xn,resolveColumnSelectors:()=>ft,resolveWindowExpr:()=>se,rowsToColumns:()=>He,when:()=>Ae});module.exports=An(Rn);var Xe=/[,\s_]/g,Cn=/^[+-]?\d+(?:\.\d+)?$/;function rt(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}function Q(s){if(s==null||typeof s=="symbol")return null;if(rt(s))return s;if(typeof s=="boolean")return s?1:0;if(typeof s=="bigint"){let t=Number(s);return rt(t)?t:null}if(s instanceof Date){let t=s.getTime();return rt(t)?t:null}if(typeof s=="string"){let t=s.trim().replace(Xe,"");if(t==="")return null;let e=Number(t);return rt(e)?e:null}return null}function yt(s){let{val:t,min:e,max:n}=s;return t<e?e:t>n?n:t}var Ze=34028234663852886e22,Mn={Float32:{min:-Ze,max:Ze},Float64:{min:-Number.MAX_VALUE,max:Number.MAX_VALUE}};function ie(s,t="Float64"){let e=Q(s);return e===null?null:t==="Float32"?Math.fround(e):e}var Je={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}},In={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}};function Qe(s,t){if(!rt(s)||!Number.isInteger(s))return!1;if(!t)return!0;let e=typeof t=="string"?Je[t]:t;return s>=e.min&&s<=e.max}function tt(s,t="Int32",e={}){let n=Q(s);if(n===null)return null;let r=n;switch(e.coerce||"truncate"){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 i=typeof t=="string"?Je[t]:t;return yt({val:r,min:i.min,max:i.max})}function ae(s,t="Int64"){if(s==null||typeof s=="symbol")return null;let e=null;if(typeof s=="bigint")e=s;else if(typeof s=="boolean")e=s?1n:0n;else if(typeof s=="string"){let r=s.trim().replace(Xe,"");if(r==="")return null;if(Cn.test(r))e=BigInt(r.split(".")[0]);else{let o=Q(s);if(o===null)return null;e=BigInt(Math.trunc(o))}}else{let r=Q(s);if(r===null)return null;e=BigInt(Math.trunc(r))}let n=typeof t=="string"?In[t]:t;return yt({val:e,min:n.min,max:n.max})}function St(s,t={}){let e=Q(s);if(e===null)return null;let{precision:n,scale:r}=t,o=e;if(r!==void 0){let i=Math.pow(10,r);o=Math.round(o*i)/i}if(n!==void 0){let i=r||0,a=n-i;if(a>0){let l=Math.pow(10,a)-Math.pow(10,-i);o=yt({val:o,min:-l,max:l})}}return o}function tn(s){let t=s|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 kt=/^\d{2}:\d{2}/,Et=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;var le=1e3,nn=6e4,rn=36e5,dt=864e5,vt=1e3,Ot=1e6;function sn(s,t="ms"){let e=s.getTime();switch(t){case"s":return Math.floor(e/le);case"ms":return e;case"us":return e*vt;case"ns":return e*Ot}}function on(s){let t=s.getUTCFullYear();return Math.floor((t-1)/100)+1}function an(s){let t=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let n=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-n.getTime())/dt+1)/7)}function ln(s){let t=s.getUTCFullYear();return Math.floor((t-1)/1e3)+1}function ue(s,t,e=1){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+t,e,0,0,0,0))}function un(s){let t=new Date(Date.UTC(s.getUTCFullYear(),0,1)),e=s.getTime()-t.getTime();return Math.floor(e/dt)+1}function cn(s){return Math.floor(s.getUTCMonth()/3)+1}function hn(s){let t=s instanceof Date?s.getUTCFullYear():s;return t%4===0&&t%100!==0||t%400===0}function G(s){return s instanceof Date&&!Number.isNaN(s.getTime())}function en(s){let t=Math.abs(s);return t>=1e12?s:t<=1e10?s*1e3:s}var Sn=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"];function fn(s,t,e){let n=t;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 r={get"%Y"(){return String(s.getUTCFullYear())},get"%y"(){return String(s.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(s.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(s.getUTCDate()).padStart(2,"0")},get"%e"(){return String(s.getUTCDate()).padStart(2," ")},get"%H"(){return String(s.getUTCHours()).padStart(2,"0")},get"%I"(){return String(s.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return s.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(s.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(s.getUTCSeconds()).padStart(2,"0")},get"%A"(){return s.toLocaleDateString(e,{weekday:"long",timeZone:"UTC"})},get"%a"(){return s.toLocaleDateString(e,{weekday:"short",timeZone:"UTC"})},get"%B"(){return s.toLocaleDateString(e,{month:"long",timeZone:"UTC"})},get"%b"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%h"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%j"(){let o=new Date(Date.UTC(s.getUTCFullYear(),0,1)),i=s.getTime()-o.getTime(),a=Math.floor(i/dt)+1;return String(a).padStart(3,"0")},get"%u"(){return String(s.getUTCDay()||7)},get"%w"(){return String(s.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(s.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(s.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let o of Sn)n.includes(o)&&(n=n.replaceAll(o,r[o]));return n.replace(/\0/g,"%")}function mn(s,t,e=!0){if(typeof s!="string"||typeof t!="string")return null;let n=[],r=1,o="",i=0;for(;i<t.length;){let b=t[i];if(b==="%")if(i+1<t.length){let T=t[i+1];if(T==="%")o+="%",i+=2;else if(t.slice(i,i+3)==="%ms")n.push({name:"ms",index:r++}),o+="(\\d{1,3})",i+=3;else{switch(T){case"Y":n.push({name:"year",index:r++}),o+="(\\d{4})";break;case"y":n.push({name:"year_short",index:r++}),o+="(\\d{2})";break;case"m":n.push({name:"month",index:r++}),o+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:r++}),o+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:r++}),o+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:r++}),o+="(\\d{1,2})";break;case"S":n.push({name:"second",index:r++}),o+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:r++}),o+="(\\d{1,6})";break;default:o+=b+T}i+=2}}else o+=b,i++;else"\\^$*+?.()|[]{}".indexOf(b)!==-1?o+="\\"+b:o+=b,i++}let a=new RegExp("^"+o+"$"),l=s.match(a);if(!l){if(e)return null;let b=new Date(s);return G(b)?b:null}let u=1970,c=1,h=1,f=0,m=0,p=0,y=0;for(let b of n){let T=l[b.index],A=parseInt(T,10);switch(b.name){case"year":u=A;break;case"year_short":u=A+(A>=69?1900:2e3);break;case"month":c=A;break;case"day":h=A;break;case"hour":f=A;break;case"minute":m=A;break;case"second":p=A;break;case"ms":y=parseInt(T.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(T.padEnd(6,"0").slice(0,3),10);break}}let x=new Date(Date.UTC(u,c-1,h,f,m,p,y));return G(x)?x:null}function X(s){if(s instanceof Date)return G(s)?s:null;if(typeof s=="number"){let t=new Date(en(s));return G(t)?t:null}if(typeof s=="bigint"){let t=new Date(en(Number(s)));return G(t)?t:null}if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=new Date(t);return G(e)?e:null}return null}function $(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function D(s){return Array.isArray(s)||$(s)}function Y(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function xt(s){if(!Y(s))return!1;let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype}function pn(s){return typeof s!="function"?!1:/^class\s/.test(Function.prototype.toString.call(s))||s.prototype!==void 0&&s.prototype.constructor===s&&Object.getOwnPropertyDescriptor(s,"prototype")?.writable===!1}function kn(s){if(s==null)return!1;if(s instanceof Uint8Array||typeof s=="string")return!0;if(Array.isArray(s)){let t=s.length;for(let e=0;e<t;e++)if(!Qe(s[e],{min:-128,max:255}))return!1;return!0}return!!$(s)}function gn(s){return kn(s)?s instanceof Uint8Array?s:typeof s=="string"?new TextEncoder().encode(s):ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s):null}function st(s){return s==null?[]:Array.isArray(s)?s:$(s)?Array.from(s):[s]}function Z(s,t,{mode:e="every",allowNulls:n=!1,allowEmpty:r=!0}={}){if(!D(s))return!1;let o=s.length;if(o===0)return r?e==="every":!1;let i=a=>a==null?n:typeof t=="function"?pn(t)?a instanceof t:t(a):t==="date"?G(a):t==="object"?Y(a):t==="plainObject"?xt(a):t==="number"?rt(a):typeof a===t;if(e==="every"){for(let a=0;a<o;a++)if(!i(s[a]))return!1;return!0}else{for(let a=0;a<o;a++)if(i(s[a]))return!0;return!1}}function ce(s,t=!1){if(!D(s))return[];let e=Array.from(s);return e.sort((n,r)=>n==null&&r==null?0:n==null?1:r==null?-1:n<r?t?1:-1:n>r?t?-1:1:0),e}var yn={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1};function j(s){if(!D(s))return{...yn};let t=s.length;if(t===0)return{...yn};let e=null,n=null,r=0,o=0,i=0,a=0,l=0;for(let c=0;c<t;c++){let h=s[c];if(h==null){o++;continue}(e==null||h<e)&&(e=h),(n==null||h>n)&&(n=h);let f=Q(h);if(f!==null){i+=f,r++;let m=f-a;a+=m/r;let p=f-a;l+=m*p}}let u=r>1?l/(r-1):0;return{sum:r>0?i:null,count:r,min:e,max:n,mean:r>0?i/r:null,variance:u,std:Math.sqrt(u),nullCount:o,len:t,hasNulls:o>0,isNumeric:r>0&&r===t-o}}function ut(s,t=null,{mode:e="both",returnStringOnNull:n=!1,maxScanStart:r=1,maxScanEnd:o=1,maxMatchesStart:i=1,maxMatchesEnd:a=1,trimFirst:l=!1,stringOptions:{literal:u=!1,caseInsensitive:c=!1}={}}={}){if(s==null)return n?"":null;let h=(d,I="both")=>I==="start"?d.trimStart():I==="end"?d.trimEnd():d.trim(),f=s;if(l&&t!=null&&(f=h(s,e)),t==null){let d=h(f,e);return n||d!==""?d:null}let m=t instanceof RegExp?d=>t.test(d):(()=>{let d=new Set(c?t.toLowerCase():t);return I=>d.has(c?I.toLowerCase():I)})(),p=f.length,y=new Uint8Array(p),A=u&&typeof t=="string"?({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=t.length;if(E===0)return;let N=c?f.toLowerCase():f,K=c?t.toLowerCase():t,_=d?0:p-1,C=0,v=0;for(;_>=0&&_<p&&!(R!==null&&R>=0&&C>=R);){let M=d?_:_-E+1;if(!d&&M<0)break;let O=d?N.indexOf(K,M):N.lastIndexOf(K,M);if(O===-1)break;let q=d?O-_:_-(O+E-1);if(v+=q,I!==null&&I>=0&&v>=I)break;for(let H=0;H<E;H++)y[O+H]=1;C++,_=d?O+E:O-1}}:({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=d?0:p-1,N=d?p:-1,K=d?1:-1,_=!1,C=0,v=0;for(let M=E;M!==N;M+=K)if(m(f[M])){if(!_){if(I!==null&&I>=0&&v>=I||R!==null&&R>=0&&C>=R)break;_=!0,C++}y[M]=1}else _=!1,v++};(e==="both"||e==="start")&&A({isStart:!0,limit:r,maxMatches:i}),(e==="both"||e==="end")&&A({isStart:!1,limit:o,maxMatches:a});let S="";for(let d=0;d<p;d++)y[d]===0&&(S+=f[d]);return n||S!==""?S:null}var B="*",he="*literal*";var w=s=>t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++){let o=t[r];n[r]=o==null?null:s(o)}return n},U=(s,t,e)=>(n,r)=>{let o=n.length,i=s._resolve(t,r,o),a=new Array(o);if(D(i))for(let l=0;l<o;l++){let u=n[l],c=i[l];a[l]=u==null||c==null?null:e(u,c)}else for(let l=0;l<o;l++){let u=n[l];a[l]=u==null||i==null?null:e(u,i)}return a},g=(s,t)=>{let e=s.constructor,n=new e(s.colName||"");return Object.assign(n,s),n.ops=t?[...s.ops,t]:[...s.ops],n},bt=class{ops=[];outputName="";aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;_resolve(t,e,n){return t&&typeof t=="object"&&"evaluate"in t?t.isLiteral&&t.ops.length===1?t.literalValue:t.evaluate(e,n):t}alias(t){let e=this.constructor,n=new e(this.colName||"");return Object.assign(n,this),n.outputName=t,n}cast(t){return g(this,e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=t.coerce(e[o]);return r})}debug(t){return g(this,e=>(console.log(`[DEBUG] ${t?t+": ":""}`,e),e))}evaluate(t,e){let n=this.colName,r=n&&n!=="*"?t[n]||new Array(e).fill(null):new Array(e).fill(null),o=this.ops,i=o.length;for(let a=0;a<i;a++)r=o[a](r,t);return r}_evaluatePre(t,e,n){let r=this.colName,o=r&&r!=="*"?e[r]||new Array(n).fill(null):new Array(n).fill(null),i=this.ops,a=t!==void 0?t:i.length;for(let l=0;l<a;l++)o=i[l](o,e);return o}_evaluatePost(t,e,n){let r=this.ops,o=t!==void 0?t:r.length,i=e;for(let a=o;a<r.length;a++)i=r[a](i,n);return i}evaluatePrePartition(t,e){return this._evaluatePre(this.partitionOpsIndex,t,e)}evaluatePostPartition(t,e){return this._evaluatePost(this.partitionOpsIndex,t,e)}evaluatePreGrouping(t,e){return this._evaluatePre(this.groupingOpsIndex,t,e)}evaluatePostGrouping(t,e){return this._evaluatePost(this.groupingOpsIndex,t,e)}};var fe=s=>class extends s{abs(){return g(this,w(t=>Math.abs(t)))}acos(){return g(this,w(t=>t<-1||t>1?null:Math.acos(t)))}acosh(){return g(this,w(t=>t<1?null:Math.acosh(t)))}add(t){return g(this,U(this,t,(e,n)=>e+n))}asin(){return g(this,w(t=>t<-1||t>1?null:Math.asin(t)))}asinh(){return g(this,w(Math.asinh))}atan(){return g(this,w(Math.atan))}atanh(){return g(this,w(t=>t<=-1||t>=1?null:Math.atanh(t)))}cbrt(){return g(this,w(Math.cbrt))}ceil(){return g(this,w(Math.ceil))}clip(t=null,e=null){return g(this,w(n=>t!==null&&e!==null?yt({val:n,min:t,max:e}):t!==null?Math.max(n,t):e!==null?Math.min(n,e):n))}cos(){return g(this,w(Math.cos))}cosh(){return g(this,w(Math.cosh))}degrees(){return g(this,w(t=>t*(180/Math.PI)))}div(t){return g(this,U(this,t,(e,n)=>n===0?null:e/n))}exp(){return g(this,w(Math.exp))}expm1(){return g(this,w(Math.expm1))}floor(){return g(this,w(Math.floor))}floordiv(t){return g(this,U(this,t,(e,n)=>n===0?null:Math.floor(e/n)))}hypot(t){return g(this,U(this,t,(e,n)=>Math.hypot(e,n)))}log(t=Math.E){return g(this,w(e=>e<=0?null:t===Math.E?Math.log(e):Math.log(e)/Math.log(t)))}log1p(){return g(this,w(t=>t<=-1?null:Math.log1p(t)))}mod(t){return g(this,U(this,t,(e,n)=>n===0?null:e%n))}mul(t){return g(this,U(this,t,(e,n)=>e*n))}negate(){return g(this,w(t=>-t))}pow(t){return g(this,U(this,t,(e,n)=>Math.pow(e,n)))}radians(){return g(this,w(t=>t*(Math.PI/180)))}rand(t,{min:e=0,max:n=1,integer:r=!1}={}){return g(this,o=>{let i=o.length,a=new Float64Array(i),l=t!==void 0?tn(t):Math.random,u=n-e;for(let c=0;c<i;c++){let h=l();a[c]=r?Math.floor(h*(u+1))+e:h*u+e}return a})}round(t=0){let e=Math.pow(10,t);return g(this,w(n=>Math.round(n*e)/e))}sign(){return g(this,w(Math.sign))}sin(){return g(this,w(Math.sin))}sinh(){return g(this,w(Math.sinh))}sqrt(){return g(this,w(t=>t<0?null:Math.sqrt(t)))}sub(t){return g(this,U(this,t,(e,n)=>e-n))}tan(){return g(this,w(Math.tan))}tanh(){return g(this,w(Math.tanh))}trunc(){return g(this,w(Math.trunc))}};function P(s){return s==null?s:s instanceof Date?`d:${s.getTime()}`:s instanceof Uint8Array?`u:${s.toString()}`:typeof s=="object"||typeof s=="function"?String(s):s}var me=s=>class extends s{between(t,e,n="both"){return g(this,(r,o)=>{let i=r.length,a=this._resolve(t,o,i),l=this._resolve(e,o,i),u=new Array(i),c=D(a),h=D(l);for(let f=0;f<i;f++){let m=r[f],p=c?a[f]:a,y=h?l[f]:l;if(m==null||p==null||y==null)u[f]=null;else{let x=n==="both"||n==="left"?m>=p:m>p,b=n==="both"||n==="right"?m<=y:m<y;u[f]=x&&b}}return u})}eq(t){return g(this,U(this,t,(e,n)=>e===n))}eq_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!0:l==null||u==null?i[a]=!1:i[a]=l===u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!0:l==null||o==null?i[a]=!1:i[a]=l===o}return i})}ge(t){return g(this,U(this,t,(e,n)=>e>=n))}gt(t){return g(this,U(this,t,(e,n)=>e>n))}has_nulls(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}is_close(t,e={}){let{abs_tol:n=1e-8,rel_tol:r=1e-8,nans_equal:o=!1}=e;return g(this,(i,a)=>{let l=i.length,u=this._resolve(t,a,l),c=D(u),h=new Array(l);for(let f=0;f<l;f++){let m=i[f],p=c?u[f]:u;if(m==null||p==null)h[f]=null;else if(Number.isNaN(m)||Number.isNaN(p))o&&Number.isNaN(m)&&Number.isNaN(p)?h[f]=!0:h[f]=!1;else if(!Number.isFinite(m)||!Number.isFinite(p))h[f]=m===p;else{let y=Math.abs(m-p),x=Math.max(r*Math.max(Math.abs(m),Math.abs(p)),n);h[f]=y<=x}}return h})}is_duplicated(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=(n.get(r[i])||0)>1;return o})}is_empty(t={}){let{ignoreNulls:e=!1}=t;return g(this,w(n=>{if(typeof n=="string")return n.length===0;if(D(n)){if(e){let r=n.length,o=0;for(let i=0;i<r;i++)n[i]!=null&&o++;return o===0}return n.length===0}return null}))}is_finite(){return g(this,w(Number.isFinite))}is_first_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=0;o<e;o++){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:a.has(P(c))}}return o})}is_infinite(){return g(this,w(t=>t===1/0||t===-1/0))}is_last_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=e-1;o>=0;o--){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_n_distinct(t){return this._deriveAgg(e=>{let n=new Set,r=e.length;for(let o=0;o<r;o++)n.add(P(e[o]));return n.size===t})}is_nan(){return g(this,w(Number.isNaN))}is_not_nan(){return g(this,w(t=>!Number.isNaN(t)))}is_not_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]!=null;return n})}is_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]==null;return n})}is_unique(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=n.get(r[i])===1;return o})}le(t){return g(this,U(this,t,(e,n)=>e<=n))}lt(t){return g(this,U(this,t,(e,n)=>e<n))}ne(t){return g(this,U(this,t,(e,n)=>e!==n))}ne_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!1:l==null||u==null?i[a]=!0:i[a]=l!==u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!1:l==null||o==null?i[a]=!0:i[a]=l!==o}return i})}not_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=!c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:!a.has(P(c))}}return o})}};function W(s,t,e,n=""){if(!(s in t))throw new wt(s,`${e} "${s}" does not exist${n}`)}var ct=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},V=class extends ct{},wt=class extends V{constructor(t,e){super(e||`Column "${t}" does not exist in the DataFrame.`)}},ht=class extends ct{},et=class extends ct{};var pe=s=>class extends s{aggFn=this.aggFn||null;_deriveAgg(t){let e=g(this);return e.aggFn=t,e.groupingOpsIndex=this.ops.length,e.partitionOpsIndex=this.ops.length,e}all(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(!t[e])return!1;return!0})}all_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]!=null)return!1;return!0})}any(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e])return!0;return!1})}any_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}avg(){return this._deriveAgg(t=>j(t).mean)}count(t={}){return t.includeNulls?this._deriveAgg(e=>e.length):this._deriveAgg(e=>j(e).count)}first(){return this._deriveAgg(t=>t[0]??null)}last(){return this._deriveAgg(t=>t[t.length-1]??null)}max(){return this._deriveAgg(t=>j(t).max)}mean(){return this.avg()}median(){return this._deriveAgg(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveAgg(t=>j(t).min)}mode(){return this._deriveAgg(t=>{if(!D(t))return null;let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return null;let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return o.length===0?null:(o.sort((i,a)=>i==null&&a==null?0:i==null?1:a==null||i<a?-1:i>a?1:0),o[0])})}n_unique(){return this._deriveAgg(t=>new Set(t).size)}quantile(t){if(t<0||t>1)throw new et("Quantile q must be between 0 and 1");return this._deriveAgg(e=>{let n=[];for(let l=0;l<e.length;l++)e[l]!=null&&n.push(e[l]);let r=n.length;if(!r)return null;n.sort((l,u)=>l-u);let o=(r-1)*t,i=Math.floor(o),a=Math.ceil(o);return i===a?n[i]:n[i]+(o-i)*(n[a]-n[i])})}std(){return this._deriveAgg(t=>j(t).std)}sum(){return this._deriveAgg(t=>j(t).sum)}};var ge=s=>class extends s{partitionBy=this.partitionBy||null;_rolling(t,e){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=Math.max(0,i-t+1),l=i+1,u=r.slice(a,l);return e(u)},n}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++)n[u]!=null&&i++;return i},e}cum_max(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c>i)&&(i=c)}return i},e}cum_min(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c<i)&&(i=c)}return i},e}cum_prod(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=1,a=!1,l=t?o:0,u=t?n.length-1:o;for(let c=l;c<=u;c++){let h=n[c];h!=null&&(i*=h,a=!0)}return a?i:null},e}cum_sum(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i+=c)}return i},e}dense_rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=Array.from(new Set(e)).sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++)i.set(o[l],l+1);let a=e[r];return i.get(a)??null},t}lag(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i-t>=0&&(a=r[i-t]),a},n}lead(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i+t<r.length&&(a=r[i+t]),a},n}over(t){let e=g(this),n=Array.isArray(t)?t:[t];return e.partitionBy=n,e}rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=[...e].sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++){let u=o[l];i.has(u)||i.set(u,l+1)}let a=e[r];return i.get(a)??null},t}rolling_max(t){return this._rolling(t,e=>j(e).max)}rolling_mean(t){return this._rolling(t,e=>j(e).mean)}rolling_median(t){return this._rolling(t,e=>{if(!Z(e,"number",{allowNulls:!0}))return null;let n=e.length,r=[];for(let a=0;a<n;a++){let l=e[a];l!=null&&r.push(l)}let o=r.length;if(o===0)return null;r.sort((a,l)=>a-l);let i=Math.floor(o/2);return o%2!==0?r[i]:(r[i-1]+r[i])/2})}rolling_min(t){return this._rolling(t,e=>j(e).min)}rolling_quantile(t,e){return this._rolling(e,n=>{let r=[];for(let u=0;u<n.length;u++)n[u]!=null&&r.push(n[u]);let o=r.length;if(o===0)return null;r.sort((u,c)=>u-c);let i=t*(o-1),a=Math.floor(i),l=Math.ceil(i);return a===l?r[a]:r[a]+(i-a)*(r[l]-r[a])})}rolling_rank(t){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=Math.max(0,o-t+1),a=o+1,l=n.slice(i,a),u=n[o];if(u==null)return null;let c=[];for(let m=0;m<l.length;m++)l[m]!=null&&c.push(l[m]);if(c.length===0)return null;let h=[...c].sort((m,p)=>m-p),f=new Map;for(let m=0;m<h.length;m++){let p=h[m];f.has(p)||f.set(p,m+1)}return f.get(u)??null},e}rolling_std(t){return this._rolling(t,e=>j(e).std)}rolling_sum(t){return this._rolling(t,e=>j(e).sum)}row_number(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){return r+1},t.outputName="row_number",t}};var Rt=class{constructor(t){this.expr=t}expr;_deriveString(t){return g(this.expr,w(e=>t(String(e))))}concat(t){return g(this.expr,U(this.expr,t,(e,n)=>String(e)+String(n)))}contains(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>t instanceof RegExp?t.test(e):e.includes(t))}count_matches(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>{if(t instanceof RegExp){let n=t.global?t:new RegExp(t.source,t.flags+"g"),r=e.match(n);return r?r.length:0}else{let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}})}decode_uri_component(){return this._deriveString(t=>{try{return decodeURIComponent(t)}catch{return t}})}encode_uri_component(){return this._deriveString(t=>{try{return encodeURIComponent(t)}catch{return t}})}ends_with(t){return this._deriveString(e=>e.endsWith(t))}explode(){return this._deriveString(t=>t.split(""))}extract(t,e=0){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{let r=n.match(t);return r&&r[e]!==void 0?r[e]:null})}len(){return this.len_chars()}len_bytes(){return this._deriveString(t=>new TextEncoder().encode(t).length)}len_chars(){return this._deriveString(t=>t.length)}lower(){return this._deriveString(t=>t.toLowerCase())}lpad(t,e=" "){return this._deriveString(n=>n.padStart(t,e))}pad_end(t,e=" "){return this.rpad(t,e)}pad_start(t,e=" "){return this.lpad(t,e)}replace(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>n.replace(t,e))}replace_all(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{if(t instanceof RegExp){let r=t.global?t:new RegExp(t.source,t.flags+"g");return n.replace(r,e)}return n.replaceAll(t,e)})}reverse(){return this._deriveString(t=>t.split("").reverse().join(""))}rpad(t,e=" "){return this._deriveString(n=>n.padEnd(t,e))}slice(t,e){return this._deriveString(n=>{let r=t<0?n.length+t:t,o=e!==void 0?r+e:void 0;return n.slice(r,o)})}slice_str(t,e){return this.slice(t,e)}split(t){return this._deriveString(e=>e.split(t))}starts_with(t){return this._deriveString(e=>e.startsWith(t))}strip_chars(t,e){return this._deriveString(n=>ut(n,t,{mode:"both",...e}))}strip_chars_end(t,e){return this._deriveString(n=>ut(n,t,{mode:"end",...e}))}strip_chars_start(t,e){return this._deriveString(n=>ut(n,t,{mode:"start",...e}))}strip_prefix(t){return this._deriveString(e=>ut(e,t,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(t){return this._deriveString(e=>ut(e,t,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(t,e=!0){return this._deriveString(n=>mn(n,t,e))}to_date(){return this._deriveString(t=>{let e=X(t);if(!e)return null;let n=new Date(e);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(X)}to_decimal(t,e){return this._deriveString(n=>St(n,{precision:t,scale:e}))}to_integer(){return this._deriveString(t=>tt(t))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(t=>{let e=X(t);if(e)return e.toISOString().split("T")[1].slice(0,12);let n=t.trim();if(kt.test(n)){let r=new Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(t=>t.replace(/\b\w/g,e=>e.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(t=>t.toUpperCase())}zfill(t){return this._deriveString(e=>e.padStart(t,"0"))}},ye=s=>class extends s{get str(){return new Rt(this)}};var de=s=>class extends s{and(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!1||c===!1?a[l]=!1:u==null||c==null?a[l]=null:a[l]=!0}return a})}not(){return g(this,w(t=>!t))}or(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!0||c===!0?a[l]=!0:u==null||c==null?a[l]=null:a[l]=!1}return a})}xor(t){return g(this,U(this,t,(e,n)=>!!e!=!!n))}};var Ut=class{constructor(t){this.expr=t}expr;_deriveDate(t){return g(this.expr,w(e=>{let n=X(e);return n?t(n):null}))}_deriveDuration(t){return g(this.expr,w(e=>typeof e=="number"?t(e):null))}century(){return this._deriveDate(on)}date(){return this._deriveDate(t=>new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())))}datetime(){return this._deriveDate(t=>t)}day(){return this._deriveDate(t=>t.getUTCDate())}epoch(t="ms"){return this._deriveDate(e=>sn(e,t))}hour(){return this._deriveDate(t=>t.getUTCHours())}is_leap_year(){return this._deriveDate(hn)}microsecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*vt)}millennium(){return this._deriveDate(ln)}millisecond(){return this._deriveDate(t=>t.getUTCMilliseconds())}minute(){return this._deriveDate(t=>t.getUTCMinutes())}month(){return this._deriveDate(t=>t.getUTCMonth()+1)}month_end(){return this._deriveDate(t=>ue(t,1,0))}month_start(){return this._deriveDate(t=>ue(t,0,1))}nanosecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*Ot)}ordinal_day(){return this._deriveDate(un)}quarter(){return this._deriveDate(cn)}second(){return this._deriveDate(t=>t.getUTCSeconds())}strftime(t,e){return this._deriveDate(n=>fn(n,t,e))}time(){return this._deriveDate(t=>t.toISOString().split("T")[1].slice(0,12))}timestamp(t="ms"){return this.epoch(t)}to_string(t,e){return this.strftime(t,e)}total_days(){return this._deriveDuration(t=>t/dt)}total_hours(){return this._deriveDuration(t=>t/rn)}total_microseconds(){return this._deriveDuration(t=>t*vt)}total_milliseconds(){return this._deriveDuration(t=>t)}total_minutes(){return this._deriveDuration(t=>t/nn)}total_nanoseconds(){return this._deriveDuration(t=>t*Ot)}total_seconds(){return this._deriveDuration(t=>t/le)}week(){return this._deriveDate(an)}weekday(){return this._deriveDate(t=>t.getUTCDay()||7)}year(){return this._deriveDate(t=>t.getUTCFullYear())}},xe=s=>class extends s{get dt(){return new Ut(this)}};var Mt=class{constructor(t){this.expr=t}expr;_deriveList(t){return g(this.expr,w(e=>D(e)?t(e):null))}all(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(!e[n])return!1;return!0})}any(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(e[n])return!0;return!1})}contains(t){return this._deriveList(e=>Array.from(e).includes(t))}contains_all(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(!n.includes(t[r]))return!1;return!0})}contains_any(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(n.includes(t[r]))return!0;return!1})}count_matches(t){return this._deriveList(e=>{let n=Array.from(e),r=0;for(let o of n)o===t&&r++;return r})}drop_nulls(){return this._deriveList(t=>{let e=Array.from(t),n=[];for(let r=0;r<e.length;r++)e[r]!=null&&n.push(e[r]);return n})}first(t=!0){return this.get(0,t)}gather(t,e=!0){let n=Array.isArray(t)?t:[t];return this._deriveList(r=>{let o=r.length,i=new Array(n.length);for(let a=0;a<n.length;a++){let l=n[a],u=r.at(l);if(u===void 0&&!e)throw new et(`Index ${l} is out of bounds for list of length ${o}`);i[a]=u??null}return i})}gather_every(t,e=0){if(t<=0)throw new et("Step size n must be positive");return this._deriveList(n=>{let r=n.length,o=[];for(let i=e;i<r;i+=t)o.push(n[i]);return o})}get(t,e=!0){return this._deriveList(n=>{let r=n.at(t);if(r===void 0&&!e)throw new et(`Index ${t} is out of bounds for list of length ${n.length}`);return r??null})}join(t,{ignoreNulls:e=!1}={}){return this._deriveList(n=>{let r=Array.from(n),o=[];for(let i=0;i<r.length;i++){let a=r[i];a!=null?o.push(String(a)):e||o.push("")}return o.join(t)})}last(t=!0){return this.get(-1,t)}len(){return this.lengths()}lengths(){return this._deriveList(t=>t.length)}max(){return this._deriveList(t=>j(t).max)}mean(){return this._deriveList(t=>{let{sum:e,count:n}=j(t);return e!==null&&n>0?e/n:null})}median(){return this._deriveList(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveList(t=>j(t).min)}mode(){return this._deriveList(t=>{let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return[];let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return ce(o)})}n_unique(){return this._deriveList(t=>new Set(Array.from(t)).size)}reverse(){return this._deriveList(t=>Array.from(t).reverse())}slice(t,e){return this._deriveList(n=>{let r=Array.from(n),o=t<0?Math.max(0,r.length+t):t,i=e!==void 0?o+e:r.length;return r.slice(o,i)})}sort(t=!1){return this._deriveList(e=>ce(e,t))}sum(){return this._deriveList(t=>j(t).sum)}unique(){return this._deriveList(t=>Array.from(new Set(t)))}},be=s=>class extends s{get list(){return new Mt(this)}};var dn=s=>class extends s{fill_null(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a];i[a]=l??o[a]}else for(let a=0;a<r;a++){let l=e[a];i[a]=l??o}return i})}reverse(){return g(this,t=>t.slice().reverse())}};var k=class extends be(xe(de(ye(ge(pe(me(fe(dn(bt))))))))){colName;excludedCols=[];constructor(t){super(),this.colName=String(t),this.outputName=this.colName}};function we(s){let t=new k(he);return t.isLiteral=!0,t.literalValue=s,t.ops.push(e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=s;return r}),t}function _e(){return new k("*")}function Te(s){let t=new k("*");return t.excludedCols=Array.isArray(s)?s:[s],t}function De(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,e=new k("*coalesce*");return e.ops.push((n,r)=>{let o=n.length,i=c=>c&&typeof c=="object"&&"evaluate"in c?c.evaluate(r,o):typeof c=="string"?r[c]||new Array(o).fill(null):c,a=t.map(i),l=new Array(o),u=a.length;for(let c=0;c<o;c++){let h=null;for(let f=0;f<u;f++){let m=a[f],p=D(m)?m[c]:m;if(p!=null){h=p;break}}l[c]=h}return l}),e}var Ft=class{predicates;values;constructor(t,e){this.predicates=t,this.values=e}then(t){return new _t(this.predicates,this.values.concat(t))}},Nt=class{predicates;constructor(t){this.predicates=[t]}then(t){return new _t(this.predicates,[t])}},_t=class s extends k{predicates;values;otherwiseValue;constructor(t,e,n=null){super(typeof t=="string"?t:"*when*"),this.predicates=Array.isArray(t)?t:[],this.values=e||[],this.otherwiseValue=n,this.ops.push((r,o)=>{let i=r.length,a=m=>m&&typeof m=="object"&&"evaluate"in m?m.evaluate(o,i):typeof m=="string"&&m in o?o[m]:m,l=this.predicates.map(a),u=this.values.map(a),c=a(this.otherwiseValue),h=new Array(i),f=l.length;for(let m=0;m<i;m++){let p=!1;for(let y=0;y<f;y++)if((D(l[y])?l[y][m]:l[y])===!0){h[m]=D(u[y])?u[y][m]:u[y],p=!0;break}p||(h[m]=D(c)?c[m]:c)}return h})}when(t){return new Ft(this.predicates.concat(t),this.values)}otherwise(t){return new s(this.predicates,this.values,t)}};function Ae(s){return new Nt(s)}function ft(s,t,e){let n=[],r=e?new Set(e):new Set;for(let o of s)if(typeof o=="string")n.push(new k(o));else if(o instanceof k&&o.colName==="*"){let i=new Set(o.excludedCols);for(let a of t)if(!r.has(a)&&!i.has(a)){let l=new k(a);l.ops=[...o.ops],l.aggFn=o.aggFn,l.partitionOpsIndex=o.partitionOpsIndex,l.groupingOpsIndex=o.groupingOpsIndex,l.partitionBy=o.partitionBy,o.evaluateWindow&&(l.evaluateWindow=o.evaluateWindow),o.outputName&&o.outputName!=="*"&&(l.outputName=o.outputName),n.push(l)}}else if(o&&typeof o=="object"&&"evaluate"in o&&!o.colName){for(let i of t)if(!r.has(i)){let a=new k(i);a.ops=[...o.ops],a.aggFn=o.aggFn,a.groupingOpsIndex=o.groupingOpsIndex,a.partitionOpsIndex=o.partitionOpsIndex,n.push(a)}}else n.push(o);return n}var z=class{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}},lt=class extends z{get isNumeric(){return!0}},Tt=class extends lt{get isInteger(){return!0}},ot=class extends Tt{get isSigned(){return!0}},it=class extends Tt{get isUnsigned(){return!0}},mt=class extends lt{get isFloat(){return!0}},at=class extends z{get isTemporal(){return!0}},pt=class extends z{get isNested(){return!0}};var Lt=class extends ot{name="Int8";coerce(t){return tt(t,"Int8")}equals(t){return t.name==="Int8"}allocate(t){return new Int8Array(t)}},Ce=new Lt,jt=class extends ot{name="Int16";coerce(t){return tt(t,"Int16")}equals(t){return t.name==="Int16"}allocate(t){return new Int16Array(t)}},Ie=new jt,Bt=class extends ot{name="Int32";coerce(t){return tt(t,"Int32")}equals(t){return t.name==="Int32"}allocate(t){return new Int32Array(t)}},Se=new Bt,Vt=class extends ot{name="Int64";coerce(t){return ae(t)}equals(t){return t.name==="Int64"}allocate(t){return new BigInt64Array(t)}},ke=new Vt,Kt=class extends it{name="UInt8";coerce(t){return tt(t,"UInt8")}equals(t){return t.name==="UInt8"}allocate(t){return new Uint8Array(t)}},Ee=new Kt,$t=class extends it{name="UInt16";coerce(t){return tt(t,"UInt16")}equals(t){return t.name==="UInt16"}allocate(t){return new Uint16Array(t)}},ve=new $t,Pt=class extends it{name="UInt32";coerce(t){return tt(t,"UInt32")}equals(t){return t.name==="UInt32"}allocate(t){return new Uint32Array(t)}},Oe=new Pt,Wt=class extends it{name="UInt64";coerce(t){return ae(t,"UInt64")}equals(t){return t.name==="UInt64"}allocate(t){return new BigUint64Array(t)}},Re=new Wt,qt=class extends mt{name="Float32";coerce(t){return ie(t,"Float32")}equals(t){return t.name==="Float32"}allocate(t){return new Float32Array(t)}},Ue=new qt,Ht=class extends mt{name="Float64";coerce(t){return ie(t,"Float64")}equals(t){return t.name==="Float64"}allocate(t){return new Float64Array(t)}},Me=new Ht,Dt=class s extends lt{constructor(e,n){super();this.precision=e;this.scale=n;this.name=e!==void 0&&n!==void 0?`Decimal(${e}, ${n})`:"Decimal"}precision;scale;name;coerce(e){return St(e,{precision:this.precision,scale:this.scale})}equals(e){return e instanceof s&&this.precision===e.precision&&this.scale===e.scale}allocate(e){return new Array(e).fill(null)}},Gt=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)}},Fe=new Gt,zt=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)}},Ne=new zt,Yt=class extends z{name="Binary";get isBinary(){return!0}coerce(t){return gn(t)}equals(t){return t.name==="Binary"}allocate(t){return new Array(t).fill(null)}},Le=new Yt,Zt=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)}},je=new Zt,Xt=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)}},Be=new Xt,Jt=class extends at{name="Date";coerce(t){let e=X(t);return e?(e.setUTCHours(0,0,0,0),e):null}equals(t){return t.name==="Date"}allocate(t){return new Array(t).fill(null)}},Ve=new Jt,Qt=class extends at{name="Datetime";coerce(t){return X(t)}equals(t){return t.name==="Datetime"}allocate(t){return new Array(t).fill(null)}},Ke=new Qt,te=class extends at{name="Time";coerce(t){if(t==null)return null;if(typeof t=="string"){let n=t.trim();if(kt.test(n)){let r=new globalThis.Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}}let e=X(t);return e?e.toISOString().split("T")[1].slice(0,12):null}equals(t){return t.name==="Time"}allocate(t){return new Array(t).fill(null)}},$e=new te,ee=class extends at{name="Duration";coerce(t){return Q(t)}equals(t){return t.name==="Duration"}allocate(t){return new Array(t).fill(null)}},Pe=new ee,ne=class s extends pt{constructor(e){super();this.innerType=e}innerType;name="List";coerce(e){if(e==null)return null;let n=D(e)?Array.from(e):[e],r=n.length,o=new Array(r);for(let i=0;i<r;i++)o[i]=this.innerType.coerce(n[i]);return o}equals(e){return e instanceof s&&this.innerType.equals(e.innerType)}allocate(e){return new Array(e).fill(null)}},We=s=>new ne(s),re=class s extends pt{constructor(e){super();this.fields=e}fields;name="Struct";coerce(e){if(!Y(e))return null;let n={};for(let[r,o]of globalThis.Object.entries(this.fields))n[r]=o.coerce(e[r]);return n}equals(e){if(!(e instanceof s))return!1;let n=globalThis.Object.keys(this.fields),r=globalThis.Object.keys(e.fields);if(n.length!==r.length)return!1;for(let o of n)if(!e.fields[o]||!this.fields[o].equals(e.fields[o]))return!1;return!0}allocate(e){return new Array(e).fill(null)}},qe=s=>new re(s);var L={Int8:Ce,Int16:Ie,Int32:Se,Int64:ke,UInt8:Ee,UInt16:ve,UInt32:Oe,UInt64:Re,Float32:Ue,Float64:Me,Decimal:(s,t)=>new Dt(s,t),Boolean:Fe,Utf8:Ne,Binary:Le,Date:Ve,Datetime:Ke,Time:$e,Duration:Pe,Object:Be,Null:je,List:We,Struct:qe};function En(s,t,e){let n=new Map,r=e.length,o=new Array(r);for(let i=0;i<r;i++){let a=e[i];typeof a=="string"?(W(a,s,"Partition key"," in the DataFrame."),o[i]=s[a]):o[i]=a.evaluate(s,t)}for(let i=0;i<t;i++){let a=new Array(o.length);for(let c=0;c<o.length;c++){let h=o[c][i];a[c]=h==null?"":String(h)}let l=a.join("\0"),u=n.get(l);u===void 0&&(u=[],n.set(l,u)),u.push(i)}return n}function se(s,t,e){let n=new Array(e);if(e===0)return n;let r=s.partitionBy||[],o=En(t,e,r),i=s.evaluatePrePartition(t,e);for(let a of o.values()){let l=a.length,u=new Array(l);for(let c=0;c<l;c++)u[c]=i[a[c]];if(s.evaluateWindow){for(let c=0;c<l;c++)n[a[c]]=s.evaluateWindow(u,a,c);continue}if(s.aggFn){let c=s.aggFn(u);for(let h=0;h<l;h++)n[a[h]]=c;continue}for(let c=0;c<l;c++)n[a[c]]=i[a[c]]}return s.evaluatePostPartition(n,t)}function He(s){if(!Array.isArray(s)||s.length===0)return{columns:{},height:0};let t=s.length,e=new Set;for(let o=0;o<t;o++){let i=s[o];if(Y(i)){let a=Object.keys(i);for(let l=0;l<a.length;l++)e.add(a[l])}}let n=Array.from(e),r={};for(let o=0;o<n.length;o++)r[n[o]]=new Array(t);for(let o=0;o<t;o++){let i=s[o]||{};for(let a=0;a<n.length;a++){let l=n[a],u=i[l];r[l][o]=u===void 0?null:u}}return{columns:r,height:t}}function Ge(s,t){let e=Object.keys(s),n=new Array(t);for(let r=0;r<t;r++){let o={};for(let i=0;i<e.length;i++){let a=e[i],l=s[a][r];o[a]=l===void 0?null:l}n[r]=o}return n}function vn(s,t,e){let n={};for(let r=0;r<e.length;r++){let o=e[r],i=s[o][t];n[o]=i===void 0?null:i}return n}function nt(s){if(s.length===0)return L.Utf8;let t=!0,e=!0,n=!0,r=!0,o=!0,i=!0,a=!1,l=!1,u=[];for(let c=0;c<s.length;c++){let h=s[c];if(h!=null){if(l=!0,!Array.isArray(h))i=!1;else for(let f=0;f<h.length;f++)u.push(h[f]);h instanceof Date&&(a=!0),typeof h!="boolean"&&(t=!1),typeof h!="bigint"&&(r=!1),typeof h!="number"?(n=!1,e=!1):Number.isInteger(h)||(e=!1),!(h instanceof Date)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(o=!1)}}if(!l)return L.Utf8;if(i){let c=nt(u);return L.List(c)}if(t)return L.Boolean;if(r)return L.Int64;if(n&&!e)return L.Float64;if(n&&e){let c=!0;for(let h=0;h<s.length;h++){let f=s[h];if(f!=null&&(f<-2147483648||f>2147483647)){c=!1;break}}return c?L.Int32:L.Float64}return o&&a?L.Datetime:L.Utf8}function At(s,t){let e=Object.keys(s),n=e.length,r=t.length,o={};for(let i=0;i<n;i++){let a=e[i],l=s[a],u=new Array(r);for(let c=0;c<r;c++)u[c]=l[t[c]];o[a]=u}return o}var Ct=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(t,e,n,r,o,i){this.groups=t,this.keys=e,this.allKeys=n,this.parentColumns=r,this.parentHeight=o,this.parentSchema=i}to_dataframe(){let t=this.keys.length,e=new Array(t);for(let a=0;a<t;a++)e[a]=String(this.keys[a]);let n=this.groups.size,r={};for(let a=0;a<e.length;a++)r[e[a]]=new Array(n);let o=0;for(let a of this.groups.values()){if(a.length===0)continue;let l=a[0];for(let u=0;u<e.length;u++){let c=e[u],h=this.parentColumns[c][l];r[c][o]=h===void 0?null:h}o++}let i={};for(let a of e)i[a]=this.parentSchema[a];return new F(r,i,o)}agg(...t){let e=this.allKeys.length,n=new Array(e);for(let h=0;h<e;h++)n[h]=String(this.allKeys[h]);let r=this.keys.length,o=new Array(r);for(let h=0;h<r;h++)o[h]=String(this.keys[h]);let i=ft(t.flat(),n,o),a=this.groups.size,l={};for(let h=0;h<o.length;h++)l[o[h]]=new Array(a);let u=0;for(let h of this.groups.values()){if(h.length===0)continue;let f=h[0];for(let m=0;m<o.length;m++){let p=o[m],y=this.parentColumns[p][f];l[p][u]=y===void 0?null:y}u++}for(let h=0;h<i.length;h++){let f=i[h],m=f.outputName||f.colName||"*";if(!f.aggFn){l[m]=f.evaluate(l,a);continue}let p=f.evaluatePreGrouping(this.parentColumns,this.parentHeight),y=new Array(a),x=0;for(let b of this.groups.values()){if(b.length===0)continue;let T=new Array(b.length);for(let A=0;A<b.length;A++)T[A]=p[b[A]];y[x]=f.aggFn(T),x++}l[m]=f.evaluatePostGrouping(y,l)}let c={};for(let h of o)c[h]=this.parentSchema[h];for(let h of i){let f=h.outputName||h.colName||"*";c[f]=nt(l[f])}return new F(l,c,u)}};function xn(s,t,e){if(s==null)throw new V(`Invalid input to ${t} at index ${e}: item cannot be null or undefined.`);if(s instanceof F)return[s];if(xt(s))return[new F(s)];if(D(s)){if(Z(s,F,{mode:"every"}))return s;if(Z(s,"plainObject",{mode:"every"}))return[new F(s)];let n=Z(s,F,{mode:"some"});for(let r=0;r<s.length;r++)if(n?!(s[r]instanceof F):!xt(s[r]))throw new V(n?`Invalid input to ${t} at index ${e}, sub-index ${r}: nested array must contain only DataFrame instances.`:`Invalid input to ${t} at index ${e}, row ${r}: rows must be plain objects.`)}throw new V(`Invalid input to ${t} at index ${e}: expected DataFrame, row array, or column dictionary.`)}function It(s,t={}){if(s==null)throw new V("Invalid input to concat: rawItems cannot be null or undefined.");let e=Array.isArray(s)?s:[s],n=[];for(let i=0;i<e.length;i++)n.push(...xn(e[i],"concat",i));let{how:r="vertical"}=t,o=t.horizontal?.strict??!0;if(n.length===0)return new F({},{},0);if(n.length===1&&r!=="horizontal")return n[0];switch(r){case"vertical":{let i=[];for(let m=0;m<n.length;m++)n[m].height>0&&i.push(n[m]);if(i.length===0)return new F({},{},0);let a=i[0],l=Object.keys(a._columns);for(let m=0;m<n.length;m++){let p=n[m];if(p.height===0)continue;let y=Object.keys(p._columns);if(l.length!==y.length)throw new V(`[Strict Vertical] Column count mismatch at index ${m}.`);for(let x=0;x<l.length;x++){if(l[x]!==y[x])throw new V(`[Strict Vertical] Schema mismatch at position ${x} in DF ${m}. Expected column "${l[x]}", but found "${y[x]}".`);let b=a.schema[l[x]],T=p.schema[l[x]];if(b&&T&&!b.equals(T))throw new ht(`[Strict Type Check] Schema type mismatch for column "${l[x]}": expected ${b.name}, found ${T.name}.`)}}let u=0;for(let m of n)u+=m.height;let c=n.find(m=>m.height>0)?.schema||n[0]?.schema||{},h={};for(let m of l){let p=c[m],y=!1;for(let b of n){let T=b._columns[m];if(!T){y=!0;break}if(!$(T)){for(let A=0;A<T.length;A++)if(T[A]==null){y=!0;break}}if(y)break}let x=p&&p.allocate?p.allocate(u):new Array(u).fill(null);y&&$(x)&&(x=new Array(u).fill(null)),h[m]=x}let f=0;for(let m of n){let p=m.height;if(p!==0){for(let y of l){let x=m._columns[y]||new Array(p).fill(null),b=h[y];if($(b)&&$(x))b.set(x,f);else{let T=b;for(let A=0;A<p;A++)T[f+A]=x[A]}}f+=p}}return new F(h,c,u)}case"horizontal":{let i=n[0].height;for(let c=1;c<n.length;c++)n[c].height>i&&(i=n[c].height);let a=new Set;for(let c=0;c<n.length;c++){let h=n[c];if(o&&h.height!==i)throw new V(`[Horizontal] Row count mismatch at index ${c}. Expected ${i}, got ${h.height}. Set strict=false to allow padding.`);for(let f of Object.keys(h._columns)){if(a.has(f))throw new V(`[Horizontal] Duplicate column name "${f}" detected. Horizontal concat requires unique names.`);a.add(f)}}let l={},u={};for(let c of n){let h=c.height;Object.assign(u,c.schema);for(let[f,m]of Object.entries(c._columns))if(h===i)l[f]=$(m)?Array.from(m):m;else{let p=new Array(i);for(let y=0;y<h;y++)p[y]=m[y];for(let y=h;y<i;y++)p[y]=null;l[f]=p}}return new F(l,u,i)}case"diagonal":{let i=new Set;for(let f of n)for(let m of Object.keys(f._columns))i.add(m);let a=Array.from(i),l=0;for(let f=0;f<n.length;f++)l+=n[f].height;let u={};for(let f of a){let m=null;for(let p of n){let y=p.schema[f];if(y){if(m===null)m=y;else if(!m.equals(y))throw new ht(`[Strict Type Check] Schema type mismatch for column "${f}": expected ${m.name}, found ${y.name}.`)}}u[f]=m||L.Utf8}let c={};for(let f=0;f<a.length;f++)c[a[f]]=new Array(l).fill(null);let h=0;for(let f=0;f<n.length;f++){let m=n[f],p=m.height;if(p!==0){for(let y=0;y<a.length;y++){let x=a[y],b=c[x],T=m._columns[x];if(T!==void 0)if($(T)&&$(b))b.set(T,h);else{let A=b;for(let S=0;S<p;S++)A[h+S]=T[S]}else{let A=b;for(let S=0;S<p;S++)A[h+S]=null}}h+=p}}return new F(c,u,l)}}}var F=class s{_columns;_height;_schema={};constructor(t,e,n){if(Array.isArray(t)){let{columns:r,height:o}=He(t);this._columns=r,this._height=o,e?this.applySchema(e):this.inferSchema();return}if(Y(t)){let r=-1;for(let[o,i]of Object.entries(t)){let a=D(i)?i.length:0;if(r===-1)r=a;else if(a!==r)throw new V(`Column height mismatch: Column "${o}" has length ${a}, but previous columns have length ${r}`)}this._columns=t,this._height=n!==void 0?n:r===-1?0:r,e?this.applySchema(e):this.inferSchema();return}this._columns={},this._height=0,e?this.applySchema(e):this._schema={}}inferSchema(){let t={},e=Object.keys(this._columns);for(let n of e)t[n]=nt(this._columns[n]);this._schema=t}applySchema(t){this._schema=t;let e=Object.keys(t),n={};for(let r of e){let o=t[r],i=this._columns[r],a=o.allocate?o.allocate(this._height):new Array(this._height).fill(null);if(!i){this._height>0&&$(a)&&(a=new Array(this._height).fill(null)),n[r]=a;continue}let l=!1,u=new Array(this._height);for(let c=0;c<this._height;c++){let h=o.coerce(i[c]);u[c]=h,h==null&&(l=!0)}l&&$(a)&&(a=new Array(this._height));for(let c=0;c<this._height;c++)a[c]=u[c];n[r]=a}this._columns=n}getSchema(){return this._schema}to_dicts(){return Ge(this._columns,this._height)}to_dict(){return{...this._columns}}get columns(){return Object.keys(this._columns)}concat(t,e={}){let n=Z(t,s,{mode:"every",allowEmpty:!1})?t:[t];return It([this,...n],e)}drop(...t){let e=new Set(t.flat()),n={},r={};for(let o of Object.keys(this._columns))e.has(o)||(n[o]=this._columns[o],r[o]=this._schema[o]);return new s(n,r,this._height)}get dtypes(){let t=Object.keys(this._columns),e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=this._schema[t[r]];return n}filter(...t){if(this._height===0)return new s({},this._schema,0);let e=this._height,n=Object.keys(this._columns),r=n.length,o=[],i=[];for(let f of t)typeof f=="function"?i.push(f):o.push(f.evaluate(this._columns,e));let a=[],l=0,u=null;if(i.length>0){let f=this._columns;u={};for(let m=0;m<r;m++){let p=n[m],y=f[p];Object.defineProperty(u,p,{get(){let x=y[l];return x===void 0?null:x},enumerable:!0,configurable:!0})}}for(let f=0;f<e;f++){let m=!0;for(let p=0;p<o.length;p++)if(!o[p][f]){m=!1;break}if(m){if(u){l=f;for(let p=0;p<i.length;p++)if(!i[p](u)){m=!1;break}}m&&a.push(f)}}let c=At(this._columns,a),h=a.length;return new s(c,this._schema,h)}groupby(t){let e=st(t),n=new Map,r=this._height,o=e.length,i=new Array(o);for(let c=0;c<o;c++)i[c]=String(e[c]);for(let c=0;c<i.length;c++)W(i[c],this._columns,"Grouping key");let a=o===1?i[0]:null,l=a?this._columns[a]:null;for(let c=0;c<r;c++){let h;if(a){let m=l[c];h=m==null?"":String(m)}else{let m=new Array(o);for(let p=0;p<o;p++){let y=this._columns[i[p]][c];m[p]=y==null?"":String(y)}h=m.join("\0")}let f=n.get(h);f===void 0&&n.set(h,f=[]),f.push(c)}let u=Object.keys(this._columns);return new Ct(n,e,u,this._columns,this._height,this._schema)}head(t=10){return this.limit(t,{offset:0,from:"start"})}get height(){return this._height}hstack(t,e={}){return this.concat(t,{how:"horizontal",horizontal:e})}join(t){let{other:e,on:n,how:r="inner",suffixes:o=["","_right"]}=t,i=st(n);for(let _ of i){let C=String(_);W(C,this._columns,"Join key"," in the left DataFrame."),W(C,e._columns,"Join key"," in the right DataFrame.")}let[a,l]=o,u=Object.keys(this._columns),c=Object.keys(e._columns),h=new Set(i),f=u.length,m=c.length,p=(_,C)=>{let v=i.length;if(v===1){let O=_[i[0]][C];return O==null?null:String(O)}let M=new Array(v);for(let O=0;O<v;O++){let q=_[i[O]][C];if(q==null)return null;M[O]=String(q)}return M.join("\0")},y=new Map,x=e._height,b=e._columns;for(let _=0;_<x;_++){let C=p(b,_);if(C===null)continue;let v=y.get(C);v===void 0&&(v=[],y.set(C,v)),v.push(_)}let T=this._height,A=this._columns,S=[],d=[],I=r==="outer"||r==="right",R=I?new Set:null;for(let _=0;_<T;_++){let C=p(A,_),v=C===null?void 0:y.get(C);if(v===void 0)(r==="left"||r==="outer")&&(S.push(_),d.push(null));else for(let M=0;M<v.length;M++){let O=v[M];I&&R.add(O),S.push(_),d.push(O)}}if(I)for(let _=0;_<x;_++)R.has(_)||(S.push(-1),d.push(_));let E=S.length,N={},K={};for(let _=0;_<f;_++){let C=u[_],v=C in e._columns&&!h.has(C)?`${C}${a}`:C,M=this._columns[C],O=h.has(C),q=new Array(E);if(O){let H=e._columns[C];for(let J=0;J<E;J++){let ze=S[J];if(ze!==-1)q[J]=M[ze];else{let Ye=d[J];q[J]=Ye!==null?H[Ye]:null}}}else for(let H=0;H<E;H++){let J=S[H];q[H]=J!==-1?M[J]:null}N[v]=q,this._schema[C]&&(K[v]=this._schema[C])}for(let _=0;_<m;_++){let C=c[_];if(!h.has(C)){let v=C in this._columns?`${C}${l}`:C,M=e._columns[C],O=new Array(E);for(let q=0;q<E;q++){let H=d[q];O[q]=H!==null?M[H]:null}N[v]=O,e._schema[C]&&(K[v]=e._schema[C])}}return new s(N,K,E)}limit(t,e={}){let{offset:n=0,from:r="start"}=e,o=this._height,i=isNaN(t)?0:Math.max(Math.floor(t),0),a=isNaN(n)?0:Math.max(Math.floor(n),0);if(i===0||o===0||a>=o){let f={},m={};for(let p of Object.keys(this._columns))f[p]=[],m[p]=this._schema[p];return new s(f,m,0)}let l=0,u=0;r==="end"?(u=Math.max(o-a,0),l=Math.max(u-i,0)):(u=Math.min(a+i,o),l=a);let c=Math.max(u-l,0),h={};for(let f of Object.keys(this._columns))h[f]=this._columns[f].slice(l,u);return new s(h,this._schema,c)}pivot(t){if(this._height===0)return new s({},{},0);let{index:e,columns:n,values:r}=t,o=st(e),i=o.length,a=new Array(i);for(let d=0;d<i;d++)a[d]=String(o[d]);let l=String(n),u=String(r);for(let d of a)W(d,this._columns,"Pivot index key"," in the DataFrame.");W(l,this._columns,"Pivot column key"),W(u,this._columns,"Pivot values key"," in the DataFrame.");let c=new Map,h=new Set,f=this._height,m=this._columns[l],p=this._columns[u];for(let d=0;d<f;d++){let I=new Array(i);for(let K=0;K<i;K++){let _=this._columns[a[K]][d];I[K]=_==null?"":String(_)}let R=I.join("\0"),E=String(m[d]);h.add(E);let N=c.get(R);N===void 0&&(N={firstIdx:d,indices:[]},c.set(R,N)),N.indices.push(d)}let y=c.size,x={},b={};for(let d=0;d<i;d++){let I=a[d];x[I]=new Array(y),this._schema[I]&&(b[I]=this._schema[I])}let T=Array.from(h),A=this._schema[u]||L.Utf8;for(let d=0;d<T.length;d++){let I=T[d];x[I]=new Array(y).fill(null),b[I]=A}let S=0;for(let d of c.values()){let I=d.firstIdx;for(let E=0;E<i;E++){let N=a[E];x[N][S]=this._columns[N][I]}let R=d.indices;for(let E=0;E<R.length;E++){let N=R[E],K=String(m[N]);x[K][S]=p[N]}S++}return new s(x,b,y)}rename(t){let e=t||{},n={},r={},o=Object.keys(this._columns);for(let a of o){let l=e[a]||a;n[l]=this._columns[a],r[l]=this._schema[a]}if(Object.keys(n).length<o.length)throw new V("Rename collision: Multiple columns mapped to the same output name.");return new s(n,r,this._height)}reverse(){if(this._height===0)return this;let t={},e=Object.keys(this._columns),n=e.length;for(let r=0;r<n;r++){let o=e[r];t[o]=this._columns[o].slice().reverse()}return new s(t,this._schema,this._height)}get schema(){return this._schema}select(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o={},i={};for(let a of r){let l=a.outputName||a.colName||"*";if(l in o)throw new V(`Duplicate column selection: "${l}" is selected multiple times.`);o[l]=a.isWindow?se(a,this._columns,this._height):a.evaluate(this._columns,this._height);let u=a.colName||l,c=a instanceof k&&a.ops.length===0&&!a.isWindow&&!a.aggFn;i[l]=c&&this._schema[u]?this._schema[u]:nt(o[l])}return new s(o,i,this._height)}get shape(){return[this.height,this.width]}slice(t,e){let n=this._height,r=t<0?Math.max(n+t,0):Math.min(t,n),o=e===void 0?n:e<0?Math.max(n+e,0):Math.min(e,n),i=Math.max(o-r,0);return this.limit(i,{offset:r})}sort(t){if(!t||!t.by||this._height===0)return this;let{by:e,descending:n=!1,nullsLast:r=!0,custom:o}=t,i=st(e);for(let p=0;p<i.length;p++){let y=i[p];typeof y=="string"&&W(y,this._columns,"Sort key")}let a=Array.isArray(n)?n:new Array(i.length).fill(n),l=i.length,u=new Array(l);for(let p=0;p<l;p++){let y=i[p],x=a[p]?-1:1,b=o&&typeof y=="string"?o[y]:null,T=y?.evaluate?y.evaluate(this._columns,this._height):this._columns[y]||new Array(this._height).fill(null);u[p]={values:T,isDesc:x,customComp:b}}let c=u.length,h=r?1:-1,f=new Array(this._height);for(let p=0;p<this._height;p++)f[p]=p;f.sort((p,y)=>{for(let x=0;x<c;x++){let{values:b,isDesc:T,customComp:A}=u[x],S=b[p],d=b[y];if(A){let R=A(S,d);if(R!==0)return R*T;continue}if(S==null||d==null){if(S===d)continue;return(S==null?1:-1)*h}if(S===d)continue;return(S<d?-1:1)*T}return 0});let m=At(this._columns,f);return new s(m,this._schema,this._height)}tail(t=10){return this.limit(t,{offset:0,from:"end"})}to_list(t){if(this._height===0)return[];let e=t&&typeof t!="string"&&"evaluate"in t,n;if(e)n=t.evaluate(this._columns,this._height);else{let r=t;if(r==null)return new Array(this._height).fill(null);W(r,this._columns,"Column"),n=this._columns[r]}return Array.isArray(n)?n:Array.from(n)}unique(t){if(this._height===0)return new s({},this._schema,0);let e=st(t),n=e.length===0?Object.keys(this._columns):e.map(String);for(let h of n)W(h,this._columns,"Unique column key");let r=new Set,o=[],i=n.length,a=this._height,l=i===1?this._columns[n[0]]:null;for(let h=0;h<a;h++){let f;if(l){let m=l[h];f=m==null?"":String(m)}else{let m=new Array(i);for(let p=0;p<i;p++){let y=this._columns[n[p]][h];m[p]=y==null?"":String(y)}f=m.join("\0")}r.has(f)||(r.add(f),o.push(h))}let u=At(this._columns,o),c=o.length;return new s(u,this._schema,c)}unpivot(t){let{idVars:e,valueVars:n,varName:r="variable",valueName:o="value"}=t,i=st(e).map(String),a=st(n).map(String),l=i.length,u=a.length;for(let p of i)W(p,this._columns,"Unpivot id variable key");for(let p of a)W(p,this._columns,"Unpivot value variable key");let c=this._height*u,h={};for(let p=0;p<l;p++)h[i[p]]=new Array(c);h[r]=new Array(c),h[o]=new Array(c);let f=0;for(let p=0;p<this._height;p++)for(let y=0;y<u;y++){let x=a[y];for(let b=0;b<l;b++){let T=i[b];h[T][f]=this._columns[T][p]}h[r][f]=x,h[o][f]=this._columns[x][p],f++}let m={};for(let p of i)m[p]=this._schema[p];return m[r]=L.Utf8,m[o]=nt(h[o]),new s(h,m,c)}vstack(t){return this.concat(t,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(t){let e=t.flat(),n=[];for(let r of e)if(typeof r=="string")n.push(new k(r));else if(Y(r)&&"evaluate"in r)n.push(r);else if(Y(r))for(let[o,i]of Object.entries(r))if(Y(i)&&"evaluate"in i)n.push(i.alias(o));else{let a=new k(o);a.evaluate=(l,u)=>new Array(u).fill(i),n.push(a)}return n}with_columns(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o=r.length,i={...this._columns},a={...this._schema};for(let l=0;l<o;l++){let u=r[l],c=u.outputName||u.colName||"*";u.isWindow?i[c]=se(u,this._columns,this._height):i[c]=u.evaluate(this._columns,this._height);let h=u.colName||c;u instanceof k&&u.ops.length===0&&!u.isWindow&&!u.aggFn&&this._schema[h]?a[c]=this._schema[h]:a[c]=nt(i[c])}return new s(i,a,this._height)}};var On={data:(s,t)=>new F(s,t),col:s=>new k(s),all:_e,exclude:Te,coalesce:De,concat:It,lit:we,when:Ae,DataType:L};0&&(module.exports={$tbl,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Binary,BinaryType,Boolean,BooleanType,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,LITERAL_MARKER,List,ListExpr,ListExprNamespace,ListType,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectType,SchemaError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,all,assertColumnExists,coalesce,columnsToRows,concat,derive,exclude,gatherColumnsByIndices,getRowFromColumns,inferColumnType,kleeneBinary,kleeneUnary,lit,normalizeToDataFrames,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,when});
1
+ "use strict";var bn=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var No=Object.prototype.hasOwnProperty;var E=(n,e)=>()=>(n&&(e=n(n=0)),e);var Ar=(n,e)=>{for(var t in e)bn(n,t,{get:e[t],enumerable:!0})},vo=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ro(e))!No.call(n,o)&&o!==t&&bn(n,o,{get:()=>e[o],enumerable:!(r=Eo(e,o))||r.enumerable});return n};var Tr=n=>vo(bn({},"__esModule",{value:!0}),n);var G,xn,_n,ze,ae=E(()=>{"use strict";G="*",xn="*literal*",_n="*coalesce*",ze="*element*"});function P(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Ce(n){if(!P(n))return!1;let e=Object.getPrototypeOf(n);if(e===null)return!0;let t=Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor;return typeof t!="function"?!1:Function.prototype.toString.call(t)===Zo}function Vr(n){if(typeof n!="function")return!1;let e="";try{e=Function.prototype.toString.call(n)}catch{return!1}if(/^class[\s{]/.test(e))return!0;if(n===Symbol||n===BigInt)return!1;let t=Object.getOwnPropertyDescriptor(n,"prototype");return t&&!t.writable?e.includes("[native code]"):!1}function le(n,e,t,r){if(!P(n))return!1;if(!(Symbol.toStringTag in n))return Object.prototype.toString.call(n)===e;if(!t)return!1;try{return t.call(n,r),!0}catch{return!1}}function F(n){return le(n,Fo,wn)&&wn?!Number.isNaN(wn.call(n)):!1}function de(n){return le(n,Mo,Ho)}function wt(n){return le(n,Uo,Jo)}function St(n){return le(n,jo,Yo)}function Lr(n){return le(n,Lo,Xo,"key")}function Pr(n){return P(n)?Symbol.toStringTag in n?n instanceof Error:Object.prototype.toString.call(n)===Vo:!1}function Ir(n){return le(n,vr,Sn)}function kr(n){return le(n,Fr,Dn)}function Er(n){return le(n,Mr,An)}function Rr(n){return le(n,Ur,He)}function Nr(n){return le(n,jr,Je)}function oe(n){if(!P(n))return n;switch(Object.prototype.toString.call(n)){case Fr:if(kr(n))try{return Dn.call(n)}catch{}break;case vr:if(Ir(n))try{return Sn.call(n)}catch{}break;case Mr:if(Er(n))try{return An.call(n)}catch{}break;case Ur:if(Rr(n)&&He)try{return He.call(n)}catch{}break;case jr:if(Nr(n)&&Je)try{return Je.call(n)}catch{}break}if(Symbol.toStringTag in n){if(kr(n))try{return Dn.call(n)}catch{}else if(Ir(n))try{return Sn.call(n)}catch{}else if(Er(n))try{return An.call(n)}catch{}else if(Rr(n)&&He)try{return He.call(n)}catch{}else if(Nr(n)&&Je)try{return Je.call(n)}catch{}}if(typeof n.valueOf=="function"&&n.valueOf!==Object.prototype.valueOf)try{let t=n.valueOf();if(typeof t!="object"||t===null)return t}catch{}return n}var Fo,Mo,Uo,jo,Vo,Lo,vr,Fr,Mr,Ur,jr,Po,Bo,Cr,Or,$o,Ko,qo,Wo,Go,zo,Ho,Jo,Yo,wn,Xo,Sn,Dn,An,He,Je,Zo,ge=E(()=>{"use strict";Fo="[object Date]",Mo="[object RegExp]",Uo="[object Set]",jo="[object Map]",Vo="[object Error]",Lo="[object URLSearchParams]",vr="[object String]",Fr="[object Number]",Mr="[object Boolean]",Ur="[object BigInt]",jr="[object Symbol]",Po=typeof Date=="function"?Date.prototype:void 0,Bo=Object.getPrototypeOf(/./),Cr=typeof Set=="function"?Set.prototype:void 0,Or=typeof Map=="function"?Map.prototype:void 0,$o=typeof URLSearchParams=="function"?URLSearchParams.prototype:void 0,Ko=Object.getPrototypeOf(""),qo=Object.getPrototypeOf(0),Wo=Object.getPrototypeOf(!0),Go=typeof BigInt=="function"?BigInt.prototype:void 0,zo=typeof Symbol=="function"?Symbol.prototype:void 0,Ho=Object.getOwnPropertyDescriptor(Bo,"source")?.get,Jo=Cr?Object.getOwnPropertyDescriptor(Cr,"size")?.get:void 0,Yo=Or?Object.getOwnPropertyDescriptor(Or,"size")?.get:void 0,wn=Po?.valueOf,Xo=$o?.has,Sn=Ko.valueOf,Dn=qo.valueOf,An=Wo.valueOf,He=Go?.valueOf,Je=zo?.valueOf,Zo=Function.prototype.toString.call(Object)});function Z(n,e){return typeof n!="number"?!1:Number.isNaN(n)?e?.allowNaN??e?.allowNonFiniteNumbers??!1:Number.isFinite(n)?!0:e?.allowNonFiniteNumbers??!1}function Br(n){for(let e=1;e<n.length;e++)if(n[e].length!==3)return!1;return!0}function Gr(n,e){if(Qo.test(n))return null;let t=n.trim();if(t==="")return null;t.startsWith("(")&&t.endsWith(")")&&(t="-"+t.slice(1,-1).trim());let r=t[t.length-1];(r==="-"||r==="+")&&t.length>1&&(t=r+t.slice(0,-1).trim()),e||(t=t.replace(es,""));let o=t.includes("."),s=t.includes(",");if(o&&s){let i=t.lastIndexOf("."),a=t.lastIndexOf(","),u=a>i,c=u?".":",",l=u?a:i,f=t.slice(0,l).split(c);return f.length>1&&!Br(f)||f[0].replace($r,"").length>3?null:u?t.replace(Kr,"").replace(Dt,"."):t.replace(Dt,"")}if(s||o){let i=s?",":".",a=t.split(i);if(a.length>2||i===","&&a.length===2&&a[1].length===3){let u=a[0].replace($r,"").length;if(u===0){if(i===","||a.length>2)return null}else return u>3?null:Br(a)?t.replace(s?Dt:Kr,""):null}if(s)return t.replace(Dt,".")}return t}function te(n,{allowNonFiniteNumbers:e=!1,strictNumericString:t=!1,floatScientific:r=!0}={}){if(n==null||typeof n=="symbol")return null;switch(n=oe(n),typeof n){case"number":return Z(n,{allowNonFiniteNumbers:e})?n:null;case"boolean":return n?1:0;case"bigint":{let o=Number(n);return Z(o,{allowNonFiniteNumbers:e})?o:null}case"object":{if(F(n)){let o=n.getTime();return Z(o,{allowNonFiniteNumbers:e})?o:null}return null}case"string":{let o=Gr(n,t);if(o===null)return null;if(e){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(Wr.test(o)&&!r||!qr.test(o))return null;let i=Number(o);return Z(i,{allowNonFiniteNumbers:e})?i:null}default:return null}}function zr({locale:n="en-US",accountingNegatives:e=!1,fallback:t="NaN",formatNonFinite:r=!1,...o}={}){o.useGrouping===void 0&&(o.useGrouping=!1),o.maximumFractionDigits===void 0&&o.maximumSignificantDigits===void 0&&(o.maximumFractionDigits=20),e&&(o.currencySign="accounting",o.style===void 0&&(o.style="decimal"));let s=new Intl.NumberFormat(n,o);return i=>{if(typeof i=="bigint")return e&&i<0n?`(${s.format(-i)})`:s.format(i);let a=te(i,{allowNonFiniteNumbers:!0});return a===null||Number.isNaN(a)?t:Number.isFinite(a)?e&&a<0?`(${s.format(Math.abs(a))})`:s.format(a):r?t:e&&a===-1/0?`(${s.format(1/0)})`:String(a)}}function Tn(n,{floatPrecision:e="Float64",allowNonFiniteNumbers:t=!0,floatScientific:r=!0,strictNumericString:o=!1}={}){let s=te(n,{allowNonFiniteNumbers:t,floatScientific:r,strictNumericString:o});return s===null||(e==="Float32"&&(s=Math.fround(s)),!Z(s,{allowNonFiniteNumbers:t}))?null:s}function me(n,{range:e="Int32",coerce:t="truncate"}={}){let r=te(n);if(r===null)return null;switch(t){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 e=="string"?ts[e]:e;return ue(r,{min:o.min,max:o.max})}function Me(n,{range:e="Int64",truncate:t=!1}={}){if(n==null||typeof n=="symbol")return null;n=oe(n);let r=null;if(typeof n=="bigint")r=n;else if(typeof n=="string"){let s=Gr(n,!1);if(s===null||!qr.test(s))return null;if(Wr.test(s)){let i=Number(s);if(!Number.isFinite(i)||!t&&!Number.isInteger(i))return null;r=BigInt(Math.trunc(i))}else{let i=s.indexOf(".");if(i!==-1){if(!t&&/[^0]/.test(s.slice(i+1)))return null;s=s.slice(0,i)}try{r=BigInt(s)}catch{return null}}}else{let s=te(n);if(s===null||!t&&!Number.isInteger(s))return null;r=BigInt(Math.trunc(s))}let o=typeof e=="string"?ns[e]:e;return ue(r,{min:o.min,max:o.max})}function rs(n,e){let t=n-e;if(t<0||e<0)return null;if(t>15)return Number.MAX_SAFE_INTEGER;let r=Math.min(e,16),o=Math.pow(10,t)-Math.pow(10,-r);return o>0?o:null}function Cn(n,e){let t=n.toString();if(t.includes("e")){let r=Math.pow(10,e);return Math.round(n*r)/r}return+(Math.round(+(t+"e"+e))+"e"+-e)}function At(n,{precision:e,scale:t}={}){let r=te(n);if(r===null)return null;let o=r;if(t!==void 0&&(o=Cn(o,t)),e!==void 0){let i=rs(e,t??0);i!==null&&(o=ue(o,{min:-i,max:i}))}return o}function ue(n,e){if(!e)return n;let{min:t=null,max:r=null,safe:o=!0}=e;if(t!==null&&r!==null&&t>r)return t;let s=n;if(o&&typeof s=="number"){if(Number.isNaN(s))return t!==null?t:r!==null?r:n;if(s===1/0)return r!==null?r:n;if(s===-1/0)return t!==null?t:n}return t!==null&&s<t?t:r!==null&&s>r?r:s}function Hr(n){let e=n|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}}var qr,Qo,es,Wr,$r,Kr,Dt,ts,ns,Ye=E(()=>{"use strict";ge();qr=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,Qo=/0[xobXOB]/,es=/[\s_]/g,Wr=/[eE]/;$r=/^[+-]/,Kr=/\./g,Dt=/,/g;ts={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}};ns={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function U(n){if(!ArrayBuffer.isView(n))return!1;if(Jr)return Jr.call(n)!==void 0;let e=Object.prototype.toString.call(n);return e!=="[object DataView]"&&e.endsWith("Array]")}function C(n){return Array.isArray(n)||U(n)}function Xe(n){return n==null?[]:Array.isArray(n)?[...n]:U(n)?Array.from(n):[n]}function Ue(n){let e=Xe(n),t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=String(e[o]);return r}function W(n,e,{mode:t="every",allowNulls:r=!1,allowEmpty:o=!0}={}){if(!C(n))return!1;let s=n.length;if(s===0)return o?t==="every":!1;let i=n,a;if(typeof e=="function")a=Vr(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=F;break;case"object":a=P;break;case"plainObject":a=Ce;break;case"number":a=Z;break;default:a=u=>typeof u===e;break}if(r){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 Ze(n,{descending:e=!1,nullsLast:t=!0}={}){if(!C(n))return[];let r=n,o=r.length;if(o===0)return[];if(U(n)){let f=r.slice().sort();return e&&f.reverse(),Array.from(f)}let s=[],i=[],a=!0,u=!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"&&(u=!1),!a&&!u&&(c=!1)}}return s.length>1&&(a?s.sort(e?(f,m)=>m-f:(f,m)=>f-m):u?s.sort(e?(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 e?-y:y}return f<m?e?1:-1:f>m?e?-1:1:0})),i.length===0?s:t?s.concat(i):i.concat(s)}function $(n){if(!C(n))return{...Yr};let e=n.length;if(e===0)return{...Yr};let t=null,r=null,o=0,s=0,i=0,a=0,u=0,c=0;for(let f=0;f<e;f++){let m=n[f];if(m==null||typeof m=="number"&&!Z(m,{allowNonFiniteNumbers:!0,allowNaN:!1})){s++;continue}(t==null||m<t)&&(t=m),(r==null||m>r)&&(r=m);let h=te(m);if(h!==null){let p=i+h;Math.abs(i)>=Math.abs(h)?a+=i-p+h:a+=h-p+i,i=p,o++;let y=h-u;u+=y/o;let d=h-u;c+=y*d}}let l=o>1?c/(o-1):0;return{sum:o>0?i+a:null,count:o,min:t,max:r,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 Oe(n,{strict:e=!1,keySelector:t}={}){let r=Array.from(n),o=new Map;if(e){let i=t??q,a=new Map,u=r.length;for(let l=0;l<u;l++){let f=r[l],m=i(f),h=a.get(m);h===void 0?a.set(m,{val:f,count:1}):h.count++}let c=[];for(let l of a.values())c.push(l.val);for(let l=0;l<u;l++){let f=r[l],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 Xr(n,{step:e=1,offsetStart:t=0,offsetEnd:r,maxItemsGathered:o,null_on_oob:s=!0}={}){if(n==null)return null;if(o!==void 0&&o<=0)return[];if(e===0)throw new Error("Step size step cannot be zero");let i=n.length;if(i===0?t!==0:t>=i||t<-i){if(!s)throw new Error(`Start offset ${t} is out of bounds for array of length ${i}`);return null}let u=t<0?i+t:t,c=r!==void 0?r<0?i+r:r:e>0?i:-1,l=[];if(e>0)for(let f=u;f<c&&f<i&&!(f>=0&&(l.push(n[f]),o!==void 0&&l.length>=o));f+=e);else for(let f=u;f>c&&f>=0&&!(f<i&&(l.push(n[f]),o!==void 0&&l.length>=o));f+=e);return l}function Zr(n,e=",",{ignoreNulls:t=!1,nullValue:r="",prefix:o="",suffix:s="",limit:i,truncationMarker:a="...",valueFormatter:u}={}){let c=n.length,l=[],f=i!==void 0?Math.max(0,i):c,m=!1;for(let h=0;h<c;h++){if(l.length>=f){m=!0;break}let p=n[h];p!=null?l.push(u?u(p,h):String(p)):t||l.push(r)}return o+l.join(e)+(m?a:"")+s}function Ie(n,e,t={}){let r=n.length,{mode:o="cumulative",step:s=1,coerce:i=y=>y,condition:a,reverse:u=!1,startIndex:c=u?r-1:0,endIndex:l=u?-1:r}=t,f=u?-1:1,m=c,h=l,p=(y,d)=>{(!a||a(n[y],y,n))&&(n[y]=i(d))};if(o==="constant"){let y=i(e);for(let d=m;u?d>h:d<h;d+=f)p(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;u?d>h:d<h;d+=f)p(d,s({index:y,initialValue:e,originalValue:n[d],absoluteIndex:d,targetArray:n})),y++}else for(let y=m;u?y>h:y<h;y+=f)p(y,e+y*s);else{let y=e,d=!0,g=0;for(let b=m;u?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 Qr(n){let e=n.length,t=0,r=new Float64Array(e);for(let s=0;s<e;s++){let i=n[s],a=te(i,{allowNonFiniteNumbers:!0});a!==null&&Z(a,{allowNonFiniteNumbers:!0,allowNaN:!1})&&(r[t++]=a)}if(t===0)return null;let o=r.subarray(0,t);return o.sort(),o}function je(n){let e=Qr(n);if(!e)return null;let t=e.length,r=Math.floor(t/2);return t%2!==0?e[r]:(e[r-1]+e[r])/2}function Tt(n,e){if(e<0||e>1)return null;let t=Qr(n);if(!t)return null;let r=t.length,o=e*(r-1),s=Math.floor(o),i=Math.ceil(o);return s===i?t[s]:t[s]+(o-s)*(t[i]-t[s])}function Ct(n){if(!C(n)||n.length===0)return null;let e=new Map,t=n.length,r=0,o=[];for(let s=0;s<t;s++){let i=n[s];if(i==null||typeof i=="number"&&!Z(i,{allowNonFiniteNumbers:!0,allowNaN:!1}))continue;let a=(e.get(i)??0)+1;e.set(i,a),a>r?(r=a,o=[i]):a===r&&o.push(i)}return o.length===0?null:Ze(o)}var Jr,Yr,Qe=E(()=>{"use strict";ge();Ye();Ot();Jr=(()=>{try{let n=new Uint8Array(0),e=Object.getPrototypeOf(n),t=Object.getPrototypeOf(e),r=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.get;return r&&r.call(n)==="Uint8Array"?r:void 0}catch{return}})();Yr={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function eo(n){let e=oe(n);return typeof e=="string"?e.trim().length===0:!1}function It(n){let e=oe(n);if(e==null)return"";let t=String(e);return typeof RegExp.escape=="function"?RegExp.escape(t):t.replace(os,"\\$&")}function Ve(n,e=null,t={}){if(n==null)return t.returnStringOnNull?"":null;let{mode:r="both",returnStringOnNull:o=!1,maxScanStart:s=1,maxScanEnd:i=1,maxMatchesStart:a=1,maxMatchesEnd:u=1,trimFirst:c=!1,stringOptions:l}=t,{literal:f=!1,caseInsensitive:m=!1}=l??{},h=(w,A="both")=>A==="start"?w.trimStart():A==="end"?w.trimEnd():w.trim(),p=n;if(c&&e!=null&&(p=h(n,r)),e==null){let w=h(p,r);return o||w!==""?w:null}let y=de(e)?w=>{try{e.lastIndex=0}catch{}return e.test(w)}:(()=>{let w=new Set(m?e.toLowerCase():e);return A=>w.has(m?A.toLowerCase():A)})(),d=p.length;if(s===1&&a===1&&i===1&&u===1&&!f){let w=0,A=d;if(r==="both"||r==="start")for(;w<d&&y(p[w]);)w++;if(r==="both"||r==="end")for(;A>w&&y(p[A-1]);)A--;let M=w===0&&A===d?p:p.substring(w,A);return o||M!==""?M:null}let b=new Uint8Array(d),D=(w,A,M)=>{if(d===0||M===0)return;let fe=w?0:d-1,ie=w?d:-1,I=w?1:-1,k=!1,L=0,K=0;for(let H=fe;H!==ie;H+=I)if(y(p[H])){if(!k){if(A!==null&&A>=0&&K>=A||M!==null&&M>=0&&L>=M)break;k=!0,L++}b[H]=1}else if(k=!1,K++,A!==null&&A>=0&&K>=A)break},_=(w,A,M,fe,ie)=>{if(d===0||ie===0||A===0)return;let I=M?0:d-1,k=0,L=0,K=m?p.toLowerCase():p;for(;I>=0&&I<d&&!(ie!==null&&ie>=0&&k>=ie);){let H=M?I:I-A+1;if(!M&&H<0)break;let J=M?K.indexOf(w,H):K.lastIndexOf(w,H);if(J===-1)break;let re=M?J-I:I-(J+A-1);if(L+=re,fe!==null&&fe>=0&&L>=fe)break;for(let ee=0;ee<A;ee++)b[J+ee]=1;k++,I=M?J+A:J-1}};if(r==="both"||r==="start")if(f&&typeof e=="string"){let w=m?e.toLowerCase():e;_(w,e.length,!0,s,a)}else D(!0,s,a);if(r==="both"||r==="end")if(f&&typeof e=="string"){let w=m?e.toLowerCase():e;_(w,e.length,!1,i,u)}else D(!1,i,u);let S="";for(let w=0;w<d;w++)b[w]===0&&(S+=p[w]);return o||S!==""?S:null}function q(n,{depth:e=0,maxDepth:t=50}={}){if(e>t)return"v:circular";if(n===null)return"v:null";if(n===void 0)return"v:undefined";if(F(n))return`d:${n.getTime()}`;if(U(n))return`u:${n.constructor.name}:${n.toString()}`;if(Array.isArray(n)){let r=n.length,o=new Array(r),s={depth:e+1,maxDepth:t};for(let i=0;i<r;i++)o[i]=q(n[i],s);return`a:[${o.join(",")}]`}if(wt(n)){let r=Array.from(n),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++)s[a]=q(r[a],i);return s.sort(),`set:[${s.join(",")}]`}if(St(n)){let r=Array.from(n.keys()),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=r[a];s[a]=`${q(u,i)}:${q(n.get(u),i)}`}return s.sort(),`map:{${s.join(",")}}`}if(typeof n=="object"&&typeof n.toJSON=="function"){let r=n.toJSON();if(r!==n)return`j:${q(r,{depth:e+1,maxDepth:t})}`}if(Ce(n)){let r=Object.keys(n).sort(),o=r.length,s=new Array(o),i={depth:e+1,maxDepth:t};for(let a=0;a<o;a++){let u=r[a];s[a]=`${u}:${q(n[u],i)}`}return`o:{${s.join(",")}}`}return de(n)?`r:${n.toString()}`:typeof n=="function"?`f:${n.toString()}`:typeof n=="string"?`s:${n}`:typeof n=="symbol"?`y:${n.toString()}`:`${typeof n}:${n}`}var os,Ot=E(()=>{"use strict";ge();Qe();os=/[-\/\\^$*+?.()|\[\]{}]/g});var On,In,kn=E(()=>{"use strict";On=1000n,In=1000000n});function as(n){let e=to.get(n);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),to.set(n,e)),e}function ls(n,e){let t=`${n}_${e}`,r=no.get(t);return r||(r=new Intl.DateTimeFormat(n,{timeZoneName:"short",timeZone:e}),no.set(t,r)),r}function us(n){let e=ro.get(n);if(e===void 0){try{Intl.DateTimeFormat(void 0,{timeZone:n}),e=!0}catch{e=!1}ro.set(n,e)}return e}function pe(n){let e=!n||n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n;return us(e)?e:"UTC"}function ke(n,e=0,t=1,r=0,o=0,s=0,i=0){let a=new Date(0);return a.setUTCFullYear(n,e,t),a.setUTCHours(r,o,s,i),a}function Et(n,e=0,t=1,r=0,o=0,s=0,i=0){if(n>=100||n<0)return Date.UTC(n,e,t,r,o,s,i);let a=new Date(0);return a.setUTCFullYear(n,e,t),a.setUTCHours(r,o,s,i),a.getTime()}function cs(n,e,t){let r=[0,3,2,5,0,3,5,1,4,6,2,4],o=n;return e<3&&(o-=1),(o+Math.floor(o/4)-Math.floor(o/100)+Math.floor(o/400)+r[e-1]+t)%7}function Rt(n,e){let t=pe(e);if(t.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=as(t).formatToParts(n),s="0",i="0",a="0",u="0",c="0",l="0",f="0";for(let d=0,g=o.length;d<g;d++){let b=o[d];switch(b.type){case"year":s=b.value;break;case"month":i=b.value;break;case"day":a=b.value;break;case"hour":u=b.value;break;case"minute":c=b.value;break;case"second":l=b.value;break;case"fractionalSecond":f=b.value;break}}let m=parseInt(s,10),h=parseInt(i,10),p=parseInt(a,10),y=cs(m,h,p);return{year:m,month:h,day:p,hour:parseInt(u,10),minute:parseInt(c,10),second:parseInt(l,10),ms:parseInt(f,10),dayOfWeek:y}}function Rn(n,e){if(e.toUpperCase()==="UTC")return 0;let t=Rt(n,"UTC"),r=Rt(n,e),o=Et(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.ms),s=Et(r.year,r.month-1,r.day,r.hour,r.minute,r.second,r.ms);return Math.round((s-o)/6e4)}function fs(n,e){let t=pe(e),r=Rn(n,t),o=r>=0?"+":"-",s=Math.abs(r),i=String(Math.floor(s/60)).padStart(2,"0"),a=String(s%60).padStart(2,"0");return`${o}${i}${a}`}function Q(n,e){let t=oe(n);if(t==null)return null;let r=null;if(F(t))r=t;else if(typeof t=="number"||typeof t=="bigint")r=new Date(ms(t));else if(typeof t=="string"){if(eo(t))return null;r=new Date(t)}if(!r||!F(r))return null;if(e?.dateOnly){let o=typeof t=="string",s=o&&is.test(t),i=o&&!s&&!oo.test(t)?"local":"UTC",a=Rt(r,i);return ke(a.year,a.month-1,a.day)}return r}function vt(n){let e=oe(n);if(e==null)return null;let t=null;if(typeof e=="string"){let o=e.trim();if(ss.test(o)){let s=oo.test(o);t=Q(`1970-01-01T${o}${s?"":"Z"}`)}}let r=t||Q(e);return r?Ee(r,"%H:%M:%S.%ms"):null}function so(n,e="ms"){let t=n.getTime();switch(e){case"s":return Math.floor(t/1e3);case"ms":return t;case"us":return BigInt(t)*On;case"ns":return BigInt(t)*In}}function ms(n){if(typeof n=="bigint"){let t=n<0n?-n:n;return t<=30000000000n?Number(n)*1e3:t<=30000000000000n?Number(n):t<=30000000000000000n?Number(n/On):Number(n/In)}let e=Math.abs(n);return e<=3e10?n*1e3:e<=3e13?n:e<=3e16?Math.floor(n/1e3):Math.floor(n/1e6)}function io(n){if(!F(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/100)+1}function ao(n){if(!F(n))return null;let e=ke(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let r=ke(e.getUTCFullYear(),0,1),o=Math.round((e.getTime()-r.getTime())/864e5);return Math.floor(o/7)+1}function lo(n){if(!F(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/1e3)+1}function vn(n,e,t=1){return F(n)?ke(n.getUTCFullYear(),n.getUTCMonth()+e,t):null}function Fn(n){if(!F(n))return null;let e=Et(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),t=Et(n.getUTCFullYear(),0,1);return Math.floor((e-t)/864e5)+1}function uo(n){return F(n)?Math.floor(n.getUTCMonth()/3)+1:null}function Mn(n){let e;if(F(n))e=n.getUTCFullYear();else if(Z(n))e=n;else return!1;return e%4===0&&e%100!==0||e%400===0}function co(n){return n.replace(/%[FTRD]/g,e=>hs[e]||e)}function En(n,e){return new Date(n.getTime()-e*60*1e3)}function ys(n){let e=n[0]==="+"?1:-1,t=parseInt(n.slice(1,3),10)||0,r=parseInt(n.slice(3,5),10)||0;return e*(t*60+r)}function Ee(n,e,t,r="UTC"){if(!F(n)||typeof e!="string")return"";let o=t&&t.trim()||Intl.DateTimeFormat().resolvedOptions().locale||"en-US",s=co(e),i=null,a=()=>i??=Rt(n,r);return s.replace(kt,(u,c)=>{if(c==="%")return"%";let l=Un[c];return l?l.format(n,o,r,a()):u})}function fo(n,e,t=!0,r="UTC"){if(typeof n!="string"||typeof e!="string")return null;let o=co(e),s=[],i="",a=0;kt.lastIndex=0;let u;for(;(u=kt.exec(o))!==null;){let y=o.slice(a,u.index);i+=It(y);let d=u[1];if(d==="%")i+="\\%";else{let g=Un[d];g&&g.parseRegex?(s.push(g),i+=`(${g.parseRegex})`):i+=It(u[0])}a=kt.lastIndex}i+=It(o.slice(a));let c=new RegExp("^\\s*"+i+"\\s*$"),l=n.match(c);if(!l)return t?null:Q(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=l[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=Mn(f.year)?366:365;if(f.day<1||f.day>y)return null;let d=ke(f.year,0,1);d.setUTCDate(f.day),f.month=d.getUTCMonth()+1,f.day=d.getUTCDate()}let p=ke(f.year,f.month-1,f.day,f.hour,f.minute,f.second,f.ms);if(!F(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=En(p,ys(f.offset));else if(r.toUpperCase()!=="UTC"){let y=pe(r),d=Rn(p,y);p=En(p,d);let g=Rn(p,y);g!==d&&(p=En(p,g-d))}return F(p)?p:null}var ss,oo,is,to,no,ro,Un,ps,kt,hs,jn=E(()=>{"use strict";Ot();ge();Ye();kn();ss=/^\d{2}:\d{2}/,oo=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,is=/^\d{4}-\d{2}-\d{2}$/,to=new Map;no=new Map;ro=new Map;Un={Y:{key:"Y",format:(n,e,t,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,e,t,r)=>String(Math.abs(r.year)%100).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"year",parseNormalize:n=>{let e=parseInt(n,10);return e+(e>=69?1900:2e3)}},m:{key:"m",format:(n,e,t,r)=>String(r.month).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"month"},d:{key:"d",format:(n,e,t,r)=>String(r.day).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"day"},e:{key:"e",format:(n,e,t,r)=>String(r.day).padStart(2," "),parseRegex:"\\s?\\d{1,2}",parseField:"day"},H:{key:"H",format:(n,e,t,r)=>String(r.hour).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},I:{key:"I",format:(n,e,t,r)=>String(r.hour%12||12).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"hour"},p:{key:"p",format:(n,e,t,r)=>r.hour>=12?"PM":"AM",parseRegex:"AM|PM|am|pm",parseField:"ampm",parseNormalize:n=>n.toUpperCase()},M:{key:"M",format:(n,e,t,r)=>String(r.minute).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"minute"},S:{key:"S",format:(n,e,t,r)=>String(r.second).padStart(2,"0"),parseRegex:"\\d{2}",parseField:"second"},A:{key:"A",format:(n,e,t)=>n.toLocaleDateString(e,{weekday:"long",timeZone:pe(t)})},a:{key:"a",format:(n,e,t)=>n.toLocaleDateString(e,{weekday:"short",timeZone:pe(t)})},B:{key:"B",format:(n,e,t)=>n.toLocaleDateString(e,{month:"long",timeZone:pe(t)})},b:{key:"b",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:pe(t)})},h:{key:"h",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:pe(t)})},j:{key:"j",format:(n,e,t,r)=>String(Fn(ke(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,e,t,r)=>String(r.dayOfWeek||7)},w:{key:"w",format:(n,e,t,r)=>String(r.dayOfWeek)},Z:{key:"Z",format:(n,e,t)=>{let r=pe(t);if(r.toUpperCase()==="UTC")return"UTC";let o=ls(e,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,e,t)=>fs(n,t),parseRegex:"[+-]\\d{2}(?::?\\d{2})?",parseField:"offset",parseNormalize:n=>n.replace(":","")},ms:{key:"ms",format:(n,e,t,r)=>String(r.ms).padStart(3,"0"),parseRegex:"\\d{3}",parseField:"ms",parseNormalize:n=>parseInt(n,10)},f:{key:"f",format:(n,e,t,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)}},ps=Object.keys(Un).concat("%").sort((n,e)=>e.length-n.length),kt=new RegExp("%("+ps.join("|")+")","g"),hs={"%F":"%Y-%m-%d","%T":"%H:%M:%S","%R":"%H:%M","%D":"%m/%d/%y"}});function mo(n,{format:e="json",allowPrimitives:t=!1,trimBeforeParse:r=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:i,skipLines:a}={},guard:u,onError:c,fallback:l=et}={}){if(typeof n!="string")return l!==et?l:n;let f=r?n.trim():n;if(f==="")return l!==et?l:n;let m;try{if(e==="ndjson"){let h=[],p=0,y=0,d=0;Vn.lastIndex=0;let g;for(;;){g=Vn.exec(f);let b=g?f.substring(d,g.index):f.substring(d);g&&(d=Vn.lastIndex);let D=b.trim();if(D!==""&&(p++,a===void 0||p>a))if(!t&&!ds(D)){if(!s)throw new Error("NDJSON line is not wrapped and primitives are disallowed")}else try{if(h.push(JSON.parse(D,o)),y++,i!==void 0&&y>=i)break}catch(_){if(!s)throw _}if(!g)break}if(h.length===0)throw new Error("No valid NDJSON lines processed");m=h}else{if(!t&&!gs(f))throw new Error("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(f,o)}}catch(h){return c?.(h),l!==et?l:n}return u&&!u(m)?(c?.(new Error("Parsed value failed guard validation")),l!==et?l:n):m}function tt(n={}){let e=n.bigintStrategy??"string",t=n.handleCircular?new WeakSet:null,o=Array.isArray(n.replacer)?n.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 n.replacer=="function")c=n.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 n.onCustom=="function"){let f=n.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 n.onCircular?n.onCircular.call(this,a,l):"[Circular]";t.add(l)}return typeof l=="bigint"?n.voidBigIntReplacement?c:n.onBigInt?n.onBigInt(l):s(l):U(l)?n.voidTypedArrayReplacement?c:n.onTypedArray?n.onTypedArray(l):Array.from(l):wt(l)?n.voidSetReplacement?c:n.onSet?n.onSet(l):Array.from(l):St(l)?n.voidMapReplacement?c:n.onMap?n.onMap(l):Array.from(l.entries()):de(l)?n.voidRegExpReplacement?c:n.onRegExp?n.onRegExp(l):l.toString():F(l)?n.voidDateReplacement?c:n.onDate?n.onDate(l):n.formatDate?n.formatDate(l):l.toISOString():Pr(l)?n.onError?n.onError(l):{name:l.name,message:l.message,stack:l.stack}:Lr(l)?n.onURLSearchParams?n.onURLSearchParams(l):l.toString():c}}var Vn,et,ds,gs,Ft=E(()=>{"use strict";Qe();ge();Vn=/\r\n|\n|\r/g,et=Symbol("no_fallback"),ds=n=>{let e=n.length;if(e<2)return!1;let t=n[0],r=n[e-1];return t==="{"&&r==="}"||t==="["&&r==="]"},gs=n=>{let e=0,t=n.length;for(;e<t&&/\s/.test(n[e]);)e++;let r=t-1;for(;r>=e&&/\s/.test(n[r]);)r--;if(e>=r)return!1;let o=n[e],s=n[r];return o==="{"&&s==="}"||o==="["&&s==="]"}});var Mt=E(()=>{"use strict"});var Y,Re,nt,be,xe,Le,_e,Pe,Ut=E(()=>{"use strict";Y=class n{matches(e){if(e==null)return!1;if(e instanceof n)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 n)return this instanceof e;try{let t=e();if(t instanceof n)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}},Re=class extends Y{get isNumeric(){return!0}},nt=class extends Re{get isInteger(){return!0}},be=class extends nt{get isSigned(){return!0}},xe=class extends nt{get isUnsigned(){return!0}},Le=class extends Re{get isFloat(){return!0}},_e=class extends Y{get isTemporal(){return!0}},Pe=class extends Y{get isNested(){return!0}}});var jt,Ln,Vt,Pn,Lt,Bn,Pt,ot,Bt,$n,$t,Kn,Kt,qn,qt,Wn,Wt,Gn,Gt,st,rt,zt,it,Ht,Be,Jt,zn,Yt,Hn,Xt,Jn,Zt,Yn,Qt,at,en,Xn,tn,Zn,nn,Qn,rn,er,tr=E(()=>{"use strict";Ut();B();jt=class extends be{name="Int8";coerce(e){return me(e,{range:"Int8"})}equals(e){return e.name==="Int8"}allocate(e){return new Int8Array(e)}},Ln=new jt,Vt=class extends be{name="Int16";coerce(e){return me(e,{range:"Int16"})}equals(e){return e.name==="Int16"}allocate(e){return new Int16Array(e)}},Pn=new Vt,Lt=class extends be{name="Int32";coerce(e){return me(e,{range:"Int32"})}equals(e){return e.name==="Int32"}allocate(e){return new Int32Array(e)}},Bn=new Lt,Pt=class extends be{name="Int64";coerce(e){return Me(e,{truncate:!0})}equals(e){return e.name==="Int64"}allocate(e){return new BigInt64Array(e)}},ot=new Pt,Bt=class extends xe{name="UInt8";coerce(e){return me(e,{range:"UInt8"})}equals(e){return e.name==="UInt8"}allocate(e){return new Uint8Array(e)}},$n=new Bt,$t=class extends xe{name="UInt16";coerce(e){return me(e,{range:"UInt16"})}equals(e){return e.name==="UInt16"}allocate(e){return new Uint16Array(e)}},Kn=new $t,Kt=class extends xe{name="UInt32";coerce(e){return me(e,{range:"UInt32"})}equals(e){return e.name==="UInt32"}allocate(e){return new Uint32Array(e)}},qn=new Kt,qt=class extends xe{name="UInt64";coerce(e){return Me(e,{range:"UInt64"})}equals(e){return e.name==="UInt64"}allocate(e){return new BigUint64Array(e)}},Wn=new qt,Wt=class extends Le{name="Float32";coerce(e){return Tn(e,{floatPrecision:"Float32"})}equals(e){return e.name==="Float32"}allocate(e){return new Float32Array(e)}},Gn=new Wt,Gt=class extends Le{name="Float64";coerce(e){return Tn(e,{floatPrecision:"Float64"})}equals(e){return e.name==="Float64"}allocate(e){return new Float64Array(e)}},st=new Gt,rt=class n extends Re{constructor(t,r){super();this.precision=t;this.scale=r;this.name=t!==void 0&&r!==void 0?`Decimal(${t}, ${r})`:"Decimal"}precision;scale;name;coerce(t){return At(t,{precision:this.precision,scale:this.scale})}equals(t){return t instanceof n&&this.precision===t.precision&&this.scale===t.scale}allocate(t){return new Array(t).fill(null)}},zt=class extends Y{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)}},it=new zt,Ht=class extends Y{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)}},Be=new Ht,Jt=class extends Y{name="Binary";get isBinary(){return!0}coerce(e){return po(e)}equals(e){return e.name==="Binary"}allocate(e){return new Array(e).fill(null)}},zn=new Jt,Yt=class extends Y{name="Null";get isNull(){return!0}coerce(e){return null}equals(e){return e.name==="Null"}allocate(e){return new Array(e).fill(null)}},Hn=new Yt,Xt=class extends Y{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)}},Jn=new Xt,Zt=class extends _e{name="Date";coerce(e){return Q(e,{dateOnly:!0})}equals(e){return e.name==="Date"}allocate(e){return new Array(e).fill(null)}},Yn=new Zt,Qt=class extends _e{name="Datetime";coerce(e){return Q(e)}equals(e){return e.name==="Datetime"}allocate(e){return new Array(e).fill(null)}},at=new Qt,en=class extends _e{name="Time";coerce(e){return vt(e)}equals(e){return e.name==="Time"}allocate(e){return new Array(e).fill(null)}},Xn=new en,tn=class extends _e{name="Duration";coerce(e){return te(e)}equals(e){return e.name==="Duration"}allocate(e){return new Array(e).fill(null)}},Zn=new tn,nn=class n extends Pe{constructor(t){super();this.innerType=t}innerType;name="Array";coerce(t){if(t==null)return null;let r=C(t)?Array.from(t):[t],o=r.length,s=new Array(o);for(let i=0;i<o;i++)s[i]=this.innerType.coerce(r[i]);return s}equals(t){return t instanceof n&&this.innerType.equals(t.innerType)}allocate(t){return new Array(t).fill(null)}},Qn=n=>new nn(n),rn=class n extends Pe{constructor(t){super();this.fields=t}fields;name="Struct";coerce(t){if(!P(t))return null;let r={},o=Object.keys(this.fields),s=o.length;for(let i=0;i<s;i++){let a=o[i],u=this.fields[a];r[a]=u.coerce(t[a])}return r}equals(t){if(!(t instanceof n))return!1;let r=Object.keys(this.fields),o=Object.keys(t.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(t.fields[i]))return!1}return!0}allocate(t){return new Array(t).fill(null)}},er=n=>new rn(n)});var R,we=E(()=>{"use strict";Ut();tr();tr();Ut();R={Int8:Ln,Int16:Pn,Int32:Bn,Int64:ot,UInt8:$n,UInt16:Kn,UInt32:qn,UInt64:Wn,Float32:Gn,Float64:st,Decimal:(n,e)=>new rt(n,e),Boolean:it,Utf8:Be,Binary:zn,Date:Yn,Datetime:at,Time:Xn,Duration:Zn,Object:Jn,Null:Hn,Array:Qn,Struct:er}});function bs(n={}){let e=n.nullValue!==void 0?n.nullValue:"",t=zr(n.numericFormatOptions),r=n.replacerOptions||{},o=a=>n.datetimeFormat?Ee(a,n.datetimeFormat):n.dateFormat?Ee(a,n.dateFormat):n.timeFormat?Ee(a,n.timeFormat):a.toISOString(),s=tt({formatDate:o,...r}),i=typeof r.onBigInt=="function";return a=>{if(a==null||typeof a=="symbol"||typeof a=="function")return{str:e,isNumeric:!1};if(typeof a=="bigint"&&!i&&!r.voidBigIntReplacement)return{str:t(a),isNumeric:!0};let u=s.call(null,"",a),c=oe(u);return c==null||typeof c=="symbol"||typeof c=="function"?{str:e,isNumeric:!1}:typeof c=="string"?{str:c,isNumeric:!1}:typeof c=="number"||typeof c=="bigint"?{str:t(c),isNumeric:!0}:typeof c=="boolean"?{str:c?"true":"false",isNumeric:!1}:typeof c=="object"?{str:JSON.stringify(c,tt({formatDate:o,...r})),isNumeric:!1}:{str:String(c),isNumeric:!1}}}function sn(n,e,t={}){let{separator:r=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:i=`
2
+ `,quoteStyle:a="necessary",includeBom:u=!1,onRow:c,...l}=t,f=Object.keys(n),m=f.length,h=[],p=!0,y=bs(l),d=(b,D=!1)=>{let _,S=!1;if(D)_=String(b);else{let A=y(b);_=A.str,S=A.isNumeric}if(a==="never")return _;if(a==="always"){let A=_.split(o).join(o+o);return o+A+o}if(a==="non_numeric"&&!S&&b!=null){let A=_.split(o).join(o+o);return o+A+o}if(_.includes(r)||_.includes(o)||_.includes(`
3
+ `)||_.includes("\r")){let A=_.split(o).join(o+o);return o+A+o}return _},g=b=>{if(p){let D=u?"\uFEFF"+b:b;c?c(D):h.push(D),p=!1}else c?c(i+b):h.push(b)};if(s){let b=new Array(m);for(let D=0;D<m;D++)b[D]=d(f[D],!0);g(b.join(r))}for(let b=0;b<e;b++){let D=new Array(m);for(let _=0;_<m;_++)D[_]=d(n[f[_]][b],!1);g(D.join(r))}return c?u?"\uFEFF":"":h.join(i)}function yo(n,e={}){let t=e.separator||",",r=e.quoteChar||'"',o=n;o.startsWith("\uFEFF")&&(o=o.substring("\uFEFF".length));let s=[],i=[],a="",u=!1,c=!1,l=!1,f=o.length;for(let m=0;m<f;m++){let h=o[m];if(u)c=!0,l=!1,h===r?m+1<f&&o[m+1]===r?(a+=r,m++):u=!1:a+=h;else if(h===r)c=!0,l=!1,u=!0;else if(h===t)i.push(a),a="",l=!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!==""||l)&&(i.push(a),s.push(i),i=[],a="",c=!1,l=!1):(c=!0,l=!1,a+=h)}}return(c||i.length>0||a!==""||l)&&(i.push(a),s.push(i)),s}function go(n,e={}){let t=new Set(e.nullValues??["","NA","null","NaN"]),r=n.length,o=!0,s=!0,i=!0,a=!0,u=!1;for(let l=0;l<r;l++){let f=n[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&&Me(f,{truncate:!1})===null&&(i=!1),s&&te(f,{allowNonFiniteNumbers:!0})===null&&(s=!1),a&&Q(f)===null&&(a=!1),!o&&!s&&!i&&!a)break}}let c=new Array(r);if(!u||!o&&!s&&!i&&!a){for(let l=0;l<r;l++){let f=n[l];c[l]=t.has(f.trim())?null:f}return{type:Be,values:c}}if(o){for(let l=0;l<r;l++){let f=n[l].trim();if(t.has(f))c[l]=null;else{let m=f.toLowerCase();c[l]=m==="true"||m==="1"}}return{type:it,values:c}}if(i){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:Me(f,{truncate:!1})}return{type:ot,values:c}}if(s){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:te(f,{allowNonFiniteNumbers:!0})}return{type:st,values:c}}if(a){for(let l=0;l<r;l++){let f=n[l].trim();c[l]=t.has(f)?null:Q(f)}return{type:at,values:c}}return{type:Be,values:c}}var bo=E(()=>{"use strict";jn();Ft();Ye();Mt();we();ge()});function xs(n){return n==null?!1:typeof n=="string"||U(n)?!0:Array.isArray(n)}function po(n){return xs(n)?Object.prototype.toString.call(n)==="[object Uint8Array]"?n:typeof n=="string"?new TextEncoder().encode(n):U(n)?new Uint8Array(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)):new Uint8Array(n):null}var xo=E(()=>{"use strict";Qe()});var B=E(()=>{"use strict";ge();Ye();jn();Qe();Ot();Ft();bo();xo()});function X(n,e,t,r=""){if(!(n in e))throw new he(n,`${t} "${n}" does not exist${r}`)}function an(n,e){let t=Object.keys(n),r=t.length,o=e;for(let s=0;s<r;s++){let i=t[s],a=n[i],u=C(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 _o=E(()=>{"use strict";se();B()});var Ne,j,he,Ke,Se,z,se=E(()=>{"use strict";_o();Ne=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},j=class extends Ne{},he=class extends j{constructor(e,t){super(t||`Column "${e}" does not exist in the DataFrame.`)}},Ke=class extends Ne{},Se=class extends Ne{},z=class extends Ne{}});var x,N,ne=E(()=>{"use strict";ae();se();x=(n,e)=>{let t=n.constructor,r=n.colNames||n.colName||"",o=new t(r);return Object.assign(o,n),o.ops=e?[...n.ops,e]:[...n.ops],o},N=class n{ops=[];outputName="";isLiteral;literalValue;aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;evaluateWindow;_resolve(e,t,r){return e instanceof n?e.isLiteral&&e.ops.length===1?e.literalValue:e.evaluate(t,r):e}alias(e){let t=x(this);return t.outputName=e,t}cast(e){return x(this,t=>{let r=t.length,o=new Array(r);for(let s=0;s<r;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 r=this.colName;if(r&&r!=="*"&&!r.startsWith("*")&&!(r in e))throw new he(r);return r&&r!=="*"?e[r]||new Array(t).fill(null):new Array(t).fill(null)}evaluate(e,t){let r=this._getInitialValue(e,t),o=this.ops,s=o.length;for(let i=0;i<s;i++)r=o[i](r,e);return r}evaluatePre(e,t,r){let o=this._getInitialValue(t,r),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,r){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,r);return i}}});function _s(n,e,t){let r=new Map,o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];typeof a=="string"?(X(a,n,"Partition key"," in the DataFrame."),s[i]=n[a]):s[i]=a.evaluate(n,e)}if(o===1){let i=s[0];for(let a=0;a<e;a++){let u=i[a],c=u==null?"":q(u),l=r.get(c);l===void 0&&(l=[],r.set(c,l)),l.push(a)}return r}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?"":q(f)}let u=a.join("\0"),c=r.get(u);c===void 0&&(c=[],r.set(u,c)),c.push(i)}return r}function nr(n,e,t){let r=new Array(t);if(t===0)return r;let o=n.partitionBy||[],s=_s(e,t,o),i=n.evaluatePre(n.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(n.evaluateWindow){for(let l=0;l<u;l++)r[a[l]]=n.evaluateWindow(c,a,l);continue}if(n.aggFn){let l=n.aggFn(c);for(let f=0;f<u;f++)r[a[f]]=l;continue}for(let l=0;l<u;l++)r[a[l]]=i[a[l]]}return n.evaluatePost(n.partitionOpsIndex,r,e)}function rr(n){if(!Array.isArray(n)||n.length===0)return{columns:{},height:0};let e=n.length,t=new Set;for(let s=0;s<e;s++){let i=n[s];if(P(i)){let a=Object.keys(i);for(let u=0;u<a.length;u++)t.add(a[u])}}let r=Array.from(t),o={};for(let s=0;s<r.length;s++)o[r[s]]=new Array(e);for(let s=0;s<e;s++){let i=n[s]||{};for(let a=0;a<r.length;a++){let u=r[a],c=i[u];o[u][s]=c===void 0?null:c}}return{columns:o,height:e}}function or(n,e){let t=Object.keys(n),r=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=n[a][o];s[a]=u===void 0?null:u}r[o]=s}return r}function ws(n,e,t){let r={};for(let o=0;o<t.length;o++){let s=t[o],i=n[s][e];r[s]=i===void 0?null:i}return r}function ye(n){if(n.length===0)return R.Utf8;let e=!0,t=!0,r=!0,o=!0,s=!0,i=!0,a=!0,u=!0,c=!1,l=!1,f=[];for(let m=0;m<n.length;m++){let h=n[m];if(h!=null){if(l=!0,h instanceof Uint8Array||(a=!1),!C(h)||h instanceof Uint8Array)i=!1;else{let p=h,y=p.length;for(let d=0;d<y;d++)f.push(p[d])}F(h)&&(c=!0),typeof h!="boolean"&&(e=!1),typeof h!="bigint"&&(o=!1),typeof h!="number"?(r=!1,t=!1):Number.isInteger(h)||(t=!1),!F(h)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(s=!1),(!P(h)||h instanceof Uint8Array)&&(u=!1)}}if(!l)return R.Utf8;if(a)return R.Binary;if(i){let m=ye(f);return R.Array(m)}if(e)return R.Boolean;if(o)return R.Int64;if(r&&!t)return R.Float64;if(r&&t){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?R.Int32:R.Float64}return s&&c?R.Datetime:u?R.Object:R.Utf8}function qe(n,e){let t=Object.keys(n),r=t.length,o=e.length,s={};for(let i=0;i<r;i++){let a=t[i],u=n[a],c=U(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 ve(n,e,t){let r=e.length;if(r===1){let s=n[e[0]][t];return s==null?"":q(s)}let o=new Array(r);for(let s=0;s<r;s++){let i=n[e[s]][t];o[s]=i==null?"":q(i)}return o.join("\0")}function De(n,e,t){let r=e.allocate?e.allocate(t):new Array(t);if(U(r)){let s=r;for(let i=0;i<t;i++){let a=e.coerce(n[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(n[c]);return u}s[i]=a}}else for(let s=0;s<t;s++)r[s]=e.coerce(n[s]);return r}function sr(n,e){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,e,"utf8")}else if(P(n)&&typeof n.write=="function")n.write(e);else throw new TypeError("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}var lt=E(()=>{"use strict";we();Mt();B();se()});function ut(n,e,t){return n.isWindow?nr(n,e,t):n.evaluate(e,t)}var T,V,Ae=E(()=>{"use strict";B();lt();T=n=>e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++){let s=e[o];r[o]=s==null?null:n(s)}return r},V=(n,e,t)=>(r,o)=>{let s=r.length,i=n._resolve(e,o,s),a=new Array(s);if(C(i))for(let u=0;u<s;u++){let c=r[u],l=i[u];a[u]=c==null||l==null?null:t(c,l)}else for(let u=0;u<s;u++){let c=r[u];a[u]=c==null||i==null?null:t(c,i)}return a}});var ct,ir=E(()=>{"use strict";ne();Ae();B();ct=class extends N{abs(){return x(this,T(Math.abs))}acos(){return x(this,T(e=>e<-1||e>1?null:Math.acos(e)))}acosh(){return x(this,T(e=>e<1?null:Math.acosh(e)))}add(e){return x(this,V(this,e,(t,r)=>t+r))}asin(){return x(this,T(e=>e<-1||e>1?null:Math.asin(e)))}asinh(){return x(this,T(Math.asinh))}atan(){return x(this,T(Math.atan))}atan2(e){return x(this,V(this,e,Math.atan2))}atanh(){return x(this,T(e=>e<=-1||e>=1?null:Math.atanh(e)))}cbrt(){return x(this,T(Math.cbrt))}ceil(){return x(this,T(Math.ceil))}clip(e=null,t=null){return x(this,T(r=>ue(r,{min:e,max:t})))}copysign(e){return x(this,V(this,e,(t,r)=>Math.abs(t)*(r>=0?1:-1)))}cos(){return x(this,T(Math.cos))}cosh(){return x(this,T(Math.cosh))}degrees(){return x(this,T(e=>e*(180/Math.PI)))}div(e){return x(this,V(this,e,(t,r)=>r===0?null:t/r))}exp(){return x(this,T(Math.exp))}expm1(){return x(this,T(Math.expm1))}floor(){return x(this,T(Math.floor))}floordiv(e){return x(this,V(this,e,(t,r)=>r===0?null:Math.floor(t/r)))}hypot(e){return x(this,V(this,e,Math.hypot))}log(e=Math.E){return x(this,T(t=>t<=0?null:e===Math.E?Math.log(t):Math.log(t)/Math.log(e)))}log1p(){return x(this,T(e=>e<=-1?null:Math.log1p(e)))}mod(e){return x(this,V(this,e,(t,r)=>r===0?null:t%r))}mul(e){return x(this,V(this,e,(t,r)=>t*r))}negate(){return x(this,T(e=>-e))}pow(e){return x(this,V(this,e,Math.pow))}radians(){return x(this,T(e=>e*(Math.PI/180)))}rand(e,{min:t=0,max:r=1,integer:o=!1}={}){return x(this,s=>{let i=s.length,a=new Float64Array(i),u=e!==void 0?Hr(e):Math.random,c=r-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){return x(this,T(t=>Cn(t,e)))}sign(){return x(this,T(Math.sign))}sin(){return x(this,T(Math.sin))}sinh(){return x(this,T(Math.sinh))}sqrt(){return x(this,T(e=>e<0?null:Math.sqrt(e)))}sub(e){return x(this,V(this,e,(t,r)=>t-r))}tan(){return x(this,T(Math.tan))}tanh(){return x(this,T(Math.tanh))}trunc(){return x(this,T(Math.trunc))}}});var ft,ar=E(()=>{"use strict";ne();Ae();B();ft=class extends N{and(e){return x(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),i=C(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,T(e=>!e))}or(e){return x(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),i=C(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,r)=>!!t!=!!r))}}});function So(n,e,t,r){let o=n.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=n[a];if(u==null)s[a]=null;else{let c=i[a],l=new Set;if(C(c)){let m=c.length;for(let h=0;h<m;h++)l.add(q(c[h]))}else l.add(q(c));let f=l.has(q(u));s[a]=r?!f:f}}}else{let i=C(t)?t:[],a=new Set,u=i.length;for(let c=0;c<u;c++)a.add(q(i[c]));for(let c=0;c<o;c++){let l=n[c];if(l==null)s[c]=null;else{let f=a.has(q(l));s[c]=r?!f:f}}}return s}function Do(n,e){let{frequencies:t}=Oe(n,{strict:!0}),r=n.length,o=new Array(r);for(let s=0;s<r;s++){let i=t.get(n[s])||0;o[s]=e?i>1:i===1}return o}function Ao(n,e,t){let r=n.length,o=new Array(r);if(C(e))for(let s=0;s<r;s++){let i=n[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<r;s++){let i=n[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 mt,lr=E(()=>{"use strict";ne();Ae();B();mt=class extends N{between(e,t,r="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=C(a),f=C(u);for(let m=0;m<i;m++){let h=o[m],p=l?a[m]:a,y=f?u[m]:u;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(e){return x(this,V(this,e,(t,r)=>t===r))}eq_missing(e){return x(this,(t,r)=>{let o=this._resolve(e,r,t.length);return Ao(t,o,!1)})}ge(e){return x(this,V(this,e,(t,r)=>t>=r))}gt(e){return x(this,V(this,e,(t,r)=>t>r))}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:r=1e-8,nans_equal:o=!1}={}){return x(this,(s,i)=>{let a=s.length,u=this._resolve(e,i,a),c=C(u),l=new Array(a);for(let f=0;f<a;f++){let m=s[f],h=c?u[f]:u;if(m==null||h==null)l[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)),t);l[f]=p<=y}else Number.isNaN(m)&&Number.isNaN(h)?l[f]=o:l[f]=m===h}return l})}is_duplicated(){return x(this,e=>Do(e,!0))}is_empty({ignoreNulls:e=!1}={}){return x(this,T(t=>typeof t=="string"?t.length===0:C(t)?e?W(t,"nullish",{mode:"every"}):t.length===0:null))}is_finite(){return x(this,T(Number.isFinite))}is_in(e){return x(this,(t,r)=>So(t,r,e,!1))}is_infinite(){return x(this,T(e=>e===1/0||e===-1/0))}is_nan(){return x(this,T(Number.isNaN))}is_not_nan(){return x(this,T(e=>!Number.isNaN(e)))}is_not_null(){return x(this,e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=e[o]!=null;return r})}is_null(){return x(this,e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=e[o]==null;return r})}is_unique(){return x(this,e=>Do(e,!1))}le(e){return x(this,V(this,e,(t,r)=>t<=r))}lt(e){return x(this,V(this,e,(t,r)=>t<r))}ne(e){return x(this,V(this,e,(t,r)=>t!==r))}ne_missing(e){return x(this,(t,r)=>{let o=this._resolve(e,r,t.length);return Ao(t,o,!0)})}not_in(e){return x(this,(t,r)=>So(t,r,e,!0))}}});var ln,pt,ur=E(()=>{"use strict";ne();Ae();B();ln=class{constructor(e){this.expr=e}expr;_deriveString(e){return x(this.expr,T(t=>e(String(t))))}_patternGuard(e,t){return e==null?x(this.expr,r=>new Array(r.length).fill(null)):t()}concat(e){return x(this.expr,V(this.expr,e,(t,r)=>String(t)+String(r)))}contains(e){return this._patternGuard(e,()=>this._deriveString(t=>de(e)?e.test(t):t.includes(e)))}count_matches(e){return this._patternGuard(e,()=>this._deriveString(t=>{if(de(e)){let r=e.global?e:new RegExp(e.source,e.flags+"g"),o=t.match(r);return o?o.length:0}else{let r=0,o=t.indexOf(e);for(;o!==-1;)r++,o=t.indexOf(e,o+e.length);return r}}))}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(r=>{let o=r.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(r=>r.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(r=>r.replace(e,t)))}replace_all(e,t){return this._patternGuard(e,()=>this._deriveString(r=>r.replaceAll(e,t)))}reverse(){return this._deriveString(e=>e.split("").reverse().join(""))}rpad(e,t=" "){return this._deriveString(r=>r.padEnd(e,t))}slice(e,t){return this._deriveString(r=>{let o=e<0?r.length+e:e,s=t!==void 0?o+t:void 0;return r.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(r=>Ve(r,e,{mode:"both",...t}))}strip_chars_end(e,t){return this._deriveString(r=>Ve(r,e,{mode:"end",...t}))}strip_chars_start(e,t){return this._deriveString(r=>Ve(r,e,{mode:"start",...t}))}strip_prefix(e){return this._deriveString(t=>Ve(t,e,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(e){return this._deriveString(t=>Ve(t,e,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(e,t=!0){return this._deriveString(r=>fo(r,e,t))}to_date(){return this._deriveString(e=>Q(e,{dateOnly:!0}))}to_datetime(){return this._deriveString(Q)}to_decimal(e,t){return this._deriveString(r=>At(r,{precision:e,scale:t}))}to_integer(){return this._deriveString(e=>me(e))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(vt)}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"))}},pt=class extends N{get str(){return new ln(this)}}});var ht,cr=E(()=>{"use strict";ne();se();B();ht=class extends N{_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=>W(e,t=>!!t,{mode:"every"}))}all_null(){return this._deriveAgg(e=>W(e,"nullish",{mode:"every"}))}any(){return this._deriveAgg(e=>W(e,t=>!!t,{mode:"some"}))}any_null(){return this._deriveAgg(e=>W(e,"nullish",{mode:"some"}))}avg(){return this._deriveAgg(e=>$(e).mean)}count(e={}){return e.includeNulls?this._deriveAgg(t=>t.length):this._deriveAgg(t=>$(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=>$(e).max)}mean(){return this.avg()}median(){return this._deriveAgg(e=>je(e))}min(){return this._deriveAgg(e=>$(e).min)}mode(){return this._deriveAgg(e=>Ct(e))}n_unique(e={}){return this._deriveAgg(t=>Oe(t,e).count)}quantile(e){if(e<0||e>1)throw new Se("Quantile q must be between 0 and 1");return this._deriveAgg(t=>Tt(t,e))}std(){return this._deriveAgg(e=>$(e).std)}sum(){return this._deriveAgg(e=>$(e).sum)}}});function fr(n,e,t={}){if(e==null)return null;let r=t.dense?"_denseRankCache":"_rankCache",o=n[r];if(!o){let s=n;if(t.ignoreNulls){s=[];let u=n.length;for(let c=0;c<u;c++)n[c]!=null&&s.push(n[c])}t.dense&&(s=Array.from(new Set(s)));let i=Ze(s);o=new Map;let a=i.length;for(let u=0;u<a;u++){let c=i[u];o.has(c)||o.set(c,u+1)}n[r]=o}return o.get(e)??null}var yt,mr=E(()=>{"use strict";ne();B();yt=class extends N{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(r,o,s){let i=Math.max(0,s-e+1),a=s+1,u=r.slice(i,a);return t(u)})}_cum(e,t,r,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 h=s[m];h!=null&&(u=r(u,h),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,r)=>t===null||r>t?r:t)}cum_min(e=!1){return this._cum(e,null,(t,r)=>t===null||r<t?r:t)}cum_prod(e=!1){return this._cum(e,1,(t,r)=>t*r,(t,r)=>r?t:null)}cum_sum(e=!1){return this._cum(e,0,(t,r)=>t+r)}dense_rank(){return this._window(function(e,t,r){return fr(e,e[r],{dense:!0})})}lag(e=1,t=null){return this._window(function(r,o,s){let i=t;return s-e>=0&&(i=r[s-e]),i})}lead(e=1,t=null){return this._window(function(r,o,s){let i=t;return s+e<r.length&&(i=r[s+e]),i})}over(e){let t=x(this),r=Array.isArray(e)?e:[e];return t.partitionBy=r,t}rank(){return this._window(function(e,t,r){return fr(e,e[r])})}rolling_max(e){return this._rolling(e,t=>$(t).max)}rolling_mean(e){return this._rolling(e,t=>$(t).mean)}rolling_median(e){return this._rolling(e,t=>je(t))}rolling_min(e){return this._rolling(e,t=>$(t).min)}rolling_quantile(e,t){return this._rolling(t,r=>Tt(r,e))}rolling_rank(e){return this._rolling(e,t=>fr(t,t[t.length-1],{ignoreNulls:!0}))}rolling_std(e){return this._rolling(e,t=>$(t).std)}rolling_sum(e){return this._rolling(e,t=>$(t).sum)}row_number(){let e=this._window(function(t,r,o){return o+1});return e.outputName="row_number",e}}});var un,dt,pr=E(()=>{"use strict";ne();Ae();B();kn();un=class{constructor(e){this.expr=e}expr;_deriveDate(e){return x(this.expr,T(t=>{let r=Q(t);return r?e(r):null}))}_deriveDuration(e){return x(this.expr,T(t=>typeof t=="number"?e(t):null))}century(){return this._deriveDate(io)}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=>so(t,e))}hour(){return this._deriveDate(e=>e.getUTCHours())}is_leap_year(){return this._deriveDate(Mn)}microsecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*1e3)}millennium(){return this._deriveDate(lo)}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=>vn(e,1,0))}month_start(){return this._deriveDate(e=>vn(e,0,1))}nanosecond(){return this._deriveDate(e=>e.getUTCMilliseconds()*1e6)}ordinal_day(){return this._deriveDate(Fn)}quarter(){return this._deriveDate(uo)}second(){return this._deriveDate(e=>e.getUTCSeconds())}strftime(e,t){return this._deriveDate(r=>Ee(r,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/864e5)}total_hours(){return this._deriveDuration(e=>e/36e5)}total_microseconds(){return this._deriveDuration(e=>e*1e3)}total_milliseconds(){return this._deriveDuration(e=>e)}total_minutes(){return this._deriveDuration(e=>e/6e4)}total_nanoseconds(){return this._deriveDuration(e=>e*1e6)}total_seconds(){return this._deriveDuration(e=>e/1e3)}week(){return this._deriveDate(ao)}weekday(){return this._deriveDate(e=>e.getUTCDay()||7)}year(){return this._deriveDate(e=>e.getUTCFullYear())}},dt=class extends N{get dt(){return new un(this)}}});var cn,gt,hr=E(()=>{"use strict";ne();Ae();B();se();ae();cn=class{constructor(e){this.expr=e}expr;_deriveArray(e){return x(this.expr,T(t=>C(t)?e(t):null))}all(){return this._deriveArray(e=>W(e,t=>!!t,{mode:"every"}))}any(){return this._deriveArray(e=>W(e,t=>!!t,{mode:"some"}))}contains(e){return this._deriveArray(t=>t.includes(e))}contains_all(e){return this._deriveArray(t=>W(e,r=>t.includes(r),{mode:"every"}))}contains_any(e){return this._deriveArray(t=>W(e,r=>t.includes(r),{mode:"some"}))}count_matches(e){return this._deriveArray(t=>{let r=0,o=t.length;for(let s=0;s<o;s++)t[s]===e&&r++;return r})}drop_nulls(){return this._deriveArray(e=>{let t=e.length,r=[];for(let o=0;o<t;o++)e[o]!=null&&r.push(e[o]);return r})}explode({empty_as_null:e=!0,keep_nulls:t=!0}={}){return x(this.expr,r=>{let o=r.length,s=0;for(let c=0;c<o;c++){let l=r[c];if(C(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=r[c];if(C(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._deriveArray(r=>{let o=r.length,s=C(e)?e:[e],i=s.length,a=new Array(i);for(let u=0;u<i;u++){let c=s[u],l=r.at(c);if(l===void 0&&!t)throw new Se(`Index ${c} is out of bounds for array of length ${o}`);a[u]=l??null}return a})}gather_every(e={}){return this._deriveArray(t=>Xr(t,e))}get(e,t=!0){return this._deriveArray(r=>{let o=r.at(e);if(o===void 0&&!t)throw new Se(`Index ${e} is out of bounds for array of length ${r.length}`);return o??null})}join(e=",",t={}){return this._deriveArray(r=>Zr(r,e,t))}last(e=!0){return this.get(-1,e)}len(){return this.lengths()}lengths(){return this._deriveArray(e=>e.length)}max(){return this._deriveArray(e=>$(e).max)}mean(){return this._deriveArray(e=>$(e).mean)}median(){return this._deriveArray(e=>je(e))}min(){return this._deriveArray(e=>$(e).min)}mode(){return this._deriveArray(e=>Ct(e))}n_unique(e={}){return this._deriveArray(t=>Oe(t,e).count)}reverse(){return this._deriveArray(e=>e.slice().reverse())}slice(e,t){return this._deriveArray(r=>{let o=r.length,s=e<0?Math.max(0,o+e):e,i=t!==void 0?s+t:o;return r.slice(s,i)})}sort(e){return this._deriveArray(t=>Ze(t,e))}sum(){return this._deriveArray(e=>$(e).sum)}unique(e={}){return this._deriveArray(t=>Oe(t,e).values)}eval(e){return x(this.expr,(t,r)=>{let o=t.length,s=new Array(o);for(let i=0;i<o;i++){let a=t[i];if(!C(a)){s[i]=null;continue}let u=a.length,c={...r,[ze]: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),h=e.aggFn(Array.from(m));s[i]=e.evaluatePost(f,[h],c)}else s[i]=ut(e,c,u)}return s})}},gt=class extends N{get arr(){return new cn(this)}}});var fn,Oo=E(()=>{"use strict";ne();B();fn=class extends N{fill_null({value:e=void 0,strategy:t=void 0,limit:r=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=$(o)[t],Ie(a,u,{mode:"constant",condition:c=>c==null})}else if(t==="forward"||t==="backward"){let u=t==="forward",c=null,l=0;Ie(a,null,{mode:"independent",reverse:!u,step:({originalValue:f})=>f!=null?(c=f,l=0,f):c!==null&&(r===void 0||l<r)?(l++,c):null})}else throw new Error(`Unsupported fill_null strategy: "${t}"`);else{let u=this._resolve(e,s,i),c=C(u);Ie(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 Io={};Ar(Io,{ColumnExpr:()=>O,resolveColumnSelectors:()=>Te});function As(n,e){for(let t of e)for(let r of Object.getOwnPropertyNames(t.prototype))r!=="constructor"&&Object.defineProperty(n.prototype,r,Object.getOwnPropertyDescriptor(t.prototype,r)||Object.create(null))}function Ts(n,e,t,r){if(!(n instanceof O)){if(P(n)&&"evaluate"in n&&!n.colName){let o=[];for(let s=0;s<e.length;s++)t.has(e[s])||o.push(e[s]);return o}return null}if(n.colNames&&n.colNames.length>0)return n.colNames;if(n.colName==="*"){let o=new Set(n.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(n.targetType||n.targetTypes&&n.targetTypes.length>0){if(!r)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=r[i];if(a){if(n.targetType)a.matches(n.targetType)&&o.push(i);else if(n.targetTypes){for(let u=0;u<n.targetTypes.length;u++)if(a.matches(n.targetTypes[u])){o.push(i);break}}}}return o}return null}function Te(n,e,t,r,o){let s=[],i=t?new Set(t):new Set;for(let a=0;a<n.length;a++){let u=n[a];if(typeof u=="string"){s.push(new O(u));continue}if(P(u)&&u.isUnnest){let l=[],f=u.colName;if(typeof f=="string"&&r&&r[f]&&r[f].name==="Struct"&&(l=Object.keys(r[f].fields)),l.length===0&&o){let p=Object.keys(o)[0],y=p?o[p].length:0,d=u.baseExpr.evaluate(o,y),g=d.length;for(let b=0;b<g;b++){let D=d[b];if(D!=null&&typeof D=="object"){l=Object.keys(D);break}}}let m=l.length;if(m>0){for(let h=0;h<m;h++){let p=l[h],y=u.baseExpr.struct.field(p);s.push(y)}continue}}let c=Ts(u,e,i,r);if(c!==null)for(let l=0;l<c.length;l++){let f=new O(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 O,ce=E(()=>{"use strict";ne();ir();lr();cr();mr();ur();ar();pr();hr();yr();Oo();B();we();ae();O=class n extends N{colName;colNames;excludedCols=[];targetType;targetTypes;static isColExpr(e){if(!P(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 n.isColExpr(e)?e:new n(e)}constructor(e){super(),Array.isArray(e)?e.some(r=>r instanceof Y||typeof r=="function")?(this.targetTypes=e,this.colName="",this.outputName=""):(this.colNames=e.map(String),this.colName="",this.outputName=""):e instanceof Y||typeof e=="function"?(this.targetType=e,this.colName="",this.outputName=""):(this.colName=String(e),this.outputName=this.colName)}};As(O,[ct,mt,ht,yt,pt,ft,dt,gt,bt,fn])});function ko(n){if(n==null)throw new Error("Column reference cannot be null or undefined.");return mn||(mn=(ce(),Tr(Io)).ColumnExpr),mn.isColExpr(n)?n:new mn(n)}var mn,pn,bt,yr=E(()=>{"use strict";ne();mn=null;pn=class{constructor(e){this.expr=e;return new Proxy(this,{get(t,r,o){return r in t?Reflect.get(t,r,o):typeof r=="string"?t.field(r):Reflect.get(t,r,o)}})}expr;field(e){return x(this.expr,t=>{let r=t.length,o=new Array(r);for(let s=0;s<r;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 r=t.length,o=new Array(r),s=Object.keys(e),i=s.length;for(let a=0;a<r;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 h=l[m];c[h]=u[h]}for(let m=0;m<i;m++){let h=s[m];if(h in c){let p=e[h];c[p]=c[h],delete c[h]}}o[a]=c}return o})}with_fields(e){return x(this.expr,(t,r)=>{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=ko(f),h=m.outputName||m.colName;if(!h)throw new Error("Expressions passed to struct.with_fields must have a name/alias.");i.push({name:h,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],h=ko(e[m]);i.push({name:m,expr:h})}}let a=i.length,u=new Array(a);for(let c=0;c<a;c++)u[c]=i[c].expr.evaluate(r,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),h=m.length;for(let p=0;p<h;p++){let y=m[p];f[y]=l[y]}for(let p=0;p<a;p++)f[i[p].name]=u[p][c];s[c]=f}return s})}unnest(){let e=x(this.expr);return e.isUnnest=!0,e.baseExpr=this.expr,e}},bt=class extends N{get struct(){return new pn(this)}}});var ks={};Ar(ks,{$df:()=>Is,ALL_COLUMNS_MARKER:()=>G,AggregationExpr:()=>ht,ArithmeticExpr:()=>ct,Array:()=>Qn,ArrayDataType:()=>Qn,ArrayExpr:()=>gt,ArrayExprNamespace:()=>cn,ArrayType:()=>nn,Binary:()=>zn,BinaryType:()=>Jt,Boolean:()=>it,BooleanDataType:()=>it,BooleanType:()=>zt,COALESCE_MARKER:()=>_n,ColumnExpr:()=>O,ColumnNotFoundError:()=>he,ComparisonExpr:()=>mt,ComputeError:()=>Se,DFScriptError:()=>Ne,DataFrame:()=>v,DataFrameError:()=>j,DataType:()=>Y,DataTypeRegistry:()=>R,Date:()=>Yn,DateDataType:()=>Yn,DateTimeExprNamespace:()=>un,DateType:()=>Zt,Datetime:()=>at,DatetimeType:()=>Qt,DecimalType:()=>rt,Duration:()=>Zn,DurationType:()=>tn,ELEMENT_MARKER:()=>ze,ExprBase:()=>N,Float32:()=>Gn,Float32Type:()=>Wt,Float64:()=>st,Float64Type:()=>Gt,FloatDataType:()=>Le,GroupedData:()=>_t,Int16:()=>Pn,Int16Type:()=>Vt,Int32:()=>Bn,Int32Type:()=>Lt,Int64:()=>ot,Int64Type:()=>Pt,Int8:()=>Ln,Int8Type:()=>jt,IntegerDataType:()=>nt,LITERAL_MARKER:()=>xn,LogicalExpr:()=>ft,NestedDataType:()=>Pe,Null:()=>Hn,NullType:()=>Yt,NumericDataType:()=>Re,Object:()=>Jn,ObjectDataType:()=>Jn,ObjectType:()=>Xt,SchemaError:()=>Ke,ShapeError:()=>z,SignedIntegerType:()=>be,StringExpr:()=>pt,StringExprNamespace:()=>ln,Struct:()=>er,StructExpr:()=>bt,StructExprNamespace:()=>pn,StructType:()=>rn,TemporalDataType:()=>_e,TemporalExpr:()=>dt,Time:()=>Xn,TimeType:()=>en,UInt16:()=>Kn,UInt16Type:()=>$t,UInt32:()=>qn,UInt32Type:()=>Kt,UInt64:()=>Wn,UInt64Type:()=>qt,UInt8:()=>$n,UInt8Type:()=>Bt,UnsignedIntegerType:()=>xe,Utf8:()=>Be,Utf8Type:()=>Ht,When:()=>yn,WhenThen:()=>xt,WhenThenChain:()=>hn,WindowExpr:()=>yt,all:()=>We,assertColumnExists:()=>X,assertHeight:()=>an,coalesce:()=>br,coerceColumn:()=>De,columnsToRows:()=>or,computeRowHash:()=>ve,concat:()=>Ge,derive:()=>x,element:()=>wr,evaluateExpression:()=>ut,exclude:()=>gr,gatherColumnsByIndices:()=>qe,getRowFromColumns:()=>ws,implode:()=>_r,inferColumnType:()=>ye,kleeneBinary:()=>V,kleeneUnary:()=>T,lit:()=>dr,read_csv:()=>gn,read_json:()=>dn,resolveColumnSelectors:()=>Te,resolveWindowExpr:()=>nr,rowsToColumns:()=>rr,seq_range:()=>Fe,when:()=>xr,writeStringToFileOrStream:()=>sr});module.exports=Tr(ks);ae();ne();ir();ar();lr();ur();cr();mr();pr();hr();yr();ce();ce();ae();se();B();function Fe(n,e={strict:!0}){let t=e,r=new O(xn);return r.literalValue=n,t.name&&(r.outputName=t.name),r.ops.push(o=>{let s=o.length,i=(S,w)=>S===void 0?w:ue(S<0?s+S:S,{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 S=t.pad??!1,w=t.truncate??!1;if(S&&!w&&l>c)throw new z(`Cannot pad seq_range output: specified length ${l} starting at index ${a} exceeds slice width ${c} (requires truncation).`);if(w&&!S&&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,h=!!t.dtype,p=t.mode||"cumulative",y=t.step!==void 0?t.step:1,d=h?S=>t.dtype.coerce(S):S=>S;if(f){let S=t.dtype?.allocate?t.dtype.allocate(m):new Array(m);return Ie(S,n,{mode:p,step:y,coerce:d,startIndex:0,endIndex:m}),S}let g=Math.min(a+l,u),b=t.padValue!==void 0?t.padValue:null,D=d(b);if(p==="constant"&&a===0&&g===m&&!t.dtype){let S=new Array(m);for(let w=0;w<m;w++)S[w]=n;return S}let _=new Array(m);return _.fill(D),Ie(_,n,{mode:p,step:y,coerce:d,startIndex:a,endIndex:g}),_}),r}function dr(n,e){let t=Fe(n,{strict:!0,mode:"constant",dtype:e?.dtype,name:e?.name});return t.isLiteral=!0,t}ce();ae();function We(){return new O("*")}ce();ae();function gr(n){let e=new O("*");return e.excludedCols=Array.isArray(n)?n:[n],e}ce();B();ae();function br(...n){let e=n.length===1&&Array.isArray(n[0])?n[0]:n,t=new O(_n);return t.ops.push((r,o)=>{let s=r.length,i=l=>O.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 h=u[m],p=C(h)?h[l]:h;if(p!=null){f=p;break}}c[l]=f}return c}),t}ce();B();var hn=class{predicates;values;constructor(e,t){this.predicates=e,this.values=t}then(e){return new xt(this.predicates,this.values.concat(e))}},yn=class{predicates;constructor(e){this.predicates=[e]}then(e){return new xt(this.predicates,[e])}},xt=class n extends O{predicates;values;otherwiseValue;constructor(e,t,r=null){super(typeof e=="string"?e:"*when*"),this.predicates=Array.isArray(e)?e:[],this.values=t||[],this.otherwiseValue=r,this.ops.push((o,s)=>{let i=o.length,a=h=>O.isColExpr(h)?h.evaluate(s,i):typeof h=="string"&&h in s?s[h]:h,u=this.predicates.length,c=new Array(u),l=new Array(u);for(let h=0;h<u;h++)c[h]=a(this.predicates[h]),l[h]=a(this.values[h]);let f=a(this.otherwiseValue),m=new Array(i);for(let h=0;h<i;h++){let p=!1;for(let y=0;y<u;y++)if((C(c[y])?c[y][h]:c[y])===!0){m[h]=C(l[y])?l[y][h]:l[y],p=!0;break}p||(m[h]=C(f)?f[h]:f)}return m})}when(e){return new hn(this.predicates.concat(e),this.values)}otherwise(e){return new n(this.predicates,this.values,e)}};function xr(n){return new yn(n)}ce();function _r(n){return O.toColExpr(n).implode()}ce();ae();function wr(){return new O(ze)}Ae();lt();var _t=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(e,t,r,o,s,i){this.groups=e,this.keys=t,this.allKeys=r,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 r=this.groups.size,o={};for(let a=0;a<t.length;a++)o[t[a]]=new Array(r);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 v._createDirect(o,i,s)}agg(...e){let t=this.allKeys.length,r=new Array(t);for(let f=0;f<t;f++)r[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=Te(e.flat(),r,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 h=0;h<s.length;h++){let p=s[h],y=this.parentColumns[p][m];u[p][c]=y===void 0?null:y}c++}for(let f=0;f<i.length;f++){let m=i[f],h=m.outputName||m.colName||"*";if(!m.aggFn)u[h]=m.evaluate(u,a);else{let p=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 D=0;D<g.length;D++)b[D]=p[g[D]];y[d]=m.aggFn(b),d++}u[h]=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]=ye(u[m])}return v._createDirect(u,l,c)}};Mt();Ft();we();B();se();we();B();se();function Cs(n,e,t){if(n==null)throw new j(`Invalid input to ${e} at index ${t}: item cannot be null or undefined.`);if(n instanceof v)return[n];if(Ce(n))return[new v(n)];if(C(n)){if(W(n,v,{mode:"every"}))return n;if(W(n,"plainObject",{mode:"every"}))return[new v(n)];let r=W(n,v,{mode:"some"});for(let o=0;o<n.length;o++)if(r?!(n[o]instanceof v):!Ce(n[o]))throw new j(r?`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 Ge(n,{how:e="vertical",horizontal:t}={}){if(n==null)throw new j("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(...Cs(r[i],"concat",i));let s=t?.strict??!0;if(o.length===0)return v._createDirect({},{},0);if(o.length===1&&e!=="horizontal")return o[0];switch(e){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 v._createDirect({},{},0);let a=i[0],u=Object.keys(a._columns);for(let p=0;p<o.length;p++){let y=o[p];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 ${p}.`);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 ${p}. Expected column "${u[g]}", but found "${d[g]}".`);let b=a.schema[u[g]],D=y.schema[u[g]];if(b&&D&&!b.equals(D))throw new Ke(`[Strict Type Check] Schema type mismatch for column "${u[g]}": expected ${b.name}, found ${D.name}.`)}}let c=0;for(let p of o)c+=p.height;let l={},f=o.length;for(let p=0;p<f;p++)if(o[p].height>0){l=o[p].schema;break}Object.keys(l).length===0&&f>0&&(l=o[0].schema);let m={};for(let p of u){let y=l[p],d=!1;for(let b of o){let D=b._columns[p];if(!D){d=!0;break}if(!U(D)){for(let _=0;_<D.length;_++)if(D[_]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(c):new Array(c).fill(null);d&&U(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 u){let g=p._columns[d]||new Array(y).fill(null),b=m[d];if(U(b)&&U(g))b.set(g,h);else{let D=b;for(let _=0;_<y;_++)D[h+_]=g[_]}}h+=y}}return v._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),h=m.length;for(let p=0;p<h;p++){let y=m[p],d=l._columns[y];if(f===i)u[y]=U(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 v._createDirect(u,c,i)}case"diagonal":{let i=new Set;for(let m of o)for(let h of Object.keys(m._columns))i.add(h);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 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 Ke(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${h.name}, found ${y.name}.`)}}c[m]=h||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 h=o[m],p=h.height;if(p!==0){for(let y=0;y<a.length;y++){let d=a[y],g=l[d],b=h._columns[d];if(b!==void 0)if(U(b)&&U(g))g.set(b,f);else{let D=g;for(let _=0;_<p;_++)D[f+_]=b[_]}else{let D=g;for(let _=0;_<p;_++)D[f+_]=null}}f+=p}}return v._createDirect(l,c,u)}}}lt();var v=class n{_columns;_height;_schema={};static _createDirect(e,t,r){an(e,r);let o=Object.create(n.prototype);return o._columns=e,o._schema=t,o._height=r,o}constructor(e,t,r){if(Array.isArray(e)){let{columns:o,height:s}=rr(e);this._columns=o,this._height=s,t?this.applySchema(t):this.inferSchema();return}if(P(e)){this._columns=e,this._height=an(e,r),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),r=t.length;for(let o=0;o<r;o++){let s=t[o];e[s]=ye(this._columns[s])}this.applySchema(e)}applySchema(e){this._schema=e;let t=Object.keys(e),r={};for(let o of t){let s=e[o],i=this._columns[o];r[o]=i?De(i,s,this._height):De(new Array(this._height).fill(null),s,this._height)}this._columns=r}get columns(){return Object.keys(this._columns)}concat(e,t={}){let r=W(e,n,{mode:"every",allowEmpty:!1})?e:[e];return Ge([this,...r],t)}drop(...e){let t=new Set(e.flat()),r={},o={};for(let s of Object.keys(this._columns))t.has(s)||(r[s]=this._columns[s],o[s]=this._schema[s]);return n._createDirect(r,o,this._height)}drop_nulls(e){return this._height===0?this:this.filter(e?new O(e).is_not_null():We().is_not_null())}get dtypes(){let e=Object.keys(this._columns),t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=this._schema[e[o]];return r}explode(e,t){let r=O.toColExpr(e),o=r.colNames||[r.colName||r.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.");X(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 O(f).arr.explode(t):new O(f))}return this.select(...u)}fill_null(e={}){return this._height===0?this:this.with_columns(We().fill_null(e))}filter(...e){if(this._height===0)return n._createDirect({},this._schema,0);let t=this._height,r=Object.keys(this._columns),o=r.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=Te(a,r,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,h=null;if(i.length>0){let d=this._columns;h={};for(let g=0;g<o;g++){let b=r[g],D=d[b];Object.defineProperty(h,b,{get(){let _=D[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(h){m=d;for(let b=0;b<i.length;b++)if(!i[b](h)){g=!1;break}}g&&f.push(d)}}let p=qe(this._columns,f),y=f.length;return n._createDirect(p,this._schema,y)}get_schema(){return this._schema}groupby(e){let t=Xe(e),r=new Map,o=this._height,s=Ue(e);for(let a=0;a<s.length;a++)X(s[a],this._columns,"Grouping key");for(let a=0;a<o;a++){let u=ve(this._columns,s,a),c=r.get(u);c===void 0&&r.set(u,c=[]),c.push(a)}let i=Object.keys(this._columns);return new _t(r,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,r){let o=O.toColExpr(r).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 r=this._height,o=Object.keys(this._columns),s=o.length;if(e===void 0&&t===void 0){if(r!==1||s!==1)throw new j("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 j("DataFrame.item() requires both row and column to be specified if not empty.");if(e<0||e>=r)throw new z(`Row index ${e} is out of bounds for DataFrame height ${r}.`);let i;if(typeof t=="number"){if(t<0||t>=s)throw new z(`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 he(i);return this._columns[i][e]}*iter_columns(){let e=Object.keys(this._columns),t=e.length,r=this._columns;for(let o=0;o<t;o++)yield r[e[o]]}*iter_rows({named:e=!1}={}){let t=Object.keys(this._columns),r=t.length,o=this._columns,s=this._height,i=new Array(r);for(let a=0;a<r;a++)i[a]=o[t[a]];if(e)for(let a=0;a<s;a++){let u={};for(let c=0;c<r;c++)u[t[c]]=i[c][a];yield u}else for(let a=0;a<s;a++){let u=new Array(r);for(let c=0;c<r;c++)u[c]=i[c][a];yield u}}join(e){let{other:t,on:r,how:o="inner",suffixes:s=["","_right"]}=e,i=Ue(r);for(let I=0;I<i.length;I++){let k=i[I];X(k,this._columns,"Join key"," in the left DataFrame."),X(k,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,h=l.length,p=(I,k)=>{let L=i.length;for(let K=0;K<L;K++)if(I[i[K]][k]==null)return null;return ve(I,i,k)},y=new Map,d=t._height,g=t._columns;for(let I=0;I<d;I++){let k=p(g,I);if(k===null)continue;let L=y.get(k);L===void 0&&(L=[],y.set(k,L)),L.push(I)}let b=this._height,D=this._columns,_=[],S=[],w=o==="outer"||o==="right",A=w?new Set:null;for(let I=0;I<b;I++){let k=p(D,I),L=k===null?void 0:y.get(k);if(L===void 0)(o==="left"||o==="outer")&&(_.push(I),S.push(null));else for(let K=0;K<L.length;K++){let H=L[K];w&&A.add(H),_.push(I),S.push(H)}}if(w)for(let I=0;I<d;I++)A.has(I)||(_.push(-1),S.push(I));let M=_.length,fe={},ie={};for(let I=0;I<m;I++){let k=c[I],L=k in t._columns&&!f.has(k)?`${k}${a}`:k,K=this._columns[k],H=f.has(k),J=new Array(M);if(H){let re=t._columns[k];for(let ee=0;ee<M;ee++){let Sr=_[ee];if(Sr!==-1)J[ee]=K[Sr];else{let Dr=S[ee];J[ee]=Dr!==null?re[Dr]:null}}}else for(let re=0;re<M;re++){let ee=_[re];J[re]=ee!==-1?K[ee]:null}fe[L]=J,this._schema[k]&&(ie[L]=this._schema[k])}for(let I=0;I<h;I++){let k=l[I];if(!f.has(k)){let L=k in this._columns?`${k}${u}`:k,K=t._columns[k],H=new Array(M);for(let J=0;J<M;J++){let re=S[J];H[J]=re!==null?K[re]:null}fe[L]=H,t._schema[k]&&(ie[L]=t._schema[k])}}return n._createDirect(fe,ie,M)}limit(e,{offset:t=0,from:r="start"}={}){let o=this._height,s=ue(Math.floor(e),{min:0,max:o}),i=ue(Math.floor(t),{min:0,max:o}),a=i,u=Math.min(i+s,o);r==="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 h=0;h<m;h++){let p=f[h];l[p]=this._columns[p].slice(a,u)}return n._createDirect(l,this._schema,c)}pivot(e){if(this._height===0)return n._createDirect({},{},0);let{index:t,columns:r,values:o}=e,s=Ue(t),i=s.length;for(let S=0;S<i;S++)X(s[S],this._columns,"Pivot index key");let a=String(r),u=String(o);X(a,this._columns,"Pivot column key"),X(u,this._columns,"Pivot values key");let c=new Map,l=[],f=new Set,m=this._height,h=this._columns[a],p=this._columns[u];for(let S=0;S<m;S++){let w=ve(this._columns,s,S);f.add(String(h[S])),c.get(w)===void 0&&(c.set(w,c.size),l.push(S))}let y=c.size,d={},g={};for(let S=0;S<i;S++){let w=s[S];d[w]=this._columns[w],this._schema[w]&&(g[w]=this._schema[w])}let b=qe(d,l),D=Array.from(f),_=this._schema[u]||R.Utf8;for(let S=0;S<D.length;S++){let w=D[S];b[w]=new Array(y).fill(null),g[w]=_}for(let S=0;S<m;S++){let w=ve(this._columns,s,S),A=c.get(w),M=String(h[S]);b[M][A]=p[S]}return n._createDirect(b,g,y)}rename(e){let t=e||{},r={},o={},s=Object.keys(this._columns);for(let a of s){let u=t[a]||a;r[u]=this._columns[a],o[u]=this._schema[a]}if(Object.keys(r).length<s.length)throw new j("Rename collision: Multiple columns mapped to the same output name.");return n._createDirect(r,o,this._height)}reverse(){if(this._height===0)return this;let e={},t=Object.keys(this._columns),r=t.length;for(let o=0;o<r;o++){let s=t[o];e[s]=this._columns[s].slice().reverse()}return n._createDirect(e,this._schema,this._height)}get schema(){return this._schema}select(...e){let t=this._normalizeArgs(e),r=Object.keys(this._columns),o=Te(t,r,void 0,this._schema,this._columns),s=o.length;if(s===0)return n._createDirect({},{},this._height);let i={},a={},u=new Array(s),c=new Array(s),l=new Set,f=null;for(let p=0;p<s;p++){let y=o[p],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=ut(y,this._columns,this._height);u[p]=g,c[p]=d;let b=g&&g.rowMap;if(b)if(f){let D=b.length;if(D!==f.length)throw new z(`Mismatched explode heights: Column "${d}" has length ${D}, but another exploded column has length ${f.length}`);for(let _=0;_<D;_++)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,h=s>0;for(let p=0;p<s;p++){let y=o[p],d=y.aggFn!=null&&(y.partitionBy==null||y.partitionBy.length===0),g=!!y.isLiteral;if(!d&&!g){h=!1;break}}for(let p=0;p<s;p++){let y=c[p],d=u[p],g=d,b=g&&g.rowMap,D=C(d)?d.length:0,_=f&&!b?this._height:m;if(D!==_)throw new z(`Column height mismatch: Column "${y}" has length ${D}, but expected ${_}`);if(f&&!b){let S=f.length;if(U(d)){let w=new g.constructor(S);for(let A=0;A<S;A++)w[A]=g[f[A]];d=w}else{let w=new Array(S);for(let A=0;A<S;A++)w[A]=g[f[A]];d=w}}u[p]=d}h&&(m=1);for(let p=0;p<s;p++){let y=o[p],d=c[p],g=u[p],b=y.colName||d,_=y instanceof O&&y.ops.length===0&&!y.isWindow&&!y.aggFn&&this._schema[b]||ye(g);a[d]=_,i[d]=De(g,_,m)}return n._createDirect(i,a,m)}get shape(){return[this.height,this.width]}slice(e,t){let r=this._height,o=e<0?Math.max(r+e,0):Math.min(e,r),s=t===void 0?r:t<0?Math.max(r+t,0):Math.min(t,r),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:r=!1,nullsLast:o=!0,custom:s}=e,i=Xe(t);for(let p=0;p<i.length;p++){let y=O.toColExpr(i[p]);y.colName&&X(y.colName,this._columns,"Sort key")}let a=Array.isArray(r)?r:new Array(i.length).fill(r),u=i.length,c=new Array(u);for(let p=0;p<u;p++){let y=i[p],d=a[p]?-1:1,g=s&&typeof y=="string"?s[y]:null,b=O.toColExpr(y).evaluate(this._columns,this._height);c[p]={values:b,isDesc:d,customComp:g}}let l=c.length,f=o?1:-1,m=new Array(this._height);for(let p=0;p<this._height;p++)m[p]=p;m.sort((p,y)=>{for(let d=0;d<l;d++){let{values:g,isDesc:b,customComp:D}=c[d],_=g[p],S=g[y];if(D){let A=D(_,S);if(A!==0)return A*b;continue}if(_==null||S==null){if(_===S)continue;return(_==null?1:-1)*f}if(_===S)continue;return(_<S?-1:1)*b}return 0});let h=qe(this._columns,m);return n._createDirect(h,this._schema,this._height)}tail(e=10){return this.limit(e,{offset:0,from:"end"})}to_dict(){return{...this._columns}}to_dicts(){return or(this._columns,this._height)}to_array(e){if(this._height===0)return[];if(e==null)return new Array(this._height).fill(null);let r=O.toColExpr(e).evaluate(this._columns,this._height);return Array.isArray(r)?r:Array.from(r)}transpose({include_header:e=!1,header_name:t="column",column_names:r}={}){if(this._height===0){let l={},f={};return e&&(l[t]=De([],R.Utf8,0),f[t]=R.Utf8),n._createDirect(l,f,0)}let o=this.columns;typeof r=="string"&&(X(r,this._columns,"column_names"),o=o.filter(l=>l!==r));let s=[];if(typeof r=="string"){let l=this._columns[r];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 "${r}" contains null/undefined at index ${f}`);s[f]=String(m)}}else if(r!=null&&typeof r!="string"&&Symbol.iterator in Object(r)){let l=Array.from(r);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]=De(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 p=0;p<a;p++)m[p]=this._columns[o[p]][l];let h=ye(m);u[f]=De(m,h,a),c[f]=h}return n._createDirect(u,c,a)}unique(e){if(this._height===0)return n._createDirect({},this._schema,0);let t=Xe(e),r=t.length===0?Object.keys(this._columns):t.map(String);for(let c of r)X(c,this._columns,"Unique column key");let o=new Set,s=[],i=this._height;for(let c=0;c<i;c++){let l=ve(this._columns,r,c);o.has(l)||(o.add(l),s.push(c))}let a=qe(this._columns,s),u=s.length;return n._createDirect(a,this._schema,u)}unpivot(e){let{idVars:t,valueVars:r,varName:o="variable",valueName:s="value"}=e,i=Ue(t),a=Ue(r),u=i.length,c=a.length;for(let p of i)X(p,this._columns,"Unpivot id variable key");for(let p of a)X(p,this._columns,"Unpivot value variable key");let l=this._height*c,f={};for(let p=0;p<u;p++)f[i[p]]=new Array(l);f[o]=new Array(l),f[s]=new Array(l);let m=0;for(let p=0;p<this._height;p++)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][p]}f[o][m]=d,f[s][m]=this._columns[d][p],m++}let h={};for(let p of i)h[p]=this._schema[p];return h[o]=R.Utf8,h[s]=ye(f[s]),n._createDirect(f,h,l)}vstack(e){return this.concat(e,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(e){let t=e.flat(),r=[];for(let o of t)if(typeof o=="string")r.push(new O(o));else if(O.isColExpr(o))r.push(o);else if(P(o)){let s=Object.keys(o),i=s.length;for(let a=0;a<i;a++){let u=s[a],c=o[u];if(O.isColExpr(c))r.push(c.alias(u));else{let l=new O(u);l.evaluate=(f,m)=>new Array(m).fill(c),r.push(l)}}}return r}with_columns(...e){if(e.length===0)return this;let t=this._normalizeArgs(e),r=Object.keys(this._columns),o=Te(t,r,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=r.length;for(let c=0;c<u;c++){let l=r[c];a.push(i.get(l)||new O(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 r=Fe(t,{mode:"independent",dtype:R.UInt32,step:1}),o=this.insert_column(0,e,r);return o._schema[e]=R.UInt32,o}write_json(e,{format:t="json",replacerOptions:r}={}){if(t!=="json"&&t!=="ndjson")throw new TypeError(`Unsupported JSON format: "${t}". Expected "json" or "ndjson".`);let o=r?.replacer===null?void 0:tt(r),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.to_dicts(),o);return sr(e,s),s}write_csv(e,t={}){if(e){if(typeof e=="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(e,"w");try{sn(this._columns,this._height,{...t,onRow:s=>{r.writeSync(o,s,null,"utf8")}})}finally{r.closeSync(o)}}else if(P(e)&&typeof e.write=="function")sn(this._columns,this._height,{...t,onRow:r=>{e.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._columns,this._height,t)}};lt();we();B();se();function dn(n,{format:e="json",trimBeforeParse:t=!0,schema:r,...o}={}){let s=mo(n,{format:e,trimBeforeParse:t,...o});if(s===n)throw new j(`Invalid JSON input: must be a valid, non-empty JSON ${e} string.`);let i=Array.isArray(s)?s:P(s)?[s]:[];return new v(i,r)}B();function gn(n,e={}){let{hasHeader:t=!0,schema:r,inferSchema:o=!0}=e,s=yo(n,e);if(s.length===0)return new v({});let i,a;t?(i=s[0],a=s.slice(1)):(i=s[0].map((m,h)=>`column_${h}`),a=s);let u=i.length,c=a.length,l={};for(let m=0;m<u;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]:"";l[h]=p}let f={};for(let m=0;m<u;m++){let h=i[m],p=l[h];if(r&&r[h])f[h]=p;else if(o){let{values:y}=go(p,e);f[h]=y}else f[h]=p}return new v(f,r)}function Os(n,e){return new v(n,e)}var Is={data:Os,col:n=>new O(n),all:We,exclude:gr,coalesce:br,concat:Ge,read_json:dn,read_csv:gn,lit:dr,when:xr,implode:_r,seq_range:Fe,element:wr,DataType:R};we();se();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,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,when,writeStringToFileOrStream});
package/dist/types.d.ts CHANGED
@@ -1,13 +1,24 @@
1
1
  import type { DataFrame } from "./dataframe/dataframe";
2
+ import type { RegisteredDataType } from "./datatypes";
3
+ export type { RegisteredDataType };
2
4
  export type RowRecord = Record<string, any>;
5
+ export type JSONFormat =
6
+ /** Standard JSON format. */
7
+ "json"
8
+ /** Newline Delimited JSON format. */
9
+ | "ndjson";
3
10
  export type ColumnData<T = any> = ArrayLike<T> & Iterable<T>;
4
11
  export type ColumnDict = Record<string, ColumnData>;
12
+ export type DataFrameSchema = Record<string, RegisteredDataType>;
5
13
  export type DataFrameColumns<T extends RowRecord> = {
6
14
  [K in keyof T]: ColumnData<T[K]>;
7
15
  };
8
- export type Scalar = string | number | boolean | bigint | Date | null | undefined;
16
+ export type AnyTypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
17
+ export type ValidPrimitiveTypes = string | number | boolean | bigint | symbol | null | undefined;
18
+ export type ValidScalarTypes = Exclude<ValidPrimitiveTypes, symbol> | Date | AnyTypedArray;
9
19
  export type AggFn<V, R = any> = (values: V[]) => R;
10
20
  export type OpFn = (vals: ColumnData, columns: ColumnDict) => ColumnData;
21
+ export type IntoExpr = string | IExpr;
11
22
  export interface IExpr {
12
23
  ops: OpFn[];
13
24
  colName?: string;
@@ -24,13 +35,11 @@ export interface IExpr {
24
35
  } | null;
25
36
  isWindow?: boolean;
26
37
  alias(name: string): this;
27
- cast(dataType: any): this;
38
+ cast(dataType: RegisteredDataType): this;
28
39
  _resolve(val: any, columns: ColumnDict, height: number): ColumnData | any;
29
40
  evaluate(columns: ColumnDict, height: number): ColumnData;
30
- evaluatePreGrouping(columns: ColumnDict, height: number): ColumnData;
31
- evaluatePostGrouping(aggregatedArray: any[], columns: ColumnDict): ColumnData;
32
- evaluatePrePartition(columns: ColumnDict, height: number): ColumnData;
33
- evaluatePostPartition(aggregatedArray: any[], columns: ColumnDict): ColumnData;
41
+ evaluatePre(opsIndex: number | undefined, columns: ColumnDict, height: number): ColumnData;
42
+ evaluatePost(opsIndex: number | undefined, aggregatedArray: any[], columns: ColumnDict): ColumnData;
34
43
  evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
35
44
  debug(label?: string): this;
36
45
  }
@@ -45,3 +54,22 @@ export interface ConcatOptions {
45
54
  horizontal?: HorizontalConcatOptions;
46
55
  }
47
56
  export type ConcatItem = DataFrame<any> | ColumnDict | RowRecord[];
57
+ export type { UniqueArrayStatsOptions, JoinArrayOptions } from "./utils/array";
58
+ export interface ExplodeOptions {
59
+ empty_as_null?: boolean;
60
+ keep_nulls?: boolean;
61
+ }
62
+ import type { DataType } from "./datatypes/DataType";
63
+ export type InferDataType<T> = T extends DataType<infer U> ? U : any;
64
+ export type InferSchema<S extends DataFrameSchema> = {
65
+ [K in keyof S]: InferDataType<S[K]>;
66
+ };
67
+ export type FlattenUnion<T> = {
68
+ [K in (T extends any ? keyof T : never)]?: T extends any ? (K extends keyof T ? T[K] : never) : never;
69
+ };
70
+ export type FillNullStrategy = "forward" | "backward" | "min" | "max" | "mean" | "zero" | "one";
71
+ export interface FillNullOptions {
72
+ value?: any;
73
+ strategy?: FillNullStrategy;
74
+ limit?: number;
75
+ }