@sqlitecloud/drivers 0.0.34

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.
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.sqlitecloud=t():e.sqlitecloud=t()}(this,(()=>(()=>{var e={672:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,s)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getInitializationCommands=t.anonimizeError=t.anonimizeCommand=t.OperationsQueue=t.SQLiteCloudConnection=t.DEFAULT_PORT=t.DEFAULT_TIMEOUT=void 0;const i=n(230),a=n(261);t.DEFAULT_TIMEOUT=3e5,t.DEFAULT_PORT=9960,t.SQLiteCloudConnection=class{constructor(e,t){this.operations=new c,this.config="string"==typeof e?this.validateConfiguration({connectionString:e}):this.validateConfiguration(e),this.connect(t)}get connected(){var e;return(null===(e=this.transport)||void 0===e?void 0:e.connected)||!1}connect(e){return this.operations.enqueue((t=>{var r,s;a.isBrowser||(null===(r=this.config)||void 0===r?void 0:r.useWebsocket)||(null===(s=this.config)||void 0===s?void 0:s.gatewayUrl)?Promise.resolve().then((()=>o(n(122)))).then((n=>{this.transport=new n.WebSocketTransport,this.transport.connect(this.config,(n=>{n&&(console.error(`SQLiteCloudConnection.connect - error while connecting WebSocketTransport: ${n.toString()}`,this.config,n),this.close()),null==e||e.call(this,n||null),t(n)}))})).catch((e=>{t(e)})):Promise.resolve().then((()=>o(n(36)))).then((n=>{this.transport=new n.TlsSocketTransport,this.transport.connect(this.config,(n=>{n&&(console.error(`SQLiteCloudConnection.connect - error while connecting TlsSocketTransport: ${n.toString()}`,this.config,n),this.close()),null==e||e.call(this,n||null),t(n)}))})).catch((e=>{t(e)}))})),this}validateConfiguration(e){if(e.connectionString&&(e=Object.assign(Object.assign(Object.assign({},e),(0,a.parseConnectionString)(e.connectionString)),{connectionString:e.connectionString})),e.port||(e.port=t.DEFAULT_PORT),e.timeout=e.timeout&&e.timeout>0?e.timeout:t.DEFAULT_TIMEOUT,e.clientId||(e.clientId="SQLiteCloud"),e.verbose=(0,a.parseBoolean)(e.verbose),e.noBlob=(0,a.parseBoolean)(e.noBlob),e.compression=(0,a.parseBoolean)(e.compression),e.createDatabase=(0,a.parseBoolean)(e.createDatabase),e.nonlinearizable=(0,a.parseBoolean)(e.nonlinearizable),e.sqliteMode=(0,a.parseBoolean)(e.sqliteMode),!e.username||!e.password||!e.host)throw console.error("SQLiteCloudConnection.validateConfiguration - missing arguments",e),new i.SQLiteCloudError("The user, password and host arguments must be specified.",{errorCode:"ERR_MISSING_ARGS"});return e.connectionString||(e.connectionString=`sqlitecloud://${e.username}:${e.password}@${e.host}:${e.port}/${e.database}`),e}log(e,...t){this.config.verbose&&(e=l(e),console.log(`${(new Date).toISOString()} ${this.config.clientId}: ${e}`,...t))}verbose(){this.config.verbose=!0}sendCommands(e,t){return this.operations.enqueue((n=>{if(this.transport)this.transport.processCommands(e,((e,r)=>{null==t||t.call(this,e,r),n(e)}));else{const e=new i.SQLiteCloudError("Connection not established",{errorCode:"ERR_CONNECTION_NOT_ESTABLISHED"});null==t||t.call(this,e),n(e)}})),this}close(){var e;return this.operations.clear(),null===(e=this.transport)||void 0===e||e.close(),this.transport=void 0,this}};class c{constructor(){this.queue=[],this.isProcessing=!1}enqueue(e){this.queue.push(e),this.isProcessing||this.processNext()}clear(){this.queue=[],this.isProcessing=!1}processNext(){if(0===this.queue.length)return void(this.isProcessing=!1);this.isProcessing=!0;const e=this.queue.shift();null==e||e((()=>{this.processNext()}))}}function l(e){return(e=(e=e.replace(/USER \S+/,"USER ******")).replace(/PASSWORD \S+?(?=;)/,"PASSWORD ******")).replace(/HASH \S+?(?=;)/,"HASH ******")}t.OperationsQueue=c,t.anonimizeCommand=l,t.anonimizeError=function(e){return(null==e?void 0:e.message)&&(e.message=l(e.message)),e},t.getInitializationCommands=function(e){let t=`AUTH USER ${e.username||""} ${e.passwordHashed?"HASH":"PASSWORD"} ${e.password||""}; `;return e.database&&(e.createDatabase&&!e.dbMemory&&(t+=`CREATE DATABASE ${e.database} IF NOT EXISTS; `),t+=`USE DATABASE ${e.database}; `),e.sqliteMode&&(t+="SET CLIENT KEY SQLITE TO 1; "),e.compression&&(t+="SET CLIENT KEY COMPRESSION TO 1; "),e.nonlinearizable&&(t+="SET CLIENT KEY NONLINEARIZABLE TO 1; "),e.noBlob&&(t+="SET CLIENT KEY NOBLOB TO 1; "),e.maxData&&(t+=`SET CLIENT KEY MAXDATA TO ${e.maxData}; `),e.maxRows&&(t+=`SET CLIENT KEY MAXROWS TO ${e.maxRows}; `),e.maxRowset&&(t+=`SET CLIENT KEY MAXROWSET TO ${e.maxRowset}; `),t}},537:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(s,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Database=void 0;const o=n(672),i=n(875),a=n(230),c=n(261),l=n(195),u=s(n(729));class h extends u.default{constructor(e,t,n){super(),this.connections=[],this.config="string"==typeof e?{connectionString:e}:e,"function"==typeof t&&(n=t,t=void 0),this.getConnection(n)}getConnection(e){var t;(null===(t=this.connections)||void 0===t?void 0:t.length)>0?null==e||e.call(this,null,this.connections[0]):this.connections.push(new o.SQLiteCloudConnection(this.config,(t=>{t?this.handleError(this.connections[0],t,e):(console.assert,null==e||e.call(this,null,this.connections[0]),this.emitEvent("open"))})))}handleError(e,t,n){e&&(this.connections=this.connections.filter((t=>t!==e)),e.close()),n?n.call(this,t):this.emitEvent("error",t)}processContext(e){if(e&&Array.isArray(e)&&e.length>0&&e[0]===a.SQLiteCloudArrayType.ARRAY_TYPE_SQLITE_EXEC)return{lastID:e[2],changes:e[3],totalChanges:e[4],finalized:e[5]}}emitEvent(e,...t){setTimeout((()=>{this.emit(e,...t)}),0)}getConfiguration(){return JSON.parse(JSON.stringify(this.config))}verbose(){this.config.verbose=!0;for(const e of this.connections)e.verbose();return this}configure(e,t){return this}run(e,...t){const{args:n,callback:r}=(0,c.popCallback)(t),s=(null==n?void 0:n.length)>0?(0,c.prepareSql)(e,...n):e;return this.getConnection(((e,t)=>{e||!t?this.handleError(null,e,r):t.sendCommands(s,((e,n)=>{if(e)this.handleError(t,e,r);else{const e=this.processContext(n);null==r||r.call(e||this,null,e?void 0:n)}}))})),this}get(e,...t){const{args:n,callback:r}=(0,c.popCallback)(t),s=(null==n?void 0:n.length)>0?(0,c.prepareSql)(e,...n):e;return this.getConnection(((e,t)=>{e||!t?this.handleError(null,e,r):t.sendCommands(s,((e,n)=>{e?this.handleError(t,e,r):n&&n instanceof i.SQLiteCloudRowset&&n.length>0?null==r||r.call(this,null,n[0]):null==r||r.call(this,null)}))})),this}all(e,...t){const{args:n,callback:r}=(0,c.popCallback)(t),s=(null==n?void 0:n.length)>0?(0,c.prepareSql)(e,...n):e;return this.getConnection(((e,t)=>{e||!t?this.handleError(null,e,r):t.sendCommands(s,((e,n)=>{e?this.handleError(t,e,r):n&&n instanceof i.SQLiteCloudRowset?null==r||r.call(this,null,n):null==r||r.call(this,null)}))})),this}each(e,...t){const{args:n,callback:r,complete:s}=(0,c.popCallback)(t),o=(null==n?void 0:n.length)>0?(0,c.prepareSql)(e,...n):e;return this.getConnection(((e,t)=>{e||!t?this.handleError(null,e,r):t.sendCommands(o,((e,n)=>{if(e)this.handleError(t,e,r);else if(n&&n instanceof i.SQLiteCloudRowset){if(r)for(const e of n)r.call(this,null,e);s&&s.call(this,null,n.numberOfRows)}else null==r||r.call(this,new a.SQLiteCloudError("Invalid rowset"))}))})),this}prepare(e,...t){const{args:n,callback:r}=(0,c.popCallback)(t);return new l.Statement(this,e,...n,r)}exec(e,t){return this.getConnection(((n,r)=>{n||!r?this.handleError(null,n,t):r.sendCommands(e,((e,n)=>{if(e)this.handleError(r,e,t);else{const e=this.processContext(n);null==t||t.call(e||this,null)}}))})),this}close(e){var t;if((null===(t=this.connections)||void 0===t?void 0:t.length)>0)for(const e of this.connections)e.close();null==e||e.call(this,null),this.emitEvent("close")}loadExtension(e,t){return t?t.call(this,new Error("Database.loadExtension - Not implemented")):this.emitEvent("error",new Error("Database.loadExtension - Not implemented")),this}interrupt(){}sql(e,...t){return r(this,void 0,void 0,(function*(){let n="";if(Array.isArray(e)&&"raw"in e)e.forEach(((e,r)=>{n+=e+(r<t.length?"?":"")})),n=(0,c.prepareSql)(n,...t);else{if("string"!=typeof e)throw new Error("Invalid sql");n=(null==t?void 0:t.length)>0?(0,c.prepareSql)(e,...t):e}return new Promise(((e,t)=>{this.getConnection(((r,s)=>{r||!s?t(r):s.sendCommands(n,((n,r)=>{if(n)t(n);else{const t=this.processContext(r);e(t||r)}}))}))}))}))}}t.Database=h},875:function(e,t,n){"use strict";var r,s,o,i,a=this&&this.__classPrivateFieldSet||function(e,t,n,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,n):s?s.value=n:t.set(e,n),n},c=this&&this.__classPrivateFieldGet||function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteCloudRowset=t.SQLiteCloudRow=void 0;const l=n(230);class u{constructor(e,t,n){r.set(this,void 0),s.set(this,void 0),a(this,r,e,"f"),a(this,s,n,"f");for(let e=0;e<t.length;e++)this[t[e]]=n[e]}getRowset(){return c(this,r,"f")}getData(){return c(this,s,"f")}}t.SQLiteCloudRow=u,r=new WeakMap,s=new WeakMap;class h extends Array{constructor(e,t){super(e.numberOfRows),o.set(this,void 0),i.set(this,void 0),a(this,o,e,"f"),a(this,i,t,"f");const n=this.columnsNames;for(let t=0;t<e.numberOfColumns;t++){n[t]||(n[t]=`column_${t}`);let e=0;for(;n.findIndex(((e,r)=>r!==t&&e===n[t]))>=0;)n[t]=`${n[t]}_${e}`,e++}for(let r=0,s=0;r<e.numberOfRows;r++,s+=e.numberOfColumns)this[r]=new u(this,n,t.slice(s,s+e.numberOfColumns))}get version(){return c(this,o,"f").version}get numberOfRows(){return c(this,o,"f").numberOfRows}get numberOfColumns(){return c(this,o,"f").numberOfColumns}get columnsNames(){return c(this,o,"f").columns.map((e=>e.name))}get metadata(){return c(this,o,"f")}getItem(e,t){if(e<0||e>=this.numberOfRows||t<0||t>=this.numberOfColumns)throw new l.SQLiteCloudError(`This rowset has ${this.numberOfColumns} columns by ${this.numberOfRows} rows, requested column ${t} and row ${e} is invalid.`);return c(this,i,"f")[e*this.numberOfColumns+t]}slice(e,t){e=void 0===e?0:e<0?this.numberOfRows+e:e,e=Math.min(Math.max(e,0),this.numberOfRows),t=void 0===t?this.numberOfRows:t<0?this.numberOfRows+t:t,t=Math.min(Math.max(e,t),this.numberOfRows);const n=Object.assign(Object.assign({},c(this,o,"f")),{numberOfRows:t-e}),r=c(this,i,"f").slice(e*this.numberOfColumns,t*this.numberOfColumns);return console.assert(r&&r.length===n.numberOfRows*n.numberOfColumns,"SQLiteCloudRowset.slice - invalid rowset data"),new h(n,r)}map(e){const t=[];for(let n=0;n<this.numberOfRows;n++){const r=this[n];t.push(e(r,n,this))}return t}filter(e){const t=[];for(let n=0;n<this.numberOfRows;n++)e(this[n],n,this)&&t.push(...c(this,i,"f").slice(n*this.numberOfColumns,(n+1)*this.numberOfColumns));return new h(Object.assign(Object.assign({},c(this,o,"f")),{numberOfRows:t.length/this.numberOfColumns}),t)}}t.SQLiteCloudRowset=h,o=new WeakMap,i=new WeakMap},195:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Statement=void 0;const r=n(261);t.Statement=class{constructor(e,t,...n){const{args:s,callback:o}=(0,r.popCallback)(n);this._database=e,this._sql=t,(null==s?void 0:s.length)>0?this.bind(...s,o):null==o||o.call(this,null)}bind(...e){const{args:t,callback:n}=(0,r.popCallback)(e);try{this._preparedSql=(0,r.prepareSql)(this._sql,...t),n&&n.call(this,null)}catch(e){this._preparedSql=void 0,n&&n.call(this,e)}return this}run(...e){const{args:t,callback:n}=(0,r.popCallback)(e||[]);return(null==t?void 0:t.length)>0?this.bind(...t,(e=>{e?null==n||n.call(this,e):this._database.run(this._preparedSql||"",n)})):this._database.run(this._preparedSql||"",n),this}get(...e){const{args:t,callback:n}=(0,r.popCallback)(e||[]);return(null==t?void 0:t.length)>0?this.bind(...t,(e=>{e?null==n||n.call(this,e):this._database.get(this._preparedSql||"",n)})):this._database.get(this._preparedSql||"",n),this}all(...e){const{args:t,callback:n}=(0,r.popCallback)(e||[]);return(null==t?void 0:t.length)>0?this.bind(...t,(e=>{e?null==n||n.call(this,e):this._database.all(this._preparedSql||"",n)})):this._database.all(this._preparedSql||"",n),this}each(...e){const{args:t,callback:n,complete:s}=(0,r.popCallback)(e);return(null==t?void 0:t.length)>0?this.bind(...t,(e=>{e?null==n||n.call(this,e):this._database.each(this._preparedSql||"",n,s)})):this._database.each(this._preparedSql||"",n,s),this}}},36:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TlsSocketTransport=void 0;const s=n(230),o=n(875),i=n(672),a=n(672),c=r(n(492)),l=n(405),u="+",h="!",d="-",p=":",f=",",g="*",m="/",y="#",b="_",v="$",w="%",_="^",C="=";function k(e){const t=parseInt(e.subarray(0,e.indexOf(":")+1).toString());e=e.subarray(e.indexOf(":")+1);const{data:n,fwdBuffer:r}=function(e,t=1){const n=[];for(let r=0;r<t;r++){const t=e.indexOf(" ");n[r]=parseInt(e.subarray(0,t).toString()),e=e.subarray(t+1)}return{data:n,fwdBuffer:e}}(e,3);return{index:t,metadata:{version:n[0],numberOfRows:n[1],numberOfColumns:n[2],columns:[]},fwdBuffer:r}}function S(e,t){function n(){const{data:t,fwdBuffer:n}=E(e);return e=n,t}for(let e=0;e<t.numberOfColumns;e++)t.columns.push({name:n()});if(2==t.version){for(let e=0;e<t.numberOfColumns;e++)t.columns[e].type=n();for(let e=0;e<t.numberOfColumns;e++)t.columns[e].database=n();for(let e=0;e<t.numberOfColumns;e++)t.columns[e].table=n();for(let e=0;e<t.numberOfColumns;e++)t.columns[e].column=n()}return e}function E(e){function t(t){return{data:t,fwdBuffer:e.subarray(i)}}console.assert(e&&e instanceof Buffer);const n=e.subarray(0,1).toString("utf8");console.assert(n!==w,"Compressed data shouldn't be decompressed before parsing"),console.assert(n!==m,"Chunked data should be parsed by parseRowsetChunks");let r=e.indexOf(" ");-1===r&&(r=e.length-1);let i=-1;if(n===p||n===f||n===b)i=r+1;else{const t=parseInt(e.subarray(1,r).toString());i=r+1+t}switch(n){case p:return t(parseInt(e.subarray(1,r).toString()));case f:return t(parseFloat(e.subarray(1,r).toString()));case b:return t(null);case u:return t(e.subarray(r+1,i).toString("utf8"));case h:return t(e.subarray(r+1,i-1).toString("utf8"));case _:return t(e.subarray(r+1,i).toString("utf8"));case y:return t(JSON.parse(e.subarray(r+1,i).toString("utf8")));case v:return t(e.subarray(r+1,i));case C:return t(function(e,t){const n=[],r=e.subarray(t+1,e.length),s=parseInt(r.subarray(0,t-2).toString("utf8"));let o=r.subarray(r.indexOf(" ")+1,r.length);for(let e=0;e<s;e++){const{data:e,fwdBuffer:t}=E(o);n.push(e),o=t}return n}(e,r));case g:return t(function(e,t){e=e.subarray(t+1,e.length);const{metadata:n,fwdBuffer:r}=k(e);e=S(r,n);const s=[];for(let t=0;t<n.numberOfRows*n.numberOfColumns;t++){const{data:t,fwdBuffer:n}=E(e);s.push(t),e=n}return console.assert(s&&s.length===n.numberOfRows*n.numberOfColumns,"SQLiteCloudConnection.parseRowset - invalid rowset data"),new o.SQLiteCloudRowset(n,s)}(e,r));case d:!function(e,t){const n=e.subarray(t+1).toString("utf8").split(" ");let r=n.shift()||"0",o="0",i="-1";const a=r.split(":");r=a[0],a.length>1&&(o=a[1],a.length>2&&(i=a[2]));const c=n.join(" "),l=parseInt(r),u=parseInt(o),h=parseInt(i);throw new s.SQLiteCloudError(c,{errorCode:l.toString(),externalErrorCode:u.toString(),offsetCode:h})}(e,r)}throw new TypeError(`Data type: ${n} is not defined in SCSP`)}function T(e){return`+${Buffer.byteLength(e,"utf-8")} ${e}`}t.TlsSocketTransport=class{get connected(){return!!this.socket}connect(e,t){console.assert(!this.connected,"Connection already established");const n=e=>{this.socket&&(this.socket.removeAllListeners("data"),this.socket.removeAllListeners("error"),this.socket.removeAllListeners("close"),e&&this.close())};return this.config=e,this.socket=c.default.connect(this.config.port,this.config.host,this.config.tlsOptions,(()=>{var r;if(null===(r=this.socket)||void 0===r?void 0:r.authorized){if(null===this.socket)return void n(new s.SQLiteCloudError("Connection was closed before it was done opening"));console.assert(this.socket,"Connection already closed");const r=(0,i.getInitializationCommands)(e);this.processCommands(r,(e=>{e&&this.socket&&this.close(),t&&(null==t||t.call(this,e),t=void 0),n(e)}))}else{const e=(0,a.anonimizeError)(this.socket.authorizationError);console.error("Connection was not authorized",e),this.close(),n(new s.SQLiteCloudError("Connection was not authorized",{cause:e}))}})),this.socket.on("close",(()=>{this.socket=null,n(new s.SQLiteCloudError("Connection was closed"))})),this.socket.once("error",(e=>{console.error("Connection error",e),n(new s.SQLiteCloudError("Connection error",{cause:e}))})),this}processCommands(e,t){var n,r,i;if(!this.socket)return null==t||t.call(this,new s.SQLiteCloudError("Connection not established",{errorCode:"ERR_CONNECTION_NOT_ESTABLISHED"})),this;e=T(e);let c=Buffer.alloc(0);const u=[];let h;new Date;const d=(e,n)=>{clearTimeout(h),this.socket&&(this.socket.removeAllListeners("data"),this.socket.removeAllListeners("error"),this.socket.removeAllListeners("close")),t&&(null==t||t.call(this,e,n),t=void 0)},g=e=>{var t,n,r,s;try{let i=0===c.length?e.subarray(0,1).toString():c.subarray(0,1).toString("utf8");if(c=Buffer.concat([c,e]),(s=i)!=p&&s!=f&&s!=b){const s=function(e){return parseInt(e.subarray(1,e.indexOf(" ")).toString("utf8"))}(c);if(c.length-c.indexOf(" ")-1>=s){if(null===(t=this.config)||void 0===t?void 0:t.verbose){let e=c.toString("utf8");e.length>1e3&&(e=e.substring(0,100)+"..."+e.substring(e.length-40))}if(i===w&&({buffer:c,dataType:i}=function(e){const t=e.indexOf(" ");e=e.subarray(t+1);const n=parseInt(e.subarray(0,e.indexOf(" ")+1).toString("utf8"));e=e.subarray(e.indexOf(" ")+1);const r=parseInt(e.subarray(0,e.indexOf(" ")+1).toString("utf8")),s=(e=e.subarray(e.indexOf(" ")+1)).subarray(0,1).toString("utf8"),o=Buffer.alloc(r),i=e.subarray(e.length-n),a=l.decompressBlock(i,o,0,n,0);if(e=Buffer.concat([e.subarray(0,e.length-n),o]),a<=0||a!==r)throw new Error(`lz4 decompression error at offset ${a}`);return{buffer:e,dataType:s}}(c)),i!==m){null===(n=this.socket)||void 0===n||n.off("data",g);const{data:e}=E(c);d(null,e)}else if("0 0 0 "===e.subarray(e.indexOf(" ")+1,e.length).toString()){const e=function(e){let t={version:1,numberOfColumns:0,numberOfRows:0,columns:[]};const n=[];for(let r=0;r<e.length;r++){let s=e[r];const o=s.subarray(0,1).toString();console.assert(o===m),s=s.subarray(s.indexOf(" ")+1);const{index:i,metadata:a,fwdBuffer:c}=k(s);s=c,1===i?(t=a,s=S(s,t)):t.numberOfRows+=a.numberOfRows;for(let e=0;e<a.numberOfRows*t.numberOfColumns;e++){const{data:e,fwdBuffer:t}=E(s);n.push(e),s=t}}return console.assert(n&&n.length===t.numberOfRows*t.numberOfColumns,"SQLiteCloudConnection.parseRowsetChunks - invalid rowset data"),new o.SQLiteCloudRowset(t,n)}(u);null==d||d.call(this,null,e)}else{u.push(c),c=Buffer.alloc(0);const e=T("OK");null===(r=this.socket)||void 0===r||r.write(e)}}}else if(" "==c.subarray(c.length-1,c.length).toString("utf8")){const{data:e}=E(c);d(null,e)}}catch(e){console.assert(e instanceof Error),e instanceof Error&&d(e)}};return null===(n=this.socket)||void 0===n||n.once("close",(()=>{d(new s.SQLiteCloudError("Connection was closed",{cause:(0,a.anonimizeCommand)(e)}))})),null===(r=this.socket)||void 0===r||r.write(e,"utf8",(()=>{var t,n;h=setTimeout((()=>{const t=new s.SQLiteCloudError("Request timed out",{cause:(0,a.anonimizeCommand)(e)});d(t)}),null===(t=this.config)||void 0===t?void 0:t.timeout),null===(n=this.socket)||void 0===n||n.on("data",g)})),null===(i=this.socket)||void 0===i||i.once("error",(e=>{console.error("Socket error",e),this.close(),d(new s.SQLiteCloudError("Socket error",{cause:(0,a.anonimizeError)(e)}))})),this}close(){return console.assert(null!==this.socket,"TlsSocketTransport.close - connection already closed"),this.socket&&(this.socket.destroy(),this.socket=null),this.socket=void 0,this}}},122:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketTransport=void 0;const r=n(230),s=n(875),o=n(46);t.WebSocketTransport=class{get connected(){return!!this.socket}connect(e,t){var n;try{if(console.assert(!this.connected,"Connection already established"),!this.socket){this.config=e;const t=this.config.connectionString,r=(null===(n=this.config)||void 0===n?void 0:n.gatewayUrl)||`ws://${this.config.host}:4000`;this.socket=(0,o.io)(r,{auth:{token:t}})}null==t||t.call(this,null)}catch(e){null==t||t.call(this,e)}return this}processCommands(e,t){return this.socket?(this.socket.emit("v1/sql",{sql:e,row:"array"},(e=>{if(null==e?void 0:e.error){const n=new r.SQLiteCloudError(e.error.detail,Object.assign({},e.error));null==t||t.call(this,n)}else{const{data:n,metadata:r}=e;if(n&&r&&void 0!==r.numberOfRows&&void 0!==r.numberOfColumns&&void 0!==r.columns){console.assert(Array.isArray(n),"SQLiteCloudWebsocketConnection.processCommands - data is not an array");const e=new s.SQLiteCloudRowset(r,n.flat());return void(null==t||t.call(this,null,e))}null==t||t.call(this,null,null==e?void 0:e.data)}})),this):(null==t||t.call(this,new r.SQLiteCloudError("Connection not established",{errorCode:"ERR_CONNECTION_NOT_ESTABLISHED"})),this)}close(){var e;return console.assert(null!==this.socket,"WebsocketTransport.close - connection already closed"),this.socket&&(null===(e=this.socket)||void 0===e||e.close(),this.socket=void 0),this.socket=void 0,this}}},230:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteCloudArrayType=t.SQLiteCloudError=void 0;class n extends Error{constructor(e,t){super(e),this.name="SQLiteCloudError",t&&Object.assign(this,t)}}var r;t.SQLiteCloudError=n,(r=t.SQLiteCloudArrayType||(t.SQLiteCloudArrayType={}))[r.ARRAY_TYPE_SQLITE_EXEC=10]="ARRAY_TYPE_SQLITE_EXEC",r[r.ARRAY_TYPE_DB_STATUS=11]="ARRAY_TYPE_DB_STATUS",r[r.ARRAY_TYPE_METADATA=12]="ARRAY_TYPE_METADATA",r[r.ARRAY_TYPE_VM_STEP=20]="ARRAY_TYPE_VM_STEP",r[r.ARRAY_TYPE_VM_COMPILE=21]="ARRAY_TYPE_VM_COMPILE",r[r.ARRAY_TYPE_VM_STEP_ONE=22]="ARRAY_TYPE_VM_STEP_ONE",r[r.ARRAY_TYPE_VM_SQL=23]="ARRAY_TYPE_VM_SQL",r[r.ARRAY_TYPE_VM_STATUS=24]="ARRAY_TYPE_VM_STATUS",r[r.ARRAY_TYPE_VM_LIST=25]="ARRAY_TYPE_VM_LIST",r[r.ARRAY_TYPE_BACKUP_INIT=40]="ARRAY_TYPE_BACKUP_INIT",r[r.ARRAY_TYPE_BACKUP_STEP=41]="ARRAY_TYPE_BACKUP_STEP",r[r.ARRAY_TYPE_BACKUP_END=42]="ARRAY_TYPE_BACKUP_END",r[r.ARRAY_TYPE_SQLITE_STATUS=50]="ARRAY_TYPE_SQLITE_STATUS"},261:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBoolean=t.parseConnectionString=t.popCallback=t.prepareSql=t.escapeSqlParameter=t.isNode=t.isBrowser=void 0;const r=n(230);function s(e){if(null==e)return"NULL";if("string"==typeof e)return`'${e=e.replace(/'/g,"''")}'`;if("number"==typeof e)return e.toString();if("boolean"==typeof e)return e?"1":"0";if(Buffer.isBuffer(e))return`X'${e.toString("hex")}'`;if("object"==typeof e){let t=JSON.stringify(e);return t=t.replace(/'/g,"''"),`'${t}'`}throw new r.SQLiteCloudError("Unsupported parameter type: "+typeof e)}t.isBrowser="undefined"!=typeof window&&void 0!==window.document,t.isNode="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,t.escapeSqlParameter=s,t.prepareSql=function(e,...t){1===(null==t?void 0:t.length)&&Array.isArray(t[0])&&(t=t[0]);let n=1,o=e.replace(/\?(\d+)?/g,((e,o)=>{const i=o?parseInt(o):n;let a;if(n++,!t[0]||"object"!=typeof t[0]||t[0]instanceof Buffer||(a=t[0][i]),!a){if(i>t.length)throw new r.SQLiteCloudError("Not enough parameters");a=t[i-1]}return null!=a?s(a):"NULL"}));if(1===(null==t?void 0:t.length)&&t[0]&&"object"==typeof t[0]){const e=t[0];for(const[t,n]of Object.entries(e)){const e=t.charAt(0);if("$"==e||":"==e||"@"==e){const e=s(n);o=o.replace(new RegExp(`\\${t}`,"g"),e)}}}return o},t.popCallback=function(e){const t=e;return e&&e.length>0&&"function"==typeof e[e.length-1]?e.length>1&&"function"==typeof e[e.length-2]?{args:t.slice(0,-2),callback:e[e.length-2],complete:e[e.length-1]}:{args:t.slice(0,-1),callback:e[e.length-1]}:{args:t}},t.parseConnectionString=function(e){try{const t=e.replace("sqlitecloud:","https:"),n=new URL(t),r={};n.searchParams.forEach(((e,t)=>{r[t]=e}));const s=Object.assign({username:n.username,password:n.password,host:n.hostname,port:n.port?parseInt(n.port):void 0},r),o=n.pathname.replace("/","");return o&&(s.database=o),s}catch(t){throw new r.SQLiteCloudError(`Invalid connection string: ${e}`)}},t.parseBoolean=function(e){return"string"==typeof e?"true"===e.toLowerCase()||"1"===e:!!e}},227:(e,t,n)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,s=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(s=r))})),t.splice(s,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(447)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,n)=>{e.exports=function(e){function t(e){let n,s,o,i=null;function a(...e){if(!a.enabled)return;const r=a,s=Number(new Date),o=s-(n||s);r.diff=o,r.prev=n,r.curr=s,n=s,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,s)=>{if("%%"===n)return"%";i++;const o=t.formatters[s];if("function"==typeof o){const t=e[i];n=o.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(s!==t.namespaces&&(s=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(s),...t.skips.map(s).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),s=r.length;for(n=0;n<s;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function s(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new s(r,o||e,i),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function i(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,s=[];if(0===this._eventsCount)return s;for(r in e=this._events)t.call(e,r)&&s.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,o=r.length,i=new Array(o);s<o;s++)i[s]=r[s].fn;return i},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,s,o,i){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],h=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),h){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,s),!0;case 5:return u.fn.call(u.context,t,r,s,o),!0;case 6:return u.fn.call(u.context,t,r,s,o,i),!0}for(l=1,c=new Array(h-1);l<h;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var d,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),h){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,s);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,s){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return i(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||s&&!a.once||r&&a.context!==r||i(this,o);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||s&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:i(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},405:(e,t,n)=>{var r=n(887),s=n(325),o=65536,i=h(5<<20),a=function(){try{return new Uint32Array(o)}catch(n){for(var e=new Array(o),t=0;t<o;t++)e[t]=0;return e}}(),c=407708164,l=2147483648,u={4:65536,5:262144,6:1048576,7:4194304};function h(e){try{return new Uint8Array(e)}catch(r){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t}}function d(e,t,n){if(void 0!==typeof e.buffer){if(Uint8Array.prototype.slice)return e.slice(t,n);var r=e.length;t=(t|=0)<0?Math.max(r+t,0):Math.min(t,r),n=(n=void 0===n?r:0|n)<0?Math.max(r+n,0):Math.min(n,r);for(var s=new Uint8Array(n-t),o=t,i=0;o<n;)s[i++]=e[o++];return s}return e.slice(t,n)}t.compressBound=function(e){return e+e/255+16|0},t.decompressBound=function(e){var t=0;if(s.readU32(e,t)!==c)throw new Error("invalid magic number");t+=4;var n=e[t++];if(64!=(192&n))throw new Error("incompatible descriptor version "+(192&n));var r=0!=(16&n),o=0!=(8&n),i=e[t++]>>4&7;if(void 0===u[i])throw new Error("invalid block size "+i);var a=u[i];if(o)return s.readU64(e,t);t++;for(var h=0;;){var d=s.readU32(e,t);if(t+=4,h+=d&l?d&=2147483647:a,0===d)return h;r&&(t+=4),t+=d}},t.makeBuffer=h,t.decompressBlock=function(e,t,n,r,s){var o,i,a,c,l;for(a=n+r;n<a;){var u=e[n++],h=u>>4;if(h>0){if(15===h)for(;h+=e[n],255===e[n++];);for(c=n+h;n<c;)t[s++]=e[n++]}if(n>=a)break;if(o=15&u,i=e[n++]|e[n++]<<8,15===o)for(;o+=e[n],255===e[n++];);for(c=(l=s-i)+(o+=4);l<c;)t[s++]=0|t[l++]}return s},t.compressBlock=function(e,t,n,r,o){var i,a,c,l,u,h,d,p;if(h=0,d=r+n,a=n,r>=13)for(var f=67;n+4<d-5;){var g=s.readU32(e,n),m=s.hashU32(g)>>>0;if(i=o[m=(m>>16^m)>>>0&65535]-1,o[m]=n+1,i<0||n-i>>>16>0||s.readU32(e,i)!==g)n+=f++>>6;else{for(f=67,u=n-a,l=n-i,i+=4,c=n+=4;n<d-5&&e[n]===e[i];)n++,i++;var y=(c=n-c)<15?c:15;if(u>=15){for(t[h++]=240+y,p=u-15;p>=255;p-=255)t[h++]=255;t[h++]=p}else t[h++]=(u<<4)+y;for(var b=0;b<u;b++)t[h++]=e[a+b];if(t[h++]=l,t[h++]=l>>8,c>=15){for(p=c-15;p>=255;p-=255)t[h++]=255;t[h++]=p}a=n}}if(0===a)return 0;if((u=d-a)>=15){for(t[h++]=240,p=u-15;p>=255;p-=255)t[h++]=255;t[h++]=p}else t[h++]=u<<4;for(n=a;n<d;)t[h++]=e[n++];return h},t.decompressFrame=function(e,n){var r,o,i,a,h=0,d=0;if(s.readU32(e,h)!==c)throw new Error("invalid magic number");if(h+=4,64!=(192&(a=e[h++])))throw new Error("incompatible descriptor version");r=0!=(16&a),o=0!=(4&a),i=0!=(8&a);var p=e[h++]>>4&7;if(void 0===u[p])throw new Error("invalid block size");for(i&&(h+=8),h++;;){var f;if(f=s.readU32(e,h),h+=4,0===f)break;if(r&&(h+=4),0!=(f&l)){f&=2147483647;for(var g=0;g<f;g++)n[d++]=e[h++]}else d=t.decompressBlock(e,n,h,f,d),h+=f}return o&&(h+=4),d},t.compressFrame=function(e,n){var l=0;s.writeU32(n,l,c),l+=4,n[l++]=64,n[l++]=112,n[l]=r.hash(0,n,4,l-4)>>8,l++;var h=u[7],d=e.length,p=0;for(function(e){for(var t=0;t<o;t++)a[t]=0}();d>0;){var f,g=d>h?h:d;if((f=t.compressBlock(e,i,p,g,a))>g||0===f){s.writeU32(n,l,2147483648|g),l+=4;for(var m=p+g;p<m;)n[l++]=e[p++];d-=g}else{s.writeU32(n,l,f),l+=4;for(var y=0;y<f;)n[l++]=i[y++];p+=g,d-=g}}return s.writeU32(n,l,0),l+4},t.decompress=function(e,n){var r,s;return void 0===n&&(n=t.decompressBound(e)),r=t.makeBuffer(n),(s=t.decompressFrame(e,r))!==n&&(r=d(r,0,s)),r},t.compress=function(e,n){var r,s;return void 0===n&&(n=t.compressBound(e.length)),r=t.makeBuffer(n),(s=t.compressFrame(e,r))!==n&&(r=d(r,0,s)),r}},325:(e,t)=>{t.hashU32=function(e){return-1252372727^(e=(e=(e=374761393+(e=-949894596^(e=2127912214+(e|=0)+(e<<12)|0)^e>>>19)+(e<<5)|0)-744332180^e<<9)-42973499+(e<<3)|0)^e>>>16|0},t.readU64=function(e,t){var n=0;return n|=e[t++]<<0,n|=e[t++]<<8,n|=e[t++]<<16,n|=e[t++]<<24,n|=e[t++]<<32,n|=e[t++]<<40,(n|=e[t++]<<48)|e[t++]<<56},t.readU32=function(e,t){var n=0;return n|=e[t++]<<0,n|=e[t++]<<8,(n|=e[t++]<<16)|e[t++]<<24},t.writeU32=function(e,t,n){e[t++]=n>>0&255,e[t++]=n>>8&255,e[t++]=n>>16&255,e[t++]=n>>24&255},t.imul=function(e,t){var n=65535&e,r=65535&t;return n*r+((e>>>16)*r+n*(t>>>16)<<16)|0}},887:(e,t,n)=>{var r=n(325),s=2654435761,o=2246822519,i=3266489917,a=374761393;function c(e,t){return(e|=0)>>>(32-(t|=0)|0)|e<<t|0}function l(e,t,n){return e|=0,t|=0,n|=0,0|r.imul(e>>>(32-t|0)|e<<t,n)}function u(e,t){return(e|=0)>>>(t|=0)^e|0}function h(e,t,n,s,o){return l(r.imul(t,n)+e,s,o)}function d(e,t,n){return l(e+r.imul(t[n],a),11,s)}function p(e,t,n){return h(e,r.readU32(t,n),i,17,668265263)}function f(e,t,n){return[h(e[0],r.readU32(t,n+0),o,13,s),h(e[1],r.readU32(t,n+4),o,13,s),h(e[2],r.readU32(t,n+8),o,13,s),h(e[3],r.readU32(t,n+12),o,13,s)]}t.hash=function(e,t,n,l){var h,g;if(g=l,l>=16){for(h=[e+s+o,e+o,e,e-s];l>=16;)h=f(h,t,n),n+=16,l-=16;h=c(h[0],1)+c(h[1],7)+c(h[2],12)+c(h[3],18)+g}else h=e+a+l>>>0;for(;l>=4;)h=p(h,t,n),n+=4,l-=4;for(;l>0;)h=d(h,t,n),n++,l--;return(h=u(r.imul(u(r.imul(u(h,15),o),13),i),16))>>>0}},824:e=>{var t=1e3,n=60*t,r=60*n,s=24*r;function o(e,t,n,r){var s=t>=1.5*n;return Math.round(e/n)+" "+r+(s?"s":"")}e.exports=function(e,i){i=i||{};var a,c,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var i=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*s;case"hours":case"hour":case"hrs":case"hr":case"h":return i*r;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}}}(e);if("number"===l&&isFinite(e))return i.long?(a=e,(c=Math.abs(a))>=s?o(a,c,s,"day"):c>=r?o(a,c,r,"hour"):c>=n?o(a,c,n,"minute"):c>=t?o(a,c,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=s?Math.round(e/s)+"d":o>=r?Math.round(e/r)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},492:()=>{},419:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},754:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0,t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}},222:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=void 0;const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.parse=function(e){if(e.length>2e3)throw"URI too long";const t=e,s=e.indexOf("["),o=e.indexOf("]");-1!=s&&-1!=o&&(e=e.substring(0,s)+e.substring(s,o).replace(/:/g,";")+e.substring(o,e.length));let i=n.exec(e||""),a={},c=14;for(;c--;)a[r[c]]=i[c]||"";return-1!=s&&-1!=o&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,a.query),a}},726:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.yeast=t.decode=t.encode=void 0;const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),r={};let s,o=0,i=0;function a(e){let t="";do{t=n[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}for(t.encode=a,t.decode=function(e){let t=0;for(i=0;i<e.length;i++)t=64*t+r[e.charAt(i)];return t},t.yeast=function(){const e=a(+new Date);return e!==s?(o=0,s=e):e+"."+a(o++)};i<64;i++)r[n[i]]=i},242:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.globalThisShim=void 0,t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},679:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.Socket=void 0;const r=n(481);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return r.Socket}}),t.protocol=r.Socket.protocol;var s=n(870);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return s.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return s.TransportError}});var o=n(385);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var i=n(622);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return i.installTimerFunctions}});var a=n(222);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return a.parse}});var c=n(552);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return c.nextTick}})},481:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const s=n(385),o=n(622),i=n(754),a=n(222),c=r(n(227)),l=n(260),u=n(373),h=n(552),d=(0,c.default)("engine.io-client:socket");class p extends l.Emitter{constructor(e,t={}){super(),this.binaryType=h.defaultBinaryType,this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=(0,a.parse)(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=(0,a.parse)(t.host).host),(0,o.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,i.decode)(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=u.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",n),new s.transports[e](n)}open(){let e;if(this.opts.rememberUpgrade&&p.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return d("error while creating transport: %s",e),this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),n=!1;p.priorWebsocketSuccess=!1;const r=()=>{n||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(r=>{if(!n)if("pong"===r.type&&"probe"===r.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;p.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause((()=>{n||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{d('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}})))};function s(){n||(n=!0,l(),t.close(),t=null)}const o=n=>{const r=new Error("probe error: "+n);r.transport=t.name,s(),d('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",r)};function i(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),s())}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",i),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(d("socket open"),this.readyState="open",p.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=(0,o.byteLength)(n)),t>0&&e>this.maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this.maxPayload),this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const s={type:e,data:t,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){d("socket error %j",e),p.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}t.Socket=p,p.protocol=u.protocol},870:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const s=n(373),o=n(260),i=n(622),a=r(n(227)),c=n(754),l=(0,a.default)("engine.io-client:transport");class u extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}t.TransportError=u;class h extends o.Emitter{constructor(e){super(),this.writable=!1,(0,i.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new u(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):l("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,s.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,c.encode)(e);return t.length?"?"+t:""}}t.Transport=h},385:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const r=n(484),s=n(308),o=n(20);t.transports={websocket:s.WS,webtransport:o.WT,polling:r.Polling}},484:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Request=t.Polling=void 0;const s=n(870),o=r(n(227)),i=n(726),a=n(373),c=n(666),l=n(260),u=n(622),h=n(242),d=(0,o.default)("engine.io-client:polling");function p(){}const f=null!=new c.XHR({xdomain:!1}).responseType;class g extends s.Transport{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=f&&!t,this.opts.withCredentials&&(this.cookieJar=(0,c.createCookieJar)())}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{d("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(d("we are currently polling - waiting to pause"),e++,this.once("pollComplete",(function(){d("pre-pause polling complete"),--e||t()}))),this.writable||(d("we are currently writing - waiting to pause"),e++,this.once("drain",(function(){d("pre-pause writing complete"),--e||t()})))}else t()}poll(){d("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){d("polling got data %s",e),(0,a.decodePayload)(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this.poll():d('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{d("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(d("transport open - closing"),e()):(d("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,a.encodePayload)(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,i.yeast)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new m(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){d("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}t.Polling=g;class m extends l.Emitter{constructor(e,t){super(),(0,u.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=(0,u.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new c.XHR(t);try{d("xhr open %s: %s",this.method,this.uri),n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},d("xhr data %s",this.data),n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=m.requestsCount++,m.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=p,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete m.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(t.Request=m,m.requestsCount=0,m.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",y);else if("function"==typeof addEventListener){const e="onpagehide"in h.globalThisShim?"pagehide":"unload";addEventListener(e,y,!1)}function y(){for(let e in m.requests)m.requests.hasOwnProperty(e)&&m.requests[e].abort()}},552:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.usingBrowserWebSocket=t.WebSocket=t.nextTick=void 0;const r=n(242);t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.WebSocket=r.globalThisShim.WebSocket||r.globalThisShim.MozWebSocket,t.usingBrowserWebSocket=!0,t.defaultBinaryType="arraybuffer"},308:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=void 0;const s=n(870),o=n(726),i=n(622),a=n(552),c=r(n(227)),l=n(373),u=(0,c.default)("engine.io-client:websocket"),h="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class d extends s.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=h?{}:(0,i.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=a.usingBrowserWebSocket&&!h?t?new a.WebSocket(e,t):new a.WebSocket(e):new a.WebSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;(0,l.encodePacket)(n,this.supportsBinary,(e=>{const t={};!a.usingBrowserWebSocket&&(n.options&&(t.compress=n.options.compress),this.opts.perMessageDeflate)&&("string"==typeof e?Buffer.byteLength(e):e.length)<this.opts.perMessageDeflate.threshold&&(t.compress=!1);try{a.usingBrowserWebSocket?this.ws.send(e):this.ws.send(e,t)}catch(e){u("websocket closed before onclose event")}r&&(0,a.nextTick)((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,o.yeast)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!a.WebSocket}}t.WS=d},20:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const s=n(870),o=n(552),i=n(373),a=(0,r(n(227)).default)("engine.io-client:webtransport");class c extends s.Transport{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{a("transport closed gracefully"),this.onClose()})).catch((e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=(0,i.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=(0,i.createPacketEncoderStream)();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const s=()=>{n.read().then((({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),s())})).catch((e=>{a("an error occurred while reading: %s",e)}))};s();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then((()=>{r&&(0,o.nextTick)((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}}t.WT=c},666:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createCookieJar=t.XHR=void 0;const r=n(419),s=n(242);t.XHR=function(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||r.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(s.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},t.createCookieJar=function(){}},622:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.byteLength=t.installTimerFunctions=t.pick=void 0;const r=n(242);t.pick=function(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})};const s=r.globalThisShim.setTimeout,o=r.globalThisShim.clearTimeout;t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=s.bind(r.globalThisShim),e.clearTimeoutFn=o.bind(r.globalThisShim)):(e.setTimeoutFn=r.globalThisShim.setTimeout.bind(r.globalThisShim),e.clearTimeoutFn=r.globalThisShim.clearTimeout.bind(r.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let r=0,s=e.length;r<s;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}},87:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const r=Object.create(null);t.PACKET_TYPES_REVERSE=r,Object.keys(n).forEach((e=>{r[n[e]]=e})),t.ERROR_PACKET={type:"error",data:"parser error"}},469:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)r[n.charCodeAt(e)]=e;t.encode=e=>{let t,r=new Uint8Array(e),s=r.length,o="";for(t=0;t<s;t+=3)o+=n[r[t]>>2],o+=n[(3&r[t])<<4|r[t+1]>>4],o+=n[(15&r[t+1])<<2|r[t+2]>>6],o+=n[63&r[t+2]];return s%3==2?o=o.substring(0,o.length-1)+"=":s%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=e=>{let t,n,s,o,i,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const u=new ArrayBuffer(a),h=new Uint8Array(u);for(t=0;t<c;t+=4)n=r[e.charCodeAt(t)],s=r[e.charCodeAt(t+1)],o=r[e.charCodeAt(t+2)],i=r[e.charCodeAt(t+3)],h[l++]=n<<2|s>>4,h[l++]=(15&s)<<4|o>>2,h[l++]=(3&o)<<6|63&i;return u}},572:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const r=n(87),s=n(469),o="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:i(e.substring(1),t)}:r.PACKET_TYPES_REVERSE[n]?e.length>1?{type:r.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:r.PACKET_TYPES_REVERSE[n]}:r.ERROR_PACKET};const i=(e,t)=>{if(o){const n=(0,s.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},908:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=t.encodePacketToBinary=void 0;const r=n(87),s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),o="function"==typeof ArrayBuffer,i=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>s&&t instanceof Blob?n?a(t):c(t,a):o&&(t instanceof ArrayBuffer||i(t))?n?a(t):c(new Blob([t]),a):a(r.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u;t.encodePacketToBinary=function(e,t){return s&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):o&&(e.data instanceof ArrayBuffer||i(e.data))?t(l(e.data)):void a(e,!1,(e=>{u||(u=new TextEncoder),t(u.encode(e))}))}},373:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=t.createPacketDecoderStream=t.createPacketEncoderStream=void 0;const r=n(908);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const s=n(572);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return s.decodePacket}});const o=n(87),i=String.fromCharCode(30);let a;function c(e){return e.reduce(((e,t)=>e+t.length),0)}function l(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let s=0;s<t;s++)n[s]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}t.encodePayload=(e,t)=>{const n=e.length,s=new Array(n);let o=0;e.forEach(((e,a)=>{(0,r.encodePacket)(e,!1,(e=>{s[a]=e,++o===n&&t(s.join(i))}))}))},t.decodePayload=(e,t)=>{const n=e.split(i),r=[];for(let e=0;e<n.length;e++){const o=(0,s.decodePacket)(n[e],t);if(r.push(o),"error"===o.type)break}return r},t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,r.encodePacketToBinary)(e,(n=>{const r=n.length;let s;if(r<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,r);else if(r<65536){s=new Uint8Array(3);const e=new DataView(s.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{s=new Uint8Array(9);const e=new DataView(s.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(s[0]|=128),t.enqueue(s),t.enqueue(n)}))}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let r=0,i=-1,u=!1;return new TransformStream({transform(h,d){for(n.push(h);;){if(0===r){if(c(n)<1)break;const e=l(n,1);u=128==(128&e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(c(n)<2)break;const e=l(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(c(n)<8)break;const e=l(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){d.enqueue(o.ERROR_PACKET);break}i=s*Math.pow(2,32)+t.getUint32(4),r=3}else{if(c(n)<i)break;const e=l(n,i);d.enqueue((0,s.decodePacket)(u?e:a.decode(e),t)),r=0}if(0===i||i>e){d.enqueue(o.ERROR_PACKET);break}}}})},t.protocol=4},159:(e,t)=>{"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=void 0,t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},46:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.connect=t.io=t.Socket=t.Manager=t.protocol=void 0;const s=n(84),o=n(168);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return o.Manager}});const i=n(312);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return i.Socket}});const a=r(n(227)).default("socket.io-client"),c={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=s.url(e,t.path||"/socket.io"),r=n.source,i=n.id,l=n.path,u=c[i]&&l in c[i].nsps;let h;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(a("ignoring socket cache for %s",r),h=new o.Manager(r,t)):(c[i]||(a("new io instance for %s",r),c[i]=new o.Manager(r,t)),h=c[i]),n.query&&!t.query&&(t.query=n.queryKey),h.socket(n.path,t)}t.io=l,t.connect=l,t.default=l,Object.assign(l,{Manager:o.Manager,Socket:i.Socket,io:l,connect:l});var u=n(514);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}}),e.exports=l},168:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return s(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(679),c=n(312),l=o(n(514)),u=n(149),h=n(159),d=n(260),p=i(n(227)).default("socket.io-client:manager");class f extends d.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,a.installTimerFunctions(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new h.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||l;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=u.on(t,"open",(function(){n.onopen(),e&&e()})),s=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=u.on(t,"error",s);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const n=this.setTimeoutFn((()=>{p("connect attempt timed out after %d",e),r(),s(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(u.on(e,"ping",this.onping.bind(this)),u.on(e,"data",this.ondata.bind(this)),u.on(e,"error",this.onerror.bind(this)),u.on(e,"close",this.onclose.bind(this)),u.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){a.nextTick((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){p("cleanup"),this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){p("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){p("closed due to %s",e),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)p("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();p("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(p("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(p("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(p("reconnect success"),e.onreconnect())})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=f},149:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=void 0,t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},312:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const s=n(514),o=n(149),i=n(260),a=r(n(227)).default("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class l extends i.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[o.on(e,"open",this.onopen.bind(this)),o.on(e,"packet",this.onpacket.bind(this)),o.on(e,"error",this.onerror.bind(this)),o.on(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:s.PacketType.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const r=t.pop();this._registerAckCallback(e,r),n.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return!this.flags.volatile||r&&this.connected?this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n):a("discard packet as the transport is not currently writable"),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const s=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))}),r);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(s),t.apply(this,[null,...e])}}emitWithAck(e,...t){const n=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((r,s)=>{t.push(((e,t)=>n?e?s(e):r(t):r(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n===this._queue[0])return null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:s.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case s.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case s.PacketType.EVENT:case s.PacketType.BINARY_EVENT:this.onevent(e);break;case s.PacketType.ACK:case s.PacketType.BINARY_ACK:this.onack(e);break;case s.PacketType.DISCONNECT:this.ondisconnect();break;case s.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,a("sending ack %j",r),t.packet({type:s.PacketType.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:s.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}t.Socket=l},84:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=void 0;const s=n(679),o=r(n(227)).default("socket.io-client:url");t.url=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(o("protocol-less url %s",e),e=void 0!==n?n.protocol+"//"+e:"https://"+e),o("parse %s",e),r=s.parse(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}},880:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reconstructPacket=t.deconstructPacket=void 0;const r=n(665);function s(e,t){if(!e)return e;if((0,r.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=s(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=s(e[r],t));return n}return e}function o(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=o(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=o(e[n],t));return e}t.deconstructPacket=function(e){const t=[],n=e.data,r=e;return r.data=s(n,t),r.attachments=t.length,{packet:r,buffers:t}},t.reconstructPacket=function(e,t){return e.data=o(e.data,t),delete e.attachments,e}},514:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0;const r=n(260),s=n(880),o=n(665),i=(0,n(227).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;function l(e){return"[object Object]"===Object.prototype.toString.call(e)}t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c=t.PacketType||(t.PacketType={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return i("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,o.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),i("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,s.deconstructPacket)(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}};class u extends r.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new h(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,o.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const s=e.substring(r,t);if(s!=Number(s)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(s)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!u.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return i("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return l(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||l(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=u;class h{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,s.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},665:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasBinary=t.isBinary=void 0;const n="function"==typeof ArrayBuffer,r=Object.prototype.toString,s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),o="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);function i(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||s&&e instanceof Blob||o&&e instanceof File}t.isBinary=i,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if(i(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1}},260:(e,t,n)=>{"use strict";function r(e){if(e)return function(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>r}),r.prototype.on=r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},r.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var s=0;s<r.length;s++)if((n=r[s])===t||n.fn===t){r.splice(s,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var s=(n=n.slice(0)).length;r<s;++r)n[r].apply(this,t)}return this},r.prototype.emitReserved=r.prototype.emit,r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.WebSocketTransport=e.prepareSql=e.escapeSqlParameter=e.SQLiteCloudConnection=e.SQLiteCloudRow=e.SQLiteCloudRowset=e.SQLiteCloudError=e.Statement=e.Database=void 0;var t=n(537);Object.defineProperty(e,"Database",{enumerable:!0,get:function(){return t.Database}});var s=n(195);Object.defineProperty(e,"Statement",{enumerable:!0,get:function(){return s.Statement}});var o=n(230);Object.defineProperty(e,"SQLiteCloudError",{enumerable:!0,get:function(){return o.SQLiteCloudError}});var i=n(875);Object.defineProperty(e,"SQLiteCloudRowset",{enumerable:!0,get:function(){return i.SQLiteCloudRowset}}),Object.defineProperty(e,"SQLiteCloudRow",{enumerable:!0,get:function(){return i.SQLiteCloudRow}});var a=n(672);Object.defineProperty(e,"SQLiteCloudConnection",{enumerable:!0,get:function(){return a.SQLiteCloudConnection}});var c=n(261);Object.defineProperty(e,"escapeSqlParameter",{enumerable:!0,get:function(){return c.escapeSqlParameter}}),Object.defineProperty(e,"prepareSql",{enumerable:!0,get:function(){return c.prepareSql}});var l=n(122);Object.defineProperty(e,"WebSocketTransport",{enumerable:!0,get:function(){return l.WebSocketTransport}})})(),r})()));
@@ -0,0 +1,59 @@
1
+ /**
2
+ * statement.ts
3
+ */
4
+ import { Database } from './database';
5
+ import { RowCallback, RowsCallback, RowCountCallback, ResultsCallback } from './types';
6
+ /** A statement generated by Database.prepare used to prepare SQL with ? bindings */
7
+ export declare class Statement<T> {
8
+ constructor(database: Database, sql: string, ...params: any[]);
9
+ /** Statement belongs to this database */
10
+ private _database;
11
+ /** The SQL statement with ? binding placeholders */
12
+ private _sql;
13
+ /** The SQL statement with binding values applied */
14
+ private _preparedSql?;
15
+ /**
16
+ * Binds parameters to the prepared statement and calls the callback when done
17
+ * or when an error occurs. The function returns the Statement object to allow
18
+ * for function chaining. The first and only argument to the callback is null
19
+ * when binding was successful, otherwise it is the error object. Binding parameters
20
+ * with this function completely resets the statement object and row cursor and
21
+ * removes all previously bound parameters, if any. Currently bound parameters
22
+ * are escaped client side and turned into literals before being executed on the server.
23
+ */
24
+ bind(...params: any[]): this;
25
+ /**
26
+ * Binds parameters and executes the statement. The function returns the Statement object to
27
+ * allow for function chaining. If you specify bind parameters, they will be bound to the statement
28
+ * before it is executed. Note that the bindings and the row cursor are reset when you specify
29
+ * even a single bind parameter. The callback behavior is identical to the Database#run method
30
+ * with the difference that the statement will not be finalized after it is run. This means you
31
+ * can run it multiple times.
32
+ */
33
+ run(callback?: ResultsCallback<T>): this;
34
+ run(params: any, callback?: ResultsCallback<T>): this;
35
+ /**
36
+ * Binds parameters, executes the statement and retrieves the first result row.
37
+ * The function returns the Statement object to allow for function chaining.
38
+ * The parameters are the same as the Statement#run function, with the following differences:
39
+ * The signature of the callback is function(err, row) {}. If the result set is empty,
40
+ * the second parameter is undefined, otherwise it is an object containing the values
41
+ * for the first row.
42
+ */
43
+ get(callback?: RowCallback<T>): this;
44
+ get(params: any, callback?: RowCallback<T>): this;
45
+ /**
46
+ * Binds parameters, executes the statement and calls the callback with
47
+ * all result rows. The function returns the Statement object to allow
48
+ * for function chaining. The parameters are the same as the Statement#run function
49
+ */
50
+ all(callback?: RowsCallback<T>): this;
51
+ all(params: any, callback?: RowsCallback<T>): this;
52
+ /**
53
+ * Binds parameters, executes the statement and calls the callback for each result row.
54
+ * The function returns the Statement object to allow for function chaining. Parameters
55
+ * are the same as the Database#each function.
56
+ */
57
+ each(callback?: RowCallback<T>, complete?: RowCountCallback): this;
58
+ each(params: any, callback?: RowCallback<T>, complete?: RowCountCallback): this;
59
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * statement.ts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Statement = void 0;
7
+ const utilities_1 = require("./utilities");
8
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
9
+ /** A statement generated by Database.prepare used to prepare SQL with ? bindings */
10
+ class Statement {
11
+ constructor(database, sql, ...params) {
12
+ const { args, callback } = (0, utilities_1.popCallback)(params);
13
+ this._database = database;
14
+ this._sql = sql;
15
+ if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
16
+ this.bind(...args, callback);
17
+ }
18
+ else {
19
+ callback === null || callback === void 0 ? void 0 : callback.call(this, null);
20
+ }
21
+ }
22
+ /**
23
+ * Binds parameters to the prepared statement and calls the callback when done
24
+ * or when an error occurs. The function returns the Statement object to allow
25
+ * for function chaining. The first and only argument to the callback is null
26
+ * when binding was successful, otherwise it is the error object. Binding parameters
27
+ * with this function completely resets the statement object and row cursor and
28
+ * removes all previously bound parameters, if any. Currently bound parameters
29
+ * are escaped client side and turned into literals before being executed on the server.
30
+ */
31
+ bind(...params) {
32
+ const { args, callback } = (0, utilities_1.popCallback)(params);
33
+ try {
34
+ this._preparedSql = (0, utilities_1.prepareSql)(this._sql, ...args);
35
+ if (callback) {
36
+ callback.call(this, null);
37
+ }
38
+ }
39
+ catch (error) {
40
+ this._preparedSql = undefined;
41
+ if (callback) {
42
+ callback.call(this, error);
43
+ }
44
+ }
45
+ return this;
46
+ }
47
+ run(...params) {
48
+ const { args, callback } = (0, utilities_1.popCallback)(params || []);
49
+ if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
50
+ // apply new bindings then execute
51
+ this.bind(...args, (error) => {
52
+ if (error) {
53
+ callback === null || callback === void 0 ? void 0 : callback.call(this, error);
54
+ }
55
+ else {
56
+ this._database.run(this._preparedSql || '', callback);
57
+ }
58
+ });
59
+ }
60
+ else {
61
+ // execute prepared sql with same bindings
62
+ this._database.run(this._preparedSql || '', callback);
63
+ }
64
+ return this;
65
+ }
66
+ get(...params) {
67
+ const { args, callback } = (0, utilities_1.popCallback)(params || []);
68
+ if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
69
+ // apply new bindings then execute
70
+ this.bind(...args, (error) => {
71
+ if (error) {
72
+ callback === null || callback === void 0 ? void 0 : callback.call(this, error);
73
+ }
74
+ else {
75
+ this._database.get(this._preparedSql || '', callback);
76
+ }
77
+ });
78
+ }
79
+ else {
80
+ // execute prepared sql with same bindings
81
+ this._database.get(this._preparedSql || '', callback);
82
+ }
83
+ return this;
84
+ }
85
+ all(...params) {
86
+ const { args, callback } = (0, utilities_1.popCallback)(params || []);
87
+ if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
88
+ // apply new bindings then execute
89
+ this.bind(...args, (error) => {
90
+ if (error) {
91
+ callback === null || callback === void 0 ? void 0 : callback.call(this, error);
92
+ }
93
+ else {
94
+ this._database.all(this._preparedSql || '', callback);
95
+ }
96
+ });
97
+ }
98
+ else {
99
+ // execute prepared sql with same bindings
100
+ this._database.all(this._preparedSql || '', callback);
101
+ }
102
+ return this;
103
+ }
104
+ each(...params) {
105
+ const { args, callback, complete } = (0, utilities_1.popCallback)(params);
106
+ if ((args === null || args === void 0 ? void 0 : args.length) > 0) {
107
+ // apply new bindings then execute
108
+ this.bind(...args, (error) => {
109
+ if (error) {
110
+ callback === null || callback === void 0 ? void 0 : callback.call(this, error);
111
+ }
112
+ else {
113
+ this._database.each(this._preparedSql || '', callback, complete);
114
+ }
115
+ });
116
+ }
117
+ else {
118
+ // execute prepared sql with same bindings
119
+ this._database.each(this._preparedSql || '', callback, complete);
120
+ }
121
+ return this;
122
+ }
123
+ }
124
+ exports.Statement = Statement;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * transport-tls.ts - handles low level communication with sqlitecloud server via tls socket and binary protocol
3
+ */
4
+ import { SQLiteCloudConfig, ErrorCallback, ResultsCallback } from './types';
5
+ import { ConnectionTransport } from './connection';
6
+ /**
7
+ * Implementation of SQLiteCloudConnection that connects directly to the database via tls socket and raw, binary protocol.
8
+ * SQLiteCloud low-level connection, will do messaging, handle socket, authentication, etc.
9
+ * A connection socket is established when the connection is created and closed when the connection is closed.
10
+ * All operations are serialized by waiting for any pending operations to complete. Once a connection is closed,
11
+ * it cannot be reopened and you must create a new connection.
12
+ */
13
+ export declare class TlsSocketTransport implements ConnectionTransport {
14
+ /** Configuration passed to connect */
15
+ private config?;
16
+ /** Currently opened tls socket used to communicated with SQLiteCloud server */
17
+ private socket?;
18
+ /** True if connection is open */
19
+ get connected(): boolean;
20
+ connect(config: SQLiteCloudConfig, callback?: ErrorCallback): this;
21
+ /** Will send a command immediately (no queueing), return the rowset/result or throw an error */
22
+ processCommands(commands: string, callback?: ResultsCallback): this;
23
+ /** Disconnect from server, release connection. */
24
+ close(): this;
25
+ }