UNPKG

@zestlet/fp

Version:

TypeScript functional programming library with over 70% AI-generated code, featuring precise type inference and currying support

2 lines (1 loc) 35.3 kB
"use strict";function curry(h){return function g(...x){return x.length>=h.length?h.apply(null,x):function(...b){return g.apply(null,[...x,...b])}}}function t$v(h,g,x){return h<0||h>=x.length?[...x]:[...x.slice(0,h),g(x[h]),...x.slice(h+1)]}const adjust=curry(t$v);function o$m(h,g){return g.every(h)}const all=curry(o$m);function t$u(h,g){return h.every(x=>x(g))}const allPass=curry(t$u);function t$t(h){return()=>h}const always=t$t;function n$f(h,g){return g.some(h)}const any=curry(n$f);function o$l(h,g){return h.length===0?!1:h.some(x=>x(g))}const anyPass=curry(o$l);function o$k(h,g){return h.flatMap(x=>g.map(b=>x(b)))}const ap=curry(o$k);function u$6(h,g){if(h<=0||h>g.length)return[];const x=[];for(let b=0;b<=g.length-h;b++)x.push(g.slice(b,b+h));return x}const aperture=curry(u$6);function t$s(h,g){return[...g,h]}const append=curry(t$s);function i$i(h,g){if(g.length===0)return[[],[]];const x=Math.min(h.length,g.length),b=[[],[]];for(let $=0;$<x;$++)b[h[$]?0:1].push(g[$]);return b}const bifurcate=curry(i$i);function T$j(h,g){if(h<=0)return[];const x=[];for(let b=0;b<g.length;b+=h)x.push(g.slice(b,b+h));return x}const chunk=curry(T$j);function e$c(h){return{...h}}const clone=e$c;function o$j(h){return(...g)=>!h(...g)}const complement=o$j;function compose(...h){return h.length===0?g=>g:h.length===1?h[0]:g=>{let x=g;for(let b=h.length-1;b>=0;b--)x=h[b](x);return x}}function composeAsync(...h){return h.length===0?async g=>g:h.length===1?h[0]:async g=>{let x=g;for(let b=h.length-1;b>=0;b--)x=await h[b](x);return x}}function o$i(h,g){return[...g,...h]}const concat=curry(o$i);function l$4(h,g){return g.reduce((x,b,$,A)=>{const j=h(b,$,A);return x[j]=(x[j]||0)+1,x},{})}const countBy=curry(l$4);function o$h(h,g){return g.filter(x=>!h.includes(x))}const difference=curry(o$h);function o$g(h,g,x){const b=new Set(g.map(h));return x.filter(($,A,j)=>!b.has(h($,A,j)))}const differenceBy=curry(o$g);function T$i(h,g,x){return x.filter(b=>!g.some($=>h(b,$)))}const differenceWith=curry(T$i);function a$b(h,g){return h<0?[...g]:g.slice(h)}const drop=curry(a$b);function a$a(h,g){return h<=0?[...g]:g.slice(0,-h)}const dropLast=curry(a$a);function i$h(h,g){let x=g.length-1;for(;x>=0&&h(g[x],x,g);)x--;return g.slice(0,x+1)}const dropLastWhile=curry(i$h);function o$f(h){return h.length===0?[]:h.reduce((g,x,b)=>((b===0||x!==h[b-1])&&g.push(x),g),[])}const dropRepeats=o$f;function T$h(h,g){return g.length===0?[]:g.reduce((x,b,$)=>(($===0||!h(b,g[$-1]))&&x.push(b),x),[])}const dropRepeatsWith=curry(T$h);function a$9(h,g){let x=0;for(;x<g.length&&h(g[x],x,g);)x++;return g.slice(x)}const dropWhile=curry(a$9);function False(...h){return!1}function t$r(h,g){return g.filter(h)}const filter=curry(t$r);function flow(...h){if(h.length===0)return b=>b;if(h.length===1)return h[0];const[g,...x]=h;return function(...b){return x.reduce(($,A)=>A($),g(...b))}}function n$e(h,g){return g.find(h)}const find=curry(n$e);function n$d(h,g){return g.findIndex(h)}const findIndex=curry(n$d);function n$c(h,g){return g.findLast(h)}const findLast=curry(n$c);function a$8(h,g){for(let x=g.length-1;x>=0;x--)if(h(g[x],x,g))return x;return-1}const findLastIndex=curry(a$8);function n$b(h){return h[0]}const first=n$b;function l$3(h,g){return g.flatMap(h)}const flatMap=curry(l$3);function n$a(h,g){return g.flat(h)}const flatten=curry(n$a);function t$q(h){return(g,x,...b)=>h(x,g,...b)}const flip=t$q;function o$e(h,g){return g.forEach(h),g}const forEach=curry(o$e);function e$b(h){return Object.fromEntries(h)}const fromPairs=e$b;function l$2(h,g){return g.reduce((x,b,$)=>{const A=h(b,$,g);return x[A]||(x[A]=[]),x[A].push(b),x},{})}const groupBy=curry(l$2);function isNil(h){return h==null}function isNotNil(h){return h!=null}function isArray(h){return Array.isArray(h)}function isString(h){return typeof h=="string"}function isNumber(h){return typeof h=="number"&&!isNaN$1(h)}function isBoolean(h){return typeof h=="boolean"}function isFunction(h){return typeof h=="function"}function isObject(h){return h!==null&&typeof h=="object"}function isPlainObject(h){if(!isObject(h))return!1;const g=Object.getPrototypeOf(h);return g===null||g===Object.prototype}function isRegExp(h){return Object.prototype.toString.call(h)==="[object RegExp]"}function isDate(h){return Object.prototype.toString.call(h)==="[object Date]"}function isError(h){return Object.prototype.toString.call(h)==="[object Error]"}function isSymbol(h){return typeof h=="symbol"}function isNull(h){return h===null}function isUndefined(h){return h===void 0}function isNaN$1(h){return Number.isNaN(h)}function isFinite(h){return Number.isFinite(h)}function isPositive(h){return isNumber(h)&&h>0}function isNegative(h){return isNumber(h)&&h<0}function isZero(h){return isNumber(h)&&h===0}function isEven(h){return isNumber(h)&&h%2===0}function isOdd(h){return isNumber(h)&&h%2!==0}function isInfinity(h){return h===1/0}function isNegativeInfinity(h){return h===-1/0}function isPositiveInfinity(h){return h===1/0}function isEmptyString(h){return isString(h)&&h.length===0}function isEmptyArray(h){return isArray(h)&&h.length===0}function isEmptyObject(h){return isPlainObject(h)&&Object.keys(h).length===0}function isBlankString(h){return isString(h)&&h.trim().length===0}function isNumeric(h){return isString(h)&&/^-?\d*\.?\d+$/.test(h)}function isAlpha(h){return isString(h)&&/^[a-zA-Z]+$/.test(h)}function isAlphanumeric(h){return isString(h)&&/^[a-zA-Z0-9]+$/.test(h)}function isEmail(h){return isString(h)&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)}function isUrl(h){try{return isString(h)&&!!new URL(h)}catch{return!1}}function isArrayOf(h,g){return isArray(h)&&h.every(g)}function isArrayLike(h){return h!==null&&typeof h=="object"&&"length"in h&&typeof h.length=="number"&&h.length>=0}function isPromise(h){return h!==null&&typeof h=="object"&&"then"in h&&typeof h.then=="function"}function isIterable(h){return h!==null&&typeof h[Symbol.iterator]=="function"}function isGenerator(h){return isFunction(h)&&h.constructor.name==="GeneratorFunction"}function isAsyncGenerator(h){return isFunction(h)&&h.constructor.name==="AsyncGeneratorFunction"}function isGenericGenerator(h){return isFunction(h)&&(h.constructor.name==="GeneratorFunction"||h.constructor.name==="AsyncGeneratorFunction")}function isInteger(h){return isNumber(h)&&Number.isInteger(h)}function isFloat(h){return isNumber(h)&&!Number.isInteger(h)}function t$p(h,g){return Object.prototype.hasOwnProperty.call(g,h)}const has=curry(t$p);function n$9(h,...g){return h}const identity=n$9;function o$d(h,g){return g.includes(h)}const includes=curry(o$d);function c$3(h,g){return g.reduce((x,b,$)=>{const A=h(b,$,g);return x[A]=b,x},{})}const indexBy=curry(c$3);function o$c(h,g){return g.indexOf(h)}const indexOf=curry(o$c);function n$8(h){return h.slice(0,-1)}const init=n$8;function T$g(h,g,x){const b=h<0?Math.max(x.length+h,0):Math.min(h,x.length);return[...x.slice(0,b),g,...x.slice(b)]}const insert=curry(T$g);function i$g(h,g){return g.length===0?[]:g.length===1?[...g[0]]:g.reduce((x,b,$)=>$===0?[b]:[...x,h,b],[]).flat()}const intercalate=curry(i$g);function i$f(h,g){const x=[],b=Math.max(g.length,h.length);for(let $=0;$<b;$++)$<g.length&&x.push(g[$]),$<h.length&&x.push(h[$]);return x}const interleave=curry(i$f);function e$a(h,g){return g.filter(x=>h.includes(x))}const intersection=curry(e$a);function o$b(h,g,x){const b=new Set(g.map(h));return x.filter(($,A,j)=>b.has(h($,A,j)))}const intersectionBy=curry(o$b);function T$f(h,g,x){return x.filter(b=>g.some($=>h(b,$)))}const intersectionWith=curry(T$f);function T$e(h,g){const x=g.length;if(x<=1)return[...g];const b=[];for(let $=0;$<x-1;$++)b.push(g[$]),b.push(h);return b.push(g[x-1]),b}const intersperse=curry(T$e);function o$a(h){const g={};for(const x in h)if(Object.prototype.hasOwnProperty.call(h,x)){const b=h[x];g[b]=x}return g}const invert=o$a;function s$4(h){const g={};for(const x in h)if(Object.prototype.hasOwnProperty.call(h,x)){const b=h[x];g[b]?g[b].push(x):g[b]=[x]}return g}const invertMulti=curry(s$4),ObjectTags={Number:"[object Number]",String:"[object String]",Boolean:"[object Boolean]",Symbol:"[object Symbol]",BigInt:"[object BigInt]",Date:"[object Date]",RegExp:"[object RegExp]",Array:"[object Array]",Map:"[object Map]",Set:"[object Set]",ArrayBuffer:"[object ArrayBuffer]",SharedArrayBuffer:"[object SharedArrayBuffer]",DataView:"[object DataView]",Int8Array:"[object Int8Array]",Uint8Array:"[object Uint8Array]",Uint8ClampedArray:"[object Uint8ClampedArray]",Int16Array:"[object Int16Array]",Uint16Array:"[object Uint16Array]",Int32Array:"[object Int32Array]",Uint32Array:"[object Uint32Array]",Float32Array:"[object Float32Array]",Float64Array:"[object Float64Array]",BigInt64Array:"[object BigInt64Array]",BigUint64Array:"[object BigUint64Array]",Error:"[object Error]",Function:"[object Function]",AsyncFunction:"[object AsyncFunction]",GeneratorFunction:"[object GeneratorFunction]",Arguments:"[object Arguments]",Object:"[object Object]"},getObjectTag=h=>Object.prototype.toString.call(h);function y$6(h,g,x=new WeakMap){if(h===g)return!0;if(h==null||g==null)return!1;const b=getObjectTag(h),$=getObjectTag(g);if(b!==$)return!1;const A=typeof h,j=typeof g;if(A==="object"){if(x.has(h))return x.get(h)===g;x.set(h,g)}let O,B,k=!0;switch(b){case ObjectTags.Number:O=A==="object"?h.valueOf():h,B=j==="object"?g.valueOf():g,k=isNaN$1(O)&&isNaN$1(B)?!0:O===B;break;case ObjectTags.Boolean:case ObjectTags.String:case ObjectTags.Symbol:case ObjectTags.BigInt:O=A==="object"?h.valueOf():h,B=j==="object"?g.valueOf():g,k=O===B;break;case ObjectTags.Date:O=h.getTime(),B=g.getTime(),k=isNaN$1(O)&&isNaN$1(B)?!0:O===B;break;case ObjectTags.RegExp:k=h.source===g.source&&h.flags===g.flags;break;case ObjectTags.Array:case ObjectTags.Arguments:if(h.length!==g.length)k=!1;else for(let w=0;w<h.length;w++)if(!y$6(h[w],g[w],x)){k=!1;break}break;case ObjectTags.Map:if(h.size!==g.size)k=!1;else for(const[w,I]of h){let v=!1;for(const P of g.keys())if(y$6(w,P,x)){if(!y$6(I,g.get(P),x)){k=!1;break}v=!0;break}if(!v||!k){k=!1;break}}break;case ObjectTags.Set:if(h.size!==g.size)k=!1;else{const w=new Set;for(const I of g.values())w.add(I);for(const I of h){let v=!1;for(const P of w)if(y$6(I,P,x)){w.delete(P),v=!0;break}if(!v){k=!1;break}}}break;case ObjectTags.ArrayBuffer:case ObjectTags.SharedArrayBuffer:if(h.byteLength!==g.byteLength)k=!1;else{const w=new Uint8Array(h),I=new Uint8Array(g);for(let v=0;v<h.byteLength;v++)if(w[v]!==I[v]){k=!1;break}}break;case ObjectTags.DataView:h.byteLength!==g.byteLength||h.byteOffset!==g.byteOffset?k=!1:y$6(h.buffer,g.buffer,x)||(k=!1);break;case ObjectTags.Int8Array:case ObjectTags.Uint8Array:case ObjectTags.Uint8ClampedArray:case ObjectTags.Int16Array:case ObjectTags.Uint16Array:case ObjectTags.Int32Array:case ObjectTags.Uint32Array:case ObjectTags.Float32Array:case ObjectTags.Float64Array:case ObjectTags.BigInt64Array:case ObjectTags.BigUint64Array:if(h.length!==g.length)k=!1;else for(let w=0;w<h.length;w++)if(h[w]!==g[w]){k=!1;break}break;case ObjectTags.Object:const E=Object.keys(h),W=Object.keys(g);if(E.length!==W.length)k=!1;else for(const w of E)if(!Object.prototype.hasOwnProperty.call(g,w)||!y$6(h[w],g[w],x)){k=!1;break}if(k){const w=Object.getOwnPropertySymbols(h),I=Object.getOwnPropertySymbols(g);if(w.length!==I.length)k=!1;else for(const v of w)if(!Object.prototype.hasOwnProperty.call(g,v)||!y$6(h[v],g[v],x)){k=!1;break}}break;case ObjectTags.Error:k=h.name===g.name&&h.message===g.message;break;case ObjectTags.Function:case ObjectTags.AsyncFunction:case ObjectTags.GeneratorFunction:k=!1;break;default:k=!1;break}return!k&&A==="object"&&x.delete(h),k}const isEqual=(h,g)=>y$6(h,g);function a$7(h,g){return g.join(h)}const join=curry(a$7);function o$9(h,g){return h.map(x=>x(g))}const juxt=curry(o$9);function n$7(h){return Object.keys(h)}const keys=n$7;function n$6(h){return h[h.length-1]}const last=n$6;function t$o(h,g){return g.lastIndexOf(h)}const lastIndexOf=curry(t$o);function t$n(h){return h.length}const length=t$n,mergeDeleteSymbol=Symbol("mergeDelete");function f$1(h,g){return(x,b)=>{const $=new WeakMap;function A(j,O,B=[],k=null,E=null){if(O==null||j==null)return O;if(isObject(O)&&$.has(O))return $.get(O);if(isObject(j)&&$.has(j))return $.get(j);const W=B.length>0?B[B.length-1]:"";if(h&&B.length>0){const w=h(O,j,{key:W,path:B,source:E||O,target:k||j});if(w===mergeDeleteSymbol)return mergeDeleteSymbol;if(w!==void 0)return w}if(isPlainObject(j)&&isPlainObject(O)){const w=g?{...j}:j;return g?($.set(O,w),$.set(j,w)):$.set(O,j),Object.keys(O).forEach(I=>{const v=j[I],P=O[I],M=[...B,I],N=A(v,P,M,j,O);N===mergeDeleteSymbol?(g||I in w)&&delete w[I]:w[I]=N}),w}return O}return!isObject(x)||!isObject(b)?b:A(x,b)}}function mergeWithImpl(h,g,x){return f$1(h,!0)(g,x)}function mergeWithInPlaceImpl(h,g,x){return f$1(h,!1)(g,x)}const mergeWith=curry(mergeWithImpl),mergeWithInPlace=curry(mergeWithInPlaceImpl);function c$2(h,g){return mergeWithImpl(null,h,g)}function s$3(h,g){return mergeWithImpl(null,g,h)}function S(h,g){return mergeWithInPlaceImpl(null,h,g)}function T$d(h,g){return mergeWithInPlaceImpl(null,g,h)}const mergeLeft=curry(c$2),mergeRight=curry(s$3),mergeLeftInPlace=curry(S),mergeRightInPlace=curry(T$d);function l$1(h,g){return g.map(h)}const map=curry(l$1);function c$1(h,g){const x={};return Object.entries(g).forEach(([b,$])=>{const[A,j]=h([b,$],g);x[A]=j}),x}const mapEntries=curry(c$1);function y$5(h,g){const x={};return Object.entries(g).forEach(([b,$])=>{const A=h(b,$,g);x[A]=$}),x}const mapKeys=curry(y$5);function c(h,g){const x={};return Object.entries(g).forEach(([b,$])=>{x[b]=h($,b,g)}),x}const mapValues=curry(c);function e$9(h){if(h.length!==0)return Math.max(...h)}const max=e$9;function i$e(h,g){if(g.length!==0)return g.reduce((x,b)=>h(b)>h(x)?b:x)}const maxBy=curry(i$e);function e$8(h,g){if(g.length!==0)return g.reduce((x,b)=>h(b,x)>0?b:x)}const maxWith=curry(e$8);function t$m(h){return h.length===0?0:h.reduce((g,x)=>g+x,0)/h.length}const mean=t$m;function i$d(h){if(h.length===0)return NaN;const g=[...h].sort((b,$)=>b-$),x=Math.floor(g.length/2);return g.length%2===0?(g[x-1]+g[x])/2:g[x]}const median=i$d;function e$7(h){if(h.length!==0)return Math.min(...h)}const min=e$7;function i$c(h,g){if(g.length!==0)return g.reduce((x,b)=>h(b)<h(x)?b:x)}const minBy=curry(i$c);function e$6(h,g){if(g.length!==0)return g.reduce((x,b)=>h(b,x)<0?b:x)}const minWith=curry(e$6);function u$5(h,g,x){if(x.length===0)return[];const b=h<0?x.length+h:h,$=g<0?x.length+g:g;if(b<0||b>=x.length||$<0||$>=x.length)return[...x];const A=x[b],j=[...x];return j.splice(b,1),j.splice($,0,A),j}const move=curry(u$5);function n$5(h,g){return!g.some(h)}const none=curry(n$5);function e$5(h,g){return h.length===0?!0:!h.some(x=>x(g,0,[g]))}const nonePass=curry(e$5);function noop(...h){}function a$6(h,g){return g.at(h)}const nth=curry(a$6);function s$2(h,g){const x=new Set(h);return Object.entries(g).reduce((b,[$,A])=>(x.has($)||(b[$]=A),b),{})}const omit=curry(s$2);function y$4(h,g){const x={};for(const b in g)if(Object.prototype.hasOwnProperty.call(g,b)){const $=g[b];h($,b,g)||(x[b]=$)}return x}const omitBy=curry(y$4);function i$b(h,g){const x=new Set(h);return g.filter((b,$)=>!x.has($))}const omitIndices=curry(i$b);function once(h){let g=!1,x;return(...b)=>(g||(g=!0,x=h(...b)),x)}function T$c(h,g,x){if(h<=x.length)return[...x];const b=h-x.length;return[...Array(b).fill(g),...x]}const padLeft=curry(T$c);function T$b(h,g,x){if(h<=x.length)return[...x];const b=h-x.length;return[...x,...Array(b).fill(g)]}const padRight=curry(T$b);function i$a(h){if(h.length<2)return[];const g=[];for(let x=0;x<h.length-1;x+=2)x+1<h.length&&g.push([h[x],h[x+1]]);return g}const pairwise=i$a;function T$a(h,g){const x={},b={...g};for(const $ of h)$ in g&&(x[$]=g[$],delete b[$]);return[x,b]}const partition=curry(T$a);function T$9(h,g){const x=[],b=[];for(let $=0;$<g.length;$++)h(g[$],$,g)?x.push(g[$]):b.push(g[$]);return[x,b]}const splitBy=curry(T$9);function a$5(h,g){if(h.length===0)return g;if(g==null)return;const[x,...b]=h;if(!(x in g))return;const $=g[x];return a$5(b,$)}const path=curry(a$5);function n$4(h,g,x){if(g.length===0)return x;if(x==null)return h;const[b,...$]=g;if(!(b in x))return h;const A=x[b];return n$4(h,$,A)}const pathOr=curry(n$4);function t$l(h,g){return h.reduce((x,b)=>(b in g&&(x[b]=g[b]),x),{})}const pick=curry(t$l);function T$8(h,g){const x={};for(const b in g)if(Object.prototype.hasOwnProperty.call(g,b)){const $=g[b];h($,b)&&(x[b]=$)}return x}const pickBy=curry(T$8);function i$9(h,g){return h.map(x=>g[x]).filter((x,b)=>h[b]>=0&&h[b]<g.length)}const pickIndices=curry(i$9);function pipe(h,...g){return g.length===0?h:g.reduce((x,b)=>b(x),h)}function flowAsync(...h){return h.length===0?async g=>g:h.length===1?h[0]:async g=>{let x=g;for(const b of h)x=await b(x);return x}}function t$k(h,g){return g.map(x=>x[h])}const pluck=curry(t$k);function a$4(h,g){return[h,...g]}const prepend=curry(a$4);function t$j(h){return h.length===0?NaN:h.reduce((g,x)=>g*x,1)}const product=t$j;function t$i(h,g){return g[h]}const prop=curry(t$i);function t$h(h,g,x){return x==null?h:Object.prototype.hasOwnProperty.call(x,g)?x[g]:h}const propOr=curry(t$h);function l(h,g,x){if(x===0)return[];const b=Math.max(Math.ceil((g-h)/x),0),$=Array(b);let A=0,j=h;if(x>0)for(;j<g;)$[A++]=j,j+=x;else for(;j>g;)$[A++]=j,j+=x;return $}const range=curry(l);function n$3(h,g,x){return x.reduce(h,g)}const reduce=curry(n$3);function i$8(h,g,x){let b=g;for(let $=x.length-1;$>=0;$--)b=h(b,x[$],$,x);return b}const reduceRight=curry(i$8);function d$1(h,g,x,b){let $=x;for(let A=b.length-1;A>=0;A--){const j=g($,b[A],A,b);if(!h(j,b[A],A,b))break;$=j}return $}const reduceRightWhile=curry(d$1);function d(h,g,x,b){let $=x;for(let A=0;A<b.length;A++){const j=g($,b[A],A,b);if(!h(j,b[A],A,b))break;$=j}return $}const reduceWhile=curry(d);function o$8(h,g){const x=[];for(let b=0;b<g.length;b++){const $=g[b];h($,b,g)||x.push($)}return x}const reject=curry(o$8);function t$g(h,g){const x=h<0?g.length+h:h;return x<0||x>=g.length?[...g]:[...g.slice(0,x),...g.slice(x+1)]}const remove=curry(t$g);function t$f(h,g){return Array.from({length:g},()=>h)}const repeat=curry(t$f);function e$4(h){return[...h].reverse()}const reverse=e$4;function o$7(h,g){if(g.length===0)return[...g];const x=(h%g.length+g.length)%g.length;return[...g.slice(x),...g.slice(0,x)]}const rotateLeft=curry(o$7);function o$6(h,g){if(g.length===0)return[...g];const x=(h%g.length+g.length)%g.length;return[...g.slice(-x),...g.slice(0,-x)]}const rotateRight=curry(o$6);function t$e(h){if(h.length===0)return;const g=Math.floor(Math.random()*h.length);return h[g]}const sample=t$e;function m$1(h,g){if(g.length===0||h<=0)return[];const x=Math.min(h,g.length),b=new Array(g.length).fill(0).map(($,A)=>A);for(let $=0;$<x;$++){const A=$+Math.floor(Math.random()*(b.length-$));[b[$],b[A]]=[b[A],b[$]]}return b.slice(0,x).map($=>g[$])}const sampleSize=curry(m$1);function T$7(h,g,x){const b=[g];let $=g;for(let A=0;A<x.length;A++)$=h($,x[A],A,x),b.push($);return b}const scan=curry(T$7);function i$7(h,g,x){const b=[g];for(let $=x.length-1;$>=0;$--)b.unshift(h(b[0],x[$],$,x));return b}const scanRight=curry(i$7);function T$6(h,g,x){return{...x,[h]:g}}const set=curry(T$6);function o$5(h,g,x){const[b,...$]=h;if(b===void 0)return g;const A=$.length>0&&typeof $[0]=="number"&&Number($[0])>=0;if(x==null){const O=typeof b=="number"&&Number(b)>=0?[]:{};return o$5(h,g,O)}if(Array.isArray(x)){const O=Number(b),B=[...x];if(isNaN(O))throw new Error(`Cannot use non-numeric index with array: ${String(b)}`);return B[O]=o$5($,g,x[O]===void 0?A?[]:{}:x[O]),B}if(typeof x=="object"){const O=x,B=O[b];if(B!=null&&typeof B!="object"){const k=typeof $[0]=="number"&&Number($[0])>=0?[]:{};return{...O,[b]:o$5($,g,k)}}return{...O,[b]:o$5($,g,B===void 0?A?[]:{}:B)}}const j=typeof b=="number"&&Number(b)>=0?[]:{};return o$5(h,g,j)}const setPath=curry(o$5);function e$3(h){const g=[...h];for(let x=g.length-1;x>0;x--){const b=Math.floor(Math.random()*(x+1));[g[x],g[b]]=[g[b],g[x]]}return g}const shuffle=e$3;function t$d(h,g,x){return x.slice(h,g)}const slice=curry(t$d);function o$4(h){return[...h].sort()}const sort=o$4;function u$4(h,g){return[...g].sort((x,b)=>{const $=h(x)??0,A=h(b)??0;return $<A?-1:$>A?1:0})}const sortBy=curry(u$4);function t$c(h,g){return[...g].sort(h)}const sortWith=curry(t$c);function T$5(h,g,x,b){const $=h<0?Math.max(b.length+h,0):Math.min(h,b.length),A=Math.max(0,Math.min(g,b.length-$));return[...b.slice(0,$),...x,...b.slice($+A)]}const splice=curry(T$5);function e$2(h,g){return h<0?[[],[...g]]:[g.slice(0,h),g.slice(h)]}const splitAt=curry(e$2);function n$2(h,g){const x=g.findIndex(h);return x===-1?[[...g],[]]:[g.slice(0,x),g.slice(x)]}const splitWhen=curry(n$2);function t$b(h){return h.reduce((g,x)=>g+x,0)}const sum=t$b;function m(h,g){return g.reduce((x,b)=>x+h(b),0)}const sumBy=curry(m);function u$3(h,g,x){if(x.length===0)return[];const b=h<0?x.length+h:h,$=g<0?x.length+g:g;if(b<0||b>=x.length||$<0||$>=x.length)return[...x];const A=[...x];return[A[b],A[$]]=[A[$],A[b]],A}const swap=curry(u$3);function t$a(h,g){return[...new Set([...g.filter(x=>!h.includes(x)),...h.filter(x=>!g.includes(x))])]}const symmetricDifference=curry(t$a);function U$1(h,g,x){const b=new Set(x.map(h)),$=new Set(g.map(h)),A=[];let j=0;for(const O of x){const B=h(O,j++,x);$.has(B)||A.push(O),j++}j=0;for(const O of g){const B=h(O,j++,g);b.has(B)||A.push(O),j++}return A}const symmetricDifferenceBy=curry(U$1);function T$4(h,g,x){const b=[];for(const $ of x)g.some(A=>h($,A))||b.push($);for(const $ of g)x.some(A=>h(A,$))||b.push($);return b}const symmetricDifferenceWith=curry(T$4);function t$9(h){return h.slice(1)}const tail=t$9;function t$8(h,g){return h<0?[]:g.slice(0,h)}const take=curry(t$8);function t$7(h,g){return h<=0?[]:g.slice(-h)}const takeLast=curry(t$7);function n$1(h,g){const x=[];for(let b=g.length-1;b>=0&&h(g[b],b,g);b--)x.unshift(g[b]);return x}const takeLastWhile=curry(n$1);function n(h,g){const x=[];for(let b=0;b<g.length&&h(g[b],b,g);b++)x.push(g[b]);return x}const takeWhile=curry(n);function t$6(h){return h.reduce((g,x)=>(g.set(x,(g.get(x)||0)+1),g),new Map)}const tally=t$6;function t$5(h,g){return h(g),g}const tap=curry(t$5);function u$2(h,g){return Array.from({length:g},(x,b)=>h(b))}const times=curry(u$2);function t$4(h){return Object.entries(h)}const toPairs=t$4;function i$6(h){if(h.length===0)return[];const g=Math.min(...h.map(b=>b.length)),x=[];for(let b=0;b<g;b++)x.push(h.map($=>$[b]));return x}const transpose=i$6;function True(...h){return!0}function a$3(h){return g=>h(g)}const unary=a$3;function R(h,g){const x=[];let b=g;for(;;){const $=h(b);if(!$)break;const[A,j]=$;x.push(A),b=j}return x}const unfold=curry(R);function o$3(h,g){return[...new Set([...g,...h])]}const union=curry(o$3);function U(h,g,x){const b=new Set,$=[];let A=0;for(const j of x){const O=h(j,A++,x);b.has(O)||(b.add(O),$.push(j))}A=0;for(const j of g){const O=h(j,A++,g);b.has(O)||(b.add(O),$.push(j))}return $}const unionBy=curry(U);function T$3(h,g,x){const b=[...x];for(const $ of g)b.some(A=>h(A,$))||b.push($);return b}const unionWith=curry(T$3);function r(h){return[...new Set(h)]}const unique=r;function y$3(h,g){const x=new Set,b=[];let $=0;for(const A of g){const j=h(A,$++,g);x.has(j)||(x.add(j),b.push(A))}return b}const uniqueBy=curry(y$3);function i$5(h){if(h.length===0)return[];const g=h[0].length,x=Array.from({length:g},()=>[]);for(const b of h)for(let $=0;$<g;$++)x[$].push(b[$]);return x}const unzip=i$5;function T$2(h,g,x){if(x.length===0)return[];const b=h<0?x.length+h:h;return b<0||b>=x.length?[...x]:[...x.slice(0,b),g,...x.slice(b+1)]}const update=curry(T$2);function t$3(h){return[...Object.values(h),...Object.getOwnPropertySymbols(h).map(g=>h[g])]}const values=t$3;function i$4(h,g){const x=[];for(const b of g)for(const $ of h)x.push([b,$]);return x}const xprod=curry(i$4);function i$3(h,g){const x=Math.min(g.length,h.length),b=[];for(let $=0;$<x;$++)b.push([g[$],h[$]]);return b}const zip=curry(i$3);function a$2(h,g){return h.reduce((x,b,$)=>($<g.length&&(x[b]=g[$]),x),{})}const zipObj=curry(a$2);function T$1(h,g,x){const b=Math.min(x.length,g.length),$=[];for(let A=0;A<b;A++)$.push(h(x[A],g[A]));return $}const zipWith=curry(T$1),ZipAllShortest=Symbol("ZipAllShortest");function i$2(h,g){if(g.length===0)return[];if(h===ZipAllShortest){const x=Math.min(...g.map(b=>b.length));return Array.from({length:x},(b,$)=>g.map(A=>A[$]))}else{const x=Math.max(...g.map(b=>b.length));return Array.from({length:x},(b,$)=>g.map(A=>$<A.length?A[$]:h))}}const zipAll=curry(i$2);function i$1(h){const g=Math.max(0,...h.map(b=>b.length)),x=[];for(let b=0;b<g;b++)for(let $=0;$<h.length;$++)b<h[$].length&&x.push(h[$][b]);return x}const weave=i$1;function u$1(h,g){if(g.length===0)return[];const x=Math.max(...g.map($=>$.length)),b=[];for(let $=0;$<x;$++){const A=g.map(j=>j[$]);b.push(h(A))}return b}const unzipWith=curry(u$1);function t$2(h,g,x){return isEqual(x[g],h)}const propEq=curry(t$2);function a$1(h,g,x){if(g.length===0)return h===x;if(x==null)return!1;const[b,...$]=g;if(!(b in x))return!1;const A=x[b];return A===h?!0:a$1(h,$,A)}const pathEq=curry(a$1);function i(h,g){const x=[{},{}];for(const b in g)if(Object.prototype.hasOwnProperty.call(g,b)){const $=g[b],A=h($,b,g)?x[0]:x[1];A[b]=$}return x}const partitionWith=curry(i);function o$2(h){return JSON.parse(JSON.stringify(h))}const jsonClone=o$2;function e$1(h,g,x){for(let b=0;b<x.length;b++)if(h(x[b],b,x)===g)return!0;return!1}const includesBy=curry(e$1);function f(h,g,x){for(let b=0;b<x.length;b++){const $=g(x[b],b,x);if($!==void 0)return $}return h}const findMap=curry(f);function o$1(h,g){return g.reduce((x,b,$,A)=>(h(b,$,A)&&x.push($),x),[])}const findIndices=curry(o$1),FALSY_VALUES=[!1,null,0,-0,0n,"",void 0,NaN];function t$1(h){return h.filter(g=>!FALSY_VALUES.includes(g))}const compact=t$1;function s$1(h,g){const x={...g},b=g;for(const $ in h)if(Object.prototype.hasOwnProperty.call(b,$)){const A=h[$];typeof A=="function"?x[$]=A(b[$]):A&&typeof A=="object"&&b[$]&&typeof b[$]=="object"&&(x[$]=s$1(A,b[$]))}return x}const evolve=curry(s$1);function lens(h,g){return{get:h,set:g}}function lensProp(h){return lens(g=>g[h],(g,x)=>({...x,[h]:g}))}function lensPath(h){return lens(g=>path(h,g),(g,x)=>setPath(h,g,x))}const lensView=curry((h,g)=>h.get(g)),lensSet=curry((h,g,x)=>h.set(g,x)),lensOver=curry((h,g,x)=>h.set(g(h.get(x)),x));function y$2(h,g=new WeakMap){if(h===null||typeof h!="object"&&typeof h!="function"||typeof h=="function")return h;if(g.has(h))return g.get(h);const x=getObjectTag(h);let b;switch(x){case ObjectTags.Number:case ObjectTags.String:case ObjectTags.Boolean:case ObjectTags.Symbol:case ObjectTags.BigInt:b=new h.constructor(h.valueOf());break;case ObjectTags.Date:b=new Date(h.getTime());break;case ObjectTags.RegExp:b=new RegExp(h.source,h.flags);break;case ObjectTags.Array:case ObjectTags.Arguments:b=new h.constructor(h.length),g.set(h,b);for(let A=0;A<h.length;A++)b[A]=y$2(h[A],g);return b;case ObjectTags.Map:return b=new Map,g.set(h,b),h.forEach((A,j)=>{b.set(y$2(j,g),y$2(A,g))}),b;case ObjectTags.Set:return b=new Set,g.set(h,b),h.forEach(A=>{b.add(y$2(A,g))}),b;case ObjectTags.ArrayBuffer:b=h.slice(0);break;case ObjectTags.SharedArrayBuffer:b=h;break;case ObjectTags.DataView:const $=y$2(h.buffer,g);b=new DataView($,h.byteOffset,h.byteLength);break;case ObjectTags.Int8Array:case ObjectTags.Uint8Array:case ObjectTags.Uint8ClampedArray:case ObjectTags.Int16Array:case ObjectTags.Uint16Array:case ObjectTags.Int32Array:case ObjectTags.Uint32Array:case ObjectTags.Float32Array:case ObjectTags.Float64Array:case ObjectTags.BigInt64Array:case ObjectTags.BigUint64Array:b=new h.constructor(h);break;case ObjectTags.Object:b=Object.create(Object.getPrototypeOf(h)),g.set(h,b);for(const A in h)Object.prototype.hasOwnProperty.call(h,A)&&(b[A]=y$2(h[A],g));return Object.getOwnPropertySymbols(h).forEach(A=>{Object.prototype.propertyIsEnumerable.call(h,A)&&(b[A]=y$2(h[A],g))}),b;case ObjectTags.Error:b=new h.constructor(h.message),b.name=h.name;break;default:console.warn(`deepClone: Unsupported type ${x}. Returning original object.`),b=h;break}return b!==h&&g.set(h,b),b}const cloneDeep=h=>y$2(h);function y$1(h,g){if(!h.length)return!0;if(!g||typeof g!="object")return!1;let x=g;for(const b of h)if(!(b in x)||(x=x[b],x==null))return!1;return!0}const hasPath=curry(y$1),o=/\.?([^\.\[\]]+)|\[(\d+)\]/g;function u(h){if(!h)return[];const g=[];let x;for(;(x=o.exec(h))!==null;){const b=x[2]?Number(x[2]):x[1];b!==void 0&&g.push(b)}return g}const pathToArray=u;function a(h,g){for(const x in h){const b=h[x];if(b&&!b(g[x],x,g))return!1}return!0}const where=curry(a);function p(h,g){for(const x in h)if(!isEqual(h[x],g[x]))return!1;return!0}const whereEq=curry(p);function y(h,g){for(const x in h){const b=h[x];if(b&&b(g[x],x,g))return!0}return!1}const whereAny=curry(y);function e(h,g){return(...x)=>{const b=x.map(($,A)=>{const j=g[A];return j?j($):$});return h(...b)}}const useWith=curry(e);function t(h,g){return(...x)=>{const b=g.map($=>$(...x));return h(...b)}}const converge=curry(t);function s(h,g){return h.apply(null,g)}const call=curry(s);function T(h,g){return h.bind(g)}const bind=curry(T);exports.FALSY_VALUES=FALSY_VALUES;exports.False=False;exports.True=True;exports.ZipAllShortest=ZipAllShortest;exports.adjust=adjust;exports.all=all;exports.allPass=allPass;exports.always=always;exports.any=any;exports.anyPass=anyPass;exports.ap=ap;exports.aperture=aperture;exports.append=append;exports.bifurcate=bifurcate;exports.bind=bind;exports.call=call;exports.chunk=chunk;exports.clone=clone;exports.cloneDeep=cloneDeep;exports.compact=compact;exports.complement=complement;exports.compose=compose;exports.composeAsync=composeAsync;exports.concat=concat;exports.converge=converge;exports.countBy=countBy;exports.curry=curry;exports.difference=difference;exports.differenceBy=differenceBy;exports.differenceWith=differenceWith;exports.drop=drop;exports.dropLast=dropLast;exports.dropLastWhile=dropLastWhile;exports.dropRepeats=dropRepeats;exports.dropRepeatsWith=dropRepeatsWith;exports.dropWhile=dropWhile;exports.evolve=evolve;exports.filter=filter;exports.find=find;exports.findIndex=findIndex;exports.findIndices=findIndices;exports.findLast=findLast;exports.findLastIndex=findLastIndex;exports.findMap=findMap;exports.first=first;exports.flatMap=flatMap;exports.flatten=flatten;exports.flip=flip;exports.flow=flow;exports.flowAsync=flowAsync;exports.forEach=forEach;exports.fromPairs=fromPairs;exports.groupBy=groupBy;exports.has=has;exports.hasPath=hasPath;exports.identity=identity;exports.includes=includes;exports.includesBy=includesBy;exports.indexBy=indexBy;exports.indexOf=indexOf;exports.init=init;exports.insert=insert;exports.intercalate=intercalate;exports.interleave=interleave;exports.intersection=intersection;exports.intersectionBy=intersectionBy;exports.intersectionWith=intersectionWith;exports.intersperse=intersperse;exports.invert=invert;exports.invertMulti=invertMulti;exports.isAlpha=isAlpha;exports.isAlphanumeric=isAlphanumeric;exports.isArray=isArray;exports.isArrayLike=isArrayLike;exports.isArrayOf=isArrayOf;exports.isAsyncGenerator=isAsyncGenerator;exports.isBlankString=isBlankString;exports.isBoolean=isBoolean;exports.isDate=isDate;exports.isEmail=isEmail;exports.isEmptyArray=isEmptyArray;exports.isEmptyObject=isEmptyObject;exports.isEmptyString=isEmptyString;exports.isEqual=isEqual;exports.isError=isError;exports.isEven=isEven;exports.isFinite=isFinite;exports.isFloat=isFloat;exports.isFunction=isFunction;exports.isGenerator=isGenerator;exports.isGenericGenerator=isGenericGenerator;exports.isInfinity=isInfinity;exports.isInteger=isInteger;exports.isIterable=isIterable;exports.isNaN=isNaN$1;exports.isNegative=isNegative;exports.isNegativeInfinity=isNegativeInfinity;exports.isNil=isNil;exports.isNotNil=isNotNil;exports.isNull=isNull;exports.isNumber=isNumber;exports.isNumeric=isNumeric;exports.isObject=isObject;exports.isOdd=isOdd;exports.isPlainObject=isPlainObject;exports.isPositive=isPositive;exports.isPositiveInfinity=isPositiveInfinity;exports.isPromise=isPromise;exports.isRegExp=isRegExp;exports.isString=isString;exports.isSymbol=isSymbol;exports.isUndefined=isUndefined;exports.isUrl=isUrl;exports.isZero=isZero;exports.join=join;exports.jsonClone=jsonClone;exports.juxt=juxt;exports.keys=keys;exports.last=last;exports.lastIndexOf=lastIndexOf;exports.length=length;exports.lens=lens;exports.lensOver=lensOver;exports.lensPath=lensPath;exports.lensProp=lensProp;exports.lensSet=lensSet;exports.lensView=lensView;exports.map=map;exports.mapEntries=mapEntries;exports.mapKeys=mapKeys;exports.mapValues=mapValues;exports.max=max;exports.maxBy=maxBy;exports.maxWith=maxWith;exports.mean=mean;exports.median=median;exports.mergeDeleteSymbol=mergeDeleteSymbol;exports.mergeLeft=mergeLeft;exports.mergeLeftInPlace=mergeLeftInPlace;exports.mergeRight=mergeRight;exports.mergeRightInPlace=mergeRightInPlace;exports.mergeWith=mergeWith;exports.mergeWithInPlace=mergeWithInPlace;exports.min=min;exports.minBy=minBy;exports.minWith=minWith;exports.move=move;exports.none=none;exports.nonePass=nonePass;exports.noop=noop;exports.nth=nth;exports.omit=omit;exports.omitBy=omitBy;exports.omitIndices=omitIndices;exports.once=once;exports.padLeft=padLeft;exports.padRight=padRight;exports.pairwise=pairwise;exports.partition=partition;exports.partitionWith=partitionWith;exports.path=path;exports.pathEq=pathEq;exports.pathOr=pathOr;exports.pathToArray=pathToArray;exports.pick=pick;exports.pickBy=pickBy;exports.pickIndices=pickIndices;exports.pipe=pipe;exports.pluck=pluck;exports.prepend=prepend;exports.product=product;exports.prop=prop;exports.propEq=propEq;exports.propOr=propOr;exports.range=range;exports.reduce=reduce;exports.reduceRight=reduceRight;exports.reduceRightWhile=reduceRightWhile;exports.reduceWhile=reduceWhile;exports.reject=reject;exports.remove=remove;exports.repeat=repeat;exports.reverse=reverse;exports.rotateLeft=rotateLeft;exports.rotateRight=rotateRight;exports.sample=sample;exports.sampleSize=sampleSize;exports.scan=scan;exports.scanRight=scanRight;exports.set=set;exports.setPath=setPath;exports.shuffle=shuffle;exports.slice=slice;exports.sort=sort;exports.sortBy=sortBy;exports.sortWith=sortWith;exports.splice=splice;exports.splitAt=splitAt;exports.splitBy=splitBy;exports.splitWhen=splitWhen;exports.sum=sum;exports.sumBy=sumBy;exports.swap=swap;exports.symmetricDifference=symmetricDifference;exports.symmetricDifferenceBy=symmetricDifferenceBy;exports.symmetricDifferenceWith=symmetricDifferenceWith;exports.tail=tail;exports.take=take;exports.takeLast=takeLast;exports.takeLastWhile=takeLastWhile;exports.takeWhile=takeWhile;exports.tally=tally;exports.tap=tap;exports.times=times;exports.toPairs=toPairs;exports.transpose=transpose;exports.unary=unary;exports.unfold=unfold;exports.union=union;exports.unionBy=unionBy;exports.unionWith=unionWith;exports.unique=unique;exports.uniqueBy=uniqueBy;exports.unzip=unzip;exports.unzipWith=unzipWith;exports.update=update;exports.useWith=useWith;exports.values=values;exports.weave=weave;exports.where=where;exports.whereAny=whereAny;exports.whereEq=whereEq;exports.xprod=xprod;exports.zip=zip;exports.zipAll=zipAll;exports.zipObj=zipObj;exports.zipWith=zipWith;