@activepieces/piece-csv 0.4.18 → 0.4.19

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@activepieces/piece-csv",
3
- "version": "0.4.18",
3
+ "version": "0.4.19",
4
4
  "main": "./src/index.js",
5
5
  "dependencies": {},
6
6
  "files": [
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var DA=Object.create;var Ga=Object.defineProperty;var OA=Object.getOwnPropertyDescriptor;var NA=Object.getOwnPropertyNames;var RA=Object.getPrototypeOf,$A=Object.prototype.hasOwnProperty;var l=(u,s)=>Ga(u,"name",{value:s,configurable:!0});var qo=(u,s)=>()=>{try{return s||u((s={exports:{}}).exports,s),s.exports}catch(i){throw s=0,i}},Xf=(u,s)=>{for(var i in s)Ga(u,i,{get:s[i],enumerable:!0})},Kf=(u,s,i,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let A of NA(s))!$A.call(u,A)&&A!==i&&Ga(u,A,{get:()=>s[A],enumerable:!(r=OA(s,A))||r.enumerable});return u};var ta=(u,s,i)=>(i=u!=null?DA(RA(u)):{},Kf(s||!u||!u.__esModule?Ga(i,"default",{value:u,enumerable:!0}):i,u)),zA=u=>Kf(Ga({},"__esModule",{value:!0}),u);var xp=qo((gp,xs)=>{(function(u){"use strict";let s="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${s}\\.${s}\\.${s}\\.${s}$`,"i"),threeOctet:new RegExp(`^${s}\\.${s}\\.${s}$`,"i"),twoOctet:new RegExp(`^${s}\\.${s}$`,"i"),longValue:new RegExp(`^${s}$`,"i")},r=new RegExp("^0[0-7]+$","i"),A=new RegExp("^0x[a-f0-9]+$","i"),M="%[0-9a-z]{1,}",L="(?:[0-9a-f]+::?)+",B={zoneIndex:new RegExp(M,"i"),native:new RegExp(`^(::)?(${L})?([0-9a-f]+)?(::)?(${M})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${s}\\.${s}\\.${s}\\.${s}(${M})?)$`,"i"),transitional:new RegExp(`^((?:${L})|(?:::)(?:${L})?)${s}\\.${s}\\.${s}\\.${s}(${M})?$`,"i")};function Y(z,J){if(z.indexOf("::")!==z.lastIndexOf("::"))return null;let ee=0,re=-1,pe=(z.match(B.zoneIndex)||[])[0],me,We;for(pe&&(pe=pe.substring(1),z=z.replace(/%.+$/,""));(re=z.indexOf(":",re+1))>=0;)ee++;if(z.substr(0,2)==="::"&&ee--,z.substr(-2,2)==="::"&&ee--,ee>J)return null;for(We=J-ee,me=":";We--;)me+="0:";return z=z.replace("::",me),z[0]===":"&&(z=z.slice(1)),z[z.length-1]===":"&&(z=z.slice(0,-1)),J=(function(){let br=z.split(":"),Ke=[];for(let Wr=0;Wr<br.length;Wr++)Ke.push(parseInt(br[Wr],16));return Ke})(),{parts:J,zoneId:pe}}l(Y,"expandIPv6");function te(z,J,ee,re){if(z.length!==J.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let pe=0,me;for(;re>0;){if(me=ee-re,me<0&&(me=0),z[pe]>>me!==J[pe]>>me)return!1;re-=ee,pe+=1}return!0}l(te,"matchCIDR");function Te(z){if(A.test(z))return parseInt(z,16);if(z[0]==="0"&&!isNaN(parseInt(z[1],10))){if(r.test(z))return parseInt(z,8);throw new Error(`ipaddr: cannot parse ${z} as octal`)}return parseInt(z,10)}l(Te,"parseIntAuto");function he(z,J){for(;z.length<J;)z=`0${z}`;return z}l(he,"padPart");let Pe={};Pe.IPv4=(function(){function z(J){if(J.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let ee,re;for(ee=0;ee<J.length;ee++)if(re=J[ee],!(0<=re&&re<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=J}return l(z,"IPv4"),z.prototype.SpecialRanges={unspecified:[[new z([0,0,0,0]),8]],broadcast:[[new z([255,255,255,255]),32]],multicast:[[new z([224,0,0,0]),4]],linkLocal:[[new z([169,254,0,0]),16]],loopback:[[new z([127,0,0,0]),8]],carrierGradeNat:[[new z([100,64,0,0]),10]],private:[[new z([10,0,0,0]),8],[new z([172,16,0,0]),12],[new z([192,168,0,0]),16]],reserved:[[new z([192,0,0,0]),24],[new z([192,0,2,0]),24],[new z([192,88,99,0]),24],[new z([198,18,0,0]),15],[new z([198,51,100,0]),24],[new z([203,0,113,0]),24],[new z([240,0,0,0]),4]],as112:[[new z([192,175,48,0]),24],[new z([192,31,196,0]),24]],amt:[[new z([192,52,193,0]),24]]},z.prototype.kind=function(){return"ipv4"},z.prototype.match=function(J,ee){let re;if(ee===void 0&&(re=J,J=re[0],ee=re[1]),J.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return te(this.octets,J.octets,8,ee)},z.prototype.prefixLengthFromSubnetMask=function(){let J=0,ee=!1,re={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},pe,me,We;for(pe=3;pe>=0;pe-=1)if(me=this.octets[pe],me in re){if(We=re[me],ee&&We!==0)return null;We!==8&&(ee=!0),J+=We}else return null;return 32-J},z.prototype.range=function(){return Pe.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){return this.octets.slice(0)},z.prototype.toIPv4MappedAddress=function(){return Pe.IPv6.parse(`::ffff:${this.toString()}`)},z.prototype.toNormalizedString=function(){return this.toString()},z.prototype.toString=function(){return this.octets.join(".")},z})(),Pe.IPv4.broadcastAddressFromCIDR=function(z){try{let J=this.parseCIDR(z),ee=J[0].toByteArray(),re=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],me=0;for(;me<4;)pe.push(parseInt(ee[me],10)|parseInt(re[me],10)^255),me++;return new this(pe)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},Pe.IPv4.isIPv4=function(z){return this.parser(z)!==null},Pe.IPv4.isValid=function(z){try{return new this(this.parser(z)),!0}catch{return!1}},Pe.IPv4.isValidCIDR=function(z){try{return this.parseCIDR(z),!0}catch{return!1}},Pe.IPv4.isValidFourPartDecimal=function(z){return!!(Pe.IPv4.isValid(z)&&z.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},Pe.IPv4.isValidCIDRFourPartDecimal=function(z){let J=z.match(/^(.+)\/(\d+)$/);return!Pe.IPv4.isValidCIDR(z)||!J?!1:Pe.IPv4.isValidFourPartDecimal(J[1])},Pe.IPv4.networkAddressFromCIDR=function(z){let J,ee,re,pe,me;try{for(J=this.parseCIDR(z),re=J[0].toByteArray(),me=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],ee=0;ee<4;)pe.push(parseInt(re[ee],10)&parseInt(me[ee],10)),ee++;return new this(pe)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},Pe.IPv4.parse=function(z){let J=this.parser(z);if(J===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(J)},Pe.IPv4.parseCIDR=function(z){let J;if(J=z.match(/^(.+)\/(\d+)$/)){let ee=parseInt(J[2]);if(ee>=0&&ee<=32){let re=[this.parse(J[1]),ee];return Object.defineProperty(re,"toString",{value:l(function(){return this.join("/")},"value")}),re}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},Pe.IPv4.parser=function(z){let J,ee,re;if(J=z.match(i.fourOctet))return(function(){let pe=J.slice(1,6),me=[];for(let We=0;We<pe.length;We++)ee=pe[We],me.push(Te(ee));return me})();if(J=z.match(i.longValue)){if(re=Te(J[1]),re>4294967295||re<0)throw new Error("ipaddr: address outside defined range");return(function(){let pe=[],me;for(me=0;me<=24;me+=8)pe.push(re>>me&255);return pe})().reverse()}else return(J=z.match(i.twoOctet))?(function(){let pe=J.slice(1,4),me=[];if(re=Te(pe[1]),re>16777215||re<0)throw new Error("ipaddr: address outside defined range");return me.push(Te(pe[0])),me.push(re>>16&255),me.push(re>>8&255),me.push(re&255),me})():(J=z.match(i.threeOctet))?(function(){let pe=J.slice(1,5),me=[];if(re=Te(pe[2]),re>65535||re<0)throw new Error("ipaddr: address outside defined range");return me.push(Te(pe[0])),me.push(Te(pe[1])),me.push(re>>8&255),me.push(re&255),me})():null},Pe.IPv4.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>32)throw new Error("ipaddr: invalid IPv4 prefix length");let J=[0,0,0,0],ee=0,re=Math.floor(z/8);for(;ee<re;)J[ee]=255,ee++;return re<4&&(J[re]=Math.pow(2,z%8)-1<<8-z%8),new this(J)},Pe.IPv6=(function(){function z(J,ee){let re,pe;if(J.length===16)for(this.parts=[],re=0;re<=14;re+=2)this.parts.push(J[re]<<8|J[re+1]);else if(J.length===8)this.parts=J;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(re=0;re<this.parts.length;re++)if(pe=this.parts[re],!(0<=pe&&pe<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");ee&&(this.zoneId=ee)}return l(z,"IPv6"),z.prototype.SpecialRanges={unspecified:[new z([0,0,0,0,0,0,0,0]),128],linkLocal:[new z([65152,0,0,0,0,0,0,0]),10],multicast:[new z([65280,0,0,0,0,0,0,0]),8],loopback:[new z([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new z([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new z([0,0,0,0,0,65535,0,0]),96],discard:[new z([256,0,0,0,0,0,0,0]),64],rfc6145:[new z([0,0,0,0,65535,0,0,0]),96],rfc6052:[new z([100,65435,0,0,0,0,0,0]),96],"6to4":[new z([8194,0,0,0,0,0,0,0]),16],teredo:[new z([8193,0,0,0,0,0,0,0]),32],benchmarking:[new z([8193,2,0,0,0,0,0,0]),48],amt:[new z([8193,3,0,0,0,0,0,0]),32],as112v6:[[new z([8193,4,274,0,0,0,0,0]),48],[new z([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new z([8193,16,0,0,0,0,0,0]),28],orchid2:[new z([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new z([8193,48,0,0,0,0,0,0]),28],reserved:[[new z([8193,0,0,0,0,0,0,0]),23],[new z([8193,3512,0,0,0,0,0,0]),32]]},z.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},z.prototype.kind=function(){return"ipv6"},z.prototype.match=function(J,ee){let re;if(ee===void 0&&(re=J,J=re[0],ee=re[1]),J.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return te(this.parts,J.parts,16,ee)},z.prototype.prefixLengthFromSubnetMask=function(){let J=0,ee=!1,re={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},pe,me;for(let We=7;We>=0;We-=1)if(pe=this.parts[We],pe in re){if(me=re[pe],ee&&me!==0)return null;me!==16&&(ee=!0),J+=me}else return null;return 128-J},z.prototype.range=function(){return Pe.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){let J,ee=[],re=this.parts;for(let pe=0;pe<re.length;pe++)J=re[pe],ee.push(J>>8),ee.push(J&255);return ee},z.prototype.toFixedLengthString=function(){let J=(function(){let re=[];for(let pe=0;pe<this.parts.length;pe++)re.push(he(this.parts[pe].toString(16),4));return re}).call(this).join(":"),ee="";return this.zoneId&&(ee=`%${this.zoneId}`),J+ee},z.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let J=this.parts.slice(-2),ee=J[0],re=J[1];return new Pe.IPv4([ee>>8,ee&255,re>>8,re&255])},z.prototype.toNormalizedString=function(){let J=(function(){let re=[];for(let pe=0;pe<this.parts.length;pe++)re.push(this.parts[pe].toString(16));return re}).call(this).join(":"),ee="";return this.zoneId&&(ee=`%${this.zoneId}`),J+ee},z.prototype.toRFC5952String=function(){let J=/((^|:)(0(:|$)){2,})/g,ee=this.toNormalizedString(),re=0,pe=-1,me;for(;me=J.exec(ee);)me[0].length>pe&&(re=me.index,pe=me[0].length);return pe<0?ee:`${ee.substring(0,re)}::${ee.substring(re+pe)}`},z.prototype.toString=function(){return this.toRFC5952String()},z})(),Pe.IPv6.broadcastAddressFromCIDR=function(z){try{let J=this.parseCIDR(z),ee=J[0].toByteArray(),re=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],me=0;for(;me<16;)pe.push(parseInt(ee[me],10)|parseInt(re[me],10)^255),me++;return new this(pe)}catch(J){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${J})`)}},Pe.IPv6.isIPv6=function(z){return this.parser(z)!==null},Pe.IPv6.isValid=function(z){if(typeof z=="string"&&z.indexOf(":")===-1)return!1;try{let J=this.parser(z);return new this(J.parts,J.zoneId),!0}catch{return!1}},Pe.IPv6.isValidCIDR=function(z){if(typeof z=="string"&&z.indexOf(":")===-1)return!1;try{return this.parseCIDR(z),!0}catch{return!1}},Pe.IPv6.networkAddressFromCIDR=function(z){let J,ee,re,pe,me;try{for(J=this.parseCIDR(z),re=J[0].toByteArray(),me=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],ee=0;ee<16;)pe.push(parseInt(re[ee],10)&parseInt(me[ee],10)),ee++;return new this(pe)}catch(We){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${We})`)}},Pe.IPv6.parse=function(z){let J=this.parser(z);if(J.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(J.parts,J.zoneId)},Pe.IPv6.parseCIDR=function(z){let J,ee,re;if((ee=z.match(/^(.+)\/(\d+)$/))&&(J=parseInt(ee[2]),J>=0&&J<=128))return re=[this.parse(ee[1]),J],Object.defineProperty(re,"toString",{value:l(function(){return this.join("/")},"value")}),re;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},Pe.IPv6.parser=function(z){let J,ee,re,pe,me,We;if(re=z.match(B.deprecatedTransitional))return this.parser(`::ffff:${re[1]}`);if(B.native.test(z))return Y(z,8);if((re=z.match(B.transitional))&&(We=re[6]||"",J=re[1],re[1].endsWith("::")||(J=J.slice(0,-1)),J=Y(J+We,6),J.parts)){for(me=[parseInt(re[2]),parseInt(re[3]),parseInt(re[4]),parseInt(re[5])],ee=0;ee<me.length;ee++)if(pe=me[ee],!(0<=pe&&pe<=255))return null;return J.parts.push(me[0]<<8|me[1]),J.parts.push(me[2]<<8|me[3]),{parts:J.parts,zoneId:J.zoneId}}return null},Pe.IPv6.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>128)throw new Error("ipaddr: invalid IPv6 prefix length");let J=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ee=0,re=Math.floor(z/8);for(;ee<re;)J[ee]=255,ee++;return re<16&&(J[re]=Math.pow(2,z%8)-1<<8-z%8),new this(J)},Pe.fromByteArray=function(z){let J=z.length;if(J===4)return new Pe.IPv4(z);if(J===16)return new Pe.IPv6(z);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},Pe.isValid=function(z){return Pe.IPv6.isValid(z)||Pe.IPv4.isValid(z)},Pe.isValidCIDR=function(z){return Pe.IPv6.isValidCIDR(z)||Pe.IPv4.isValidCIDR(z)},Pe.parse=function(z){if(Pe.IPv6.isValid(z))return Pe.IPv6.parse(z);if(Pe.IPv4.isValid(z))return Pe.IPv4.parse(z);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},Pe.parseCIDR=function(z){try{return Pe.IPv6.parseCIDR(z)}catch{try{return Pe.IPv4.parseCIDR(z)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},Pe.process=function(z){let J=this.parse(z);return J.kind()==="ipv6"&&J.isIPv4MappedAddress()?J.toIPv4Address():J},Pe.subnetMatch=function(z,J,ee){let re,pe,me,We;ee==null&&(ee="unicast");for(pe in J)if(Object.prototype.hasOwnProperty.call(J,pe)){for(me=J[pe],me[0]&&!(me[0]instanceof Array)&&(me=[me]),re=0;re<me.length;re++)if(We=me[re],z.kind()===We[0].kind()&&z.match.apply(z,We))return pe}return ee},typeof xs<"u"&&xs.exports?xs.exports=Pe:u.ipaddr=Pe})(gp)});var yh=qo((U9,_h)=>{var ys=l(u=>u instanceof Date,"isDate"),yF=l((u,s)=>{let i={},r=s||".";if(typeof u!="object"||ys(u))return u;let A=l((M,L,B)=>{if(!Object.values(M).length&&B)return i[B]=M,M;Object.entries(M).forEach(([Y,te])=>{let Te=B?B+r+Y:Y;if(typeof te=="object"&&te!==null&&(L.forEach(he=>{te===he&&!ys(te)&&(te="[Circular]")}),L.push(te),typeof te=="object"&&!ys(te)))return A(te,L,Te);i[Te]=te})},"flat");return A(u,[u]),i},"flatten"),EF=l((u,s)=>{let i={},r=s||".",A=["__proto__","constructor","prototype"];return typeof u!="object"||ys(u)?u:(l(L=>{Object.keys(L).forEach(B=>{let Y=B.split(r);Y.reduce((te,Te,he)=>A.includes(Y[he])?te:te[Te]||(te[Te]=isNaN(Number(Y[he+1]))?Y.length-1===he?L[B]:{}:[]),i)})},"unflat")(u),i)},"unflatten");_h.exports={flatten:yF,unflatten:EF}});var bh=qo((Ih,Li)=>{var Pr={version:"1.15.0"};Pr[437]=(function(){for(var u=`\0\x07\b
1
+ "use strict";var DA=Object.create;var Ga=Object.defineProperty;var OA=Object.getOwnPropertyDescriptor;var NA=Object.getOwnPropertyNames;var RA=Object.getPrototypeOf,$A=Object.prototype.hasOwnProperty;var l=(u,s)=>Ga(u,"name",{value:s,configurable:!0});var qo=(u,s)=>()=>{try{return s||u((s={exports:{}}).exports,s),s.exports}catch(i){throw s=0,i}},Xf=(u,s)=>{for(var i in s)Ga(u,i,{get:s[i],enumerable:!0})},Kf=(u,s,i,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let A of NA(s))!$A.call(u,A)&&A!==i&&Ga(u,A,{get:()=>s[A],enumerable:!(r=OA(s,A))||r.enumerable});return u};var ta=(u,s,i)=>(i=u!=null?DA(RA(u)):{},Kf(s||!u||!u.__esModule?Ga(i,"default",{value:u,enumerable:!0}):i,u)),zA=u=>Kf(Ga({},"__esModule",{value:!0}),u);var xp=qo((gp,xs)=>{(function(u){"use strict";let s="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${s}\\.${s}\\.${s}\\.${s}$`,"i"),threeOctet:new RegExp(`^${s}\\.${s}\\.${s}$`,"i"),twoOctet:new RegExp(`^${s}\\.${s}$`,"i"),longValue:new RegExp(`^${s}$`,"i")},r=new RegExp("^0[0-7]+$","i"),A=new RegExp("^0x[a-f0-9]+$","i"),M="%[0-9a-z]{1,}",L="(?:[0-9a-f]+::?)+",B={zoneIndex:new RegExp(M,"i"),native:new RegExp(`^(::)?(${L})?([0-9a-f]+)?(::)?(${M})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${s}\\.${s}\\.${s}\\.${s}(${M})?)$`,"i"),transitional:new RegExp(`^((?:${L})|(?:::)(?:${L})?)${s}\\.${s}\\.${s}\\.${s}(${M})?$`,"i")};function Y(z,J){if(z.indexOf("::")!==z.lastIndexOf("::"))return null;let ee=0,re=-1,pe=(z.match(B.zoneIndex)||[])[0],me,We;for(pe&&(pe=pe.substring(1),z=z.replace(/%.+$/,""));(re=z.indexOf(":",re+1))>=0;)ee++;if(z.substr(0,2)==="::"&&ee--,z.substr(-2,2)==="::"&&ee--,ee>J)return null;for(We=J-ee,me=":";We--;)me+="0:";return z=z.replace("::",me),z[0]===":"&&(z=z.slice(1)),z[z.length-1]===":"&&(z=z.slice(0,-1)),J=(function(){let br=z.split(":"),Ke=[];for(let Wr=0;Wr<br.length;Wr++)Ke.push(parseInt(br[Wr],16));return Ke})(),{parts:J,zoneId:pe}}l(Y,"expandIPv6");function te(z,J,ee,re){if(z.length!==J.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let pe=0,me;for(;re>0;){if(me=ee-re,me<0&&(me=0),z[pe]>>me!==J[pe]>>me)return!1;re-=ee,pe+=1}return!0}l(te,"matchCIDR");function Te(z){if(A.test(z))return parseInt(z,16);if(z[0]==="0"&&!isNaN(parseInt(z[1],10))){if(r.test(z))return parseInt(z,8);throw new Error(`ipaddr: cannot parse ${z} as octal`)}return parseInt(z,10)}l(Te,"parseIntAuto");function he(z,J){for(;z.length<J;)z=`0${z}`;return z}l(he,"padPart");let Pe={};Pe.IPv4=(function(){function z(J){if(J.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let ee,re;for(ee=0;ee<J.length;ee++)if(re=J[ee],!(0<=re&&re<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=J}return l(z,"IPv4"),z.prototype.SpecialRanges={unspecified:[[new z([0,0,0,0]),8]],broadcast:[[new z([255,255,255,255]),32]],multicast:[[new z([224,0,0,0]),4]],linkLocal:[[new z([169,254,0,0]),16]],loopback:[[new z([127,0,0,0]),8]],carrierGradeNat:[[new z([100,64,0,0]),10]],private:[[new z([10,0,0,0]),8],[new z([172,16,0,0]),12],[new z([192,168,0,0]),16]],reserved:[[new z([192,0,0,0]),24],[new z([192,0,2,0]),24],[new z([192,88,99,0]),24],[new z([198,18,0,0]),15],[new z([198,51,100,0]),24],[new z([203,0,113,0]),24],[new z([240,0,0,0]),4]],as112:[[new z([192,175,48,0]),24],[new z([192,31,196,0]),24]],amt:[[new z([192,52,193,0]),24]]},z.prototype.kind=function(){return"ipv4"},z.prototype.match=function(J,ee){let re;if(ee===void 0&&(re=J,J=re[0],ee=re[1]),J.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return te(this.octets,J.octets,8,ee)},z.prototype.prefixLengthFromSubnetMask=function(){let J=0,ee=!1,re={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},pe,me,We;for(pe=3;pe>=0;pe-=1)if(me=this.octets[pe],me in re){if(We=re[me],ee&&We!==0)return null;We!==8&&(ee=!0),J+=We}else return null;return 32-J},z.prototype.range=function(){return Pe.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){return this.octets.slice(0)},z.prototype.toIPv4MappedAddress=function(){return Pe.IPv6.parse(`::ffff:${this.toString()}`)},z.prototype.toNormalizedString=function(){return this.toString()},z.prototype.toString=function(){return this.octets.join(".")},z})(),Pe.IPv4.broadcastAddressFromCIDR=function(z){try{let J=this.parseCIDR(z),ee=J[0].toByteArray(),re=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],me=0;for(;me<4;)pe.push(parseInt(ee[me],10)|parseInt(re[me],10)^255),me++;return new this(pe)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},Pe.IPv4.isIPv4=function(z){return this.parser(z)!==null},Pe.IPv4.isValid=function(z){try{return new this(this.parser(z)),!0}catch{return!1}},Pe.IPv4.isValidCIDR=function(z){try{return this.parseCIDR(z),!0}catch{return!1}},Pe.IPv4.isValidFourPartDecimal=function(z){return!!(Pe.IPv4.isValid(z)&&z.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},Pe.IPv4.isValidCIDRFourPartDecimal=function(z){let J=z.match(/^(.+)\/(\d+)$/);return!Pe.IPv4.isValidCIDR(z)||!J?!1:Pe.IPv4.isValidFourPartDecimal(J[1])},Pe.IPv4.networkAddressFromCIDR=function(z){let J,ee,re,pe,me;try{for(J=this.parseCIDR(z),re=J[0].toByteArray(),me=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],ee=0;ee<4;)pe.push(parseInt(re[ee],10)&parseInt(me[ee],10)),ee++;return new this(pe)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},Pe.IPv4.parse=function(z){let J=this.parser(z);if(J===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(J)},Pe.IPv4.parseCIDR=function(z){let J;if(J=z.match(/^(.+)\/(\d+)$/)){let ee=parseInt(J[2]);if(ee>=0&&ee<=32){let re=[this.parse(J[1]),ee];return Object.defineProperty(re,"toString",{value:l(function(){return this.join("/")},"value")}),re}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},Pe.IPv4.parser=function(z){let J,ee,re;if(J=z.match(i.fourOctet))return(function(){let pe=J.slice(1,6),me=[];for(let We=0;We<pe.length;We++)ee=pe[We],me.push(Te(ee));return me})();if(J=z.match(i.longValue)){if(re=Te(J[1]),re>4294967295||re<0)throw new Error("ipaddr: address outside defined range");return(function(){let pe=[],me;for(me=0;me<=24;me+=8)pe.push(re>>me&255);return pe})().reverse()}else return(J=z.match(i.twoOctet))?(function(){let pe=J.slice(1,4),me=[];if(re=Te(pe[1]),re>16777215||re<0)throw new Error("ipaddr: address outside defined range");return me.push(Te(pe[0])),me.push(re>>16&255),me.push(re>>8&255),me.push(re&255),me})():(J=z.match(i.threeOctet))?(function(){let pe=J.slice(1,5),me=[];if(re=Te(pe[2]),re>65535||re<0)throw new Error("ipaddr: address outside defined range");return me.push(Te(pe[0])),me.push(Te(pe[1])),me.push(re>>8&255),me.push(re&255),me})():null},Pe.IPv4.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>32)throw new Error("ipaddr: invalid IPv4 prefix length");let J=[0,0,0,0],ee=0,re=Math.floor(z/8);for(;ee<re;)J[ee]=255,ee++;return re<4&&(J[re]=Math.pow(2,z%8)-1<<8-z%8),new this(J)},Pe.IPv6=(function(){function z(J,ee){let re,pe;if(J.length===16)for(this.parts=[],re=0;re<=14;re+=2)this.parts.push(J[re]<<8|J[re+1]);else if(J.length===8)this.parts=J;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(re=0;re<this.parts.length;re++)if(pe=this.parts[re],!(0<=pe&&pe<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");ee&&(this.zoneId=ee)}return l(z,"IPv6"),z.prototype.SpecialRanges={unspecified:[new z([0,0,0,0,0,0,0,0]),128],linkLocal:[new z([65152,0,0,0,0,0,0,0]),10],multicast:[new z([65280,0,0,0,0,0,0,0]),8],loopback:[new z([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new z([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new z([0,0,0,0,0,65535,0,0]),96],discard:[new z([256,0,0,0,0,0,0,0]),64],rfc6145:[new z([0,0,0,0,65535,0,0,0]),96],rfc6052:[new z([100,65435,0,0,0,0,0,0]),96],"6to4":[new z([8194,0,0,0,0,0,0,0]),16],teredo:[new z([8193,0,0,0,0,0,0,0]),32],benchmarking:[new z([8193,2,0,0,0,0,0,0]),48],amt:[new z([8193,3,0,0,0,0,0,0]),32],as112v6:[[new z([8193,4,274,0,0,0,0,0]),48],[new z([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new z([8193,16,0,0,0,0,0,0]),28],orchid2:[new z([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new z([8193,48,0,0,0,0,0,0]),28],reserved:[[new z([8193,0,0,0,0,0,0,0]),23],[new z([8193,3512,0,0,0,0,0,0]),32]]},z.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},z.prototype.kind=function(){return"ipv6"},z.prototype.match=function(J,ee){let re;if(ee===void 0&&(re=J,J=re[0],ee=re[1]),J.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return te(this.parts,J.parts,16,ee)},z.prototype.prefixLengthFromSubnetMask=function(){let J=0,ee=!1,re={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},pe,me;for(let We=7;We>=0;We-=1)if(pe=this.parts[We],pe in re){if(me=re[pe],ee&&me!==0)return null;me!==16&&(ee=!0),J+=me}else return null;return 128-J},z.prototype.range=function(){return Pe.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){let J,ee=[],re=this.parts;for(let pe=0;pe<re.length;pe++)J=re[pe],ee.push(J>>8),ee.push(J&255);return ee},z.prototype.toFixedLengthString=function(){let J=(function(){let re=[];for(let pe=0;pe<this.parts.length;pe++)re.push(he(this.parts[pe].toString(16),4));return re}).call(this).join(":"),ee="";return this.zoneId&&(ee=`%${this.zoneId}`),J+ee},z.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let J=this.parts.slice(-2),ee=J[0],re=J[1];return new Pe.IPv4([ee>>8,ee&255,re>>8,re&255])},z.prototype.toNormalizedString=function(){let J=(function(){let re=[];for(let pe=0;pe<this.parts.length;pe++)re.push(this.parts[pe].toString(16));return re}).call(this).join(":"),ee="";return this.zoneId&&(ee=`%${this.zoneId}`),J+ee},z.prototype.toRFC5952String=function(){let J=/((^|:)(0(:|$)){2,})/g,ee=this.toNormalizedString(),re=0,pe=-1,me;for(;me=J.exec(ee);)me[0].length>pe&&(re=me.index,pe=me[0].length);return pe<0?ee:`${ee.substring(0,re)}::${ee.substring(re+pe)}`},z.prototype.toString=function(){return this.toRFC5952String()},z})(),Pe.IPv6.broadcastAddressFromCIDR=function(z){try{let J=this.parseCIDR(z),ee=J[0].toByteArray(),re=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],me=0;for(;me<16;)pe.push(parseInt(ee[me],10)|parseInt(re[me],10)^255),me++;return new this(pe)}catch(J){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${J})`)}},Pe.IPv6.isIPv6=function(z){return this.parser(z)!==null},Pe.IPv6.isValid=function(z){if(typeof z=="string"&&z.indexOf(":")===-1)return!1;try{let J=this.parser(z);return new this(J.parts,J.zoneId),!0}catch{return!1}},Pe.IPv6.isValidCIDR=function(z){if(typeof z=="string"&&z.indexOf(":")===-1)return!1;try{return this.parseCIDR(z),!0}catch{return!1}},Pe.IPv6.networkAddressFromCIDR=function(z){let J,ee,re,pe,me;try{for(J=this.parseCIDR(z),re=J[0].toByteArray(),me=this.subnetMaskFromPrefixLength(J[1]).toByteArray(),pe=[],ee=0;ee<16;)pe.push(parseInt(re[ee],10)&parseInt(me[ee],10)),ee++;return new this(pe)}catch(We){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${We})`)}},Pe.IPv6.parse=function(z){let J=this.parser(z);if(J.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(J.parts,J.zoneId)},Pe.IPv6.parseCIDR=function(z){let J,ee,re;if((ee=z.match(/^(.+)\/(\d+)$/))&&(J=parseInt(ee[2]),J>=0&&J<=128))return re=[this.parse(ee[1]),J],Object.defineProperty(re,"toString",{value:l(function(){return this.join("/")},"value")}),re;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},Pe.IPv6.parser=function(z){let J,ee,re,pe,me,We;if(re=z.match(B.deprecatedTransitional))return this.parser(`::ffff:${re[1]}`);if(B.native.test(z))return Y(z,8);if((re=z.match(B.transitional))&&(We=re[6]||"",J=re[1],re[1].endsWith("::")||(J=J.slice(0,-1)),J=Y(J+We,6),J.parts)){for(me=[parseInt(re[2]),parseInt(re[3]),parseInt(re[4]),parseInt(re[5])],ee=0;ee<me.length;ee++)if(pe=me[ee],!(0<=pe&&pe<=255))return null;return J.parts.push(me[0]<<8|me[1]),J.parts.push(me[2]<<8|me[3]),{parts:J.parts,zoneId:J.zoneId}}return null},Pe.IPv6.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>128)throw new Error("ipaddr: invalid IPv6 prefix length");let J=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ee=0,re=Math.floor(z/8);for(;ee<re;)J[ee]=255,ee++;return re<16&&(J[re]=Math.pow(2,z%8)-1<<8-z%8),new this(J)},Pe.fromByteArray=function(z){let J=z.length;if(J===4)return new Pe.IPv4(z);if(J===16)return new Pe.IPv6(z);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},Pe.isValid=function(z){return Pe.IPv6.isValid(z)||Pe.IPv4.isValid(z)},Pe.isValidCIDR=function(z){return Pe.IPv6.isValidCIDR(z)||Pe.IPv4.isValidCIDR(z)},Pe.parse=function(z){if(Pe.IPv6.isValid(z))return Pe.IPv6.parse(z);if(Pe.IPv4.isValid(z))return Pe.IPv4.parse(z);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},Pe.parseCIDR=function(z){try{return Pe.IPv6.parseCIDR(z)}catch{try{return Pe.IPv4.parseCIDR(z)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},Pe.process=function(z){let J=this.parse(z);return J.kind()==="ipv6"&&J.isIPv4MappedAddress()?J.toIPv4Address():J},Pe.subnetMatch=function(z,J,ee){let re,pe,me,We;ee==null&&(ee="unicast");for(pe in J)if(Object.prototype.hasOwnProperty.call(J,pe)){for(me=J[pe],me[0]&&!(me[0]instanceof Array)&&(me=[me]),re=0;re<me.length;re++)if(We=me[re],z.kind()===We[0].kind()&&z.match.apply(z,We))return pe}return ee},typeof xs<"u"&&xs.exports?xs.exports=Pe:u.ipaddr=Pe})(gp)});var yh=qo((UM,_h)=>{var ys=l(u=>u instanceof Date,"isDate"),yF=l((u,s)=>{let i={},r=s||".";if(typeof u!="object"||ys(u))return u;let A=l((M,L,B)=>{if(!Object.values(M).length&&B)return i[B]=M,M;Object.entries(M).forEach(([Y,te])=>{let Te=B?B+r+Y:Y;if(typeof te=="object"&&te!==null&&(L.forEach(he=>{te===he&&!ys(te)&&(te="[Circular]")}),L.push(te),typeof te=="object"&&!ys(te)))return A(te,L,Te);i[Te]=te})},"flat");return A(u,[u]),i},"flatten"),EF=l((u,s)=>{let i={},r=s||".",A=["__proto__","constructor","prototype"];return typeof u!="object"||ys(u)?u:(l(L=>{Object.keys(L).forEach(B=>{let Y=B.split(r);Y.reduce((te,Te,he)=>A.includes(Y[he])?te:te[Te]||(te[Te]=isNaN(Number(Y[he+1]))?Y.length-1===he?L[B]:{}:[]),i)})},"unflat")(u),i)},"unflatten");_h.exports={flatten:yF,unflatten:EF}});var bh=qo((Ih,Li)=>{var Pr={version:"1.15.0"};Pr[437]=(function(){for(var u=`\0\x07\b
2
2
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~\x7F\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0`,s=[],i={},r=0;r!=u.length;++r)u.charCodeAt(r)!==65533&&(i[u.charAt(r)]=r),s[r]=u.charAt(r);return{enc:i,dec:s}})();Pr[620]=(function(){for(var u=`\0\x07\b
3
3
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~\x7F\xC7\xFC\xE9\xE2\xE4\xE0\u0105\xE7\xEA\xEB\xE8\xEF\xEE\u0107\xC4\u0104\u0118\u0119\u0142\xF4\xF6\u0106\xFB\xF9\u015A\xD6\xDC\xA2\u0141\xA5\u015B\u0192\u0179\u017B\xF3\xD3\u0144\u0143\u017A\u017C\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0`,s=[],i={},r=0;r!=u.length;++r)u.charCodeAt(r)!==65533&&(i[u.charAt(r)]=r),s[r]=u.charAt(r);return{enc:i,dec:s}})();Pr[737]=(function(){for(var u=`\0\x07\b
4
4
  \v\f\r\x1B !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\`abcdefghijklmnopqrstuvwxyz{|}~\x7F\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E\u038F\xB1\u2265\u2264\u03AA\u03AB\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0`,s=[],i={},r=0;r!=u.length;++r)u.charCodeAt(r)!==65533&&(i[u.charAt(r)]=r),s[r]=u.charAt(r);return{enc:i,dec:s}})();Pr[850]=(function(){for(var u=`\0\x07\b
@@ -137,14 +137,14 @@
137
137
  `,p=d.charCodeAt(0),h=new RegExp((c=="|"?"\\|":c)+"+$"),m="",x=[];a.dense=Array.isArray(e);for(var v=a.skipHidden&&e["!cols"]||[],_=a.skipHidden&&e["!rows"]||[],y=o.s.c;y<=o.e.c;++y)(v[y]||{}).hidden||(x[y]=Xr(y));var g=o.s.r,E=!1,k=0;return t._read=function(){if(!E)return E=!0,t.push("\uFEFF");for(;g<=o.e.r;)if(++g,!(_[g-1]||{}).hidden&&(m=zf(e,o,g-1,x,f,p,c,a),m!=null&&(a.strip&&(m=m.replace(h,"")),m||a.blankrows!==!1)))return t.push((k++?d:"")+m);return t.push(null)},t}l(hA,"write_csv_stream");function mA(e,n){var t=Ko(),a=n||{},o=a.header!=null?a.header:df,c=a.footer!=null?a.footer:pf;t.push(o);var f=Ut(e["!ref"]);a.dense=Array.isArray(e),t.push(hf(e,f,a));var d=f.s.r,p=!1;return t._read=function(){if(d>f.e.r)return p||(p=!0,t.push("</table>"+c)),t.push(null);for(;d<=f.e.r;){t.push(ff(e,f,d,a)),++d;break}},t}l(mA,"write_html_stream");function gA(e,n){var t=Ko({objectMode:!0});if(e==null||e["!ref"]==null)return t.push(null),t;var a={t:"n",v:0},o=0,c=1,f=[],d=0,p="",h={s:{r:0,c:0},e:{r:0,c:0}},m=n||{},x=m.range!=null?m.range:e["!ref"];switch(m.header===1?o=1:m.header==="A"?o=2:Array.isArray(m.header)&&(o=3),typeof x){case"string":h=Ir(x);break;case"number":h=Ir(e["!ref"]),h.s.r=x;break;default:h=x}o>0&&(c=0);var v=nt(h.s.r),_=[],y=0,g=Array.isArray(e),E=h.s.r,k=0,I={};g&&!e[E]&&(e[E]=[]);var w=m.skipHidden&&e["!cols"]||[],Z=m.skipHidden&&e["!rows"]||[];for(k=h.s.c;k<=h.e.c;++k)if(!(w[k]||{}).hidden)switch(_[k]=Xr(k),a=g?e[E][k]:e[_[k]+v],o){case 1:f[k]=k-h.s.c;break;case 2:f[k]=_[k];break;case 3:f[k]=m.header[k-h.s.c];break;default:if(a==null&&(a={w:"__EMPTY",t:"s"}),p=d=Sn(a,null,m),y=I[d]||0,!y)I[d]=1;else{do p=d+"_"+y++;while(I[p]);I[d]=y,I[p]=1}f[k]=p}return E=h.s.r+c,t._read=function(){for(;E<=h.e.r;)if(!(Z[E-1]||{}).hidden){var q=Rf(e,h,E,_,o,f,g,m);if(++E,q.isempty===!1||(o===1?m.blankrows!==!1:m.blankrows)){t.push(q.row);return}}return t.push(null)},t}l(gA,"write_json_stream");var jf={to_json:gA,to_html:mA,to_csv:hA,set_readable:Bf};if(typeof Wo<"u"&&(u.parse_xlscfb=Wo),u.parse_zip=Pf,u.read=Ho,u.readFile=Cf,u.readFileSync=Cf,u.write=Go,u.writeFile=Nf,u.writeFileSync=Nf,u.writeFileAsync=iA,u.utils=pA,u.writeXLSX=Cc,u.writeFileXLSX=nA,u.SSF=z0,typeof jf<"u"&&(u.stream=jf),typeof qe<"u"&&(u.CFB=qe),typeof require<"u"){var Vf=require("stream");(Vf||{}).Readable&&Bf(Vf.Readable)}}l(As,"make_xlsx_lib");typeof w0<"u"?As(w0):typeof go<"u"&&go.exports?As(go.exports):typeof define=="function"&&define.amd?define("xlsx",function(){return mo.version||As(mo),mo}):As(mo);if(typeof window<"u"&&!window.XLSX)try{window.XLSX=mo}catch{}});var NF={};Xf(NF,{csv:()=>OF});module.exports=zA(NF);var MA=Object.freeze({status:"aborted"});function Xe(u,s,i){function r(B,Y){if(B._zod||Object.defineProperty(B,"_zod",{value:{def:Y,constr:L,traits:new Set},enumerable:!1}),B._zod.traits.has(u))return;B._zod.traits.add(u),s(B,Y);let te=L.prototype,Te=Object.keys(te);for(let he=0;he<Te.length;he++){let Pe=Te[he];Pe in B||(B[Pe]=te[Pe].bind(B))}}l(r,"init");let A=i?.Parent??Object;class M extends A{static{l(this,"Definition")}}Object.defineProperty(M,"name",{value:u});function L(B){var Y;let te=i?.Parent?new M:this;r(te,B),(Y=te._zod).deferred??(Y.deferred=[]);for(let Te of te._zod.deferred)Te();return te}return l(L,"_"),Object.defineProperty(L,"init",{value:r}),Object.defineProperty(L,Symbol.hasInstance,{value:l(B=>i?.Parent&&B instanceof i.Parent?!0:B?._zod?.traits?.has(u),"value")}),Object.defineProperty(L,"name",{value:u}),L}l(Xe,"$constructor");var Cn=class extends Error{static{l(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Yo=class extends Error{static{l(this,"$ZodEncodeError")}constructor(s){super(`Encountered unidirectional transform during encode: ${s}`),this.name="ZodEncodeError"}},Mc={};function jn(u){return u&&Object.assign(Mc,u),Mc}l(jn,"config");function Uc(u){let s=Object.values(u).filter(r=>typeof r=="number");return Object.entries(u).filter(([r,A])=>s.indexOf(+r)===-1).map(([r,A])=>A)}l(Uc,"getEnumValues");function qf(u,s){return typeof s=="bigint"?s.toString():s}l(qf,"jsonStringifyReplacer");function es(u){return{get value(){{let i=u();return Object.defineProperty(this,"value",{value:i}),i}throw new Error("cached value already set")}}}l(es,"cached");function Yf(u){return u==null}l(Yf,"nullish");function rs(u){let s=u.startsWith("^")?1:0,i=u.endsWith("$")?u.length-1:u.length;return u.slice(s,i)}l(rs,"cleanRegex");var Jf=Symbol("evaluating");function gt(u,s,i){let r;Object.defineProperty(u,s,{get(){if(r!==Jf)return r===void 0&&(r=Jf,r=i()),r},set(A){Object.defineProperty(u,s,{value:A})},configurable:!0})}l(gt,"defineLazy");var Bc="captureStackTrace"in Error?Error.captureStackTrace:(...u)=>{};function Xa(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}l(Xa,"isObject");var LA=es(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let u=Function;return new u(""),!0}catch{return!1}});function Qf(u){if(Xa(u)===!1)return!1;let s=u.constructor;if(s===void 0||typeof s!="function")return!0;let i=s.prototype;return!(Xa(i)===!1||Object.prototype.hasOwnProperty.call(i,"isPrototypeOf")===!1)}l(Qf,"isPlainObject");var ed=new Set(["string","number","symbol"]);function na(u){return u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}l(na,"escapeRegex");function ts(u,s,i){let r=new u._zod.constr(s??u._zod.def);return(!s||i?.parent)&&(r._zod.parent=u),r}l(ts,"clone");function Jr(u){let s=u;if(!s)return{};if(typeof s=="string")return{error:l(()=>s,"error")};if(s?.message!==void 0){if(s?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");s.error=s.message}return delete s.message,typeof s.error=="string"?{...s,error:l(()=>s.error,"error")}:s}l(Jr,"normalizeParams");function rd(u){return Object.keys(u).filter(s=>u[s]._zod.optin==="optional"&&u[s]._zod.optout==="optional")}l(rd,"optionalKeys");var td={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ia(u,s=0){if(u.aborted===!0)return!0;for(let i=s;i<u.issues.length;i++)if(u.issues[i]?.continue!==!0)return!0;return!1}l(ia,"aborted");function ai(u,s){return s.map(i=>{var r;return(r=i).path??(r.path=[]),i.path.unshift(u),i})}l(ai,"prefixIssues");function Qo(u){return typeof u=="string"?u:u?.message}l(Qo,"unwrapMessage");function oi(u,s,i){let r={...u,path:u.path??[]};if(!u.message){let A=Qo(u.inst?._zod.def?.error?.(u))??Qo(s?.error?.(u))??Qo(i.customError?.(u))??Qo(i.localeError?.(u))??"Invalid input";r.message=A}return delete r.inst,delete r.continue,s?.reportInput||delete r.input,r}l(oi,"finalizeIssue");function nd(u){return Array.isArray(u)?"array":typeof u=="string"?"string":"unknown"}l(nd,"getLengthableOrigin");function jc(...u){let[s,i,r]=u;return typeof s=="string"?{message:s,code:"custom",input:i,inst:r}:{...s}}l(jc,"issue");var id=l((u,s)=>{u.name="$ZodError",Object.defineProperty(u,"_zod",{value:u._zod,enumerable:!1}),Object.defineProperty(u,"issues",{value:s,enumerable:!1}),u.message=JSON.stringify(s,qf,2),Object.defineProperty(u,"toString",{value:l(()=>u.message,"value"),enumerable:!1})},"initializer"),ad=Xe("$ZodError",id),Ka=Xe("$ZodError",id,{Parent:Error});var BA=l(u=>(s,i,r,A)=>{let M=r?Object.assign(r,{async:!1}):{async:!1},L=s._zod.run({value:i,issues:[]},M);if(L instanceof Promise)throw new Cn;if(L.issues.length){let B=new(A?.Err??u)(L.issues.map(Y=>oi(Y,M,jn())));throw Bc(B,A?.callee),B}return L.value},"_parse"),ns=BA(Ka),jA=l(u=>async(s,i,r,A)=>{let M=r?Object.assign(r,{async:!0}):{async:!0},L=s._zod.run({value:i,issues:[]},M);if(L instanceof Promise&&(L=await L),L.issues.length){let B=new(A?.Err??u)(L.issues.map(Y=>oi(Y,M,jn())));throw Bc(B,A?.callee),B}return L.value},"_parseAsync"),is=jA(Ka),VA=l(u=>(s,i,r)=>{let A=r?{...r,async:!1}:{async:!1},M=s._zod.run({value:i,issues:[]},A);if(M instanceof Promise)throw new Cn;return M.issues.length?{success:!1,error:new(u??ad)(M.issues.map(L=>oi(L,A,jn())))}:{success:!0,data:M.value}},"_safeParse"),Ja=VA(Ka),WA=l(u=>async(s,i,r)=>{let A=r?Object.assign(r,{async:!0}):{async:!0},M=s._zod.run({value:i,issues:[]},A);return M instanceof Promise&&(M=await M),M.issues.length?{success:!1,error:new u(M.issues.map(L=>oi(L,A,jn())))}:{success:!0,data:M.value}},"_safeParseAsync"),qa=WA(Ka);var HA="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ZA=new RegExp(`^${HA}$`);var od=l(u=>{let s=u?`[\\s\\S]{${u?.minimum??0},${u?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${s}$`)},"string"),sd=/^-?\d+n?$/,cd=/^-?\d+$/,Vc=/^-?\d+(?:\.\d+)?$/,ud=/^(?:true|false)$/i;var si=Xe("$ZodCheck",(u,s)=>{var i;u._zod??(u._zod={}),u._zod.def=s,(i=u._zod).onattach??(i.onattach=[])}),GA={number:"number",bigint:"bigint",object:"date"};var ld=Xe("$ZodCheckGreaterThan",(u,s)=>{si.init(u,s);let i=GA[typeof s.value];u._zod.onattach.push(r=>{let A=r._zod.bag,M=(s.inclusive?A.minimum:A.exclusiveMinimum)??Number.NEGATIVE_INFINITY;s.value>M&&(s.inclusive?A.minimum=s.value:A.exclusiveMinimum=s.value)}),u._zod.check=r=>{(s.inclusive?r.value>=s.value:r.value>s.value)||r.issues.push({origin:i,code:"too_small",minimum:typeof s.value=="object"?s.value.getTime():s.value,input:r.value,inclusive:s.inclusive,inst:u,continue:!s.abort})}});var fd=Xe("$ZodCheckNumberFormat",(u,s)=>{si.init(u,s),s.format=s.format||"float64";let i=s.format?.includes("int"),r=i?"int":"number",[A,M]=td[s.format];u._zod.onattach.push(L=>{let B=L._zod.bag;B.format=s.format,B.minimum=A,B.maximum=M,i&&(B.pattern=cd)}),u._zod.check=L=>{let B=L.value;if(i){if(!Number.isInteger(B)){L.issues.push({expected:r,format:s.format,code:"invalid_type",continue:!1,input:B,inst:u});return}if(!Number.isSafeInteger(B)){B>0?L.issues.push({input:B,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:u,origin:r,inclusive:!0,continue:!s.abort}):L.issues.push({input:B,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:u,origin:r,inclusive:!0,continue:!s.abort});return}}B<A&&L.issues.push({origin:"number",input:B,code:"too_small",minimum:A,inclusive:!0,inst:u,continue:!s.abort}),B>M&&L.issues.push({origin:"number",input:B,code:"too_big",maximum:M,inclusive:!0,inst:u,continue:!s.abort})}});var dd=Xe("$ZodCheckMinLength",(u,s)=>{var i;si.init(u,s),(i=u._zod.def).when??(i.when=r=>{let A=r.value;return!Yf(A)&&A.length!==void 0}),u._zod.onattach.push(r=>{let A=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;s.minimum>A&&(r._zod.bag.minimum=s.minimum)}),u._zod.check=r=>{let A=r.value;if(A.length>=s.minimum)return;let L=nd(A);r.issues.push({origin:L,code:"too_small",minimum:s.minimum,inclusive:!0,input:A,inst:u,continue:!s.abort})}});var Wc=Xe("$ZodCheckStringFormat",(u,s)=>{var i,r;si.init(u,s),u._zod.onattach.push(A=>{let M=A._zod.bag;M.format=s.format,s.pattern&&(M.patterns??(M.patterns=new Set),M.patterns.add(s.pattern))}),s.pattern?(i=u._zod).check??(i.check=A=>{s.pattern.lastIndex=0,!s.pattern.test(A.value)&&A.issues.push({origin:"string",code:"invalid_format",format:s.format,input:A.value,...s.pattern?{pattern:s.pattern.toString()}:{},inst:u,continue:!s.abort})}):(r=u._zod).check??(r.check=()=>{})}),pd=Xe("$ZodCheckRegex",(u,s)=>{Wc.init(u,s),u._zod.check=i=>{s.pattern.lastIndex=0,!s.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:"regex",input:i.value,pattern:s.pattern.toString(),inst:u,continue:!s.abort})}});var md={major:4,minor:3,patch:6};var at=Xe("$ZodType",(u,s)=>{var i;u??(u={}),u._zod.def=s,u._zod.bag=u._zod.bag||{},u._zod.version=md;let r=[...u._zod.def.checks??[]];u._zod.traits.has("$ZodCheck")&&r.unshift(u);for(let A of r)for(let M of A._zod.onattach)M(u);if(r.length===0)(i=u._zod).deferred??(i.deferred=[]),u._zod.deferred?.push(()=>{u._zod.run=u._zod.parse});else{let A=l((L,B,Y)=>{let te=ia(L),Te;for(let he of B){if(he._zod.def.when){if(!he._zod.def.when(L))continue}else if(te)continue;let Pe=L.issues.length,z=he._zod.check(L);if(z instanceof Promise&&Y?.async===!1)throw new Cn;if(Te||z instanceof Promise)Te=(Te??Promise.resolve()).then(async()=>{await z,L.issues.length!==Pe&&(te||(te=ia(L,Pe)))});else{if(L.issues.length===Pe)continue;te||(te=ia(L,Pe))}}return Te?Te.then(()=>L):L},"runChecks"),M=l((L,B,Y)=>{if(ia(L))return L.aborted=!0,L;let te=A(B,r,Y);if(te instanceof Promise){if(Y.async===!1)throw new Cn;return te.then(Te=>u._zod.parse(Te,Y))}return u._zod.parse(te,Y)},"handleCanaryResult");u._zod.run=(L,B)=>{if(B.skipChecks)return u._zod.parse(L,B);if(B.direction==="backward"){let te=u._zod.parse({value:L.value,issues:[]},{...B,skipChecks:!0});return te instanceof Promise?te.then(Te=>M(Te,L,B)):M(te,L,B)}let Y=u._zod.parse(L,B);if(Y instanceof Promise){if(B.async===!1)throw new Cn;return Y.then(te=>A(te,r,B))}return A(Y,r,B)}}gt(u,"~standard",()=>({validate:l(A=>{try{let M=Ja(u,A);return M.success?{value:M.data}:{issues:M.error?.issues}}catch{return qa(u,A).then(L=>L.success?{value:L.data}:{issues:L.error?.issues})}},"validate"),vendor:"zod",version:1}))}),ss=Xe("$ZodString",(u,s)=>{at.init(u,s),u._zod.pattern=[...u?._zod.bag?.patterns??[]].pop()??od(u._zod.bag),u._zod.parse=(i,r)=>{if(s.coerce)try{i.value=String(i.value)}catch{}return typeof i.value=="string"||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:u}),i}}),Hc=Xe("$ZodStringFormat",(u,s)=>{Wc.init(u,s),ss.init(u,s)});var yd=Xe("$ZodURL",(u,s)=>{Hc.init(u,s),u._zod.check=i=>{try{let r=i.value.trim(),A=new URL(r);s.hostname&&(s.hostname.lastIndex=0,s.hostname.test(A.hostname)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:s.hostname.source,input:i.value,inst:u,continue:!s.abort})),s.protocol&&(s.protocol.lastIndex=0,s.protocol.test(A.protocol.endsWith(":")?A.protocol.slice(0,-1):A.protocol)||i.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:s.protocol.source,input:i.value,inst:u,continue:!s.abort})),s.normalize?i.value=A.href:i.value=r;return}catch{i.issues.push({code:"invalid_format",format:"url",input:i.value,inst:u,continue:!s.abort})}}});var Zc=Xe("$ZodNumber",(u,s)=>{at.init(u,s),u._zod.pattern=u._zod.bag.pattern??Vc,u._zod.parse=(i,r)=>{if(s.coerce)try{i.value=Number(i.value)}catch{}let A=i.value;if(typeof A=="number"&&!Number.isNaN(A)&&Number.isFinite(A))return i;let M=typeof A=="number"?Number.isNaN(A)?"NaN":Number.isFinite(A)?void 0:"Infinity":void 0;return i.issues.push({expected:"number",code:"invalid_type",input:A,inst:u,...M?{received:M}:{}}),i}}),Ed=Xe("$ZodNumberFormat",(u,s)=>{fd.init(u,s),Zc.init(u,s)}),Gc=Xe("$ZodBoolean",(u,s)=>{at.init(u,s),u._zod.pattern=ud,u._zod.parse=(i,r)=>{if(s.coerce)try{i.value=!!i.value}catch{}let A=i.value;return typeof A=="boolean"||i.issues.push({expected:"boolean",code:"invalid_type",input:A,inst:u}),i}}),Td=Xe("$ZodBigInt",(u,s)=>{at.init(u,s),u._zod.pattern=sd,u._zod.parse=(i,r)=>{if(s.coerce)try{i.value=BigInt(i.value)}catch{}return typeof i.value=="bigint"||i.issues.push({expected:"bigint",code:"invalid_type",input:i.value,inst:u}),i}});var Ad=Xe("$ZodAny",(u,s)=>{at.init(u,s),u._zod.parse=i=>i}),wd=Xe("$ZodUnknown",(u,s)=>{at.init(u,s),u._zod.parse=i=>i});var Sd=Xe("$ZodVoid",(u,s)=>{at.init(u,s),u._zod.parse=(i,r)=>{let A=i.value;return typeof A>"u"||i.issues.push({expected:"void",code:"invalid_type",input:A,inst:u}),i}}),Fd=Xe("$ZodDate",(u,s)=>{at.init(u,s),u._zod.parse=(i,r)=>{if(s.coerce)try{i.value=new Date(i.value)}catch{}let A=i.value,M=A instanceof Date;return M&&!Number.isNaN(A.getTime())||i.issues.push({expected:"date",code:"invalid_type",input:A,...M?{received:"Invalid Date"}:{},inst:u}),i}});function gd(u,s,i){u.issues.length&&s.issues.push(...ai(i,u.issues)),s.value[i]=u.value}l(gd,"handleArrayResult");var kd=Xe("$ZodArray",(u,s)=>{at.init(u,s),u._zod.parse=(i,r)=>{let A=i.value;if(!Array.isArray(A))return i.issues.push({expected:"array",code:"invalid_type",input:A,inst:u}),i;i.value=Array(A.length);let M=[];for(let L=0;L<A.length;L++){let B=A[L],Y=s.element._zod.run({value:B,issues:[]},r);Y instanceof Promise?M.push(Y.then(te=>gd(te,i,L))):gd(Y,i,L)}return M.length?Promise.all(M).then(()=>i):i}});function os(u,s,i,r,A){if(u.issues.length){if(A&&!(i in r))return;s.issues.push(...ai(i,u.issues))}u.value===void 0?i in r&&(s.value[i]=void 0):s.value[i]=u.value}l(os,"handlePropertyResult");function XA(u){let s=Object.keys(u.shape);for(let r of s)if(!u.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let i=rd(u.shape);return{...u,keys:s,keySet:new Set(s),numKeys:s.length,optionalKeys:new Set(i)}}l(XA,"normalizeDef");function KA(u,s,i,r,A,M){let L=[],B=A.keySet,Y=A.catchall._zod,te=Y.def.type,Te=Y.optout==="optional";for(let he in s){if(B.has(he))continue;if(te==="never"){L.push(he);continue}let Pe=Y.run({value:s[he],issues:[]},r);Pe instanceof Promise?u.push(Pe.then(z=>os(z,i,he,s,Te))):os(Pe,i,he,s,Te)}return L.length&&i.issues.push({code:"unrecognized_keys",keys:L,input:s,inst:M}),u.length?Promise.all(u).then(()=>i):i}l(KA,"handleCatchall");var Pd=Xe("$ZodObject",(u,s)=>{if(at.init(u,s),!Object.getOwnPropertyDescriptor(s,"shape")?.get){let B=s.shape;Object.defineProperty(s,"shape",{get:l(()=>{let Y={...B};return Object.defineProperty(s,"shape",{value:Y}),Y},"get")})}let r=es(()=>XA(s));gt(u._zod,"propValues",()=>{let B=s.shape,Y={};for(let te in B){let Te=B[te]._zod;if(Te.values){Y[te]??(Y[te]=new Set);for(let he of Te.values)Y[te].add(he)}}return Y});let A=Xa,M=s.catchall,L;u._zod.parse=(B,Y)=>{L??(L=r.value);let te=B.value;if(!A(te))return B.issues.push({expected:"object",code:"invalid_type",input:te,inst:u}),B;B.value={};let Te=[],he=L.shape;for(let Pe of L.keys){let z=he[Pe],J=z._zod.optout==="optional",ee=z._zod.run({value:te[Pe],issues:[]},Y);ee instanceof Promise?Te.push(ee.then(re=>os(re,B,Pe,te,J))):os(ee,B,Pe,te,J)}return M?KA(Te,te,B,Y,r.value,u):Te.length?Promise.all(Te).then(()=>B):B}});function xd(u,s,i,r){for(let M of u)if(M.issues.length===0)return s.value=M.value,s;let A=u.filter(M=>!ia(M));return A.length===1?(s.value=A[0].value,A[0]):(s.issues.push({code:"invalid_union",input:s.value,inst:i,errors:u.map(M=>M.issues.map(L=>oi(L,r,jn())))}),s)}l(xd,"handleUnionResults");var Xc=Xe("$ZodUnion",(u,s)=>{at.init(u,s),gt(u._zod,"optin",()=>s.options.some(A=>A._zod.optin==="optional")?"optional":void 0),gt(u._zod,"optout",()=>s.options.some(A=>A._zod.optout==="optional")?"optional":void 0),gt(u._zod,"values",()=>{if(s.options.every(A=>A._zod.values))return new Set(s.options.flatMap(A=>Array.from(A._zod.values)))}),gt(u._zod,"pattern",()=>{if(s.options.every(A=>A._zod.pattern)){let A=s.options.map(M=>M._zod.pattern);return new RegExp(`^(${A.map(M=>rs(M.source)).join("|")})$`)}});let i=s.options.length===1,r=s.options[0]._zod.run;u._zod.parse=(A,M)=>{if(i)return r(A,M);let L=!1,B=[];for(let Y of s.options){let te=Y._zod.run({value:A.value,issues:[]},M);if(te instanceof Promise)B.push(te),L=!0;else{if(te.issues.length===0)return te;B.push(te)}}return L?Promise.all(B).then(Y=>xd(Y,A,u,M)):xd(B,A,u,M)}});var Id=Xe("$ZodDiscriminatedUnion",(u,s)=>{s.inclusive=!1,Xc.init(u,s);let i=u._zod.parse;gt(u._zod,"propValues",()=>{let A={};for(let M of s.options){let L=M._zod.propValues;if(!L||Object.keys(L).length===0)throw new Error(`Invalid discriminated union option at index "${s.options.indexOf(M)}"`);for(let[B,Y]of Object.entries(L)){A[B]||(A[B]=new Set);for(let te of Y)A[B].add(te)}}return A});let r=es(()=>{let A=s.options,M=new Map;for(let L of A){let B=L._zod.propValues?.[s.discriminator];if(!B||B.size===0)throw new Error(`Invalid discriminated union option at index "${s.options.indexOf(L)}"`);for(let Y of B){if(M.has(Y))throw new Error(`Duplicate discriminator value "${String(Y)}"`);M.set(Y,L)}}return M});u._zod.parse=(A,M)=>{let L=A.value;if(!Xa(L))return A.issues.push({code:"invalid_type",expected:"object",input:L,inst:u}),A;let B=r.value.get(L?.[s.discriminator]);return B?B._zod.run(A,M):s.unionFallback?i(A,M):(A.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:s.discriminator,input:L,path:[s.discriminator],inst:u}),A)}});var bd=Xe("$ZodRecord",(u,s)=>{at.init(u,s),u._zod.parse=(i,r)=>{let A=i.value;if(!Qf(A))return i.issues.push({expected:"record",code:"invalid_type",input:A,inst:u}),i;let M=[],L=s.keyType._zod.values;if(L){i.value={};let B=new Set;for(let te of L)if(typeof te=="string"||typeof te=="number"||typeof te=="symbol"){B.add(typeof te=="number"?te.toString():te);let Te=s.valueType._zod.run({value:A[te],issues:[]},r);Te instanceof Promise?M.push(Te.then(he=>{he.issues.length&&i.issues.push(...ai(te,he.issues)),i.value[te]=he.value})):(Te.issues.length&&i.issues.push(...ai(te,Te.issues)),i.value[te]=Te.value)}let Y;for(let te in A)B.has(te)||(Y=Y??[],Y.push(te));Y&&Y.length>0&&i.issues.push({code:"unrecognized_keys",input:A,inst:u,keys:Y})}else{i.value={};for(let B of Reflect.ownKeys(A)){if(B==="__proto__")continue;let Y=s.keyType._zod.run({value:B,issues:[]},r);if(Y instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof B=="string"&&Vc.test(B)&&Y.issues.length){let he=s.keyType._zod.run({value:Number(B),issues:[]},r);if(he instanceof Promise)throw new Error("Async schemas not supported in object keys currently");he.issues.length===0&&(Y=he)}if(Y.issues.length){s.mode==="loose"?i.value[B]=A[B]:i.issues.push({code:"invalid_key",origin:"record",issues:Y.issues.map(he=>oi(he,r,jn())),input:B,path:[B],inst:u});continue}let Te=s.valueType._zod.run({value:A[B],issues:[]},r);Te instanceof Promise?M.push(Te.then(he=>{he.issues.length&&i.issues.push(...ai(B,he.issues)),i.value[Y.value]=he.value})):(Te.issues.length&&i.issues.push(...ai(B,Te.issues)),i.value[Y.value]=Te.value)}}return M.length?Promise.all(M).then(()=>i):i}});var Cd=Xe("$ZodEnum",(u,s)=>{at.init(u,s);let i=Uc(s.entries),r=new Set(i);u._zod.values=r,u._zod.pattern=new RegExp(`^(${i.filter(A=>ed.has(typeof A)).map(A=>typeof A=="string"?na(A):A.toString()).join("|")})$`),u._zod.parse=(A,M)=>{let L=A.value;return r.has(L)||A.issues.push({code:"invalid_value",values:i,input:L,inst:u}),A}}),Dd=Xe("$ZodLiteral",(u,s)=>{if(at.init(u,s),s.values.length===0)throw new Error("Cannot create literal schema with no valid values");let i=new Set(s.values);u._zod.values=i,u._zod.pattern=new RegExp(`^(${s.values.map(r=>typeof r=="string"?na(r):r?na(r.toString()):String(r)).join("|")})$`),u._zod.parse=(r,A)=>{let M=r.value;return i.has(M)||r.issues.push({code:"invalid_value",values:s.values,input:M,inst:u}),r}});var Od=Xe("$ZodTransform",(u,s)=>{at.init(u,s),u._zod.parse=(i,r)=>{if(r.direction==="backward")throw new Yo(u.constructor.name);let A=s.transform(i.value,i);if(r.async)return(A instanceof Promise?A:Promise.resolve(A)).then(L=>(i.value=L,i));if(A instanceof Promise)throw new Cn;return i.value=A,i}});function vd(u,s){return u.issues.length&&s===void 0?{issues:[],value:void 0}:u}l(vd,"handleOptionalResult");var Nd=Xe("$ZodOptional",(u,s)=>{at.init(u,s),u._zod.optin="optional",u._zod.optout="optional",gt(u._zod,"values",()=>s.innerType._zod.values?new Set([...s.innerType._zod.values,void 0]):void 0),gt(u._zod,"pattern",()=>{let i=s.innerType._zod.pattern;return i?new RegExp(`^(${rs(i.source)})?$`):void 0}),u._zod.parse=(i,r)=>{if(s.innerType._zod.optin==="optional"){let A=s.innerType._zod.run(i,r);return A instanceof Promise?A.then(M=>vd(M,i.value)):vd(A,i.value)}return i.value===void 0?i:s.innerType._zod.run(i,r)}});var Rd=Xe("$ZodNullable",(u,s)=>{at.init(u,s),gt(u._zod,"optin",()=>s.innerType._zod.optin),gt(u._zod,"optout",()=>s.innerType._zod.optout),gt(u._zod,"pattern",()=>{let i=s.innerType._zod.pattern;return i?new RegExp(`^(${rs(i.source)}|null)$`):void 0}),gt(u._zod,"values",()=>s.innerType._zod.values?new Set([...s.innerType._zod.values,null]):void 0),u._zod.parse=(i,r)=>i.value===null?i:s.innerType._zod.run(i,r)});var $d=Xe("$ZodPipe",(u,s)=>{at.init(u,s),gt(u._zod,"values",()=>s.in._zod.values),gt(u._zod,"optin",()=>s.in._zod.optin),gt(u._zod,"optout",()=>s.out._zod.optout),gt(u._zod,"propValues",()=>s.in._zod.propValues),u._zod.parse=(i,r)=>{if(r.direction==="backward"){let M=s.out._zod.run(i,r);return M instanceof Promise?M.then(L=>as(L,s.in,r)):as(M,s.in,r)}let A=s.in._zod.run(i,r);return A instanceof Promise?A.then(M=>as(M,s.out,r)):as(A,s.out,r)}});function as(u,s,i){return u.issues.length?(u.aborted=!0,u):s._zod.run({value:u.value,issues:u.issues},i)}l(as,"handlePipeResult");var zd=Xe("$ZodCustom",(u,s)=>{si.init(u,s),at.init(u,s),u._zod.parse=(i,r)=>i,u._zod.check=i=>{let r=i.value,A=s.fn(r);if(A instanceof Promise)return A.then(M=>_d(M,i,r,u));_d(A,i,r,u)}});function _d(u,s,i,r){if(!u){let A={code:"custom",input:i,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(A.params=r._zod.def.params),s.issues.push(jc(A))}}l(_d,"handleRefineResult");var Ld;var Kc=class{static{l(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(s,...i){let r=i[0];return this._map.set(s,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,s),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(s){let i=this._map.get(s);return i&&typeof i=="object"&&"id"in i&&this._idmap.delete(i.id),this._map.delete(s),this}get(s){let i=s._zod.parent;if(i){let r={...this.get(i)??{}};delete r.id;let A={...r,...this._map.get(s)};return Object.keys(A).length?A:void 0}return this._map.get(s)}has(s){return this._map.has(s)}};function Ud(){return new Kc}l(Ud,"registry");(Ld=globalThis).__zod_globalRegistry??(Ld.__zod_globalRegistry=Ud());var Jc=globalThis.__zod_globalRegistry;function Bd(u,s){return new u({type:"string",...Jr(s)})}l(Bd,"_string");function jd(u,s){return new u({type:"string",coerce:!0,...Jr(s)})}l(jd,"_coercedString");function Vd(u,s){return new u({type:"string",format:"url",check:"string_format",abort:!1,...Jr(s)})}l(Vd,"_url");function Wd(u,s){return new u({type:"number",checks:[],...Jr(s)})}l(Wd,"_number");function Hd(u,s){return new u({type:"number",coerce:!0,checks:[],...Jr(s)})}l(Hd,"_coercedNumber");function Zd(u,s){return new u({type:"number",check:"number_format",abort:!1,format:"safeint",...Jr(s)})}l(Zd,"_int");function Gd(u,s){return new u({type:"boolean",...Jr(s)})}l(Gd,"_boolean");function Xd(u,s){return new u({type:"boolean",coerce:!0,...Jr(s)})}l(Xd,"_coercedBoolean");function Kd(u,s){return new u({type:"bigint",coerce:!0,...Jr(s)})}l(Kd,"_coercedBigint");function Jd(u){return new u({type:"any"})}l(Jd,"_any");function qd(u){return new u({type:"unknown"})}l(qd,"_unknown");function Yd(u,s){return new u({type:"void",...Jr(s)})}l(Yd,"_void");function Qd(u,s){return new u({type:"date",coerce:!0,...Jr(s)})}l(Qd,"_coercedDate");function cs(u,s){return new ld({check:"greater_than",...Jr(s),value:u,inclusive:!0})}l(cs,"_gte");function yn(u,s){return new dd({check:"min_length",...Jr(s),minimum:u})}l(yn,"_minLength");function ci(u,s){return new pd({check:"string_format",format:"regex",...Jr(s),pattern:u})}l(ci,"_regex");function ep(u,s,i){let r=Jr(i);return r.abort??(r.abort=!0),new u({type:"custom",check:"custom",fn:s,...r})}l(ep,"_custom");var xt=Xe("ZodMiniType",(u,s)=>{if(!u._zod)throw new Error("Uninitialized schema in ZodMiniType.");at.init(u,s),u.def=s,u.type=s.type,u.parse=(i,r)=>ns(u,i,r,{callee:u.parse}),u.safeParse=(i,r)=>Ja(u,i,r),u.parseAsync=async(i,r)=>is(u,i,r,{callee:u.parseAsync}),u.safeParseAsync=async(i,r)=>qa(u,i,r),u.check=(...i)=>u.clone({...s,checks:[...s.checks??[],...i.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0}),u.with=u.check,u.clone=(i,r)=>ts(u,i,r),u.brand=()=>u,u.register=((i,r)=>(i.add(u,r),u)),u.apply=i=>i(u)}),ls=Xe("ZodMiniString",(u,s)=>{ss.init(u,s),xt.init(u,s)});function P(u){return Bd(ls,u)}l(P,"string");var rp=Xe("ZodMiniStringFormat",(u,s)=>{Hc.init(u,s),ls.init(u,s)});var cw=Xe("ZodMiniURL",(u,s)=>{yd.init(u,s),rp.init(u,s)});function tp(u){return Vd(cw,u)}l(tp,"url");var fs=Xe("ZodMiniNumber",(u,s)=>{Zc.init(u,s),xt.init(u,s)});function Vt(u){return Wd(fs,u)}l(Vt,"number");var uw=Xe("ZodMiniNumberFormat",(u,s)=>{Ed.init(u,s),fs.init(u,s)});function np(u){return Zd(uw,u)}l(np,"int");var qc=Xe("ZodMiniBoolean",(u,s)=>{Gc.init(u,s),xt.init(u,s)});function $r(u){return Gd(qc,u)}l($r,"boolean");var ip=Xe("ZodMiniBigInt",(u,s)=>{Td.init(u,s),xt.init(u,s)});var lw=Xe("ZodMiniAny",(u,s)=>{Ad.init(u,s),xt.init(u,s)});function Qa(){return Jd(lw)}l(Qa,"any");var fw=Xe("ZodMiniUnknown",(u,s)=>{wd.init(u,s),xt.init(u,s)});function lr(){return qd(fw)}l(lr,"unknown");var dw=Xe("ZodMiniVoid",(u,s)=>{Sd.init(u,s),xt.init(u,s)});function ap(u){return Yd(dw,u)}l(ap,"_void");var op=Xe("ZodMiniDate",(u,s)=>{Fd.init(u,s),xt.init(u,s)});var pw=Xe("ZodMiniArray",(u,s)=>{kd.init(u,s),xt.init(u,s)});function vr(u,s){return new pw({type:"array",element:u,...Jr(s)})}l(vr,"array");var hw=Xe("ZodMiniObject",(u,s)=>{Pd.init(u,s),xt.init(u,s),gt(u,"shape",()=>s.shape)});function Q(u,s){let i={type:"object",shape:u??{},...Jr(s)};return new hw(i)}l(Q,"object");var mw=Xe("ZodMiniUnion",(u,s)=>{Xc.init(u,s),xt.init(u,s)});function _r(u,s){return new mw({type:"union",options:u,...Jr(s)})}l(_r,"union");var gw=Xe("ZodMiniDiscriminatedUnion",(u,s)=>{Id.init(u,s),xt.init(u,s)});function ui(u,s,i){return new gw({type:"union",options:s,discriminator:u,...Jr(i)})}l(ui,"discriminatedUnion");var xw=Xe("ZodMiniRecord",(u,s)=>{bd.init(u,s),xt.init(u,s)});function fr(u,s,i){return new xw({type:"record",keyType:u,valueType:s,...Jr(i)})}l(fr,"record");var vw=Xe("ZodMiniEnum",(u,s)=>{Cd.init(u,s),xt.init(u,s),u.options=Object.values(s.entries)});function Sr(u,s){let i=Array.isArray(u)?Object.fromEntries(u.map(r=>[r,r])):u;return new vw({type:"enum",entries:i,...Jr(s)})}l(Sr,"_enum");var _w=Xe("ZodMiniLiteral",(u,s)=>{Dd.init(u,s),xt.init(u,s)});function tr(u,s){return new _w({type:"literal",values:Array.isArray(u)?u:[u],...Jr(s)})}l(tr,"literal");var yw=Xe("ZodMiniTransform",(u,s)=>{Od.init(u,s),xt.init(u,s)});function li(u){return new yw({type:"transform",transform:u})}l(li,"transform");var Ew=Xe("ZodMiniOptional",(u,s)=>{Nd.init(u,s),xt.init(u,s)});function _e(u){return new Ew({type:"optional",innerType:u})}l(_e,"optional");var Tw=Xe("ZodMiniNullable",(u,s)=>{Rd.init(u,s),xt.init(u,s)});function eo(u){return new Tw({type:"nullable",innerType:u})}l(eo,"nullable");var Aw=Xe("ZodMiniPipe",(u,s)=>{$d.init(u,s),xt.init(u,s)});function fi(u,s){return new Aw({type:"pipe",in:u,out:s})}l(fi,"pipe");var ww=Xe("ZodMiniCustom",(u,s)=>{zd.init(u,s),xt.init(u,s)});function ds(u,s){return ep(ww,u??(()=>!0),s)}l(ds,"custom");var ro={};Xf(ro,{bigint:()=>bw,boolean:()=>Iw,date:()=>Cw,number:()=>Pw,string:()=>kw});function kw(u){return jd(ls,u)}l(kw,"string");function Pw(u){return Hd(fs,u)}l(Pw,"number");function Iw(u){return Xd(qc,u)}l(Iw,"boolean");function bw(u){return Kd(ip,u)}l(bw,"bigint");function Cw(u){return Qd(op,u)}l(Cw,"date");var Qc=Q({retryOnFailure:Q({defaultValue:_e($r()),hide:_e($r())}),continueOnFailure:Q({defaultValue:_e($r()),hide:_e($r())})}),Yc=class{constructor(s,i,r,A,M,L,B,Y,te,Te,he){this.name=s;this.displayName=i;this.description=r;this.props=A;this.run=M;this.test=L;this.requireAuth=B;this.errorHandlingOptions=Y;this.outputSchema=te;this.audience=Te;this.aiMetadata=he}static{l(this,"IAction")}},aa=l(u=>new Yc(u.name,u.displayName,u.description,u.props,u.run,u.test??u.run,u.requireAuth??!0,u.errorHandlingOptions??{continueOnFailure:{defaultValue:!1},retryOnFailure:{defaultValue:!1}},u.outputSchema,u.audience,u.aiMetadata),"createAction");var Rr=Q({displayName:P(),description:_e(P())}),Tr=l((u,s)=>Q({type:tr(s),required:$r(),defaultValue:_e(Qa())}),"TPropertyValue");var en=Q({...Rr.shape,...Tr(P(),"SHORT_TEXT").shape}),Vn=Q({...Rr.shape,...Tr(P(),"LONG_TEXT").shape});var cp=Q({label:P(),value:lr()}),ps=Q({disabled:_e($r()),placeholder:_e(P()),options:vr(cp)});var rn=Q({...Rr.shape,options:ps,...Tr(lr(),"STATIC_DROPDOWN").shape}),Wn=Q({...Rr.shape,options:ps,...Tr(vr(lr()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var e0=Q({...Rr.shape,...Tr(lr(),"DROPDOWN").shape,refreshers:vr(P())}),to=Q({...Rr.shape,...Tr(vr(lr()),"MULTI_SELECT_DROPDOWN").shape,refreshers:vr(P())});var Hn=Q({...Rr.shape,...Tr($r(),"CHECKBOX").shape});var Zn=Q({...Rr.shape,...Tr(Vt(),"NUMBER").shape});var no=Q({...Rr.shape,streaming:_e($r()),...Tr(lr(),"FILE").shape});var io=Q({...Rr.shape,...Tr(P(),"DATE_TIME").shape});var up=fr(P(),_r([en,Vn,rn,to,Wn,Hn,Zn,no,io])),ao=Q({...Rr.shape,properties:up,...Tr(vr(lr()),"ARRAY").shape});var oo=Q({...Rr.shape,...Tr(_r([fr(P(),lr())]),"JSON").shape});var lp=_r([en,rn,oo,ao,Wn]),Ow=fr(P(),lp),r0=Q({refreshers:vr(P()),...Rr.shape,...Tr(lr(),"DYNAMIC").shape});var hs=Q({...Rr.shape,...Tr(ap(),"MARKDOWN").shape});var so=(i=>(i.ARCHIVE="ARCHIVE",i.REGISTRY="REGISTRY",i))(so||{}),oa=(i=>(i.CUSTOM="CUSTOM",i.OFFICIAL="OFFICIAL",i))(oa||{}),sa=(pe=>(pe.ARTIFICIAL_INTELLIGENCE="ARTIFICIAL_INTELLIGENCE",pe.COMMUNICATION="COMMUNICATION",pe.COMMERCE="COMMERCE",pe.CORE="CORE",pe.UNIVERSAL_AI="UNIVERSAL_AI",pe.FLOW_CONTROL="FLOW_CONTROL",pe.BUSINESS_INTELLIGENCE="BUSINESS_INTELLIGENCE",pe.ACCOUNTING="ACCOUNTING",pe.PRODUCTIVITY="PRODUCTIVITY",pe.CONTENT_AND_FILES="CONTENT_AND_FILES",pe.DEVELOPER_TOOLS="DEVELOPER_TOOLS",pe.CUSTOMER_SUPPORT="CUSTOMER_SUPPORT",pe.FORMS_AND_SURVEYS="FORMS_AND_SURVEYS",pe.HUMAN_RESOURCES="HUMAN_RESOURCES",pe.PAYMENT_PROCESSING="PAYMENT_PROCESSING",pe.MARKETING="MARKETING",pe.SALES_AND_CRM="SALES_AND_CRM",pe))(sa||{});var co=(i=>(i.AUTHORIZATION_CODE="authorization_code",i.CLIENT_CREDENTIALS="client_credentials",i))(co||{}),t0="both_client_credentials_and_authorization_code";var Oi=(A=>(A.POLLING="POLLING",A.WEBHOOK="WEBHOOK",A.APP_WEBHOOK="APP_WEBHOOK",A.MANUAL="MANUAL",A))(Oi||{}),uo=(M=>(M.NONE="NONE",M.HEADER_PRESENT="HEADER_PRESENT",M.QUERY_PRESENT="QUERY_PRESENT",M.BODY_PARAM_PRESENT="BODY_PARAM_PRESENT",M.HEAD_REQUEST="HEAD_REQUEST",M))(uo||{}),Nw=Q({strategy:Sr(uo),paramName:_e(P())}),lo=(i=>(i.SIMULATION="SIMULATION",i.TEST_FUNCTION="TEST_FUNCTION",i))(lo||{});var ms=(i=>(i.WEBSOCKET="WEBSOCKET",i.NONE="NONE",i))(ms||{}),fp=Q({status:_e(Vt()),body:_e(lr()),headers:_e(fr(P(),P()))}),dp=Q({type:tr("DELAY"),resumeDateTime:P(),requestIdToReply:_e(P()),handlerId:_e(P()),streamStepProgress:_e(Sr(ms))}),pp=Q({type:tr("WEBHOOK"),requestId:P(),requestIdToReply:_e(P()),response:fp,handlerId:_e(P()),streamStepProgress:_e(Sr(ms))}),Rw=_r([dp,pp]);var $w=Q({body:lr(),rawBody:_e(lr()),headers:fr(P(),P()),queryParams:fr(P(),P())});function fo(u){return u!=null&&typeof u=="string"}l(fo,"isString");var n0=ta(require("crypto"),1);var zw=128,Ri,ca,Mw=l(u=>{!Ri||Ri.length<u?(Ri=Buffer.allocUnsafe(u*zw),n0.default.randomFillSync(Ri),ca=0):ca+u>Ri.length&&(n0.default.randomFillSync(Ri),ca=0),ca+=u},"fillPool"),Lw=l(u=>(Mw(u|=0),Ri.subarray(ca-u,ca)),"random"),Uw=l((u,s,i)=>{let r=(2<<31-Math.clz32(u.length-1|1))-1,A=Math.ceil(1.6*r*s/u.length);return(M=s)=>{let L="";for(;;){let B=i(A),Y=A;for(;Y--;)if(L+=u[B[Y]&r]||"",L.length===M)return L}}},"customRandom"),hp=l((u,s=21)=>Uw(u,s,Lw),"customAlphabet");var Bw="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",mp=21,E8=P().check(ci(new RegExp(`^[0-9a-zA-Z]{${mp}}$`))),jw=hp(Bw,mp);var di=fi(li(u=>u instanceof Date?u.toISOString():u),P()),mn={id:P(),created:di,updated:di},Qr=l(u=>_e(eo(u)),"Nullable");function i0(u){return _e(eo(Sr(u)))}l(i0,"NullableEnum");var w8=fi(li(u=>u==="true"||u===!0?!0:u==="false"||u===!1?!1:void 0),_e($r())),gs=l(u=>fi(li(s=>Array.isArray(s)?s:s!==void 0?[s]:void 0),_e(vr(u))),"OptionalArrayFromQuery");var k8=fr(P(),lr());var po=(Te=>(Te.OPENAI="openai",Te.OPENROUTER="openrouter",Te.ANTHROPIC="anthropic",Te.AZURE="azure",Te.GOOGLE="google",Te.ACTIVEPIECES="activepieces",Te.CLOUDFLARE_GATEWAY="cloudflare-gateway",Te.CUSTOM="custom",Te.BEDROCK="bedrock",Te.MISTRAL="mistral",Te))(po||{});var L8=P().check(ci(/^#[0-9A-Fa-f]{6}$/));var B8=Q({filename:P(),data:lr(),type:tr("file"),mimetype:_e(P())});var Vw=ta(xp());var X8=Q({...mn,name:P(),permissions:vr(P()),platformId:Qr(P()),type:P(),userCount:_e(Vt())});var vp=(r=>(r.AGENT_DECIDE="agent-decide",r.CHOOSE_YOURSELF="choose-yourself",r.LEAVE_EMPTY="leave-empty",r))(vp||{}),a0=(i=>(i.FILE="FILE",i.TABLE="TABLE",i))(a0||{}),o0=(r=>(r.SSE="sse",r.STREAMABLE_HTTP="streamable-http",r.SIMPLE_HTTP="http",r))(o0||{});var s0=(r=>(r.TEXT="text",r.NUMBER="number",r.BOOLEAN="boolean",r))(s0||{});var c0=(i=>(i.IN_PROGRESS="in-progress",i.COMPLETED="completed",i))(c0||{});var Ww=Q({mode:Sr(vp),value:lr()}),Hw=Q({auth:_e(P()),fields:fr(P(),Ww)}),Zw=Q({pieceName:P(),pieceVersion:P(),actionName:P(),predefinedInput:_e(Hw)}),Gw=Q({type:tr("PIECE"),toolName:P().check(yn(1)),pieceMetadata:Zw}),Xw=Q({type:tr("none")}),Kw=Q({type:tr("access_token"),accessToken:P()}),Jw=Q({type:tr("api_key"),apiKey:P(),apiKeyHeader:P()}),qw=Q({type:tr("headers"),headers:fr(P(),P())}),Yw=ui("type",[Xw,Kw,Jw,qw]),_p=Q({type:tr("FLOW"),toolName:P().check(yn(1)),externalFlowId:P(),flowDisplayName:_e(P())}),yp=Q({type:tr("MCP"),toolName:P().check(yn(1)),serverUrl:tp(),protocol:Sr(o0),auth:Yw}),Ep=Q({type:tr("KNOWLEDGE_BASE"),toolName:P().check(yn(1)),sourceType:Sr(a0),sourceId:P(),sourceName:P()}),Qw=ui("type",[Gw,_p,yp,Ep]),eS=Q({displayName:P(),description:_e(P()),type:Sr(s0)}),Tp=Q({type:tr("MARKDOWN"),markdown:P()}),ua={type:tr("TOOL_CALL"),input:Qr(fr(P(),lr())),output:_e(lr()),toolName:P(),status:Sr(c0),toolCallId:P(),startTime:P(),endTime:_e(P())},SN=Q(ua),Ap=ui("toolCallType",[Q({...ua,toolCallType:tr("PIECE"),pieceName:P(),pieceVersion:P(),actionName:P()}),Q({...ua,toolCallType:tr("FLOW"),displayName:P(),externalFlowId:P()}),Q({...ua,toolCallType:tr("MCP"),displayName:P(),serverUrl:P()}),Q({...ua,toolCallType:tr("KNOWLEDGE_BASE"),displayName:P(),sourceType:P()}),Q({...ua,toolCallType:tr("UNKNOWN"),displayName:P()})]),rS=_r([Tp,Ap]);var u0=(i=>(i.IMAGE="image",i.TEXT="text",i))(u0||{}),Gn=Q({apiKey:P()}),tS=Gn,nS=Q({apiKey:P(),apiKeyHash:P()}),iS=Gn,aS=Gn,oS=Gn,sS=Gn,cS=Gn,uS=Gn,lS=Gn,Pp=Q({accessKeyId:P().check(yn(1)),secretAccessKey:P().check(yn(1))}),fS=Q({}),dS=Q({}),pS=Q({}),hS=Q({}),mS=Q({}),gS=Q({}),Ip=Q({modelId:P(),modelName:P(),modelType:Sr(u0)}),bp=Q({apiKeyHeader:P(),baseUrl:P(),models:vr(Ip),defaultHeaders:_e(fr(P(),P()))}),Cp=Q({accountId:P(),gatewayId:P(),models:vr(Ip),vertexProject:_e(P()),vertexRegion:_e(P())}),Dp=Q({resourceName:P(),apiVersion:fi(li(u=>typeof u=="string"&&u.trim().length===0?void 0:u),_e(P()))}),Op=Q({region:P().check(yn(1))}),xS=_r([tS,oS,sS,cS,uS,aS,iS,nS,Pp,lS]),Np=_r([bp,Cp,Dp,Op,fS,pS,hS,mS,dS,gS]),vS=Q({id:P(),name:P(),type:Sr(u0)}),_S=Q({id:P(),name:P(),provider:Sr(po),config:Np,enabledForChat:$r()}),yS=Q({provider:Sr(po),config:Np,auth:xS,platformId:P()});var IN={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"},wp=["gpt-5.5","gpt-5.4-mini","gpt-5.4-nano","gpt-4.1","gpt-4.1-mini"],ES=["claude-sonnet-4-6","claude-opus-4-7","claude-haiku-4-5"],TS=["claude-sonnet-4.6","claude-opus-4.7","claude-haiku-4.5"],Sp=["gemini-2.5-pro","gemini-2.5-flash","gemini-3.1-pro-preview","gemini-3-flash-preview"],AS=["grok-4.20","grok-4.1-fast"],wS={openai:wp,anthropic:ES,google:Sp,activepieces:[...TS.map(u=>`anthropic/${u}`),...wp.map(u=>`openai/${u}`),...Sp.map(u=>`google/${u}`),...AS.map(u=>`x-ai/${u}`)]};var Fp=128e3,SS={openai:128e3,anthropic:2e5,google:1048576,bedrock:2e5,azure:128e3,openrouter:128e3,activepieces:2e5,mistral:128e3};function FS({provider:u}){return u?SS[u]??Fp:Fp}l(FS,"getMaxContextTokens");var kp={openai:"text-embedding-3-small",google:"text-embedding-004",azure:"text-embedding-3-small",activepieces:"text-embedding-3-small",openrouter:"openai/text-embedding-3-small"},kS={anthropic:"native",google:"native",openrouter:"plugin",activepieces:"plugin"},PS=new Set(["anthropic","mistral"]);function Dn(u){return{chatModels:wS[u],maxContextTokens:FS({provider:u}),defaultEmbeddingModel:kp[u],supportsEmbedding:kp[u]!==void 0,supportsImageGeneration:!PS.has(u),webSearch:kS[u]}}l(Dn,"buildProviderCapabilities");var IS={openai:Dn("openai"),anthropic:Dn("anthropic"),openrouter:Dn("openrouter"),azure:Dn("azure"),google:Dn("google"),"cloudflare-gateway":Dn("cloudflare-gateway"),custom:Dn("custom"),bedrock:Dn("bedrock"),mistral:Dn("mistral"),activepieces:Dn("activepieces")};var bS=Q({base64Url:P(),fileName:P(),extension:_e(P())}),CS=Q({mimeType:P(),url:P(),fileName:_e(P())}),l0=_r([bS,CS]);var DS=_r([Q({type:tr("file"),value:l0}),Q({type:tr("markdown"),value:P(),files:_e(vr(l0))})]),OS=Q({sessionId:P(),message:P(),files:_e(vr(P()))});var $p=(i=>(i.ON_NEW_RECORD="ON_NEW_RECORD",i.ON_UPDATE_RECORD="ON_UPDATE_RECORD",i))($p||{}),zp=(i=>(i.ENABLED="ENABLED",i.DISABLED="DISABLED",i))(zp||{}),f0=(r=>(r.RECORD_CREATED="RECORD_CREATED",r.RECORD_UPDATED="RECORD_UPDATED",r.RECORD_DELETED="RECORD_DELETED",r))(f0||{});var NS=_r([Q({...mn,name:P(),externalId:P(),type:tr("STATIC_DROPDOWN"),tableId:P(),projectId:P(),data:Q({options:vr(Q({value:P()}))})}),Q({...mn,name:P(),externalId:P(),type:_r([tr("TEXT"),tr("NUMBER"),tr("DATE")]),tableId:P(),projectId:P()})]),RS=Q({...mn,name:P(),folderId:Qr(P()),projectId:P(),externalId:P(),status:i0(zp),trigger:i0($p)}),$S=Q({...mn,tableId:P(),projectId:P(),cells:fr(P(),Q({updated:P(),created:P(),value:lr(),fieldName:P()}))}),zS=Q({events:vr(Sr(f0)),webhookUrl:P(),flowId:P()}),MS=Q({fields:vr(Q({id:P(),name:P()})),rows:vr(fr(P(),P())),name:P()}),LS=Q({projectId:P(),limit:_e(ro.number()),cursor:_e(P()),name:_e(P()),externalIds:gs(P()),folderId:_e(P()),folderIds:gs(P())}),US=Q({records:vr(vr(Q({fieldId:P(),value:Lp()}))),tableId:P()}),BS=Q({cells:_e(vr(Q({fieldId:P(),value:Lp()}))),tableId:P(),agentUpdate:_e($r())}),Mp=ui("operator",[$i("eq"),$i("neq"),$i("gt"),$i("gte"),$i("lt"),$i("lte"),$i("co"),Rp("exists"),Rp("not_exists")]),jS=Q({tableId:P(),limit:_e(ro.number()),cursor:_e(P()),filters:gs(Mp)});function Lp(){return fi(li(u=>u==null?u:String(u)),eo(P()))}l(Lp,"coerceToString");function $i(u){return Q({fieldId:P(),operator:tr(u),value:P()})}l($i,"valueFilter");function Rp(u){return Q({fieldId:P(),operator:tr(u)})}l(Rp,"existenceFilter");var VS=Q({status:_e(Vt()),body:_e(lr()),headers:_e(fr(P(),P()))}),WS=Q({...mn,deleted:Qr(di),ownerId:P(),displayName:P(),platformId:P(),externalId:Qr(P())});var Up=Q({name:P(),description:_e(P()),type:P(),required:$r()}),HS=Q({pieceName:P(),triggerName:P(),input:Q({toolName:P(),toolDescription:P(),inputSchema:vr(Up),returnsResponse:$r()})});var Bp="^[0-9]+\\.[0-9]+\\.[0-9]+$",XN=new RegExp(Bp),GS="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",KN=P().check(ci(new RegExp(Bp))),JN=P().check(ci(new RegExp(GS))),XS=Q({packageType:tr("ARCHIVE"),pieceType:Sr(oa),pieceName:P(),pieceVersion:P(),archiveId:P(),platformId:P()}),jp=Q({packageType:tr("REGISTRY"),pieceType:tr("OFFICIAL"),pieceName:P(),pieceVersion:P()}),Vp=Q({packageType:tr("REGISTRY"),pieceType:tr("CUSTOM"),pieceName:P(),pieceVersion:P(),platformId:P()}),qN=_r([jp,Vp]),YN=_r([XS,jp,Vp]);var KS=ui("type",[Q({type:tr("CRON_EXPRESSION"),cronExpression:P(),timezone:P()}),Q({type:tr("INTERVAL"),intervalMs:np().check(cs(6e4))})]),QN=Q({...mn,type:Sr(Oi),projectId:P(),flowId:P(),triggerName:P(),schedule:Qr(KS),flowVersionId:P(),pieceName:P(),pieceVersion:P(),deleted:Qr(P()),simulate:$r()}),Wp=(re=>(re.UNKNOWN="UNKNOWN",re.FLOW_RUN_LOG="FLOW_RUN_LOG",re.FLOW_RUN_LOG_SLICE="FLOW_RUN_LOG_SLICE",re.PACKAGE_ARCHIVE="PACKAGE_ARCHIVE",re.FLOW_STEP_FILE="FLOW_STEP_FILE",re.SAMPLE_DATA="SAMPLE_DATA",re.TRIGGER_PAYLOAD="TRIGGER_PAYLOAD",re.SAMPLE_DATA_INPUT="SAMPLE_DATA_INPUT",re.TRIGGER_EVENT_FILE="TRIGGER_EVENT_FILE",re.PROJECT_RELEASE="PROJECT_RELEASE",re.FLOW_VERSION_BACKUP="FLOW_VERSION_BACKUP",re.PLATFORM_ASSET="PLATFORM_ASSET",re.USER_PROFILE_PICTURE="USER_PROFILE_PICTURE",re.WEBHOOK_PAYLOAD="WEBHOOK_PAYLOAD",re.KNOWLEDGE_BASE="KNOWLEDGE_BASE",re.FLOW_BUNDLE="FLOW_BUNDLE",re))(Wp||{}),Hp=(i=>(i.NONE="NONE",i.ZSTD="ZSTD",i))(Hp||{}),Zp=(i=>(i.S3="S3",i.DB="DB",i))(Zp||{}),eR=Q({...mn,projectId:Qr(P()),platformId:Qr(P()),type:Sr(Wp),compression:Sr(Hp),data:_e(lr()),location:Sr(Zp),size:Qr(Vt()),fileName:Qr(P()),s3Key:Qr(P()),metadata:Qr(fr(P(),P()))}),Gp=(r=>(r.ADMIN="ADMIN",r.MEMBER="MEMBER",r.OPERATOR="OPERATOR",r))(Gp||{}),Xp=(i=>(i.ACTIVE="ACTIVE",i.INACTIVE="INACTIVE",i))(Xp||{}),rR=Q({id:P(),email:P(),firstName:P(),status:Sr(Xp),externalId:Qr(P()),platformId:Qr(P()),platformRole:Sr(Gp),lastName:P(),created:di,updated:di,lastActiveDate:Qr(di),imageUrl:Qr(P())});var d0=Q({...Rr.shape,...Tr(fr(P(),lr()),"OBJECT").shape});var Yp=Q({...Rr.shape,...Tr(P(),"COLOR").shape});var p0=_r([en,Vn,hs,Hn,rn,Wn,e0,to,r0,Zn,ao,d0,oo,io,no,Yp]),tn={ShortText(u){return{...u,valueSchema:void 0,type:"SHORT_TEXT"}},Checkbox(u){return{...u,valueSchema:void 0,type:"CHECKBOX"}},LongText(u){return{...u,valueSchema:void 0,type:"LONG_TEXT"}},MarkDown(u){return{displayName:"Markdown",required:!1,description:u.value,type:"MARKDOWN",valueSchema:void 0,variant:u.variant??"INFO"}},Number(u){return{...u,valueSchema:void 0,type:"NUMBER"}},Json(u){return{...u,valueSchema:void 0,type:"JSON"}},Array(u){return{...u,valueSchema:void 0,type:"ARRAY"}},Object(u){return{...u,valueSchema:void 0,type:"OBJECT"}},Dropdown(u){return{...u,valueSchema:void 0,type:"DROPDOWN"}},StaticDropdown(u){return{...u,valueSchema:void 0,type:"STATIC_DROPDOWN"}},MultiSelectDropdown(u){return{...u,valueSchema:void 0,type:"MULTI_SELECT_DROPDOWN"}},DynamicProperties(u){return{...u,valueSchema:void 0,type:"DYNAMIC"}},StaticMultiSelectDropdown(u){return{...u,valueSchema:void 0,type:"STATIC_MULTI_SELECT_DROPDOWN"}},DateTime(u){return{...u,valueSchema:void 0,type:"DATE_TIME"}},File(u){return{...u,valueSchema:void 0,type:"FILE"}},Custom(u){let s=u.code.toString();return{...u,code:s,valueSchema:void 0,type:"CUSTOM"}},Color(u){return{...u,valueSchema:void 0,type:"COLOR"}}};var On=Q({displayName:P(),description:_e(P())});var Qp=Q({username:P(),password:P()}),h0=Q({...On.shape,username:Q({displayName:P(),description:_e(P())}),password:Q({displayName:P(),description:_e(P())}),...Tr(Qp,"BASIC_AUTH").shape});var QS=fr(P(),_r([en,Vn,Zn,Hn,rn])),m0=Q({...On.shape,props:QS,...Tr(lr(),"CUSTOM_AUTH").shape});var zi=Q({...On.shape,...Tr(Q({auth:P()}),"SECRET_TEXT").shape});var eF=fr(P(),_r([en,Vn,zi,Zn,Hn,rn,Wn,hs])),eh=Q({...On.shape,props:eF,...Tr(lr(),"OIDC").shape});var g0=(i=>(i.HEADER="HEADER",i.BODY="BODY",i))(g0||{}),rh=_r([en,zi,rn]),th=fr(P(),rh),rF=Q({props:_e(fr(P(),rh)),authUrl:P(),tokenUrl:P(),scope:vr(P()),prompt:_e(_r([tr("none"),tr("consent"),tr("login"),tr("omit")])),pkce:_e($r()),pkceMethod:_e(_r([tr("plain"),tr("S256")])),authorizationMethod:_e(Sr(g0)),grantType:_e(_r([Sr(co),tr(t0)])),extra:_e(fr(P(),P()))}),nh=Q({access_token:P(),props:_e(th),data:fr(P(),Qa())}),x0=Q({...On.shape,...rF.shape,...Tr(nh,"OAUTH2").shape});var la=_r([h0,m0,eh,x0,zi]),ho="Connection",v0={SecretText(u){return{...u,valueSchema:void 0,type:"SECRET_TEXT"}},OAuth2(u){return{...u,valueSchema:void 0,type:"OAUTH2",displayName:u.displayName||ho}},BasicAuth(u){return{...u,valueSchema:void 0,type:"BASIC_AUTH",displayName:u.displayName||ho,required:!0}},CustomAuth(u){return{...u,valueSchema:void 0,type:"CUSTOM_AUTH",displayName:u.displayName||ho}},OIDC(u){return{...u,valueSchema:void 0,type:"OIDC",displayName:u.displayName||ho}},None(){}};var O5={OAUTH2:"OAUTH2",CLOUD_OAUTH2:"OAUTH2",PLATFORM_OAUTH2:"OAUTH2",BASIC_AUTH:"BASIC_AUTH",CUSTOM_AUTH:"CUSTOM_AUTH",OIDC:"OIDC",SECRET_TEXT:"SECRET_TEXT",NO_AUTH:void 0};var tF=Q({...Rr.shape,...Tr(lr(),"CUSTOM").shape,code:P()});var iF=_r([p0,la]),_0=fr(P(),iF),Q5=fr(P(),p0);var ih=_r([Q({strategy:tr("CRON"),cronExpression:P()}),Q({strategy:tr("NONE")})]);var ah="2",vs="0.82.0";var y0=class{constructor(s,i,r,A,M,L,B,Y,te=vs,Te,he="",Pe){this.displayName=s;this.logoUrl=i;this.authors=r;this.events=A;this.categories=B;this.auth=Y;this.minimumSupportedRelease=te;this.maximumSupportedRelease=Te;this.description=he;this.deprecated=Pe;this._actions={};this._triggers={};this.getContextInfo=l(()=>({version:ah}),"getContextInfo");(!aF(te)||oF(te,vs))&&(this.minimumSupportedRelease=vs),M.forEach(z=>this._actions[z.name]=z),L.forEach(z=>this._triggers[z.name]=z)}static{l(this,"Piece")}metadata(){return{displayName:this.displayName,logoUrl:this.logoUrl,actions:this._actions,triggers:this._triggers,categories:this.categories,description:this.description,authors:this.authors,auth:this.auth,minimumSupportedRelease:this.minimumSupportedRelease,maximumSupportedRelease:this.maximumSupportedRelease,deprecated:this.deprecated,contextInfo:this.getContextInfo?.()}}getAction(s){return this._actions[s]}getTrigger(s){return this._triggers[s]}actions(){return this._actions}triggers(){return this._triggers}},oh=l(u=>{if(u.auth&&Array.isArray(u.auth)&&!u.auth.every((i,r,A)=>r===A.findIndex(M=>M.type===i.type)))throw new Error("Auth properties must be unique by type");return new y0(u.displayName,u.logoUrl,u.authors??[],u.events,u.actions,u.triggers,u.categories??[],u.auth,u.minimumSupportedRelease,u.maximumSupportedRelease,u.description,u.deprecated)},"createPiece");function aF(u){return/^\d+\.\d+\.\d+$/.test(u)}l(aF,"isValidSimpleSemver");function oF(u,s){let[i,r,A]=u.split(".").map(Number),[M,L,B]=s.split(".").map(Number);return i!==M?i<M:r!==L?r<L:A<B}l(oF,"isSemverLessThan");var sF=_e(fr(P(),fr(P(),P()))),sh=Q({id:_e(P()),name:P(),displayName:P(),logoUrl:P(),description:P(),authors:vr(P()),platformId:_e(P()),directoryPath:_e(P()),auth:_e(_r([la,vr(la)])),version:P(),categories:_e(vr(Sr(sa))),minimumSupportedRelease:_e(P()),maximumSupportedRelease:_e(P()),deprecated:_e($r()),i18n:sF}),cF=Sr(["human","ai","both"]),ch=Q({description:_e(P()),idempotent:_e($r())}),uh=Q({name:P(),displayName:P(),description:P(),props:_0,requireAuth:$r(),errorHandlingOptions:_e(Qc),outputSchema:_e(ds()),audience:_e(cF),aiMetadata:_e(ch)}),lh=Q({name:P(),displayName:P(),description:P(),props:_0,errorHandlingOptions:_e(Qc),type:Sr(Oi),sampleData:lr(),handshakeConfiguration:_e(ds()),renewConfiguration:_e(ih),testStrategy:Sr(lo),outputSchema:_e(ds()),aiMetadata:_e(ch)}),uF=Q({...sh.shape,actions:fr(P(),uh),triggers:fr(P(),lh)}),lF=Q({...sh.shape,actions:Vt(),triggers:Vt(),suggestedActions:_e(vr(uh)),suggestedTriggers:_e(vr(lh))}),fh=Q({projectUsage:Vt(),pieceType:Sr(oa),packageType:Sr(so),platformId:_e(P()),archiveId:_e(P())}),Q$=Q({...uF.shape,...fh.shape}),ez=Q({...lF.shape,...fh.shape}),rz=Q({name:P(),version:P()});var fF=ta(require("path")),dF=ta(require("fs/promises"));var Dr=class u extends Error{static{l(this,"CsvError")}constructor(s,i,r,...A){Array.isArray(i)&&(i=i.join(" ").trim()),super(i),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,u),this.code=s;for(let M of A)for(let L in M){let B=M[L];this[L]=Buffer.isBuffer(B)?B.toString(r.encoding):B==null?B:JSON.parse(JSON.stringify(B))}}};var dh=l(function(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)},"is_object");var _s=l(function(u){let s=[];for(let i=0,r=u.length;i<r;i++){let A=u[i];if(A==null||A===!1)s[i]={disabled:!0};else if(typeof A=="string")s[i]={name:A};else if(dh(A)){if(typeof A.name!="string")throw new Dr("CSV_OPTION_COLUMNS_MISSING_NAME",["Option columns missing name:",`property "name" is required at position ${i}`,"when column is an object literal"]);s[i]=A}else throw new Dr("CSV_INVALID_COLUMN_DEFINITION",["Invalid column definition:","expect a string or a literal object,",`got ${JSON.stringify(A)} at position ${i}`])}return s},"normalize_columns_array");var E0=class{static{l(this,"ResizeableBuffer")}constructor(s=100){this.size=s,this.length=0,this.buf=Buffer.allocUnsafe(s)}prepend(s){if(Buffer.isBuffer(s)){let i=this.length+s.length;if(i>=this.size&&(this.resize(),i>=this.size))throw Error("INVALID_BUFFER_STATE");let r=this.buf;this.buf=Buffer.allocUnsafe(this.size),s.copy(this.buf,0),r.copy(this.buf,s.length),this.length+=s.length}else{let i=this.length++;i===this.size&&this.resize();let r=this.clone();this.buf[0]=s,r.copy(this.buf,1,0,i)}}append(s){let i=this.length++;i===this.size&&this.resize(),this.buf[i]=s}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){let s=this.length;this.size=this.size*2;let i=Buffer.allocUnsafe(this.size);this.buf.copy(i,0,0,s),this.buf=i}toString(s){return s?this.buf.slice(0,this.length).toString(s):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},T0=E0;var pF=12,hF=13,mF=10,gF=32,xF=9,ph=l(function(u){return{bomSkipped:!1,bufBytesStart:0,castField:u.cast_function,commenting:!1,error:void 0,enabled:u.from_line===1,escaping:!1,escapeIsQuote:Buffer.isBuffer(u.escape)&&Buffer.isBuffer(u.quote)&&Buffer.compare(u.escape,u.quote)===0,expectedRecordLength:Array.isArray(u.columns)?u.columns.length:void 0,field:new T0(20),firstLineToHeaders:u.cast_first_line_to_header,needMoreDataSize:Math.max(u.comment!==null?u.comment.length:0,...u.delimiter.map(s=>s.length),u.quote!==null?u.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new T0(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:u.record_delimiter.length===0?0:Math.max(...u.record_delimiter.map(s=>s.length)),trimChars:[Buffer.from(" ",u.encoding)[0],Buffer.from(" ",u.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[Buffer.from(Buffer.from([hF],"utf8").toString(),u.encoding),Buffer.from(Buffer.from([mF],"utf8").toString(),u.encoding),Buffer.from(Buffer.from([pF],"utf8").toString(),u.encoding),Buffer.from(Buffer.from([gF],"utf8").toString(),u.encoding),Buffer.from(Buffer.from([xF],"utf8").toString(),u.encoding)]}},"init_state");var hh=l(function(u){return u.replace(/([A-Z])/g,function(s,i){return"_"+i.toLowerCase()})},"underscore");var A0=l(function(u){let s={};for(let r in u)s[hh(r)]=u[r];if(s.encoding===void 0||s.encoding===!0)s.encoding="utf8";else if(s.encoding===null||s.encoding===!1)s.encoding=null;else if(typeof s.encoding!="string"&&s.encoding!==null)throw new Dr("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(s.encoding)}`],s);if(s.bom===void 0||s.bom===null||s.bom===!1)s.bom=!1;else if(s.bom!==!0)throw new Dr("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(s.bom)}`],s);if(s.cast_function=null,s.cast===void 0||s.cast===null||s.cast===!1||s.cast==="")s.cast=void 0;else if(typeof s.cast=="function")s.cast_function=s.cast,s.cast=!0;else if(s.cast!==!0)throw new Dr("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(s.cast)}`],s);if(s.cast_date===void 0||s.cast_date===null||s.cast_date===!1||s.cast_date==="")s.cast_date=!1;else if(s.cast_date===!0)s.cast_date=function(r){let A=Date.parse(r);return isNaN(A)?r:new Date(A)};else if(typeof s.cast_date!="function")throw new Dr("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(s.cast_date)}`],s);if(s.cast_first_line_to_header=null,s.columns===!0)s.cast_first_line_to_header=void 0;else if(typeof s.columns=="function")s.cast_first_line_to_header=s.columns,s.columns=!0;else if(Array.isArray(s.columns))s.columns=_s(s.columns);else if(s.columns===void 0||s.columns===null||s.columns===!1)s.columns=!1;else throw new Dr("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(s.columns)}`],s);if(s.group_columns_by_name===void 0||s.group_columns_by_name===null||s.group_columns_by_name===!1)s.group_columns_by_name=!1;else{if(s.group_columns_by_name!==!0)throw new Dr("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(s.group_columns_by_name)}`],s);if(s.columns===!1)throw new Dr("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],s)}if(s.comment===void 0||s.comment===null||s.comment===!1||s.comment==="")s.comment=null;else if(typeof s.comment=="string"&&(s.comment=Buffer.from(s.comment,s.encoding)),!Buffer.isBuffer(s.comment))throw new Dr("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(s.comment)}`],s);if(s.comment_no_infix===void 0||s.comment_no_infix===null||s.comment_no_infix===!1)s.comment_no_infix=!1;else if(s.comment_no_infix!==!0)throw new Dr("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(s.comment_no_infix)}`],s);let i=JSON.stringify(s.delimiter);if(Array.isArray(s.delimiter)||(s.delimiter=[s.delimiter]),s.delimiter.length===0)throw new Dr("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${i}`],s);if(s.delimiter=s.delimiter.map(function(r){if(r==null||r===!1)return Buffer.from(",",s.encoding);if(typeof r=="string"&&(r=Buffer.from(r,s.encoding)),!Buffer.isBuffer(r)||r.length===0)throw new Dr("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${i}`],s);return r}),s.escape===void 0||s.escape===!0?s.escape=Buffer.from('"',s.encoding):typeof s.escape=="string"?s.escape=Buffer.from(s.escape,s.encoding):(s.escape===null||s.escape===!1)&&(s.escape=null),s.escape!==null&&!Buffer.isBuffer(s.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(s.escape)}`);if(s.from===void 0||s.from===null)s.from=1;else if(typeof s.from=="string"&&/\d+/.test(s.from)&&(s.from=parseInt(s.from)),Number.isInteger(s.from)){if(s.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(u.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(s.from)}`);if(s.from_line===void 0||s.from_line===null)s.from_line=1;else if(typeof s.from_line=="string"&&/\d+/.test(s.from_line)&&(s.from_line=parseInt(s.from_line)),Number.isInteger(s.from_line)){if(s.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(u.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(u.from_line)}`);if(s.ignore_last_delimiters===void 0||s.ignore_last_delimiters===null)s.ignore_last_delimiters=!1;else if(typeof s.ignore_last_delimiters=="number")s.ignore_last_delimiters=Math.floor(s.ignore_last_delimiters),s.ignore_last_delimiters===0&&(s.ignore_last_delimiters=!1);else if(typeof s.ignore_last_delimiters!="boolean")throw new Dr("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(s.ignore_last_delimiters)}`],s);if(s.ignore_last_delimiters===!0&&s.columns===!1)throw new Dr("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],s);if(s.info===void 0||s.info===null||s.info===!1)s.info=!1;else if(s.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(s.info)}`);if(s.max_record_size===void 0||s.max_record_size===null||s.max_record_size===!1)s.max_record_size=0;else if(!(Number.isInteger(s.max_record_size)&&s.max_record_size>=0))if(typeof s.max_record_size=="string"&&/\d+/.test(s.max_record_size))s.max_record_size=parseInt(s.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(s.max_record_size)}`);if(s.objname===void 0||s.objname===null||s.objname===!1)s.objname=void 0;else if(Buffer.isBuffer(s.objname)){if(s.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");s.encoding===null||(s.objname=s.objname.toString(s.encoding))}else if(typeof s.objname=="string"){if(s.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof s.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${s.objname}`);if(s.objname!==void 0){if(typeof s.objname=="number"){if(s.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(s.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(s.on_record===void 0||s.on_record===null)s.on_record=void 0;else if(typeof s.on_record!="function")throw new Dr("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(s.on_record)}`],s);if(s.on_skip!==void 0&&s.on_skip!==null&&typeof s.on_skip!="function")throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(s.on_skip)}`);if(s.quote===null||s.quote===!1||s.quote==="")s.quote=null;else if(s.quote===void 0||s.quote===!0?s.quote=Buffer.from('"',s.encoding):typeof s.quote=="string"&&(s.quote=Buffer.from(s.quote,s.encoding)),!Buffer.isBuffer(s.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(s.quote)}`);if(s.raw===void 0||s.raw===null||s.raw===!1)s.raw=!1;else if(s.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(s.raw)}`);if(s.record_delimiter===void 0)s.record_delimiter=[];else if(typeof s.record_delimiter=="string"||Buffer.isBuffer(s.record_delimiter)){if(s.record_delimiter.length===0)throw new Dr("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(s.record_delimiter)}`],s);s.record_delimiter=[s.record_delimiter]}else if(!Array.isArray(s.record_delimiter))throw new Dr("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(s.record_delimiter)}`],s);if(s.record_delimiter=s.record_delimiter.map(function(r,A){if(typeof r!="string"&&!Buffer.isBuffer(r))throw new Dr("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${A},`,`got ${JSON.stringify(r)}`],s);if(r.length===0)throw new Dr("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${A},`,`got ${JSON.stringify(r)}`],s);return typeof r=="string"&&(r=Buffer.from(r,s.encoding)),r}),typeof s.relax_column_count!="boolean")if(s.relax_column_count===void 0||s.relax_column_count===null)s.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(s.relax_column_count)}`);if(typeof s.relax_column_count_less!="boolean")if(s.relax_column_count_less===void 0||s.relax_column_count_less===null)s.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(s.relax_column_count_less)}`);if(typeof s.relax_column_count_more!="boolean")if(s.relax_column_count_more===void 0||s.relax_column_count_more===null)s.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(s.relax_column_count_more)}`);if(typeof s.relax_quotes!="boolean")if(s.relax_quotes===void 0||s.relax_quotes===null)s.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(s.relax_quotes)}`);if(typeof s.skip_empty_lines!="boolean")if(s.skip_empty_lines===void 0||s.skip_empty_lines===null)s.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(s.skip_empty_lines)}`);if(typeof s.skip_records_with_empty_values!="boolean")if(s.skip_records_with_empty_values===void 0||s.skip_records_with_empty_values===null)s.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(s.skip_records_with_empty_values)}`);if(typeof s.skip_records_with_error!="boolean")if(s.skip_records_with_error===void 0||s.skip_records_with_error===null)s.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(s.skip_records_with_error)}`);if(s.rtrim===void 0||s.rtrim===null||s.rtrim===!1)s.rtrim=!1;else if(s.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(s.rtrim)}`);if(s.ltrim===void 0||s.ltrim===null||s.ltrim===!1)s.ltrim=!1;else if(s.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(s.ltrim)}`);if(s.trim===void 0||s.trim===null||s.trim===!1)s.trim=!1;else if(s.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(s.trim)}`);if(s.trim===!0&&u.ltrim!==!1?s.ltrim=!0:s.ltrim!==!0&&(s.ltrim=!1),s.trim===!0&&u.rtrim!==!1?s.rtrim=!0:s.rtrim!==!0&&(s.rtrim=!1),s.to===void 0||s.to===null)s.to=-1;else if(typeof s.to=="string"&&/\d+/.test(s.to)&&(s.to=parseInt(s.to)),Number.isInteger(s.to)){if(s.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(u.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(u.to)}`);if(s.to_line===void 0||s.to_line===null)s.to_line=-1;else if(typeof s.to_line=="string"&&/\d+/.test(s.to_line)&&(s.to_line=parseInt(s.to_line)),Number.isInteger(s.to_line)){if(s.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(u.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(u.to_line)}`);return s},"normalize_options");var mh=l(function(u){return u.every(s=>s==null||s.toString&&s.toString().trim()==="")},"isRecordEmpty"),vF=13,_F=10,fa={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},gh=l(function(u={}){let s={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},i=A0(u);return{info:s,original_options:u,options:i,state:ph(i),__needMoreData:l(function(r,A,M){if(M)return!1;let{encoding:L,escape:B,quote:Y}=this.options,{quoting:te,needMoreDataSize:Te,recordDelimiterMaxLength:he}=this.state,Pe=A-r-1,z=Math.max(Te,he===0?Buffer.from(`\r
138
138
  `,L).length:he,te?(B===null?0:B.length)+Y.length:0,te?Y.length+he:0);return Pe<z},"__needMoreData"),parse:l(function(r,A,M,L){let{bom:B,comment_no_infix:Y,encoding:te,from_line:Te,ltrim:he,max_record_size:Pe,raw:z,relax_quotes:J,rtrim:ee,skip_empty_lines:re,to:pe,to_line:me}=this.options,{comment:We,escape:br,quote:Ke,record_delimiter:Wr}=this.options,{bomSkipped:Et,previousBuf:zt,rawBuffer:vt,escapeIsQuote:Ft}=this.state,pr;if(zt===void 0)if(r===void 0){L();return}else pr=r;else zt!==void 0&&r===void 0?pr=zt:pr=Buffer.concat([zt,r]);if(Et===!1)if(B===!1)this.state.bomSkipped=!0;else if(pr.length<3){if(A===!1){this.state.previousBuf=pr;return}}else{for(let yr in fa)if(fa[yr].compare(pr,0,fa[yr].length)===0){let nn=fa[yr].length;this.state.bufBytesStart+=nn,pr=pr.slice(nn),this.options=A0({...this.original_options,encoding:yr}),{comment:We,escape:br,quote:Ke}=this.options;break}this.state.bomSkipped=!0}let Wt=pr.length,Je;for(Je=0;Je<Wt&&!this.__needMoreData(Je,Wt,A);Je++){if(this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1),me!==-1&&this.info.lines>me){this.state.stop=!0,L();return}this.state.quoting===!1&&Wr.length===0&&this.__autoDiscoverRecordDelimiter(pr,Je)&&(Wr=this.options.record_delimiter);let yr=pr[Je];if(z===!0&&vt.append(yr),(yr===vF||yr===_F)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(br!==null&&this.state.quoting===!0&&this.__isEscape(pr,Je,yr)&&Je+br.length<Wt)if(Ft){if(this.__isQuote(pr,Je+br.length)){this.state.escaping=!0,Je+=br.length-1;continue}}else{this.state.escaping=!0,Je+=br.length-1;continue}if(this.state.commenting===!1&&this.__isQuote(pr,Je))if(this.state.quoting===!0){let ar=pr[Je+Ke.length],Se=ee&&this.__isCharTrimable(pr,Je+Ke.length),H=We!==null&&this.__compareBytes(We,pr,Je+Ke.length,ar),Fe=this.__isDelimiter(pr,Je+Ke.length,ar),Ie=Wr.length===0?this.__autoDiscoverRecordDelimiter(pr,Je+Ke.length):this.__isRecordDelimiter(ar,pr,Je+Ke.length);if(br!==null&&this.__isEscape(pr,Je,yr)&&this.__isQuote(pr,Je+br.length))Je+=br.length-1;else if(!ar||Fe||Ie||H||Se){this.state.quoting=!1,this.state.wasQuoting=!0,Je+=Ke.length-1;continue}else if(J===!1){let we=this.__error(new Dr("CSV_INVALID_CLOSING_QUOTE",["Invalid Closing Quote:",`got "${String.fromCharCode(ar)}"`,`at line ${this.info.lines}`,"instead of delimiter, record delimiter, trimable character","(if activated) or comment"],this.options,this.__infoField()));if(we!==void 0)return we}else this.state.quoting=!1,this.state.wasQuoting=!0,this.state.field.prepend(Ke),Je+=Ke.length-1}else if(this.state.field.length!==0){if(J===!1){let ar=this.__infoField(),Se=Object.keys(fa).map(Fe=>fa[Fe].equals(this.state.field.toString())?Fe:!1).filter(Boolean)[0],H=this.__error(new Dr("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(ar.column)} at line ${ar.lines}, value is ${JSON.stringify(this.state.field.toString(te))}`,Se?`(${Se} bom)`:void 0],this.options,ar,{field:this.state.field}));if(H!==void 0)return H}}else{this.state.quoting=!0,Je+=Ke.length-1;continue}if(this.state.quoting===!1){let ar=this.__isRecordDelimiter(yr,pr,Je);if(ar!==0){if(this.state.commenting&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0)this.info.comment_lines++;else{if(this.state.enabled===!1&&this.info.lines+(this.state.wasRowDelimiter===!0?1:0)>=Te){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),Je+=ar-1;continue}if(re===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,Je+=ar-1;continue}this.info.bytes=this.state.bufBytesStart+Je;let Fe=this.__onField();if(Fe!==void 0)return Fe;this.info.bytes=this.state.bufBytesStart+Je+ar;let Ie=this.__onRecord(M);if(Ie!==void 0)return Ie;if(pe!==-1&&this.info.records>=pe){this.state.stop=!0,L();return}}this.state.commenting=!1,Je+=ar-1;continue}if(this.state.commenting)continue;if(We!==null&&(Y===!1||this.state.record.length===0&&this.state.field.length===0)&&this.__compareBytes(We,pr,Je,yr)!==0){this.state.commenting=!0;continue}let Se=this.__isDelimiter(pr,Je,yr);if(Se!==0){this.info.bytes=this.state.bufBytesStart+Je;let H=this.__onField();if(H!==void 0)return H;Je+=Se-1;continue}}}if(this.state.commenting===!1&&Pe!==0&&this.state.record_length+this.state.field.length>Pe)return this.__error(new Dr("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${Pe}`,`at line ${this.info.lines}`],this.options,this.__infoField()));let nn=he===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(pr,Je),lt=ee===!1||this.state.wasQuoting===!1;if(nn===!0&&lt===!0)this.state.field.append(yr);else{if(ee===!0&&!this.__isCharTrimable(pr,Je))return this.__error(new Dr("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));nn===!1&&(Je+=this.__isCharTrimable(pr,Je)-1);continue}}if(A===!0)if(this.state.quoting===!0){let yr=this.__error(new Dr("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(yr!==void 0)return yr}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+Je;let yr=this.__onField();if(yr!==void 0)return yr;let nn=this.__onRecord(M);if(nn!==void 0)return nn}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=Je,this.state.previousBuf=pr.slice(Je);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},"parse"),__onRecord:l(function(r){let{columns:A,group_columns_by_name:M,encoding:L,info:B,from:Y,relax_column_count:te,relax_column_count_less:Te,relax_column_count_more:he,raw:Pe,skip_records_with_empty_values:z}=this.options,{enabled:J,record:ee}=this.state;if(J===!1)return this.__resetRecord();let re=ee.length;if(A===!0){if(z===!0&&mh(ee)){this.__resetRecord();return}return this.__firstLineToColumns(ee)}if(A===!1&&this.info.records===0&&(this.state.expectedRecordLength=re),re!==this.state.expectedRecordLength){let pe=A===!1?new Dr("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${re} on line ${this.info.lines}`],this.options,this.__infoField(),{record:ee}):new Dr("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${A.length},`,`got ${re} on line ${this.info.lines}`],this.options,this.__infoField(),{record:ee});if(te===!0||Te===!0&&re<this.state.expectedRecordLength||he===!0&&re>this.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=pe;else{let me=this.__error(pe);if(me)return me}}if(z===!0&&mh(ee)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,Y===1||this.info.records>=Y){let{objname:pe}=this.options;if(A!==!1){let me={};for(let We=0,br=ee.length;We<br;We++)A[We]===void 0||A[We].disabled||(M===!0&&me[A[We].name]!==void 0?Array.isArray(me[A[We].name])?me[A[We].name]=me[A[We].name].concat(ee[We]):me[A[We].name]=[me[A[We].name],ee[We]]:me[A[We].name]=ee[We]);if(Pe===!0||B===!0){let We=Object.assign({record:me},Pe===!0?{raw:this.state.rawBuffer.toString(L)}:{},B===!0?{info:this.__infoRecord()}:{}),br=this.__push(pe===void 0?We:[me[pe],We],r);if(br)return br}else{let We=this.__push(pe===void 0?me:[me[pe],me],r);if(We)return We}}else if(Pe===!0||B===!0){let me=Object.assign({record:ee},Pe===!0?{raw:this.state.rawBuffer.toString(L)}:{},B===!0?{info:this.__infoRecord()}:{}),We=this.__push(pe===void 0?me:[ee[pe],me],r);if(We)return We}else{let me=this.__push(pe===void 0?ee:[ee[pe],ee],r);if(me)return me}}this.__resetRecord()},"__onRecord"),__firstLineToColumns:l(function(r){let{firstLineToHeaders:A}=this.state;try{let M=A===void 0?r:A.call(null,r);if(!Array.isArray(M))return this.__error(new Dr("CSV_INVALID_COLUMN_MAPPING",["Invalid Column Mapping:","expect an array from column function,",`got ${JSON.stringify(M)}`],this.options,this.__infoField(),{headers:M}));let L=_s(M);this.state.expectedRecordLength=L.length,this.options.columns=L,this.__resetRecord();return}catch(M){return M}},"__firstLineToColumns"),__resetRecord:l(function(){this.options.raw===!0&&this.state.rawBuffer.reset(),this.state.error=void 0,this.state.record=[],this.state.record_length=0},"__resetRecord"),__onField:l(function(){let{cast:r,encoding:A,rtrim:M,max_record_size:L}=this.options,{enabled:B,wasQuoting:Y}=this.state;if(B===!1)return this.__resetField();let te=this.state.field.toString(A);if(M===!0&&Y===!1&&(te=te.trimRight()),r===!0){let[Te,he]=this.__cast(te);if(Te!==void 0)return Te;te=he}this.state.record.push(te),L!==0&&typeof te=="string"&&(this.state.record_length+=te.length),this.__resetField()},"__onField"),__resetField:l(function(){this.state.field.reset(),this.state.wasQuoting=!1},"__resetField"),__push:l(function(r,A){let{on_record:M}=this.options;if(M!==void 0){let L=this.__infoRecord();try{r=M.call(null,r,L)}catch(B){return B}if(r==null)return}A(r)},"__push"),__cast:l(function(r){let{columns:A,relax_column_count:M}=this.options;if(Array.isArray(A)===!0&&M&&this.options.columns.length<=this.state.record.length)return[void 0,void 0];if(this.state.castField!==null)try{let B=this.__infoField();return[void 0,this.state.castField.call(null,r,B)]}catch(B){return[B]}if(this.__isFloat(r))return[void 0,parseFloat(r)];if(this.options.cast_date!==!1){let B=this.__infoField();return[void 0,this.options.cast_date.call(null,r,B)]}return[void 0,r]},"__cast"),__isCharTrimable:l(function(r,A){return l((L,B)=>{let{timchars:Y}=this.state;e:for(let te=0;te<Y.length;te++){let Te=Y[te];for(let he=0;he<Te.length;he++)if(Te[he]!==L[B+he])continue e;return Te.length}return 0},"isTrim")(r,A)},"__isCharTrimable"),__isFloat:l(function(r){return r-parseFloat(r)+1>=0},"__isFloat"),__compareBytes:l(function(r,A,M,L){if(r[0]!==L)return 0;let B=r.length;for(let Y=1;Y<B;Y++)if(r[Y]!==A[M+Y])return 0;return B},"__compareBytes"),__isDelimiter:l(function(r,A,M){let{delimiter:L,ignore_last_delimiters:B}=this.options;if(B===!0&&this.state.record.length===this.options.columns.length-1)return 0;if(B!==!1&&typeof B=="number"&&this.state.record.length===B-1)return 0;e:for(let Y=0;Y<L.length;Y++){let te=L[Y];if(te[0]===M){for(let Te=1;Te<te.length;Te++)if(te[Te]!==r[A+Te])continue e;return te.length}}return 0},"__isDelimiter"),__isRecordDelimiter:l(function(r,A,M){let{record_delimiter:L}=this.options,B=L.length;e:for(let Y=0;Y<B;Y++){let te=L[Y],Te=te.length;if(te[0]===r){for(let he=1;he<Te;he++)if(te[he]!==A[M+he])continue e;return te.length}}return 0},"__isRecordDelimiter"),__isEscape:l(function(r,A,M){let{escape:L}=this.options;if(L===null)return!1;let B=L.length;if(L[0]===M){for(let Y=0;Y<B;Y++)if(L[Y]!==r[A+Y])return!1;return!0}return!1},"__isEscape"),__isQuote:l(function(r,A){let{quote:M}=this.options;if(M===null)return!1;let L=M.length;for(let B=0;B<L;B++)if(M[B]!==r[A+B])return!1;return!0},"__isQuote"),__autoDiscoverRecordDelimiter:l(function(r,A){let{encoding:M}=this.options,L=[Buffer.from(`\r
139
139
  `,M),Buffer.from(`
140
- `,M),Buffer.from("\r",M)];e:for(let B=0;B<L.length;B++){let Y=L[B].length;for(let te=0;te<Y;te++)if(L[B][te]!==r[A+te])continue e;return this.options.record_delimiter.push(L[B]),this.state.recordDelimiterMaxLength=L[B].length,L[B].length}return 0},"__autoDiscoverRecordDelimiter"),__error:l(function(r){let{encoding:A,raw:M,skip_records_with_error:L}=this.options,B=typeof r=="string"?new Error(r):r;if(L){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(B,M?this.state.rawBuffer.toString(A):void 0);return}else return B},"__error"),__infoDataSet:l(function(){return{...this.info,columns:this.options.columns}},"__infoDataSet"),__infoRecord:l(function(){let{columns:r,raw:A,encoding:M}=this.options;return{...this.__infoDataSet(),error:this.state.error,header:r===!0,index:this.state.record.length,raw:A?this.state.rawBuffer.toString(M):void 0}},"__infoRecord"),__infoField:l(function(){let{columns:r}=this.options,A=Array.isArray(r);return{...this.__infoRecord(),column:A===!0?r.length>this.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}},"__infoField")}},"transform");var xh=l(function(u,s={}){typeof u=="string"&&(u=Buffer.from(u));let i=s&&s.objname?{}:[],r=gh(s),A=l(Y=>{r.options.objname===void 0?i.push(Y):i[Y[0]]=Y[1]},"push"),M=l(()=>{},"close"),L=r.parse(u,!1,A,M);if(L!==void 0)throw L;let B=r.parse(void 0,!0,A,M);if(B!==void 0)throw B;return i},"parse");var vh=aa({audience:"both",name:"convert_csv_to_json",displayName:"Convert CSV to JSON",description:"This function reads a CSV string and converts it into JSON array format.",errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{csv_text:tn.LongText({displayName:"CSV Text",defaultValue:"",required:!0}),has_headers:tn.Checkbox({displayName:"Does the CSV have headers?",defaultValue:!1,required:!0}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter Type",description:"Select the delimiter type for the CSV text.",defaultValue:"",required:!0,options:{options:[{label:"Comma",value:","},{label:"Tab",value:" "}]}})},async run(u){let{csv_text:s,has_headers:i,delimiter_type:r}=u.propsValue;if(!fo(s))throw new Error(JSON.stringify({message:"The input should be a string."}));return xh(s,{delimiter:r,columns:!!i})}});var kh=ta(yh());var TF=/\\(\\)?/g,AF=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),wF=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,SF=/^\w*$/,FF=l(function(u){return Object.prototype.toString.call(u)},"getTag"),Eh=l(function(u){let s=typeof u;return s==="symbol"||s==="object"&&u&&FF(u)==="[object Symbol]"},"isSymbol"),kF=l(function(u,s){if(Array.isArray(u))return!1;let i=typeof u;return i==="number"||i==="symbol"||i==="boolean"||!u||Eh(u)?!0:SF.test(u)||!wF.test(u)||s!=null&&u in Object(s)},"isKey"),PF=l(function(u){let s=[];return u.charCodeAt(0)===46&&s.push(""),u.replace(AF,function(i,r,A,M){let L=i;A?L=M.replace(TF,"$1"):r&&(L=r.trim()),s.push(L)}),s},"stringToPath"),IF=l(function(u,s){return Array.isArray(u)?u:kF(u,s)?[u]:PF(u)},"castPath"),bF=l(function(u){if(typeof u=="string"||Eh(u))return u;let s=`${u}`;return s=="0"&&1/u==-INFINITY?"-0":s},"toKey"),Th=l(function(u,s){s=IF(s,u);let i=0,r=s.length;for(;u!=null&&i<r;)u=u[bF(s[i++])];return i&&i===r?u:void 0},"get");var Ah=l(function(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)},"is_object");var Es=l(function(u){if(u==null)return[void 0,void 0];if(typeof u!="object")return[Error('Invalid option "columns": expect an array or an object')];if(Array.isArray(u)){let s=[];for(let i of u)if(typeof i=="string")s.push({key:i,header:i});else if(typeof i=="object"&&i!==null&&!Array.isArray(i)){if(!i.key)return[Error('Invalid column definition: property "key" is required')];i.header===void 0&&(i.header=i.key),s.push(i)}else return[Error("Invalid column definition: expect a string or an object")];u=s}else{let s=[];for(let i in u)s.push({key:i,header:u[i]});u=s}return[void 0,u]},"normalize_columns");var Mi=class u extends Error{static{l(this,"CsvError")}constructor(s,i,...r){Array.isArray(i)&&(i=i.join(" ")),super(i),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,u),this.code=s;for(let A of r)for(let M in A){let L=A[M];this[M]=Buffer.isBuffer(L)?L.toString():L==null?L:JSON.parse(JSON.stringify(L))}}};var wh=l(function(u){return u.replace(/([A-Z])/g,function(s,i){return"_"+i.toLowerCase()})},"underscore");var Ts=l(function(u){let s={};for(let A in u)s[wh(A)]=u[A];if(s.bom===void 0||s.bom===null||s.bom===!1)s.bom=!1;else if(s.bom!==!0)return[new Mi("CSV_OPTION_BOOLEAN_INVALID_TYPE",["option `bom` is optional and must be a boolean value,",`got ${JSON.stringify(s.bom)}`])];if(s.delimiter===void 0||s.delimiter===null)s.delimiter=",";else if(Buffer.isBuffer(s.delimiter))s.delimiter=s.delimiter.toString();else if(typeof s.delimiter!="string")return[new Mi("CSV_OPTION_DELIMITER_INVALID_TYPE",["option `delimiter` must be a buffer or a string,",`got ${JSON.stringify(s.delimiter)}`])];if(s.quote===void 0||s.quote===null)s.quote='"';else if(s.quote===!0)s.quote='"';else if(s.quote===!1)s.quote="";else if(Buffer.isBuffer(s.quote))s.quote=s.quote.toString();else if(typeof s.quote!="string")return[new Mi("CSV_OPTION_QUOTE_INVALID_TYPE",["option `quote` must be a boolean, a buffer or a string,",`got ${JSON.stringify(s.quote)}`])];if((s.quoted===void 0||s.quoted===null)&&(s.quoted=!1),s.escape_formulas===void 0||s.escape_formulas===null)s.escape_formulas=!1;else if(typeof s.escape_formulas!="boolean")return[new Mi("CSV_OPTION_ESCAPE_FORMULAS_INVALID_TYPE",["option `escape_formulas` must be a boolean,",`got ${JSON.stringify(s.escape_formulas)}`])];if((s.quoted_empty===void 0||s.quoted_empty===null)&&(s.quoted_empty=void 0),s.quoted_match===void 0||s.quoted_match===null||s.quoted_match===!1?s.quoted_match=null:Array.isArray(s.quoted_match)||(s.quoted_match=[s.quoted_match]),s.quoted_match)for(let A of s.quoted_match){let M=typeof A=="string",L=A instanceof RegExp;if(!M&&!L)return[Error(`Invalid Option: quoted_match must be a string or a regex, got ${JSON.stringify(A)}`)]}if((s.quoted_string===void 0||s.quoted_string===null)&&(s.quoted_string=!1),(s.eof===void 0||s.eof===null)&&(s.eof=!0),s.escape===void 0||s.escape===null)s.escape='"';else if(Buffer.isBuffer(s.escape))s.escape=s.escape.toString();else if(typeof s.escape!="string")return[Error(`Invalid Option: escape must be a buffer or a string, got ${JSON.stringify(s.escape)}`)];if(s.escape.length>1)return[Error(`Invalid Option: escape must be one character, got ${s.escape.length} characters`)];(s.header===void 0||s.header===null)&&(s.header=!1);let[i,r]=Es(s.columns);if(i!==void 0)return[i];if(s.columns=r,(s.quoted===void 0||s.quoted===null)&&(s.quoted=!1),(s.cast===void 0||s.cast===null)&&(s.cast={}),(s.cast.bigint===void 0||s.cast.bigint===null)&&(s.cast.bigint=A=>""+A),(s.cast.boolean===void 0||s.cast.boolean===null)&&(s.cast.boolean=A=>A?"1":""),(s.cast.date===void 0||s.cast.date===null)&&(s.cast.date=A=>""+A.getTime()),(s.cast.number===void 0||s.cast.number===null)&&(s.cast.number=A=>""+A),(s.cast.object===void 0||s.cast.object===null)&&(s.cast.object=A=>JSON.stringify(A)),(s.cast.string===void 0||s.cast.string===null)&&(s.cast.string=function(A){return A}),s.on_record!==void 0&&typeof s.on_record!="function")return[Error('Invalid Option: "on_record" must be a function.')];if(s.record_delimiter===void 0||s.record_delimiter===null)s.record_delimiter=`
140
+ `,M),Buffer.from("\r",M)];e:for(let B=0;B<L.length;B++){let Y=L[B].length;for(let te=0;te<Y;te++)if(L[B][te]!==r[A+te])continue e;return this.options.record_delimiter.push(L[B]),this.state.recordDelimiterMaxLength=L[B].length,L[B].length}return 0},"__autoDiscoverRecordDelimiter"),__error:l(function(r){let{encoding:A,raw:M,skip_records_with_error:L}=this.options,B=typeof r=="string"?new Error(r):r;if(L){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(B,M?this.state.rawBuffer.toString(A):void 0);return}else return B},"__error"),__infoDataSet:l(function(){return{...this.info,columns:this.options.columns}},"__infoDataSet"),__infoRecord:l(function(){let{columns:r,raw:A,encoding:M}=this.options;return{...this.__infoDataSet(),error:this.state.error,header:r===!0,index:this.state.record.length,raw:A?this.state.rawBuffer.toString(M):void 0}},"__infoRecord"),__infoField:l(function(){let{columns:r}=this.options,A=Array.isArray(r);return{...this.__infoRecord(),column:A===!0?r.length>this.state.record.length?r[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}},"__infoField")}},"transform");var xh=l(function(u,s={}){typeof u=="string"&&(u=Buffer.from(u));let i=s&&s.objname?{}:[],r=gh(s),A=l(Y=>{r.options.objname===void 0?i.push(Y):i[Y[0]]=Y[1]},"push"),M=l(()=>{},"close"),L=r.parse(u,!1,A,M);if(L!==void 0)throw L;let B=r.parse(void 0,!0,A,M);if(B!==void 0)throw B;return i},"parse");var vh=aa({audience:"both",name:"convert_csv_to_json",displayName:"Convert CSV to JSON",description:"This function reads a CSV string and converts it into JSON array format.",aiMetadata:{description:"Parses a CSV or tab-separated text string into a JSON array, treating the first row either as column headers or as plain data depending on the header option. Use this to make CSV text queryable before looping or filtering rows; use Convert JSON to CSV for the reverse direction, and run Convert Excel to CSV first when the source is an .xlsx/.xls file. The chosen delimiter (comma or tab) must match the actual data or columns will not split; read-only and idempotent.",idempotent:!0},errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{csv_text:tn.LongText({displayName:"CSV Text",defaultValue:"",required:!0}),has_headers:tn.Checkbox({displayName:"Does the CSV have headers?",defaultValue:!1,required:!0}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter Type",description:"Select the delimiter type for the CSV text.",defaultValue:"",required:!0,options:{options:[{label:"Comma",value:","},{label:"Tab",value:" "}]}})},async run(u){let{csv_text:s,has_headers:i,delimiter_type:r}=u.propsValue;if(!fo(s))throw new Error(JSON.stringify({message:"The input should be a string."}));return xh(s,{delimiter:r,columns:!!i})}});var kh=ta(yh());var TF=/\\(\\)?/g,AF=RegExp(`[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,"g"),wF=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,SF=/^\w*$/,FF=l(function(u){return Object.prototype.toString.call(u)},"getTag"),Eh=l(function(u){let s=typeof u;return s==="symbol"||s==="object"&&u&&FF(u)==="[object Symbol]"},"isSymbol"),kF=l(function(u,s){if(Array.isArray(u))return!1;let i=typeof u;return i==="number"||i==="symbol"||i==="boolean"||!u||Eh(u)?!0:SF.test(u)||!wF.test(u)||s!=null&&u in Object(s)},"isKey"),PF=l(function(u){let s=[];return u.charCodeAt(0)===46&&s.push(""),u.replace(AF,function(i,r,A,M){let L=i;A?L=M.replace(TF,"$1"):r&&(L=r.trim()),s.push(L)}),s},"stringToPath"),IF=l(function(u,s){return Array.isArray(u)?u:kF(u,s)?[u]:PF(u)},"castPath"),bF=l(function(u){if(typeof u=="string"||Eh(u))return u;let s=`${u}`;return s=="0"&&1/u==-INFINITY?"-0":s},"toKey"),Th=l(function(u,s){s=IF(s,u);let i=0,r=s.length;for(;u!=null&&i<r;)u=u[bF(s[i++])];return i&&i===r?u:void 0},"get");var Ah=l(function(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)},"is_object");var Es=l(function(u){if(u==null)return[void 0,void 0];if(typeof u!="object")return[Error('Invalid option "columns": expect an array or an object')];if(Array.isArray(u)){let s=[];for(let i of u)if(typeof i=="string")s.push({key:i,header:i});else if(typeof i=="object"&&i!==null&&!Array.isArray(i)){if(!i.key)return[Error('Invalid column definition: property "key" is required')];i.header===void 0&&(i.header=i.key),s.push(i)}else return[Error("Invalid column definition: expect a string or an object")];u=s}else{let s=[];for(let i in u)s.push({key:i,header:u[i]});u=s}return[void 0,u]},"normalize_columns");var Mi=class u extends Error{static{l(this,"CsvError")}constructor(s,i,...r){Array.isArray(i)&&(i=i.join(" ")),super(i),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,u),this.code=s;for(let A of r)for(let M in A){let L=A[M];this[M]=Buffer.isBuffer(L)?L.toString():L==null?L:JSON.parse(JSON.stringify(L))}}};var wh=l(function(u){return u.replace(/([A-Z])/g,function(s,i){return"_"+i.toLowerCase()})},"underscore");var Ts=l(function(u){let s={};for(let A in u)s[wh(A)]=u[A];if(s.bom===void 0||s.bom===null||s.bom===!1)s.bom=!1;else if(s.bom!==!0)return[new Mi("CSV_OPTION_BOOLEAN_INVALID_TYPE",["option `bom` is optional and must be a boolean value,",`got ${JSON.stringify(s.bom)}`])];if(s.delimiter===void 0||s.delimiter===null)s.delimiter=",";else if(Buffer.isBuffer(s.delimiter))s.delimiter=s.delimiter.toString();else if(typeof s.delimiter!="string")return[new Mi("CSV_OPTION_DELIMITER_INVALID_TYPE",["option `delimiter` must be a buffer or a string,",`got ${JSON.stringify(s.delimiter)}`])];if(s.quote===void 0||s.quote===null)s.quote='"';else if(s.quote===!0)s.quote='"';else if(s.quote===!1)s.quote="";else if(Buffer.isBuffer(s.quote))s.quote=s.quote.toString();else if(typeof s.quote!="string")return[new Mi("CSV_OPTION_QUOTE_INVALID_TYPE",["option `quote` must be a boolean, a buffer or a string,",`got ${JSON.stringify(s.quote)}`])];if((s.quoted===void 0||s.quoted===null)&&(s.quoted=!1),s.escape_formulas===void 0||s.escape_formulas===null)s.escape_formulas=!1;else if(typeof s.escape_formulas!="boolean")return[new Mi("CSV_OPTION_ESCAPE_FORMULAS_INVALID_TYPE",["option `escape_formulas` must be a boolean,",`got ${JSON.stringify(s.escape_formulas)}`])];if((s.quoted_empty===void 0||s.quoted_empty===null)&&(s.quoted_empty=void 0),s.quoted_match===void 0||s.quoted_match===null||s.quoted_match===!1?s.quoted_match=null:Array.isArray(s.quoted_match)||(s.quoted_match=[s.quoted_match]),s.quoted_match)for(let A of s.quoted_match){let M=typeof A=="string",L=A instanceof RegExp;if(!M&&!L)return[Error(`Invalid Option: quoted_match must be a string or a regex, got ${JSON.stringify(A)}`)]}if((s.quoted_string===void 0||s.quoted_string===null)&&(s.quoted_string=!1),(s.eof===void 0||s.eof===null)&&(s.eof=!0),s.escape===void 0||s.escape===null)s.escape='"';else if(Buffer.isBuffer(s.escape))s.escape=s.escape.toString();else if(typeof s.escape!="string")return[Error(`Invalid Option: escape must be a buffer or a string, got ${JSON.stringify(s.escape)}`)];if(s.escape.length>1)return[Error(`Invalid Option: escape must be one character, got ${s.escape.length} characters`)];(s.header===void 0||s.header===null)&&(s.header=!1);let[i,r]=Es(s.columns);if(i!==void 0)return[i];if(s.columns=r,(s.quoted===void 0||s.quoted===null)&&(s.quoted=!1),(s.cast===void 0||s.cast===null)&&(s.cast={}),(s.cast.bigint===void 0||s.cast.bigint===null)&&(s.cast.bigint=A=>""+A),(s.cast.boolean===void 0||s.cast.boolean===null)&&(s.cast.boolean=A=>A?"1":""),(s.cast.date===void 0||s.cast.date===null)&&(s.cast.date=A=>""+A.getTime()),(s.cast.number===void 0||s.cast.number===null)&&(s.cast.number=A=>""+A),(s.cast.object===void 0||s.cast.object===null)&&(s.cast.object=A=>JSON.stringify(A)),(s.cast.string===void 0||s.cast.string===null)&&(s.cast.string=function(A){return A}),s.on_record!==void 0&&typeof s.on_record!="function")return[Error('Invalid Option: "on_record" must be a function.')];if(s.record_delimiter===void 0||s.record_delimiter===null)s.record_delimiter=`
141
141
  `;else if(Buffer.isBuffer(s.record_delimiter))s.record_delimiter=s.record_delimiter.toString();else if(typeof s.record_delimiter!="string")return[Error(`Invalid Option: record_delimiter must be a buffer or a string, got ${JSON.stringify(s.record_delimiter)}`)];switch(s.record_delimiter){case"unix":s.record_delimiter=`
142
142
  `;break;case"mac":s.record_delimiter="\r";break;case"windows":s.record_delimiter=`\r
143
143
  `;break;case"ascii":s.record_delimiter="";break;case"unicode":s.record_delimiter="\u2028";break}return[void 0,s]},"normalize_options");var CF=Buffer.from([239,187,191]),Sh=l(function(u,s,i){return{options:u,state:s,info:i,__transform:l(function(r,A){if(!Array.isArray(r)&&typeof r!="object")return Error(`Invalid Record: expect an array or an object, got ${JSON.stringify(r)}`);if(this.info.records===0){if(Array.isArray(r)){if(this.options.header===!0&&this.options.columns===void 0)return Error("Undiscoverable Columns: header option requires column option or object records")}else if(this.options.columns===void 0){let[B,Y]=Es(Object.keys(r));if(B)return;this.options.columns=Y}}if(this.info.records===0){this.bom(A);let B=this.headers(A);if(B)return B}try{this.options.on_record&&this.options.on_record(r,this.info.records)}catch(B){return B}let M,L;if(this.options.eof){if([M,L]=this.stringify(r),M)return M;if(L===void 0)return;L=L+this.options.record_delimiter}else{if([M,L]=this.stringify(r),M)return M;if(L===void 0)return;(this.options.header||this.info.records)&&(L=this.options.record_delimiter+L)}this.info.records++,A(L)},"__transform"),stringify:l(function(r,A=!1){if(typeof r!="object")return[void 0,r];let{columns:M}=this.options,L=[];if(Array.isArray(r)){M&&r.splice(M.length);for(let Y=0;Y<r.length;Y++){let te=r[Y],[Te,he]=this.__cast(te,{index:Y,column:Y,records:this.info.records,header:A});if(Te)return[Te];L[Y]=[he,te]}}else for(let Y=0;Y<M.length;Y++){let te=Th(r,M[Y].key),[Te,he]=this.__cast(te,{index:Y,column:M[Y].key,records:this.info.records,header:A});if(Te)return[Te];L[Y]=[he,te]}let B="";for(let Y=0;Y<L.length;Y++){let te,Te,[he,Pe]=L[Y];if(typeof he=="string")te=this.options;else if(Ah(he)){if(te=he,he=te.value,delete te.value,typeof he!="string"&&he!==void 0&&he!==null&&Te)return[Error(`Invalid Casting Value: returned value must return a string, null or undefined, got ${JSON.stringify(he)}`)];if(te={...this.options,...te},[Te,te]=Ts(te),Te!==void 0)return[Te]}else if(he==null)te=this.options;else return[Error(`Invalid Casting Value: returned value must return a string, an object, null or undefined, got ${JSON.stringify(he)}`)];let{delimiter:z,escape:J,quote:ee,quoted:re,quoted_empty:pe,quoted_string:me,quoted_match:We,record_delimiter:br,escape_formulas:Ke}=te;if(he===""&&Pe===""){let Wr=We&&We.filter(zt=>typeof zt=="string"?he.indexOf(zt)!==-1:zt.test(he));Wr=Wr&&Wr.length>0,(Wr||pe===!0||me===!0&&pe!==!1)===!0&&(he=ee+he+ee),B+=he}else if(he){if(typeof he!="string")return[Error(`Formatter must return a string, null or undefined, got ${JSON.stringify(he)}`)];let Wr=z.length&&he.indexOf(z)>=0,Et=ee!==""&&he.indexOf(ee)>=0,zt=he.indexOf(J)>=0&&J!==ee,vt=he.indexOf(br)>=0,Ft=me&&typeof Pe=="string",pr=We&&We.filter(Je=>typeof Je=="string"?he.indexOf(Je)!==-1:Je.test(he));if(pr=pr&&pr.length>0,Ke)switch(he[0]){case"=":case"+":case"-":case"@":case" ":case"\r":case"\uFF1D":case"\uFF0B":case"\uFF0D":case"\uFF20":he=`'${he}`;break}let Wt=Et===!0||Wr||vt||re||Ft||pr;if(Wt===!0&&zt===!0){let Je=J==="\\"?new RegExp(J+J,"g"):new RegExp(J,"g");he=he.replace(Je,J+J)}if(Et===!0){let Je=new RegExp(ee,"g");he=he.replace(Je,J+ee)}Wt===!0&&(he=ee+he+ee),B+=he}else(pe===!0||Pe===""&&me===!0&&pe!==!1)&&(B+=ee+ee);Y!==L.length-1&&(B+=z)}return[void 0,B]},"stringify"),bom:l(function(r){this.options.bom===!0&&r(CF)},"bom"),headers:l(function(r){if(this.options.header===!1||this.options.columns===void 0)return;let A,M=this.options.columns.map(L=>L.header);if(this.options.eof?([A,M]=this.stringify(M,!0),M+=this.options.record_delimiter):[A,M]=this.stringify(M),A)return A;r(M)},"headers"),__cast:l(function(r,A){let M=typeof r;try{return M==="string"?[void 0,this.options.cast.string(r,A)]:M==="bigint"?[void 0,this.options.cast.bigint(r,A)]:M==="number"?[void 0,this.options.cast.number(r,A)]:M==="boolean"?[void 0,this.options.cast.boolean(r,A)]:r instanceof Date?[void 0,this.options.cast.date(r,A)]:M==="object"&&r!==null?[void 0,this.options.cast.object(r,A)]:[void 0,r,r]}catch(L){return[L]}},"__cast")}},"stringifier");var Fh=l(function(u,s={}){let i=[],[r,A]=Ts(s);if(r!==void 0)throw r;let B=Sh(A,{stop:!1},{records:0});for(let Y of u){let te=B.__transform(Y,function(Te){i.push(Te)});if(te!==void 0)throw te}if(i.length===0){B.bom(te=>{i.push(te)});let Y=B.headers(te=>{i.push(te)});if(Y!==void 0)throw Y}return i.join("")},"stringify");var DF=`
144
144
  **Notes**:
145
145
  * The input should be a JSON array.
146
146
  * The JSON object will be flattened If nested and the keys will be used as headers.
147
- `,Ph=aa({audience:"both",name:"convert_json_to_csv",displayName:"Convert JSON to CSV",description:"This function reads a JSON array and converts it into CSV format.",errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{markdown:tn.MarkDown({value:DF}),json_array:tn.Json({displayName:"JSON Array",defaultValue:[{name:"John",age:30,address:{street:"123 Main St",city:"Los Angeles"}},{name:"Jane",age:25,address:{street:"123 Main St",city:"Los Angeles"}}],description:"Provide a JSON array to convert to CSV format.",required:!0}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter Type",description:"Select the delimiter type for the CSV file.",defaultValue:",",required:!0,options:{options:[{label:"Comma",value:","},{label:"Tab",value:" "}]}})},async run(u){let{json_array:s,delimiter_type:i}=u.propsValue;if(!Array.isArray(s))throw new Error(JSON.stringify({message:"The input should be a JSON array."}));let r=s.map(A=>(0,kh.flatten)(A));return Fh(r,{header:!0,delimiter:i})}});var ws=ta(Ch()),Dh=aa({audience:"both",name:"convert_excel_to_csv",displayName:"Convert Excel to CSV",description:"Converts an Excel file (.xlsx or .xls) into CSV text.",errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{file:tn.File({displayName:"Excel File",description:"The Excel file (.xlsx or .xls) to convert to CSV.",required:!0}),sheet_name:tn.ShortText({displayName:"Sheet Name",description:"Name of the sheet to convert. Leave blank to use the first sheet.",required:!1}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter",description:"Character used to separate values in the output CSV.",defaultValue:",",required:!0,options:{options:[{label:"Comma (,)",value:","},{label:"Tab",value:" "},{label:"Semicolon (;)",value:";"}]}})},async run(u){let{file:s,sheet_name:i,delimiter_type:r}=u.propsValue,A=Buffer.from(s.base64,"base64"),M=A[0]===80&&A[1]===75,L=A[0]===208&&A[1]===207;if(!M&&!L)throw new Error("The file does not appear to be a valid Excel file (.xlsx or .xls). If you supplied a URL, make sure it points directly to the file download, not a webpage.");let B=ws.read(A,{type:"buffer"}),Y=i?.trim()||B.SheetNames[0];if(!B.SheetNames.includes(Y))throw new Error(`Sheet "${Y}" not found. Available sheets: ${B.SheetNames.join(", ")}`);let te=B.Sheets[Y];return{csv:ws.utils.sheet_to_csv(te,{FS:r}),sheet_name:Y,available_sheets:B.SheetNames}}});var OF=oh({displayName:"CSV",description:"Manipulate CSV text",minimumSupportedRelease:"0.30.0",logoUrl:"https://cdn.activepieces.com/pieces/new-core/csv.svg",auth:v0.None(),categories:["CORE"],actions:[vh,Ph,Dh],authors:["kishanprmr","MoShizzle","khaledmashaly","abuaboud","sanket-a11y"],triggers:[]});0&&(module.exports={csv});
147
+ `,Ph=aa({audience:"both",name:"convert_json_to_csv",displayName:"Convert JSON to CSV",description:"This function reads a JSON array and converts it into CSV format.",aiMetadata:{description:"Serializes a JSON array into delimited CSV text (comma or tab), flattening nested objects so dotted key paths become the column headers. Use this when preparing tabular data for a file, export, or attachment; use Convert CSV to JSON for the reverse direction. The input must be a JSON array of rows, not a single object, and the header row is always emitted; pure transformation, read-only and idempotent.",idempotent:!0},errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{markdown:tn.MarkDown({value:DF}),json_array:tn.Json({displayName:"JSON Array",defaultValue:[{name:"John",age:30,address:{street:"123 Main St",city:"Los Angeles"}},{name:"Jane",age:25,address:{street:"123 Main St",city:"Los Angeles"}}],description:"Provide a JSON array to convert to CSV format.",required:!0}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter Type",description:"Select the delimiter type for the CSV file.",defaultValue:",",required:!0,options:{options:[{label:"Comma",value:","},{label:"Tab",value:" "}]}})},async run(u){let{json_array:s,delimiter_type:i}=u.propsValue;if(!Array.isArray(s))throw new Error(JSON.stringify({message:"The input should be a JSON array."}));let r=s.map(A=>(0,kh.flatten)(A));return Fh(r,{header:!0,delimiter:i})}});var ws=ta(Ch()),Dh=aa({audience:"both",name:"convert_excel_to_csv",displayName:"Convert Excel to CSV",description:"Converts an Excel file (.xlsx or .xls) into CSV text.",aiMetadata:{description:"Reads a binary Excel workbook (.xlsx or .xls) and converts a single sheet to delimited CSV text (comma, tab, or semicolon), selecting either a named sheet or the first sheet when no name is given. Pick this when the source is a spreadsheet file; use Convert CSV to JSON when you already have CSV text. Requires a real Excel file whose signature is validated, so HTML or PDF content is rejected, and any sheet name given must exist in the workbook; read-only and idempotent.",idempotent:!0},errorHandlingOptions:{continueOnFailure:{hide:!0},retryOnFailure:{hide:!0}},props:{file:tn.File({displayName:"Excel File",description:"The Excel file (.xlsx or .xls) to convert to CSV.",required:!0}),sheet_name:tn.ShortText({displayName:"Sheet Name",description:"Name of the sheet to convert. Leave blank to use the first sheet.",required:!1}),delimiter_type:tn.StaticDropdown({displayName:"Delimiter",description:"Character used to separate values in the output CSV.",defaultValue:",",required:!0,options:{options:[{label:"Comma (,)",value:","},{label:"Tab",value:" "},{label:"Semicolon (;)",value:";"}]}})},async run(u){let{file:s,sheet_name:i,delimiter_type:r}=u.propsValue,A=Buffer.from(s.base64,"base64"),M=A[0]===80&&A[1]===75,L=A[0]===208&&A[1]===207;if(!M&&!L)throw new Error("The file does not appear to be a valid Excel file (.xlsx or .xls). If you supplied a URL, make sure it points directly to the file download, not a webpage.");let B=ws.read(A,{type:"buffer"}),Y=i?.trim()||B.SheetNames[0];if(!B.SheetNames.includes(Y))throw new Error(`Sheet "${Y}" not found. Available sheets: ${B.SheetNames.join(", ")}`);let te=B.Sheets[Y];return{csv:ws.utils.sheet_to_csv(te,{FS:r}),sheet_name:Y,available_sheets:B.SheetNames}}});var OF=oh({displayName:"CSV",description:"Manipulate CSV text",minimumSupportedRelease:"0.30.0",logoUrl:"https://cdn.activepieces.com/pieces/new-core/csv.svg",auth:v0.None(),categories:["CORE"],actions:[vh,Ph,Dh],authors:["kishanprmr","MoShizzle","khaledmashaly","abuaboud","sanket-a11y"],triggers:[]});0&&(module.exports={csv});
148
148
  /*! Bundled license information:
149
149
 
150
150
  xlsx/dist/cpexcel.js: