df-script 1.6.0 → 1.8.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 (58) hide show
  1. package/README.md +3 -1
  2. package/dist/api.d.ts +3 -1
  3. package/dist/assets/index-DBhGK6Tp.css +1 -0
  4. package/dist/assets/index-DEJEV_tU.js +195 -0
  5. package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
  6. package/dist/columnExpressions/ExprBase.d.ts +27 -12
  7. package/dist/columnExpressions/constants.d.ts +2 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
  10. package/dist/columnExpressions/functions/duration.d.ts +33 -0
  11. package/dist/columnExpressions/functions/element.d.ts +25 -0
  12. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  13. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  14. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  15. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  16. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  17. package/dist/columnExpressions/functions/when.d.ts +36 -6
  18. package/dist/columnExpressions/index.d.ts +2 -0
  19. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
  20. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
  21. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
  22. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  23. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  24. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  25. package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
  26. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  27. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +588 -11
  28. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  29. package/dist/columnExpressions/types.d.ts +1 -0
  30. package/dist/columnExpressions/utils.d.ts +10 -0
  31. package/dist/constants.d.ts +15 -3
  32. package/dist/dataframe/dataframe.d.ts +1073 -3
  33. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  34. package/dist/dataframe/types.d.ts +26 -3
  35. package/dist/dataframe/utils.d.ts +22 -1
  36. package/dist/datatypes/types.d.ts +51 -1
  37. package/dist/exceptions/index.d.ts +33 -0
  38. package/dist/exceptions/utils.d.ts +2 -0
  39. package/dist/functions/concat.d.ts +50 -0
  40. package/dist/functions/read_csv.d.ts +9 -0
  41. package/dist/functions/read_json.d.ts +7 -2
  42. package/dist/index.html +17 -0
  43. package/dist/index.js +6 -6
  44. package/dist/index.mjs +6 -0
  45. package/dist/types.d.ts +70 -14
  46. package/dist/utils/array.d.ts +55 -1
  47. package/dist/utils/csv.d.ts +1 -0
  48. package/dist/utils/date.d.ts +14 -27
  49. package/dist/utils/duration.d.ts +5 -0
  50. package/dist/utils/index.d.ts +1 -0
  51. package/dist/utils/json.d.ts +1 -0
  52. package/dist/utils/number.d.ts +1 -0
  53. package/dist/utils/object.d.ts +1 -0
  54. package/dist/utils/string.d.ts +12 -0
  55. package/package.json +28 -4
  56. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  57. package/dist/utils/guards.d.ts +0 -13
  58. package/dist/utils/list.d.ts +0 -217
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
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});
1
+ "use strict";var Nn=Object.defineProperty;var ws=Object.getOwnPropertyDescriptor;var Ss=Object.getOwnPropertyNames;var As=Object.prototype.hasOwnProperty;var k=(n,e)=>()=>(n&&(e=n(n=0)),e);var vn=(n,e)=>{for(var t in e)Nn(n,t,{get:e[t],enumerable:!0})},Ds=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ss(e))!As.call(n,o)&&o!==t&&Nn(n,o,{get:()=>e[o],enumerable:!(r=ws(e,o))||r.enumerable});return n};var Mn=n=>Ds(Nn({},"__esModule",{value:!0}),n);var re,Un,Fn,qe,jn,Vn,De=k(()=>{"use strict";re="*",Un="*literal*",Fn="*coalesce*",qe="*element*",jn="*struct*",Vn="*duration*"});var Jr=k(()=>{"use strict"});function z(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function Ue(n){if(!z(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)===qs}function ao(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 me(n,e,t,r){if(!z(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 U(n){return me(n,Ts,Ln)&&Ln?!Number.isNaN(Ln.call(n)):!1}function Te(n){return me(n,Cs,Ls)}function vt(n){return me(n,Os,Ps)}function Mt(n){return me(n,Is,Bs)}function lo(n){return me(n,ks,$s,"key")}function uo(n){return z(n)?Symbol.toStringTag in n?n instanceof Error:Object.prototype.toString.call(n)===Es:!1}function Xr(n){return me(n,no,Pn)}function Zr(n){return me(n,ro,Bn)}function Qr(n){return me(n,oo,$n)}function eo(n){return me(n,so,nt)}function to(n){return me(n,io,rt)}function ce(n){if(!z(n))return n;switch(Object.prototype.toString.call(n)){case ro:if(Zr(n))try{return Bn.call(n)}catch{}break;case no:if(Xr(n))try{return Pn.call(n)}catch{}break;case oo:if(Qr(n))try{return $n.call(n)}catch{}break;case so:if(eo(n)&&nt)try{return nt.call(n)}catch{}break;case io:if(to(n)&&rt)try{return rt.call(n)}catch{}break}if(Symbol.toStringTag in n){if(Zr(n))try{return Bn.call(n)}catch{}else if(Xr(n))try{return Pn.call(n)}catch{}else if(Qr(n))try{return $n.call(n)}catch{}else if(eo(n)&&nt)try{return nt.call(n)}catch{}else if(to(n)&&rt)try{return rt.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 Ts,Cs,Os,Is,Es,ks,no,ro,oo,so,io,Rs,Ns,Yr,Hr,vs,Ms,Us,Fs,js,Vs,Ls,Ps,Bs,Ln,$s,Pn,Bn,$n,nt,rt,qs,ge=k(()=>{"use strict";Ts="[object Date]",Cs="[object RegExp]",Os="[object Set]",Is="[object Map]",Es="[object Error]",ks="[object URLSearchParams]",no="[object String]",ro="[object Number]",oo="[object Boolean]",so="[object BigInt]",io="[object Symbol]",Rs=typeof Date=="function"?Date.prototype:void 0,Ns=Object.getPrototypeOf(/./),Yr=typeof Set=="function"?Set.prototype:void 0,Hr=typeof Map=="function"?Map.prototype:void 0,vs=typeof URLSearchParams=="function"?URLSearchParams.prototype:void 0,Ms=Object.getPrototypeOf(""),Us=Object.getPrototypeOf(0),Fs=Object.getPrototypeOf(!0),js=typeof BigInt=="function"?BigInt.prototype:void 0,Vs=typeof Symbol=="function"?Symbol.prototype:void 0,Ls=Object.getOwnPropertyDescriptor(Ns,"source")?.get,Ps=Yr?Object.getOwnPropertyDescriptor(Yr,"size")?.get:void 0,Bs=Hr?Object.getOwnPropertyDescriptor(Hr,"size")?.get:void 0,Ln=Rs?.valueOf,$s=vs?.has,Pn=Ms.valueOf,Bn=Us.valueOf,$n=Fs.valueOf,nt=js?.valueOf,rt=Vs?.valueOf,qs=Function.prototype.toString.call(Object)});var qn,Kn,co=k(()=>{"use strict";qn=1000n,Kn=1000000n});function L(n,e){return typeof n!="number"?!1:Number.isNaN(n)?e?.allowNaN??e?.allowNonFiniteNumbers??!1:Number.isFinite(n)?!0:e?.allowNonFiniteNumbers??!1}function fo(n){for(let e=1;e<n.length;e++)if(n[e].length!==3)return!1;return!0}function go(n,e){if(Ks.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(zs,""));let o=t.includes("."),s=t.includes(",");if(o&&s){let a=t.lastIndexOf("."),i=t.lastIndexOf(","),l=i>a,f=l?".":",",u=l?i:a,c=t.slice(0,u).split(f);return c.length>1&&!fo(c)||c[0].replace(mo,"").length>3?null:l?t.replace(po,"").replace(Ut,"."):t.replace(Ut,"")}if(s||o){let a=s?",":".",i=t.split(a);if(i.length>2||a===","&&i.length===2&&i[1].length===3){let l=i[0].replace(mo,"").length;if(l===0){if(a===","||i.length>2)return null}else return l>3?null:fo(i)?t.replace(s?Ut:po,""):null}if(s)return t.replace(Ut,".")}return t}function M(n,{allowNonFiniteNumbers:e=!1,strictNumericString:t=!1,floatScientific:r=!0}={}){if(n==null||typeof n=="symbol")return null;switch(n=ce(n),typeof n){case"number":return L(n,{allowNonFiniteNumbers:e})?n:null;case"boolean":return n?1:0;case"bigint":{let o=Number(n);return L(o,{allowNonFiniteNumbers:e})?o:null}case"object":{if(U(n)){let o=n.getTime();return L(o,{allowNonFiniteNumbers:e})?o:null}return null}case"string":{let o=go(n,t);if(o===null)return null;if(e){let i=o.toLowerCase();if(i==="nan"||i==="-nan"||i==="+nan")return NaN;if(i==="infinity"||i==="+infinity")return 1/0;if(i==="-infinity")return-1/0}if(yo.test(o)&&!r||!ho.test(o))return null;let a=Number(o);return L(a,{allowNonFiniteNumbers:e})?a:null}default:return null}}function _o({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 a=>{if(typeof a=="bigint")return e&&a<0n?`(${s.format(-a)})`:s.format(a);let i=M(a,{allowNonFiniteNumbers:!0});return i===null||Number.isNaN(i)?t:Number.isFinite(i)?e&&i<0?`(${s.format(Math.abs(i))})`:s.format(i):r?t:e&&i===-1/0?`(${s.format(1/0)})`:String(i)}}function zn(n,{floatPrecision:e="Float64",allowNonFiniteNumbers:t=!0,floatScientific:r=!0,strictNumericString:o=!1}={}){let s=M(n,{allowNonFiniteNumbers:t,floatScientific:r,strictNumericString:o});return s===null||(e==="Float32"&&(s=Math.fround(s)),!L(s,{allowNonFiniteNumbers:t}))?null:s}function Ft(n,{range:e="Int32"}={}){if(!L(n)||!Number.isInteger(n))return!1;let t=typeof e=="string"?bo[e]:e;return n>=t.min&&n<=t.max}function _e(n,{range:e="Int32",coerce:t="truncate"}={}){let r=M(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"?bo[e]:e;return pe(r,{min:o.min,max:o.max})}function Ke(n,{range:e="Int64",truncate:t=!1}={}){if(n==null||typeof n=="symbol")return null;n=ce(n);let r=null;if(typeof n=="bigint")r=n;else if(typeof n=="string"){let s=go(n,!1);if(s===null||!ho.test(s))return null;if(yo.test(s)){let a=Number(s);if(!Number.isFinite(a)||!t&&!Number.isInteger(a))return null;r=BigInt(Math.trunc(a))}else{let a=s.indexOf(".");if(a!==-1){if(!t&&/[^0]/.test(s.slice(a+1)))return null;s=s.slice(0,a)}try{r=BigInt(s)}catch{return null}}}else{let s=M(n);if(s===null||!t&&!Number.isInteger(s))return null;r=BigInt(Math.trunc(s))}let o=typeof e=="string"?Ws[e]:e;return pe(r,{min:o.min,max:o.max})}function Gs(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 Wn(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 jt(n,{precision:e,scale:t}={}){let r=M(n);if(r===null)return null;let o=r;if(t!==void 0&&(o=Wn(o,t)),e!==void 0){let a=Gs(e,t??0);a!==null&&(o=pe(o,{min:-a,max:a}))}return o}function pe(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 xo(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 ho,Ks,zs,yo,mo,po,Ut,bo,Ws,ot=k(()=>{"use strict";ge();ho=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,Ks=/0[xobXOB]/,zs=/[\s_]/g,yo=/[eE]/;mo=/^[+-]/,po=/\./g,Ut=/,/g;bo={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}};Ws={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}}});function $(n){if(!ArrayBuffer.isView(n))return!1;if(wo)return wo.call(n)!==void 0;let e=Object.prototype.toString.call(n);return e!=="[object DataView]"&&e.endsWith("Array]")}function E(n){return Array.isArray(n)||$(n)}function st(n){return n==null?[]:Array.isArray(n)?[...n]:$(n)?Array.from(n):[n]}function Ce(n){let e=st(n),t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=String(e[o]);return r}function Vt(n,e,t){let r=n.length,o=e<-r||e>=r;if(o&&!t)throw new oe(`Index ${e} is out of bounds for array of length ${r}`);return o?null:n.at(e)??null}function Q(n,e,{mode:t="every",allowNulls:r=!1,allowEmpty:o=!0}={}){if(!E(n))return!1;let s=n.length;if(s===0)return o?t==="every":!1;let a=n,i;if(typeof e=="function")i=ao(e)?f=>f instanceof e:e;else switch(e){case"null":i=l=>l===null;break;case"undefined":i=l=>l===void 0;break;case"nullish":i=l=>l==null;break;case"any":i=()=>!0;break;case"date":i=U;break;case"object":i=z;break;case"plainObject":i=Ue;break;case"number":i=L;break;default:i=l=>typeof l===e;break}if(r){let l=i;i=f=>f==null||l(f)}if(t==="every"){for(let l=0;l<s;l++)if(!i(a[l]))return!1;return!0}else{for(let l=0;l<s;l++)if(i(a[l]))return!0;return!1}}function it(n,{descending:e=!1,nullsLast:t=!0}={}){if(!E(n))return[];let r=n,o=r.length;if(o===0)return[];if($(n)){let c=r.slice().sort();return e&&c.reverse(),Array.from(c)}let s=[],a=[],i=!0,l=!0,f=!0;for(let c=0;c<o;c++){let m=r[c];if(m==null)a.push(m);else if(s.push(m),f){let p=typeof m;p!=="number"&&(i=!1),p!=="string"&&(l=!1),!i&&!l&&(f=!1)}}return s.length>1&&(i?s.sort(e?(c,m)=>m-c:(c,m)=>c-m):l?s.sort(e?(c,m)=>m.localeCompare(c):(c,m)=>c.localeCompare(m)):s.sort((c,m)=>{let p=typeof c,h=typeof m;if(p!==h){let y=p<h?-1:1;return e?-y:y}return c<m?e?1:-1:c>m?e?-1:1:0})),a.length===0?s:t?s.concat(a):a.concat(s)}function P(n){if(!E(n))return So;let e=n.length;if(e===0)return So;let t=null,r=null,o=null,s=null,a=0,i=0,l=0,f=0,u=0,c=0;for(let p=0;p<e;p++){let h=n[p];if(h==null||typeof h=="number"&&!L(h,{allowNonFiniteNumbers:!0,allowNaN:!1})){i++;continue}(t==null||h<t)&&(t=h,o=p),(r==null||h>r)&&(r=h,s=p);let y=M(h);if(y!==null){let d=l+y;Math.abs(l)>=Math.abs(y)?f+=l-d+y:f+=y-d+l,l=d,a++;let g=y-u;u+=g/a;let _=y-u;c+=g*_}}let m=a>1?c/(a-1):0;return{sum:a>0?l+f:null,count:a,min:t,max:r,minIdx:o,maxIdx:s,mean:a>0?(l+f)/a:null,variance:m,std:Math.sqrt(m),nullCount:i,len:e,hasNulls:i>0,isNumeric:a>0&&a===e-i}}function Oe(n,{strict:e=!1,keySelector:t}={}){let r=Array.from(n),o=new Map;if(e){let a=t??G,i=new Map,l=r.length;for(let u=0;u<l;u++){let c=r[u],m=a(c),p=i.get(m);p===void 0?i.set(m,{val:c,count:1}):p.count++}let f=[];for(let u of i.values())f.push(u.val);for(let u=0;u<l;u++){let c=r[u],m=a(c),p=i.get(m);o.set(c,p.count)}return{values:f,count:f.length,frequencies:o}}let s=r.length;for(let a=0;a<s;a++){let i=r[a];o.set(i,(o.get(i)??0)+1)}return{values:Array.from(o.keys()),count:o.size,frequencies:o}}function Do(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 v("Step size step cannot be zero");let a=n.length;if(a===0?t!==0:t>=a||t<-a){if(!s)throw new oe(`Start offset ${t} is out of bounds for array of length ${a}`);return null}let l=t<0?a+t:t,f=r!==void 0?r<0?a+r:r:e>0?a:-1,u=[];if(e>0)for(let c=l;c<f&&c<a&&!(c>=0&&(u.push(n[c]),o!==void 0&&u.length>=o));c+=e);else for(let c=l;c>f&&c>=0&&!(c<a&&(u.push(n[c]),o!==void 0&&u.length>=o));c+=e);return u}function To(n,e=",",{ignoreNulls:t=!1,nullValue:r="",prefix:o="",suffix:s="",limit:a,truncationMarker:i="...",valueFormatter:l}={}){let f=n.length,u=[],c=a!==void 0?Math.max(0,a):f,m=!1;for(let p=0;p<f;p++){if(u.length>=c){m=!0;break}let h=n[p];h!=null?u.push(l?l(h,p):String(h)):t||u.push(r)}return o+u.join(e)+(m?i:"")+s}function Fe(n,e,t={}){let r=n.length,{mode:o="cumulative",step:s=1,coerce:a=y=>y,condition:i,reverse:l=!1,startIndex:f=l?r-1:0,endIndex:u=l?-1:r}=t,c=l?-1:1,m=f,p=u,h=(y,d)=>{(!i||i(n[y],y,n))&&(n[y]=a(d))};if(o==="constant"){let y=a(e);for(let d=m;l?d>p:d<p;d+=c)h(d,y)}else if(o==="independent")if(typeof s=="function"){let y=0;for(let d=m;l?d>p:d<p;d+=c)h(d,s({index:y,initialValue:e,originalValue:n[d],absoluteIndex:d,targetArray:n})),y++}else for(let y=m;l?y>p:y<p;y+=c)h(y,e+y*s);else{let y=e,d=!0,g=0;for(let _=m;l?_>p:_<p;_+=c)d?(h(_,y),d=!1):(typeof s=="function"?y=s({prev:y,index:g,originalValue:n[_],absoluteIndex:_,targetArray:n}):y=y+s,h(_,y)),g++}}function Co(n){let e=n.length,t=0,r=new Float64Array(e);for(let s=0;s<e;s++){let a=n[s],i=M(a,{allowNonFiniteNumbers:!0});i!==null&&L(i,{allowNonFiniteNumbers:!0,allowNaN:!1})&&(r[t++]=i)}if(t===0)return null;let o=r.subarray(0,t);return o.sort(),o}function ze(n){let e=Co(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 Lt(n,e){if(e<0||e>1)return null;let t=Co(n);if(!t)return null;let r=t.length,o=e*(r-1),s=Math.floor(o),a=Math.ceil(o);return s===a?t[s]:t[s]+(o-s)*(t[a]-t[s])}function Pt(n){if(!E(n)||n.length===0)return null;let e=new Map,t=n.length,r=0,o=[];for(let s=0;s<t;s++){let a=n[s];if(a==null||typeof a=="number"&&!L(a,{allowNonFiniteNumbers:!0,allowNaN:!1}))continue;let i=(e.get(a)??0)+1;e.set(a,i),i>r?(r=i,o=[a]):i===r&&o.push(a)}return o.length===0?null:it(o)}function Oo(n,e){let t=n.length;if(t===0)return[];let r=Math.trunc(e);if(isNaN(r)||r===0)return Array.isArray(n)?n.slice():Array.from(n);let o=Math.abs(r);if(o>=t)return new Array(t).fill(null);let s=new Array(t);if(r>0){s.fill(null,0,r);for(let a=r;a<t;a++){let i=n[a-r];s[a]=i??null}}else{let a=t-o;for(let i=0;i<a;i++){let l=n[i+o];s[i]=l??null}s.fill(null,a,t)}return s}function Gn(n){let e=n.length,t=0,r=0,o=0,s=0,a=0,i=0;for(let m=0;m<e;m++){let p=n[m];if(!p)continue;let h=M(p[0]),y=M(p[1]);if(h===null||y===null)continue;t++;let d=h-r;r+=d/t;let g=h-r,_=y-o;o+=_/t;let T=y-o;i+=d*T,s+=d*g,a+=_*T}if(t<2)return{covariance:null,correlation:null};let l=i/(t-1);if(s===0||a===0)return{covariance:l,correlation:null};let f=Math.sqrt(s*a);if(f===0||Number.isNaN(f))return{covariance:l,correlation:null};let u=i/f,c=Math.max(-1,Math.min(1,u));return{covariance:l,correlation:c}}function Ao(n){let e=n.length,t=new Int32Array(e);for(let s=0;s<e;s++)t[s]=s;t.sort((s,a)=>n[s]-n[a]);let r=new Float64Array(e),o=0;for(;o<e;){let s=o+1;for(;s<e&&n[t[s]]===n[t[o]];)s++;let a=(o+1+s)/2;for(let i=o;i<s;i++)r[t[i]]=a;o=s}return r}function Js(n,e,t){if(t<2)return null;let r=0,o=0,s=0,a=0,i=0;for(let u=0;u<t;u++){let c=n[u],m=e[u],p=c-r;r+=p/(u+1);let h=c-r,y=m-o;o+=y/(u+1);let d=m-o;i+=p*d,s+=p*h,a+=y*d}if(s===0||a===0)return null;let l=Math.sqrt(s*a);if(l===0||Number.isNaN(l))return null;let f=i/l;return Math.max(-1,Math.min(1,f))}function Io(n){let e=n.length,t=new Float64Array(e),r=new Float64Array(e),o=0;for(let i=0;i<e;i++){let l=n[i];if(l){let f=M(l[0]),u=M(l[1]);f!==null&&u!==null&&(t[o]=f,r[o]=u,o++)}}if(o<2)return null;let s=Ao(t.subarray(0,o)),a=Ao(r.subarray(0,o));return Js(s,a,o)}function Eo(n){let e=n.length,t=0,r=0;for(let o=0;o<e;o++){let s=n[o];if(!s)continue;let a=M(s[0]),i=M(s[1]);a===null||i===null||(t+=a*i,r++)}return r>0?t:null}function ko(n){let e=n.length,t=0,r=0,o=0;for(let s=0;s<e;s++){let a=n[s];if(!a)continue;let i=M(a[0]),l=M(a[1]);i===null||l===null||(t+=i*l,r+=l,o++)}return o===0||Math.abs(r)<1e-12?null:t/r}function Ro(n,e){let t=Math.max(0,Math.floor(n||0)),r=Math.max(0,Math.floor(e||0)),o=t*r;if(!Ft(o,{range:"UInt32"}))throw new v(`Cartesian product size (${o} rows) exceeds maximum JavaScript array capacity.`);let s=new Array(o),a=new Array(o),i=0;for(let l=0;l<t;l++)for(let f=0;f<r;f++)s[i]=l,a[i]=f,i++;return{leftIndices:s,rightIndices:a}}function Bt(n,e,t={}){let r=t.side==="right",o=t.getValue,s=0,a=n.length;for(;s<a;){let i=s+a>>>1,l=o?o(i,n[i]):n[i];(r?l<=e:l<e)?s=i+1:a=i}return s}var wo,So,at=k(()=>{"use strict";ge();ot();$t();H();wo=(()=>{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}})();So={sum:null,count:0,min:null,max:null,minIdx:null,maxIdx:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1}});function No(n){let e=ce(n);return typeof e=="string"?e.trim().length===0:!1}function qt(n){let e=ce(n);if(e==null)return"";let t=String(e);return typeof RegExp.escape=="function"?RegExp.escape(t):t.replace(Ys,"\\$&")}function We(n,e=null,t={}){if(n==null)return t.returnStringOnNull?"":null;let{mode:r="both",returnStringOnNull:o=!1,maxScanStart:s=1,maxScanEnd:a=1,maxMatchesStart:i=1,maxMatchesEnd:l=1,trimFirst:f=!1,stringOptions:u}=t,{literal:c=!1,caseInsensitive:m=!1}=u??{},p=(S,b="both")=>b==="start"?S.trimStart():b==="end"?S.trimEnd():S.trim(),h=n;if(f&&e!=null&&(h=p(n,r)),e==null){let S=p(h,r);return o||S!==""?S:null}let y=Te(e)?S=>{try{e.lastIndex=0}catch{}return e.test(S)}:(()=>{let S=new Set(m?e.toLowerCase():e);return b=>S.has(m?b.toLowerCase():b)})(),d=h.length;if(s===1&&i===1&&a===1&&l===1&&!c){let S=0,b=d;if(r==="both"||r==="start")for(;S<d&&y(h[S]);)S++;if(r==="both"||r==="end")for(;b>S&&y(h[b-1]);)b--;let D=S===0&&b===d?h:h.substring(S,b);return o||D!==""?D:null}let _=new Uint8Array(d),T=(S,b,D)=>{if(d===0||D===0)return;let C=S?0:d-1,I=S?d:-1,N=S?1:-1,Y=!1,Z=0,W=0;for(let ie=C;ie!==I;ie+=N)if(y(h[ie])){if(!Y){if(b!==null&&b>=0&&W>=b||D!==null&&D>=0&&Z>=D)break;Y=!0,Z++}_[ie]=1}else if(Y=!1,W++,b!==null&&b>=0&&W>=b)break},A=(S,b,D,C,I)=>{if(d===0||I===0||b===0)return;let N=D?0:d-1,Y=0,Z=0,W=m?h.toLowerCase():h;for(;N>=0&&N<d&&!(I!==null&&I>=0&&Y>=I);){let ie=D?N:N-b+1;if(!D&&ie<0)break;let le=D?W.indexOf(S,ie):W.lastIndexOf(S,ie);if(le===-1)break;let Nt=D?le-N:N-(le+b-1);if(Z+=Nt,C!==null&&C>=0&&Z>=C)break;for(let $e=0;$e<b;$e++)_[le+$e]=1;Y++,N=D?le+b:le-1}};if(r==="both"||r==="start")if(c&&typeof e=="string"){let S=m?e.toLowerCase():e;A(S,e.length,!0,s,i)}else T(!0,s,i);if(r==="both"||r==="end")if(c&&typeof e=="string"){let S=m?e.toLowerCase():e;A(S,e.length,!1,a,l)}else T(!1,a,l);let x="";for(let S=0;S<d;S++)_[S]===0&&(x+=h[S]);return o||x!==""?x:null}function G(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(U(n))return`d:${n.getTime()}`;if($(n)){let o=n.toString();return`u:${n.constructor.name}:${o.length}:${o}`}if(Array.isArray(n)){let o=n.length,s=new Array(o),a={depth:e+1,maxDepth:t};for(let i=0;i<o;i++)s[i]=G(n[i],a);return`a:[${s.join("")}]`}if(vt(n)){let o=Array.from(n),s=o.length,a=new Array(s),i={depth:e+1,maxDepth:t};for(let l=0;l<s;l++)a[l]=G(o[l],i);return a.sort(),`set:[${a.join("")}]`}if(Mt(n)){let o=Array.from(n.keys()),s=o.length,a=new Array(s),i={depth:e+1,maxDepth:t};for(let l=0;l<s;l++){let f=o[l];a[l]=`${G(f,i)}${"\0"}${G(n.get(f),i)}`}return a.sort(),`map:{${a.join("")}}`}if(typeof n=="object"&&typeof n.toJSON=="function"){let o=n.toJSON();if(o!==n)return`j:${G(o,{depth:e+1,maxDepth:t})}`}if(Te(n)){let o=n.toString();return`r:${o.length}:${o}`}if(Ue(n)){let o=Object.keys(n).sort(),s=o.length,a=new Array(s),i={depth:e+1,maxDepth:t};for(let l=0;l<s;l++){let f=o[l];a[l]=`${G(f,i)}${"\0"}${G(n[f],i)}`}return`o:{${a.join("")}}`}if(typeof n=="function"){let o=n.toString();return`f:${o.length}:${o}`}if(typeof n=="string")return`s:${n.length}:${n}`;if(typeof n=="symbol"){let o=n.toString();return`y:${o.length}:${o}`}if(typeof n=="number"||typeof n=="boolean"||typeof n=="bigint")return`${typeof n}:${n}`;let r=String(n);return`${typeof n}:${r.length}:${r}`}function Qs(n){if(n==null)return[];let e=String(n);if(!e)return[];let r=e.normalize("NFC").replace(Hs,"$1$2").match(Xs)||[],o=[];for(let s=0;s<r.length;s++){let a=r[s];Zs.has(a)||o.push(a)}return o}function lt(n,e){let t=Qs(n),r=t.length;if(r===0)return"";let{format:o}=e;if(o==="camel"||o==="pascal"){let s="";for(let a=0;a<r;a++){let i=t[a];s+=a===0&&o==="camel"?i.toLowerCase():i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()}return s}if(o==="kebab"||o==="snake"){let s=o==="kebab"?"-":"_",a=new Array(r);for(let i=0;i<r;i++)a[i]=t[i].toLowerCase();return a.join(s)}return String(n)}var Ys,Hs,Xs,Zs,$t=k(()=>{"use strict";ge();at();Ys=/[-\/\\^$*+?.()|\[\]{}]/g;Hs=/(\p{L})['’](\p{L})/gu,Xs=new RegExp(["\\p{Lu}+s(?!\\p{Ll})","\\p{Lu}+(?=\\p{Lu}\\p{Ll})","\\p{Lu}+\\p{Ll}*","\\p{Ll}+","\\p{N}+","\\p{L}+"].join("|"),"gu"),Zs=new Set(["__proto__","proto","constructor","prototype"])});function ni(n){let e=vo.get(n);return e||(e=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",weekday:"short",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),vo.set(n,e)),e}function ri(n,e){let t=`${n}_${e}`,r=Mo.get(t);return r||(r=new Intl.DateTimeFormat(n,{timeZoneName:"short",timeZone:e}),Mo.set(t,r)),r}function oi(n){let e=Uo.get(n);if(e===void 0){try{Intl.DateTimeFormat(void 0,{timeZone:n}),e=!0}catch{e=!1}Uo.set(n,e)}return e}function he(n){let e=!n||n==="local"?Intl.DateTimeFormat().resolvedOptions().timeZone:n;return oi(e)?e:"UTC"}function ee(n,e=0,t=1,r=0,o=0,s=0,a=0){let i=new Date(0);return i.setUTCFullYear(n,e,t),i.setUTCHours(r,o,s,a),i}function si(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 se(n,e){let t=he(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(),timeZone:"UTC"};let o=ni(t).formatToParts(n),s="0",a="0",i="0",l="0",f="0",u="0",c="0";for(let _=0,T=o.length;_<T;_++){let A=o[_];switch(A.type){case"year":s=A.value;break;case"month":a=A.value;break;case"day":i=A.value;break;case"hour":l=A.value;break;case"minute":f=A.value;break;case"second":u=A.value;break;case"fractionalSecond":c=A.value;break}}let m=parseInt(s,10),p=parseInt(a,10),h=parseInt(i,10),y=parseInt(l,10);y===24&&(y=0);let d=Math.round(parseFloat("0."+c)*1e3)||0,g=si(m,p,h);return{year:m,month:p,day:h,hour:y,minute:parseInt(f,10),second:parseInt(u,10),ms:d,dayOfWeek:g,timeZone:t}}function Ge(n,e){let t=he(e);if(t.toUpperCase()==="UTC")return 0;let r=se(n,"UTC"),o=se(n,t),s=ee(r.year,r.month-1,r.day,r.hour,r.minute,r.second,r.ms).getTime(),a=ee(o.year,o.month-1,o.day,o.hour,o.minute,o.second,o.ms).getTime();return Math.round((a-s)/6e4)}function Fo(n,e){let t=n>=0?"+":"-",r=Math.abs(n),o=String(Math.floor(r/60)).padStart(2,"0"),s=String(r%60).padStart(2,"0");return e==="iso"?`${t}${o}:${s}`:`${t}${o}${s}`}function X(n,e){let t=ce(n);if(t==null)return null;let r=null;if(U(t))r=t;else if(typeof t=="number"||typeof t=="bigint")r=new Date(ii(t));else if(typeof t=="string"){if(No(t))return null;r=new Date(t)}if(!r||!U(r))return null;if(e?.dateOnly){let o=typeof t=="string",s=o&&ti.test(t),a=o&&!s&&!Vo.test(t)?"local":"UTC",i=se(r,a);return ee(i.year,i.month-1,i.day)}return r}function zt(n){let e=ce(n);if(e==null)return null;let t=null;if(typeof e=="string"){let o=e.trim();if(ei.test(o)){let s=Vo.test(o);t=X(`1970-01-01T${o}${s?"":"Z"}`)}}let r=t||X(e);return r?Ve(r,{format:"%H:%M:%S.%ms"}):null}function Lo(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)*qn;case"ns":return BigInt(t)*Kn}}function ii(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/qn):Number(n/Kn)}let e=Math.abs(n);return e<=3e10?n*1e3:e<=3e13?n:e<=3e16?Math.floor(n/1e3):Math.floor(n/1e6)}function Po(n){if(!U(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/100)+1}function Xn(n,e={field:"week"}){if(!U(n))return null;let t=ee(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),r=t.getUTCDay()||7;if(t.setUTCDate(t.getUTCDate()+4-r),e.field==="year")return t.getUTCFullYear();let o=ee(t.getUTCFullYear(),0,1),s=Math.round((t.getTime()-o.getTime())/864e5);return Math.floor(s/7)+1}function Bo(n){if(!U(n))return null;let e=n.getUTCFullYear();return Math.floor((e-1)/1e3)+1}function Wt(n,e,t=1){return U(n)?ee(n.getUTCFullYear(),n.getUTCMonth()+e,t):null}function Zn(n){if(!U(n))return null;let e=ee(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()).getTime(),t=ee(n.getUTCFullYear(),0,1).getTime();return Math.floor((e-t)/864e5)+1}function $o(n){return U(n)?Math.floor(n.getUTCMonth()/3)+1:null}function Qn(n){let e;if(U(n))e=n.getUTCFullYear();else if(L(n))e=n;else return!1;return e%4===0&&e%100!==0||e%400===0}function qo(n){return n.replace(/%[FTRD]/g,e=>li[e]||e)}function ui(n){let e=n.replace(":",""),t=e[0]==="+"?1:-1,r=parseInt(e.slice(1,3),10)||0,o=parseInt(e.slice(3,5),10)||0;return t*(r*60+o)}function Ve(n,{format:e,locale:t,timeZone:r="UTC"}){if(!U(n)||typeof e!="string")return"";let o=t&&t.trim()||Intl.DateTimeFormat().resolvedOptions().locale||"en-US",s=qo(e),a=null,i=()=>a??=se(n,r);return s.replace(Kt,(l,f)=>{if(f==="%")return"%";let u=er[f];return u?u.format(n,o,r,i()):l})}function Ko(n,{format:e,strict:t=!0,defaultTimeZone:r="UTC"}){if(typeof n!="string"||typeof e!="string")return null;let o=qo(e),s=[],a="",i=0;Kt.lastIndex=0;let l;for(;(l=Kt.exec(o))!==null;){let y=o.slice(i,l.index);a+=qt(y);let d=l[1];if(d==="%")a+="\\%";else{let g=er[d];g&&g.parseRegex?(s.push(g),a+=`(${g.parseRegex})`):a+=qt(l[0])}i=Kt.lastIndex}a+=qt(o.slice(i));let f=new RegExp("^\\s*"+a+"\\s*$"),u=n.match(f);if(!u)return t?null:X(n);let c={year:1970,month:1,day:1,hour:0,minute:0,second:0,ms:0,offset:null},m=null,p=!1;for(let y=0;y<s.length;y++){let d=u[y+1],g=s[y],_=g.parseNormalize?g.parseNormalize(d):parseInt(d,10);g.key==="j"&&(p=!0),g.parseField==="ampm"?m=_:g.parseField==="offset"?c.offset=_:g.parseField&&(c[g.parseField]=_)}if(m&&(m==="PM"&&c.hour<12&&(c.hour+=12),m==="AM"&&c.hour===12&&(c.hour=0)),p){let y=Qn(c.year)?366:365;if(c.day<1||c.day>y)return null;let d=ee(c.year,0,1);d.setUTCDate(c.day),c.month=d.getUTCMonth()+1,c.day=d.getUTCDate()}let h=ee(c.year,c.month-1,c.day,c.hour,c.minute,c.second,c.ms);if(!U(h)||h.getUTCFullYear()!==c.year||h.getUTCMonth()+1!==c.month||h.getUTCDate()!==c.day||h.getUTCHours()!==c.hour||h.getUTCMinutes()!==c.minute||h.getUTCSeconds()!==c.second||h.getUTCMilliseconds()!==c.ms)return null;if(c.offset)h=new Date(h.getTime()-ui(c.offset)*6e4);else if(r.toUpperCase()!=="UTC"){let y=he(r),d=Ge(h,y);h=new Date(h.getTime()-d*6e4);let g=Ge(h,y);g!==d&&(h=new Date(h.getTime()-(g-d)*6e4))}return U(h)?h:null}function zo(n,e,{excludeWeekdays:t=[],holidays:r=[],roll:o}={}){if(!Ft(e))throw new oe(`The offset parameter 'n' must be a whole integer. Received: ${e}`);if(t.length===0&&(!r||Array.isArray(r)&&r.length===0||r instanceof Set&&r.size===0)&&!o)return e;if(7-t.length<=0)throw new oe("All weekdays are excluded; cannot offset.");let a=new Set;if(r instanceof Set)for(let c of r){let m=new Date(c);t.includes(m.getUTCDay())||a.add(c)}else if(Array.isArray(r))for(let c=0;c<r.length;c++){let m=X(r[c]);if(!m||t.includes(m.getUTCDay()))continue;let p=ee(m.getUTCFullYear(),m.getUTCMonth(),m.getUTCDate());a.add(p.getTime())}let i=c=>t.includes(c.getUTCDay())?!0:a.has(c.getTime()),l=ee(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),f=new Date(l.getTime());if(o&&i(f)){if(o==="raise")throw new oe("Start date falls on an excluded day or holiday.");let c=o==="forward"?1:-1;for(;i(f);)f.setUTCDate(f.getUTCDate()+c)}if(e!==0){let c=e>0?1:-1,m=0,p=Math.abs(e);for(;m<p;)f.setUTCDate(f.getUTCDate()+c),i(f)||m++}let u=f.getTime()-l.getTime();return Math.round(u/864e5)}function tr(n,e,t){let r=he(e),o=t?.type??"total",s;if(o==="total")s=Ge(n,r);else{let l=se(n,r).year,f=Ge(ee(l,0,1),r),u=Ge(ee(l,6,1),r),c=Math.min(f,u);o==="daylightSavingTime"?s=Ge(n,r)-c:s=c}switch(t?.format??"milliseconds"){case"minutes":return s;case"hours":return s/60;case"iso":return Fo(s,"iso");case"basic":return Fo(s,"basic");default:return s*6e4}}function Wo(n,e={}){if(!U(n))return null;let t=e.excludeWeekdays??[0,6],r=n.getUTCDay();if(t.includes(r))return!1;let o=e.holidays;if(o){if(o instanceof Set){let s=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate());if(o.has(s))return!1}else if(Array.isArray(o)&&o.length>0){let s=new Set;for(let i=0;i<o.length;i++){let l=X(o[i]);l&&s.add(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))}let a=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate());if(s.has(a))return!1}}return!0}function Go(n,e={}){let t=se(n,e?.timeZone??void 0),r=e?.year??t.year,o=e?.month!=null?e.month-1:t.month-1,s=e?.day??t.day,a=e?.hour??t.hour,i=e?.minute??t.minute,l=e?.second??t.second,f=e?.ms??t.ms;return ee(r,o,s,a,i,l,f)}var ei,Vo,ti,vo,Mo,Uo,er,ai,Kt,li,nr=k(()=>{"use strict";$t();H();ge();ot();co();ei=/^\d{2}:\d{2}/,Vo=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i,ti=/^\d{4}-\d{2}-\d{2}$/,vo=new Map;Mo=new Map;Uo=new Map;er={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:he(t)})},a:{key:"a",format:(n,e,t)=>n.toLocaleDateString(e,{weekday:"short",timeZone:he(t)})},B:{key:"B",format:(n,e,t)=>n.toLocaleDateString(e,{month:"long",timeZone:he(t)})},b:{key:"b",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:he(t)})},h:{key:"h",format:(n,e,t)=>n.toLocaleDateString(e,{month:"short",timeZone:he(t)})},j:{key:"j",format:(n,e,t,r)=>String(Zn(ee(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=he(t);if(r.toUpperCase()==="UTC")return"UTC";let o=ri(e,r).formatToParts(n);for(let s=0,a=o.length;s<a;s++)if(o[s].type==="timeZoneName")return o[s].value;return"UTC"}},z:{key:"z",format:(n,e,t)=>tr(n,t,{format:"basic"}),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)}},ai=Object.keys(er).concat("%").sort((n,e)=>e.length-n.length),Kt=new RegExp("%("+ai.join("|")+")","g"),li={"%F":"%Y-%m-%d","%T":"%H:%M:%S","%R":"%H:%M","%D":"%m/%d/%y"}});function Jo(n,{format:e="json",allowPrimitives:t=!1,trimBeforeParse:r=!1,reviver:o,ndjson:{skipInvalidLines:s=!1,maxLines:a,skipLines:i}={},guard:l,onError:f,fallback:u=ct}={}){if(typeof n!="string")return u!==ct?u:n;let c=r?n.trim():n;if(c==="")return u!==ct?u:n;let m;try{if(e==="ndjson"){let p=[],h=0,y=0,d=0;rr.lastIndex=0;let g;for(;;){g=rr.exec(c);let _=g?c.substring(d,g.index):c.substring(d);g&&(d=rr.lastIndex);let T=_.trim();if(T!==""&&(h++,i===void 0||h>i))if(!t&&!ci(T)){if(!s)throw new v("NDJSON line is not wrapped and primitives are disallowed")}else try{if(p.push(JSON.parse(T,o)),y++,a!==void 0&&y>=a)break}catch(A){if(!s)throw A}if(!g)break}if(p.length===0)throw new be("No valid NDJSON lines processed");m=p}else{if(!t&&!fi(c))throw new v("JSON string is not wrapped and primitives are disallowed");m=JSON.parse(c,o)}}catch(p){return f?.(p),u!==ct?u:n}return l&&!l(m)?(f?.(new Error("Parsed value failed guard validation")),u!==ct?u:n):m}function ft(n={}){let e=n.bigintStrategy??"string",t=n.handleCircular?new WeakSet:null,o=Array.isArray(n.replacer)?n.replacer.map(String):null,s=a=>e==="number"&&a<=BigInt(Number.MAX_SAFE_INTEGER)&&a>=BigInt(Number.MIN_SAFE_INTEGER)?Number(a):a.toString();return function(i,l){let f=l;if(typeof n.replacer=="function")f=n.replacer.call(this,i,l);else if(o&&i!==""&&!Array.isArray(this)&&!o.includes(i))return;if(f===void 0)return;let u=f===l&&this!=null?this[i]:f;if(typeof n.onCustom=="function"){let c=n.onCustom.call(this,i,u);if(c!==u||c===void 0&&u!==void 0)return c}if(u!==null&&typeof u!="object"&&typeof u!="bigint")return f;if(t&&u!==null&&typeof u=="object"){if(i===""&&(t=new WeakSet),t.has(u))return n.onCircular?n.onCircular.call(this,i,u):"[Circular]";t.add(u)}return typeof u=="bigint"?n.voidBigIntReplacement?f:n.onBigInt?n.onBigInt(u):s(u):$(u)?n.voidTypedArrayReplacement?f:n.onTypedArray?n.onTypedArray(u):Array.from(u):vt(u)?n.voidSetReplacement?f:n.onSet?n.onSet(u):Array.from(u):Mt(u)?n.voidMapReplacement?f:n.onMap?n.onMap(u):Array.from(u.entries()):Te(u)?n.voidRegExpReplacement?f:n.onRegExp?n.onRegExp(u):u.toString():U(u)?n.voidDateReplacement?f:n.onDate?n.onDate(u):n.formatDate?n.formatDate(u):u.toISOString():uo(u)?n.onError?n.onError(u):{name:u.name,message:u.message,stack:u.stack}:lo(u)?n.onURLSearchParams?n.onURLSearchParams(u):u.toString():f}}var rr,ct,ci,fi,Gt=k(()=>{"use strict";at();ge();H();rr=/\r\n|\n|\r/g,ct=Symbol("no_fallback"),ci=n=>{let e=n.length;if(e<2)return!1;let t=n[0],r=n[e-1];return t==="{"&&r==="}"||t==="["&&r==="]"},fi=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 ne,Le,mt,Ie,Ee,Je,ke,Ye,Jt=k(()=>{"use strict";ne=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}},Le=class extends ne{get isNumeric(){return!0}},mt=class extends Le{get isInteger(){return!0}},Ie=class extends mt{get isSigned(){return!0}},Ee=class extends mt{get isUnsigned(){return!0}},Je=class extends Le{get isFloat(){return!0}},ke=class extends ne{get isTemporal(){return!0}},Ye=class extends ne{get isNested(){return!0}}});var Yt,or,Ht,sr,Xt,ir,Zt,ht,Qt,ar,en,lr,tn,ur,nn,cr,rn,fr,on,yt,pt,sn,dt,an,Xe,ln,mr,un,pr,cn,hr,fn,yr,ye,gt,mn,dr,He,gr,pn,_r,hn,br,_t=k(()=>{"use strict";Jt();q();Yt=class extends Ie{name="Int8";coerce(e){return _e(e,{range:"Int8"})}equals(e){return e.name==="Int8"}allocate(e){return new Int8Array(e)}},or=new Yt,Ht=class extends Ie{name="Int16";coerce(e){return _e(e,{range:"Int16"})}equals(e){return e.name==="Int16"}allocate(e){return new Int16Array(e)}},sr=new Ht,Xt=class extends Ie{name="Int32";coerce(e){return _e(e,{range:"Int32"})}equals(e){return e.name==="Int32"}allocate(e){return new Int32Array(e)}},ir=new Xt,Zt=class extends Ie{name="Int64";coerce(e){return Ke(e,{truncate:!0})}equals(e){return e.name==="Int64"}allocate(e){return new BigInt64Array(e)}},ht=new Zt,Qt=class extends Ee{name="UInt8";coerce(e){return _e(e,{range:"UInt8"})}equals(e){return e.name==="UInt8"}allocate(e){return new Uint8Array(e)}},ar=new Qt,en=class extends Ee{name="UInt16";coerce(e){return _e(e,{range:"UInt16"})}equals(e){return e.name==="UInt16"}allocate(e){return new Uint16Array(e)}},lr=new en,tn=class extends Ee{name="UInt32";coerce(e){return _e(e,{range:"UInt32"})}equals(e){return e.name==="UInt32"}allocate(e){return new Uint32Array(e)}},ur=new tn,nn=class extends Ee{name="UInt64";coerce(e){return Ke(e,{range:"UInt64"})}equals(e){return e.name==="UInt64"}allocate(e){return new BigUint64Array(e)}},cr=new nn,rn=class extends Je{name="Float32";coerce(e){return zn(e,{floatPrecision:"Float32"})}equals(e){return e.name==="Float32"}allocate(e){return new Float32Array(e)}},fr=new rn,on=class extends Je{name="Float64";coerce(e){return zn(e,{floatPrecision:"Float64"})}equals(e){return e.name==="Float64"}allocate(e){return new Float64Array(e)}},yt=new on,pt=class n extends Le{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 jt(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)}},sn=class extends ne{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)}},dt=new sn,an=class extends ne{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)}},Xe=new an,ln=class extends ne{name="Binary";get isBinary(){return!0}coerce(e){return Yo(e)}equals(e){return e.name==="Binary"}allocate(e){return new Array(e).fill(null)}},mr=new ln,un=class extends ne{name="Null";get isNull(){return!0}coerce(e){return null}equals(e){return e.name==="Null"}allocate(e){return new Array(e).fill(null)}},pr=new un,cn=class extends ne{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)}},hr=new cn,fn=class extends ke{name="Date";coerce(e){return X(e,{dateOnly:!0})}equals(e){return e.name==="Date"}allocate(e){return new Array(e).fill(null)}},yr=new fn,ye=class n extends ke{name="Datetime";timeUnit;timeZone;constructor(e="ms",t=null){super(),this.timeUnit=e,this.timeZone=t}coerce(e){return X(e)}equals(e){return e instanceof n&&e.timeUnit===this.timeUnit&&e.timeZone===this.timeZone}allocate(e){return new Array(e).fill(null)}},gt=new ye,mn=class extends ke{name="Time";coerce(e){return zt(e)}equals(e){return e.name==="Time"}allocate(e){return new Array(e).fill(null)}},dr=new mn,He=class n extends ke{name="Duration";timeUnit;constructor(e="ms"){super(),this.timeUnit=e}coerce(e){return M(e)}equals(e){return e instanceof n&&e.timeUnit===this.timeUnit}allocate(e){return new Array(e).fill(null)}},gr=new He,pn=class n extends Ye{constructor(t){super();this.innerType=t}innerType;name="Array";coerce(t){if(t==null)return null;let r=E(t)?Array.from(t):[t],o=r.length,s=new Array(o);for(let a=0;a<o;a++)s[a]=this.innerType.coerce(r[a]);return s}equals(t){return t instanceof n&&this.innerType.equals(t.innerType)}allocate(t){return new Array(t).fill(null)}},_r=n=>new pn(n),hn=class n extends Ye{constructor(t){super();this.fields=t}fields;name="Struct";coerce(t){if(!z(t))return null;let r={},o=Object.keys(this.fields),s=o.length;for(let a=0;a<s;a++){let i=o[a],l=this.fields[i];r[i]=l.coerce(t[i])}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 a=r[s];if(!this.fields[a].equals(t.fields[a]))return!1}return!0}allocate(t){return new Array(t).fill(null)}},br=n=>new hn(n)});var F,Re=k(()=>{"use strict";Jt();_t();_t();Jt();F={Int8:or,Int16:sr,Int32:ir,Int64:ht,UInt8:ar,UInt16:lr,UInt32:ur,UInt64:cr,Float32:fr,Float64:yt,Decimal:(n,e)=>new pt(n,e),Boolean:dt,Utf8:Xe,Binary:mr,Date:yr,Datetime:gt,Time:dr,Duration:gr,Object:hr,Null:pr,Array:_r,Struct:br}});function pi(n={}){let e=n.nullValue!==void 0?n.nullValue:"",t=_o(n.numericFormatOptions),r=n.replacerOptions||{},o=i=>n.datetimeFormat?Ve(i,{format:n.datetimeFormat}):n.dateFormat?Ve(i,{format:n.dateFormat}):n.timeFormat?Ve(i,{format:n.timeFormat}):i.toISOString(),s=ft({formatDate:o,...r}),a=typeof r.onBigInt=="function";return i=>{if(i==null||typeof i=="symbol"||typeof i=="function")return{str:e,isNumeric:!1};if(typeof i=="bigint"&&!a&&!r.voidBigIntReplacement)return{str:t(i),isNumeric:!0};let l=s.call(null,"",i),f=ce(l);return f==null||typeof f=="symbol"||typeof f=="function"?{str:e,isNumeric:!1}:typeof f=="string"?{str:f,isNumeric:!1}:typeof f=="number"||typeof f=="bigint"?{str:t(f),isNumeric:!0}:typeof f=="boolean"?{str:f?"true":"false",isNumeric:!1}:typeof f=="object"?{str:JSON.stringify(f,ft({formatDate:o,...r})),isNumeric:!1}:{str:String(f),isNumeric:!1}}}function dn(n,e,t={}){let{separator:r=",",quoteChar:o='"',includeHeader:s=!0,lineTerminator:a=`
2
+ `,quoteStyle:i="necessary",includeBom:l=!1,onRow:f,...u}=t,c=Object.keys(n),m=c.length,p=[],h=!0,y=pi(u),d=(_,T=!1)=>{let A,x=!1;if(T)A=String(_);else{let b=y(_);A=b.str,x=b.isNumeric}if(i==="never")return A;if(i==="always"){let b=A.split(o).join(o+o);return o+b+o}if(i==="non_numeric"&&!x&&_!=null){let b=A.split(o).join(o+o);return o+b+o}if(A.includes(r)||A.includes(o)||A.includes(`
3
+ `)||A.includes("\r")){let b=A.split(o).join(o+o);return o+b+o}return A},g=_=>{if(h){let T=l?"\uFEFF"+_:_;f?f(T):p.push(T),h=!1}else f?f(a+_):p.push(_)};if(s){let _=new Array(m);for(let T=0;T<m;T++)_[T]=d(c[T],!0);g(_.join(r))}for(let _=0;_<e;_++){let T=new Array(m);for(let A=0;A<m;A++)T[A]=d(n[c[A]][_],!1);g(T.join(r))}return f?l?"\uFEFF":"":p.join(a)}function Ho(n,e={}){let t=e.separator||",",r=e.quoteChar||'"',o=n;o.startsWith("\uFEFF")&&(o=o.substring("\uFEFF".length));let s=[],a=[],i="",l=!1,f=!1,u=!1,c=o.length;for(let m=0;m<c;m++){let p=o[m];if(l)f=!0,u=!1,p===r?m+1<c&&o[m+1]===r?(i+=r,m++):l=!1:i+=p;else if(p===r)f=!0,u=!1,l=!0;else if(p===t)a.push(i),i="",u=!0;else{let h=!1;p==="\r"?(h=!0,m+1<c&&o[m+1]===`
4
+ `&&m++):p===`
5
+ `&&(h=!0),h?(f||a.length>0||i!==""||u)&&(a.push(i),s.push(a),a=[],i="",f=!1,u=!1):(f=!0,u=!1,i+=p)}}return(f||a.length>0||i!==""||u)&&(a.push(i),s.push(a)),s}function Xo(n,e={}){let t=new Set(e.nullValues??["","NA","null","NaN"]),r=n.length,o=!0,s=!0,a=!0,i=!0,l=!1;for(let u=0;u<r;u++){let c=n[u].trim();if(!t.has(c)){if(l=!0,o){let m=c.toLowerCase();m!=="true"&&m!=="false"&&m!=="1"&&m!=="0"&&(o=!1)}if(a&&Ke(c,{truncate:!1})===null&&(a=!1),s&&M(c,{allowNonFiniteNumbers:!0})===null&&(s=!1),i&&X(c)===null&&(i=!1),!o&&!s&&!a&&!i)break}}let f=new Array(r);if(!l||!o&&!s&&!a&&!i){for(let u=0;u<r;u++){let c=n[u];f[u]=t.has(c.trim())?null:c}return{type:Xe,values:f}}if(o){for(let u=0;u<r;u++){let c=n[u].trim();if(t.has(c))f[u]=null;else{let m=c.toLowerCase();f[u]=m==="true"||m==="1"}}return{type:dt,values:f}}if(a){for(let u=0;u<r;u++){let c=n[u].trim();f[u]=t.has(c)?null:Ke(c,{truncate:!1})}return{type:ht,values:f}}if(s){for(let u=0;u<r;u++){let c=n[u].trim();f[u]=t.has(c)?null:M(c,{allowNonFiniteNumbers:!0})}return{type:yt,values:f}}if(i){for(let u=0;u<r;u++){let c=n[u].trim();f[u]=t.has(c)?null:X(c)}return{type:gt,values:f}}return{type:Xe,values:f}}var Zo=k(()=>{"use strict";nr();Gt();ot();Re();ge()});function hi(n){return n==null?!1:typeof n=="string"||$(n)?!0:Array.isArray(n)}function Yo(n){return hi(n)?Object.prototype.toString.call(n)==="[object Uint8Array]"?n:typeof n=="string"?new TextEncoder().encode(n):$(n)?new Uint8Array(n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)):new Uint8Array(n):null}var Qo=k(()=>{"use strict";at()});function es(n,e){return e==="us"?n*1e3:e==="ns"?n*1e6:n}var ts=k(()=>{"use strict"});var q=k(()=>{"use strict";ge();ot();nr();at();$t();Gt();Zo();Qo();ts()});function J(n,e,t,r=""){if(!(n in e))throw new xe(n,`${t} "${n}" does not exist${r}`)}function gn(n,e){let t=Object.keys(n),r=t.length,o=e;for(let s=0;s<r;s++){let a=t[s],i=n[a],l=E(i)?i.length:0;if(o===void 0)o=l;else if(l!==o)throw new te(`Column height mismatch: Column "${a}" has length ${l}, but DataFrame height is ${o}`)}return o===void 0?0:o}function bt(n,e="Value cannot be null or undefined"){if(n==null)throw new v(e);return n}function yi(n,e){if(!n)throw new v(e)}var ns=k(()=>{"use strict";H();q()});var we,K,xe,Ne,oe,te,v,be,H=k(()=>{"use strict";ns();we=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},K=class extends we{},xe=class extends K{constructor(e,t){super(t||`Column "${e}" does not exist in the DataFrame.`)}},Ne=class extends we{},oe=class extends we{},te=class extends we{},v=class extends we{},be=class extends we{}});function di(n,e,t){let r=new Map,o=t.length,s=new Array(o);for(let a=0;a<o;a++){let i=t[a];typeof i=="string"?(J(i,n,"Partition key"," in the DataFrame."),s[a]=n[i]):s[a]=i.evaluate(n,e)}if(o===1){let a=s[0];for(let i=0;i<e;i++){let l=a[i],f=l==null?"":G(l),u=r.get(f);u===void 0&&(u=[],r.set(f,u)),u.push(i)}return r}for(let a=0;a<e;a++){let i=new Array(o);for(let u=0;u<o;u++){let c=s[u][a];i[u]=c==null?"":G(c)}let l=i.join("\0"),f=r.get(l);f===void 0&&(f=[],r.set(l,f)),f.push(a)}return r}function Sr(n,e,t){let r=new Array(t);if(t===0)return r;let o=n._partitionBy||[],s=di(e,t,o),a=n._evaluatePre(n._partitionOpsIndex,e,t);for(let i of s.values()){let l=i.length,f=new Array(l);for(let u=0;u<l;u++)f[u]=a[i[u]];if(n._evaluateWindow){for(let u=0;u<l;u++)r[i[u]]=n._evaluateWindow(f,i,u);continue}if(n._aggFn){let u=n._aggFn(f);for(let c=0;c<l;c++)r[i[c]]=u;continue}for(let u=0;u<l;u++)r[i[u]]=a[i[u]]}return n._evaluatePost(n._partitionOpsIndex,r,e)}function Ar(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 a=n[s];if(z(a)){let i=Object.keys(a);for(let l=0;l<i.length;l++)t.add(i[l])}}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 a=n[s]||{};for(let i=0;i<r.length;i++){let l=r[i],f=a[l];o[l][s]=f===void 0?null:f}}return{columns:o,height:e}}function Dr(n,e){let t=Object.keys(n),r=new Array(e);for(let o=0;o<e;o++){let s={};for(let a=0;a<t.length;a++){let i=t[a],l=n[i][o];s[i]=l===void 0?null:l}r[o]=s}return r}function gi(n,e,t){let r={};for(let o=0;o<t.length;o++){let s=t[o],a=n[s][e];r[s]=a===void 0?null:a}return r}function Ae(n){if(n.length===0)return F.Utf8;let e=!0,t=!0,r=!0,o=!0,s=!0,a=!0,i=!0,l=!0,f=!1,u=!1,c=[];for(let m=0;m<n.length;m++){let p=n[m];if(p!=null){if(u=!0,p instanceof Uint8Array||(i=!1),!E(p)||p instanceof Uint8Array)a=!1;else{let h=p,y=h.length;for(let d=0;d<y;d++)c.push(h[d])}U(p)&&(f=!0),typeof p!="boolean"&&(e=!1),typeof p!="bigint"&&(o=!1),typeof p!="number"?(r=!1,t=!1):Number.isInteger(p)||(t=!1),!U(p)&&(typeof p!="string"||isNaN(Date.parse(p)))&&(s=!1),(!z(p)||p instanceof Uint8Array)&&(l=!1)}}if(!u)return F.Null;if(i)return F.Binary;if(a){let m=Ae(c);return F.Array(m)}if(e)return F.Boolean;if(o)return F.Int64;if(r&&!t)return F.Float64;if(r&&t){let m=!0;for(let p=0;p<n.length;p++){let h=n[p];if(h!=null&&(h<-2147483648||h>2147483647)){m=!1;break}}return m?F.Int32:F.Float64}return s&&f?F.Datetime:l?F.Object:F.Utf8}function Ze(n,e){let t=Object.keys(n),r=t.length,o=e.length,s={};for(let a=0;a<r;a++){let i=t[a],l=n[i],f=$(l)?new l.constructor(o):new Array(o);for(let u=0;u<o;u++)f[u]=l[e[u]];s[i]=f}return s}function Se(n,e,t){let r=e.length;if(r===1)return G(n[e[0]][t]);let o=new Array(r);for(let s=0;s<r;s++)o[s]=G(n[e[s]][t]);return o.join("\0")}function ve(n,e,t){let r=e.allocate?e.allocate(t):new Array(t);if($(r)){let s=r;for(let a=0;a<t;a++){let i=e.coerce(n[a]);if(i==null){let l=new Array(t);for(let f=0;f<a;f++)l[f]=s[f];l[a]=null;for(let f=a+1;f<t;f++)l[f]=e.coerce(n[f]);return l}s[a]=i}}else for(let s=0;s<t;s++)r[s]=e.coerce(n[s]);return r}function Tr(n,e){if(n)if(typeof n=="string"){if(typeof require!="function")throw new be("File writing is not supported in this environment (missing require('fs')).");require("fs").writeFileSync(n,e,"utf8")}else if(z(n)&&typeof n.write=="function")n.write(e);else throw new v("Invalid file argument. Expected a file path string or a writable stream/object with a write method.")}function Cr(n,e,t,r,o,s,a={}){let{how:i="inner",join_nulls:l=!1,maintain_order:f}=a,u=(b,D,C)=>{if(!l){for(let I=0;I<D.length;I++)if(b[D[I]][C]==null)return null}return Se(b,D,C)};if(i==="cross")return Ro(t,r);let c=new Map;for(let b=0;b<r;b++){let D=u(e,s,b);if(D===null)continue;let C=c.get(D);C===void 0&&(C=[],c.set(D,C)),C.push(b)}let m=[],p=[];if(i==="semi"||i==="anti"){for(let b=0;b<t;b++){let D=u(n,o,b),C=D===null?void 0:c.get(D),I=C!==void 0&&C.length>0;(i==="semi"&&I||i==="anti"&&!I)&&(m.push(b),p.push(null))}return{leftIndices:m,rightIndices:p}}let h=i==="outer"||i==="right",y=h?new Set:null;for(let b=0;b<t;b++){let D=u(n,o,b),C=D===null?void 0:c.get(D);if(C===void 0)(i==="left"||i==="outer")&&(m.push(b),p.push(null));else for(let I=0;I<C.length;I++){let N=C[I];h&&y.add(N),m.push(b),p.push(N)}}if(h)for(let b=0;b<r;b++)y.has(b)||(m.push(-1),p.push(b));let d=f||"none";if(d==="none"||d==="left")return{leftIndices:m,rightIndices:p};let g=m.length,_=new Int32Array(g);for(let b=0;b<g;b++)_[b]=b;let T=b=>m[b]===-1?Number.MAX_SAFE_INTEGER:m[b],A=b=>p[b]??Number.MAX_SAFE_INTEGER;d==="right"?_.sort((b,D)=>A(b)-A(D)||b-D):d==="left_right"?_.sort((b,D)=>T(b)-T(D)||A(b)-A(D)||b-D):d==="right_left"&&_.sort((b,D)=>A(b)-A(D)||T(b)-T(D)||b-D);let x=new Array(g),S=new Array(g);for(let b=0;b<g;b++){let D=_[b];x[b]=m[D],S[b]=p[D]}return{leftIndices:x,rightIndices:S}}function Or(n,e,t,r,o,s,a,i,l={}){let f=l.strategy??"backward",u=l.allow_exact_matches??!0,c=l.check_sorted??!0;J(o,n,"Join on key"," in the left DataFrame."),J(s,e,"Join on key"," in the right DataFrame.");let m=n[o],p=e[s];if(c){let x=(S,b,D,C)=>{for(let I=1;I<b;I++){let N=M(S[I-1]),Y=M(S[I]);if(L(N)&&L(Y)&&Y<N)throw new v(`${C} DataFrame key column "${D}" is not sorted in ascending order at row ${I}.`)}};x(m,t,o,"left"),x(p,r,s,"right")}let h=a.length>0,y=new Map;if(h)for(let x=0;x<r;x++){let S=Se(e,i,x),b=y.get(S);b||(b=[],y.set(S,b)),b.push(x)}let d=new Array(r);if(!h)for(let x=0;x<r;x++)d[x]=x;let g=new Array(t),_=new Array(t),T=(x,S)=>{let b=S.length;if(b===0)return null;let D=(W,ie)=>M(p[ie])??NaN;if(f==="backward"){let W=Bt(S,x,{side:u?"right":"left",getValue:D})-1;return W>=0?S[W]:null}if(f==="forward"){let W=Bt(S,x,{side:u?"left":"right",getValue:D});return W<b?S[W]:null}let C=Bt(S,x,{side:"right",getValue:D}),I=C-1,N=C;if(u||(I>=0&&D(I,S[I])===x&&I--,N<b&&D(N,S[N])===x&&N++),I<0)return N<b?S[N]:null;if(N>=b)return I>=0?S[I]:null;let Y=D(I,S[I]),Z=D(N,S[N]);return Math.abs(x-Y)<=Math.abs(x-Z)?S[I]:S[N]},A=l.tolerance!==void 0?M(l.tolerance):null;for(let x=0;x<t;x++){g[x]=x;let S=M(m[x]);if(!L(S)){_[x]=null;continue}let b=h?y.get(Se(n,a,x))||[]:d;if(b.length===0){_[x]=null;continue}let D=T(S,b);if(D!==null&&A!==null){let C=M(p[D]);(!L(A)||!L(C)||Math.abs(S-C)>A)&&(D=null)}_[x]=D}return{leftIndices:g,rightIndices:_}}function _n(n,e,t,r,o,s,a,i,l={}){let[f="",u="_right"]=l.suffixes||[],c=l.coalesce??!0,m=l.how||"inner",p=o.length,h={},y={},d=new Set(a),g=new Set(i),_=(D,C)=>{let I=C!==""?C:"_left",N=`${D}${I}`,Y=1;for(;x.has(N);)N=`${D}${I}_${Y++}`;return x.add(N),N},T=(D,C,I=-1)=>{let N=C.length,Y=new Array(N);for(let Z=0;Z<N;Z++){let W=C[Z];Y[Z]=W!==null&&W!==I?D[W]:null}return Y},A=new Map;for(let D=0;D<a.length;D++)A.has(a[D])||A.set(a[D],i[D]);let x=new Set,S=Object.keys(n),b=Object.keys(e);for(let D=0;D<S.length;D++){let C=S[D];(!(C in e)||d.has(C)||g.has(C))&&x.add(C)}for(let D=0;D<S.length;D++){let C=S[D],I=d.has(C),N;C in e&&!I&&!g.has(C)?f!==""?(x.add(C),N=_(C,f)):x.has(C)?N=_(C,f):(N=C,x.add(C)):N=C;let Y=n[C],Z=I?A.get(C):null,W=Z?e[Z]:null;if(I&&c){let ie=new Array(p);for(let le=0;le<p;le++){let Nt=o[le],$e=s[le],bs=Nt!==-1?Y[Nt]:null,xs=$e!==null&&W?W[$e]:null;ie[le]=bs??xs}h[N]=ie}else h[N]=T(Y,o);t[C]?y[N]=t[C]:Z&&r[Z]&&(y[N]=r[Z])}if(m!=="semi"&&m!=="anti")for(let D=0;D<b.length;D++){let C=b[D];if(c&&g.has(C))continue;let I;x.has(C)?I=_(C,u):(I=C,x.add(C)),h[I]=T(e[C],s),r[C]&&(y[I]=r[C])}return j._createDirect(h,y,p)}var bn=k(()=>{"use strict";Qe();Re();q();H()});function rs(n,e){if(n==null)return null;let t=typeof n=="object"&&U(n)?n.getTime():n;return e(t)}function Ir(n,e,t){if(n==null||e==null)return null;let r=typeof n=="object"&&U(n)?n.getTime():n,o=typeof e=="object"&&U(e)?e.getTime():e;return t(r,o)}function de(n,e,t){return n._isWindow?Sr(n,e,t):n.evaluate(e,t)}var O,V,fe=k(()=>{"use strict";q();ge();bn();O=n=>e=>{let t=e.length,r=new Array(t);for(let o=0;o<t;o++)r[o]=rs(e[o],n);return r},V=(n,e,t)=>(r,o)=>{let s=r.length,a=n._resolve(e,o,s),i=new Array(s);if(E(a))for(let l=0;l<s;l++)i[l]=Ir(r[l],a[l],t);else for(let l=0;l<s;l++)i[l]=Ir(r[l],a,t);return i}});var w,B,ae=k(()=>{"use strict";H();fe();w=(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},B=class n{_ops=[];_outputName="";_isLiteral;_literalValue;_aggFn=null;_castType;_groupingOpsIndex;_partitionOpsIndex;_partitionBy=null;_evaluateWindow;_evaluatePost(e,t,r){let o=this._ops,s=e!==void 0?e:o.length,a=t;for(let i=s;i<o.length;i++)a=o[i](a,r);return a}_evaluatePre(e,t,r){let o=this._getInitialValue(t,r),s=this._ops,a=e!==void 0?e:s.length;for(let i=0;i<a;i++)o=s[i](o,t);return o}_getInitialValue(e,t){let r=this._colName;if(r&&r!=="*"&&!r.startsWith("*")&&!(r in e))throw new xe(r);return(r&&r!=="*"?e[r]:null)||new Array(t).fill(null)}_resolve(e,t,r){return e instanceof n?e._isLiteral&&e._ops.length===1?e._literalValue:de(e,t,r):e}alias(e){let t=w(this);return t._outputName=e,t}cast(e){let t=w(this,O(r=>e.coerce(r)));return t._castType=e,t}debug(e){return w(this,t=>(console.log(`[DEBUG] ${e?e+": ":""}`,t),t))}evaluate(e,t){return this._evaluatePre(void 0,e,t)}}});var xt,Er=k(()=>{"use strict";ae();fe();q();xt=class extends B{abs(){return w(this,O(Math.abs))}acos(){return w(this,O(e=>e<-1||e>1?null:Math.acos(e)))}acosh(){return w(this,O(e=>e<1?null:Math.acosh(e)))}add(e){return w(this,V(this,e,(t,r)=>t+r))}asin(){return w(this,O(e=>e<-1||e>1?null:Math.asin(e)))}asinh(){return w(this,O(Math.asinh))}atan(){return w(this,O(Math.atan))}atan2(e){return w(this,V(this,e,Math.atan2))}atanh(){return w(this,O(e=>e<=-1||e>=1?null:Math.atanh(e)))}cbrt(){return w(this,O(Math.cbrt))}ceil(){return w(this,O(Math.ceil))}clip(e=null,t=null){return w(this,O(r=>pe(r,{min:e,max:t})))}copysign(e){return w(this,V(this,e,(t,r)=>Math.abs(t)*(r>=0?1:-1)))}cos(){return w(this,O(Math.cos))}cosh(){return w(this,O(Math.cosh))}degrees(){return w(this,O(e=>e*(180/Math.PI)))}div(e){return w(this,V(this,e,(t,r)=>r===0?null:t/r))}exp(){return w(this,O(Math.exp))}expm1(){return w(this,O(Math.expm1))}floor(){return w(this,O(Math.floor))}floordiv(e){return w(this,V(this,e,(t,r)=>r===0?null:Math.floor(t/r)))}hypot(e){return w(this,V(this,e,Math.hypot))}log(e=Math.E){return w(this,O(t=>t<=0?null:e===Math.E?Math.log(t):Math.log(t)/Math.log(e)))}log1p(){return w(this,O(e=>e<=-1?null:Math.log1p(e)))}mod(e){return w(this,V(this,e,(t,r)=>r===0?null:t%r))}mul(e){return w(this,V(this,e,(t,r)=>t*r))}negate(){return w(this,O(e=>-e))}pow(e){return w(this,V(this,e,Math.pow))}radians(){return w(this,O(e=>e*(Math.PI/180)))}rand(e,{min:t=0,max:r=1,integer:o=!1}={}){return w(this,s=>{let a=s.length,i=new Float64Array(a),l=e!==void 0?xo(e):Math.random,f=r-t;for(let u=0;u<a;u++){let c=l();i[u]=o?Math.floor(c*(f+1))+t:c*f+t}return i})}round(e=0){return w(this,O(t=>Wn(t,e)))}round_sig_figs(e){return w(this,O(t=>L(t)?Number(t.toPrecision(e)):t))}sign(){return w(this,O(Math.sign))}sin(){return w(this,O(Math.sin))}sinh(){return w(this,O(Math.sinh))}sqrt(){return w(this,O(e=>e<0?null:Math.sqrt(e)))}sub(e){return w(this,V(this,e,(t,r)=>t-r))}tan(){return w(this,O(Math.tan))}tanh(){return w(this,O(Math.tanh))}trunc(){return w(this,O(Math.trunc))}}});var wt,kr=k(()=>{"use strict";ae();fe();q();wt=class extends B{and(e){return w(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),a=E(s),i=new Array(o);for(let l=0;l<o;l++){let f=t[l],u=a?s[l]:s;f===!1||u===!1?i[l]=!1:f==null||u==null?i[l]=null:i[l]=!0}return i})}not(){return w(this,O(e=>!e))}or(e){return w(this,(t,r)=>{let o=t.length,s=this._resolve(e,r,o),a=E(s),i=new Array(o);for(let l=0;l<o;l++){let f=t[l],u=a?s[l]:s;f===!0||u===!0?i[l]=!0:f==null||u==null?i[l]=null:i[l]=!1}return i})}xor(e){return w(this,V(this,e,(t,r)=>!!t!=!!r))}}});function os(n,e,t,r){let o=n.length,s=new Array(o);if(t&&typeof t=="object"&&"evaluate"in t){let a=t.evaluate(e,o);for(let i=0;i<o;i++){let l=n[i];if(l==null)s[i]=null;else{let f=a[i],u=new Set;if(E(f)){let m=f.length;for(let p=0;p<m;p++)u.add(G(f[p]))}else u.add(G(f));let c=u.has(G(l));s[i]=r?!c:c}}}else{let a=E(t)?t:[],i=new Set,l=a.length;for(let f=0;f<l;f++)i.add(G(a[f]));for(let f=0;f<o;f++){let u=n[f];if(u==null)s[f]=null;else{let c=i.has(G(u));s[f]=r?!c:c}}}return s}function ss(n,e){let{frequencies:t}=Oe(n,{strict:!0}),r=n.length,o=new Array(r);for(let s=0;s<r;s++){let a=t.get(n[s])||0;o[s]=e?a>1:a===1}return o}function is(n,e,t){let r=n.length,o=new Array(r);if(E(e))for(let s=0;s<r;s++){let a=n[s],i=e[s];a==null&&i==null?o[s]=!t:a==null||i==null?o[s]=t:o[s]=t?a!==i:a===i}else for(let s=0;s<r;s++){let a=n[s];a==null&&e==null?o[s]=!t:a==null||e==null?o[s]=t:o[s]=t?a!==e:a===e}return o}var St,Rr=k(()=>{"use strict";ae();fe();q();St=class extends B{between(e,t,r="both"){return w(this,(o,s)=>{let a=o.length,i=this._resolve(e,s,a),l=this._resolve(t,s,a),f=new Array(a),u=E(i),c=E(l);for(let m=0;m<a;m++){let p=o[m],h=u?i[m]:i,y=c?l[m]:l;if(p==null||h==null||y==null)f[m]=null;else{let d=r==="both"||r==="left"?p>=h:p>h,g=r==="both"||r==="right"?p<=y:p<y;f[m]=d&&g}}return f})}eq(e){return w(this,V(this,e,(t,r)=>t===r))}eq_missing(e){return w(this,(t,r)=>{let o=this._resolve(e,r,t.length);return is(t,o,!1)})}ge(e){return w(this,V(this,e,(t,r)=>t>=r))}gt(e){return w(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 w(this,(s,a)=>{let i=s.length,l=this._resolve(e,a,i),f=E(l),u=new Array(i);for(let c=0;c<i;c++){let m=s[c],p=f?l[c]:l;if(m==null||p==null)u[c]=null;else if(L(m)&&L(p)){let h=Math.abs(m-p),y=Math.max(r*Math.max(Math.abs(m),Math.abs(p)),t);u[c]=h<=y}else Number.isNaN(m)&&Number.isNaN(p)?u[c]=o:u[c]=m===p}return u})}is_duplicated(){return w(this,e=>ss(e,!0))}is_empty({ignoreNulls:e=!1}={}){return w(this,O(t=>typeof t=="string"?t.length===0:E(t)?e?Q(t,"nullish",{mode:"every"}):t.length===0:null))}is_finite(){return w(this,O(Number.isFinite))}is_in(e){return w(this,(t,r)=>os(t,r,e,!1))}is_infinite(){return w(this,O(e=>e===1/0||e===-1/0))}is_nan(){return w(this,O(Number.isNaN))}is_not_nan(){return w(this,O(e=>!Number.isNaN(e)))}is_not_null(){return w(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 w(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 w(this,e=>ss(e,!1))}le(e){return w(this,V(this,e,(t,r)=>t<=r))}lt(e){return w(this,V(this,e,(t,r)=>t<r))}ne(e){return w(this,V(this,e,(t,r)=>t!==r))}ne_missing(e){return w(this,(t,r)=>{let o=this._resolve(e,r,t.length);return is(t,o,!0)})}not_in(e){return w(this,(t,r)=>os(t,r,e,!0))}}});var xn,At,Nr=k(()=>{"use strict";ae();fe();q();xn=class{constructor(e){this.expr=e}expr;_deriveString(e){return w(this.expr,O(t=>e(String(t))))}_patternGuard(e,t){return e==null?w(this.expr,r=>new Array(r.length).fill(null)):t()}concat(e){return w(this.expr,V(this.expr,e,(t,r)=>String(t)+String(r)))}contains(e){return this._patternGuard(e,()=>this._deriveString(t=>Te(e)?e.test(t):t.includes(e)))}count_matches(e){return this._patternGuard(e,()=>this._deriveString(t=>{if(Te(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)})}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=>We(r,e,{mode:"both",...t}))}strip_chars_end(e,t){return this._deriveString(r=>We(r,e,{mode:"end",...t}))}strip_chars_start(e,t){return this._deriveString(r=>We(r,e,{mode:"start",...t}))}strip_prefix(e){return this._deriveString(t=>We(t,e,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(e){return this._deriveString(t=>We(t,e,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(e){return this._deriveString(t=>Ko(t,e))}to_camelcase(){return this._deriveString(e=>lt(e,{format:"camel"}))}to_date(){return this._deriveString(e=>X(e,{dateOnly:!0}))}to_datetime(){return this._deriveString(X)}to_decimal(e,t){return this._deriveString(r=>jt(r,{precision:e,scale:t}))}to_integer(){return this._deriveString(e=>_e(e))}to_kebabcase(){return this._deriveString(e=>lt(e,{format:"kebab"}))}to_lowercase(){return this.lower()}to_pascalcase(){return this._deriveString(e=>lt(e,{format:"pascal"}))}to_snakecase(){return this._deriveString(e=>lt(e,{format:"snake"}))}to_time(){return this._deriveString(zt)}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"))}},At=class extends B{get str(){return new xn(this)}}});var Dt,vr=k(()=>{"use strict";ae();fe();H();q();Dt=class extends B{_deriveAgg(e){let t=w(this);return t._aggFn=e,t._groupingOpsIndex=this._ops.length,t._partitionOpsIndex=this._ops.length,t}_deriveAggBinary(e,t){return w(this,V(this,e,(r,o)=>[r,o]))._deriveAgg(t)}all(){return this._deriveAgg(e=>Q(e,t=>!!t,{mode:"every"}))}all_null(){return this._deriveAgg(e=>Q(e,"nullish",{mode:"every"}))}any(){return this._deriveAgg(e=>Q(e,t=>!!t,{mode:"some"}))}any_null(){return this._deriveAgg(e=>Q(e,"nullish",{mode:"some"}))}avg(){return this._deriveAgg(e=>P(e).mean)}corr(e){return this._deriveAggBinary(e,t=>Gn(t)?.correlation??null)}count(e={}){return e.includeNulls?this._deriveAgg(t=>t.length):this._deriveAgg(t=>P(t).count)}cov(e){return this._deriveAggBinary(e,t=>Gn(t)?.covariance??null)}dot(e){return this._deriveAggBinary(e,t=>Eo(t))}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=>P(e).max)}mean(){return this.avg()}median(){return this._deriveAgg(e=>ze(e))}min(){return this._deriveAgg(e=>P(e).min)}mode(){return this._deriveAgg(e=>Pt(e))}n_unique(e={}){return this._deriveAgg(t=>Oe(t,e).count)}null_count(){return this._deriveAgg(e=>P(e).nullCount)}quantile(e){if(e<0||e>1)throw new oe("Quantile q must be between 0 and 1");return this._deriveAgg(t=>Lt(t,e))}spearman_corr(e){return this._deriveAggBinary(e,t=>Io(t))}std(){return this._deriveAgg(e=>P(e).std)}sum(){return this._deriveAgg(e=>P(e).sum)}w_avg(e){return this._deriveAggBinary(e,t=>ko(t))}}});function Mr(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 l=n.length;for(let f=0;f<l;f++)n[f]!=null&&s.push(n[f])}t.dense&&(s=Array.from(new Set(s)));let a=it(s);o=new Map;let i=a.length;for(let l=0;l<i;l++){let f=a[l];o.has(f)||o.set(f,l+1)}n[r]=o}return o.get(e)??null}var Tt,Ur=k(()=>{"use strict";ae();q();Tt=class extends B{_partitionBy=this._partitionBy||null;_window(e){let t=w(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 a=Math.max(0,s-e+1),i=s+1,l=r.slice(a,i);return t(l)})}_cum(e,t,r,o){return this._window(function(s,a,i){let l=t,f=!1,u=e?i:0,c=e?s.length-1:i;for(let m=u;m<=c;m++){let p=s[m];p!=null&&(l=r(l,p),f=!0)}return o?o(l,f):l})}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 Mr(e,e[r],{dense:!0})})}lag(e=1,t=null){return this._window(function(r,o,s){let a=t;return s-e>=0&&(a=r[s-e]),a})}lead(e=1,t=null){return this._window(function(r,o,s){let a=t;return s+e<r.length&&(a=r[s+e]),a})}over(e){let t=w(this),r=Array.isArray(e)?e:[e];return t._partitionBy=r,t}rank(){return this._window(function(e,t,r){return Mr(e,e[r])})}rolling_max(e){return this._rolling(e,t=>P(t).max)}rolling_mean(e){return this._rolling(e,t=>P(t).mean)}rolling_median(e){return this._rolling(e,t=>ze(t))}rolling_min(e){return this._rolling(e,t=>P(t).min)}rolling_quantile(e,t){return this._rolling(t,r=>Lt(r,e))}rolling_rank(e){return this._rolling(e,t=>Mr(t,t[t.length-1],{ignoreNulls:!0}))}rolling_std(e){return this._rolling(e,t=>P(t).std)}rolling_sum(e){return this._rolling(e,t=>P(t).sum)}row_number(){let e=this._window(function(t,r,o){return o+1});return e._outputName="row_number",e}}});var wn,Ct,Fr=k(()=>{"use strict";ae();fe();q();De();H();wn=class{constructor(e){this.expr=e}expr;_deriveArray(e){return w(this.expr,O(t=>E(t)?e(t):null))}all(){return this._deriveArray(e=>Q(e,t=>!!t,{mode:"every"}))}any(){return this._deriveArray(e=>Q(e,t=>!!t,{mode:"some"}))}contains(e){return this._deriveArray(t=>t.includes(e))}contains_all(e){return this._deriveArray(t=>Q(e,r=>t.includes(r),{mode:"every"}))}contains_any(e){return this._deriveArray(t=>Q(e,r=>t.includes(r),{mode:"some"}))}count_matches(e,t={}){return this._deriveArray(r=>Oe(r,t).frequencies.get(e)??0)}filter(e){return w(this.expr,(t,r)=>{let o=t.length,s=new Array(o),a=Object.create(r);for(let i=0;i<o;i++){let l=t[i];if(!E(l)){s[i]=null;continue}let f=l.length;a[qe]=l;let u=de(e,a,f),c=[];if(E(u)){let m=Math.min(f,u.length);for(let p=0;p<m;p++)u[p]&&c.push(l[p])}else if(u)for(let m=0;m<f;m++)c.push(l[m]);s[i]=c}return s})}explode({empty_as_null:e=!0,keep_nulls:t=!0}={}){return w(this.expr,r=>{let o=r.length,s=0;for(let f=0;f<o;f++){let u=r[f];if(E(u)){s+=u.length||(e?1:0);continue}if(u!=null){s+=1;continue}t&&(s+=1)}let a=new Array(s),i=new Int32Array(s),l=0;for(let f=0;f<o;f++){let u=r[f];if(E(u)){let c=u.length;if(c>0){for(let m=0;m<c;m++)i[l]=f,a[l++]=u[m];continue}e&&(i[l]=f,a[l++]=null);continue}if(u!=null){i[l]=f,a[l++]=u;continue}t&&(i[l]=f,a[l++]=null)}return a.rowMap=i,a})}first(e=!0){return this.get(0,e)}gather(e,t=!0){return this._deriveArray(r=>{let o=typeof e=="number"?[e]:e,s=o.length,a=new Array(s);for(let i=0;i<s;i++)a[i]=Vt(r,o[i],t);return a})}gather_every(e={}){return this._deriveArray(t=>Do(t,e))}get(e,t=!0){return this._deriveArray(r=>Vt(r,e,t))}join(e=",",t={}){return this._deriveArray(r=>To(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=>P(e).max)}max_index(){return this._deriveArray(e=>P(e).maxIdx)}mean(){return this._deriveArray(e=>P(e).mean)}median(){return this._deriveArray(e=>ze(e))}min(){return this._deriveArray(e=>P(e).min)}min_index(){return this._deriveArray(e=>P(e).minIdx)}mode(){return this._deriveArray(e=>Pt(e))}n_unique(e={}){return this._deriveArray(t=>Oe(t,e).count)}reverse(){return this._deriveArray(e=>e.slice().reverse())}shift(e=1){return this._deriveArray(t=>Oo(t,e))}slice(e,t){return this._deriveArray(r=>r.slice(e,t))}splice(e,t,...r){return this._deriveArray(o=>{let s=[...o];return s.splice(e,t??s.length,...r),s})}sort(e){return this._deriveArray(t=>it(t,e))}std(){return this._deriveArray(e=>P(e).std)}sum(){return this._deriveArray(e=>P(e).sum)}to_struct({upper_bound:e,fields:t}={}){return w(this.expr,r=>{let o=r.length,s=new Array(o),a=0;if(Array.isArray(t))a=t.length;else if(typeof e=="number")a=e;else for(let l=0;l<o;l++){let f=r[l];E(f)&&f.length>a&&(a=f.length)}if(a===0)throw new oe("to_struct cannot be evaluated: struct width is 0. Provide an upper_bound, non-empty fields names, or non-empty lists.");let i=new Array(a);for(let l=0;l<a;l++)typeof t=="function"?i[l]=t(l):i[l]=(Array.isArray(t)?t[l]:null)??`field_${l}`;for(let l=0;l<o;l++){let f=r[l];if(!E(f)){s[l]=null;continue}let u={};for(let c=0;c<a;c++)u[i[c]]=Vt(f,c,!0);s[l]=u}return s})}unique(e={}){return this._deriveArray(t=>Oe(t,e).values)}variance(){return this._deriveArray(e=>P(e).variance)}eval(e){return w(this.expr,(t,r)=>{let o=t.length,s=new Array(o);for(let a=0;a<o;a++){let i=t[a];if(!E(i)){s[a]=null;continue}let l=i.length,f={...r,[qe]:i};if(e._aggFn!=null&&(e._partitionBy==null||e._partitionBy.length===0)){let c=e._groupingOpsIndex!==void 0?e._groupingOpsIndex:e._ops.length,m=e._evaluatePre(c,f,l),p=e._aggFn(Array.from(m));s[a]=e._evaluatePost(c,[p],f)}else s[a]=de(e,f,l)}return s})}},Ct=class extends B{get arr(){return new wn(this)}}});function as(n){return bt(n,"Column reference cannot be null or undefined."),Sn||(Sn=(ue(),Mn(ls)).ColumnExpr),Sn.isColExpr(n)?n:new Sn(n)}var Sn,An,Ot,jr=k(()=>{"use strict";ae();H();Sn=null;An=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 w(this.expr,t=>{let r=t.length,o=new Array(r);for(let s=0;s<r;s++){let a=t[s];o[s]=a!=null&&typeof a=="object"?a[e]:null}return o}).alias(e)}rename_fields(e){return w(this.expr,t=>{let r=t.length,o=new Array(r),s=Object.keys(e),a=s.length;for(let i=0;i<r;i++){let l=t[i];if(l==null||typeof l!="object"){o[i]=null;continue}let f={},u=Object.keys(l),c=u.length;for(let m=0;m<c;m++){let p=u[m];f[p]=l[p]}for(let m=0;m<a;m++){let p=s[m];if(p in f){let h=e[p];f[h]=f[p],delete f[p]}}o[i]=f}return o})}with_fields(e){return w(this.expr,(t,r)=>{let o=t.length,s=new Array(o),a=[];if(Array.isArray(e)){let f=e.length;for(let u=0;u<f;u++){let c=e[u],m=as(c),p=m._outputName||m._colName;if(!p)throw new v("Expressions passed to struct.with_fields must have a name/alias.");a.push({name:p,expr:m})}}else if(e&&typeof e=="object"){let f=Object.keys(e),u=f.length;for(let c=0;c<u;c++){let m=f[c],p=as(e[m]);a.push({name:m,expr:p})}}let i=a.length,l=new Array(i);for(let f=0;f<i;f++)l[f]=a[f].expr.evaluate(r,o);for(let f=0;f<o;f++){let u=t[f];if(u==null||typeof u!="object"){s[f]=null;continue}let c={},m=Object.keys(u),p=m.length;for(let h=0;h<p;h++){let y=m[h];c[y]=u[y]}for(let h=0;h<i;h++)c[a[h].name]=l[h][f];s[f]=c}return s})}unnest(){let e=w(this.expr);return e.isUnnest=!0,e.baseExpr=this.expr,e}},Ot=class extends B{get struct(){return new An(this)}}});var Dn,us=k(()=>{"use strict";ae();q();H();Dn=class extends B{fill_null({value:e=void 0,strategy:t=void 0,limit:r=void 0}={}){return w(this,(o,s)=>{let a=o.length,i=Array.from(o);if(t!==void 0)if(t==="zero"||t==="one"||t==="min"||t==="max"||t==="mean"){let l;t==="zero"?l=0:t==="one"?l=1:l=P(o)[t],Fe(i,l,{mode:"constant",condition:f=>f==null})}else if(t==="forward"||t==="backward"){let l=t==="forward",f=null,u=0;Fe(i,null,{mode:"independent",reverse:!l,step:({originalValue:c})=>c!=null?(f=c,u=0,c):f!==null&&(r===void 0||u<r)?(u++,f):null})}else throw new v(`Unsupported fill_null strategy: "${t}"`);else{let l=this._resolve(e,s,a),f=E(l);Fe(i,null,{mode:"independent",step:({index:u,originalValue:c})=>c??(f?l[u]:l)})}return i})}reverse(){return w(this,e=>e.slice().reverse())}}});var ls={};vn(ls,{ColumnExpr:()=>R,resolveColumnSelectors:()=>Me});function _i(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 bi(n,e,t,r){if(!(n instanceof R)){if(z(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 a=0;a<e.length;a++){let i=e[a];!o.has(i)&&!t.has(i)&&s.push(i)}return s}if(n._targetType||n._targetTypes&&n._targetTypes.length>0){if(!r)throw new Ne("Cannot resolve DataType column selector without DataFrame schema.");let o=[];for(let s=0;s<e.length;s++){let a=e[s];if(t.has(a))continue;let i=r[a];if(i){if(n._targetType)i.matches(n._targetType)&&o.push(a);else if(n._targetTypes){for(let l=0;l<n._targetTypes.length;l++)if(i.matches(n._targetTypes[l])){o.push(a);break}}}}return o}return null}function Me(n,e,t,r,o){let s=[],a=t?new Set(t):new Set;for(let i=0;i<n.length;i++){let l=n[i];if(typeof l=="string"){s.push(new R(l));continue}if(z(l)&&l.isUnnest){let u=[],c=l._colName;if(typeof c=="string"&&r&&r[c]&&r[c].name==="Struct"&&(u=Object.keys(r[c].fields)),u.length===0&&o){let h=Object.keys(o)[0],y=h?o[h].length:0,d=l.baseExpr.evaluate(o,y),g=d.length;for(let _=0;_<g;_++){let T=d[_];if(T!=null&&typeof T=="object"){u=Object.keys(T);break}}}let m=u.length;if(m>0){for(let p=0;p<m;p++){let h=u[p],y=l.baseExpr.struct.field(h);s.push(y)}continue}}let f=bi(l,e,a,r);if(f!==null)for(let u=0;u<f.length;u++){let c=new R(f[u]);c._ops=[...l._ops||[]],c._aggFn=l._aggFn,c._partitionOpsIndex=l._partitionOpsIndex,c._groupingOpsIndex=l._groupingOpsIndex,c._partitionBy=l._partitionBy,l._evaluateWindow&&(c._evaluateWindow=l._evaluateWindow),l._outputName&&l._outputName!=="*"&&(c._outputName=l._outputName),s.push(c)}else s.push(l)}return s}var R,ue=k(()=>{"use strict";ae();Er();Rr();vr();Ur();Nr();kr();Vr();Fr();jr();us();q();Re();H();R=class n extends B{_colName="";_colNames;_excludedCols=[];_targetType;_targetTypes;static isColExpr(e){if(!z(e))return!1;try{return"evaluate"in e&&typeof e.evaluate=="function"}catch{return!1}}static toColExpr(e){return bt(e,"Column reference cannot be null or undefined."),n.isColExpr(e)?e:new n(e)}constructor(e){super(),Array.isArray(e)?e.some(r=>r instanceof ne||typeof r=="function")?this._targetTypes=e:this._colNames=e.map(String):e instanceof ne||typeof e=="function"?this._targetType=e:(this._colName=String(e),this._outputName=this._colName)}};_i(R,[xt,St,Dt,Tt,At,wt,It,Ct,Ot,Dn])});function Pe(n,e={strict:!0}){let t=e,r=new R(Un);return r._literalValue=n,t.name&&(r._outputName=t.name),r._ops.push(o=>{let s=o.length,a=(x,S)=>x===void 0?S:pe(x<0?s+x:x,{min:0,max:s}),i=a(t.startIndex,0),l=a(t.endIndex,s),f=Math.max(0,l-i),u=t.n!==void 0?t.n:f,c=t.strict!==!1;if(c){if(u!==s)throw new te(`Column height mismatch: seq_range length ${u} does not match DataFrame height ${s}`)}else{let x=t.pad??!1,S=t.truncate??!1;if(x&&!S&&u>f)throw new te(`Cannot pad seq_range output: specified length ${u} starting at index ${i} exceeds slice width ${f} (requires truncation).`);if(S&&!x&&u<f)throw new te(`Cannot truncate seq_range output: specified length ${u} starting at index ${i} is less than slice width ${f} (requires padding).`)}let m=s,p=!!t.dtype,h=t.mode||"cumulative",y=t.step!==void 0?t.step:1,d=p?x=>t.dtype.coerce(x):x=>x;if(c){let x=t.dtype?.allocate?t.dtype.allocate(m):new Array(m);return Fe(x,n,{mode:h,step:y,coerce:d,startIndex:0,endIndex:m}),x}let g=Math.min(i+u,l),_=t.padValue!==void 0?t.padValue:null,T=d(_);if(h==="constant"&&i===0&&g===m&&!t.dtype){let x=new Array(m);for(let S=0;S<m;S++)x[S]=n;return x}let A=new Array(m);return A.fill(T),Fe(A,n,{mode:h,step:y,coerce:d,startIndex:i,endIndex:g}),A}),r}var Lr=k(()=>{"use strict";ue();De();H();q()});function Be(n,e){let t=Pe(n,{strict:!0,mode:"constant",dtype:e?.dtype,name:e?.name});return t._isLiteral=!0,t}var Tn=k(()=>{"use strict";Lr()});var cs={};vn(cs,{duration:()=>Cn});function Cn(n={}){let e=n.timeUnit??"ms",t=[],r=[[n.weeks,6048e5],[n.days,864e5],[n.hours,36e5],[n.minutes,6e4],[n.seconds,1e3],[n.milliseconds,1],[n.microseconds,.001],[n.nanoseconds,1e-6]];for(let[s,a]of r)if(s!=null){let i=L(s)?Be(s):R.toColExpr(s);t.push({expr:i,multiplier:a})}if(t.length===0)throw new v("At least one duration component must be specified for $df.duration().");let o=new R(Vn);return o._castType=new He(e),o._ops.push((s,a)=>{let i=s?s.length:0;if(i===0&&a){let c=Object.keys(a)[0];c&&E(a[c])&&(i=a[c].length)}i===0&&(i=1);let l=new Float64Array(i),f=new Uint8Array(i);for(let c=0;c<t.length;c++){let{expr:m,multiplier:p}=t[c],h=de(m,a,i);if(E(h)){let y=h,d=y.length;for(let g=0;g<i;g++){if(f[g]===1)continue;let _=M(g<d?y[g]:d===1?y[0]:null);_!=null?l[g]+=_*p:(f[g]=1,l[g]=0)}}else{let y=M(h);if(y!=null){let d=y*p;for(let g=0;g<i;g++)f[g]!==1&&(l[g]+=d)}else{f.fill(1),l.fill(0);break}}}let u=new Array(i);for(let c=0;c<i;c++)if(f[c]===1)u[c]=null;else{let m=Math.round(l[c]*1e6)/1e6;u[c]=es(m,e)}return u}),o.alias("duration")}var Pr=k(()=>{"use strict";ue();Tn();De();fe();_t();H();q()});var On,It,Vr=k(()=>{"use strict";_t();H();ae();fe();q();On=class{constructor(e){this.expr=e}expr;_colTz(){let e=this.expr._castType;return e instanceof ye?e.timeZone:null}_colTu(){let e=this.expr._castType;return e instanceof ye?e.timeUnit:null}_deriveDate(e){return w(this.expr,O(t=>{let r=X(t);return r?e(r):null}))}cast_time_unit(e){return this.expr.cast(new ye(e,this._colTz()))}century(){return this._deriveDate(Po)}convert_time_zone(e){let t=this._colTz();if(this.expr._castType instanceof ye&&t===null)throw new v('convert_time_zone() requires a timezone-aware Datetime column. Use .dt.replace({ timeZone: "..." }) to assign a timezone first.');return this.expr.cast(new ye(this._colTu()??"ms",e))}date(){return this._deriveDate(e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())))}day(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).day)}days_in_month(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>{let o=se(r,t),s=Wt(ee(o.year,o.month-1,1),1,0);return s?s.getUTCDate():null})}epoch(e="ms"){return this._deriveDate(t=>Lo(t,e))}hour(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).hour)}is_business_day(e={}){return this._deriveDate(t=>Wo(t,e))}is_leap_year(){return this._deriveDate(Qn)}iso_week(){return this._deriveDate(e=>Xn(e,{field:"week"}))}iso_year(){return this._deriveDate(e=>Xn(e,{field:"year"}))}microsecond(){return this.millisecond().mul(1e3)}millennium(){return this._deriveDate(Bo)}millisecond(){return this._deriveDate(e=>e.getUTCMilliseconds())}minute(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).minute)}month(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).month)}month_end(){return this._deriveDate(e=>Wt(e,1,0))}month_start(){return this._deriveDate(e=>Wt(e,0,1))}nanosecond(){return this.millisecond().mul(1e6)}offset_day(e,t={}){let o=t?.excludeWeekdays?.length||t?.holidays||t?.roll?w(this.expr,V(this.expr,e,(a,i)=>{let l=X(a);return l?zo(l,i,t):null})):e,{duration:s}=(Pr(),Mn(cs));return this.expr.add(s({days:o}))}ordinal_day(){return this._deriveDate(Zn)}quarter(){return this._deriveDate($o)}replace(e){return w(this.expr,O(t=>{let r=X(t);return r?Go(r,e):null}))}second(){return this._deriveDate(e=>e.getUTCSeconds())}strftime(e){let t=this._colTz(),r=t&&!e.timeZone?{...e,timeZone:t}:e;return this._deriveDate(o=>Ve(o,r))}time(){return this._deriveDate(e=>e.toISOString().split("T")[1].slice(0,12))}timestamp(e="ms"){return this.epoch(e)}total_days(){return this.expr.div(864e5)}total_hours(){return this.expr.div(36e5)}total_microseconds(){return this.expr.mul(1e3)}total_milliseconds(){return this.expr}total_minutes(){return this.expr.div(6e4)}total_nanoseconds(){return this.expr.mul(1e6)}total_seconds(){return this.expr.div(1e3)}utc_offset(e,t={}){return w(this.expr,O(r=>{let o=X(r);return o?tr(o,e,t):null}))}week(){return this.iso_week()}weekday(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).dayOfWeek||7)}year(e){let t=e||this._colTz()||"UTC";return this._deriveDate(r=>se(r,t).year)}},It=class extends B{get dt(){return new On(this)}}});function et(){return new R("*")}var fs=k(()=>{"use strict";ue()});function Br(n){let e=new R("*");return e._excludedCols=Array.isArray(n)?n:[n],e}var ms=k(()=>{"use strict";ue()});function $r(...n){let e=n.length===1&&Array.isArray(n[0])?n[0]:n,t=new R(Fn);return t._ops.push((r,o)=>{let s=r.length,a=u=>R.isColExpr(u)?u.evaluate(o,s):typeof u=="string"?o[u]||new Array(s).fill(null):u,i=e.length,l=new Array(i);for(let u=0;u<i;u++)l[u]=a(e[u]);let f=new Array(s);for(let u=0;u<s;u++){let c=null;for(let m=0;m<i;m++){let p=l[m],h=E(p)?p[u]:p;if(h!=null){c=h;break}}f[u]=c}return f}),t}var ps=k(()=>{"use strict";ue();q();De()});function qr(n){return new En(n)}var In,En,Et,hs=k(()=>{"use strict";ue();q();In=class{_predicates;_values;constructor(e,t){this._predicates=e,this._values=t}then(e){return new Et(this._predicates,this._values.concat(e))}},En=class{_predicates;constructor(e){this._predicates=[e]}then(e){return new Et(this._predicates,[e])}},Et=class n extends R{_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 a=o.length,i=p=>R.isColExpr(p)?p.evaluate(s,a):typeof p=="string"&&p in s?s[p]:p,l=this._predicates.length,f=new Array(l),u=new Array(l);for(let p=0;p<l;p++)f[p]=i(this._predicates[p]),u[p]=i(this._values[p]);let c=i(this._otherwiseValue),m=new Array(a);for(let p=0;p<a;p++){let h=!1;for(let y=0;y<l;y++)if((E(f[y])?f[y][p]:f[y])===!0){m[p]=E(u[y])?u[y][p]:u[y],h=!0;break}h||(m[p]=E(c)?c[p]:c)}return m})}when(e){return new In(this._predicates.concat(e),this._values)}otherwise(e){return new n(this._predicates,this._values,e)}}});function Kr(n){return R.toColExpr(n).implode()}var ys=k(()=>{"use strict";ue()});function zr(){return new R(qe)}var ds=k(()=>{"use strict";ue();De()});function Wr(n,...e){let t;Array.isArray(n)||n&&typeof n=="object"&&!R.isColExpr(n)?t=n:t=[n,...e];let r=Be({}).struct.with_fields(t);return delete r._isLiteral,delete r._literalValue,r._colName=jn,r.alias("struct")}var gs=k(()=>{"use strict";ue();Tn();De()});var kt=k(()=>{"use strict";De();Jr();ae();Er();kr();Rr();Nr();vr();Ur();Vr();Fr();jr();ue();Tn();fs();ms();ps();hs();ys();Lr();ds();gs();Pr();fe()});var Rt,_s=k(()=>{"use strict";Qe();bn();kt();Rt=class{_groups;_keys;_allKeys;_parentColumns;_parentHeight;_parentSchema;constructor(e,t,r,o,s,a){this._groups=e,this._keys=t,this._allKeys=r,this._parentColumns=o,this._parentHeight=s,this._parentSchema=a}to_dataframe(){let e=this._keys.length,t=new Array(e);for(let i=0;i<e;i++)t[i]=String(this._keys[i]);let r=this._groups.size,o={};for(let i=0;i<t.length;i++)o[t[i]]=new Array(r);let s=0;for(let i of this._groups.values()){if(i.length===0)continue;let l=i[0];for(let f=0;f<t.length;f++){let u=t[f],c=this._parentColumns[u][l];o[u][s]=c===void 0?null:c}s++}let a={};for(let i of t)a[i]=this._parentSchema[i];return j._createDirect(o,a,s)}agg(...e){let t=this._allKeys.length,r=new Array(t);for(let c=0;c<t;c++)r[c]=String(this._allKeys[c]);let o=this._keys.length,s=new Array(o);for(let c=0;c<o;c++)s[c]=String(this._keys[c]);let a=Me(e.flat(),r,s,this._parentSchema,this._parentColumns),i=this._groups.size,l={};for(let c=0;c<s.length;c++)l[s[c]]=new Array(i);let f=0;for(let c of this._groups.values()){if(c.length===0)continue;let m=c[0];for(let p=0;p<s.length;p++){let h=s[p],y=this._parentColumns[h][m];l[h][f]=y===void 0?null:y}f++}for(let c=0;c<a.length;c++){let m=a[c],p=m._outputName||m._colName||"*";if(!m._aggFn)l[p]=m.evaluate(l,i);else{let h=m._evaluatePre(m._groupingOpsIndex,this._parentColumns,this._parentHeight),y=new Array(i),d=0;for(let g of this._groups.values()){if(g.length===0)continue;let _=new Array(g.length);for(let T=0;T<g.length;T++)_[T]=h[g[T]];y[d]=m._aggFn(_),d++}l[p]=m._evaluatePost(m._groupingOpsIndex,y,l)}}let u={};for(let c of s)u[c]=this._parentSchema[c];for(let c of a){let m=c._outputName||c._colName||"*";u[m]=Ae(l[m])}return j._createDirect(l,u,f)}}});function Si(n,e,t){if(n==null)throw new K(`Invalid input to ${e} at index ${t}: item cannot be null or undefined.`);if(n instanceof j)return[n];if(Ue(n))return[new j(n)];if(E(n)){if(Q(n,j,{mode:"every"}))return n;if(Q(n,"plainObject",{mode:"every"}))return[new j(n)];let r=Q(n,j,{mode:"some"});for(let o=0;o<n.length;o++)if(r?!(n[o]instanceof j):!Ue(n[o]))throw new K(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 K(`Invalid input to ${e} at index ${t}: expected DataFrame, row array, or column dictionary.`)}function tt(n,{how:e="vertical",horizontal:t}={}){if(n==null)throw new K("Invalid input to concat: rawItems cannot be null or undefined.");let r=Array.isArray(n)?n:[n],o=[];for(let a=0;a<r.length;a++)o.push(...Si(r[a],"concat",a));let s=t?.strict??!0;if(o.length===0)return j._createDirect({},{},0);if(o.length===1&&e!=="horizontal")return o[0];switch(e){case"vertical":{let a=[];for(let h=0;h<o.length;h++)o[h].height>0&&a.push(o[h]);if(a.length===0)return j._createDirect({},{},0);let i=a[0],l=Object.keys(i._columns);for(let h=0;h<o.length;h++){let y=o[h];if(y.height===0)continue;let d=Object.keys(y._columns);if(l.length!==d.length)throw new K(`[Strict Vertical] Column count mismatch at index ${h}.`);for(let g=0;g<l.length;g++){if(l[g]!==d[g])throw new K(`[Strict Vertical] Schema mismatch at position ${g} in DF ${h}. Expected column "${l[g]}", but found "${d[g]}".`);let _=i.schema[l[g]],T=y.schema[l[g]];if(_&&T&&!_.equals(T))throw new Ne(`[Strict Type Check] Schema type mismatch for column "${l[g]}": expected ${_.name}, found ${T.name}.`)}}let f=0;for(let h of o)f+=h.height;let u={},c=o.length;for(let h=0;h<c;h++)if(o[h].height>0){u=o[h].schema;break}Object.keys(u).length===0&&c>0&&(u=o[0].schema);let m={};for(let h of l){let y=u[h],d=!1;for(let _ of o){let T=_._columns[h];if(!T){d=!0;break}if(!$(T)){for(let A=0;A<T.length;A++)if(T[A]==null){d=!0;break}}if(d)break}let g=y&&y.allocate?y.allocate(f):new Array(f).fill(null);d&&$(g)&&(g=new Array(f).fill(null)),m[h]=g}let p=0;for(let h of o){let y=h.height;if(y!==0){for(let d of l){let g=h._columns[d]||new Array(y).fill(null),_=m[d];if($(_)&&$(g))_.set(g,p);else{let T=_;for(let A=0;A<y;A++)T[p+A]=g[A]}}p+=y}}return j._createDirect(m,u,f)}case"horizontal":{let a=o[0].height;for(let u=1;u<o.length;u++)o[u].height>a&&(a=o[u].height);let i=new Set;for(let u=0;u<o.length;u++){let c=o[u];if(s&&c.height!==a)throw new te(`[Horizontal] Row count mismatch at index ${u}. Expected ${a}, got ${c.height}. Set strict=false to allow padding.`);for(let m of Object.keys(c._columns)){if(i.has(m))throw new K(`[Horizontal] Duplicate column name "${m}" detected. Horizontal concat requires unique names.`);i.add(m)}}let l={},f={};for(let u of o){let c=u.height;Object.assign(f,u.schema);let m=Object.keys(u._columns),p=m.length;for(let h=0;h<p;h++){let y=m[h],d=u._columns[y];if(c===a)l[y]=$(d)?Array.from(d):d;else{let g=new Array(a);for(let _=0;_<c;_++)g[_]=d[_];for(let _=c;_<a;_++)g[_]=null;l[y]=g}}}return j._createDirect(l,f,a)}case"diagonal":{let a=new Set;for(let m of o)for(let p of Object.keys(m._columns))a.add(p);let i=Array.from(a),l=0;for(let m=0;m<o.length;m++)l+=o[m].height;let f={};for(let m of i){let p=null;for(let h of o){let y=h.schema[m];if(y){if(p===null)p=y;else if(!p.equals(y))throw new Ne(`[Strict Type Check] Schema type mismatch for column "${m}": expected ${p.name}, found ${y.name}.`)}}f[m]=p||F.Utf8}let u={};for(let m=0;m<i.length;m++)u[i[m]]=new Array(l).fill(null);let c=0;for(let m=0;m<o.length;m++){let p=o[m],h=p.height;if(h!==0){for(let y=0;y<i.length;y++){let d=i[y],g=u[d],_=p._columns[d];if(_!==void 0)if($(_)&&$(g))g.set(_,c);else{let T=g;for(let A=0;A<h;A++)T[c+A]=_[A]}else{let T=g;for(let A=0;A<h;A++)T[c+A]=null}}c+=h}}return j._createDirect(u,f,l)}}}var Gr=k(()=>{"use strict";Qe();Re();q();H()});var j,Qe=k(()=>{"use strict";kt();_s();Gt();Re();q();H();Gr();bn();j=class n{_columns;_height;_schema={};static _createDirect(e,t,r){gn(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}=Ar(e);this._columns=o,this._height=s,t?this._applySchema(t):this._inferSchema();return}if(z(e)){this._columns=e,this._height=gn(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]=Ae(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],a=this._columns[o];r[o]=a?ve(a,s,this._height):ve(new Array(this._height).fill(null),s,this._height)}this._columns=r}get columns(){return Object.keys(this._columns)}concat(e,t={}){let r=Q(e,n,{mode:"every",allowEmpty:!1})?e:[e];return tt([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 R(e).is_not_null():et().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=R.toColExpr(e),o=r._colNames||[r._colName||r._outputName],s=new Set,a=o.length;for(let u=0;u<a;u++){let c=o[u];if(!c)throw new K("Expression passed to explode must have a column name.");J(c,this._columns,"Explode column"),s.add(c)}let i=Object.keys(this._columns),l=[],f=i.length;for(let u=0;u<f;u++){let c=i[u];l.push(s.has(c)?new R(c).arr.explode(t):new R(c))}return this.select(...l)}fill_null(e={}){return this._height===0?this:this.with_columns(et().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=[],a=[],i=[],l=e.length;for(let d=0;d<l;d++){let g=e[d];typeof g=="function"?a.push(g):i.push(g)}let f=Me(i,r,void 0,this._schema,this._columns),u=f.length;for(let d=0;d<u;d++)s.push(f[d].evaluate(this._columns,t));let c=[],m=0,p=null;if(a.length>0){let d=this._columns;p={};for(let g=0;g<o;g++){let _=r[g],T=d[_];Object.defineProperty(p,_,{get(){let A=T[m];return A===void 0?null:A},enumerable:!0,configurable:!0})}}for(let d=0;d<t;d++){let g=!0;for(let _=0;_<s.length;_++)if(!s[_][d]){g=!1;break}if(g){if(p){m=d;for(let _=0;_<a.length;_++)if(!a[_](p)){g=!1;break}}g&&c.push(d)}}let h=Ze(this._columns,c),y=c.length;return n._createDirect(h,this._schema,y)}get_schema(){return this._schema}groupby(e){let t=st(e),r=new Map,o=this._height,s=Ce(e);for(let i=0;i<s.length;i++)J(s[i],this._columns,"Grouping key");for(let i=0;i<o;i++){let l=Se(this._columns,s,i),f=r.get(l);f===void 0&&r.set(l,f=[]),f.push(i)}let a=Object.keys(this._columns);return new Rt(r,t,a,this._columns,this._height,this._schema)}head(e=10){return this.limit(e,{offset:0,from:"start"})}clone(){let e={};for(let t of Object.keys(this._columns)){let r=this._columns[t];Array.isArray(r)||$(r)?e[t]=r.slice():e[t]=Array.prototype.slice.call(r)}return n._createDirect(e,{...this._schema},this._height)}get height(){return this._height}hstack(e,t={}){return this.concat(e,{how:"horizontal",horizontal:t})}insert_column(e,t,r){let o=R.toColExpr(r).alias(t),s=Object.keys(this._columns),a=s.length,i=[];for(let f=0;f<a;f++){let u=s[f];u!==t&&i.push(u)}let l=Math.max(0,Math.min(e,i.length));return i.splice(l,0,o),this.select(...i)}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 K("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 K("DataFrame.item() requires both row and column to be specified if not empty.");if(e<0||e>=r)throw new te(`Row index ${e} is out of bounds for DataFrame height ${r}.`);let a;if(typeof t=="number"){if(t<0||t>=s)throw new te(`Column index ${t} is out of bounds for DataFrame width ${s}.`);a=o[t]}else if(a=t,this._columns[a]===void 0)throw new xe(a);return this._columns[a][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,a=new Array(r);for(let i=0;i<r;i++)a[i]=o[t[i]];if(e)for(let i=0;i<s;i++){let l={};for(let f=0;f<r;f++)l[t[f]]=a[f][i];yield l}else for(let i=0;i<s;i++){let l=new Array(r);for(let f=0;f<r;f++)l[f]=a[f][i];yield l}}join(e){let{other:t,on:r,leftOn:o,rightOn:s,how:a="inner",suffixes:i=["","_right"],join_nulls:l=!1,coalesce:f=!0,maintain_order:u="none"}=e;if(a==="cross"&&(r!==void 0||o!==void 0||s!==void 0))throw new v('Cannot specify "on", "leftOn", or "rightOn" when how is "cross". Cross joins produce a keyless Cartesian product.');if(r!==void 0&&(o!==void 0||s!==void 0))throw new v('Cannot specify both "on" and "leftOn"/"rightOn" in join(). Use either "on" or both "leftOn" and "rightOn".');if(o!==void 0&&s===void 0||o===void 0&&s!==void 0)throw new v('join() requires both "leftOn" and "rightOn" when specifying heterogeneous join keys.');if(a!=="cross"&&r===void 0&&o===void 0&&s===void 0)throw new v('join() requires either "on" or both "leftOn" and "rightOn" parameters.');let c=[],m=[];if(o!==void 0&&s!==void 0){if(c=Ce(o),m=Ce(s),c.length===0||m.length===0)throw new v('join() requires non-empty key arrays in "leftOn" and "rightOn".');if(c.length!==m.length)throw new v(`join() "leftOn" length (${c.length}) must match "rightOn" length (${m.length}).`)}else if(r!==void 0&&(c=Ce(r),m=c,c.length===0))throw new v('join() requires at least one key column in "on".');for(let g=0;g<c.length;g++)J(c[g],this._columns,"Join key"," in the left DataFrame."),J(m[g],t._columns,"Join key"," in the right DataFrame.");let h={...e,how:a,suffixes:i,join_nulls:l,coalesce:f,maintain_order:typeof u=="boolean"?u?"left":"none":u??"none"},{leftIndices:y,rightIndices:d}=Cr(this._columns,t._columns,this._height,t._height,c,m,h);return _n(this._columns,t._columns,this._schema,t._schema,y,d,c,m,{suffixes:i,coalesce:f,how:a})}join_asof(e){let{other:t,on:r,leftOn:o,rightOn:s,by:a,leftBy:i,rightBy:l,strategy:f="backward",tolerance:u,allow_exact_matches:c=!0,suffixes:m=["","_right"],coalesce:p=!0,check_sorted:h=!0}=e;if(!t||!(t instanceof n))throw new v("join_asof() requires a valid right DataFrame in the 'other' parameter.");let y=String(o??r??""),d=String(s??r??"");if(!y||!d)throw new v('join_asof() requires join key specified via "on", or "leftOn" and "rightOn".');let g=C=>C?Array.isArray(C)?C.map(String):[String(C)]:[],_=g(i??a),T=g(l??a);if(_.length!==T.length)throw new v('join_asof() "by" (or "leftBy" / "rightBy") key lists must have equal lengths.');for(let C=0;C<_.length;C++)J(_[C],this._columns,"Partition key"," in the left DataFrame."),J(T[C],t._columns,"Partition key"," in the right DataFrame.");let A={...e,strategy:f,tolerance:u,allow_exact_matches:c,suffixes:m,coalesce:p,check_sorted:h},{leftIndices:x,rightIndices:S}=Or(this._columns,t._columns,this._height,t._height,y,d,_,T,A),b=[y,..._],D=[d,...T];return _n(this._columns,t._columns,this._schema,t._schema,x,S,b,D,{suffixes:m,coalesce:p,how:"left"})}limit(e,{offset:t=0,from:r="start"}={}){let o=this._height,s=pe(Math.floor(e),{min:0,max:o}),a=pe(Math.floor(t),{min:0,max:o}),i=a,l=Math.min(a+s,o);r==="end"&&(l=o-a,i=Math.max(l-s,0));let f=l-i,u={},c=Object.keys(this._columns),m=c.length;for(let p=0;p<m;p++){let h=c[p];u[h]=this._columns[h].slice(i,l)}return n._createDirect(u,this._schema,f)}pivot(e){if(this._height===0)return n._createDirect({},{},0);let{index:t,columns:r,values:o}=e,s=Ce(t),a=s.length;for(let x=0;x<a;x++)J(s[x],this._columns,"Pivot index key");let i=String(r),l=String(o);J(i,this._columns,"Pivot column key"),J(l,this._columns,"Pivot values key");let f=new Map,u=[],c=new Set,m=this._height,p=this._columns[i],h=this._columns[l];for(let x=0;x<m;x++){let S=Se(this._columns,s,x);c.add(String(p[x])),f.get(S)===void 0&&(f.set(S,f.size),u.push(x))}let y=f.size,d={},g={};for(let x=0;x<a;x++){let S=s[x];d[S]=this._columns[S],this._schema[S]&&(g[S]=this._schema[S])}let _=Ze(d,u),T=Array.from(c),A=this._schema[l]||F.Utf8;for(let x=0;x<T.length;x++){let S=T[x];_[S]=new Array(y).fill(null),g[S]=A}for(let x=0;x<m;x++){let S=Se(this._columns,s,x),b=f.get(S),D=String(p[x]);_[D][b]=h[x]}return n._createDirect(_,g,y)}rename(e){let t=e||{},r={},o={},s=Object.keys(this._columns);for(let i of s){let l=t[i]||i;r[l]=this._columns[i],o[l]=this._schema[i]}if(Object.keys(r).length<s.length)throw new K("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=Me(t,r,void 0,this._schema,this._columns),s=o.length;if(s===0)return n._createDirect({},{},this._height);let a={},i={},l=new Array(s),f=new Array(s),u=new Set,c=null;for(let h=0;h<s;h++){let y=o[h],d=y._outputName||y._colName||"*";if(u.has(d))throw new K(`Duplicate column selection: "${d}" is selected multiple times.`);u.add(d);let g=de(y,this._columns,this._height);l[h]=g,f[h]=d;let _=g&&g.rowMap;if(_)if(c){let T=_.length;if(T!==c.length)throw new te(`Mismatched explode heights: Column "${d}" has length ${T}, but another exploded column has length ${c.length}`);for(let A=0;A<T;A++)if(_[A]!==c[A])throw new te(`Mismatched explode heights: Column "${d}" has mismatched row lengths compared to another exploded column.`)}else c=_}let m=c?c.length:this._height,p=s>0;for(let h=0;h<s;h++){let y=o[h],d=y._aggFn!=null&&(y._partitionBy==null||y._partitionBy.length===0),g=!!y._isLiteral;if(!d&&!g){p=!1;break}}for(let h=0;h<s;h++){let y=f[h],d=l[h],g=d,_=g&&g.rowMap,T=E(d)?d.length:0,A=c&&!_?this._height:m;if(T!==A)throw new te(`Column height mismatch: Column "${y}" has length ${T}, but expected ${A}`);if(c&&!_){let x=c.length;if($(d)){let S=new g.constructor(x);for(let b=0;b<x;b++)S[b]=g[c[b]];d=S}else{let S=new Array(x);for(let b=0;b<x;b++)S[b]=g[c[b]];d=S}}l[h]=d}p&&(m=1);for(let h=0;h<s;h++){let y=o[h],d=f[h],g=l[h],_=y._colName||d,T=y instanceof R&&y._ops.length===0&&!y._isWindow&&!y._aggFn,x=y._castType||T&&this._schema[_]||Ae(g);i[d]=x,a[d]=ve(g,x,m)}return n._createDirect(a,i,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),a=Math.max(s-o,0);return this.limit(a,{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,a=st(t);for(let h=0;h<a.length;h++){let y=R.toColExpr(a[h]);y._colName&&J(y._colName,this._columns,"Sort key")}let i=Array.isArray(r)?r:new Array(a.length).fill(r),l=a.length,f=new Array(l);for(let h=0;h<l;h++){let y=a[h],d=i[h]?-1:1,g=s&&typeof y=="string"?s[y]:null,_=R.toColExpr(y).evaluate(this._columns,this._height);f[h]={values:_,isDesc:d,customComp:g}}let u=f.length,c=o?1:-1,m=new Array(this._height);for(let h=0;h<this._height;h++)m[h]=h;m.sort((h,y)=>{for(let d=0;d<u;d++){let{values:g,isDesc:_,customComp:T}=f[d],A=g[h],x=g[y];if(T){let b=T(A,x);if(b!==0)return b*_;continue}if(A==null||x==null){if(A===x)continue;return(A==null?1:-1)*c}if(A===x)continue;return(A<x?-1:1)*_}return 0});let p=Ze(this._columns,m);return n._createDirect(p,this._schema,this._height)}tail(e=10){return this.limit(e,{offset:0,from:"end"})}to_dict(){return{...this._columns}}to_dicts(){return Dr(this._columns,this._height)}to_array(e){if(this._height===0)return[];if(e==null)return new Array(this._height).fill(null);let r=R.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 u={},c={};return e&&(u[t]=ve([],F.Utf8,0),c[t]=F.Utf8),n._createDirect(u,c,0)}let o=this.columns;typeof r=="string"&&(J(r,this._columns,"column_names"),o=o.filter(u=>u!==r));let s=[];if(typeof r=="string"){let u=this._columns[r];s=new Array(this._height);for(let c=0;c<this._height;c++){let m=u[c];if(m==null)throw new K(`Transpose column_names column "${r}" contains null/undefined at index ${c}`);s[c]=String(m)}}else if(r!=null&&typeof r!="string"&&Symbol.iterator in Object(r)){let u=Array.from(r);if(u.length!==this._height)throw new K(`column_names length (${u.length}) must match the height of the DataFrame (${this._height})`);s=new Array(this._height);for(let c=0;c<this._height;c++)s[c]=String(u[c])}else{s=new Array(this._height);for(let u=0;u<this._height;u++)s[u]=`column_${u}`}let a=new Set;e&&a.add(t);for(let u=0;u<s.length;u++){let c=s[u];if(a.has(c))throw new K(`Duplicate column name in transposed DataFrame: "${c}"`);a.add(c)}let i=o.length,l={},f={};e&&(l[t]=ve(o,F.Utf8,i),f[t]=F.Utf8);for(let u=0;u<this._height;u++){let c=s[u],m=new Array(i);for(let h=0;h<i;h++)m[h]=this._columns[o[h]][u];let p=Ae(m);l[c]=ve(m,p,i),f[c]=p}return n._createDirect(l,f,i)}unique(e){if(this._height===0)return n._createDirect({},this._schema,0);let t=st(e),r=t.length===0?Object.keys(this._columns):t.map(String);for(let f of r)J(f,this._columns,"Unique column key");let o=new Set,s=[],a=this._height;for(let f=0;f<a;f++){let u=Se(this._columns,r,f);o.has(u)||(o.add(u),s.push(f))}let i=Ze(this._columns,s),l=s.length;return n._createDirect(i,this._schema,l)}unpivot(e){let{idVars:t,valueVars:r,varName:o="variable",valueName:s="value"}=e,a=Ce(t),i=Ce(r),l=a.length,f=i.length;for(let h of a)J(h,this._columns,"Unpivot id variable key");for(let h of i)J(h,this._columns,"Unpivot value variable key");let u=this._height*f,c={};for(let h=0;h<l;h++)c[a[h]]=new Array(u);c[o]=new Array(u),c[s]=new Array(u);let m=0;for(let h=0;h<this._height;h++)for(let y=0;y<f;y++){let d=i[y];for(let g=0;g<l;g++){let _=a[g];c[_][m]=this._columns[_][h]}c[o][m]=d,c[s][m]=this._columns[d][h],m++}let p={};for(let h of a)p[h]=this._schema[h];return p[o]=F.Utf8,p[s]=Ae(c[s]),n._createDirect(c,p,u)}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 R(o));else if(R.isColExpr(o))r.push(o);else if(z(o)){let s=Object.keys(o),a=s.length;for(let i=0;i<a;i++){let l=s[i],f=o[l];if(R.isColExpr(f))r.push(f.alias(l));else{let u=new R(l);u.evaluate=(c,m)=>new Array(m).fill(f),r.push(u)}}}return r}with_columns(...e){if(e.length===0)return this;let t=this._normalizeArgs(e),r=Object.keys(this._columns),o=Me(t,r,void 0,this._schema,this._columns),s=o.length;if(s===0)return this;let a=new Map;for(let f=0;f<s;f++){let u=o[f],c=u._outputName||u._colName||"*";a.set(c,u)}let i=[],l=r.length;for(let f=0;f<l;f++){let u=r[f];i.push(a.get(u)||new R(u)),a.delete(u)}for(let f of a.values())i.push(f);return this.select(...i)}with_row_index(e="index",t=0){let r=Pe(t,{mode:"independent",dtype:F.UInt32,step:1}),o=this.insert_column(0,e,r);return o._schema[e]=F.UInt32,o}write_json(e,{format:t="json",replacerOptions:r}={}){if(t!=="json"&&t!=="ndjson")throw new v(`Unsupported JSON format: "${t}". Expected "json" or "ndjson".`);let o=r?.replacer===null?void 0:ft(r),s;if(t==="ndjson"){let a=this.to_dicts(),i=a.length,l=new Array(i);for(let f=0;f<i;f++)l[f]=JSON.stringify(a[f],o);s=l.join(`
6
+ `)}else s=JSON.stringify(this.to_dicts(),o);return Tr(e,s),s}write_csv(e,t={}){if(e){if(typeof e=="string"){if(typeof require!="function")throw new be("File writing is not supported in this environment (missing require('fs')).");let r=require("fs"),o=r.openSync(e,"w");try{dn(this._columns,this._height,{...t,onRow:s=>{r.writeSync(o,s,null,"utf8")}})}finally{r.closeSync(o)}}else if(z(e)&&typeof e.write=="function")dn(this._columns,this._height,{...t,onRow:r=>{e.write(r)}});else throw new v("Invalid file argument. Expected a file path string or a writable stream/object with a write method.");return""}return dn(this._columns,this._height,t)}}});var Ti={};vn(Ti,{$df:()=>Di,ALL_COLUMNS_MARKER:()=>re,AggregationExpr:()=>Dt,ArithmeticExpr:()=>xt,Array:()=>_r,ArrayDataType:()=>_r,ArrayExpr:()=>Ct,ArrayExprNamespace:()=>wn,ArrayType:()=>pn,Binary:()=>mr,BinaryType:()=>ln,Boolean:()=>dt,BooleanDataType:()=>dt,BooleanType:()=>sn,COALESCE_MARKER:()=>Fn,ColumnExpr:()=>R,ColumnNotFoundError:()=>xe,ComparisonExpr:()=>St,ComputeError:()=>oe,DFScriptError:()=>we,DURATION_MARKER:()=>Vn,DataFrame:()=>j,DataFrameError:()=>K,DataType:()=>ne,DataTypeRegistry:()=>F,Date:()=>yr,DateDataType:()=>yr,DateTimeExprNamespace:()=>On,DateType:()=>fn,Datetime:()=>gt,DatetimeType:()=>ye,DecimalType:()=>pt,Duration:()=>gr,DurationType:()=>He,ELEMENT_MARKER:()=>qe,ExprBase:()=>B,Float32:()=>fr,Float32Type:()=>rn,Float64:()=>yt,Float64Type:()=>on,FloatDataType:()=>Je,GroupedData:()=>Rt,IOStreamError:()=>be,Int16:()=>sr,Int16Type:()=>Ht,Int32:()=>ir,Int32Type:()=>Xt,Int64:()=>ht,Int64Type:()=>Zt,Int8:()=>or,Int8Type:()=>Yt,IntegerDataType:()=>mt,InvalidArgumentError:()=>v,LITERAL_MARKER:()=>Un,LogicalExpr:()=>wt,NestedDataType:()=>Ye,Null:()=>pr,NullType:()=>un,NumericDataType:()=>Le,Object:()=>hr,ObjectDataType:()=>hr,ObjectType:()=>cn,STRUCT_MARKER:()=>jn,SchemaError:()=>Ne,ShapeError:()=>te,SignedIntegerType:()=>Ie,StringExpr:()=>At,StringExprNamespace:()=>xn,Struct:()=>br,StructExpr:()=>Ot,StructExprNamespace:()=>An,StructType:()=>hn,TemporalDataType:()=>ke,TemporalExpr:()=>It,Time:()=>dr,TimeType:()=>mn,UInt16:()=>lr,UInt16Type:()=>en,UInt32:()=>ur,UInt32Type:()=>tn,UInt64:()=>cr,UInt64Type:()=>nn,UInt8:()=>ar,UInt8Type:()=>Qt,UnsignedIntegerType:()=>Ee,Utf8:()=>Xe,Utf8Type:()=>an,When:()=>En,WhenThen:()=>Et,WhenThenChain:()=>In,WindowExpr:()=>Tt,alignAsofIndices:()=>Or,alignKeyIndices:()=>Cr,all:()=>et,assertColumnExists:()=>J,assertHeight:()=>gn,assertNotNull:()=>bt,assertValidArgument:()=>yi,coalesce:()=>$r,coerceColumn:()=>ve,columnsToRows:()=>Dr,computeRowHash:()=>Se,concat:()=>tt,derive:()=>w,duration:()=>Cn,element:()=>zr,evalBinaryOp:()=>Ir,evalUnaryOp:()=>rs,evaluateExpression:()=>de,exclude:()=>Br,gatherColumnsByIndices:()=>Ze,getRowFromColumns:()=>gi,implode:()=>Kr,inferColumnType:()=>Ae,kleeneBinary:()=>V,kleeneUnary:()=>O,lit:()=>Be,materializeJoinedDataFrame:()=>_n,read_csv:()=>Rn,read_json:()=>kn,resolveColumnSelectors:()=>Me,resolveWindowExpr:()=>Sr,rowsToColumns:()=>Ar,seq_range:()=>Pe,struct:()=>Wr,when:()=>qr,writeStringToFileOrStream:()=>Tr});module.exports=Mn(Ti);kt();kt();Re();Gr();Qe();q();H();function kn(n,{format:e="json",trimBeforeParse:t=!0,schema:r,...o}={}){let s=Jo(n,{format:e,trimBeforeParse:t,...o});if(s===n)throw new K(`Invalid JSON input: must be a valid, non-empty JSON ${e} string.`);let a=Array.isArray(s)?s:z(s)?[s]:[];return new j(a,r)}Qe();q();function Rn(n,e={}){let{hasHeader:t=!0,schema:r,inferSchema:o=!0}=e,s=Ho(n,e);if(s.length===0)return new j({});let a,i;t?(a=s[0],i=s.slice(1)):(a=s[0].map((m,p)=>`column_${p}`),i=s);let l=a.length,f=i.length,u={};for(let m=0;m<l;m++){let p=a[m],h=new Array(f);for(let y=0;y<f;y++)h[y]=i[y][m]!==void 0?i[y][m]:"";u[p]=h}let c={};for(let m=0;m<l;m++){let p=a[m],h=u[p];if(r&&r[p])c[p]=h;else if(o){let{values:y}=Xo(h,e);c[p]=y}else c[p]=h}return new j(c,r)}function Ai(n,e){return new j(n,e)}var Di={data:Ai,col:n=>new R(n),all:et,exclude:Br,coalesce:$r,concat:tt,read_json:kn,read_csv:Rn,lit:Be,when:qr,implode:Kr,seq_range:Pe,element:zr,struct:Wr,duration:Cn,DataType:F};Re();H();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,DURATION_MARKER,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateDataType,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ELEMENT_MARKER,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,IOStreamError,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,InvalidArgumentError,LITERAL_MARKER,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectDataType,ObjectType,STRUCT_MARKER,SchemaError,ShapeError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructExpr,StructExprNamespace,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,alignAsofIndices,alignKeyIndices,all,assertColumnExists,assertHeight,assertNotNull,assertValidArgument,coalesce,coerceColumn,columnsToRows,computeRowHash,concat,derive,duration,element,evalBinaryOp,evalUnaryOp,evaluateExpression,exclude,gatherColumnsByIndices,getRowFromColumns,implode,inferColumnType,kleeneBinary,kleeneUnary,lit,materializeJoinedDataFrame,read_csv,read_json,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,seq_range,struct,when,writeStringToFileOrStream});