1import{j as _,d as y,p as De,r as K}from"./index-yjs0jCN1.js";import{u as de,g as ee}from"./gql-BXUds3tn.js";import{J as Be,S as Ue}from"./JobStatusTag-C9vExJI_.js";import{L as Le}from"./components-Cs2pwaWW.js";import{A as $e}from"./layout-CjNw_1vT.js";import{u as Me}from"./useMutation-D1nG7fOt.js";import"./ApolloContext-MQGfuinR.js";const ke=ee(` 2 query AdminImportOrgsJobsIndex { 3 jobs: importOrgsJobs { 4 totalCount 5 jobs { 6 id 7 status 8 createdAt 9 updatedAt 10 count 11 hasErrors 12 parentOrg { 13 id 14 name 15 } 16 } 17 } 18 } 19`),Pe=[{id:"id",accessor:"id",minWidth:0,Header:"ID",Cell:({value:r})=>r},{id:"parent_org",accessor:r=>{var e;return(e=r.parentOrg)==null?void 0:e.name},Header:"Parent Org",Cell:({value:r})=>r},{id:"status",accessor:r=>r.status,Header:"Status",Cell:({value:r})=>_.jsx(Be,{status:r})},{id:"count",accessor:r=>r.count,Header:"Org Count",Cell:({value:r})=>r},{id:"has_errors",accessor:r=>r.hasErrors,Header:"Errors?",Cell:({value:r})=>_.jsx(Ue,{status:r?"failure":"info",children:r?"Yes":"No"})},{id:"created_at",accessor:r=>r.createdAt,Header:"Created At",Cell:({value:r})=>r},{id:"updated_at",accessor:r=>r.updatedAt,Header:"Updated At",Cell:({value:r})=>r},{id:"edit",accessor:r=>r.id,width:120,minWidth:120,Cell:({value:r})=>_.jsx(y.HStack,{justify:"end",css:{width:"100%"},children:_.jsx(y.Button,{as:Le,to:`/admin/organizations/imports/${r}`,size:"small",children:"View"})})}];function je(){var o,a;const{data:r,previousData:e,refetch:t}=de(ke),i=r??e;if(!i)return null;const n=((o=i==null?void 0:i.jobs)==null?void 0:o.totalCount)??0,s=((a=i==null?void 0:i.jobs)==null?void 0:a.jobs)??[];return _.jsxs(_.Fragment,{children:[_.jsxs(y.HStack,{align:"center",css:{$$gutter:"$space$5",padding:"0 $$gutter"},children:[_.jsx(y.Text,{css:{flex:"auto",paddingBlock:"$5",fontWeight:"bold"},children:"Past Imports"}),_.jsx(y.Button,{size:"small",onPress:()=>t(),children:"Refresh"})]}),_.jsx(y.Table,{columns:Pe,data:s,pageable:!1,rowCount:n,getRowId:u=>u.id})]})}var se=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},B=[],T=[],Ve=typeof Uint8Array<"u"?Uint8Array:Array,re=!1;function _e(){re=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)B[e]=r[e],T[r.charCodeAt(e)]=e;T[45]=62,T[95]=63}function Je(r){re||_e();var e,t,i,n,s,o,a=r.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[a-2]==="="?2:r[a-1]==="="?1:0,o=new Ve(a*3/4-s),i=s>0?a-4:a;var u=0;for(e=0,t=0;e<i;e+=4,t+=3)n=T[r.charCodeAt(e)]<<18|T[r.charCodeAt(e+1)]<<12|T[r.charCodeAt(e+2)]<<6|T[r.charCodeAt(e+3)],o[u++]=n>>16&255,o[u++]=n>>8&255,o[u++]=n&255;return s===2?(n=T[r.charCodeAt(e)]<<2|T[r.charCodeAt(e+1)]>>4,o[u++]=n&255):s===1&&(n=T[r.charCodeAt(e)]<<10|T[r.charCodeAt(e+1)]<<4|T[r.charCodeAt(e+2)]>>2,o[u++]=n>>8&255,o[u++]=n&255),o}function Ye(r){return B[r>>18&63]+B[r>>12&63]+B[r>>6&63]+B[r&63]}function qe(r,e,t){for(var i,n=[],s=e;s<t;s+=3)i=(r[s]<<16)+(r[s+1]<<8)+r[s+2],n.push(Ye(i));return n.join("")}function le(r){re||_e();for(var e,t=r.length,i=t%3,n="",s=[],o=16383,a=0,u=t-i;a<u;a+=o)s.push(qe(r,a,a+o>u?u:a+o));return i===1?(e=r[t-1],n+=B[e>>2],n+=B[e<<4&63],n+="=="):i===2&&(e=(r[t-2]<<8)+r[t-1],n+=B[e>>10],n+=B[e>>4&63],n+=B[e<<2&63],n+="="),s.push(n),s.join("")}function H(r,e,t,i,n){var s,o,a=n*8-i-1,u=(1<<a)-1,f=u>>1,h=-7,c=t?n-1:0,I=t?-1:1,E=r[e+c];for(c+=I,s=E&(1<<-h)-1,E>>=-h,h+=a;h>0;s=s*256+r[e+c],c+=I,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=i;h>0;o=o*256+r[e+c],c+=I,h-=8);if(s===0)s=1-f;else{if(s===u)return o?NaN:(E?-1:1)*(1/0);o=o+Math.pow(2,i),s=s-f}return(E?-1:1)*o*Math.pow(2,s-i)}function me(r,e,t,i,n,s){var o,a,u,f=s*8-n-1,h=(1<<f)-1,c=h>>1,I=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,E=i?0:s-1,C=i?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+c>=1?e+=I/u:e+=I*Math.pow(2,1-c),e*u>=2&&(o++,u/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(e*u-1)*Math.pow(2,n),o=o+c):(a=e*Math.pow(2,c-1)*Math.pow(2,n),o=0));n>=8;r[t+E]=a&255,E+=C,a/=256,n-=8);for(o=o<<n|a,f+=n;f>0;r[t+E]=o&255,E+=C,o/=256,f-=8);r[t+E-C]|=m*128}var ze={}.toString,pe=Array.isArray||function(r){return ze.call(r)=="[object Array]"},He=50;l.TYPED_ARRAY_SUPPORT=se.TYPED_ARRAY_SUPPORT!==void 0?se.TYPED_ARRAY_SUPPORT:!0;q();function q(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function $(r,e){if(q()<e)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=l.prototype):(r===null&&(r=new l(e)),r.length=e),r}function l(r,e,t){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(r,e,t);if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return ie(this,r)}return ge(this,r,e,t)}l.poolSize=8192;l._augment=function(r){return r.__proto__=l.prototype,r};function ge(r,e,t,i){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?We(r,e,t,i):typeof e=="string"?Ge(r,e,t):Xe(r,e)}l.from=function(r,e,t){return ge(null,r,e,t)};l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&l[Symbol.species]);function we(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function Qe(r,e,t,i){return we(e),e<=0?$(r,e):t!==void 0?typeof i=="string"?$(r,e).fill(t,i):$(r,e).fill(t):$(r,e)}l.alloc=function(r,e,t){return Qe(null,r,e,t)};function ie(r,e){if(we(e),r=$(r,e<0?0:ne(e)|0),!l.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}l.allocUnsafe=function(r){return ie(null,r)};l.allocUnsafeSlow=function(r){return ie(null,r)};function Ge(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!l.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var i=xe(e,t)|0;r=$(r,i);var n=r.write(e,t);return n!==i&&(r=r.slice(0,n)),r}function te(r,e){var t=e.length<0?0:ne(e.length)|0;r=$(r,t);for(var i=0;i<t;i+=1)r[i]=e[i]&255;return r}function We(r,e,t,i){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(i||0))throw new RangeError("'length' is out of bounds");return t===void 0&&i===void 0?e=new Uint8Array(e):i===void 0?e=new Uint8Array(e,t):e=new
vendor: 17,325 bytes, line 19
19Uint8Array(e,t,i),l.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=l.prototype):r=te(r,e),r}function Xe(r,e){if(U(e)){var t=ne(e.length)|0;return r=$(r,t),r.length===0||e.copy(r,0,0,t),r}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||pt(e.length)?$(r,0):te(r,e);if(e.type==="Buffer"&&pe(e.data))return te(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function ne(r){if(r>=q())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+q().toString(16)+" bytes");return r|0}l.isBuffer=v;function U(r){return!!(r!=null&&r._isBuffer)}l.compare=function(e,t){if(!U(e)||!U(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,s=0,o=Math.min(i,n);s<o;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!pe(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=l.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(!U(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n};function xe(r,e){if(U(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return z(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ae(r).length;default:if(i)return z(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=xe;function Ze(r,e,t){var i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return at(this,e,t);case"utf8":case"utf-8":return Ee(this,e,t);case"ascii":return st(this,e,t);case"latin1":case"binary":return lt(this,e,t);case"base64":return nt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ut(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}l.prototype._isBuffer=!0;function j(r,e,t){var i=r[e];r[e]=r[t],r[t]=i}l.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)j(this,t,t+1);return this};l.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)j(this,t,t+3),j(this,t+1,t+2);return this};l.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)j(this,t,t+7),j(this,t+1,t+6),j(this,t+2,t+5),j(this,t+3,t+4);return this};l.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?Ee(this,0,e):Ze.apply(this,arguments)};l.prototype.equals=function(e){if(!U(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){var e="",t=He;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"};l.prototype.compare=function(e,t,i,n,s){if(!U(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var o=s-n,a=i-t,u=Math.min(o,a),f=this.slice(n,s),h=e.slice(t,i),c=0;c<u;++c)if(f[c]!==h[c]){o=f[c],a=h[c];break}return o<a?-1:a<o?1:0};function ye(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,i)),U(e))return e.length===0?-1:ae(r,e,t,i,n);if(typeof e=="number")return e=e&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ae(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function ae(r,e,t,i,n){var s=1,o=r.length,a=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,a/=2,t/=2}function u(E,C){return s===1?E[C]:E.readUInt16BE(C*s)}var f;if(n){var h=-1;for(f=t;f<o;f++)if(u(r,f)===u(e,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===a)return h*s}else h!==-1&&(f-=f-h),h=-1}else for(t+a>o&&(t=o-a),f=t;f>=0;f--){for(var c=!0,I=0;I<a;I++)if(u(r,f+I)!==u(e,I)){c=!1;break}if(c)return f}return-1}l.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};l.prototype.indexOf=function(e,t,i){return ye(this,e,t,i,!0)};l.prototype.lastIndexOf=function(e,t,i){return ye(this,e,t,i,!1)};function Ke(r,e,t,i){t=Number(t)||0;var n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;o<i;++o){var a=parseInt(e.substr(o*2,2),16);if(isNaN(a))return o;r[t+o]=a}return o}function et(r,e,t,i){return W(z(e,r.length-t),r,t,i)}function Ie(r,e,t,i){return W(_t(e),r,t,i)}function tt(r,e,t,i){return Ie(r,e,t,i)}function rt(r,e,t,i){return W(Ae(e),r,t,i)}function it(r,e,t,i){return W(mt(e,r.length-t),r,t,i)}l.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((i===void 0||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ke(this,e,t,i);case"utf8":case"utf-8":return et(this,e,t,i);case"ascii":return Ie(this,e,t,i);case"latin1":case"binary":return tt(this,e,t,i);case"base64":return rt(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return it(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function nt(r,e,t){return e===0&&t===r.length?le(r):le(r.slice(e,t))}function Ee(r,e,t){t=Math.min(r.length,t);for(var i=[],n=e;n<t;){var s=r[n],o=null,a=s>239?4:s>223?3:s>191?2:1;if(n+a<=t){var u,f,h,c;switch(a){case 1:s<128&&(o=s);break;case 2:u=r[n+1],(u&192)===128&&(c=(s&31)<<6|u&63,c>127&&(o=c));break;case 3:u=r[n+1],f=r[n+2],(u&192)===128&&(f&192)===128&&(c=(s&15)<<12|(u&63)<<6|f&63,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:u=r[n+1],f=r[n+2],h=r[n+3],(u&192)===128&&(f&192)===128&&(h&192)===128&&(c=(s&15)<<18|(u&63)<<12|(f&63)<<6|h&63,c>65535&&c<1114112&&(o=c))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|o&1023),i.push(o),n+=a}return ot(i)}var ue=4096;function ot(r){var e=r.length;if(e<=ue)return String.fromCharCode.apply(String,r);for(var t="",i=0;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=ue));return t}function st(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function lt(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function at(r,e,t){var i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);for(var n="",s=e;s<t;++s)n+=dt(r[s]);return n}function ut(r,e,t){for(var i=r.slice(e,t),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+i[s+1]*256);return n}l.prototype.slice=function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n;if(l.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=l.prototype;else{var s=t-e;n=new l(s,void 0);for(var o=0;o<s;++o)n[o]=this[o+e]}return n};function A(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(e,t,i){e=e|0,t=t|0,i||A(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return n};l.prototype.readUIntBE=function(e,t,i){e=e|0,t=t|0,i||A(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n};l.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]};l.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUInt32LE=function(e,t){return t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUInt32BE=function(e,t){return t||A(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readIntLE=function(e,t,i){e=e|0,t=t|0,i||A(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n};l.prototype.readIntBE=function(e,t,i){e=e|0,t=t|0,i||A(e,t,this.length);for(var n=t,s=1,o=this[e+--n];n>0&&(s*=256);)o+=this[e+--n]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};l.prototype.readInt8=function(e,t){return t||A(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){t||A(e,2,this.length);var i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};l.prototype.readInt16BE=function(e,t){t||A(e,2,this.length);var i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};l.prototype.readInt32LE=function(e,t){return t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readFloatLE=function(e,t){return t||A(e,4,this.length),H(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),H(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),H(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),H(this,e,!1,52,8)};function F(r,e,t,i,n,s){if(!U(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;F(this,e,t,i,s,0)}var o=1,a=0;for(this[t]=e&255;++a<i&&(o*=256);)this[t+a]=e/o&255;return t+i};l.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;F(this,e,t,i,s,0)}var o=i-1,a=1;for(this[t+o]=e&255;--o>=0&&(a*=256);)this[t+o]=e/a&255;return t+i};l.prototype.writeUInt8=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function Q(r,e,t,i){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(r.length-t,2);n<s;++n)r[t+n]=(e&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}l.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Q(this,e,t,!0),t+2};l.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Q(this,e,t,!1),t+2};function G(r,e,t,i){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(r.length-t,4);n<s;++n)r[t+n]=e>>>(i?n:3-n)*8&255}l.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):G(this,e,t,!0),t+4};l.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):G(this,e,t,!1),t+4};l.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);F(this,e,t,i,s-1,-s)}var o=0,a=1,u=0;for(this[t]=e&255;++o<i&&(a*=256);)e<0&&u===0&&this[t+o-1]!==0&&(u=1),this[t+o]=(e/a>>0)-u&255;return t+i};l.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);F(this,e,t,i,s-1,-s)}var o=i-1,a=1,u=0;for(this[t+o]=e&255;--o>=0&&(a*=256);)e<0&&u===0&&this[t+o+1]!==0&&(u=1),this[t+o]=(e/a>>0)-u&255;return t+i};l.prototype.writeInt8=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Q(this,e,t,!0),t+2};l.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Q(this,e,t,!1),t+2};l.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):G(this,e,t,!0),t+4};l.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t|0,i||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):G(this,e,t,!1),t+4};function Se(r,e,t,i,n,s){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function be(r,e,t,i,n){return n||Se(r,e,t,4),me(r,e,t,i,23,4),t+4}l.prototype.writeFloatLE=function(e,t,i){return be(this,e,t,!0,i)};l.prototype.writeFloatBE=function(e,t,i){return be(this,e,t,!1,i)};function Oe(r,e,t,i,n){return n||Se(r,e,t,8),me(r,e,t,i,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,i){return Oe(this,e,t,!0,i)};l.prototype.writeDoubleBE=function(e,t,i){return Oe(this,e,t,!1,i)};l.prototype.copy=function(e,t,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);var s=n-i,o;if(this===e&&i<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+i];else if(s<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s};l.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{var a=U(e)?e:z(new l(e,n).toString()),u=a.length;for(o=0;o<i-t;++o)this[o+t]=a[o%u]}return this};var ft=/[^+\/0-9A-Za-z-_]/g;function ct(r){if(r=ht(r).replace(ft,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function ht(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function dt(r){return r<16?"0"+r.toString(16):r.toString(16)}function z(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],o=0;o<i;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function _t(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function mt(r,e){for(var t,i,n,s=[],o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),i=t>>8,n=t%256,s.push(n),s.push(i);return s}function Ae(r){return Je(ct(r))}function W(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function pt(r){return r!==r}function v(r){return r!=null&&(!!r._isBuffer||Re(r)||gt(r))}function Re(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function gt(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&Re(r.slice(0,0))}
19class p extends Error{constructor(e,t,i,...n){Array.isArray(t)&&(t=t.join(" ").trim()),super(t),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,p),this.code=e;for(const s of n)for(const o in s){const a=s[o];this[o]=v(a)?a.toString(i.encoding):a==null?a:JSON.parse(JSON.stringify(a))}}}const wt=function(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)},Ce=function(r){const e=[];for(let t=0,i=r.length;t<i;t++){const n=r[t];if(n==null||n===!1)e[t]={disabled:!0};else if(typeof n=="string")e[t]={name:n};else if(wt(n)){if(typeof n.name!="string")throw new p("CSV_OPTION_COLUMNS_MISSING_NAME",["Option columns missing name:",`property "name" is required at position ${t}`,"when column is an object literal"]);e[t]=n}else throw new p("CSV_INVALID_COLUMN_DEFINITION",["Invalid column definition:","expect a string or a literal object,",`got ${JSON.stringify(n)} at position ${t}`])}return e};class fe{constructor(e=100){this.size=e,this.length=0,this.buf=l.allocUnsafe(e)}prepend(e){if(v(e)){const t=this.length+e.length;if(t>=this.size&&(this.resize(),t>=this.size))throw Error("INVALID_BUFFER_STATE");const i=this.buf;this.buf=l.allocUnsafe(this.size),e.copy(this.buf,0),i.copy(this.buf,e.length),this.length+=e.length}else{const t=this.length++;t===this.size&&this.resize();const i=this.clone();this.buf[0]=e,i.copy(this.buf,1,0,t)}}append(e){const t=this.length++;t===this.size&&this.resize(),this.buf[t]=e}clone(){return l.from(this.buf.slice(0,this.length))}resize(){const e=this.length;this.size=this.size*2;const t=l.allocUnsafe(this.size);this.buf.copy(t,0,0,e),this.buf=t}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}}const xt=12,yt=13,It=10,Et=32,St=9,bt=function(r){return{bomSkipped:!1,bufBytesStart:0,castField:r.cast_function,commenting:!1,error:void 0,enabled:r.from_line===1,escaping:!1,escapeIsQuote:v(r.escape)&&v(r.quote)&&l.compare(r.escape,r.quote)===0,expectedRecordLength:Array.isArray(r.columns)?r.columns.length:void 0,field:new fe(20),firstLineToHeaders:r.cast_first_line_to_header,needMoreDataSize:Math.max(r.comment!==null?r.comment.length:0,...r.delimiter.map(e=>e.length),r.quote!==null?r.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new fe(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:r.record_delimiter.length===0?0:Math.max(...r.record_delimiter.map(e=>e.length)),trimChars:[l.from(" ",r.encoding)[0],l.from(" ",r.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[l.from(l.from([yt],"utf8").toString(),r.encoding),l.from(l.from([It],"utf8").toString(),r.encoding),l.from(l.from([xt],"utf8").toString(),r.encoding),l.from(l.from([Et],"utf8").toString(),r.encoding),l.from(l.from([St],"utf8").toString(),r.encoding)]}},Ot=function(r){return r.replace(/([A-Z])/g,function(e,t){return"_"+t.toLowerCase()})},ce=function(r){const e={};for(const i in r)e[Ot(i)]=r[i];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new p("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new p("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new p("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(i){const n=Date.parse(i);return isNaN(n)?i:new Date(n)};else if(typeof e.cast_date!="function")throw new p("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=Ce(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new p("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new p("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}
19`],e);if(e.columns===!1)throw new p("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=l.from(e.comment,e.encoding)),!v(e.comment))throw new p("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);if(e.comment_no_infix===void 0||e.comment_no_infix===null||e.comment_no_infix===!1)e.comment_no_infix=!1;else if(e.comment_no_infix!==!0)throw new p("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(e.comment_no_infix)}`],e);const t=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new p("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);if(e.delimiter=e.delimiter.map(function(i){if(i==null||i===!1)return l.from(",",e.encoding);if(typeof i=="string"&&(i=l.from(i,e.encoding)),!v(i)||i.length===0)throw new p("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);return i}),e.escape===void 0||e.escape===!0?e.escape=l.from('"',e.encoding):typeof e.escape=="string"?e.escape=l.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!v(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(r.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(r.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(r.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new p("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new p("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(v(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new p("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.on_skip!==void 0&&e.on_skip!==null&&typeof e.on_skip!="function")throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(e.on_skip)}`);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=l.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=l.from(e.quote,e.encoding)),!v(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||v(e.record_delimiter)){if(e.record_delimiter.length===0)throw new p("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new p("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of str
19ing|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(i,n){if(typeof i!="string"&&!v(i))throw new p("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${n},`,`got ${JSON.stringify(i)}`],e);if(i.length===0)throw new p("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${n},`,`got ${JSON.stringify(i)}`],e);return typeof i=="string"&&(i=l.from(i,e.encoding)),i}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&r.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&r.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(r.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(r.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(r.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(r.to_line)}`);return e},he=function(r){return r.every(e=>e==null||e.toString&&e.toString().trim()==="")},At=13,Rt=10,V={utf8:l.from([239,187,191]),utf16le:l.from([255,254])},Ct=function(r={}){const e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},t=ce(r);return{info:e,original_options:r,options:t,state:bt(t),__needMoreData:function(i,n,s){if(s)return!1;const{encoding:o,escape:a,quote:u}=this.options,{quoting:f,needMoreDataSize:h,recordDelimiterMaxLength:c}=this.state,I=n-i-1,E=Math.max(h,c===0?l.from(`\r 20`,o).length:c,f?(a===null?0:a.length)+u.length:0,f?u.length+c:0);return I<E},parse:function(i,n,s,o){const{bom:a,comment_no_infix:u,encoding:f,from_line:h,ltrim:c,max_record_size:I,raw:E,relax_quotes:C,rtrim:m,skip_empty_lines:S,to:b,to_line:x}=this.options;let{comment:g,escape:N,quote:D,record_delimiter:X}=this.options;
20const{bomSkipped:Ne,previousBuf:J,rawBuffer:Fe,escapeIsQuote:Te}=this.state;let w;if(J===void 0)if(i===void 0){o();return}else w=i;else J!==void 0&&i===void 0?w=J:w=l.concat([J,i]);if(Ne===!1)if(a===!1)this.state.bomSkipped=!0;else if(w.length<3){if(n===!1){this.state.previousBuf=w;return}}else{for(const O in V)if(V[O].compare(w,0,V[O].length)===0){const M=V[O].length;this.state.bufBytesStart+=M,w=w.slice(M),this.options=ce({...this.original_options,encoding:O}),{comment:g,escape:N,quote:D}=this.options;break}this.state.bomSkipped=!0}const Z=w.length;let d;for(d=0;d<Z&&!this.__needMoreData(d,Z,n);d++){if(this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1),x!==-1&&this.info.lines>x){this.state.stop=!0,o();return}this.state.quoting===!1&&X.length===0&&this.__autoDiscoverRecordDelimiter(w,d)&&(X=this.options.record_delimiter);const O=w[d];if(E===!0&&Fe.append(O),(O===At||O===Rt)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(N!==null&&this.state.quoting===!0&&this.__isEscape(w,d,O)&&d+N.length<Z)if(Te){if(this.__isQuote(w,d+N.length)){this.state.escaping=!0,d+=N.length-1;continue}}else{this.state.escaping=!0,d+=N.length-1;continue}if(this.state.commenting===!1&&this.__isQuote(w,d))if(this.state.quoting===!0){const R=w[d+D.length],k=m&&this.__isCharTrimable(w,d+D.length),L=g!==null&&this.__compareBytes(g,w,d+D.length,R),P=this.__isDelimiter(w,d+D.length,R),Y=X.length===0?this.__autoDiscoverRecordDelimiter(w,d+D.length):this.__isRecordDelimiter(R,w,d+D.length);if(N!==null&&this.__isEscape(w,d,O)&&this.__isQuote(w,d+N.length))d+=N.length-1;else if(!R||P||Y||L||k){this.state.quoting=!1,this.state.wasQuoting=!0,d+=D.length-1;continue}else if(C===!1){const oe=this.__error(new p("CSV_INVALID_CLOSING_QUOTE",["Invalid Closing Quote:",`got "${String.fromCharCode(R)}"`,`at line ${this.info.lines}`,"instead of delimiter, record delimiter, trimable character","(if activated) or comment"],this.options,this.__infoField()));if(oe!==void 0)return oe}else this.state.quoting=!1,this.state.wasQuoting=!0,this.state.field.prepend(D),d+=D.length-1}else if(this.state.field.length!==0){if(C===!1){const R=this.__infoField(),k=Object.keys(V).map(P=>V[P].equals(this.state.field.toString())?P:!1).filter(Boolean)[0],L=this.__error(new p("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(R.column)} at line ${R.lines}, value is ${JSON.stringify(this.state.field.toString(f))}`,k?`(${k} bom)`:void 0],this.options,R,{field:this.state.field}));if(L!==void 0)return L}}else{this.state.quoting=!0,d+=D.length-1;continue}if(this.state.quoting===!1){const R=this.__isRecordDelimiter(O,w,d);if(R!==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)>=h){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),d+=R-1;continue}if(S===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,d+=R-1;continue}this.info.bytes=this.state.bufBytesStart+d;const P=this.__onField();if(P!==void 0)return P;this.info.bytes=this.state.bufBytesStart+d+R;const Y=this.__onRecord(s);if(Y!==void 0)return Y;if(b!==-1&&this.info.records>=b){this.state.stop=!0,o();return}}this.state.commenting=!1,d+=R-1;continue}if(this.state.commenting)continue;if(g!==null&&(u===!1||this.state.record.length===0&&this.state.field.length===0)&&this.__compareBytes(g,w,d,O)!==0){this.state.commenting=!0;continue}const k=this.__isDelimiter(w,d,O);if(k!==0){this.info.bytes=this.state.bufBytesStart+d;const L=this.__onField();if(L!==void 0)return L;d+=k-1;continue}}}if(this.state.commenting===!1&&I!==0&&this.state.record_length+this.state.field.length>I)return this.__error(new p("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${I}`,`at line ${this.info.lines}`],this.options,this.__infoField()));const M=c===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(w,d),ve=m===!1||this.state.wasQuoting===!1;if(M===!0&&ve===!0)this.state.field.append(O);else{if(m===!0&&!this.__isCharTrimable(w,d))return this.__error(new p("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","foun
20d non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));M===!1&&(d+=this.__isCharTrimable(w,d)-1);continue}}if(n===!0)if(this.state.quoting===!0){const O=this.__error(new p("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(O!==void 0)return O}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+d;const O=this.__onField();if(O!==void 0)return O;const M=this.__onRecord(s);if(M!==void 0)return M}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=d,this.state.previousBuf=w.slice(d);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(i){const{columns:n,group_columns_by_name:s,encoding:o,info:a,from:u,relax_column_count:f,relax_column_count_less:h,relax_column_count_more:c,raw:I,skip_records_with_empty_values:E}=this.options,{enabled:C,record:m}=this.state;if(C===!1)return this.__resetRecord();const S=m.length;if(n===!0){if(E===!0&&he(m)){this.__resetRecord();return}return this.__firstLineToColumns(m)}if(n===!1&&this.info.records===0&&(this.state.expectedRecordLength=S),S!==this.state.expectedRecordLength){const b=n===!1?new p("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${S} on line ${this.info.lines}`],this.options,this.__infoField(),{record:m}):new p("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${n.length},`,`got ${S} on line ${this.info.lines}`],this.options,this.__infoField(),{record:m});if(f===!0||h===!0&&S<this.state.expectedRecordLength||c===!0&&S>this.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=b;else{const x=this.__error(b);if(x)return x}}if(E===!0&&he(m)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,u===1||this.info.records>=u){const{objname:b}=this.options;if(n!==!1){const x={};for(let g=0,N=m.length;g<N;g++)n[g]===void 0||n[g].disabled||(s===!0&&x[n[g].name]!==void 0?Array.isArray(x[n[g].name])?x[n[g].name]=x[n[g].name].concat(m[g]):x[n[g].name]=[x[n[g].name],m[g]]:x[n[g].name]=m[g]);if(I===!0||a===!0){const g=Object.assign({record:x},I===!0?{raw:this.state.rawBuffer.toString(o)}:{},a===!0?{info:this.__infoRecord()}:{}),N=this.__push(b===void 0?g:[x[b],g],i);if(N)return N}else{const g=this.__push(b===void 0?x:[x[b],x],i);if(g)return g}}else if(I===!0||a===!0){const x=Object.assign({record:m},I===!0?{raw:this.state.rawBuffer.toString(o)}:{},a===!0?{info:this.__infoRecord()}:{}),g=this.__push(b===void 0?x:[m[b],x],i);if(g)return g}else{const x=this.__push(b===void 0?m:[m[b],m],i);if(x)return x}}this.__resetRecord()},__firstLineToColumns:function(i){const{firstLineToHeaders:n}=this.state;try{const s=n===void 0?i:n.call(null,i);if(!Array.isArray(s))return this.__error(new p("CSV_INVALID_COLUMN_MAPPING",["Invalid Column Mapping:","expect an array from column function,",`got ${JSON.stringify(s)}`],this.options,this.__infoField(),{headers:s}));const o=Ce(s);this.state.expectedRecordLength=o.length,this.options.columns=o,this.__resetRecord();return}catch(s){return s}},__resetRecord:function(){this.options.raw===!0&&this.state.rawBuffer.reset(),this.state.error=void 0,this.state.record=[],this.state.record_length=0},__onField:function(){const{cast:i,encoding:n,rtrim:s,max_record_size:o}=this.options,{enabled:a,wasQuoting:u}=this.state;if(a===!1)return this.__resetField();let f=this.state.field.toString(n);if(s===!0&&u===!1&&(f=f.trimRight()),i===!0){const[h,c]=this.__cast(f);if(h!==void 0)return h;f=c}this.state.record.push(f),o!==0&&typeof f=="string"&&(this.state.record_length+=f.length),this.__resetField()},__resetField:function(){this.state.field.reset(),this.state.wasQuoting=!1},__push:function(i,n){const{on_record:s}=this.options;if(s!==void 0){const o=this.__infoRecord();try{i=s.call(null,i,o)}catch(a){return a}if(i==null)return}n(i)}
20,__cast:function(i){const{columns:n,relax_column_count:s}=this.options;if(Array.isArray(n)===!0&&s&&this.options.columns.length<=this.state.record.length)return[void 0,void 0];if(this.state.castField!==null)try{const a=this.__infoField();return[void 0,this.state.castField.call(null,i,a)]}catch(a){return[a]}if(this.__isFloat(i))return[void 0,parseFloat(i)];if(this.options.cast_date!==!1){const a=this.__infoField();return[void 0,this.options.cast_date.call(null,i,a)]}return[void 0,i]},__isCharTrimable:function(i,n){return((o,a)=>{const{timchars:u}=this.state;e:for(let f=0;f<u.length;f++){const h=u[f];for(let c=0;c<h.length;c++)if(h[c]!==o[a+c])continue e;return h.length}return 0})(i,n)},__isFloat:function(i){return i-parseFloat(i)+1>=0},__compareBytes:function(i,n,s,o){if(i[0]!==o)return 0;const a=i.length;for(let u=1;u<a;u++)if(i[u]!==n[s+u])return 0;return a},__isDelimiter:function(i,n,s){const{delimiter:o,ignore_last_delimiters:a}=this.options;if(a===!0&&this.state.record.length===this.options.columns.length-1)return 0;if(a!==!1&&typeof a=="number"&&this.state.record.length===a-1)return 0;e:for(let u=0;u<o.length;u++){const f=o[u];if(f[0]===s){for(let h=1;h<f.length;h++)if(f[h]!==i[n+h])continue e;return f.length}}return 0},__isRecordDelimiter:function(i,n,s){const{record_delimiter:o}=this.options,a=o.length;e:for(let u=0;u<a;u++){const f=o[u],h=f.length;if(f[0]===i){for(let c=1;c<h;c++)if(f[c]!==n[s+c])continue e;return f.length}}return 0},__isEscape:function(i,n,s){const{escape:o}=this.options;if(o===null)return!1;const a=o.length;if(o[0]===s){for(let u=0;u<a;u++)if(o[u]!==i[n+u])return!1;return!0}return!1},__isQuote:function(i,n){const{quote:s}=this.options;if(s===null)return!1;const o=s.length;for(let a=0;a<o;a++)if(s[a]!==i[n+a])return!1;return!0},__autoDiscoverRecordDelimiter:function(i,n){const{encoding:s}=this.options,o=[l.from(`\r 21`,s),l.from(` 22`,s),l.from("\r",s)];e:for(let a=0;a<o.length;a++){const u=o[a].length;for(let f=0;f<u;f++)if(o[a][f]!==i[n+f])continue e;return this.options.record_delimiter.push(o[a]),this.state.recordDelimiterMaxLength=o[a].length,o[a].length}return 0},__error:function(i){const{encoding:n,raw:s,skip_records_with_error:o}=this.options,a=typeof i=="string"?new Error(i):i;if(o){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(a,s?this.state.rawBuffer.toString(n):void 0);return}else return a},__infoDataSet:function(){return{...this.info,columns:this.options.columns}},__infoRecord:function(){const{columns:i,raw:n,encoding:s}=this.options;return{...this.__infoDataSet(),error:this.state.error,header:i===!0,index:this.state.record.length,raw:n?this.state.rawBuffer.toString(s):void 0}},__infoField:function(){const{columns:i}=this.options,n=Array.isArray(i);return{...this.__infoRecord(),column:n===!0?i.length>this.state.record.length?i[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}},Nt=function(r,e={}){typeof r=="string"&&(r=l.from(r));const t=e&&e.objname?{}:[],i=Ct(e),n=u=>{i.options.objname===void 0?t.push(u):t[u[0]]=u[1]},s=()=>{},o=i.parse(r,!1,n,s);if(o!==void 0)throw o;const a=i.parse(void 0,!0,n,s);if(a!==void 0)throw a;return t},Ft=[{id:"Org Name",accessor:"Org Name",Header:"Org Name",Cell:({value:r})=>r},{id:"Org Slug",accessor:"Org Slug",Header:"Org Slug",Cell:({value:r})=>r},{id:"City/Region Served",accessor:"City/Region Served",Header:"City/Region Served",Cell:({value:r})=>r},{id:"Org Type",accessor:"Org Type",Header:"Org Type",Cell:({value:r})=>r},{id:"Org Theme",accessor:"Org Theme",Header:"Org Theme",Cell:({value:r})=>r},{id:"Seed Org",accessor:"Seed Org",Header:"Seed Org",Cell:({value:r})=>r}];function Tt(){var C;const r=De(),{data:e,previousData:t}=de(ee(` 23 query AdminImportOrgsJobsIndex_UploadCard { 24 orgs(perPage: 100000) { 25 orgs { 26 id 27 name 28 slug 29 } 30 } 31 } 32 `)),[i]=Me(ee(` 33 mutation AdminImportOrgsJobsIndex_UploadCardMutation($input: ImportOrgsInput!) { 34 job: importOrgs(input: $input) { 35 id 36 status 37 createdAt 38 updatedAt 39 count 40 hasErrors 41 parentOrg { 42 id 43 name 44 } 45 } 46 } 47 `),{update:(m,{data:S}
47)=>{S&&m.modify({id:"ROOT_QUERY",fields:{importOrgsJobs:(b,{toReference:x})=>({...b,jobs:[x(S.job),...b.jobs??[]]})}})}}),n=e??t,s=((C=n==null?void 0:n.orgs)==null?void 0:C.orgs)??[],[o,a]=K.useState(null),[u,f]=K.useState(null),[h,c]=K.useState(null);async function I(m){var b;const S=((b=m.target.files)==null?void 0:b[0])??null;if(a(S),S){const x=Nt(await S.text(),{columns:!0});f(x)}else f(null)}async function E(){if(!o||!h||o.type!=="text/csv")return;const m=await o.text(),{data:S}=await i({variables:{input:{parentOrgId:h,csv:m}}});a(null),f(null),c(null),S!=null&&S.job&&r(`/admin/organizations/imports/${S.job.id}`)}return _.jsxs(y.VStack,{children:[_.jsx($e,{children:_.jsxs(y.Card,{as:y.VStack,padding:!0,children:[_.jsx(y.Text,{css:{fontWeight:"bold"},children:"Import Organizations"}),_.jsxs(y.VStack,{space:"small",children:[_.jsx(y.Label,{htmlFor:"import_parentOrgId",children:"Parent Org"}),_.jsxs(y.Select,{id:"import_parentOrgId",value:h,onChange:m=>c(m.target.value),children:[_.jsx("option",{value:"",children:"Select a parent org"}),s.map(m=>_.jsxs("option",{value:m.id,children:[m.name," (ID: ",m.id,", Slug: ",m.slug,")"]},m.id))]})]}),o?_.jsxs(y.HStack,{align:"center",children:[_.jsx(y.Text,{css:{flex:"auto"},children:o?o.name:"Choose a CSV file to upload"}),_.jsxs(y.HStack,{as:"label",css:{position:"relative"},children:[_.jsx(y.Box,{as:"input",accept:"text/csv",type:"file",css:{visibility:"hidden",position:"absolute",left:0,right:0,width:"100%",height:"100%"},onChange:I}),_.jsx(y.Button,{as:"span",intent:"warning",children:"Change"})]}),_.jsx(y.Button,{isDisabled:!h,onPress:E,children:"Upload"})]}):_.jsxs(y.HStack,{as:"label",css:{flex:"auto",position:"relative"},children:[_.jsx(y.Box,{as:"input",accept:"text/csv",type:"file",css:{visibility:"hidden",position:"absolute",left:0,right:0,width:"100%",height:"100%"},onChange:I}),_.jsx(y.Button,{as:"span",css:{flex:"auto"},children:"Choose a CSV file to upload"})]})]})}),u&&_.jsxs(y.Box,{css:{marginBottom:"$15"},children:[_.jsx(y.Box,{css:{$$gutter:"$space$5",padding:"0 $$gutter $6"},children:_.jsx(y.Text,{css:{fontWeight:"bold"},children:"Import Data"})}),_.jsx(y.Table,{columns:Ft,data:u})]})]})}function kt(){return _.jsxs(_.Fragment,{children:[_.jsx(Tt,{}),_.jsx(je,{})]})}export{kt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.