@imam-inter/openim-sdk-js-wasm 3.8.2-1 → 3.8.2-3
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.
- package/lib/worker-legacy.js +1 -1
- package/lib/worker.js +1 -1
- package/package.json +1 -1
package/lib/worker-legacy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,a=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&s(e,r,t[r]);if(n)for(var r of n(t))o.call(t,r)&&s(e,r,t[r]);return e},u=(e,n)=>t(e,r(n)),c=(e,t,r)=>(s(e,"symbol"!=typeof t?t+"":t,r),r);const l={CONNECT_TIMEOUT:{code:-32300,message:"Connect timeout"},APPLICATION_ERROR:{code:-32500,message:"Application error"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"}};const f=class{constructor(e){c(this,"_event"),c(this,"_methods",{}),c(this,"_timeout",0),c(this,"_$connect",null),this._event=e.event,this._timeout=e.timeout||0,e.methods&&Object.entries(e.methods).forEach((([e,t])=>{this.registerMethod(e,t)})),this._event.onerror=e=>{const{code:t,message:r,data:n}=e;if(n.event&&Array.isArray(n.args)&&n.args.length){const e=n.args[0],i=this._getAckEventName(e.method),o={jsonrpc:"2.0",id:null==e?void 0:e.id,error:{code:t,message:r,data:e}};this._event.emit(i,o)}else console.error(e)},this.connect()}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}_getSynEventName(e){return`${f.EVENT.SYN_SIGN}${e}`}_getAckEventName(e){return`${f.EVENT.ACK_SIGN}${e}`}connect(e){return this._$connect||(this._$connect=new Promise(((t,r)=>{const n=e||this._timeout;let i;n&&(i=setTimeout((()=>{const e=u(a({},l.TIMEOUT),{data:{timeout:n}});r(e)}),n));const o=f.EVENT.CONNECT,s=this._getAckEventName(o),c=this._getSynEventName(o),d=()=>{clearTimeout(i),t()};this._event.on(s,d);this._event.on(c,(()=>{this._event.emit(s),d()})),this._event.emit(c)}))),this._$connect}registerMethod(e,t){if(this._methods[e])throw new Error(`${e} already registered`);this._methods[e]=t;const r=this._getSynEventName(e);this._event.on(r,(r=>{const n=this._getAckEventName(e);r.id?Promise.resolve(t(...r.params)).then((e=>{const t={jsonrpc:"2.0",result:e,id:r.id};this._event.emit(n,t)})).catch((e=>{const t={jsonrpc:"2.0",id:r.id,error:{code:(null==e?void 0:e.code)||l.APPLICATION_ERROR.code,message:(null==e?void 0:e.message)||l.APPLICATION_ERROR.message,data:null}};this._event.emit(n,t)})):t(...r.params)}))}removeMethod(e){this._methods[e]||delete this._methods[e];const t=this._getSynEventName(e);this._event.off(t)}invoke(e,...t){return new Promise(((r,n)=>{const i=t[t.length-1],o=i&&"object"==typeof i&&(Reflect.has(i,"isNotify")||Reflect.has(i,"timeout")),s=o?i:{isNotify:!1,timeout:0},c=o?t.slice(0,-1):t,d=this._getSynEventName(e),h=f.uuid(),_={jsonrpc:"2.0",method:e,params:c,id:h};if(this._event.emit(d,_),s.isNotify)r(void 0);else{const t=this._getAckEventName(e),i=s.timeout||this._timeout;let o;i&&(o=setTimeout((()=>{const e=u(a({},l.CONNECT_TIMEOUT),{data:{timeout:i}});n(e)}),i));const c=e=>{e.id===h&&(clearTimeout(o),this._event.off(t,c),e.error?n(e.error):r(e.result))};this._event.on(t,c)}}))}destroy(){Object.entries(this._methods).forEach((([e])=>{const t=this._getSynEventName(e);this._event.off(t)}));const e=this._getAckEventName(f.EVENT.CONNECT),t=this._getSynEventName(f.EVENT.CONNECT);this._event.off(t),this._event.off(e),this._event.destroy&&this._event.destroy()}};let d=f;c(d,"CODES",l),c(d,"EVENT",{SYN_SIGN:"syn:",ACK_SIGN:"ack:",CONNECT:"__rpc_connect_event",SYNC_METHODS:"__rpc_sync_methods_event"});const h={ErrorInit:10001,ErrorNoRecord:10002,ErrorDBTimeout:10003};var _;!function(e){e.Login="Login",e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnUserTokenInvalid="OnUserTokenInvalid",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvOnlineOnlyMessage="OnRecvOnlineOnlyMessage",e.OnRecvOfflineNewMessage="onRecvOfflineNewMessage",e.OnRecvOnlineOnlyMessages="OnRecvOnlineOnlyMessages",e.OnRecvOfflineNewMessages="onRecvOfflineNewMessages",e.OnRecvMessageRevoked="OnRecvMessageRevoked",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnConversationUserInputStatusChanged="OnConversationUserInputStatusChanged",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerProgress="OnSyncServerProgress",e.OnSyncServerStart="OnSyncServerStart",e.OnTotalUnreadMessageCountChanged="OnTotalUnreadMessageCountChanged",e.OnBlackAdded="OnBlackAdded",e.OnBlackDeleted="OnBlackDeleted",e.OnFriendApplicationAccepted="OnFriendApplicationAccepted",e.OnFriendApplicationAdded="OnFriendApplicationAdded",e.OnFriendApplicationDeleted="OnFriendApplicationDeleted",e.OnFriendApplicationRejected="OnFriendApplicationRejected",e.OnFriendInfoChanged="OnFriendInfoChanged",e.OnFriendAdded="OnFriendAdded",e.OnFriendDeleted="OnFriendDeleted",e.OnJoinedGroupAdded="OnJoinedGroupAdded",e.OnJoinedGroupDeleted="OnJoinedGroupDeleted",e.OnGroupDismissed="OnGroupDismissed",e.OnGroupMemberAdded="OnGroupMemberAdded",e.OnGroupMemberDeleted="OnGroupMemberDeleted",e.OnGroupApplicationAdded="OnGroupApplicationAdded",e.OnGroupApplicationDeleted="OnGroupApplicationDeleted",e.OnGroupInfoChanged="OnGroupInfoChanged",e.OnGroupMemberInfoChanged="OnGroupMemberInfoChanged",e.OnGroupApplicationAccepted="OnGroupApplicationAccepted",e.OnGroupApplicationRejected="OnGroupApplicationRejected",e.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnUploadLogsProgress="OnUploadLogsProgress",e.OnReceiveNewInvitation="OnReceiveNewInvitation",e.OnInviteeAccepted="OnInviteeAccepted",e.OnInviteeRejected="OnInviteeRejected",e.OnInvitationCancelled="OnInvitationCancelled",e.OnHangUp="OnHangUp",e.OnInvitationTimeout="OnInvitationTimeout",e.OnInviteeAcceptedByOtherDevice="OnInviteeAcceptedByOtherDevice",e.OnInviteeRejectedByOtherDevice="OnInviteeRejectedByOtherDevice",e.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal",e.UnUsedEvent="UnUsedEvent"}(_||(_={}));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var m={exports:{}};m.exports=function(){var e=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0},t=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){return e.length?e+t:e}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(e&&n){var o=function(t){"object"===(void 0===t?"undefined":r(t))&&Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]}))},s=!0,a=!1,u=void 0;try{for(var c,l=n[Symbol.iterator]();!(s=(c=l.next()).done);s=!0)o(c.value)}catch(e){a=!0,u=e}finally{try{!s&&l.return&&l.return()}finally{if(a)throw u}}}return e}function u(e){return e&&e.constructor.prototype===Object.prototype}function c(e){return e&&e.constructor.prototype===Array.prototype}function l(e){if(!e)return e;if("function"==typeof e.clone)return e.clone();if(u(e)||c(e)){var t=new e.constructor;return Object.getOwnPropertyNames(e).forEach((function(r){"function"!=typeof e[r]&&(t[r]=l(e[r]))})),t}return JSON.parse(JSON.stringify(e))}function f(e,t,n){var i=void 0===t?"undefined":r(t);if("function"!==i&&"string"!==i)throw new Error("type must be a class constructor or string");if("function"!=typeof n)throw new Error("handler must be a function");var o=!0,s=!1,a=void 0;try{for(var u,c=e[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var l=u.value;if(l.type===t)return void(l.handler=n)}}catch(e){s=!0,a=e}finally{try{!o&&c.return&&c.return()}finally{if(s)throw a}}e.push({type:t,handler:n})}function d(e,t,r){return h(e,t)||h(e,r)}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];if((void 0===e?"undefined":r(e))===i.type||"string"!=typeof i.type&&e instanceof i.type)return i.handler}}function _(){var h=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,_={isSquelBuilder:function(e){return e&&!!e._toParamString}},p=function(e){return!_.isSquelBuilder(e)||!e.options.rawNesting};_.DefaultQueryBuilderOptions={autoQuoteTableNames:!1,autoQuoteFieldNames:!1,autoQuoteAliasNames:!0,useAsForTableAliasNames:!1,nameQuoteCharacter:"`",tableAliasQuoteCharacter:"`",fieldAliasQuoteCharacter:'"',valueHandlers:[],parameterCharacter:"?",numberedParameters:!1,numberedParametersPrefix:"$",numberedParametersStartAt:1,replaceSingleQuotes:!1,singleQuoteReplacement:"''",separator:" ",stringFormatter:null,rawNesting:!1},_.globalValueHandlers=[],_.registerValueHandler=function(e,t){f(_.globalValueHandlers,e,t)},_.Cloneable=function(){function e(){o(this,e)}return t(e,[{key:"clone",value:function(){return a(new this.constructor,l(a({},this)))}}]),e}(),_.BaseBuilder=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this)),r=JSON.parse(JSON.stringify(_.DefaultQueryBuilderOptions));return["stringFormatter"].forEach((function(e){r[e]=_.DefaultQueryBuilderOptions[e]})),t.options=a({},r,e),t}return i(s,e),t(s,[{key:"registerValueHandler",value:function(e,t){return f(this.options.valueHandlers,e,t),this}},{key:"_sanitizeExpression",value:function(e){if(!_.isSquelBuilder(e)&&"string"!=typeof e)throw new Error("expression must be a string or builder instance");return e}},{key:"_sanitizeName",value:function(e,t){if("string"!=typeof e)throw new Error(t+" must be a string");return e}},{key:"_sanitizeField",value:function(e){return _.isSquelBuilder(e)||(e=this._sanitizeName(e,"field name")),e}},{key:"_sanitizeBaseBuilder",value:function(e){if(_.isSquelBuilder(e))return e;throw new Error("must be a builder instance")}},{key:"_sanitizeTable",value:function(e){if("string"!=typeof e)try{e=this._sanitizeBaseBuilder(e)}catch(e){throw new Error("table name must be a string or a builder")}else e=this._sanitizeName(e,"table");return e}},{key:"_sanitizeTableAlias",value:function(e){return this._sanitizeName(e,"table alias")}},{key:"_sanitizeFieldAlias",value:function(e){return this._sanitizeName(e,"field alias")}},{key:"_sanitizeLimitOffset",value:function(e){if(0>(e=parseInt(e))||isNaN(e))throw new Error("limit/offset must be >= 0");return e}},{key:"_sanitizeValue",value:function(e){var t=void 0===e?"undefined":r(e);if(null===e);else if("string"===t||"number"===t||"boolean"===t);else if(_.isSquelBuilder(e));else if(!d(e,this.options.valueHandlers,_.globalValueHandlers))throw new Error("field value must be a string, number, boolean, null or one of the registered custom value types");return e}},{key:"_escapeValue",value:function(e){return this.options.replaceSingleQuotes&&e?e.replace(/\'/g,this.options.singleQuoteReplacement):e}},{key:"_formatTableName",value:function(e){if(this.options.autoQuoteTableNames){var t=this.options.nameQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatFieldAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.fieldAliasQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatTableAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.tableAliasQuoteCharacter;e=""+t+e+t}return this.options.useAsForTableAliasNames?"AS "+e:e}},{key:"_formatFieldName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options.autoQuoteFieldNames){var r=this.options.nameQuoteCharacter;e=t.ignorePeriodsForFieldNameQuotes?""+r+e+r:e.split(".").map((function(e){return"*"===e?e:""+r+e+r})).join(".")}return e}},{key:"_formatCustomValue",value:function(e,t,r){var n=d(e,this.options.valueHandlers,_.globalValueHandlers);return n&&(e=n(e,t,r))&&e.rawNesting?{formatted:!0,rawNesting:!0,value:e.value}:{formatted:!!n,value:e}}},{key:"_formatValueForParamArray",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e)?e.map((function(e){return t._formatValueForParamArray(e,r)})):this._formatCustomValue(e,!0,r).value}},{key:"_formatValueForQueryString",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this._formatCustomValue(e,!1,n),o=i.rawNesting,s=i.formatted,a=i.value;if(s)return o?a:this._applyNestingFormatting(a,p(e));if(c(a))a=a.map((function(e){return t._formatValueForQueryString(e)})),a=this._applyNestingFormatting(a.join(", "),p(a));else{var u=void 0===a?"undefined":r(a);if(null===a)a="NULL";else if("boolean"===u)a=a?"TRUE":"FALSE";else if(_.isSquelBuilder(a))a=this._applyNestingFormatting(a.toString(),p(a));else if("number"!==u){if("string"===u&&this.options.stringFormatter)return this.options.stringFormatter(a);a=n.dontQuote?""+a:"'"+this._escapeValue(a)+"'"}}return a}},{key:"_applyNestingFormatting",value:function(e){if(e&&"string"==typeof e&&(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!this.options.rawNesting){var t="("===e.charAt(0)&&")"===e.charAt(e.length-1);if(t)for(var r=0,n=1;e.length-1>++r;){var i=e.charAt(r);if("("===i)n++;else if(")"===i&&1>--n){t=!1;break}}t||(e="("+e+")")}return e}},{key:"_buildString",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.nested,i=r.buildParameterized,o=r.formattingOptions;t=t||[],e=e||"";for(var s="",a=-1,u=[],l=this.options.parameterCharacter,f=0;e.length>f;)if(e.substr(f,l.length)===l){var d=t[++a];if(i)if(_.isSquelBuilder(d)){var h=d._toParamString({buildParameterized:i,nested:!0});s+=h.text,h.values.forEach((function(e){return u.push(e)}))}else c(d=this._formatValueForParamArray(d,o))?(s+="("+d.map((function(){return l})).join(", ")+")",d.forEach((function(e){return u.push(e)}))):(s+=l,u.push(d));else s+=this._formatValueForQueryString(d,o);f+=l.length}else s+=e.charAt(f),f++;return{text:this._applyNestingFormatting(s,!!n),values:u}}},{key:"_buildManyStrings",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[],i=[],o=0;e.length>o;++o){var s=e[o],a=t[o],u=this._buildString(s,a,{buildParameterized:r.buildParameterized,nested:!1}),c=u.text,l=u.values;n.push(c),l.forEach((function(e){return i.push(e)}))}return{text:(n=n.join(this.options.separator)).length?this._applyNestingFormatting(n,!!r.nested):"",values:i}}},{key:"_toParamString",value:function(e){throw new Error("Not yet implemented")}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(e).text}},{key:"toParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(a({},e,{buildParameterized:!0}))}}]),s}(_.Cloneable),_.Expression=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._nodes=[],t}return i(r,e),t(r,[{key:"and",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e=this._sanitizeExpression(e),this._nodes.push({type:"AND",expr:e,para:r}),this}},{key:"or",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e=this._sanitizeExpression(e),this._nodes.push({type:"OR",expr:e,para:r}),this}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._nodes[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.type,l=u.expr,f=u.para,d=_.isSquelBuilder(l)?l._toParamString({buildParameterized:e.buildParameterized,nested:!0}):this._buildString(l,f,{buildParameterized:e.buildParameterized}),h=d.text,p=d.values;t.length&&t.push(c),t.push(h),p.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t=t.join(" "),{text:this._applyNestingFormatting(t,!!e.nested),values:r}}}]),r}(_.BaseBuilder),_.Case=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t));return u(e)&&(t=e,e=null),e&&(i._fieldName=i._sanitizeField(e)),i.options=a({},_.DefaultQueryBuilderOptions,t),i._cases=[],i._elseValue=null,i}return i(r,e),t(r,[{key:"when",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this._cases.unshift({expression:e,values:r||[]}),this}},{key:"then",value:function(e){if(0==this._cases.length)throw new Error("when() needs to be called first");return this._cases[0].result=e,this}},{key:"else",value:function(e){return this._elseValue=e,this}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._cases[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.expression,f=c.values,d=c.result;t=s(t," ");var h=this._buildString(l,f,{buildParameterized:e.buildParameterized,nested:!0});t+="WHEN "+h.text+" THEN "+this._formatValueForQueryString(d),h.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return t.length?(t+=" ELSE "+this._formatValueForQueryString(this._elseValue)+" END",this._fieldName&&(t=this._fieldName+" "+t),t="CASE "+t):t=this._formatValueForQueryString(this._elseValue),{text:t,values:r}}}]),r}(_.BaseBuilder),_.Block=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return i(r,e),t(r,[{key:"exposedMethods",value:function(){for(var e={},t=this;t;)Object.getOwnPropertyNames(t).forEach((function(r){"constructor"===r||"function"!=typeof t[r]||"_"===r.charAt(0)||_.Block.prototype[r]||(e[r]=t[r])})),t=Object.getPrototypeOf(t);return e}}]),r}(_.BaseBuilder),_.StringBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._str=t,i}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._str,values:[]}}}]),r}(_.Block),_.FunctionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._strings=[],t._values=[],t}return i(r,e),t(r,[{key:"function",value:function(e){this._strings.push(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._values.push(r)}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._buildManyStrings(this._strings,this._values,e)}}]),r}(_.Block),_.registerValueHandler(_.FunctionBlock,(function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.toParam():e.toString()})),_.AbstractTableBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._tables=[],i}return i(r,e),t(r,[{key:"_table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t?this._sanitizeTableAlias(t):t,e=this._sanitizeTable(e),this.options.singleTable&&(this._tables=[]),this._tables.push({table:e,alias:t})}},{key:"_hasTable",value:function(){return 0<this._tables.length}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._hasTable()){var n=!0,i=!1,o=void 0;try{for(var a,u=this._tables[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.table,f=c.alias;t=s(t,", ");var d=void 0;if(_.isSquelBuilder(l)){var h=l._toParamString({buildParameterized:e.buildParameterized,nested:!0}),p=h.text,g=h.values;d=p,g.forEach((function(e){return r.push(e)}))}else d=this._formatTableName(l);f&&(d+=" "+this._formatTableAlias(f)),t+=d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}this.options.prefix&&(t=this.options.prefix+" "+t)}return{text:t,values:r}}}]),r}(_.Block),_.TargetTableBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"target",value:function(e){this._table(e)}}]),r}(_.AbstractTableBlock),_.UpdateTableBlock=function(r){function s(){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return i(s,r),t(s,[{key:"table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("table() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.FromTableBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{prefix:"FROM"})))}return i(r,e),t(r,[{key:"from",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}}]),r}(_.AbstractTableBlock),_.IntoTableBlock=function(r){function s(e){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,a({},e,{prefix:"INTO",singleTable:!0})))}return i(s,r),t(s,[{key:"into",value:function(e){this._table(e)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("into() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.GetFieldBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"fields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(e)){var r=!0,n=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var a=o.value;this.field(a,null,t)}}catch(e){n=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}}else for(var u in e){var l=e[u];this.field(u,l,t)}}},{key:"field",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.queryBuilder,r=e.buildParameterized,n="",i=[],o=!0,a=!1,u=void 0;try{for(var c,l=this._fields[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;n=s(n,", ");var d=f.name,h=f.alias,p=f.options;if("string"==typeof d)n+=this._formatFieldName(d,p);else{var g=d._toParamString({nested:!0,buildParameterized:r});n+=g.text,g.values.forEach((function(e){return i.push(e)}))}h&&(n+=" AS "+this._formatFieldAlias(h))}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}if(!n.length){var m=t&&t.getBlock(_.FromTableBlock);m&&m._hasTable()&&(n="*")}return{text:n,values:i}}}]),r}(_.Block),_.AbstractSetFieldBlock=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._reset(),t}return i(s,e),t(s,[{key:"_reset",value:function(){this._fields=[],this._values=[[]],this._valueOptions=[[]]}},{key:"_set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._values.length>1)throw new Error("Cannot set multiple rows of fields this way.");void 0!==t&&(t=this._sanitizeValue(t)),e=this._sanitizeField(e);var n=this._fields.indexOf(e);-1===n&&(this._fields.push(e),n=this._fields.length-1),this._values[0][n]=t,this._valueOptions[0][n]=r}},{key:"_setFields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===e?"undefined":r(e)))throw new Error("Expected an object but got "+(void 0===e?"undefined":r(e)));for(var n in e)this._set(n,e[n],t)}},{key:"_setFieldsRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(e))throw new Error("Expected an array of objects but got "+(void 0===e?"undefined":r(e)));this._reset();for(var n=0;e.length>n;++n){var i=e[n];for(var o in i){var s=i[o];o=this._sanitizeField(o),s=this._sanitizeValue(s);var a=this._fields.indexOf(o);if(0<n&&-1===a)throw new Error("All fields in subsequent rows must match the fields in the first row");-1===a&&(this._fields.push(o),a=this._fields.length-1),c(this._values[n])||(this._values[n]=[],this._valueOptions[n]=[]),this._values[n][a]=s,this._valueOptions[n][a]=t}}}}]),s}(_.Block),_.SetFieldBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t,r){this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"_toParamString",value:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized;if(0>=this._fields.length)throw new Error("set() needs to be called");for(var t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._formatFieldName(this._fields[n]),o=this._values[0][n];0>i.indexOf("=")&&(i=i+" = "+this.options.parameterCharacter);var a=this._buildString(i,[o],{buildParameterized:e,formattingOptions:this._valueOptions[0][n]});t+=a.text,a.values.forEach((function(e){return r.push(e)}))}return{text:"SET "+t,values:r}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldValueBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"setFieldsRows",value:function(e,t){this._setFieldsRows(e,t)}},{key:"_toParamString",value:function(){for(var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized,r=this._fields.map((function(t){return e._formatFieldName(t)})).join(", "),n=[],i=[],o=0;o<this._values.length;++o){n[o]="";for(var a=0;a<this._values[o].length;++a){var u=this._buildString(this.options.parameterCharacter,[this._values[o][a]],{buildParameterized:t,formattingOptions:this._valueOptions[o][a]});u.values.forEach((function(e){return i.push(e)})),n[o]=s(n[o],", "),n[o]+=u.text}}return{text:r.length?"("+r+") VALUES ("+n.join("), (")+")":"",values:i}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldsFromQueryBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t._query=null,t}return i(r,e),t(r,[{key:"fromQuery",value:function(e,t){var r=this;this._fields=e.map((function(e){return r._sanitizeField(e)})),this._query=this._sanitizeBaseBuilder(t)}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._fields.length&&this._query){var n=this._query._toParamString({buildParameterized:e.buildParameterized,nested:!0}),i=n.text,o=n.values;t="("+this._fields.join(", ")+") "+this._applyNestingFormatting(i),r=o}return{text:t,values:r}}}]),r}(_.Block),_.DistinctBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"distinct",value:function(){this._useDistinct=!0}},{key:"_toParamString",value:function(){return{text:this._useDistinct?"DISTINCT":"",values:[]}}}]),r}(_.Block),_.GroupByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._groups=[],t}return i(r,e),t(r,[{key:"group",value:function(e){this._groups.push(this._sanitizeField(e))}},{key:"_toParamString",value:function(){return{text:this._groups.length?"GROUP BY "+this._groups.join(", "):"",values:[]}}}]),r}(_.Block),_.AbstractVerbSingleValueBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._value=null,t}return i(r,e),t(r,[{key:"_setValue",value:function(e){this._value=null!==e?this._sanitizeLimitOffset(e):e}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=null!==this._value?this.options.verb+" "+this.options.parameterCharacter:"",r=null!==this._value?[this._value]:[];return this._buildString(t,r,e)}}]),r}(_.Block),_.OffsetBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"OFFSET"})))}return i(r,e),t(r,[{key:"offset",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.LimitBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"LIMIT"})))}return i(r,e),t(r,[{key:"limit",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.AbstractConditionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._conditions=[],t}return i(r,e),t(r,[{key:"_condition",value:function(e){e=this._sanitizeExpression(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._conditions.push({expr:e,values:r||[]})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._conditions[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.expr,l=u.values,f=_.isSquelBuilder(c)?c._toParamString({buildParameterized:e.buildParameterized}):this._buildString(c,l,{buildParameterized:e.buildParameterized});f.text.length&&t.push(f.text),f.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t.length&&(t=t.join(") AND (")),{text:t.length?this.options.verb+" ("+t+")":"",values:r}}}]),r}(_.Block),_.WhereBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"WHERE"})))}return i(r,e),t(r,[{key:"where",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._condition.apply(this,[e].concat(r))}}]),r}(_.AbstractConditionBlock),_.HavingBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"HAVING"})))}return i(r,e),t(r,[{key:"having",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._condition.apply(this,[e].concat(r))}}]),r}(_.AbstractConditionBlock),_.OrderByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._orders=[],t}return i(r,e),t(r,[{key:"order",value:function(e,t){e=this._sanitizeField(e),"string"!=typeof t&&(void 0===t?t="ASC":null!==t&&(t=t?"ASC":"DESC"));for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];this._orders.push({field:e,dir:t,values:n||[]})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._orders[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,f=l.field,d=l.dir,h=l.values;t=s(t,", ");var _=this._buildString(f,h,{buildParameterized:e.buildParameterized});t+=_.text,c(_.values)&&_.values.forEach((function(e){return r.push(e)})),null!==d&&(t+=" "+d)}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t.length?"ORDER BY "+t:"",values:r}}}]),r}(_.Block),_.JoinBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._joins=[],t}return i(r,e),t(r,[{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"INNER";e=this._sanitizeTable(e,!0),t=t?this._sanitizeTableAlias(t):t,r=r?this._sanitizeExpression(r):r,this._joins.push({type:n,table:e,alias:t,condition:r})}},{key:"left_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT")}},{key:"right_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"RIGHT")}},{key:"outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"OUTER")}},{key:"left_outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT OUTER")}},{key:"full_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"FULL")}},{key:"cross_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"CROSS")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._joins[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table,d=c.alias,h=c.condition;t=s(t,this.options.separator);var p=void 0;if(_.isSquelBuilder(f)){var g=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});g.values.forEach((function(e){return r.push(e)})),p=g.text}else p=this._formatTableName(f);if(t+=l+" JOIN "+p,d&&(t+=" "+this._formatTableAlias(d)),h){t+=" ON ";var m=void 0;m=_.isSquelBuilder(h)?h._toParamString({buildParameterized:e.buildParameterized}):this._buildString(h,[],{buildParameterized:e.buildParameterized}),t+=this._applyNestingFormatting(m.text),m.values.forEach((function(e){return r.push(e)}))}}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.UnionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._unions=[],t}return i(r,e),t(r,[{key:"union",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UNION";e=this._sanitizeTable(e),this._unions.push({type:t,table:e})}},{key:"union_all",value:function(e){this.union(e,"UNION ALL")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._unions[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table;t=s(t,this.options.separator);var d=void 0;if(f instanceof _.BaseBuilder){var h=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});d=h.text,h.values.forEach((function(e){return r.push(e)}))}else t=this._formatTableName(f);t+=l+" "+d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.QueryBuilder=function(r){function s(e,t){o(this,s);var r=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));r.blocks=t||[];var i=!0,a=!1,u=void 0;try{for(var c,l=r.blocks[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value,d=f.exposedMethods();for(var h in d){var _=d[h];if(void 0!==r[h])throw new Error("Builder already has a builder method called: "+h);!function(e,t,n){r[t]=function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];return n.call.apply(n,[e].concat(i)),r}}(f,h,_)}}}catch(e){a=!0,u=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw u}}return r}return i(s,r),t(s,[{key:"registerValueHandler",value:function(t,r){var n=!0,i=!1,o=void 0;try{for(var a,u=this.blocks[Symbol.iterator]();!(n=(a=u.next()).done);n=!0)a.value.registerValueHandler(t,r)}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"registerValueHandler",this).call(this,t,r),this}},{key:"updateOptions",value:function(e){this.options=a({},this.options,e);var t=!0,r=!1,n=void 0;try{for(var i,o=this.blocks[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;s.options=a({},s.options,e)}}catch(e){r=!0,n=e}finally{try{!t&&o.return&&o.return()}finally{if(r)throw n}}}},{key:"_toParamString",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=a({},this.options,t);var r=this.blocks.map((function(r){return r._toParamString({buildParameterized:t.buildParameterized,queryBuilder:e})})),n=r.map((function(e){return e.text})),i=r.map((function(e){return e.values})),o=n.filter((function(e){return 0<e.length})).join(t.separator),s=[];if(i.forEach((function(e){return e.forEach((function(e){return s.push(e)}))})),!t.nested&&t.numberedParameters){var u=void 0!==t.numberedParametersStartAt?t.numberedParametersStartAt:1,c=t.parameterCharacter.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");o=o.replace(new RegExp(c,"g"),(function(){return""+t.numberedParametersPrefix+u++}))}return{text:this._applyNestingFormatting(o,!!t.nested),values:s}}},{key:"clone",value:function(){var e=this.blocks.map((function(e){return e.clone()}));return new this.constructor(this.options,e)}},{key:"getBlock",value:function(e){return this.blocks.filter((function(t){return t instanceof e}))[0]}}]),s}(_.BaseBuilder),_.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"SELECT"),new _.FunctionBlock(e),new _.DistinctBlock(e),new _.GetFieldBlock(e),new _.FromTableBlock(e),new _.JoinBlock(e),new _.WhereBlock(e),new _.GroupByBlock(e),new _.HavingBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e),new _.OffsetBlock(e),new _.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"UPDATE"),new _.UpdateTableBlock(e),new _.SetFieldBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"DELETE"),new _.TargetTableBlock(e),new _.FromTableBlock(a({},e,{singleTable:!0})),new _.JoinBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"INSERT"),new _.IntoTableBlock(e),new _.InsertFieldValueBlock(e),new _.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder);var g={VERSION:"5.13.0",flavour:h,expr:function(e){return new _.Expression(e)},case:function(e,t){return new _.Case(e,t)},select:function(e,t){return new _.Select(e,t)},update:function(e,t){return new _.Update(e,t)},insert:function(e,t){return new _.Insert(e,t)},delete:function(e,t){return new _.Delete(e,t)},str:function(){var e=new _.FunctionBlock;return e.function.apply(e,arguments),e},rstr:function(){var e=new _.FunctionBlock({rawNesting:!0});return e.function.apply(e,arguments),e},registerValueHandler:_.registerValueHandler};return g.remove=g.delete,g.cls=_,g}var p=_();return p.flavours={},p.useFlavour=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return p;if(p.flavours[e]instanceof Function){var t=_(e);return p.flavours[e].call(null,t),t.flavours=p.flavours,t.useFlavour=p.useFlavour,t}throw new Error("Flavour not available: "+e)},p.flavours.mssql=function(r){var u=r.cls;u.DefaultQueryBuilderOptions.replaceSingleQuotes=!0,u.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,u.DefaultQueryBuilderOptions.numberedParametersPrefix="@",r.registerValueHandler(Date,(function(e){return"'"+e.getUTCFullYear()+"-"+(e.getUTCMonth()+1)+"-"+e.getUTCDate()+" "+e.getUTCHours()+":"+e.getUTCMinutes()+":"+e.getUTCSeconds()+"'"})),u.MssqlLimitOffsetTopBlock=function(e){function r(e){o(this,r);var s=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));s._limits=null,s._offsets=null;var a=function(e){e=this._sanitizeLimitOffset(e),this._parent._limits=e};return s.ParentBlock=function(e){function t(e){o(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.options));return r._parent=e,r}return i(t,e),t}(u.Block),s.LimitBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.limit=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&this._parent._offsets&&(e="FETCH NEXT "+this._parent._limits+" ROWS ONLY"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.TopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.top=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&!this._parent._offsets&&(e="TOP ("+this._parent._limits+")"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.OffsetBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"offset",value:function(e){this._parent._offsets=this._sanitizeLimitOffset(e)}},{key:"_toParamString",value:function(){var e="";return this._parent._offsets&&(e="OFFSET "+this._parent._offsets+" ROWS"),{text:e,values:[]}}}]),r}(s.ParentBlock),s}return i(r,e),t(r,[{key:"LIMIT",value:function(){return new this.LimitBlock(this)}},{key:"TOP",value:function(){return new this.TopBlock(this)}},{key:"OFFSET",value:function(){return new this.OffsetBlock(this)}}]),r}(u.Block),u.MssqlUpdateTopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._limits=null,t.limit=t.top=function(e){t._limits=t._sanitizeLimitOffset(e)},t}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._limits?"TOP ("+this._limits+")":"",values:[]}}}]),r}(u.Block),u.MssqlInsertFieldValueBlock=function(r){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._outputs=[],t}return i(s,r),t(s,[{key:"output",value:function(e){var t=this;"string"==typeof e?this._outputs.push("INSERTED."+this._sanitizeField(e)):e.forEach((function(e){t._outputs.push("INSERTED."+t._sanitizeField(e))}))}},{key:"_toParamString",value:function(t){var r=e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t);if(r.text.length&&0<this._outputs.length){var n="OUTPUT "+this._outputs.join(", ")+" ",i=r.text.indexOf("VALUES");r.text=r.text.substr(0,i)+n+r.text.substr(i)}return r}}]),s}(u.InsertFieldValueBlock),u.MssqlUpdateDeleteOutputBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._outputs=[],t}return i(r,e),t(r,[{key:"outputs",value:function(e){for(var t in e)this.output(t,e[t])}},{key:"output",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this._sanitizeField(e),t=t?this._sanitizeFieldAlias(t):t,this._outputs.push({name:this.options.forDelete?"DELETED."+e:"INSERTED."+e,alias:t})}},{key:"_toParamString",value:function(e){var t="";if(this._outputs.length){var r=!0,n=!1,i=void 0;try{for(var o,a=this._outputs[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;t=s(t,", "),t+=u.name,u.alias&&(t+=" AS "+this._formatFieldAlias(u.alias))}}catch(e){n=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}t="OUTPUT "+t}return{text:t,values:[]}}}]),r}(u.Block),u.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t);var i=new u.MssqlLimitOffsetTopBlock(e);return r=r||[new u.StringBlock(e,"SELECT"),new u.DistinctBlock(e),i.TOP(),new u.GetFieldBlock(e),new u.FromTableBlock(e),new u.JoinBlock(e),new u.WhereBlock(e),new u.GroupByBlock(e),new u.OrderByBlock(e),i.OFFSET(),i.LIMIT(),new u.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"UPDATE"),new u.MssqlUpdateTopBlock(e),new u.UpdateTableBlock(e),new u.SetFieldBlock(e),new u.MssqlUpdateDeleteOutputBlock(e),new u.WhereBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"DELETE"),new u.TargetTableBlock(e),new u.FromTableBlock(a({},e,{singleTable:!0})),new u.JoinBlock(e),new u.MssqlUpdateDeleteOutputBlock(a({},e,{forDelete:!0})),new u.WhereBlock(e),new u.OrderByBlock(e),new u.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"INSERT"),new u.IntoTableBlock(e),new u.MssqlInsertFieldValueBlock(e),new u.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder)},p.flavours.mysql=function(e){var r=e.cls;r.MysqlOnDuplicateKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onDupUpdate",value:function(e,t,r){this._set(e,t,r)}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._fields[n],o=this._values[0][n],a=this._valueOptions[0][n];if(void 0===o)t+=i;else{var u=this._buildString(i+" = "+this.options.parameterCharacter,[o],{buildParameterized:e.buildParameterized,formattingOptions:a});t+=u.text,u.values.forEach((function(e){return r.push(e)}))}}return{text:t.length?"ON DUPLICATE KEY UPDATE "+t:"",values:r}}}]),r}(r.AbstractSetFieldBlock),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.MysqlOnDuplicateKeyUpdateBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Replace=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"REPLACE"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),e.replace=function(e,t){return new r.Replace(e,t)}},p.flavours.postgres=function(e){var r=e.cls;r.DefaultQueryBuilderOptions.numberedParameters=!0,r.DefaultQueryBuilderOptions.numberedParametersStartAt=1,r.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,r.DefaultQueryBuilderOptions.useAsForTableAliasNames=!0,r.PostgresOnConflictKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onConflict",value:function(e,t){var r=this;this._onConflict=!0,e&&(c(e)||(e=[e]),this._dupFields=e.map(this._sanitizeField.bind(this)),t&&Object.keys(t).forEach((function(e){r._set(e,t[e])})))}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._fields[n],o=this._values[0][n],a=this._valueOptions[0][n];if(void 0===o)t+=i;else{var u=this._buildString(i+" = "+this.options.parameterCharacter,[o],{buildParameterized:e.buildParameterized,formattingOptions:a});t+=u.text,u.values.forEach((function(e){return r.push(e)}))}}var c={text:"",values:r};if(this._onConflict){var l=this._dupFields?"("+this._dupFields.join(", ")+") ":"",f=t.length?"UPDATE SET "+t:"NOTHING";c.text="ON CONFLICT "+l+"DO "+f}return c}}]),r}(r.AbstractSetFieldBlock),r.ReturningBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"returning",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.queryBuilder;var t=e.buildParameterized,r="",n=[],i=!0,o=!1,a=void 0;try{for(var u,c=this._fields[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;r=s(r,", ");var f=l.name,d=l.alias,h=l.options;if("string"==typeof f)r+=this._formatFieldName(f,h);else{var _=f._toParamString({nested:!0,buildParameterized:t});r+=_.text,_.values.forEach((function(e){return n.push(e)}))}d&&(r+=" AS "+this._formatFieldAlias(d))}}catch(e){o=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(o)throw a}}return{text:r.length>0?"RETURNING "+r:"",values:n}}}]),r}(r.Block),r.WithBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._tables=[],t}return i(r,e),t(r,[{key:"with",value:function(e,t){this._tables.push({alias:e,table:t})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._tables[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.alias,l=u.table._toParamString({buildParameterized:e.buildParameterized,nested:!0});t.push(c+" AS "+l.text),l.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return{text:t.length?"WITH "+t.join(", "):"",values:r}}}]),r}(r.Block),r.DistinctOnBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._distinctFields=[],t}return i(r,e),t(r,[{key:"distinct",value:function(){var e=this;this._useDistinct=!0;for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){e._distinctFields.push(e._sanitizeField(t))}))}},{key:"_toParamString",value:function(){var e="";return this._useDistinct&&(e="DISTINCT",this._distinctFields.length&&(e+=" ON ("+this._distinctFields.join(", ")+")")),{text:e,values:[]}}}]),r}(r.Block),r.Select=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"SELECT"),new r.FunctionBlock(e),new r.DistinctOnBlock(e),new r.GetFieldBlock(e),new r.FromTableBlock(e),new r.JoinBlock(e),new r.WhereBlock(e),new r.GroupByBlock(e),new r.HavingBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.OffsetBlock(e),new r.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.PostgresOnConflictKeyUpdateBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Update=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"UPDATE"),new r.UpdateTableBlock(e),new r.SetFieldBlock(e),new r.FromTableBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Delete=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"DELETE"),new r.TargetTableBlock(e),new r.FromTableBlock(a({},e,{singleTable:!0})),new r.JoinBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder)},p}();var v=p(m.exports);function y(e,t){!function(e,t){e.exec(`\n create table if not exists 'chat_logs_${t}' (\n 'client_msg_id' char(32),\n 'server_msg_id' char(32),\n 'send_id' char(32),\n 'recv_id' char(32),\n 'sender_platform_id' smallint,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'sender_face_background_color' varchar(255),\n 'session_type' smallint,\n 'msg_from' smallint,\n 'content_type' smallint,\n 'content' varchar(1000),\n 'is_read' tinyint(1),\n 'status' smallint,\n 'seq' int DEFAULT 0,\n 'send_time' int,\n 'create_time' int,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'local_ex' varchar(1024),\n 'is_react' tinyint(1),\n 'is_external_extensions' tinyint(1),\n 'msg_first_modify_time' int,\n PRIMARY KEY ('client_msg_id')\n );\n `)}(e,t)}function b(e){return e.exec("\n select * from local_super_groups;\n ")}function w(e,t){const r=v.insert().into("local_friends").setFields(t).toString();return e.exec(r)}function E(e,t){const r=v.insert().into("local_groups").setFields(t).toString();return e.exec(r)}function O(e){return e.exec("\n SELECT * FROM local_groups\n ")}function S(e,t,r){return e.exec(`INSERT INTO local_notification_seqs (conversation_id, seq) VALUES ("${t}", ${r});`)}function k(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_stranger\n WHERE user_id = (${r.join(",")})\n `)}function R(e){return e.exec("\n SELECT * FROM local_app_sdk_version LIMIT 1\n ")}function N(e,t,r){return e.exec(`\n SELECT * FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}"\n `)}function M(e,t,r){let n=e;return"object"==typeof e&&(n=JSON.stringify(e)),{data:void 0!==e?n:"{}",errCode:t||0,errMsg:r||""}}const x=[["user_id","userID"],["group_id","groupID"],["client_msg_id","clientMsgID"],["server_msg_id","serverMsgID"],["send_id","sendID"],["recv_id","recvID"],["sender_platform_id","senderPlatformID"],["sender_nick_name","senderNickname"],["sender_face_url","senderFaceURL"],["sender_facebackground_color","senderFaceBackgroundColor"],["session_type","sessionType"],["msg_from","msgFrom"],["content_type","contentType"],["content","content"],["is_read","isRead"],["is_react","isReact"],["is_external_extensions","isExternalExtensions"],["msg_first_modify_time","msgFirstModifyTime"],["status","status"],["seq","seq"],["send_time","sendTime"],["create_time","createTime"],["attached_info","attachedInfo"],["ex","ex"],["face_url","faceURL"],["face_background_color","faceBackgroundColor"],["creator_user_id","creatorUserID"],["conversation_id","conversationID"],["owner_user_id","ownerUserID"],["notification_user_id","notificationUserID"],["operator_user_id","operatorUserID"],["from_face_url","fromFaceURL"],["from_user_id","fromUserID"],["from_gender","fromGender"],["from_nickname","fromNickname"],["to_user_id","toUserID"],["to_nickname","toNickname"],["to_face_url","toFaceURL"],["to_gender","toGender"],["req_msg","reqMsg"],["handle_msg","handleMsg"],["handle_time","handleTime"],["handle_result","handleResult"],["handler_user_id","handlerUserID"],["handle_user_id","handleUserID"],["inviter_user_id","inviterUserID"],["mute_end_time","muteEndTime"],["role_level","roleLevel"],["join_time","joinTime"],["join_source","joinSource"],["friend_user_id","friendUserID"],["recv_msg_opt","recvMsgOpt"],["group_at_type","groupAtType"],["latest_msg_send_time","latestMsgSendTime"],["draft_text_time","draftTextTime"],["is_private_chat","isPrivateChat"],["is_not_in_group","isNotInGroup"],["update_unread_count_time","updateUnreadCountTime"],["is_msg_destruct","isMsgDestruct"],["msg_destruct_time","msgDestructTime"],["part_hash","partHash"],["upload_id","uploadID"],["upload_info","uploadInfo"],["expire_time","expireTime"],["entity_id","entityID"],["version_id","versionID"],["display_is_read","displayIsRead"]];function A(e){const t=function(e){const t=x.find((t=>t[0]===e));if(t)return t[1]}(e);if(t)return t;const r=[];let n=-2;for(let t=0;t<e.length;t++){const i=e[t];"_"===i&&t<e.length-1?n=t:t-1===n?r.push(i.toUpperCase()):r.push(i)}return r.join("")}function I(e){const t=function(e){const t=x.find((t=>t[1]===e));if(t)return t[0]}(e);if(t)return t;const r=[];for(let t=0;t<e.length;t++){const n=e[t];n.toLowerCase()!==n&&r.push("_"),r.push(n.toLowerCase())}return r.join("")}const T=/[\0\b\t\n\r\x1a"'\\]/g,C={"\0":"\\0","\b":"\\b","\t":"\\t","\n":"\\n","\r":"\\r","":"\\Z",'"':'\\"',"'":"\\'","\\":"\\\\"};function F(e,t="CamelCase",r=[],n={}){const{columns:i=[],values:o=[]}=e||{},s=[];return o.forEach((e=>{const o={};i.forEach(((i,s)=>{let a=i,u=e[s];"CamelCase"===t&&(a=A(i)),"SnakeCase"===t&&(a=I(i)),r.find((e=>e===a))&&(u=!!u),a=n[i]||a,o[a]=u})),s.push(o)})),s}function B(e,t=!0){const r={};return Object.keys(e).forEach((n=>{let i=e[n];t&&function(e){return"string"==typeof e}(i)&&(i=function(e,t={backslashSupported:!1}){if(null==e)throw new Error("Need to pass a valid string");if(!(t=t||{}).backslashSupported)return"'"+e.replace(/'/g,"''")+"'";const r=T,n=C;let i,o=r.lastIndex=0,s="";for(;i=r.exec(e);)s+=e.slice(o,i.index)+n[i[0]],o=r.lastIndex;return 0===o?"'"+e+"'":o<e.length?"'"+s+e.slice(o)+"'":"'"+s+"'"}(i).slice(1,-1)),r[I(n)]=i})),r}function P(e,t={}){const r={};return Object.keys(e).forEach((n=>{const i=t[n]||n;r[i]=e[n]})),r}var D="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function $(){throw new Error("setTimeout has not been defined")}function L(){throw new Error("clearTimeout has not been defined")}var U=$,q=L;function j(e){if(U===setTimeout)return setTimeout(e,0);if((U===$||!U)&&setTimeout)return U=setTimeout,setTimeout(e,0);try{return U(e,0)}catch(t){try{return U.call(null,e,0)}catch(t){return U.call(this,e,0)}}}"function"==typeof D.setTimeout&&(U=setTimeout),"function"==typeof D.clearTimeout&&(q=clearTimeout);var J,z=[],W=!1,H=-1;function G(){W&&J&&(W=!1,J.length?z=J.concat(z):H=-1,z.length&&Y())}function Y(){if(!W){var e=j(G);W=!0;for(var t=z.length;t;){for(J=z,z=[];++H<t;)J&&J[H].run();H=-1,t=z.length}J=null,W=!1,function(e){if(q===clearTimeout)return clearTimeout(e);if((q===L||!q)&&clearTimeout)return q=clearTimeout,clearTimeout(e);try{return q(e)}catch(t){try{return q.call(null,e)}catch(t){return q.call(this,e)}}}(e)}}function V(e,t){this.fun=e,this.array=t}V.prototype.run=function(){this.fun.apply(null,this.array)};function Q(){}var K=Q,X=Q,Z=Q,ee=Q,te=Q,re=Q,ne=Q;var ie=D.performance||{},oe=ie.now||ie.mozNow||ie.msNow||ie.oNow||ie.webkitNow||function(){return(new Date).getTime()};var se=new Date;var ae={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];z.push(new V(e,t)),1!==z.length||W||j(Y)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:K,addListener:X,once:Z,off:ee,removeListener:te,removeAllListeners:re,emit:ne,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*oe.call(ie),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-se)/1e3}},ue=[],ce=[],le="undefined"!=typeof Uint8Array?Uint8Array:Array,fe=!1;function de(){fe=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)ue[t]=e[t],ce[e.charCodeAt(t)]=t;ce["-".charCodeAt(0)]=62,ce["_".charCodeAt(0)]=63}function he(e,t,r){for(var n,i,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(ue[(i=n)>>18&63]+ue[i>>12&63]+ue[i>>6&63]+ue[63&i]);return o.join("")}function _e(e){var t;fe||de();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;a<u;a+=s)o.push(he(e,a,a+s>u?u:a+s));return 1===n?(t=e[r-1],i+=ue[t>>2],i+=ue[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ue[t>>10],i+=ue[t>>4&63],i+=ue[t<<2&63],i+="="),o.push(i),o.join("")}function pe(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?i-1:0,d=r?-1:1,h=e[t+f];for(f+=d,o=h&(1<<-l)-1,h>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=d,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=c}return(h?-1:1)*s*Math.pow(2,o-n)}function ge(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,_=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=_,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+h]=255&s,h+=_,s/=256,c-=8);e[r+h-_]|=128*p}var me={}.toString,ve=Array.isArray||function(e){return"[object Array]"==me.call(e)};function ye(){return we.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function be(e,t){if(ye()<t)throw new RangeError("Invalid typed array length");return we.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=we.prototype:(null===e&&(e=new we(t)),e.length=t),e}function we(e,t,r){if(!(we.TYPED_ARRAY_SUPPORT||this instanceof we))return new we(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Se(this,e)}return Ee(this,e,t,r)}function Ee(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);we.TYPED_ARRAY_SUPPORT?(e=t).__proto__=we.prototype:e=ke(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!we.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Me(t,r);e=be(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Ne(t)){var r=0|Re(t.length);return 0===(e=be(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?be(e,0):ke(e,t);if("Buffer"===t.type&&ve(t.data))return ke(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Oe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Se(e,t){if(Oe(t),e=be(e,t<0?0:0|Re(t)),!we.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function ke(e,t){var r=t.length<0?0:0|Re(t.length);e=be(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Re(e){if(e>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ne(e){return!(null==e||!e._isBuffer)}function Me(e,t){if(Ne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return rt(e).length;default:if(n)return tt(e).length;t=(""+t).toLowerCase(),n=!0}}function xe(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,r);case"utf8":case"utf-8":return Ue(this,t,r);case"ascii":return je(this,t,r);case"latin1":case"binary":return Je(this,t,r);case"base64":return Le(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return We(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Ae(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Ie(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=we.from(t,n)),Ne(t))return 0===t.length?-1:Te(e,t,r,n,i);if("number"==typeof t)return t&=255,we.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Te(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Te(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var f=!0,d=0;d<u;d++)if(c(e,o+d)!==c(t,d)){f=!1;break}if(f)return o}return-1}function Ce(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function Fe(e,t,r,n){return nt(tt(t,e.length-r),e,r,n)}function Be(e,t,r,n){return nt(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function Pe(e,t,r,n){return Be(e,t,r,n)}function De(e,t,r,n){return nt(rt(t),e,r,n)}function $e(e,t,r,n){return nt(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function Le(e,t,r){return 0===t&&r===e.length?_e(e):_e(e.slice(t,r))}function Ue(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],l=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=qe)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=qe));return r}(n)}we.TYPED_ARRAY_SUPPORT=void 0===D.TYPED_ARRAY_SUPPORT||D.TYPED_ARRAY_SUPPORT,ye(),we.poolSize=8192,we._augment=function(e){return e.__proto__=we.prototype,e},we.from=function(e,t,r){return Ee(null,e,t,r)},we.TYPED_ARRAY_SUPPORT&&(we.prototype.__proto__=Uint8Array.prototype,we.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&we[Symbol.species]),we.alloc=function(e,t,r){return function(e,t,r,n){return Oe(t),t<=0?be(e,t):void 0!==r?"string"==typeof n?be(e,t).fill(r,n):be(e,t).fill(r):be(e,t)}(null,e,t,r)},we.allocUnsafe=function(e){return Se(null,e)},we.allocUnsafeSlow=function(e){return Se(null,e)},we.isBuffer=function(e){return null!=e&&(!!e._isBuffer||it(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&it(e.slice(0,0))}(e))},we.compare=function(e,t){if(!Ne(e)||!Ne(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},we.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},we.concat=function(e,t){if(!ve(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return we.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=we.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!Ne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},we.byteLength=Me,we.prototype._isBuffer=!0,we.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Ae(this,t,t+1);return this},we.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Ae(this,t,t+3),Ae(this,t+1,t+2);return this},we.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Ae(this,t,t+7),Ae(this,t+1,t+6),Ae(this,t+2,t+5),Ae(this,t+3,t+4);return this},we.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Ue(this,0,e):xe.apply(this,arguments)},we.prototype.equals=function(e){if(!Ne(e))throw new TypeError("Argument must be a Buffer");return this===e||0===we.compare(this,e)},we.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},we.prototype.compare=function(e,t,r,n,i){if(!Ne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),l=0;l<a;++l)if(u[l]!==c[l]){o=u[l],s=c[l];break}return o<s?-1:s<o?1:0},we.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},we.prototype.indexOf=function(e,t,r){return Ie(this,e,t,r,!0)},we.prototype.lastIndexOf=function(e,t,r){return Ie(this,e,t,r,!1)},we.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ce(this,e,t,r);case"utf8":case"utf-8":return Fe(this,e,t,r);case"ascii":return Be(this,e,t,r);case"latin1":case"binary":return Pe(this,e,t,r);case"base64":return De(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var qe=4096;function je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function Je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function ze(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=et(e[o]);return i}function We(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function He(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,r,n,i,o){if(!Ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function Ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function Ve(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function Qe(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ke(e,t,r,n,i){return i||Qe(e,0,r,4),ge(e,t,r,n,23,4),r+4}function Xe(e,t,r,n,i){return i||Qe(e,0,r,8),ge(e,t,r,n,52,8),r+8}we.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),we.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=we.prototype;else{var i=t-e;r=new we(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},we.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},we.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},we.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},we.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},we.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},we.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},we.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},we.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},we.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},we.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},we.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},we.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},we.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),pe(this,e,!0,23,4)},we.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),pe(this,e,!1,23,4)},we.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),pe(this,e,!0,52,8)},we.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),pe(this,e,!1,52,8)},we.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},we.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},we.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,255,0),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},we.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ve(this,e,t,!0),t+4},we.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,127,-128),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},we.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ve(this,e,t,!0),t+4},we.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeFloatLE=function(e,t,r){return Ke(this,e,t,!0,r)},we.prototype.writeFloatBE=function(e,t,r){return Ke(this,e,t,!1,r)},we.prototype.writeDoubleLE=function(e,t,r){return Xe(this,e,t,!0,r)},we.prototype.writeDoubleBE=function(e,t,r){return Xe(this,e,t,!1,r)},we.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!we.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},we.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!we.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=Ne(e)?e:tt(new we(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var Ze=/[^+\/0-9A-Za-z-_]/g;function et(e){return e<16?"0"+e.toString(16):e.toString(16)}function tt(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function rt(e){return function(e){var t,r,n,i,o,s;fe||de();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new le(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t<n;t+=4,r+=3)i=ce[e.charCodeAt(t)]<<18|ce[e.charCodeAt(t+1)]<<12|ce[e.charCodeAt(t+2)]<<6|ce[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=ce[e.charCodeAt(t)]<<2|ce[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=ce[e.charCodeAt(t)]<<10|ce[e.charCodeAt(t+1)]<<4|ce[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ze,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function nt(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function it(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ot={exports:{}};function st(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var at=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ut=function(e){return at.exec(e).slice(1)};function ct(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function lt(e){var t=ft(e),r="/"===yt(e,-1);return(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function ft(e){return"/"===e.charAt(0)}function dt(){return lt(vt(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function ht(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ct(e).substr(1),t=ct(t).substr(1);for(var n=r(e.split("/")),i=r(t.split("/")),o=Math.min(n.length,i.length),s=o,a=0;a<o;a++)if(n[a]!==i[a]){s=a;break}var u=[];for(a=s;a<n.length;a++)u.push("..");return(u=u.concat(i.slice(s))).join("/")}function _t(e){var t=ut(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."}function pt(e,t){var r=ut(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r}function gt(e){return ut(e)[3]}var mt={extname:gt,basename:pt,dirname:_t,sep:"/",delimiter:":",relative:ht,join:dt,isAbsolute:ft,normalize:lt,resolve:ct};function vt(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var yt="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)},bt=g(Object.freeze({__proto__:null,resolve:ct,normalize:lt,isAbsolute:ft,join:dt,relative:ht,sep:"/",delimiter:":",dirname:_t,basename:pt,extname:gt,default:mt})),wt=g(Object.freeze({__proto__:null,default:{}})),Et=g(Object.freeze({__proto__:null,default:{}}));!function(e,t){var r=void 0,n=function(t){return r||(r=new Promise((function(r,n){var i,o=(i=void 0!==t?t:{}).onAbort;i.onAbort=function(e){n(new Error(e)),o&&o(e)},i.postRun=i.postRun||[],i.postRun.push((function(){r(i)})),e=void 0,i||(i=void 0!==i?i:{}),i.onRuntimeInitialized=function(){function e(e,t){this.Qa=e,this.db=t,this.Pa=1,this.wb=[]}function t(e,t){if(this.db=t,t=J(e)+1,this.hb=Ue(t),null===this.hb)throw Error("Unable to allocate memory for the SQL string");j(e,F,this.hb,t),this.sb=this.hb,this.eb=this.Mb=null}function r(e,{filename:t=!1}={}){!1===t?(this.filename="dbfile_"+(4294967295*Math.random()>>>0),this.Xc=!0,null!=e&&Re.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(s(this.filename,n)),this.db=R(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Ye(4),o=i.cwrap,s=o("sqlite3_open","number",["string","number"]),a=o("sqlite3_close_v2","number",["number"]),u=o("sqlite3_exec","number",["number","string","number","number","number"]),c=o("sqlite3_changes","number",["number"]),l=o("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=o("sqlite3_sql","string",["number"]),d=o("sqlite3_normalized_sql","string",["number"]),h=o("sqlite3_prepare_v2","number",["number","number","number","number","number"]),_=o("sqlite3_bind_text","number",["number","number","number","number","number"]),p=o("sqlite3_bind_blob","number",["number","number","number","number","number"]),g=o("sqlite3_bind_double","number",["number","number","number"]),m=o("sqlite3_bind_int","number",["number","number","number"]),v=o("sqlite3_bind_parameter_index","number",["number","string"]),y=o("sqlite3_step","number",["number"]),b=o("sqlite3_errmsg","string",["number"]),w=o("sqlite3_column_count","number",["number"]),E=o("sqlite3_data_count","number",["number"]),N=o("sqlite3_column_double","number",["number","number"]),M=o("sqlite3_column_text","string",["number","number"]),x=o("sqlite3_column_blob","number",["number","number"]),A=o("sqlite3_column_bytes","number",["number","number"]),T=o("sqlite3_column_type","number",["number","number"]),B=o("sqlite3_column_name","string",["number","number"]),P=o("sqlite3_reset","number",["number"]),D=o("sqlite3_clear_bindings","number",["number"]),$=o("sqlite3_finalize","number",["number"]),L=o("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),U=o("sqlite3_value_type","number",["number"]),z=o("sqlite3_value_bytes","number",["number"]),W=o("sqlite3_value_text","string",["number"]),H=o("sqlite3_value_blob","number",["number"]),G=o("sqlite3_value_double","number",["number"]),Y=o("sqlite3_result_double","",["number","number"]),V=o("sqlite3_result_null","",["number"]),Q=o("sqlite3_result_text","",["number","string","number","number"]),K=o("sqlite3_result_blob","",["number","number","number","number"]),X=o("sqlite3_result_int","",["number","number"]),Z=o("sqlite3_result_error","",["number","string","number"]),ee=o("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=y(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),N(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),M(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=A(this.Qa,e);e=x(this.Qa,e);for(var r=new Uint8Array(t),n=0;n<t;n+=1)r[n]=C[e+n];return r},e.prototype.get=function(e){null!=e&&this.bind(e)&&this.step(),e=[];for(var t=E(this.Qa),r=0;r<t;r+=1)switch(T(this.Qa,r)){case 1:case 2:e.push(this.Pc(r));break;case 3:e.push(this.Qc(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},e.prototype.getColumnNames=function(){for(var e=[],t=w(this.Qa),r=0;r<t;r+=1)e.push(B(this.Qa,r));return e},e.prototype.getAsObject=function(e){e=this.get(e);for(var t=this.getColumnNames(),r={},n=0;n<t.length;n+=1)r[t[n]]=e[n];return r},e.prototype.getSQL=function(){return f(this.Qa)},e.prototype.getNormalizedSQL=function(){return d(this.Qa)},e.prototype.run=function(e){return null!=e&&this.bind(e),this.step(),this.reset()},e.prototype.zc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1);var r=I(e=De(e));this.wb.push(r),this.db.handleError(_(this.Qa,t,r,e.length-1,0))},e.prototype.uc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1);var r=I(e);this.wb.push(r),this.db.handleError(p(this.Qa,t,r,e.length,0))},e.prototype.yc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1),this.db.handleError((e===(0|e)?m:g)(this.Qa,t,e))},e.prototype.xc=function(e){null==e&&(e=this.Pa,this.Pa+=1),p(this.Qa,e,0,0,0)},e.prototype.Tb=function(e,t){switch(null==t&&(t=this.Pa,this.Pa+=1),typeof e){case"string":return void this.zc(e,t);case"number":case"boolean":return void this.yc(e+0,t);case"object":if(null===e)return void this.xc(t);if(null!=e.length)return void this.uc(e,t)}throw"Wrong API use : tried to bind a value of an unknown type ("+e+")."},e.prototype.wc=function(e){var t=this;return Object.keys(e).forEach((function(r){var n=v(t.Qa,r);0!==n&&t.Tb(e[r],n)})),!0},e.prototype.vc=function(e){for(var t=0;t<e.length;t+=1)this.Tb(e[t],t+1);return!0},e.prototype.reset=function(){return 0===D(this.Qa)&&0===P(this.Qa)},e.prototype.freemem=function(){for(var e;void 0!==(e=this.wb.pop());)qe(e)},e.prototype.free=function(){var e=0===$(this.Qa);return delete this.db.nb[this.Qa],this.Qa=0,e},t.prototype.next=function(){if(null===this.hb)return{done:!0};if(null!==this.eb&&(this.eb.free(),this.eb=null),!this.db.db)throw this.Bb(),Error("Database closed");var t=He(),r=Ye(4);k(n),k(r);try{this.db.handleError(h(this.db.db,this.sb,-1,n,r)),this.sb=R(r,"i32");var i=R(n,"i32");return 0===i?(this.Bb(),{done:!0}):(this.eb=new e(i,this.db),this.db.nb[i]=this.eb,{value:this.eb,done:!1})}catch(e){throw this.Mb=q(this.sb),this.Bb(),e}finally{Ge(t)}},t.prototype.Bb=function(){qe(this.hb),this.hb=null},t.prototype.getRemainingSQL=function(){return null!==this.Mb?this.Mb:q(this.sb)},"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t.prototype[Symbol.iterator]=function(){return this}),r.prototype.run=function(e,t){if(!this.db)throw"Database closed";if(t){e=this.prepare(e,t);try{e.step()}finally{e.free()}}else this.handleError(u(this.db,e,0,0,n));return this},r.prototype.exec=function(t,r){if(!this.db)throw"Database closed";var i=He(),o=null;try{var s=J(t)+1,a=Ye(s);j(t,C,a,s);var u=a,c=Ye(4);for(t=[];0!==R(u,"i8");){k(n),k(c),this.handleError(h(this.db,u,-1,n,c));var l=R(n,"i32");if(u=R(c,"i32"),0!==l){for(s=null,o=new e(l,this),null!=r&&o.bind(r);o.step();)null===s&&(s={columns:o.getColumnNames(),values:[]},t.push(s)),s.values.push(o.get());o.free()}}return t}catch(e){throw o&&o.free(),e}finally{Ge(i)}},r.prototype.each=function(e,t,r,n){"function"==typeof t&&(n=r,r=t,t=void 0),e=this.prepare(e,t);try{for(;e.step();)r(e.getAsObject())}finally{e.free()}if("function"==typeof n)return n()},r.prototype.prepare=function(t,r){if(k(n),this.handleError(l(this.db,t,-1,n,0)),0===(t=R(n,"i32")))throw"Nothing to prepare";var i=new e(t,this);return null!=r&&i.bind(r),this.nb[t]=i},r.prototype.iterateStatements=function(e){return new t(e,this)},r.prototype.export=function(){Object.values(this.nb).forEach((function(e){e.free()})),Object.values(this.Xa).forEach(O),this.Xa={},this.handleError(a(this.db));var e=Re.readFile(this.filename,{encoding:"binary"});return this.handleError(s(this.filename,n)),this.db=R(n,"i32"),e},r.prototype.close=function(){null!==this.db&&(Object.values(this.nb).forEach((function(e){e.free()})),Object.values(this.Xa).forEach(O),this.Xa={},this.handleError(a(this.db)),this.Xc&&Re.unlink("/"+this.filename),this.db=null)},r.prototype.handleError=function(e){if(0===e)return null;throw e=b(this.db),Error(e)},r.prototype.getRowsModified=function(){return c(this.db)},r.prototype.create_function=function(e,t){Object.prototype.hasOwnProperty.call(this.Xa,e)&&(O(this.Xa[e]),delete this.Xa[e]);var r=S((function(e,r,n){for(var i,o=[],s=0;s<r;s+=1){var a=R(n+4*s,"i32"),u=U(a);if(1===u||2===u)a=G(a);else if(3===u)a=W(a);else if(4===u){a=z(u=a),u=H(u);for(var c=new Uint8Array(a),l=0;l<a;l+=1)c[l]=C[u+l];a=c}else a=null;o.push(a)}try{i=t.apply(null,o)}catch(t){return void Z(e,t,-1)}switch(typeof i){case"boolean":X(e,i?1:0);break;case"number":Y(e,i);break;case"string":Q(e,i,-1,-1);break;case"object":null===i?V(e):null!=i.length?(r=I(i),K(e,r,i.length,-1),qe(r)):Z(e,"Wrong API use : tried to return a value of an unknown type ("+i+").",-1);break;default:V(e)}}),"viii");return this.Xa[e]=r,this.handleError(L(this.db,e,t.length,1,0,r,0,0,0)),this},i.Database=r;var te=new Map;i.register_for_idb=e=>{let t=S((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=S((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=S((function(e,t){e=q(e),te.set(t,e)}),"vii");i._register_for_idb(t,r,n)},i.cleanup_file=e=>{let t=[...te.entries()].find((t=>t[1]===e));te.delete(t[0])},i.reset_filesystem=()=>{Re.root=null,Re.lc()}};var s,a={};for(s in i)i.hasOwnProperty(s)&&(a[s]=i[s]);var u,c,l,f,d,h="./this.program",_="object"==typeof window,p="function"==typeof importScripts,g="object"==typeof ae&&"object"==typeof ae.versions&&"string"==typeof ae.versions.node,m="";g?(m=p?bt.dirname(m)+"/":"/Users/mac/Documents/cid/sdk/openim-sdk-js-wasm/node_modules/@jlongster/sql.js/dist/",u=function(e,t){return f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFileSync(e,t?null:"utf8")},l=function(e){return(e=u(e,!0)).buffer||(e=new Uint8Array(e)),x(e.buffer),e},c=function(e,t,r){f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFile(e,(function(e,n){e?r(e):t(n.buffer)}))},1<ae.argv.length&&(h=ae.argv[1].replace(/\\/g,"/")),ae.argv.slice(2),e.exports=i,i.inspect=function(){return"[Emscripten Module object]"}):(_||p)&&(p?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),m=0!==m.indexOf("blob:")?m.substr(0,m.lastIndexOf("/")+1):"",u=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},p&&(l=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),c=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var v=i.print||console.log.bind(console),y=i.printErr||console.warn.bind(console);for(s in a)a.hasOwnProperty(s)&&(i[s]=a[s]);a=null,i.thisProgram&&(h=i.thisProgram);var b,w,E=[];function O(e){b.delete(H.get(e)),E.push(e)}function S(e,t){if(!b){b=new WeakMap;for(var r=0;r<H.length;r++){var n=H.get(r);n&&b.set(n,r)}}if(b.has(e))e=b.get(e);else{if(E.length)r=E.pop();else{try{H.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}r=H.length-1}try{H.set(r,e)}catch(a){if(!(a instanceof TypeError))throw a;if("function"==typeof WebAssembly.Function){var i={i:"i32",j:"i64",f:"f32",d:"f64"},o={parameters:[],results:"v"==t[0]?[]:[i[t[0]]]};for(n=1;n<t.length;++n)o.parameters.push(i[t[n]]);t=new WebAssembly.Function(o,e)}else{i=[1,0,1,96],o=t.slice(0,1),t=t.slice(1);var s={i:127,j:126,f:125,d:124};for(i.push(t.length),n=0;n<t.length;++n)i.push(s[t[n]]);"v"==o?i.push(0):i=i.concat([1,s[o]]),i[1]=i.length-2,t=new Uint8Array([0,97,115,109,1,0,0,0].concat(i,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),t=new WebAssembly.Module(t),t=new WebAssembly.Instance(t,{e:{f:e}}).exports.f}H.set(r,t)}b.set(e,r),e=r}return e}function k(e){var t="i32";switch("*"===t.charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":C[e>>0]=0;break;case"i16":B[e>>1]=0;break;case"i32":P[e>>2]=0;break;case"i64":Z=[0,(X=0,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[e>>2]=Z[0],P[e+4>>2]=Z[1];break;case"float":D[e>>2]=0;break;case"double":$[e>>3]=0;break;default:oe("invalid type for setValue: "+t)}}function R(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return C[e>>0];case"i16":return B[e>>1];case"i32":case"i64":return P[e>>2];case"float":return D[e>>2];case"double":return $[e>>3];default:oe("invalid type for getValue: "+t)}return null}i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&oe("no native wasm support detected");var N,M=!1;function x(e,t){e||oe("Assertion failed: "+t)}function A(e){var t=i["_"+e];return x(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function I(e){var t=Ue(e.length);return e.subarray||e.slice?F.set(e,t):F.set(new Uint8Array(e),t),t}var T,C,F,B,P,D,$,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,r){var n=t+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.subarray&&L)return L.decode(e.subarray(t,r));for(n="";t<r;){var i=e[t++];if(128&i){var o=63&e[t++];if(192==(224&i))n+=String.fromCharCode((31&i)<<6|o);else{var s=63&e[t++];65536>(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function q(e,t){return e?U(F,e,t):""}function j(e,t,r,n){if(!(0<n))return 0;var i=r;n=r+n-1;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(127>=s){if(r>=n)break;t[r++]=s}else{if(2047>=s){if(r+1>=n)break;t[r++]=192|s>>6}else{if(65535>=s){if(r+2>=n)break;t[r++]=224|s>>12}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63}t[r++]=128|s>>6&63}t[r++]=128|63&s}}return t[r]=0,r-i}function J(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&57343>=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function z(e){var t=J(e)+1,r=Ue(t);return r&&j(e,C,r,t),r}function W(){var e=N.buffer;T=e,i.HEAP8=C=new Int8Array(e),i.HEAP16=B=new Int16Array(e),i.HEAP32=P=new Int32Array(e),i.HEAPU8=F=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=D=new Float32Array(e),i.HEAPF64=$=new Float64Array(e)}var H,G=[],Y=[],V=[];function Q(){var e=i.preRun.shift();G.unshift(e)}var K,X,Z,ee,te=0,re=null;function ne(){te++,i.monitorRunDependencies&&i.monitorRunDependencies(te)}function ie(){if(te--,i.monitorRunDependencies&&i.monitorRunDependencies(te),0==te&&re){var e=re;re=null,e()}}function oe(e){throw i.onAbort&&i.onAbort(e),y(e),M=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function se(){return K.startsWith("data:application/octet-stream;base64,")}if(i.preloadedImages={},i.preloadedAudios={},K="sql-wasm.wasm",!se()){var ue=K;K=i.locateFile?i.locateFile(ue,m):m+ue}function ce(){var e=K;try{if(e==K&&w)return new Uint8Array(w);if(l)return l(e);throw"both async and sync fetching of the wasm failed"}catch(e){oe(e)}}function le(e){for(;0<e.length;){var t=e.shift();if("function"==typeof t)t(i);else{var r=t.pd;"number"==typeof r?void 0===t.yb?H.get(r)():H.get(r)(t.yb):r(void 0===t.yb?null:t.yb)}}}function fe(e,t){for(var r=0,n=e.length-1;0<=n;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e}function de(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=fe(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function he(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function _e(e){if("/"===e)return"/";var t=(e=(e=de(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)}function pe(e,t){return de(e+"/"+t)}function ge(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:Re.cwd()))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=fe(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."}function me(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;0<=r&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ge(e).substr(1),t=ge(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o<n;o++)if(e[o]!==t[o]){i=o;break}for(n=[],o=i;o<e.length;o++)n.push("..");return(n=n.concat(t.slice(i))).join("/")}var ve=[];function ye(e,t){ve[e]={input:[],output:[],gb:t},Re.Qb(e,be)}var be={open:function(e){var t=ve[e.node.rdev];if(!t)throw new Re.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.gb.flush(e.tty)},flush:function(e){e.tty.gb.flush(e.tty)},read:function(e,t,r,n){if(!e.tty||!e.tty.gb.cc)throw new Re.ErrnoError(60);for(var i=0,o=0;o<n;o++){try{var s=e.tty.gb.cc(e.tty)}catch(e){throw new Re.ErrnoError(29)}if(void 0===s&&0===i)throw new Re.ErrnoError(6);if(null==s)break;i++,t[r+o]=s}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,r,n){if(!e.tty||!e.tty.gb.Nb)throw new Re.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.gb.Nb(e.tty,t[r+i])}catch(e){throw new Re.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},Ee={cc:function(e){if(!e.input.length){var t=null;if(g){var r=we.alloc(256),n=0;try{n=f.readSync(ae.stdin.fd,r,0,256,null)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}t=0<n?r.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&(null!==(t=readline())&&(t+="\n"));if(!t)return null;e.input=De(t,!0)}return e.input.shift()},Nb:function(e,t){null===t||10===t?(v(U(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(v(U(e.output,0)),e.output=[])}},Oe={Nb:function(e,t){null===t||10===t?(y(U(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(y(U(e.output,0)),e.output=[])}};function Se(e){e=65536*Math.ceil(e/65536);var t=Ve(65536,e);return t?(F.fill(0,t,t+e),t):0}var ke={Va:null,mount:function(){return ke.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(Re.Rc(r)||Re.isFIFO(r))throw new Re.ErrnoError(63);return ke.Va||(ke.Va={dir:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr,lookup:ke.node_ops.lookup,mknod:ke.node_ops.mknod,rename:ke.node_ops.rename,unlink:ke.node_ops.unlink,rmdir:ke.node_ops.rmdir,readdir:ke.node_ops.readdir,symlink:ke.node_ops.symlink},stream:{llseek:ke.stream_ops.llseek}},file:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr},stream:{llseek:ke.stream_ops.llseek,read:ke.stream_ops.read,write:ke.stream_ops.write,allocate:ke.stream_ops.allocate,mmap:ke.stream_ops.mmap,msync:ke.stream_ops.msync}},link:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr,readlink:ke.node_ops.readlink},stream:{}},Vb:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr},stream:Re.Cc}}),r=Re.createNode(e,t,r,n),Re.isDir(r.mode)?(r.node_ops=ke.Va.dir.node,r.stream_ops=ke.Va.dir.stream,r.Na={}):Re.isFile(r.mode)?(r.node_ops=ke.Va.file.node,r.stream_ops=ke.Va.file.stream,r.Ra=0,r.Na=null):Re.fb(r.mode)?(r.node_ops=ke.Va.link.node,r.stream_ops=ke.Va.link.stream):Re.pb(r.mode)&&(r.node_ops=ke.Va.Vb.node,r.stream_ops=ke.Va.Vb.stream),r.timestamp=Date.now(),e&&(e.Na[t]=r,e.timestamp=r.timestamp),r},qd:function(e){return e.Na?e.Na.subarray?e.Na.subarray(0,e.Ra):new Uint8Array(e.Na):new Uint8Array(0)},Zb:function(e,t){var r=e.Na?e.Na.length:0;r>=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0<e.Ra&&e.Na.set(r.subarray(0,e.Ra),0))},gd:function(e,t){if(e.Ra!=t)if(0==t)e.Na=null,e.Ra=0;else{var r=e.Na;e.Na=new Uint8Array(t),r&&e.Na.set(r.subarray(0,Math.min(t,e.Ra))),e.Ra=t}},node_ops:{getattr:function(e){var t={};return t.dev=Re.pb(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,Re.isDir(e.mode)?t.size=4096:Re.isFile(e.mode)?t.size=e.Ra:Re.fb(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.Ac=4096,t.blocks=Math.ceil(t.size/t.Ac),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ke.gd(e,t.size)},lookup:function(){throw Re.Db[44]},mknod:function(e,t,r,n){return ke.createNode(e,t,r,n)},rename:function(e,t,r){if(Re.isDir(e.mode)){try{var n=Re.lookupNode(t,r)}catch(e){}if(n)for(var i in n.Na)throw new Re.ErrnoError(55)}delete e.parent.Na[e.name],e.parent.timestamp=Date.now(),e.name=r,t.Na[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.Na[t],e.timestamp=Date.now()},rmdir:function(e,t){var r,n=Re.lookupNode(e,t);for(r in n.Na)throw new Re.ErrnoError(55);delete e.Na[t],e.timestamp=Date.now()},readdir:function(e){var t,r=[".",".."];for(t in e.Na)e.Na.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,t,r){return(e=ke.createNode(e,t,41471,0)).link=r,e},readlink:function(e){if(!Re.fb(e.mode))throw new Re.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,n,i){var o=e.node.Na;if(i>=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;n<e;n++)t[r+n]=o[i+n];return e},write:function(e,t,r,n,i,o){if(t.buffer===C.buffer&&(o=!1),!n)return 0;if((e=e.node).timestamp=Date.now(),t.subarray&&(!e.Na||e.Na.subarray)){if(o)return e.Na=t.subarray(r,r+n),e.Ra=n;if(0===e.Ra&&0===i)return e.Na=t.slice(r,r+n),e.Ra=n;if(i+n<=e.Ra)return e.Na.set(t.subarray(r,r+n),i),n}if(ke.Zb(e,i+n),e.Na.subarray&&t.subarray)e.Na.set(t.subarray(r,r+n),i);else for(o=0;o<n;o++)e.Na[i+o]=t[r+o];return e.Ra=Math.max(e.Ra,i+n),n},llseek:function(e,t,r){if(1===r?t+=e.position:2===r&&Re.isFile(e.node.mode)&&(t+=e.node.Ra),0>t)throw new Re.ErrnoError(28);return t},allocate:function(e,t,r){ke.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new Re.ErrnoError(28);if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==T){if((0<n||n+r<e.length)&&(e=e.subarray?e.subarray(n,n+r):Array.prototype.slice.call(e,n,n+r)),n=!0,!(r=Se(r)))throw new Re.ErrnoError(48);C.set(e,r)}else n=!1,r=e.byteOffset;return{ed:r,vb:n}},msync:function(e,t,r,n,i){if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);return 2&i||ke.stream_ops.write(e,t,0,n,r,!1),0}}};var Re={root:null,mb:[],Xb:{},streams:[],Zc:1,Ua:null,Wb:"/",Hb:!1,hc:!0,Sa:{},nc:{kc:{qc:1,rc:2}},ErrnoError:null,Db:{},Lc:null,tb:0,lookupPath:function(e,t){if(t=t||{},!(e=ge(Re.cwd(),e)))return{path:"",node:null};var r,n={Cb:!0,Pb:0};for(r in n)void 0===t[r]&&(t[r]=n[r]);if(8<t.Pb)throw new Re.ErrnoError(32);e=fe(e.split("/").filter((function(e){return!!e})),!1);var i=Re.root;for(n="/",r=0;r<e.length;r++){var o=r===e.length-1;if(o&&t.parent)break;if(i=Re.lookupNode(i,e[r]),n=pe(n,e[r]),Re.ab(i)&&(!o||o&&t.Cb)&&(i=i.lb.root),!o||t.Ta)for(o=0;Re.fb(i.mode);)if(i=Re.readlink(n),n=ge(he(n),i),i=Re.lookupPath(n,{Pb:t.Pb}).node,40<o++)throw new Re.ErrnoError(32)}return{path:n,node:i}},Ya:function(e){for(var t;;){if(Re.isRoot(e))return e=e.mount.jc,t?"/"!==e[e.length-1]?e+"/"+t:e+t:e;t=t?e.name+"/"+t:e.name,e=e.parent}},Gb:function(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%Re.Ua.length},ec:function(e){var t=Re.Gb(e.parent.id,e.name);e.cb=Re.Ua[t],Re.Ua[t]=e},fc:function(e){var t=Re.Gb(e.parent.id,e.name);if(Re.Ua[t]===e)Re.Ua[t]=e.cb;else for(t=Re.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=Re.Vc(e);if(r)throw new Re.ErrnoError(r,e);for(r=Re.Ua[Re.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return Re.lookup(e,t)},createNode:function(e,t,r,n){return e=new Re.FSNode(e,t,r,n),Re.ec(e),e},Ab:function(e){Re.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=Re.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return Re.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=Re.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return Re.lookupNode(e,t),20}catch(e){}return Re.Za(e,"wx")},qb:function(e,t,r){try{var n=Re.lookupNode(e,t)}catch(e){return e.Oa}if(e=Re.Za(e,"wx"))return e;if(r){if(!Re.isDir(n.mode))return 54;if(Re.isRoot(n)||Re.Ya(n)===Re.cwd())return 10}else if(Re.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?Re.fb(e.mode)?32:Re.isDir(e.mode)&&("r"!==Re.$b(t)||512&t)?31:Re.Za(e,Re.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||Re.oc,e=e||0;e<=t;e++)if(!Re.streams[e])return e;throw new Re.ErrnoError(33)},$a:function(e){return Re.streams[e]},Jc:function(e,t,r){Re.ub||(Re.ub=function(){},Re.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new Re.ub;for(n in e)i[n]=e[n];return e=i,t=Re.$c(t,r),e.fd=t,Re.streams[t]=e},Dc:function(e){Re.streams[e]=null},Cc:{open:function(e){e.stream_ops=Re.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Re.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){Re.Xb[e]={stream_ops:t}},Oc:function(e){return Re.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return Re.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),Re.tb++,1<Re.tb&&y("warning: "+Re.tb+" FS.syncfs operations in flight at once, probably just doing extra work");var i=Re.bc(Re.root.mount),o=0;i.forEach((function(t){if(!t.type.mc)return n(null);t.type.mc(t,e,n)}))},mount:function(e,t,r){var n="/"===r,i=!r;if(n&&Re.root)throw new Re.ErrnoError(10);if(!n&&!i){var o=Re.lookupPath(r,{Cb:!1});if(r=o.path,o=o.node,Re.ab(o))throw new Re.ErrnoError(10);if(!Re.isDir(o.mode))throw new Re.ErrnoError(54)}return t={type:e,vd:t,jc:r,mb:[]},(e=e.mount(t)).mount=t,t.root=e,n?Re.root=e:o&&(o.lb=t,o.mount&&o.mount.mb.push(t)),e},yd:function(e){if(e=Re.lookupPath(e,{Cb:!1}),!Re.ab(e.node))throw new Re.ErrnoError(28);var t=(e=e.node).lb,r=Re.bc(t);Object.keys(Re.Ua).forEach((function(e){for(e=Re.Ua[e];e;){var t=e.cb;r.includes(e.mount)&&Re.Ab(e),e=t}})),e.lb=null,e.mount.mb.splice(e.mount.mb.indexOf(t),1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=Re.lookupPath(e,{parent:!0}).node;if(!(e=_e(e))||"."===e||".."===e)throw new Re.ErrnoError(28);var i=Re.Lb(n,e);if(i)throw new Re.ErrnoError(i);if(!n.node_ops.mknod)throw new Re.ErrnoError(63);return n.node_ops.mknod(n,e,t,r)},create:function(e,t){return Re.mknod(e,4095&(void 0!==t?t:438)|32768,0)},mkdir:function(e,t){return Re.mknod(e,1023&(void 0!==t?t:511)|16384,0)},td:function(e,t){e=e.split("/");for(var r="",n=0;n<e.length;++n)if(e[n]){r+="/"+e[n];try{Re.mkdir(r,t)}catch(e){if(20!=e.Oa)throw e}}},rb:function(e,t,r){return void 0===r&&(r=t,t=438),Re.mknod(e,8192|t,r)},symlink:function(e,t){if(!ge(e))throw new Re.ErrnoError(44);var r=Re.lookupPath(t,{parent:!0}).node;if(!r)throw new Re.ErrnoError(44);t=_e(t);var n=Re.Lb(r,t);if(n)throw new Re.ErrnoError(n);if(!r.node_ops.symlink)throw new Re.ErrnoError(63);return r.node_ops.symlink(r,t,e)},rename:function(e,t){var r=he(e),n=he(t),i=_e(e),o=_e(t),s=Re.lookupPath(e,{parent:!0}),a=s.node;if(s=(s=Re.lookupPath(t,{parent:!0})).node,!a||!s)throw new Re.ErrnoError(44);if(a.mount!==s.mount)throw new Re.ErrnoError(75);var u=Re.lookupNode(a,i);if("."!==(n=me(e,n)).charAt(0))throw new Re.ErrnoError(28);if("."!==(n=me(t,r)).charAt(0))throw new Re.ErrnoError(55);try{var c=Re.lookupNode(s,o)}catch(e){}if(u!==c){if(r=Re.isDir(u.mode),i=Re.qb(a,i,r))throw new Re.ErrnoError(i);if(i=c?Re.qb(s,o,r):Re.Lb(s,o))throw new Re.ErrnoError(i);if(!a.node_ops.rename)throw new Re.ErrnoError(63);if(Re.ab(u)||c&&Re.ab(c))throw new Re.ErrnoError(10);if(s!==a&&(i=Re.Za(a,"w")))throw new Re.ErrnoError(i);try{Re.Sa.willMovePath&&Re.Sa.willMovePath(e,t)}catch(r){y("FS.trackingDelegate['willMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}Re.fc(u);try{a.node_ops.rename(u,s,o)}catch(e){throw e}finally{Re.ec(u)}try{Re.Sa.onMovePath&&Re.Sa.onMovePath(e,t)}catch(r){y("FS.trackingDelegate['onMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}}},rmdir:function(e){var t=Re.lookupPath(e,{parent:!0}).node,r=_e(e),n=Re.lookupNode(t,r),i=Re.qb(t,r,!0);if(i)throw new Re.ErrnoError(i);if(!t.node_ops.rmdir)throw new Re.ErrnoError(63);if(Re.ab(n))throw new Re.ErrnoError(10);try{Re.Sa.willDeletePath&&Re.Sa.willDeletePath(e)}catch(t){y("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.rmdir(t,r),Re.Ab(n);try{Re.Sa.onDeletePath&&Re.Sa.onDeletePath(e)}catch(t){y("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readdir:function(e){if(!(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.readdir)throw new Re.ErrnoError(54);return e.node_ops.readdir(e)},unlink:function(e){var t=Re.lookupPath(e,{parent:!0}).node,r=_e(e),n=Re.lookupNode(t,r),i=Re.qb(t,r,!1);if(i)throw new Re.ErrnoError(i);if(!t.node_ops.unlink)throw new Re.ErrnoError(63);if(Re.ab(n))throw new Re.ErrnoError(10);try{Re.Sa.willDeletePath&&Re.Sa.willDeletePath(e)}catch(t){y("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.unlink(t,r),Re.Ab(n);try{Re.Sa.onDeletePath&&Re.Sa.onDeletePath(e)}catch(t){y("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readlink:function(e){if(!(e=Re.lookupPath(e).node))throw new Re.ErrnoError(44);if(!e.node_ops.readlink)throw new Re.ErrnoError(28);return ge(Re.Ya(e.parent),e.node_ops.readlink(e))},stat:function(e,t){if(!(e=Re.lookupPath(e,{Ta:!t}).node))throw new Re.ErrnoError(44);if(!e.node_ops.getattr)throw new Re.ErrnoError(63);return e.node_ops.getattr(e)},lstat:function(e){return Re.stat(e,!0)},chmod:function(e,t,r){if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!r}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);e.node_ops.setattr(e,{mode:4095&t|-4096&e.mode,timestamp:Date.now()})},lchmod:function(e,t){Re.chmod(e,t,!0)},fchmod:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);Re.chmod(e.node,t)},chown:function(e,t,r,n){if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!n}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);e.node_ops.setattr(e,{timestamp:Date.now()})},lchown:function(e,t,r){Re.chown(e,t,r,!0)},fchown:function(e,t,r){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);Re.chown(e.node,t,r)},truncate:function(e,t){if(0>t)throw new Re.ErrnoError(28);if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);if(Re.isDir(e.mode))throw new Re.ErrnoError(31);if(!Re.isFile(e.mode))throw new Re.ErrnoError(28);var r=Re.Za(e,"w");if(r)throw new Re.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(28);Re.truncate(e.node,t)},kd:function(e,t,r){(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,o){if(""===e)throw new Re.ErrnoError(44);if(r=64&(t="string"==typeof t?Re.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var s=e;else{e=de(e);try{s=Re.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(s){if(128&t)throw new Re.ErrnoError(20)}else s=Re.mknod(e,r,0),a=!0;if(!s)throw new Re.ErrnoError(44);if(Re.pb(s.mode)&&(t&=-513),65536&t&&!Re.isDir(s.mode))throw new Re.ErrnoError(54);if(!a&&(r=Re.Wc(s,t)))throw new Re.ErrnoError(r);512&t&&Re.truncate(s,0),t&=-131713,(n=Re.Jc({node:s,path:Re.Ya(s),flags:t,seekable:!0,position:0,stream_ops:s.stream_ops,jd:[],error:!1},n,o)).stream_ops.open&&n.stream_ops.open(n),!i.logReadFiles||1&t||(Re.Ob||(Re.Ob={}),e in Re.Ob||(Re.Ob[e]=1,y("FS.trackingDelegate error on read file: "+e)));try{Re.Sa.onOpenFile&&(o=0,1!=(2097155&t)&&(o|=Re.nc.kc.qc),0!=(2097155&t)&&(o|=Re.nc.kc.rc),Re.Sa.onOpenFile(e,o))}catch(t){y("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(Re.kb(e))throw new Re.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Re.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Re.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Re.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(1==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.read)throw new Re.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.write)throw new Re.ErrnoError(28);e.seekable&&1024&e.flags&&Re.llseek(e,0,2);var s=void 0!==i;if(s){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),s||(e.position+=t);try{e.path&&Re.Sa.onWriteToFile&&Re.Sa.onWriteToFile(e.path)}catch(t){y("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(0>t||0>=r)throw new Re.ErrnoError(28);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(!Re.isFile(e.node.mode)&&!Re.isDir(e.node.mode))throw new Re.ErrnoError(43);if(!e.stream_ops.allocate)throw new Re.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new Re.ErrnoError(2);if(1==(2097155&e.flags))throw new Re.ErrnoError(2);if(!e.stream_ops.mmap)throw new Re.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new Re.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=Re.open(e,t.flags);e=Re.stat(e).size;var i=new Uint8Array(e);return Re.read(n,i,0,e,0),"utf8"===t.encoding?r=U(i,0):"binary"===t.encoding&&(r=i),Re.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=Re.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array(J(t)+1);t=j(t,n,0,n.length),Re.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Re.write(e,t,0,t.byteLength,void 0,r.Bc)}Re.close(e)},cwd:function(){return Re.Wb},chdir:function(e){if(null===(e=Re.lookupPath(e,{Ta:!0})).node)throw new Re.ErrnoError(44);if(!Re.isDir(e.node.mode))throw new Re.ErrnoError(54);var t=Re.Za(e.node,"x");if(t)throw new Re.ErrnoError(t);Re.Wb=e.path},Fc:function(){Re.mkdir("/tmp"),Re.mkdir("/home"),Re.mkdir("/home/web_user")},Ec:function(){Re.mkdir("/dev"),Re.Qb(Re.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),Re.rb("/dev/null",Re.bb(1,3)),ye(Re.bb(5,0),Ee),ye(Re.bb(6,0),Oe),Re.rb("/dev/tty",Re.bb(5,0)),Re.rb("/dev/tty1",Re.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(g)try{var t=Et;return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){oe("randomDevice")}}();Re.Wa("/dev","random",e),Re.Wa("/dev","urandom",e),Re.mkdir("/dev/shm"),Re.mkdir("/dev/shm/tmp")},Hc:function(){Re.mkdir("/proc");var e=Re.mkdir("/proc/self");Re.mkdir("/proc/self/fd"),Re.mount({mount:function(){var t=Re.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=Re.$a(+t);if(!r)throw new Re.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){i.stdin?Re.Wa("/dev","stdin",i.stdin):Re.symlink("/dev/tty","/dev/stdin"),i.stdout?Re.Wa("/dev","stdout",null,i.stdout):Re.symlink("/dev/tty","/dev/stdout"),i.stderr?Re.Wa("/dev","stderr",null,i.stderr):Re.symlink("/dev/tty1","/dev/stderr"),Re.open("/dev/stdin",0),Re.open("/dev/stdout",1),Re.open("/dev/stderr",1)},Yb:function(){Re.ErrnoError||(Re.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},Re.ErrnoError.prototype=Error(),Re.ErrnoError.prototype.constructor=Re.ErrnoError,[44].forEach((function(e){Re.Db[e]=new Re.ErrnoError(e),Re.Db[e].stack="<generic error, no stack>"})))},lc:function(){Re.Yb(),Re.Ua=Array(4096),Re.mount(ke,{},"/"),Re.Fc(),Re.Ec(),Re.Hc(),Re.Lc={MEMFS:ke}},jb:function(e,t,r){Re.jb.Hb=!0,Re.Yb(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,Re.Ic()},wd:function(){Re.jb.Hb=!1;var e=i._fflush;for(e&&e(0),e=0;e<Re.streams.length;e++){var t=Re.streams[e];t&&Re.close(t)}},Eb:function(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r},od:function(e,t){return(e=Re.xb(e,t)).exists?e.object:null},xb:function(e,t){try{var r=Re.lookupPath(e,{Ta:!t});e=r.path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,ad:!1,cd:null,bd:null};try{r=Re.lookupPath(e,{parent:!0}),n.ad=!0,n.cd=r.path,n.bd=r.node,n.name=_e(e),r=Re.lookupPath(e,{Ta:!t}),n.exists=!0,n.path=r.path,n.object=r.node,n.name=r.node.name,n.isRoot="/"===r.path}catch(e){n.error=e.Oa}return n},md:function(e,t){for(e="string"==typeof e?e:Re.Ya(e),t=t.split("/").reverse();t.length;){var r=t.pop();if(r){var n=pe(e,r);try{Re.mkdir(n)}catch(e){}e=n}}return n},Gc:function(e,t,r,n,i){return e=pe("string"==typeof e?e:Re.Ya(e),t),Re.create(e,Re.Eb(n,i))},zb:function(e,t,r,n,i,o){if(e=t?pe("string"==typeof e?e:Re.Ya(e),t):e,n=Re.Eb(n,i),i=Re.create(e,n),r){if("string"==typeof r){e=Array(r.length),t=0;for(var s=r.length;t<s;++t)e[t]=r.charCodeAt(t);r=e}Re.chmod(i,146|n),e=Re.open(i,577),Re.write(e,r,0,r.length,0,o),Re.close(e),Re.chmod(i,n)}return i},Wa:function(e,t,r,n){e=pe("string"==typeof e?e:Re.Ya(e),t),t=Re.Eb(!!r,!!n),Re.Wa.Kb||(Re.Wa.Kb=64);var i=Re.bb(Re.Wa.Kb++,0);return Re.Qb(i,{open:function(e){e.seekable=!1},close:function(){n&&n.buffer&&n.buffer.length&&n(10)},read:function(e,t,n,i){for(var o=0,s=0;s<i;s++){try{var a=r()}catch(e){throw new Re.ErrnoError(29)}if(void 0===a&&0===o)throw new Re.ErrnoError(6);if(null==a)break;o++,t[n+s]=a}return o&&(e.node.timestamp=Date.now()),o},write:function(e,t,r,i){for(var o=0;o<i;o++)try{n(t[r+o])}catch(e){throw new Re.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),o}}),Re.rb(e,t,i)},ac:function(e){if(e.Ib||e.Sc||e.link||e.Na)return!0;if("undefined"!=typeof XMLHttpRequest)throw Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!u)throw Error("Cannot load without read() or XMLHttpRequest.");try{e.Na=De(u(e.url),!0),e.Ra=e.Na.length}catch(e){throw new Re.ErrnoError(29)}},ld:function(e,t,r,n,i){function o(){this.Jb=!1,this.ob=[]}if(o.prototype.get=function(e){if(!(e>this.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var s=this;s.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===s.ob[e]){var a=s.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):De(u.responseText||"",!0),a[e]=t}if(void 0===s.ob[e])throw Error("doXHR failed!");return s.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!p)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o;Object.defineProperties(s,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),s={Ib:!1,Na:s}}else s={Ib:!1,url:r};var a=Re.Gc(e,t,s,n,i);s.Na?a.Na=s.Na:s.url&&(a.Na=null,a.url=s.url),Object.defineProperties(a,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];u[e]=function(){return Re.ac(a),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(Re.ac(a),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o<n;o++)t[r+o]=e[i+o];else for(o=0;o<n;o++)t[r+o]=e.get(i+o);return n},a.stream_ops=u,a},nd:function(e,t,r,n,o,s,a,u,l,f){function d(r){function c(r){f&&f(),u||Re.zb(e,t,r,n,o,l),s&&s(),ie()}var d=!1;i.preloadPlugins.forEach((function(e){!d&&e.canHandle(h)&&(e.handle(r,h,c,(function(){a&&a(),ie()})),d=!0)})),d||c(r)}undefined.jb();var h=t?ge(pe(e,t)):e;ne(),"string"==typeof r?function(e,t,r){var n="al "+e;c(e,(function(r){x(r,'Loading data file "'+e+'" failed (no arrayBuffer).'),t(new Uint8Array(r)),n&&ie()}),(function(){if(!r)throw'Loading data file "'+e+'" failed.';r()})),n&&ne()}(r,(function(e){d(e)}),a):d(r)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Rb:function(){return"EM_FS_"+window.location.pathname},Sb:20,ib:"FILE_DATA",xd:function(e,t,r){t=t||function(){},r=r||function(){};var n=Re.indexedDB();try{var i=n.open(Re.Rb(),Re.Sb)}catch(e){return r(e)}i.onupgradeneeded=function(){v("creating db"),i.result.createObjectStore(Re.ib)},i.onsuccess=function(){var n=i.result.transaction([Re.ib],"readwrite"),o=n.objectStore(Re.ib),s=0,a=0,u=e.length;e.forEach((function(e){(e=o.put(Re.xb(e).object.Na,e)).onsuccess=function(){++s+a==u&&(0==a?t():r())},e.onerror=function(){a++,s+a==u&&(0==a?t():r())}})),n.onerror=r},i.onerror=r},rd:function(e,t,r){t=t||function(){},r=r||function(){};var n=Re.indexedDB();try{var i=n.open(Re.Rb(),Re.Sb)}catch(e){return r(e)}i.onupgradeneeded=r,i.onsuccess=function(){var n=i.result;try{var o=n.transaction([Re.ib],"readonly")}catch(e){return void r(e)}var s=o.objectStore(Re.ib),a=0,u=0,c=e.length;e.forEach((function(e){var n=s.get(e);n.onsuccess=function(){Re.xb(e).exists&&Re.unlink(e),Re.zb(he(e),_e(e),n.result,!0,!0,!0),++a+u==c&&(0==u?t():r())},n.onerror=function(){u++,a+u==c&&(0==u?t():r())}})),o.onerror=r},i.onerror=r}},Ne={};function Me(e,t,r){try{var n=e(t)}catch(e){if(e&&e.node&&de(t)!==de(Re.Ya(e.node)))return-54;throw e}return P[r>>2]=n.dev,P[r+4>>2]=0,P[r+8>>2]=n.ino,P[r+12>>2]=n.mode,P[r+16>>2]=n.nlink,P[r+20>>2]=n.uid,P[r+24>>2]=n.gid,P[r+28>>2]=n.rdev,P[r+32>>2]=0,Z=[n.size>>>0,(X=n.size,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+40>>2]=Z[0],P[r+44>>2]=Z[1],P[r+48>>2]=4096,P[r+52>>2]=n.blocks,P[r+56>>2]=n.atime.getTime()/1e3|0,P[r+60>>2]=0,P[r+64>>2]=n.mtime.getTime()/1e3|0,P[r+68>>2]=0,P[r+72>>2]=n.ctime.getTime()/1e3|0,P[r+76>>2]=0,Z=[n.ino>>>0,(X=n.ino,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+80>>2]=Z[0],P[r+84>>2]=Z[1],0}var xe,Ae=void 0;function Ie(){return P[(Ae+=4)-4>>2]}function Te(e){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);return e}xe=g?function(){var e=ae.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Ce,Fe={};function Be(){if(!Ce){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(e in Fe)void 0===Fe[e]?delete t[e]:t[e]=Fe[e];var r=[];for(e in t)r.push(e+"="+t[e]);Ce=r}return Ce}function Pe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=Re.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function De(e,t){var r=Array(J(e)+1);return e=j(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Pe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return Re.isDir(this.mode)}},Ib:{get:function(){return Re.pb(this.mode)}}}),Re.FSNode=Pe,Re.lc();var $e={a:function(e,t,r,n){oe("Assertion failed: "+q(e)+", at: "+[t?q(t):"unknown filename",r,n?q(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!ee){ee=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);P[We()>>2]=60*o,P[ze()>>2]=Number(t!=i),r=e(r),n=e(n),r=z(r),n=z(n),i<t?(P[Je()>>2]=r,P[Je()+4>>2]=n):(P[Je()>>2]=n,P[Je()+4>>2]=r)}}(),e=new Date(1e3*P[e>>2]),P[t>>2]=e.getSeconds(),P[t+4>>2]=e.getMinutes(),P[t+8>>2]=e.getHours(),P[t+12>>2]=e.getDate(),P[t+16>>2]=e.getMonth(),P[t+20>>2]=e.getFullYear()-1900,P[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);P[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,P[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),P[t+32>>2]=e,e=P[Je()+(e?4:0)>>2],P[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=q(e),-8&t)var n=-28;else(r=Re.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&Re.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},A:function(e,t){try{return e=q(e),Re.chmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},H:function(e,t,r){try{return e=q(e),Re.chown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},B:function(e,t){try{return Re.fchmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},I:function(e,t,r){try{return Re.fchown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},b:function(e,t,r){Ae=r;try{var n=Te(e);switch(t){case 0:var i=Ie();return 0>i?-28:Re.open(n.path,n.flags,0,i).fd;case 1:case 2:case 13:case 14:return 0;case 3:return n.flags;case 4:return i=Ie(),n.flags|=i,0;case 12:return i=Ie(),B[i+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return P[Le()>>2]=28,-1}}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},E:function(e,t){try{var r=Te(e);return Me(Re.stat,r.path,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},n:function(e,t,r){try{return Re.Nc(e,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=Re.cwd();return t<J(r)+1?-68:(j(r,F,e,t),e)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},G:function(){return 0},d:function(){return 42},z:function(e,t){try{return e=q(e),Me(Re.lstat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},C:function(e,t){try{return"/"===(e=de(e=q(e)))[e.length-1]&&(e=e.substr(0,e.length-1)),Re.mkdir(e,t,0),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},y:function(e,t,r,n,i,o){try{e:{o<<=12;var s=!1;if(0!=(16&n)&&0!=e%65536)var a=-28;else{if(0!=(32&n)){var u=Se(t);if(!u){a=-48;break e}s=!0}else{var c=Re.$a(i);if(!c){a=-8;break e}var l=Re.mmap(c,e,t,o,r,n);u=l.ed,s=l.vb}Ne[u]={Uc:u,Tc:t,vb:s,fd:i,dd:r,flags:n,offset:o},a=u}}return a}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},x:function(e,t){try{var r=Ne[e];if(0!==t&&r){if(t===r.Tc){var n=Re.$a(r.fd);if(n&&2&r.dd){var i=r.flags,o=r.offset,s=F.slice(e,e+t);Re.msync(n,s,o,t,i)}Ne[e]=null,r.vb&&qe(r.Uc)}var a=0}else a=-28;return a}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},w:function(e,t,r){Ae=r;try{var n=q(e),i=r?Ie():0;return Re.open(n,t,i).fd}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},J:function(e,t,r){try{if(e=q(e),0>=r)var n=-28;else{var i=Re.readlink(e),o=Math.min(r,J(i)),s=C[t+o];j(i,F,t,r+1),C[t+o]=s,n=o}return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},F:function(e){try{return e=q(e),Re.rmdir(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},e:function(e,t){try{return e=q(e),Me(Re.stat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},i:function(e){try{return e=q(e),Re.unlink(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){F.copyWithin(e,t,t+r)},c:function(e){var t=F.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{N.grow(Math.min(2147483648,n)-T.byteLength+65535>>>16),W();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=xe();xe()-t<e;);},r:function(e,t){try{var r=0;return Be().forEach((function(n,i){var o=t+r;for(i=P[e+4*i>>2]=o,o=0;o<n.length;++o)C[i++>>0]=n.charCodeAt(o);C[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},s:function(e,t){try{var r=Be();P[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),P[t>>2]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},f:function(e){try{var t=Te(e);return Re.close(t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},q:function(e,t){try{var r=Te(e),n=r.tty?2:Re.isDir(r.mode)?3:Re.fb(r.mode)?7:4;return C[t>>0]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o<r;o++){var s=P[t+(8*o+4)>>2],a=Re.read(i,C,P[t+8*o>>2],s,void 0);if(0>a){var u=-1;break e}if(e+=a,a<s)break}u=e}return P[n>>2]=u,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},o:function(e,t,r,n,i){try{var o=Te(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(Re.llseek(o,e,n),Z=[o.position>>>0,(X=o.position,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[i>>2]=Z[0],P[i+4>>2]=Z[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},k:function(e){try{var t=Te(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o<r;o++){var s=Re.write(i,C,P[t+8*o>>2],P[t+(8*o+4)>>2],void 0);if(0>s){var a=-1;break e}e+=s}a=e}return P[n>>2]=a,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},h:function(e){var t=Date.now();return P[e>>2]=t/1e3|0,P[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(P[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*P[r>>2],t+=P[r+4>>2]/1e3}else t=Date.now();e=q(e);try{Re.kd(e,t,t);var n=0}catch(e){if(!(e instanceof Re.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw i.extraStackTrace&&(n+="\n"+i.extraStackTrace()),n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n),e+" : "+n}n=e.Oa,P[Le()>>2]=n,n=-1}return n}};!function(){function e(e){i.asm=e.exports,N=i.asm.L,W(),H=i.asm.Da,Y.unshift(i.asm.M),ie()}function t(t){e(t.instance)}function r(e){return function(){if(!w&&(_||p)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()})).catch((function(){return ce()}));if(c)return new Promise((function(e,t){c(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ce()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){y("failed to asynchronously prepare wasm: "+e),oe(e)}))}var n={a:$e};if(ne(),i.instantiateWasm)try{return i.instantiateWasm(n,e)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}w||"function"!=typeof WebAssembly.instantiateStreaming||se()||K.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.M).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.N).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.O).apply(null,arguments)};var Le=i.___errno_location=function(){return(Le=i.___errno_location=i.asm.P).apply(null,arguments)};i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.Q).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.R).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.S).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.T).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.U).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.V).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.W).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.X).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.Y).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.Z).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm._).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.$).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.aa).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.ba).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.ca).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.da).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.ea).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.fa).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.ga).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.ha).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.ia).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.ja).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.ka).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.la).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.ma).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.na).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.oa).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.pa).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.qa).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.ra).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sa).apply(null,arguments)},i._sqlite3_normalized_sql=function(){return(i._sqlite3_normalized_sql=i.asm.ta).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.ua).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.va).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.wa).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.xa).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.ya).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.za).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.Aa).apply(null,arguments)};var Ue=i._malloc=function(){return(Ue=i._malloc=i.asm.Ba).apply(null,arguments)},qe=i._free=function(){return(qe=i._free=i.asm.Ca).apply(null,arguments)};i._RegisterExtensionFunctions=function(){return(i._RegisterExtensionFunctions=i.asm.Ea).apply(null,arguments)},i._register_for_idb=function(){return(i._register_for_idb=i.asm.Fa).apply(null,arguments)};var je,Je=i.__get_tzname=function(){return(Je=i.__get_tzname=i.asm.Ga).apply(null,arguments)},ze=i.__get_daylight=function(){return(ze=i.__get_daylight=i.asm.Ha).apply(null,arguments)},We=i.__get_timezone=function(){return(We=i.__get_timezone=i.asm.Ia).apply(null,arguments)},He=i.stackSave=function(){return(He=i.stackSave=i.asm.Ja).apply(null,arguments)},Ge=i.stackRestore=function(){return(Ge=i.stackRestore=i.asm.Ka).apply(null,arguments)},Ye=i.stackAlloc=function(){return(Ye=i.stackAlloc=i.asm.La).apply(null,arguments)},Ve=i._memalign=function(){return(Ve=i._memalign=i.asm.Ma).apply(null,arguments)};function Qe(){function e(){if(!je&&(je=!0,i.calledRun=!0,!M)){if(i.noFSInit||Re.jb.Hb||Re.jb(),Re.hc=!1,le(Y),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;){var e=i.postRun.shift();V.unshift(e)}le(V)}}if(!(0<te)){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)Q();le(G),0<te||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),e()}),1)):e())}}if(i.cwrap=function(e,t,r,n){var i=(r=r||[]).every((function(e){return"number"===e}));return"string"!==t&&i&&!n?A(e):function(){return function(e,t,r,n){var i,o={string:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);t=Ye(r),j(e,F,t,r)}return t},array:function(e){var t=Ye(e.length);return C.set(e,t),t}},s=A(e),a=[];if(e=0,n)for(var u=0;u<n.length;u++){var c=o[r[u]];c?(0===e&&(e=He()),a[u]=c(n[u])):a[u]=n[u]}return r=s.apply(null,a),i=r,r="string"===t?q(i):"boolean"===t?!!i:i,0!==e&&Ge(e),r}(e,t,r,arguments)}},i.UTF8ToString=q,i.FS=Re,i.stackSave=He,i.stackRestore=Ge,i.stackAlloc=Ye,re=function e(){je||Qe(),je||(re=e)},i.run=Qe,i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();return Qe(),i})),r)};e.exports=n,e.exports.default=n}(ot);var Ot=p(ot.exports);const St=63,kt=44;const Rt=class{constructor(e,t){this.FS=e,this.backend=t,this.node_ops={getattr:t=>{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(kt)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.lock(t)}unlock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.unlock(t)}createNode(e,t,r,n){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(St);var i=this.FS.createNode(e,t,r,n);return this.FS.isDir(i.mode)?(i.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},i.stream_ops={},i.contents={}):this.FS.isFile(i.mode)&&(i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i.contents=this.backend.createFile(t)),e&&(e.contents[t]=i,e.timestamp=i.timestamp),i}};let Nt=1,Mt=2;function xt(e){return(e[16]<<8)+e[17]}function At(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function It(e,t,r,n){let i=At(t,r,n),o=0;return i.map((i=>{let s=0,a=t;r>i&&r<i+t&&(s=r-i),n>i&&n<i+t&&(a=n-i);let u=a-s,c=new ArrayBuffer(t);if(r>i+t||n<=i)return null;let l=e.byteOffset+o,f=e.buffer.byteLength-l;if(f<=0)return null;let d=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,d),s),o+=d,{pos:i,data:c,offset:s,length:d}})).filter(Boolean)}class Tt{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t<e.length;t++){let r=e[t];this.buffer.set(r.pos,r)}}open(){if(this.openHandles++,1===this.openHandles){this.ops.open();let e=this.ops.readMeta();null==this.meta&&(null==e&&(e={size:0}),this.meta=e)}return this.meta}close(){this.fsync(),this.openHandles=Math.max(this.openHandles-1,0),0===this.openHandles&&this.ops.close()}delete(){this.ops.delete()}load(e){let t=e.reduce(((e,t)=>{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e}),{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;t<r;t++)e[t]=0;return r}n=Math.max(n,0);let o=Math.min(r,this.meta.size-n),s=n,a=n+o,u=At(this.meta.blockSize,s,a),c=function(e,t,r){let n=new ArrayBuffer(r-t),i=new Uint8Array(n);for(let n=0;n<e.length;n++){let o=e[n];if("ArrayBuffer"!==o.data.constructor.name)throw new Error("Chunk data is not an ArrayBuffer");let s=0,a=o.data.byteLength;if(t>o.pos&&(s=t-o.pos),r<o.pos+o.data.byteLength&&(a=r-o.pos),s>o.data.byteLength||a<0)continue;let u=a-s;i.set(new Uint8Array(o.data,s,u),o.pos-t+s)}return n}(this.load(u),s,a);if(i.byteLength-t<c.byteLength)throw new Error("Buffer given to `read` is too small");let l=new Uint8Array(i);l.set(new Uint8Array(c),t);for(let e=o;e<r;e++)l[t+e]=0;return r}write(e,t,r,n){if(null==this.meta.blockSize){let r=xt(new Uint8Array(e.buffer,e.byteOffset+t));if(![512,1024,2048,4096,8192,16384,32768,65536].includes(r))throw new Error("File has invalid page size. (the first block of a new file must be written first)");this.setattr({blockSize:r})}let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(0===i.byteLength)return 0;r=Math.min(r,i.byteLength-t);let o=It(new Uint8Array(i,t,r),this.meta.blockSize,n,n+r),{partialWrites:s,fullWrites:a}=o.reduce(((e,t)=>(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e)),{fullWrites:[],partialWrites:[]}),u=[];s.length>0&&(u=this.load(s.map((e=>e.pos))));let c=a.concat(u.map((e=>{let t=s.find((t=>t.pos===e.pos));return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e})));return this.bufferChunks(c),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=Mt&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=xt(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(It(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}let Ct,Ft,Bt,Pt=3735928559;class Dt{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log(`waiting for ${e}`);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log(`resumed for ${e}`)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=new DataView(this.buffer,this.offset).getUint32(0)===Pt;return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e<r;e++)i.push(n.getUint16(2*e));let o=String.fromCharCode.apply(null,i);return this.log("string",o),this.offset+=t,null==this.peekOffset&&this.flip(),o}_int32(){let e=new DataView(this.buffer,this.offset).getInt32();return this.log("_int32",e),this.offset+=4,e}int32(){this.waitWrite("int32");let e=this._int32();return this.log("int32",e),null==this.peekOffset&&this.flip(),e}bytes(){this.waitWrite("bytes");let e=this._int32(),t=new ArrayBuffer(e);return new Uint8Array(t).set(new Uint8Array(this.buffer,this.offset,e)),this.log("bytes",t),this.offset+=e,null==this.peekOffset&&this.flip(),t}}class $t{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o,this.useAtomics?Atomics.store(this.atomicView,0,0):this.atomicView[0]=0}log(...e){this.debug&&console.log(`[writer: ${this.name}]`,...e)}waitRead(e){if(this.useAtomics){if(this.log(`waiting for ${e}`),0!==Atomics.compareExchange(this.atomicView,0,0,1))throw new Error("Wrote something into unwritable buffer! This is disastrous");for(Atomics.notify(this.atomicView,0);1===Atomics.load(this.atomicView,0);)Atomics.wait(this.atomicView,0,1,500);this.log(`resumed for ${e}`)}else this.atomicView[0]=1;this.offset=4}finalize(){this.log("finalizing"),new DataView(this.buffer,this.offset).setUint32(0,Pt),this.waitRead("finalize")}string(e){this.log("string",e);let t=2*e.length;this._int32(t);let r=new DataView(this.buffer,this.offset,t);for(let t=0;t<e.length;t++)r.setUint16(2*t,e.charCodeAt(t));this.offset+=t,this.waitRead("string")}_int32(e){new DataView(this.buffer,this.offset).setInt32(0,e),this.offset+=4}int32(e){this.log("int32",e),this._int32(e),this.waitRead("int32")}bytes(e){this.log("bytes",e);let t=e.byteLength;this._int32(t),new Uint8Array(this.buffer,this.offset).set(new Uint8Array(e)),this.offset+=t,this.waitRead("bytes")}}function Lt(e,t){return Math.round(e/t)}class Ut{constructor(e){this.filename=e}getStoreName(){return this.filename.replace(/\//g,"-")}invokeWorker(e,t){if(null==this.reader||null==this.writer)throw new Error(`Attempted ${e} on ${this.filename} but file not open`);let r=this.reader,n=this.writer;switch(e){case"readBlocks":{let{name:e,positions:i,blockSize:o}=t,s=[];for(let t of i){n.string("readBlock"),n.string(e),n.int32(Lt(t,o)),n.finalize();let i=r.bytes();r.done(),s.push({pos:t,data:0===i.byteLength?new ArrayBuffer(o):i})}return s}case"writeBlocks":{let{name:e,writes:i,blockSize:o}=t;n.string("writeBlocks"),n.string(e);for(let e of i)n.int32(Lt(e.pos,o)),n.bytes(e.data);n.finalize();let s=r.int32();return r.done(),s}case"readMeta":{n.string("readMeta"),n.string(t.name),n.finalize();let e=r.int32(),i=r.int32();return r.done(),-1===e?null:{size:e,blockSize:i}}case"writeMeta":{let{name:e,meta:i}=t;n.string("writeMeta"),n.string(e),n.int32(i.size),n.finalize();let o=r.int32();return r.done(),o}case"closeFile":{n.string("closeFile"),n.string(t.name),n.finalize();let e=r.int32();return r.done(),e}case"lockFile":{n.string("lockFile"),n.string(t.name),n.int32(t.lockType),n.finalize();let e=r.int32();return r.done(),0===e}case"unlockFile":{n.string("unlockFile"),n.string(t.name),n.int32(t.lockType),n.finalize();let e=r.int32();return r.done(),0===e}}}lock(e){return this.invokeWorker("lockFile",{name:this.getStoreName(),lockType:e})}unlock(e){return this.invokeWorker("unlockFile",{name:this.getStoreName(),lockType:e})}delete(){(this.reader||this.writer)&&this.close();let e=globalThis.indexedDB.deleteDatabase(this.getStoreName());e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new $t(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new Dt(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",(e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}}))}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function qt(e,t){return Math.round(e/t)}async function jt(e){return await function(){if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const r=()=>indexedDB.databases().finally(t);e=setInterval(r,100),r()})).finally((()=>clearInterval(e)))}(),new Promise(((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)}))}class Jt{constructor(e,t){this.dbName=e,this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=t}async getDb(){return this._openDb||(this._openDb=await jt(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise(((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}}))}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise(((o,s)=>{let a=i.get(0);a.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(a.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void s(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>s()},a.onerror=s}))}}class zt{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new Jt(this.dbName,t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>Nt&&e===Nt&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:xt(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(qt(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=qt(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=Nt&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>Nt),this.writeQueue=[]),this.cachedFirstBlock=null}}class Wt{constructor(e){this.onFallbackFailure=e}createFile(e){let t;t="undefined"!=typeof SharedArrayBuffer?new Ut(e):new zt(e,this.onFallbackFailure);let r=new Tt(e,t);return("production"!==ae.env.NODE_ENV||ae.env.PERF_BUILD)&&(null==this._files&&(this._files=new Set),this._files.add(r)),r}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}function Ht(e,t){if(Ct)return Ct;if(!e)throw new Error("must speciefic database file");return Ct=new Promise(((r,n)=>{const i=async function(e,t="/sql-wasm.wasm"){if(!Ft){Ft=await Ot({locateFile:()=>t});const e=new Rt(Ft.FS,new Wt);Ft.register_for_idb(e),Ft.FS.mkdir("/sql"),Ft.FS.mount(e,{},"/sql")}const r=`/sql/${e}`,n=new Ft.Database(r,{filename:!0});if("undefined"==typeof SharedArrayBuffer){const e=Ft.FS.open(r,"a+");await e.node.contents.readIfFallback(),Ft.FS.close(e)}return n.exec("\n PRAGMA page_size=8192;\n PRAGMA journal_mode=MEMORY;\n "),n}(e,t);i.then((e=>r(e))).catch((e=>n(e)))})),Ct}async function Gt(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));if(0===r.length)return M("");const n=function(e,t){const r=v.insert().into("local_conversations").setFieldsRows(t).toString();return e.exec(r)}(t,r);return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}async function Yt(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("temp_cache_local_chat_logs").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}self.$RefreshReg$=()=>{},self.$RefreshSig$=()=>()=>{};const Vt=new Map,Qt=self,Kt=new d({event:new class{constructor(e){c(this,"_currentEndpoint"),c(this,"_targetEndpoint"),c(this,"_events"),c(this,"_originOnmessage"),c(this,"_receiveMessage"),c(this,"onerror",null),c(this,"config"),c(this,"sendAdapter"),c(this,"receiveAdapter"),this._events={},this._currentEndpoint=e.currentEndpoint,this._targetEndpoint=e.targetEndpoint,this._originOnmessage=null,this.config=e.config,this.receiveAdapter=e.receiveAdapter,this.sendAdapter=e.sendAdapter;const t=e=>{const t=this.receiveAdapter?this.receiveAdapter(e):e.data;if(t&&"string"==typeof t.event){const e=this._events[t.event]||[];if(e.length)return void e.forEach((e=>{e(...t.args||[])}));this.onerror&&this.onerror(u(a({},l.METHOD_NOT_FOUND),{data:t}))}};if(this._currentEndpoint.addEventListener)return"start"in this._currentEndpoint&&this._currentEndpoint.start&&this._currentEndpoint.start(),this._currentEndpoint.addEventListener("message",t,!1),void(this._receiveMessage=t);this._originOnmessage=this._currentEndpoint.onmessage,this._currentEndpoint.onmessage=e=>{this._originOnmessage&&this._originOnmessage(e),t(e)},this._receiveMessage=this._currentEndpoint.onmessage}emit(e,...t){const r={event:e,args:t},n=this.sendAdapter?this.sendAdapter(r,this._targetEndpoint):{data:r},i=n.data||r,o=this.config?"function"==typeof this.config?this.config(i,this._targetEndpoint)||{}:this.config||{}:{};Array.isArray(n.transfer)&&n.transfer.length&&(o.transfer=n.transfer),this._targetEndpoint.postMessage(i,o)}on(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}off(e,t){if(!this._events[e])return;if(!t)return void(this._events[e]=[]);const r=this._events[e]||[];this._events[e]=r.filter((e=>e!==t))}destroy(){if(this._currentEndpoint.removeEventListener)this._currentEndpoint.removeEventListener("message",this._receiveMessage,!1);else try{this._currentEndpoint.onmessage=this._originOnmessage}catch(e){console.warn(e)}}}({currentEndpoint:Qt,targetEndpoint:Qt})});Kt.registerMethod("fileMapSet",((e,t)=>(Vt.set(e,t),M(e)))),Kt.registerMethod("fileMapClear",(()=>(Vt.clear(),M("")))),Kt.registerMethod("wasmOpen",(e=>new Promise(((t,r)=>{const n=Vt.get(e);n?t(M(n.size)):r("file not found")})))),Kt.registerMethod("wasmClose",(async e=>new Promise((t=>{Vt.delete(e),t(M(e))})))),Kt.registerMethod("wasmRead",((e,t,r)=>{const n=Vt.get(e);if(!n)throw"file not found";const i=n.slice(t,t+r);return new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{t(r.error)},r.readAsArrayBuffer(i)}))})),Kt.registerMethod("getUpload",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_uploads where part_hash = '${t}' limit 1;\n `)}(await Ht(),e),r=F(t[0],"CamelCase");if(0===r.length)throw`no upload with partHash = ${e}`;return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_uploads").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_uploads").setFields(t).where(`part_hash = '${t.part_hash}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteUpload",(async function(e){try{const t=function(e,t){const r=v.delete().from("local_uploads").where(`part_hash = '${t}'`).toString();return e.exec(r)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setSqlWasmPath",(function(e){Bt=e})),Kt.registerMethod("initDB",(async function(e,t){try{const r=await Ht(`${t}${e}.sqlite`,Bt),n=[],i=function(e){return e.exec("\n create table if not exists 'local_uploads' (\n 'part_hash' text,\n 'upload_id' varchar(1000),\n 'upload_info' varchar(2000),\n 'expire_time' integer,\n 'create_time' integer,\n PRIMARY KEY ('part_hash')\n )\n ")}(r),o=function(e){return e.exec("\n create table if not exists 'local_stranger'\n (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n PRIMARY KEY ('user_id')\n )\n ")}(r),s=function(e){return e.exec("\n create table if not exists 'local_conversations' (\n 'conversation_id' char(128),\n 'conversation_type' integer,\n 'user_id' char(64),\n 'group_id' char(128),\n 'show_name' varchar(255),\n 'face_url' varchar(255),\n 'face_background_color' varchar(255),\n 'recv_msg_opt' integer,\n 'unread_count' integer,\n 'group_at_type' integer,\n 'latest_msg' varchar(1000),\n 'latest_msg_send_time' integer,\n 'draft_text' text,\n 'draft_text_time' integer,\n 'is_pinned' numeric,\n 'burn_duration' integer,\n 'is_private_chat' numeric,\n 'is_not_in_group' numeric,\n 'update_unread_count_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'max_seq' integer,\n 'min_seq' integer,\n 'has_read_seq' integer,\n 'msg_destruct_time' integer default 604800,\n 'is_msg_destruct' numeric default false,\n primary key ('conversation_id')\n )\n ")}(r),a=function(e){return e.exec("\n create table if not exists 'local_users' (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n primary key ('user_id')\n )\n ")}(r),u=function(e){return e.exec("\n create table if not exists 'local_blacks' (\n 'owner_user_id' varchar(64),\n 'block_user_id' varchar(64),\n 'nickname' varchar(255),\n 'face_url' varchar(255),\n 'gender' INTEGER,\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('owner_user_id', 'block_user_id')\n ) \n ")}(r),c=function(e){return e.exec("\n create table if not exists 'local_friends'\n (\n 'owner_user_id' varchar(64),\n 'friend_user_id' varchar(64),\n 'remark' varchar(255),\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'is_pinned' numeric,\n primary key ('owner_user_id', 'friend_user_id')\n ) \n ")}(r),l=function(e){return e.exec("\n create table if not exists 'local_groups'\n (\n 'group_id' varchar(64) PRIMARY KEY,\n 'name' TEXT,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' INTEGER,\n 'status' INTEGER,\n 'creator_user_id' varchar(64),\n 'group_type' INTEGER,\n 'owner_user_id' varchar(64),\n 'member_count' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' INTEGER,\n 'look_member_info' INTEGER,\n 'apply_member_friend' INTEGER,\n 'notification_update_time' INTEGER,\n 'notification_user_id' TEXT,\n 'display_is_read' numeric\n ) \n ")}(r),f=function(e){return e.exec('\n create table if not exists "local_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),d=function(e){return e.exec("\n create table if not exists 'local_group_members' (\n 'group_id' varchar(64),\n 'user_id' varchar(64),\n 'nickname' varchar(255),\n 'user_group_face_url' varchar(255),\n 'role_level' integer,\n 'join_time' integer,\n 'join_source' integer,\n 'inviter_user_id' text,\n 'mute_end_time' integer DEFAULT 0,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n PRIMARY KEY ('group_id', 'user_id')\n ) \n ")}(r),h=function(e){return e.exec('\n create table if not exists "local_admin_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),_=function(e){return e.exec("\n create table if not exists 'local_friend_requests'\n (\n 'from_user_id' varchar(64),\n 'from_nickname' varchar(255),\n 'from_face_url' varchar(255),\n 'to_user_id' varchar(64),\n 'to_nickname' varchar(255),\n 'to_face_url' varchar(255),\n 'handle_result' INTEGER,\n 'req_msg' varchar(255),\n 'create_time' INTEGER,\n 'handler_user_id' varchar(64),\n 'handle_msg' varchar(255),\n 'handle_time' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('from_user_id', 'to_user_id')\n ); \n ")}(r),p=function(e){return e.exec("\n create table if not exists 'local_super_groups' (\n 'group_id' varchar(64),\n 'name' text,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'status' integer,\n 'creator_user_id' varchar(64),\n 'group_type' integer,\n 'owner_user_id' varchar(64),\n 'member_count' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' integer,\n 'look_member_info' integer,\n 'apply_member_friend' integer,\n 'notification_update_time' integer,\n 'notification_user_id' text,\n primary key ('group_id')\n )\n ")}(r),g=function(e){return e.exec("\n create table if not exists 'temp_cache_local_chat_logs' (\n 'client_msg_id' char(64),\n 'server_msg_id' char(64),\n 'send_id' char(64),\n 'recv_id' char(64),\n 'sender_platform_id' integer,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'sender_face_background_color' varchar(255),\n 'session_type' integer,\n 'msg_from' integer,\n 'content_type' integer,\n 'content' varchar(1000),\n 'is_read' numeric,\n 'status' integer,\n 'seq' integer DEFAULT 0,\n 'send_time' integer,\n 'create_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n PRIMARY KEY ('client_msg_id')\n );\n ")}(r),m=function(e){return e.exec("\n create table if not exists 'local_notification_seqs'\n (\n 'conversation_id' char(128),\n 'seq' integer,\n PRIMARY KEY ('conversation_id')\n )\n ")}(r),v=function(e){return e.exec("\n create table if not exists 'local_sending_messages'\n (\n conversation_id varchar(128),\n client_msg_id varchar(64),\n ex varchar(1024),\n PRIMARY KEY ('conversation_id', 'client_msg_id')\n );\n ")}(r),y=function(e){return e.exec("\n create table if not exists 'local_conversation_unread_messages' (\n 'conversation_id' char(128),\n 'client_msg_id' char(64),\n 'send_time' integer,\n 'ex' varchar(1024),\n primary key (\n 'conversation_id',\n 'client_msg_id'\n )\n );\n ")}(r),b=function(e){return e.exec("\n create table if not exists 'local_app_sdk_version' (\n 'version' varchar(255),\n primary key ('version')\n ) \n ")}(r),w=function(e){return e.exec("\n create table if not exists 'local_sync_version' (\n 'table_name' varchar(255),\n 'entity_id' varchar(255),\n 'version_id' text,\n 'version' integer,\n 'create_time' integer,\n 'id_list' text,\n primary key ('table_name','entity_id')\n ) \n ")}(r);return function(e){!function(e){try{e.exec("\n ALTER TABLE local_friends ADD COLUMN is_pinned numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_groups ADD COLUMN display_is_read numeric;\n ")}catch(e){}}(e),function(e){try{const t=e.exec("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'chat_logs_%';");t.length>0&&t[0].values&&t[0].values.forEach((t=>{const r=t[0];try{e.exec(`ALTER TABLE '${r}' ADD COLUMN sender_face_background_color varchar(255);`)}catch(e){}}));try{e.exec("ALTER TABLE temp_cache_local_chat_logs ADD COLUMN sender_face_background_color varchar(255);")}catch(e){}try{e.exec("ALTER TABLE local_conversations ADD COLUMN face_background_color varchar(255);")}catch(e){}}catch(e){}}(e)}(r),n.push(i,o,s,a,p,y,u,c,l,d,_,f,h,g,m,v,b,w),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("close",(async function(){try{return await async function(){if(!Ct)return;(await Ct).close(),Ct=void 0}(),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessage",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}' limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with id ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMultipleMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendingMessageList",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status = 1;\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessageTimeAndStatus",(async function(e,t,r,n,i){try{const o=await Ht(),s=function(e,t,r,n,i,o){return e.exec(`\n UPDATE 'chat_logs_${t}' SET server_msg_id = '${n}', send_time = ${i}, status = ${o} WHERE client_msg_id = '${r}' and seq=0;\n `)}(o,e,t,r,n,i);if(0===o.getRowsModified())throw"updateMessageTimeAndStatus no record updated";return M(s)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessageBySeq",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`seq = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessageBySeq no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertMessage",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFields(r).toString();return e.exec(n)}(r,e,B(JSON.parse(t)));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertMessageList",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){y(e,t);const n=v.insert().into(`'chat_logs_${t}'`).setFieldsRows(r).toString();return e.exec(n)}(r,e,JSON.parse(t).map((e=>B(e))));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageList",(async function(e,t,r,n=!1){try{const i=function(e,t,r,n,i){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${i?">":"<"} ${n} ORDER BY send_time ${i?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageListNoTime",(async function(e,t,r=!1){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' ORDER BY send_time ${n?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("messageIfExists",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}';\n `)}(await Ht(),e,t);return M(0!==r.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByKeyword",(async function(e,t,r,n,i,o,s,a){try{const u=function(e,t,r,n,i,o,s,a,u){const c=s||(new Date).getTime();let l="";const f=r.map((e=>`${e}`)).join(","),d=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(l+="And ("),t+1>=n.length?l+="content like '%"+n[t]+"%') ":l+="content like '%"+n[t]+"%' "+d})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${c} \n AND status <=3 \n And content_type IN (${f}) \n ${l}\n ORDER BY send_time DESC LIMIT ${u} OFFSET ${a};\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o,s,a);return M(F(u[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByContentType",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=i||(new Date).getTime();return e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${n} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ORDER BY send_time DESC LIMIT ${s} OFFSET ${o};\n `)}(await Ht(),e,JSON.parse(t),r,n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByContentTypeAndKeyword",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=s||(new Date).getTime();let c="";const l=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(c+="And ("),t+1>=n.length?c+="content like '%"+n[t]+"%') ":c+="content like '%"+n[t]+"%' "+l})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ${c}\n ORDER BY send_time DESC;\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMsgSenderFaceURLAndSenderNickname",(async function(e,t,r,n,i){try{return function(e,t,r,n,i,o){y(e,t);const s=`sender_face_url = '${n}', sender_nick_name = '${i}'${o?`, sender_face_background_color = '${o}'`:""}`;e.exec(`\n UPDATE 'chat_logs_${t}' SET ${s} WHERE send_id = '${r}';\n `)}(await Ht(),e,t,r,n,i),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAlreadyExistSeqList",(async function(e,t){var r;try{const n=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(null!==(r=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]).map((e=>e.seq)))&&void 0!==r?r:[])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageBySeq",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq = ${r} limit 1;\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with seq ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessagesByClientMsgIDs",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return 0===r.length?M("",h.ErrorNoRecord,`no message with clientMsgIDListStr ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessagesBySeqs",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationNormalMsgSeq",(async function(e){var t,r;try{const n=function(e,t){return y(e,t),e.exec(`\n SELECT seq FROM 'chat_logs_${t}' order by seq desc limit 1;\n `)}(await Ht(),e);return M(null!==(r=null===(t=F(n[0],"CamelCase")[0])||void 0===t?void 0:t.seq)&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationPeerNormalMsgSeq",(async function(e,t){var r,n;try{const i=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' where send_id != '${r}' order by seq desc limit 1;\n `)}(await Ht(),e,t);return M(null!==(n=null===(r=F(i[0],"CamelCase")[0])||void 0===r?void 0:r.seq)&&void 0!==n?n:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE 1=1;\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markDeleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n UPDATE 'chat_logs_${t}' SET status = 2 WHERE (1=1) and (conversation_id = '${t}')';\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getUnreadMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_id != '${r}' and is_read = 0;\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationMessageAsReadBySeqs",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){y(e,t);const i=r.map((e=>`${e}`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE seq IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationMessageAsRead",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=r.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE client_msg_id IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationMsgs",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`)).join(",");return e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE client_msg_id IN (${n});\n `)}(await Ht(),e,JSON.parse(t));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationAllMessageAsRead",(async function(e,t){try{const r=await Ht();return function(e,t,r){e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE is_read = 0 and send_id != '${r}';\n `)}(r,e,JSON.parse(t)),M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchAllMessageByContentType",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE content_type = ${r};\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertSendingMessage",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_sending_messages").setFields(t).toString();return e.exec(r)}(t,B(JSON.parse(e)));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteSendingMessage",(async function(e,t){try{const r=function(e,t,r){const n=v.delete().from("local_sending_messages").where(`conversation_id = '${t}'`).where(`client_msg_id = '${r}'`).toString();return e.exec(n)}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllSendingMessages",(async function(){try{const e=function(e){const t=v.select().from("local_sending_messages").toString();return e.exec(t)}(await Ht());return M(F(e[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getLatestActiveMessage",(async function(e,t){try{const r=function(e,t,r){y(e,t);const n=r?"ASC":"DESC";return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status < 4 ORDER BY send_time ${n};\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time > 0 order by case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) desc;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationListToSync",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getHiddenConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time = 0;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversation",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where conversation_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with id ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMultipleConversation",(async function(e){try{const t=await Ht(),r=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select * from local_conversations where conversation_id in (${r.join(",")});\n `)}(t,JSON.parse(e));return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsConversation",(async function(e,t){try{const r=await Ht();let n=t;"string"==typeof t&&(n=B(P(JSON.parse(t))));const i=function(e,t,r){const n=v.update().table("local_conversations").setFields(r).where(`conversation_id = '${t}'`).toString();return e.exec(n)}(r,e,n);if(0===r.getRowsModified())throw"updateColumnsConversation no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("decrConversationUnreadCount",(async function(e,t){try{const r=function(e,t,r){e.exec("begin"),e.exec(`\n update local_conversations set \n unread_count=unread_count-${r} \n where conversation_id = '${t}';\n `);const n=e.exec(`select unread_count from local_conversations where conversation_id = '${t}'`);return Number(n[0].values[0])<0&&e.exec(`\n update local_conversations set \n unread_count=0 \n where conversation_id = '${t}';\n `),e.exec("commit")}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertConversationList",Gt),Kt.registerMethod("getTotalUnreadMsgCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n select sum(unread_count) from local_conversations where recv_msg_opt < 2 and latest_msg_send_time > 0;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertConversation",(async function(e){return Gt(`[${e}]`)})),Kt.registerMethod("getConversationByUserID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where user_id = "${t}" limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with userID ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationListSplit",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_conversations\n WHERE latest_msg_send_time > 0\n ORDER BY case\n when is_pinned = 1 then 0\n else 1 end, max(latest_msg_send_time, draft_text_time) DESC\n LIMIT ${r} OFFSET ${t}\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversation",(async function(e){try{return function(e,t){e.exec(`\n DELETE\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllConversation",(async function(){try{return function(e){e.exec("\n DELETE FROM local_conversations;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchUpdateConversationList",(async function(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));return 0===r.length||r.forEach((e=>{!function(e,t){const r=v.update().table("local_conversations").setFields(t).where(`conversation_id = '${t.conversation_id}'`).toString();e.exec(r)}(t,e)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("conversationIfExists",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT count(*)\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e);return M(0!==t.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("resetConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("resetAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("clearConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("clearAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setConversationDraft",(async function(e,t){try{return function(e,t,r){const n=(new Date).getTime();e.exec(`\n update local_conversations\n set draft_text='${r}',\n draft_text_time=${n},\n latest_msg_send_time=case when latest_msg_send_time = 0 then ${n} else latest_msg_send_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("removeConversationDraft",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set draft_text="${r}",\n draft_text_time=0\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("unPinConversation",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set is_pinned=${r},\n draft_text_time=case when draft_text = "" then 0 else draft_text_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("incrConversationUnreadCount",(async function(e){try{const t=function(e,t){return e.exec(`\n update local_conversations set \n unread_count=unread_count+1 \n where conversation_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setMultipleConversationRecvMsgOpt",(async function(e,t){try{return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE local_conversations\n SET recv_msg_opt=${r}\n WHERE conversation_id IN (${n})\n `)}(await Ht(),JSON.parse(e),t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllSingleConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where conversation_type = 1;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversations",(async function(){try{const e=function(e){return e.exec("\n SELECT * FROM local_conversations\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchConversations",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_conversations\n WHERE show_name LIKE '%${t}%'\n ORDER BY latest_msg_send_time DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getLoginUser",(async function(e){try{const t=function(e,t){return e.exec(`\n select *, name as nickname from local_users where user_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no login user with id ${e}`):M(F(t[0],"CamelCase",[],{name:"nickname"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_users").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_users").setFields(t).where(`user_id = '${t.user_id}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));if(0===t.getRowsModified())throw"updateLoginUser no record updated";return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getStrangerInfo",(async function(e){try{const t=await Ht();return M(F(k(t,JSON.parse(e))[0],"CamelCase",[],{name:"nickname"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setStrangerInfo",(function(e){try{return JSON.parse(e).map((e=>B(P(e,{nickname:"name"})))).map((e=>async function(e){try{const t=await Ht(),r=k(t,[e.user_id]);return F(r[0]).length?function(e,t){const r=v.update().table("local_stranger").setFields(t).where(`user_id = '${t.user_id}'`).toString();e.exec(r)}(t,e):function(e,t){const r=v.insert().into("local_stranger").setFields(t).toString();e.exec(r)}(t,e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}(e))),Promise.resolve(M(""))}catch(e){return console.error(e),Promise.resolve(M(void 0,h.ErrorInit,JSON.stringify(e)))}})),Kt.registerMethod("getAppSDKVersion",(async function(){try{const e=R(await Ht());return 0===e.length?M("",h.ErrorNoRecord,"no app version with database"):M(F(e[0],"CamelCase",[])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setAppSDKVersion",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e))),n=F(R(t)[0],"CamelCase",[]);return n[0]&&n[0].version?(function(e,t,r){const n=v.update().table("local_app_sdk_version").setFields(r).where(`version = '${t}'`).toString();e.exec(n)}(t,n[0].version,r),M("")):(function(e,t){const r=v.insert().into("local_app_sdk_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getVersionSync",(async function(e,t){try{const r=N(await Ht(),e,t);if(0===r.length)return M("",h.ErrorNoRecord,`no sync version with tableName ${e}, entityID ${t}`);const n=F(r[0],"CamelCase",[],{id_list:"uidList"})[0];return n.uidList=JSON.parse(n.uidList),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setVersionSync",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e)));r.id_list=JSON.stringify(r.uid_list),delete r.uid_list;const n=F(N(t,r.table_name,r.entity_id)[0],"CamelCase",[]);return n[0]&&n[0].tableName?(function(e,t,r,n){delete n.table;const i=v.update().table("local_sync_version").setFields(n).where(`table_name = '${t}' AND entity_id = '${r}'`).toString();e.exec(i)}(t,n[0].tableName,n[0].entityID,r),M("")):(function(e,t){delete t.table;const r=v.insert().into("local_sync_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteVersionSync",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}";\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedSuperGroupList",(async function(){try{const e=await Ht();return M(F(b(e)[0]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedSuperGroupIDList",(async function(){try{const e=await Ht(),t=F(b(e)[0]);return M(t.map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSuperGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_super_groups where group_id = '${t}' LIMIT 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no super group with id ${e}`):M(F(t[0])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteSuperGroup",(async function(e){try{const t=function(e,t){return e.exec(`\n delete from local_super_groups where group_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertSuperGroup",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_super_groups").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{groupName:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateSuperGroup",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.update().table("local_super_groups").setFields(r).where(`group_id = '${t}'`).toString();return e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"})));if(0===r.getRowsModified())throw"updateSuperGroup no record updated";return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationUnreadMessageList",(async function(e,t){try{const r=await Ht();!function(e,t,r){e.exec(`\n delete from local_conversation_unread_messages where conversation_id = '${t}' and send_time <= ${r};\n `)}(r,e,t);return M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertConversationUnreadMessageList",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_conversation_unread_messages").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackList",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{block_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackListUserID",(async function(){try{const e=function(e){return e.exec("\n SELECT block_user_id\n FROM local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackInfoByBlockUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_blacks\n WHERE owner_user_id = "${r}"\n AND block_user_id = "${t}"\n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_blacks\n where block_user_id in (${r.join(",")})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_blacks").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"block_user_id",name:"nickname"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteBlack",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_blacks\n where owner_user_id = "${r}"\n and block_user_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_blacks").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and block_user_id = '${t.block_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_friend_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteFriendRequestBothUserID",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friend_requests").setFields(t).where(`from_user_id = '${t.from_user_id}' and to_user_id = '${t.to_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getRecvFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friend_requests\n where to_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_friend_requests\n where from_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendApplicationByBothID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n limit 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBothFriendReq",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where (from_user_id = "${t}"\n and to_user_id = "${r}")\n or (from_user_id = "${r}"\n and to_user_id = "${t}")\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroup",(async function(e){try{const t=await Ht();return E(t,B(P(JSON.parse(e),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroup",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_groups \n WHERE group_id="${t}" \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroup",(async function(e,t){try{const r=await Ht();return function(e,t,r){const n=v.update().table("local_groups").setFields(r).where(`group_id = '${t}'`).toString();e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedGroupList",(async function(){try{const e=await Ht();return M(F(O(e)[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT *\n FROM local_groups\n WHERE group_id = "${t}"\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no group with id ${e}`):M(F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupInfoByGroupIDOrGroupName",(async function(e,t,r){try{const n=function(e,t,r,n){let i="";const o=`group_id like "%${t}%"`,s=`name like "%${t}%"`;return r&&(i=o),n&&(i=s),n&&r&&(i=o+" or "+s),e.exec(`\n select *\n from local_groups\n where ${i}\n order by create_time desc\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("subtractMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count-1 where group_id = '${t}'\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("addMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count+1 where group_id = '${t}' \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedWorkingGroupIDList",(async function(){try{const e=await Ht(),t=F(O(e)[0],"CamelCase",["displayIsRead"]),r=[];return t.forEach((e=>{2===e.groupType&&r.push(e.groupID)})),M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedWorkingGroupList",(async function(){try{const e=O(await Ht()),t=F(e[0],"CamelCase",["displayIsRead"],{name:"groupName"}).filter((e=>2===e.groupType));return M(JSON.stringify(t))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberAllGroupIDs",(async function(){try{const e=function(e){return e.exec("\n select distinct group_id from local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",["displayIsRead"]).map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroups",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select * from local_groups where group_id in (${r});\n `)}(await Ht(),JSON.parse(e)),r=F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"});return M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertGroup",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{groupName:"name"}));return E(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllGroup",(async function(){try{return function(e){e.exec("\n DELETE FROM local_groups;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberInfoByGroupIDUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_group_members\n WHERE group_id = "${t}" \n AND user_id = "${r}" \n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupMemberList",(async function(){try{const e=function(e){return e.exec("\n SELECT *\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupMemberUserIDList",(async function(){try{const e=function(e){return e.exec("\n SELECT user_id\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberCount",(async function(e){var t,r;try{const n=function(e,t){return e.exec(`\n SELECT count(*) FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(null===(r=null===(t=n[0])||void 0===t?void 0:t.values[0])||void 0===r?void 0:r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupSomeMemberInfo",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_group_members\n where group_id = "${t}"\n and user_id in (${n.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupAdminID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 3\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListSplit",(async function(e,t,r,n,i){try{const o=function(e,t,r,n,i,o){let s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `;return 1===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n LIMIT ${i} OFFSET ${n}\n `),2===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),3===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),4===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),5===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),6===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id != "${o}" \n LIMIT ${i} OFFSET ${n}\n `),e.exec(s)}(await Ht(),e,t,r,n,i);return M(F(o[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberOwnerAndAdmin",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1 \n ORDER BY role_level DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberOwner",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 2\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListSplitByJoinTimeFilter",(async function(e,t,r,n=0,i=1e11,o){try{const s=function(e,t,r,n,i=0,o=1e11,s){let a="";a=0===s.length?`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n And user_id NOT IN (${s.map((e=>`'${e}'`)).join(",")})\n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,JSON.parse(o));return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupOwnerAndAdminByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberUIDListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFieldsRows(t).toString();e.exec(r)}(t,(JSON.parse(e)||[]).map((e=>B(P(e,{faceURL:"user_group_face_url"}))))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupMember",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}" \n and user_id="${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupAllMembers",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_members").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupMemberField",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=v.update().table("local_group_members").setFields(n).where(`group_id = '${t}' and user_id = '${r}'`).toString();e.exec(i)}(n,e,t,B(P(JSON.parse(r),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchGroupMembers",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){let a="";a=r?n&&i?`\n SELECT * FROM local_group_members \n WHERE ( user_id like "%${t}%" or nickname like "%${t}%" ) \n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||i?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`}\n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n&&n?`\n SELECT * FROM local_group_members \n WHERE user_id like "%${t}%" or nickname like "%${t}%" \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||n?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`} \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,o);return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getUserJoinedGroupIDs",(async function(e){try{const t=function(e,t){return e.exec(`\n select group_id from local_group_members where user_id = "${t}";\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListByUserIDs",(async function(e,t,r){try{const n=function(e,t,r,n){const i=n.map((e=>`'${e}'`));let o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `;return 1===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n And user_id IN (${i.join(",")})\n `),2===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),3===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),4===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),5===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),e.exec(o)}(await Ht(),e,t,JSON.parse(r));return M(F(n[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_admin_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAdminGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_admin_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_admin_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAdminGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_admin_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertFriend",(async function(e){try{const t=await Ht();return w(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteFriend",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_friends \n WHERE owner_user_id="${r}" \n and friend_user_id="${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateFriend",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friends").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and friend_user_id = '${t.friend_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllFriendList",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${t}"\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchFriendList",(async function(e,t,r,n){try{const i=function(e,t,r,n,i){let o="";const s=`name like "%${t}%"`,a=`remark like "%${t}%"`;return r&&(o=`friend_user_id like "%${t}%"`),n&&(o=o?o+" or "+s:s),i&&(o=o?o+" or "+a:a),e.exec(`\n select *\n from local_friends\n where ${o}\n order by create_time desc\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendInfoByFriendUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${r}"\n and friend_user_id = "${t}"\n limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no friend with id ${e}`):M(F(r[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select *\n from local_friends\n where friend_user_id in (${r})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getPageFriendList",(async function(e,t,r){try{const n=function(e,t,r,n){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${n}"\n order by name\n limit ${r} offset ${t}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsFriend",(async function(e,t){try{const r=await Ht(),n=B(P(JSON.parse(t),{userID:"friend_user_id",nickname:"name"}));return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(","),i=v.update().table("local_friends").setFields(r).where(`friend_user_id IN (${n})`).toString();e.exec(i)}(r,JSON.parse(e),n),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendListCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n SELECT COUNT(*) FROM local_friends;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertFriend",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{userID:"friend_user_id",nickname:"name"}));return w(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllFriend",(async function(){try{return function(e){e.exec("\n DELETE FROM local_friends;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertTempCacheMessageList",Yt),Kt.registerMethod("InsertTempCacheMessage",(async function(e){return Yt(`[${e}]`)})),Kt.registerMethod("getNotificationAllSeqs",(async function(){try{const e=function(e){return e.exec("SELECT * from local_notification_seqs where 1 = 1;")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertNotificationSeq",(async function(e){try{const t=JSON.parse(e),r=await Ht();return t.map((e=>{const{conversationID:t,seq:n}=e;S(r,t,n)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setNotificationSeq",(async function(e,t){try{const r=await Ht();let n=function(e,t,r){return e.exec(`UPDATE local_notification_seqs set seq = ${r} where conversation_id = "${t}"`)}(r,e,t);return 0===r.getRowsModified()&&(n=S(r,e,t)),M(n[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getExistedTables",(async function(){try{const e=function(e){return e.exec('\n SELECT name FROM sqlite_master WHERE type="table";\n ')}(await Ht());return M(F(e[0],"CamelCase",[],{tbl_name:"tblName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("exec",(async e=>{const t=await Ht();try{const r=t.exec(e);console.info(`sql debug with exec sql = ${e.trim()} , return `,r)}catch(t){console.info(`sql debug with exec sql = ${e} , return `,t)}})),Kt.registerMethod("getRowsModified",(async()=>{const e=await Ht();try{const t=e.getRowsModified();console.info("sql debug with getRowsModified return ",t)}catch(e){console.info("sql debug with getRowsModified return ",e)}})),Kt.registerMethod("exportDB",(async()=>{const e=await Ht();try{const t=e.export(),r=new Blob([t]);return URL.createObjectURL(r)}catch(e){console.info("sql export error, return ",e)}}))}();
|
|
1
|
+
!function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,a=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&s(e,r,t[r]);if(n)for(var r of n(t))o.call(t,r)&&s(e,r,t[r]);return e},u=(e,n)=>t(e,r(n)),c=(e,t,r)=>(s(e,"symbol"!=typeof t?t+"":t,r),r);const l={CONNECT_TIMEOUT:{code:-32300,message:"Connect timeout"},APPLICATION_ERROR:{code:-32500,message:"Application error"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"}};const f=class{constructor(e){c(this,"_event"),c(this,"_methods",{}),c(this,"_timeout",0),c(this,"_$connect",null),this._event=e.event,this._timeout=e.timeout||0,e.methods&&Object.entries(e.methods).forEach((([e,t])=>{this.registerMethod(e,t)})),this._event.onerror=e=>{const{code:t,message:r,data:n}=e;if(n.event&&Array.isArray(n.args)&&n.args.length){const e=n.args[0],i=this._getAckEventName(e.method),o={jsonrpc:"2.0",id:null==e?void 0:e.id,error:{code:t,message:r,data:e}};this._event.emit(i,o)}else console.error(e)},this.connect()}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}_getSynEventName(e){return`${f.EVENT.SYN_SIGN}${e}`}_getAckEventName(e){return`${f.EVENT.ACK_SIGN}${e}`}connect(e){return this._$connect||(this._$connect=new Promise(((t,r)=>{const n=e||this._timeout;let i;n&&(i=setTimeout((()=>{const e=u(a({},l.TIMEOUT),{data:{timeout:n}});r(e)}),n));const o=f.EVENT.CONNECT,s=this._getAckEventName(o),c=this._getSynEventName(o),h=()=>{clearTimeout(i),t()};this._event.on(s,h);this._event.on(c,(()=>{this._event.emit(s),h()})),this._event.emit(c)}))),this._$connect}registerMethod(e,t){if(this._methods[e])throw new Error(`${e} already registered`);this._methods[e]=t;const r=this._getSynEventName(e);this._event.on(r,(r=>{const n=this._getAckEventName(e);r.id?Promise.resolve(t(...r.params)).then((e=>{const t={jsonrpc:"2.0",result:e,id:r.id};this._event.emit(n,t)})).catch((e=>{const t={jsonrpc:"2.0",id:r.id,error:{code:(null==e?void 0:e.code)||l.APPLICATION_ERROR.code,message:(null==e?void 0:e.message)||l.APPLICATION_ERROR.message,data:null}};this._event.emit(n,t)})):t(...r.params)}))}removeMethod(e){this._methods[e]||delete this._methods[e];const t=this._getSynEventName(e);this._event.off(t)}invoke(e,...t){return new Promise(((r,n)=>{const i=t[t.length-1],o=i&&"object"==typeof i&&(Reflect.has(i,"isNotify")||Reflect.has(i,"timeout")),s=o?i:{isNotify:!1,timeout:0},c=o?t.slice(0,-1):t,h=this._getSynEventName(e),d=f.uuid(),_={jsonrpc:"2.0",method:e,params:c,id:d};if(this._event.emit(h,_),s.isNotify)r(void 0);else{const t=this._getAckEventName(e),i=s.timeout||this._timeout;let o;i&&(o=setTimeout((()=>{const e=u(a({},l.CONNECT_TIMEOUT),{data:{timeout:i}});n(e)}),i));const c=e=>{e.id===d&&(clearTimeout(o),this._event.off(t,c),e.error?n(e.error):r(e.result))};this._event.on(t,c)}}))}destroy(){Object.entries(this._methods).forEach((([e])=>{const t=this._getSynEventName(e);this._event.off(t)}));const e=this._getAckEventName(f.EVENT.CONNECT),t=this._getSynEventName(f.EVENT.CONNECT);this._event.off(t),this._event.off(e),this._event.destroy&&this._event.destroy()}};let h=f;c(h,"CODES",l),c(h,"EVENT",{SYN_SIGN:"syn:",ACK_SIGN:"ack:",CONNECT:"__rpc_connect_event",SYNC_METHODS:"__rpc_sync_methods_event"});const d={ErrorInit:10001,ErrorNoRecord:10002,ErrorDBTimeout:10003};var _;!function(e){e.Login="Login",e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnUserTokenInvalid="OnUserTokenInvalid",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvOnlineOnlyMessage="OnRecvOnlineOnlyMessage",e.OnRecvOfflineNewMessage="onRecvOfflineNewMessage",e.OnRecvOnlineOnlyMessages="OnRecvOnlineOnlyMessages",e.OnRecvOfflineNewMessages="onRecvOfflineNewMessages",e.OnRecvMessageRevoked="OnRecvMessageRevoked",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnConversationUserInputStatusChanged="OnConversationUserInputStatusChanged",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerProgress="OnSyncServerProgress",e.OnSyncServerStart="OnSyncServerStart",e.OnTotalUnreadMessageCountChanged="OnTotalUnreadMessageCountChanged",e.OnBlackAdded="OnBlackAdded",e.OnBlackDeleted="OnBlackDeleted",e.OnFriendApplicationAccepted="OnFriendApplicationAccepted",e.OnFriendApplicationAdded="OnFriendApplicationAdded",e.OnFriendApplicationDeleted="OnFriendApplicationDeleted",e.OnFriendApplicationRejected="OnFriendApplicationRejected",e.OnFriendInfoChanged="OnFriendInfoChanged",e.OnFriendAdded="OnFriendAdded",e.OnFriendDeleted="OnFriendDeleted",e.OnJoinedGroupAdded="OnJoinedGroupAdded",e.OnJoinedGroupDeleted="OnJoinedGroupDeleted",e.OnGroupDismissed="OnGroupDismissed",e.OnGroupMemberAdded="OnGroupMemberAdded",e.OnGroupMemberDeleted="OnGroupMemberDeleted",e.OnGroupApplicationAdded="OnGroupApplicationAdded",e.OnGroupApplicationDeleted="OnGroupApplicationDeleted",e.OnGroupInfoChanged="OnGroupInfoChanged",e.OnGroupMemberInfoChanged="OnGroupMemberInfoChanged",e.OnGroupApplicationAccepted="OnGroupApplicationAccepted",e.OnGroupApplicationRejected="OnGroupApplicationRejected",e.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnUploadLogsProgress="OnUploadLogsProgress",e.OnReceiveNewInvitation="OnReceiveNewInvitation",e.OnInviteeAccepted="OnInviteeAccepted",e.OnInviteeRejected="OnInviteeRejected",e.OnInvitationCancelled="OnInvitationCancelled",e.OnHangUp="OnHangUp",e.OnInvitationTimeout="OnInvitationTimeout",e.OnInviteeAcceptedByOtherDevice="OnInviteeAcceptedByOtherDevice",e.OnInviteeRejectedByOtherDevice="OnInviteeRejectedByOtherDevice",e.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal",e.UnUsedEvent="UnUsedEvent"}(_||(_={}));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var m={exports:{}};m.exports=function(){var e=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0},t=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){return e.length?e+t:e}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(e&&n){var o=function(t){"object"===(void 0===t?"undefined":r(t))&&Object.getOwnPropertyNames(t).forEach((function(r){e[r]=t[r]}))},s=!0,a=!1,u=void 0;try{for(var c,l=n[Symbol.iterator]();!(s=(c=l.next()).done);s=!0)o(c.value)}catch(e){a=!0,u=e}finally{try{!s&&l.return&&l.return()}finally{if(a)throw u}}}return e}function u(e){return e&&e.constructor.prototype===Object.prototype}function c(e){return e&&e.constructor.prototype===Array.prototype}function l(e){if(!e)return e;if("function"==typeof e.clone)return e.clone();if(u(e)||c(e)){var t=new e.constructor;return Object.getOwnPropertyNames(e).forEach((function(r){"function"!=typeof e[r]&&(t[r]=l(e[r]))})),t}return JSON.parse(JSON.stringify(e))}function f(e,t,n){var i=void 0===t?"undefined":r(t);if("function"!==i&&"string"!==i)throw new Error("type must be a class constructor or string");if("function"!=typeof n)throw new Error("handler must be a function");var o=!0,s=!1,a=void 0;try{for(var u,c=e[Symbol.iterator]();!(o=(u=c.next()).done);o=!0){var l=u.value;if(l.type===t)return void(l.handler=n)}}catch(e){s=!0,a=e}finally{try{!o&&c.return&&c.return()}finally{if(s)throw a}}e.push({type:t,handler:n})}function h(e,t,r){return d(e,t)||d(e,r)}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];if((void 0===e?"undefined":r(e))===i.type||"string"!=typeof i.type&&e instanceof i.type)return i.handler}}function _(){var d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,_={isSquelBuilder:function(e){return e&&!!e._toParamString}},p=function(e){return!_.isSquelBuilder(e)||!e.options.rawNesting};_.DefaultQueryBuilderOptions={autoQuoteTableNames:!1,autoQuoteFieldNames:!1,autoQuoteAliasNames:!0,useAsForTableAliasNames:!1,nameQuoteCharacter:"`",tableAliasQuoteCharacter:"`",fieldAliasQuoteCharacter:'"',valueHandlers:[],parameterCharacter:"?",numberedParameters:!1,numberedParametersPrefix:"$",numberedParametersStartAt:1,replaceSingleQuotes:!1,singleQuoteReplacement:"''",separator:" ",stringFormatter:null,rawNesting:!1},_.globalValueHandlers=[],_.registerValueHandler=function(e,t){f(_.globalValueHandlers,e,t)},_.Cloneable=function(){function e(){o(this,e)}return t(e,[{key:"clone",value:function(){return a(new this.constructor,l(a({},this)))}}]),e}(),_.BaseBuilder=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this)),r=JSON.parse(JSON.stringify(_.DefaultQueryBuilderOptions));return["stringFormatter"].forEach((function(e){r[e]=_.DefaultQueryBuilderOptions[e]})),t.options=a({},r,e),t}return i(s,e),t(s,[{key:"registerValueHandler",value:function(e,t){return f(this.options.valueHandlers,e,t),this}},{key:"_sanitizeExpression",value:function(e){if(!_.isSquelBuilder(e)&&"string"!=typeof e)throw new Error("expression must be a string or builder instance");return e}},{key:"_sanitizeName",value:function(e,t){if("string"!=typeof e)throw new Error(t+" must be a string");return e}},{key:"_sanitizeField",value:function(e){return _.isSquelBuilder(e)||(e=this._sanitizeName(e,"field name")),e}},{key:"_sanitizeBaseBuilder",value:function(e){if(_.isSquelBuilder(e))return e;throw new Error("must be a builder instance")}},{key:"_sanitizeTable",value:function(e){if("string"!=typeof e)try{e=this._sanitizeBaseBuilder(e)}catch(e){throw new Error("table name must be a string or a builder")}else e=this._sanitizeName(e,"table");return e}},{key:"_sanitizeTableAlias",value:function(e){return this._sanitizeName(e,"table alias")}},{key:"_sanitizeFieldAlias",value:function(e){return this._sanitizeName(e,"field alias")}},{key:"_sanitizeLimitOffset",value:function(e){if(0>(e=parseInt(e))||isNaN(e))throw new Error("limit/offset must be >= 0");return e}},{key:"_sanitizeValue",value:function(e){var t=void 0===e?"undefined":r(e);if(null===e);else if("string"===t||"number"===t||"boolean"===t);else if(_.isSquelBuilder(e));else if(!h(e,this.options.valueHandlers,_.globalValueHandlers))throw new Error("field value must be a string, number, boolean, null or one of the registered custom value types");return e}},{key:"_escapeValue",value:function(e){return this.options.replaceSingleQuotes&&e?e.replace(/\'/g,this.options.singleQuoteReplacement):e}},{key:"_formatTableName",value:function(e){if(this.options.autoQuoteTableNames){var t=this.options.nameQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatFieldAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.fieldAliasQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatTableAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.tableAliasQuoteCharacter;e=""+t+e+t}return this.options.useAsForTableAliasNames?"AS "+e:e}},{key:"_formatFieldName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options.autoQuoteFieldNames){var r=this.options.nameQuoteCharacter;e=t.ignorePeriodsForFieldNameQuotes?""+r+e+r:e.split(".").map((function(e){return"*"===e?e:""+r+e+r})).join(".")}return e}},{key:"_formatCustomValue",value:function(e,t,r){var n=h(e,this.options.valueHandlers,_.globalValueHandlers);return n&&(e=n(e,t,r))&&e.rawNesting?{formatted:!0,rawNesting:!0,value:e.value}:{formatted:!!n,value:e}}},{key:"_formatValueForParamArray",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e)?e.map((function(e){return t._formatValueForParamArray(e,r)})):this._formatCustomValue(e,!0,r).value}},{key:"_formatValueForQueryString",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this._formatCustomValue(e,!1,n),o=i.rawNesting,s=i.formatted,a=i.value;if(s)return o?a:this._applyNestingFormatting(a,p(e));if(c(a))a=a.map((function(e){return t._formatValueForQueryString(e)})),a=this._applyNestingFormatting(a.join(", "),p(a));else{var u=void 0===a?"undefined":r(a);if(null===a)a="NULL";else if("boolean"===u)a=a?"TRUE":"FALSE";else if(_.isSquelBuilder(a))a=this._applyNestingFormatting(a.toString(),p(a));else if("number"!==u){if("string"===u&&this.options.stringFormatter)return this.options.stringFormatter(a);a=n.dontQuote?""+a:"'"+this._escapeValue(a)+"'"}}return a}},{key:"_applyNestingFormatting",value:function(e){if(e&&"string"==typeof e&&(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!this.options.rawNesting){var t="("===e.charAt(0)&&")"===e.charAt(e.length-1);if(t)for(var r=0,n=1;e.length-1>++r;){var i=e.charAt(r);if("("===i)n++;else if(")"===i&&1>--n){t=!1;break}}t||(e="("+e+")")}return e}},{key:"_buildString",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.nested,i=r.buildParameterized,o=r.formattingOptions;t=t||[],e=e||"";for(var s="",a=-1,u=[],l=this.options.parameterCharacter,f=0;e.length>f;)if(e.substr(f,l.length)===l){var h=t[++a];if(i)if(_.isSquelBuilder(h)){var d=h._toParamString({buildParameterized:i,nested:!0});s+=d.text,d.values.forEach((function(e){return u.push(e)}))}else c(h=this._formatValueForParamArray(h,o))?(s+="("+h.map((function(){return l})).join(", ")+")",h.forEach((function(e){return u.push(e)}))):(s+=l,u.push(h));else s+=this._formatValueForQueryString(h,o);f+=l.length}else s+=e.charAt(f),f++;return{text:this._applyNestingFormatting(s,!!n),values:u}}},{key:"_buildManyStrings",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[],i=[],o=0;e.length>o;++o){var s=e[o],a=t[o],u=this._buildString(s,a,{buildParameterized:r.buildParameterized,nested:!1}),c=u.text,l=u.values;n.push(c),l.forEach((function(e){return i.push(e)}))}return{text:(n=n.join(this.options.separator)).length?this._applyNestingFormatting(n,!!r.nested):"",values:i}}},{key:"_toParamString",value:function(e){throw new Error("Not yet implemented")}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(e).text}},{key:"toParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(a({},e,{buildParameterized:!0}))}}]),s}(_.Cloneable),_.Expression=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._nodes=[],t}return i(r,e),t(r,[{key:"and",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e=this._sanitizeExpression(e),this._nodes.push({type:"AND",expr:e,para:r}),this}},{key:"or",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return e=this._sanitizeExpression(e),this._nodes.push({type:"OR",expr:e,para:r}),this}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._nodes[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.type,l=u.expr,f=u.para,h=_.isSquelBuilder(l)?l._toParamString({buildParameterized:e.buildParameterized,nested:!0}):this._buildString(l,f,{buildParameterized:e.buildParameterized}),d=h.text,p=h.values;t.length&&t.push(c),t.push(d),p.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t=t.join(" "),{text:this._applyNestingFormatting(t,!!e.nested),values:r}}}]),r}(_.BaseBuilder),_.Case=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t));return u(e)&&(t=e,e=null),e&&(i._fieldName=i._sanitizeField(e)),i.options=a({},_.DefaultQueryBuilderOptions,t),i._cases=[],i._elseValue=null,i}return i(r,e),t(r,[{key:"when",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return this._cases.unshift({expression:e,values:r||[]}),this}},{key:"then",value:function(e){if(0==this._cases.length)throw new Error("when() needs to be called first");return this._cases[0].result=e,this}},{key:"else",value:function(e){return this._elseValue=e,this}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._cases[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.expression,f=c.values,h=c.result;t=s(t," ");var d=this._buildString(l,f,{buildParameterized:e.buildParameterized,nested:!0});t+="WHEN "+d.text+" THEN "+this._formatValueForQueryString(h),d.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return t.length?(t+=" ELSE "+this._formatValueForQueryString(this._elseValue)+" END",this._fieldName&&(t=this._fieldName+" "+t),t="CASE "+t):t=this._formatValueForQueryString(this._elseValue),{text:t,values:r}}}]),r}(_.BaseBuilder),_.Block=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return i(r,e),t(r,[{key:"exposedMethods",value:function(){for(var e={},t=this;t;)Object.getOwnPropertyNames(t).forEach((function(r){"constructor"===r||"function"!=typeof t[r]||"_"===r.charAt(0)||_.Block.prototype[r]||(e[r]=t[r])})),t=Object.getPrototypeOf(t);return e}}]),r}(_.BaseBuilder),_.StringBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._str=t,i}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._str,values:[]}}}]),r}(_.Block),_.FunctionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._strings=[],t._values=[],t}return i(r,e),t(r,[{key:"function",value:function(e){this._strings.push(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._values.push(r)}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._buildManyStrings(this._strings,this._values,e)}}]),r}(_.Block),_.registerValueHandler(_.FunctionBlock,(function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.toParam():e.toString()})),_.AbstractTableBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._tables=[],i}return i(r,e),t(r,[{key:"_table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t?this._sanitizeTableAlias(t):t,e=this._sanitizeTable(e),this.options.singleTable&&(this._tables=[]),this._tables.push({table:e,alias:t})}},{key:"_hasTable",value:function(){return 0<this._tables.length}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._hasTable()){var n=!0,i=!1,o=void 0;try{for(var a,u=this._tables[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.table,f=c.alias;t=s(t,", ");var h=void 0;if(_.isSquelBuilder(l)){var d=l._toParamString({buildParameterized:e.buildParameterized,nested:!0}),p=d.text,g=d.values;h=p,g.forEach((function(e){return r.push(e)}))}else h=this._formatTableName(l);f&&(h+=" "+this._formatTableAlias(f)),t+=h}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}this.options.prefix&&(t=this.options.prefix+" "+t)}return{text:t,values:r}}}]),r}(_.Block),_.TargetTableBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"target",value:function(e){this._table(e)}}]),r}(_.AbstractTableBlock),_.UpdateTableBlock=function(r){function s(){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return i(s,r),t(s,[{key:"table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("table() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.FromTableBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{prefix:"FROM"})))}return i(r,e),t(r,[{key:"from",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}}]),r}(_.AbstractTableBlock),_.IntoTableBlock=function(r){function s(e){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,a({},e,{prefix:"INTO",singleTable:!0})))}return i(s,r),t(s,[{key:"into",value:function(e){this._table(e)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("into() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.GetFieldBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"fields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(e)){var r=!0,n=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var a=o.value;this.field(a,null,t)}}catch(e){n=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}}else for(var u in e){var l=e[u];this.field(u,l,t)}}},{key:"field",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.queryBuilder,r=e.buildParameterized,n="",i=[],o=!0,a=!1,u=void 0;try{for(var c,l=this._fields[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;n=s(n,", ");var h=f.name,d=f.alias,p=f.options;if("string"==typeof h)n+=this._formatFieldName(h,p);else{var g=h._toParamString({nested:!0,buildParameterized:r});n+=g.text,g.values.forEach((function(e){return i.push(e)}))}d&&(n+=" AS "+this._formatFieldAlias(d))}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}if(!n.length){var m=t&&t.getBlock(_.FromTableBlock);m&&m._hasTable()&&(n="*")}return{text:n,values:i}}}]),r}(_.Block),_.AbstractSetFieldBlock=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._reset(),t}return i(s,e),t(s,[{key:"_reset",value:function(){this._fields=[],this._values=[[]],this._valueOptions=[[]]}},{key:"_set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._values.length>1)throw new Error("Cannot set multiple rows of fields this way.");void 0!==t&&(t=this._sanitizeValue(t)),e=this._sanitizeField(e);var n=this._fields.indexOf(e);-1===n&&(this._fields.push(e),n=this._fields.length-1),this._values[0][n]=t,this._valueOptions[0][n]=r}},{key:"_setFields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===e?"undefined":r(e)))throw new Error("Expected an object but got "+(void 0===e?"undefined":r(e)));for(var n in e)this._set(n,e[n],t)}},{key:"_setFieldsRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(e))throw new Error("Expected an array of objects but got "+(void 0===e?"undefined":r(e)));this._reset();for(var n=0;e.length>n;++n){var i=e[n];for(var o in i){var s=i[o];o=this._sanitizeField(o),s=this._sanitizeValue(s);var a=this._fields.indexOf(o);if(0<n&&-1===a)throw new Error("All fields in subsequent rows must match the fields in the first row");-1===a&&(this._fields.push(o),a=this._fields.length-1),c(this._values[n])||(this._values[n]=[],this._valueOptions[n]=[]),this._values[n][a]=s,this._valueOptions[n][a]=t}}}}]),s}(_.Block),_.SetFieldBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t,r){this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"_toParamString",value:function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized;if(0>=this._fields.length)throw new Error("set() needs to be called");for(var t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._formatFieldName(this._fields[n]),o=this._values[0][n];0>i.indexOf("=")&&(i=i+" = "+this.options.parameterCharacter);var a=this._buildString(i,[o],{buildParameterized:e,formattingOptions:this._valueOptions[0][n]});t+=a.text,a.values.forEach((function(e){return r.push(e)}))}return{text:"SET "+t,values:r}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldValueBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"setFieldsRows",value:function(e,t){this._setFieldsRows(e,t)}},{key:"_toParamString",value:function(){for(var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized,r=this._fields.map((function(t){return e._formatFieldName(t)})).join(", "),n=[],i=[],o=0;o<this._values.length;++o){n[o]="";for(var a=0;a<this._values[o].length;++a){var u=this._buildString(this.options.parameterCharacter,[this._values[o][a]],{buildParameterized:t,formattingOptions:this._valueOptions[o][a]});u.values.forEach((function(e){return i.push(e)})),n[o]=s(n[o],", "),n[o]+=u.text}}return{text:r.length?"("+r+") VALUES ("+n.join("), (")+")":"",values:i}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldsFromQueryBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t._query=null,t}return i(r,e),t(r,[{key:"fromQuery",value:function(e,t){var r=this;this._fields=e.map((function(e){return r._sanitizeField(e)})),this._query=this._sanitizeBaseBuilder(t)}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._fields.length&&this._query){var n=this._query._toParamString({buildParameterized:e.buildParameterized,nested:!0}),i=n.text,o=n.values;t="("+this._fields.join(", ")+") "+this._applyNestingFormatting(i),r=o}return{text:t,values:r}}}]),r}(_.Block),_.DistinctBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"distinct",value:function(){this._useDistinct=!0}},{key:"_toParamString",value:function(){return{text:this._useDistinct?"DISTINCT":"",values:[]}}}]),r}(_.Block),_.GroupByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._groups=[],t}return i(r,e),t(r,[{key:"group",value:function(e){this._groups.push(this._sanitizeField(e))}},{key:"_toParamString",value:function(){return{text:this._groups.length?"GROUP BY "+this._groups.join(", "):"",values:[]}}}]),r}(_.Block),_.AbstractVerbSingleValueBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._value=null,t}return i(r,e),t(r,[{key:"_setValue",value:function(e){this._value=null!==e?this._sanitizeLimitOffset(e):e}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=null!==this._value?this.options.verb+" "+this.options.parameterCharacter:"",r=null!==this._value?[this._value]:[];return this._buildString(t,r,e)}}]),r}(_.Block),_.OffsetBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"OFFSET"})))}return i(r,e),t(r,[{key:"offset",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.LimitBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"LIMIT"})))}return i(r,e),t(r,[{key:"limit",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.AbstractConditionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._conditions=[],t}return i(r,e),t(r,[{key:"_condition",value:function(e){e=this._sanitizeExpression(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._conditions.push({expr:e,values:r||[]})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._conditions[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.expr,l=u.values,f=_.isSquelBuilder(c)?c._toParamString({buildParameterized:e.buildParameterized}):this._buildString(c,l,{buildParameterized:e.buildParameterized});f.text.length&&t.push(f.text),f.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t.length&&(t=t.join(") AND (")),{text:t.length?this.options.verb+" ("+t+")":"",values:r}}}]),r}(_.Block),_.WhereBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"WHERE"})))}return i(r,e),t(r,[{key:"where",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._condition.apply(this,[e].concat(r))}}]),r}(_.AbstractConditionBlock),_.HavingBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"HAVING"})))}return i(r,e),t(r,[{key:"having",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this._condition.apply(this,[e].concat(r))}}]),r}(_.AbstractConditionBlock),_.OrderByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._orders=[],t}return i(r,e),t(r,[{key:"order",value:function(e,t){e=this._sanitizeField(e),"string"!=typeof t&&(void 0===t?t="ASC":null!==t&&(t=t?"ASC":"DESC"));for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];this._orders.push({field:e,dir:t,values:n||[]})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._orders[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,f=l.field,h=l.dir,d=l.values;t=s(t,", ");var _=this._buildString(f,d,{buildParameterized:e.buildParameterized});t+=_.text,c(_.values)&&_.values.forEach((function(e){return r.push(e)})),null!==h&&(t+=" "+h)}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t.length?"ORDER BY "+t:"",values:r}}}]),r}(_.Block),_.JoinBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._joins=[],t}return i(r,e),t(r,[{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"INNER";e=this._sanitizeTable(e,!0),t=t?this._sanitizeTableAlias(t):t,r=r?this._sanitizeExpression(r):r,this._joins.push({type:n,table:e,alias:t,condition:r})}},{key:"left_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT")}},{key:"right_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"RIGHT")}},{key:"outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"OUTER")}},{key:"left_outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT OUTER")}},{key:"full_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"FULL")}},{key:"cross_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"CROSS")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._joins[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table,h=c.alias,d=c.condition;t=s(t,this.options.separator);var p=void 0;if(_.isSquelBuilder(f)){var g=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});g.values.forEach((function(e){return r.push(e)})),p=g.text}else p=this._formatTableName(f);if(t+=l+" JOIN "+p,h&&(t+=" "+this._formatTableAlias(h)),d){t+=" ON ";var m=void 0;m=_.isSquelBuilder(d)?d._toParamString({buildParameterized:e.buildParameterized}):this._buildString(d,[],{buildParameterized:e.buildParameterized}),t+=this._applyNestingFormatting(m.text),m.values.forEach((function(e){return r.push(e)}))}}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.UnionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._unions=[],t}return i(r,e),t(r,[{key:"union",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UNION";e=this._sanitizeTable(e),this._unions.push({type:t,table:e})}},{key:"union_all",value:function(e){this.union(e,"UNION ALL")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._unions[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table;t=s(t,this.options.separator);var h=void 0;if(f instanceof _.BaseBuilder){var d=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});h=d.text,d.values.forEach((function(e){return r.push(e)}))}else t=this._formatTableName(f);t+=l+" "+h}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.QueryBuilder=function(r){function s(e,t){o(this,s);var r=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));r.blocks=t||[];var i=!0,a=!1,u=void 0;try{for(var c,l=r.blocks[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value,h=f.exposedMethods();for(var d in h){var _=h[d];if(void 0!==r[d])throw new Error("Builder already has a builder method called: "+d);!function(e,t,n){r[t]=function(){for(var t=arguments.length,i=Array(t),o=0;o<t;o++)i[o]=arguments[o];return n.call.apply(n,[e].concat(i)),r}}(f,d,_)}}}catch(e){a=!0,u=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw u}}return r}return i(s,r),t(s,[{key:"registerValueHandler",value:function(t,r){var n=!0,i=!1,o=void 0;try{for(var a,u=this.blocks[Symbol.iterator]();!(n=(a=u.next()).done);n=!0)a.value.registerValueHandler(t,r)}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"registerValueHandler",this).call(this,t,r),this}},{key:"updateOptions",value:function(e){this.options=a({},this.options,e);var t=!0,r=!1,n=void 0;try{for(var i,o=this.blocks[Symbol.iterator]();!(t=(i=o.next()).done);t=!0){var s=i.value;s.options=a({},s.options,e)}}catch(e){r=!0,n=e}finally{try{!t&&o.return&&o.return()}finally{if(r)throw n}}}},{key:"_toParamString",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=a({},this.options,t);var r=this.blocks.map((function(r){return r._toParamString({buildParameterized:t.buildParameterized,queryBuilder:e})})),n=r.map((function(e){return e.text})),i=r.map((function(e){return e.values})),o=n.filter((function(e){return 0<e.length})).join(t.separator),s=[];if(i.forEach((function(e){return e.forEach((function(e){return s.push(e)}))})),!t.nested&&t.numberedParameters){var u=void 0!==t.numberedParametersStartAt?t.numberedParametersStartAt:1,c=t.parameterCharacter.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");o=o.replace(new RegExp(c,"g"),(function(){return""+t.numberedParametersPrefix+u++}))}return{text:this._applyNestingFormatting(o,!!t.nested),values:s}}},{key:"clone",value:function(){var e=this.blocks.map((function(e){return e.clone()}));return new this.constructor(this.options,e)}},{key:"getBlock",value:function(e){return this.blocks.filter((function(t){return t instanceof e}))[0]}}]),s}(_.BaseBuilder),_.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"SELECT"),new _.FunctionBlock(e),new _.DistinctBlock(e),new _.GetFieldBlock(e),new _.FromTableBlock(e),new _.JoinBlock(e),new _.WhereBlock(e),new _.GroupByBlock(e),new _.HavingBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e),new _.OffsetBlock(e),new _.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"UPDATE"),new _.UpdateTableBlock(e),new _.SetFieldBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"DELETE"),new _.TargetTableBlock(e),new _.FromTableBlock(a({},e,{singleTable:!0})),new _.JoinBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"INSERT"),new _.IntoTableBlock(e),new _.InsertFieldValueBlock(e),new _.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder);var g={VERSION:"5.13.0",flavour:d,expr:function(e){return new _.Expression(e)},case:function(e,t){return new _.Case(e,t)},select:function(e,t){return new _.Select(e,t)},update:function(e,t){return new _.Update(e,t)},insert:function(e,t){return new _.Insert(e,t)},delete:function(e,t){return new _.Delete(e,t)},str:function(){var e=new _.FunctionBlock;return e.function.apply(e,arguments),e},rstr:function(){var e=new _.FunctionBlock({rawNesting:!0});return e.function.apply(e,arguments),e},registerValueHandler:_.registerValueHandler};return g.remove=g.delete,g.cls=_,g}var p=_();return p.flavours={},p.useFlavour=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return p;if(p.flavours[e]instanceof Function){var t=_(e);return p.flavours[e].call(null,t),t.flavours=p.flavours,t.useFlavour=p.useFlavour,t}throw new Error("Flavour not available: "+e)},p.flavours.mssql=function(r){var u=r.cls;u.DefaultQueryBuilderOptions.replaceSingleQuotes=!0,u.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,u.DefaultQueryBuilderOptions.numberedParametersPrefix="@",r.registerValueHandler(Date,(function(e){return"'"+e.getUTCFullYear()+"-"+(e.getUTCMonth()+1)+"-"+e.getUTCDate()+" "+e.getUTCHours()+":"+e.getUTCMinutes()+":"+e.getUTCSeconds()+"'"})),u.MssqlLimitOffsetTopBlock=function(e){function r(e){o(this,r);var s=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));s._limits=null,s._offsets=null;var a=function(e){e=this._sanitizeLimitOffset(e),this._parent._limits=e};return s.ParentBlock=function(e){function t(e){o(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.options));return r._parent=e,r}return i(t,e),t}(u.Block),s.LimitBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.limit=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&this._parent._offsets&&(e="FETCH NEXT "+this._parent._limits+" ROWS ONLY"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.TopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.top=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&!this._parent._offsets&&(e="TOP ("+this._parent._limits+")"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.OffsetBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"offset",value:function(e){this._parent._offsets=this._sanitizeLimitOffset(e)}},{key:"_toParamString",value:function(){var e="";return this._parent._offsets&&(e="OFFSET "+this._parent._offsets+" ROWS"),{text:e,values:[]}}}]),r}(s.ParentBlock),s}return i(r,e),t(r,[{key:"LIMIT",value:function(){return new this.LimitBlock(this)}},{key:"TOP",value:function(){return new this.TopBlock(this)}},{key:"OFFSET",value:function(){return new this.OffsetBlock(this)}}]),r}(u.Block),u.MssqlUpdateTopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._limits=null,t.limit=t.top=function(e){t._limits=t._sanitizeLimitOffset(e)},t}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._limits?"TOP ("+this._limits+")":"",values:[]}}}]),r}(u.Block),u.MssqlInsertFieldValueBlock=function(r){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._outputs=[],t}return i(s,r),t(s,[{key:"output",value:function(e){var t=this;"string"==typeof e?this._outputs.push("INSERTED."+this._sanitizeField(e)):e.forEach((function(e){t._outputs.push("INSERTED."+t._sanitizeField(e))}))}},{key:"_toParamString",value:function(t){var r=e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t);if(r.text.length&&0<this._outputs.length){var n="OUTPUT "+this._outputs.join(", ")+" ",i=r.text.indexOf("VALUES");r.text=r.text.substr(0,i)+n+r.text.substr(i)}return r}}]),s}(u.InsertFieldValueBlock),u.MssqlUpdateDeleteOutputBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._outputs=[],t}return i(r,e),t(r,[{key:"outputs",value:function(e){for(var t in e)this.output(t,e[t])}},{key:"output",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e=this._sanitizeField(e),t=t?this._sanitizeFieldAlias(t):t,this._outputs.push({name:this.options.forDelete?"DELETED."+e:"INSERTED."+e,alias:t})}},{key:"_toParamString",value:function(e){var t="";if(this._outputs.length){var r=!0,n=!1,i=void 0;try{for(var o,a=this._outputs[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;t=s(t,", "),t+=u.name,u.alias&&(t+=" AS "+this._formatFieldAlias(u.alias))}}catch(e){n=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}t="OUTPUT "+t}return{text:t,values:[]}}}]),r}(u.Block),u.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t);var i=new u.MssqlLimitOffsetTopBlock(e);return r=r||[new u.StringBlock(e,"SELECT"),new u.DistinctBlock(e),i.TOP(),new u.GetFieldBlock(e),new u.FromTableBlock(e),new u.JoinBlock(e),new u.WhereBlock(e),new u.GroupByBlock(e),new u.OrderByBlock(e),i.OFFSET(),i.LIMIT(),new u.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"UPDATE"),new u.MssqlUpdateTopBlock(e),new u.UpdateTableBlock(e),new u.SetFieldBlock(e),new u.MssqlUpdateDeleteOutputBlock(e),new u.WhereBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"DELETE"),new u.TargetTableBlock(e),new u.FromTableBlock(a({},e,{singleTable:!0})),new u.JoinBlock(e),new u.MssqlUpdateDeleteOutputBlock(a({},e,{forDelete:!0})),new u.WhereBlock(e),new u.OrderByBlock(e),new u.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"INSERT"),new u.IntoTableBlock(e),new u.MssqlInsertFieldValueBlock(e),new u.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder)},p.flavours.mysql=function(e){var r=e.cls;r.MysqlOnDuplicateKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onDupUpdate",value:function(e,t,r){this._set(e,t,r)}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._fields[n],o=this._values[0][n],a=this._valueOptions[0][n];if(void 0===o)t+=i;else{var u=this._buildString(i+" = "+this.options.parameterCharacter,[o],{buildParameterized:e.buildParameterized,formattingOptions:a});t+=u.text,u.values.forEach((function(e){return r.push(e)}))}}return{text:t.length?"ON DUPLICATE KEY UPDATE "+t:"",values:r}}}]),r}(r.AbstractSetFieldBlock),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.MysqlOnDuplicateKeyUpdateBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Replace=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"REPLACE"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),e.replace=function(e,t){return new r.Replace(e,t)}},p.flavours.postgres=function(e){var r=e.cls;r.DefaultQueryBuilderOptions.numberedParameters=!0,r.DefaultQueryBuilderOptions.numberedParametersStartAt=1,r.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,r.DefaultQueryBuilderOptions.useAsForTableAliasNames=!0,r.PostgresOnConflictKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onConflict",value:function(e,t){var r=this;this._onConflict=!0,e&&(c(e)||(e=[e]),this._dupFields=e.map(this._sanitizeField.bind(this)),t&&Object.keys(t).forEach((function(e){r._set(e,t[e])})))}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n<this._fields.length;++n){t=s(t,", ");var i=this._fields[n],o=this._values[0][n],a=this._valueOptions[0][n];if(void 0===o)t+=i;else{var u=this._buildString(i+" = "+this.options.parameterCharacter,[o],{buildParameterized:e.buildParameterized,formattingOptions:a});t+=u.text,u.values.forEach((function(e){return r.push(e)}))}}var c={text:"",values:r};if(this._onConflict){var l=this._dupFields?"("+this._dupFields.join(", ")+") ":"",f=t.length?"UPDATE SET "+t:"NOTHING";c.text="ON CONFLICT "+l+"DO "+f}return c}}]),r}(r.AbstractSetFieldBlock),r.ReturningBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"returning",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.queryBuilder;var t=e.buildParameterized,r="",n=[],i=!0,o=!1,a=void 0;try{for(var u,c=this._fields[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;r=s(r,", ");var f=l.name,h=l.alias,d=l.options;if("string"==typeof f)r+=this._formatFieldName(f,d);else{var _=f._toParamString({nested:!0,buildParameterized:t});r+=_.text,_.values.forEach((function(e){return n.push(e)}))}h&&(r+=" AS "+this._formatFieldAlias(h))}}catch(e){o=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(o)throw a}}return{text:r.length>0?"RETURNING "+r:"",values:n}}}]),r}(r.Block),r.WithBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._tables=[],t}return i(r,e),t(r,[{key:"with",value:function(e,t){this._tables.push({alias:e,table:t})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._tables[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.alias,l=u.table._toParamString({buildParameterized:e.buildParameterized,nested:!0});t.push(c+" AS "+l.text),l.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return{text:t.length?"WITH "+t.join(", "):"",values:r}}}]),r}(r.Block),r.DistinctOnBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._distinctFields=[],t}return i(r,e),t(r,[{key:"distinct",value:function(){var e=this;this._useDistinct=!0;for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){e._distinctFields.push(e._sanitizeField(t))}))}},{key:"_toParamString",value:function(){var e="";return this._useDistinct&&(e="DISTINCT",this._distinctFields.length&&(e+=" ON ("+this._distinctFields.join(", ")+")")),{text:e,values:[]}}}]),r}(r.Block),r.Select=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"SELECT"),new r.FunctionBlock(e),new r.DistinctOnBlock(e),new r.GetFieldBlock(e),new r.FromTableBlock(e),new r.JoinBlock(e),new r.WhereBlock(e),new r.GroupByBlock(e),new r.HavingBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.OffsetBlock(e),new r.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.PostgresOnConflictKeyUpdateBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Update=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"UPDATE"),new r.UpdateTableBlock(e),new r.SetFieldBlock(e),new r.FromTableBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Delete=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"DELETE"),new r.TargetTableBlock(e),new r.FromTableBlock(a({},e,{singleTable:!0})),new r.JoinBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder)},p}();var v=p(m.exports);function y(e,t){!function(e,t){e.exec(`\n create table if not exists 'chat_logs_${t}' (\n 'client_msg_id' char(32),\n 'server_msg_id' char(32),\n 'send_id' char(32),\n 'recv_id' char(32),\n 'sender_platform_id' smallint,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'sender_facebackground_color' varchar(255),\n 'session_type' smallint,\n 'msg_from' smallint,\n 'content_type' smallint,\n 'content' varchar(1000),\n 'is_read' tinyint(1),\n 'status' smallint,\n 'seq' int DEFAULT 0,\n 'send_time' int,\n 'create_time' int,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'local_ex' varchar(1024),\n 'envelope_claimed_info' varchar(1024),\n 'transfer_claimed_info' varchar(1024),\n 'is_react' tinyint(1),\n 'is_external_extensions' tinyint(1),\n 'msg_first_modify_time' int,\n PRIMARY KEY ('client_msg_id')\n );\n `)}(e,t)}function b(e){return e.exec("\n select * from local_super_groups;\n ")}function w(e,t){const r=v.insert().into("local_friends").setFields(t).toString();return e.exec(r)}function E(e,t){const r=v.insert().into("local_groups").setFields(t).toString();return e.exec(r)}function O(e){return e.exec("\n SELECT * FROM local_groups\n ")}function S(e,t,r){return e.exec(`INSERT INTO local_notification_seqs (conversation_id, seq) VALUES ("${t}", ${r});`)}function k(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_stranger\n WHERE user_id = (${r.join(",")})\n `)}function R(e){return e.exec("\n SELECT * FROM local_app_sdk_version LIMIT 1\n ")}function N(e,t,r){return e.exec(`\n SELECT * FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}"\n `)}function M(e,t,r){let n=e;return"object"==typeof e&&(n=JSON.stringify(e)),{data:void 0!==e?n:"{}",errCode:t||0,errMsg:r||""}}const x=[["user_id","userID"],["group_id","groupID"],["client_msg_id","clientMsgID"],["server_msg_id","serverMsgID"],["send_id","sendID"],["recv_id","recvID"],["sender_platform_id","senderPlatformID"],["sender_nick_name","senderNickname"],["sender_face_url","senderFaceURL"],["sender_facebackground_color","senderFaceBackgroundColor"],["session_type","sessionType"],["msg_from","msgFrom"],["content_type","contentType"],["content","content"],["is_read","isRead"],["is_react","isReact"],["is_external_extensions","isExternalExtensions"],["msg_first_modify_time","msgFirstModifyTime"],["status","status"],["seq","seq"],["send_time","sendTime"],["create_time","createTime"],["attached_info","attachedInfo"],["ex","ex"],["local_ex","localEx"],["envelope_claimed_info","envelopeClaimedInfo"],["transfer_claimed_info","transferClaimedInfo"],["face_url","faceURL"],["face_background_color","faceBackgroundColor"],["creator_user_id","creatorUserID"],["conversation_id","conversationID"],["owner_user_id","ownerUserID"],["notification_user_id","notificationUserID"],["operator_user_id","operatorUserID"],["from_face_url","fromFaceURL"],["from_user_id","fromUserID"],["from_gender","fromGender"],["from_nickname","fromNickname"],["to_user_id","toUserID"],["to_nickname","toNickname"],["to_face_url","toFaceURL"],["to_gender","toGender"],["req_msg","reqMsg"],["handle_msg","handleMsg"],["handle_time","handleTime"],["handle_result","handleResult"],["handler_user_id","handlerUserID"],["handle_user_id","handleUserID"],["inviter_user_id","inviterUserID"],["mute_end_time","muteEndTime"],["role_level","roleLevel"],["join_time","joinTime"],["join_source","joinSource"],["friend_user_id","friendUserID"],["recv_msg_opt","recvMsgOpt"],["group_at_type","groupAtType"],["latest_msg_send_time","latestMsgSendTime"],["draft_text_time","draftTextTime"],["is_private_chat","isPrivateChat"],["is_not_in_group","isNotInGroup"],["update_unread_count_time","updateUnreadCountTime"],["is_msg_destruct","isMsgDestruct"],["msg_destruct_time","msgDestructTime"],["part_hash","partHash"],["upload_id","uploadID"],["upload_info","uploadInfo"],["expire_time","expireTime"],["entity_id","entityID"],["version_id","versionID"],["display_is_read","displayIsRead"]];function A(e){const t=function(e){const t=x.find((t=>t[0]===e));if(t)return t[1]}(e);if(t)return t;const r=[];let n=-2;for(let t=0;t<e.length;t++){const i=e[t];"_"===i&&t<e.length-1?n=t:t-1===n?r.push(i.toUpperCase()):r.push(i)}return r.join("")}function I(e){const t=function(e){const t=x.find((t=>t[1]===e));if(t)return t[0]}(e);if(t)return t;const r=[];for(let t=0;t<e.length;t++){const n=e[t];n.toLowerCase()!==n&&r.push("_"),r.push(n.toLowerCase())}return r.join("")}const T=/[\0\b\t\n\r\x1a"'\\]/g,C={"\0":"\\0","\b":"\\b","\t":"\\t","\n":"\\n","\r":"\\r","":"\\Z",'"':'\\"',"'":"\\'","\\":"\\\\"};function F(e,t="CamelCase",r=[],n={}){const{columns:i=[],values:o=[]}=e||{},s=[];return o.forEach((e=>{const o={};i.forEach(((i,s)=>{let a=i,u=e[s];"CamelCase"===t&&(a=A(i)),"SnakeCase"===t&&(a=I(i)),r.find((e=>e===a))&&(u=!!u),a=n[i]||a,o[a]=u})),s.push(o)})),s}function B(e,t=!0){const r={};return Object.keys(e).forEach((n=>{let i=e[n];t&&function(e){return"string"==typeof e}(i)&&(i=function(e,t={backslashSupported:!1}){if(null==e)throw new Error("Need to pass a valid string");if(!(t=t||{}).backslashSupported)return"'"+e.replace(/'/g,"''")+"'";const r=T,n=C;let i,o=r.lastIndex=0,s="";for(;i=r.exec(e);)s+=e.slice(o,i.index)+n[i[0]],o=r.lastIndex;return 0===o?"'"+e+"'":o<e.length?"'"+s+e.slice(o)+"'":"'"+s+"'"}(i).slice(1,-1)),r[I(n)]=i})),r}function P(e,t={}){const r={};return Object.keys(e).forEach((n=>{const i=t[n]||n;r[i]=e[n]})),r}var D="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function $(){throw new Error("setTimeout has not been defined")}function L(){throw new Error("clearTimeout has not been defined")}var U=$,q=L;function j(e){if(U===setTimeout)return setTimeout(e,0);if((U===$||!U)&&setTimeout)return U=setTimeout,setTimeout(e,0);try{return U(e,0)}catch(t){try{return U.call(null,e,0)}catch(t){return U.call(this,e,0)}}}"function"==typeof D.setTimeout&&(U=setTimeout),"function"==typeof D.clearTimeout&&(q=clearTimeout);var J,z=[],W=!1,H=-1;function G(){W&&J&&(W=!1,J.length?z=J.concat(z):H=-1,z.length&&Y())}function Y(){if(!W){var e=j(G);W=!0;for(var t=z.length;t;){for(J=z,z=[];++H<t;)J&&J[H].run();H=-1,t=z.length}J=null,W=!1,function(e){if(q===clearTimeout)return clearTimeout(e);if((q===L||!q)&&clearTimeout)return q=clearTimeout,clearTimeout(e);try{return q(e)}catch(t){try{return q.call(null,e)}catch(t){return q.call(this,e)}}}(e)}}function V(e,t){this.fun=e,this.array=t}V.prototype.run=function(){this.fun.apply(null,this.array)};function Q(){}var K=Q,X=Q,Z=Q,ee=Q,te=Q,re=Q,ne=Q;var ie=D.performance||{},oe=ie.now||ie.mozNow||ie.msNow||ie.oNow||ie.webkitNow||function(){return(new Date).getTime()};var se=new Date;var ae={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];z.push(new V(e,t)),1!==z.length||W||j(Y)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:K,addListener:X,once:Z,off:ee,removeListener:te,removeAllListeners:re,emit:ne,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*oe.call(ie),r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r-=e[0],(n-=e[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-se)/1e3}},ue=[],ce=[],le="undefined"!=typeof Uint8Array?Uint8Array:Array,fe=!1;function he(){fe=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)ue[t]=e[t],ce[e.charCodeAt(t)]=t;ce["-".charCodeAt(0)]=62,ce["_".charCodeAt(0)]=63}function de(e,t,r){for(var n,i,o=[],s=t;s<r;s+=3)n=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(ue[(i=n)>>18&63]+ue[i>>12&63]+ue[i>>6&63]+ue[63&i]);return o.join("")}function _e(e){var t;fe||he();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;a<u;a+=s)o.push(de(e,a,a+s>u?u:a+s));return 1===n?(t=e[r-1],i+=ue[t>>2],i+=ue[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ue[t>>10],i+=ue[t>>4&63],i+=ue[t<<2&63],i+="="),o.push(i),o.join("")}function pe(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?i-1:0,h=r?-1:1,d=e[t+f];for(f+=h,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)}function ge(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,_=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=_,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[r+d]=255&s,d+=_,s/=256,c-=8);e[r+d-_]|=128*p}var me={}.toString,ve=Array.isArray||function(e){return"[object Array]"==me.call(e)};function ye(){return we.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function be(e,t){if(ye()<t)throw new RangeError("Invalid typed array length");return we.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=we.prototype:(null===e&&(e=new we(t)),e.length=t),e}function we(e,t,r){if(!(we.TYPED_ARRAY_SUPPORT||this instanceof we))return new we(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Se(this,e)}return Ee(this,e,t,r)}function Ee(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);we.TYPED_ARRAY_SUPPORT?(e=t).__proto__=we.prototype:e=ke(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!we.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Me(t,r);e=be(e,n);var i=e.write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(Ne(t)){var r=0|Re(t.length);return 0===(e=be(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?be(e,0):ke(e,t);if("Buffer"===t.type&&ve(t.data))return ke(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Oe(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Se(e,t){if(Oe(t),e=be(e,t<0?0:0|Re(t)),!we.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function ke(e,t){var r=t.length<0?0:0|Re(t.length);e=be(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function Re(e){if(e>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ne(e){return!(null==e||!e._isBuffer)}function Me(e,t){if(Ne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return rt(e).length;default:if(n)return tt(e).length;t=(""+t).toLowerCase(),n=!0}}function xe(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,r);case"utf8":case"utf-8":return Ue(this,t,r);case"ascii":return je(this,t,r);case"latin1":case"binary":return Je(this,t,r);case"base64":return Le(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return We(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Ae(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Ie(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=we.from(t,n)),Ne(t))return 0===t.length?-1:Te(e,t,r,n,i);if("number"==typeof t)return t&=255,we.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Te(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Te(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var f=!0,h=0;h<u;h++)if(c(e,o+h)!==c(t,h)){f=!1;break}if(f)return o}return-1}function Ce(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function Fe(e,t,r,n){return nt(tt(t,e.length-r),e,r,n)}function Be(e,t,r,n){return nt(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function Pe(e,t,r,n){return Be(e,t,r,n)}function De(e,t,r,n){return nt(rt(t),e,r,n)}function $e(e,t,r,n){return nt(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function Le(e,t,r){return 0===t&&r===e.length?_e(e):_e(e.slice(t,r))}function Ue(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,u,c=e[i],l=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=qe)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=qe));return r}(n)}we.TYPED_ARRAY_SUPPORT=void 0===D.TYPED_ARRAY_SUPPORT||D.TYPED_ARRAY_SUPPORT,ye(),we.poolSize=8192,we._augment=function(e){return e.__proto__=we.prototype,e},we.from=function(e,t,r){return Ee(null,e,t,r)},we.TYPED_ARRAY_SUPPORT&&(we.prototype.__proto__=Uint8Array.prototype,we.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&we[Symbol.species]),we.alloc=function(e,t,r){return function(e,t,r,n){return Oe(t),t<=0?be(e,t):void 0!==r?"string"==typeof n?be(e,t).fill(r,n):be(e,t).fill(r):be(e,t)}(null,e,t,r)},we.allocUnsafe=function(e){return Se(null,e)},we.allocUnsafeSlow=function(e){return Se(null,e)},we.isBuffer=function(e){return null!=e&&(!!e._isBuffer||it(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&it(e.slice(0,0))}(e))},we.compare=function(e,t){if(!Ne(e)||!Ne(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},we.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},we.concat=function(e,t){if(!ve(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return we.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=we.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!Ne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},we.byteLength=Me,we.prototype._isBuffer=!0,we.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Ae(this,t,t+1);return this},we.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Ae(this,t,t+3),Ae(this,t+1,t+2);return this},we.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Ae(this,t,t+7),Ae(this,t+1,t+6),Ae(this,t+2,t+5),Ae(this,t+3,t+4);return this},we.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Ue(this,0,e):xe.apply(this,arguments)},we.prototype.equals=function(e){if(!Ne(e))throw new TypeError("Argument must be a Buffer");return this===e||0===we.compare(this,e)},we.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},we.prototype.compare=function(e,t,r,n,i){if(!Ne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),l=0;l<a;++l)if(u[l]!==c[l]){o=u[l],s=c[l];break}return o<s?-1:s<o?1:0},we.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},we.prototype.indexOf=function(e,t,r){return Ie(this,e,t,r,!0)},we.prototype.lastIndexOf=function(e,t,r){return Ie(this,e,t,r,!1)},we.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ce(this,e,t,r);case"utf8":case"utf-8":return Fe(this,e,t,r);case"ascii":return Be(this,e,t,r);case"latin1":case"binary":return Pe(this,e,t,r);case"base64":return De(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var qe=4096;function je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function Je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function ze(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=et(e[o]);return i}function We(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function He(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,r,n,i,o){if(!Ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function Ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function Ve(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function Qe(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ke(e,t,r,n,i){return i||Qe(e,0,r,4),ge(e,t,r,n,23,4),r+4}function Xe(e,t,r,n,i){return i||Qe(e,0,r,8),ge(e,t,r,n,52,8),r+8}we.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),we.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=we.prototype;else{var i=t-e;r=new we(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},we.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},we.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},we.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},we.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},we.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},we.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},we.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},we.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},we.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},we.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},we.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},we.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},we.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),pe(this,e,!0,23,4)},we.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),pe(this,e,!1,23,4)},we.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),pe(this,e,!0,52,8)},we.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),pe(this,e,!1,52,8)},we.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},we.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},we.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,255,0),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},we.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ve(this,e,t,!0),t+4},we.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,127,-128),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},we.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ve(this,e,t,!0),t+4},we.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeFloatLE=function(e,t,r){return Ke(this,e,t,!0,r)},we.prototype.writeFloatBE=function(e,t,r){return Ke(this,e,t,!1,r)},we.prototype.writeDoubleLE=function(e,t,r){return Xe(this,e,t,!0,r)},we.prototype.writeDoubleBE=function(e,t,r){return Xe(this,e,t,!1,r)},we.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!we.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},we.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!we.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=Ne(e)?e:tt(new we(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var Ze=/[^+\/0-9A-Za-z-_]/g;function et(e){return e<16?"0"+e.toString(16):e.toString(16)}function tt(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function rt(e){return function(e){var t,r,n,i,o,s;fe||he();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new le(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t<n;t+=4,r+=3)i=ce[e.charCodeAt(t)]<<18|ce[e.charCodeAt(t+1)]<<12|ce[e.charCodeAt(t+2)]<<6|ce[e.charCodeAt(t+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=ce[e.charCodeAt(t)]<<2|ce[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=ce[e.charCodeAt(t)]<<10|ce[e.charCodeAt(t+1)]<<4|ce[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ze,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function nt(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function it(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ot={exports:{}};function st(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var at=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ut=function(e){return at.exec(e).slice(1)};function ct(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function lt(e){var t=ft(e),r="/"===yt(e,-1);return(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function ft(e){return"/"===e.charAt(0)}function ht(){return lt(vt(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function dt(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ct(e).substr(1),t=ct(t).substr(1);for(var n=r(e.split("/")),i=r(t.split("/")),o=Math.min(n.length,i.length),s=o,a=0;a<o;a++)if(n[a]!==i[a]){s=a;break}var u=[];for(a=s;a<n.length;a++)u.push("..");return(u=u.concat(i.slice(s))).join("/")}function _t(e){var t=ut(e),r=t[0],n=t[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."}function pt(e,t){var r=ut(e)[2];return t&&r.substr(-1*t.length)===t&&(r=r.substr(0,r.length-t.length)),r}function gt(e){return ut(e)[3]}var mt={extname:gt,basename:pt,dirname:_t,sep:"/",delimiter:":",relative:dt,join:ht,isAbsolute:ft,normalize:lt,resolve:ct};function vt(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n<e.length;n++)t(e[n],n,e)&&r.push(e[n]);return r}var yt="b"==="ab".substr(-1)?function(e,t,r){return e.substr(t,r)}:function(e,t,r){return t<0&&(t=e.length+t),e.substr(t,r)},bt=g(Object.freeze({__proto__:null,resolve:ct,normalize:lt,isAbsolute:ft,join:ht,relative:dt,sep:"/",delimiter:":",dirname:_t,basename:pt,extname:gt,default:mt})),wt=g(Object.freeze({__proto__:null,default:{}})),Et=g(Object.freeze({__proto__:null,default:{}}));!function(e,t){var r=void 0,n=function(t){return r||(r=new Promise((function(r,n){var i,o=(i=void 0!==t?t:{}).onAbort;i.onAbort=function(e){n(new Error(e)),o&&o(e)},i.postRun=i.postRun||[],i.postRun.push((function(){r(i)})),e=void 0,i||(i=void 0!==i?i:{}),i.onRuntimeInitialized=function(){function e(e,t){this.Qa=e,this.db=t,this.Pa=1,this.wb=[]}function t(e,t){if(this.db=t,t=J(e)+1,this.hb=Ue(t),null===this.hb)throw Error("Unable to allocate memory for the SQL string");j(e,F,this.hb,t),this.sb=this.hb,this.eb=this.Mb=null}function r(e,{filename:t=!1}={}){!1===t?(this.filename="dbfile_"+(4294967295*Math.random()>>>0),this.Xc=!0,null!=e&&Re.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(s(this.filename,n)),this.db=R(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Ye(4),o=i.cwrap,s=o("sqlite3_open","number",["string","number"]),a=o("sqlite3_close_v2","number",["number"]),u=o("sqlite3_exec","number",["number","string","number","number","number"]),c=o("sqlite3_changes","number",["number"]),l=o("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=o("sqlite3_sql","string",["number"]),h=o("sqlite3_normalized_sql","string",["number"]),d=o("sqlite3_prepare_v2","number",["number","number","number","number","number"]),_=o("sqlite3_bind_text","number",["number","number","number","number","number"]),p=o("sqlite3_bind_blob","number",["number","number","number","number","number"]),g=o("sqlite3_bind_double","number",["number","number","number"]),m=o("sqlite3_bind_int","number",["number","number","number"]),v=o("sqlite3_bind_parameter_index","number",["number","string"]),y=o("sqlite3_step","number",["number"]),b=o("sqlite3_errmsg","string",["number"]),w=o("sqlite3_column_count","number",["number"]),E=o("sqlite3_data_count","number",["number"]),N=o("sqlite3_column_double","number",["number","number"]),M=o("sqlite3_column_text","string",["number","number"]),x=o("sqlite3_column_blob","number",["number","number"]),A=o("sqlite3_column_bytes","number",["number","number"]),T=o("sqlite3_column_type","number",["number","number"]),B=o("sqlite3_column_name","string",["number","number"]),P=o("sqlite3_reset","number",["number"]),D=o("sqlite3_clear_bindings","number",["number"]),$=o("sqlite3_finalize","number",["number"]),L=o("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),U=o("sqlite3_value_type","number",["number"]),z=o("sqlite3_value_bytes","number",["number"]),W=o("sqlite3_value_text","string",["number"]),H=o("sqlite3_value_blob","number",["number"]),G=o("sqlite3_value_double","number",["number"]),Y=o("sqlite3_result_double","",["number","number"]),V=o("sqlite3_result_null","",["number"]),Q=o("sqlite3_result_text","",["number","string","number","number"]),K=o("sqlite3_result_blob","",["number","number","number","number"]),X=o("sqlite3_result_int","",["number","number"]),Z=o("sqlite3_result_error","",["number","string","number"]),ee=o("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=y(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),N(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),M(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=A(this.Qa,e);e=x(this.Qa,e);for(var r=new Uint8Array(t),n=0;n<t;n+=1)r[n]=C[e+n];return r},e.prototype.get=function(e){null!=e&&this.bind(e)&&this.step(),e=[];for(var t=E(this.Qa),r=0;r<t;r+=1)switch(T(this.Qa,r)){case 1:case 2:e.push(this.Pc(r));break;case 3:e.push(this.Qc(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},e.prototype.getColumnNames=function(){for(var e=[],t=w(this.Qa),r=0;r<t;r+=1)e.push(B(this.Qa,r));return e},e.prototype.getAsObject=function(e){e=this.get(e);for(var t=this.getColumnNames(),r={},n=0;n<t.length;n+=1)r[t[n]]=e[n];return r},e.prototype.getSQL=function(){return f(this.Qa)},e.prototype.getNormalizedSQL=function(){return h(this.Qa)},e.prototype.run=function(e){return null!=e&&this.bind(e),this.step(),this.reset()},e.prototype.zc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1);var r=I(e=De(e));this.wb.push(r),this.db.handleError(_(this.Qa,t,r,e.length-1,0))},e.prototype.uc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1);var r=I(e);this.wb.push(r),this.db.handleError(p(this.Qa,t,r,e.length,0))},e.prototype.yc=function(e,t){null==t&&(t=this.Pa,this.Pa+=1),this.db.handleError((e===(0|e)?m:g)(this.Qa,t,e))},e.prototype.xc=function(e){null==e&&(e=this.Pa,this.Pa+=1),p(this.Qa,e,0,0,0)},e.prototype.Tb=function(e,t){switch(null==t&&(t=this.Pa,this.Pa+=1),typeof e){case"string":return void this.zc(e,t);case"number":case"boolean":return void this.yc(e+0,t);case"object":if(null===e)return void this.xc(t);if(null!=e.length)return void this.uc(e,t)}throw"Wrong API use : tried to bind a value of an unknown type ("+e+")."},e.prototype.wc=function(e){var t=this;return Object.keys(e).forEach((function(r){var n=v(t.Qa,r);0!==n&&t.Tb(e[r],n)})),!0},e.prototype.vc=function(e){for(var t=0;t<e.length;t+=1)this.Tb(e[t],t+1);return!0},e.prototype.reset=function(){return 0===D(this.Qa)&&0===P(this.Qa)},e.prototype.freemem=function(){for(var e;void 0!==(e=this.wb.pop());)qe(e)},e.prototype.free=function(){var e=0===$(this.Qa);return delete this.db.nb[this.Qa],this.Qa=0,e},t.prototype.next=function(){if(null===this.hb)return{done:!0};if(null!==this.eb&&(this.eb.free(),this.eb=null),!this.db.db)throw this.Bb(),Error("Database closed");var t=He(),r=Ye(4);k(n),k(r);try{this.db.handleError(d(this.db.db,this.sb,-1,n,r)),this.sb=R(r,"i32");var i=R(n,"i32");return 0===i?(this.Bb(),{done:!0}):(this.eb=new e(i,this.db),this.db.nb[i]=this.eb,{value:this.eb,done:!1})}catch(e){throw this.Mb=q(this.sb),this.Bb(),e}finally{Ge(t)}},t.prototype.Bb=function(){qe(this.hb),this.hb=null},t.prototype.getRemainingSQL=function(){return null!==this.Mb?this.Mb:q(this.sb)},"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator&&(t.prototype[Symbol.iterator]=function(){return this}),r.prototype.run=function(e,t){if(!this.db)throw"Database closed";if(t){e=this.prepare(e,t);try{e.step()}finally{e.free()}}else this.handleError(u(this.db,e,0,0,n));return this},r.prototype.exec=function(t,r){if(!this.db)throw"Database closed";var i=He(),o=null;try{var s=J(t)+1,a=Ye(s);j(t,C,a,s);var u=a,c=Ye(4);for(t=[];0!==R(u,"i8");){k(n),k(c),this.handleError(d(this.db,u,-1,n,c));var l=R(n,"i32");if(u=R(c,"i32"),0!==l){for(s=null,o=new e(l,this),null!=r&&o.bind(r);o.step();)null===s&&(s={columns:o.getColumnNames(),values:[]},t.push(s)),s.values.push(o.get());o.free()}}return t}catch(e){throw o&&o.free(),e}finally{Ge(i)}},r.prototype.each=function(e,t,r,n){"function"==typeof t&&(n=r,r=t,t=void 0),e=this.prepare(e,t);try{for(;e.step();)r(e.getAsObject())}finally{e.free()}if("function"==typeof n)return n()},r.prototype.prepare=function(t,r){if(k(n),this.handleError(l(this.db,t,-1,n,0)),0===(t=R(n,"i32")))throw"Nothing to prepare";var i=new e(t,this);return null!=r&&i.bind(r),this.nb[t]=i},r.prototype.iterateStatements=function(e){return new t(e,this)},r.prototype.export=function(){Object.values(this.nb).forEach((function(e){e.free()})),Object.values(this.Xa).forEach(O),this.Xa={},this.handleError(a(this.db));var e=Re.readFile(this.filename,{encoding:"binary"});return this.handleError(s(this.filename,n)),this.db=R(n,"i32"),e},r.prototype.close=function(){null!==this.db&&(Object.values(this.nb).forEach((function(e){e.free()})),Object.values(this.Xa).forEach(O),this.Xa={},this.handleError(a(this.db)),this.Xc&&Re.unlink("/"+this.filename),this.db=null)},r.prototype.handleError=function(e){if(0===e)return null;throw e=b(this.db),Error(e)},r.prototype.getRowsModified=function(){return c(this.db)},r.prototype.create_function=function(e,t){Object.prototype.hasOwnProperty.call(this.Xa,e)&&(O(this.Xa[e]),delete this.Xa[e]);var r=S((function(e,r,n){for(var i,o=[],s=0;s<r;s+=1){var a=R(n+4*s,"i32"),u=U(a);if(1===u||2===u)a=G(a);else if(3===u)a=W(a);else if(4===u){a=z(u=a),u=H(u);for(var c=new Uint8Array(a),l=0;l<a;l+=1)c[l]=C[u+l];a=c}else a=null;o.push(a)}try{i=t.apply(null,o)}catch(t){return void Z(e,t,-1)}switch(typeof i){case"boolean":X(e,i?1:0);break;case"number":Y(e,i);break;case"string":Q(e,i,-1,-1);break;case"object":null===i?V(e):null!=i.length?(r=I(i),K(e,r,i.length,-1),qe(r)):Z(e,"Wrong API use : tried to return a value of an unknown type ("+i+").",-1);break;default:V(e)}}),"viii");return this.Xa[e]=r,this.handleError(L(this.db,e,t.length,1,0,r,0,0,0)),this},i.Database=r;var te=new Map;i.register_for_idb=e=>{let t=S((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=S((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=S((function(e,t){e=q(e),te.set(t,e)}),"vii");i._register_for_idb(t,r,n)},i.cleanup_file=e=>{let t=[...te.entries()].find((t=>t[1]===e));te.delete(t[0])},i.reset_filesystem=()=>{Re.root=null,Re.lc()}};var s,a={};for(s in i)i.hasOwnProperty(s)&&(a[s]=i[s]);var u,c,l,f,h,d="./this.program",_="object"==typeof window,p="function"==typeof importScripts,g="object"==typeof ae&&"object"==typeof ae.versions&&"string"==typeof ae.versions.node,m="";g?(m=p?bt.dirname(m)+"/":"/Users/mac/Documents/cid/sdk/openim-sdk-js-wasm/node_modules/@jlongster/sql.js/dist/",u=function(e,t){return f||(f=wt),h||(h=bt),e=h.normalize(e),f.readFileSync(e,t?null:"utf8")},l=function(e){return(e=u(e,!0)).buffer||(e=new Uint8Array(e)),x(e.buffer),e},c=function(e,t,r){f||(f=wt),h||(h=bt),e=h.normalize(e),f.readFile(e,(function(e,n){e?r(e):t(n.buffer)}))},1<ae.argv.length&&(d=ae.argv[1].replace(/\\/g,"/")),ae.argv.slice(2),e.exports=i,i.inspect=function(){return"[Emscripten Module object]"}):(_||p)&&(p?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),m=0!==m.indexOf("blob:")?m.substr(0,m.lastIndexOf("/")+1):"",u=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},p&&(l=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),c=function(e,t,r){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)});var v=i.print||console.log.bind(console),y=i.printErr||console.warn.bind(console);for(s in a)a.hasOwnProperty(s)&&(i[s]=a[s]);a=null,i.thisProgram&&(d=i.thisProgram);var b,w,E=[];function O(e){b.delete(H.get(e)),E.push(e)}function S(e,t){if(!b){b=new WeakMap;for(var r=0;r<H.length;r++){var n=H.get(r);n&&b.set(n,r)}}if(b.has(e))e=b.get(e);else{if(E.length)r=E.pop();else{try{H.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}r=H.length-1}try{H.set(r,e)}catch(a){if(!(a instanceof TypeError))throw a;if("function"==typeof WebAssembly.Function){var i={i:"i32",j:"i64",f:"f32",d:"f64"},o={parameters:[],results:"v"==t[0]?[]:[i[t[0]]]};for(n=1;n<t.length;++n)o.parameters.push(i[t[n]]);t=new WebAssembly.Function(o,e)}else{i=[1,0,1,96],o=t.slice(0,1),t=t.slice(1);var s={i:127,j:126,f:125,d:124};for(i.push(t.length),n=0;n<t.length;++n)i.push(s[t[n]]);"v"==o?i.push(0):i=i.concat([1,s[o]]),i[1]=i.length-2,t=new Uint8Array([0,97,115,109,1,0,0,0].concat(i,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),t=new WebAssembly.Module(t),t=new WebAssembly.Instance(t,{e:{f:e}}).exports.f}H.set(r,t)}b.set(e,r),e=r}return e}function k(e){var t="i32";switch("*"===t.charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":C[e>>0]=0;break;case"i16":B[e>>1]=0;break;case"i32":P[e>>2]=0;break;case"i64":Z=[0,(X=0,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[e>>2]=Z[0],P[e+4>>2]=Z[1];break;case"float":D[e>>2]=0;break;case"double":$[e>>3]=0;break;default:oe("invalid type for setValue: "+t)}}function R(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return C[e>>0];case"i16":return B[e>>1];case"i32":case"i64":return P[e>>2];case"float":return D[e>>2];case"double":return $[e>>3];default:oe("invalid type for getValue: "+t)}return null}i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&oe("no native wasm support detected");var N,M=!1;function x(e,t){e||oe("Assertion failed: "+t)}function A(e){var t=i["_"+e];return x(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function I(e){var t=Ue(e.length);return e.subarray||e.slice?F.set(e,t):F.set(new Uint8Array(e),t),t}var T,C,F,B,P,D,$,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,r){var n=t+r;for(r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.subarray&&L)return L.decode(e.subarray(t,r));for(n="";t<r;){var i=e[t++];if(128&i){var o=63&e[t++];if(192==(224&i))n+=String.fromCharCode((31&i)<<6|o);else{var s=63&e[t++];65536>(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function q(e,t){return e?U(F,e,t):""}function j(e,t,r,n){if(!(0<n))return 0;var i=r;n=r+n-1;for(var o=0;o<e.length;++o){var s=e.charCodeAt(o);if(55296<=s&&57343>=s)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(127>=s){if(r>=n)break;t[r++]=s}else{if(2047>=s){if(r+1>=n)break;t[r++]=192|s>>6}else{if(65535>=s){if(r+2>=n)break;t[r++]=224|s>>12}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63}t[r++]=128|s>>6&63}t[r++]=128|63&s}}return t[r]=0,r-i}function J(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);55296<=n&&57343>=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function z(e){var t=J(e)+1,r=Ue(t);return r&&j(e,C,r,t),r}function W(){var e=N.buffer;T=e,i.HEAP8=C=new Int8Array(e),i.HEAP16=B=new Int16Array(e),i.HEAP32=P=new Int32Array(e),i.HEAPU8=F=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=D=new Float32Array(e),i.HEAPF64=$=new Float64Array(e)}var H,G=[],Y=[],V=[];function Q(){var e=i.preRun.shift();G.unshift(e)}var K,X,Z,ee,te=0,re=null;function ne(){te++,i.monitorRunDependencies&&i.monitorRunDependencies(te)}function ie(){if(te--,i.monitorRunDependencies&&i.monitorRunDependencies(te),0==te&&re){var e=re;re=null,e()}}function oe(e){throw i.onAbort&&i.onAbort(e),y(e),M=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function se(){return K.startsWith("data:application/octet-stream;base64,")}if(i.preloadedImages={},i.preloadedAudios={},K="sql-wasm.wasm",!se()){var ue=K;K=i.locateFile?i.locateFile(ue,m):m+ue}function ce(){var e=K;try{if(e==K&&w)return new Uint8Array(w);if(l)return l(e);throw"both async and sync fetching of the wasm failed"}catch(e){oe(e)}}function le(e){for(;0<e.length;){var t=e.shift();if("function"==typeof t)t(i);else{var r=t.pd;"number"==typeof r?void 0===t.yb?H.get(r)():H.get(r)(t.yb):r(void 0===t.yb?null:t.yb)}}}function fe(e,t){for(var r=0,n=e.length-1;0<=n;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e}function he(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=fe(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function de(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function _e(e){if("/"===e)return"/";var t=(e=(e=he(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)}function pe(e,t){return he(e+"/"+t)}function ge(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:Re.cwd()))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=fe(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."}function me(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;0<=r&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ge(e).substr(1),t=ge(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o<n;o++)if(e[o]!==t[o]){i=o;break}for(n=[],o=i;o<e.length;o++)n.push("..");return(n=n.concat(t.slice(i))).join("/")}var ve=[];function ye(e,t){ve[e]={input:[],output:[],gb:t},Re.Qb(e,be)}var be={open:function(e){var t=ve[e.node.rdev];if(!t)throw new Re.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.gb.flush(e.tty)},flush:function(e){e.tty.gb.flush(e.tty)},read:function(e,t,r,n){if(!e.tty||!e.tty.gb.cc)throw new Re.ErrnoError(60);for(var i=0,o=0;o<n;o++){try{var s=e.tty.gb.cc(e.tty)}catch(e){throw new Re.ErrnoError(29)}if(void 0===s&&0===i)throw new Re.ErrnoError(6);if(null==s)break;i++,t[r+o]=s}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,r,n){if(!e.tty||!e.tty.gb.Nb)throw new Re.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.gb.Nb(e.tty,t[r+i])}catch(e){throw new Re.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},Ee={cc:function(e){if(!e.input.length){var t=null;if(g){var r=we.alloc(256),n=0;try{n=f.readSync(ae.stdin.fd,r,0,256,null)}catch(e){if(!e.toString().includes("EOF"))throw e;n=0}t=0<n?r.slice(0,n).toString("utf-8"):null}else"undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&(null!==(t=readline())&&(t+="\n"));if(!t)return null;e.input=De(t,!0)}return e.input.shift()},Nb:function(e,t){null===t||10===t?(v(U(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(v(U(e.output,0)),e.output=[])}},Oe={Nb:function(e,t){null===t||10===t?(y(U(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&0<e.output.length&&(y(U(e.output,0)),e.output=[])}};function Se(e){e=65536*Math.ceil(e/65536);var t=Ve(65536,e);return t?(F.fill(0,t,t+e),t):0}var ke={Va:null,mount:function(){return ke.createNode(null,"/",16895,0)},createNode:function(e,t,r,n){if(Re.Rc(r)||Re.isFIFO(r))throw new Re.ErrnoError(63);return ke.Va||(ke.Va={dir:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr,lookup:ke.node_ops.lookup,mknod:ke.node_ops.mknod,rename:ke.node_ops.rename,unlink:ke.node_ops.unlink,rmdir:ke.node_ops.rmdir,readdir:ke.node_ops.readdir,symlink:ke.node_ops.symlink},stream:{llseek:ke.stream_ops.llseek}},file:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr},stream:{llseek:ke.stream_ops.llseek,read:ke.stream_ops.read,write:ke.stream_ops.write,allocate:ke.stream_ops.allocate,mmap:ke.stream_ops.mmap,msync:ke.stream_ops.msync}},link:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr,readlink:ke.node_ops.readlink},stream:{}},Vb:{node:{getattr:ke.node_ops.getattr,setattr:ke.node_ops.setattr},stream:Re.Cc}}),r=Re.createNode(e,t,r,n),Re.isDir(r.mode)?(r.node_ops=ke.Va.dir.node,r.stream_ops=ke.Va.dir.stream,r.Na={}):Re.isFile(r.mode)?(r.node_ops=ke.Va.file.node,r.stream_ops=ke.Va.file.stream,r.Ra=0,r.Na=null):Re.fb(r.mode)?(r.node_ops=ke.Va.link.node,r.stream_ops=ke.Va.link.stream):Re.pb(r.mode)&&(r.node_ops=ke.Va.Vb.node,r.stream_ops=ke.Va.Vb.stream),r.timestamp=Date.now(),e&&(e.Na[t]=r,e.timestamp=r.timestamp),r},qd:function(e){return e.Na?e.Na.subarray?e.Na.subarray(0,e.Ra):new Uint8Array(e.Na):new Uint8Array(0)},Zb:function(e,t){var r=e.Na?e.Na.length:0;r>=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0<e.Ra&&e.Na.set(r.subarray(0,e.Ra),0))},gd:function(e,t){if(e.Ra!=t)if(0==t)e.Na=null,e.Ra=0;else{var r=e.Na;e.Na=new Uint8Array(t),r&&e.Na.set(r.subarray(0,Math.min(t,e.Ra))),e.Ra=t}},node_ops:{getattr:function(e){var t={};return t.dev=Re.pb(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,Re.isDir(e.mode)?t.size=4096:Re.isFile(e.mode)?t.size=e.Ra:Re.fb(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.Ac=4096,t.blocks=Math.ceil(t.size/t.Ac),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ke.gd(e,t.size)},lookup:function(){throw Re.Db[44]},mknod:function(e,t,r,n){return ke.createNode(e,t,r,n)},rename:function(e,t,r){if(Re.isDir(e.mode)){try{var n=Re.lookupNode(t,r)}catch(e){}if(n)for(var i in n.Na)throw new Re.ErrnoError(55)}delete e.parent.Na[e.name],e.parent.timestamp=Date.now(),e.name=r,t.Na[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.Na[t],e.timestamp=Date.now()},rmdir:function(e,t){var r,n=Re.lookupNode(e,t);for(r in n.Na)throw new Re.ErrnoError(55);delete e.Na[t],e.timestamp=Date.now()},readdir:function(e){var t,r=[".",".."];for(t in e.Na)e.Na.hasOwnProperty(t)&&r.push(t);return r},symlink:function(e,t,r){return(e=ke.createNode(e,t,41471,0)).link=r,e},readlink:function(e){if(!Re.fb(e.mode))throw new Re.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,n,i){var o=e.node.Na;if(i>=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;n<e;n++)t[r+n]=o[i+n];return e},write:function(e,t,r,n,i,o){if(t.buffer===C.buffer&&(o=!1),!n)return 0;if((e=e.node).timestamp=Date.now(),t.subarray&&(!e.Na||e.Na.subarray)){if(o)return e.Na=t.subarray(r,r+n),e.Ra=n;if(0===e.Ra&&0===i)return e.Na=t.slice(r,r+n),e.Ra=n;if(i+n<=e.Ra)return e.Na.set(t.subarray(r,r+n),i),n}if(ke.Zb(e,i+n),e.Na.subarray&&t.subarray)e.Na.set(t.subarray(r,r+n),i);else for(o=0;o<n;o++)e.Na[i+o]=t[r+o];return e.Ra=Math.max(e.Ra,i+n),n},llseek:function(e,t,r){if(1===r?t+=e.position:2===r&&Re.isFile(e.node.mode)&&(t+=e.node.Ra),0>t)throw new Re.ErrnoError(28);return t},allocate:function(e,t,r){ke.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new Re.ErrnoError(28);if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==T){if((0<n||n+r<e.length)&&(e=e.subarray?e.subarray(n,n+r):Array.prototype.slice.call(e,n,n+r)),n=!0,!(r=Se(r)))throw new Re.ErrnoError(48);C.set(e,r)}else n=!1,r=e.byteOffset;return{ed:r,vb:n}},msync:function(e,t,r,n,i){if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);return 2&i||ke.stream_ops.write(e,t,0,n,r,!1),0}}};var Re={root:null,mb:[],Xb:{},streams:[],Zc:1,Ua:null,Wb:"/",Hb:!1,hc:!0,Sa:{},nc:{kc:{qc:1,rc:2}},ErrnoError:null,Db:{},Lc:null,tb:0,lookupPath:function(e,t){if(t=t||{},!(e=ge(Re.cwd(),e)))return{path:"",node:null};var r,n={Cb:!0,Pb:0};for(r in n)void 0===t[r]&&(t[r]=n[r]);if(8<t.Pb)throw new Re.ErrnoError(32);e=fe(e.split("/").filter((function(e){return!!e})),!1);var i=Re.root;for(n="/",r=0;r<e.length;r++){var o=r===e.length-1;if(o&&t.parent)break;if(i=Re.lookupNode(i,e[r]),n=pe(n,e[r]),Re.ab(i)&&(!o||o&&t.Cb)&&(i=i.lb.root),!o||t.Ta)for(o=0;Re.fb(i.mode);)if(i=Re.readlink(n),n=ge(de(n),i),i=Re.lookupPath(n,{Pb:t.Pb}).node,40<o++)throw new Re.ErrnoError(32)}return{path:n,node:i}},Ya:function(e){for(var t;;){if(Re.isRoot(e))return e=e.mount.jc,t?"/"!==e[e.length-1]?e+"/"+t:e+t:e;t=t?e.name+"/"+t:e.name,e=e.parent}},Gb:function(e,t){for(var r=0,n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return(e+r>>>0)%Re.Ua.length},ec:function(e){var t=Re.Gb(e.parent.id,e.name);e.cb=Re.Ua[t],Re.Ua[t]=e},fc:function(e){var t=Re.Gb(e.parent.id,e.name);if(Re.Ua[t]===e)Re.Ua[t]=e.cb;else for(t=Re.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=Re.Vc(e);if(r)throw new Re.ErrnoError(r,e);for(r=Re.Ua[Re.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return Re.lookup(e,t)},createNode:function(e,t,r,n){return e=new Re.FSNode(e,t,r,n),Re.ec(e),e},Ab:function(e){Re.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=Re.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return Re.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=Re.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return Re.lookupNode(e,t),20}catch(e){}return Re.Za(e,"wx")},qb:function(e,t,r){try{var n=Re.lookupNode(e,t)}catch(e){return e.Oa}if(e=Re.Za(e,"wx"))return e;if(r){if(!Re.isDir(n.mode))return 54;if(Re.isRoot(n)||Re.Ya(n)===Re.cwd())return 10}else if(Re.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?Re.fb(e.mode)?32:Re.isDir(e.mode)&&("r"!==Re.$b(t)||512&t)?31:Re.Za(e,Re.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||Re.oc,e=e||0;e<=t;e++)if(!Re.streams[e])return e;throw new Re.ErrnoError(33)},$a:function(e){return Re.streams[e]},Jc:function(e,t,r){Re.ub||(Re.ub=function(){},Re.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new Re.ub;for(n in e)i[n]=e[n];return e=i,t=Re.$c(t,r),e.fd=t,Re.streams[t]=e},Dc:function(e){Re.streams[e]=null},Cc:{open:function(e){e.stream_ops=Re.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Re.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){Re.Xb[e]={stream_ops:t}},Oc:function(e){return Re.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return Re.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),Re.tb++,1<Re.tb&&y("warning: "+Re.tb+" FS.syncfs operations in flight at once, probably just doing extra work");var i=Re.bc(Re.root.mount),o=0;i.forEach((function(t){if(!t.type.mc)return n(null);t.type.mc(t,e,n)}))},mount:function(e,t,r){var n="/"===r,i=!r;if(n&&Re.root)throw new Re.ErrnoError(10);if(!n&&!i){var o=Re.lookupPath(r,{Cb:!1});if(r=o.path,o=o.node,Re.ab(o))throw new Re.ErrnoError(10);if(!Re.isDir(o.mode))throw new Re.ErrnoError(54)}return t={type:e,vd:t,jc:r,mb:[]},(e=e.mount(t)).mount=t,t.root=e,n?Re.root=e:o&&(o.lb=t,o.mount&&o.mount.mb.push(t)),e},yd:function(e){if(e=Re.lookupPath(e,{Cb:!1}),!Re.ab(e.node))throw new Re.ErrnoError(28);var t=(e=e.node).lb,r=Re.bc(t);Object.keys(Re.Ua).forEach((function(e){for(e=Re.Ua[e];e;){var t=e.cb;r.includes(e.mount)&&Re.Ab(e),e=t}})),e.lb=null,e.mount.mb.splice(e.mount.mb.indexOf(t),1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var n=Re.lookupPath(e,{parent:!0}).node;if(!(e=_e(e))||"."===e||".."===e)throw new Re.ErrnoError(28);var i=Re.Lb(n,e);if(i)throw new Re.ErrnoError(i);if(!n.node_ops.mknod)throw new Re.ErrnoError(63);return n.node_ops.mknod(n,e,t,r)},create:function(e,t){return Re.mknod(e,4095&(void 0!==t?t:438)|32768,0)},mkdir:function(e,t){return Re.mknod(e,1023&(void 0!==t?t:511)|16384,0)},td:function(e,t){e=e.split("/");for(var r="",n=0;n<e.length;++n)if(e[n]){r+="/"+e[n];try{Re.mkdir(r,t)}catch(e){if(20!=e.Oa)throw e}}},rb:function(e,t,r){return void 0===r&&(r=t,t=438),Re.mknod(e,8192|t,r)},symlink:function(e,t){if(!ge(e))throw new Re.ErrnoError(44);var r=Re.lookupPath(t,{parent:!0}).node;if(!r)throw new Re.ErrnoError(44);t=_e(t);var n=Re.Lb(r,t);if(n)throw new Re.ErrnoError(n);if(!r.node_ops.symlink)throw new Re.ErrnoError(63);return r.node_ops.symlink(r,t,e)},rename:function(e,t){var r=de(e),n=de(t),i=_e(e),o=_e(t),s=Re.lookupPath(e,{parent:!0}),a=s.node;if(s=(s=Re.lookupPath(t,{parent:!0})).node,!a||!s)throw new Re.ErrnoError(44);if(a.mount!==s.mount)throw new Re.ErrnoError(75);var u=Re.lookupNode(a,i);if("."!==(n=me(e,n)).charAt(0))throw new Re.ErrnoError(28);if("."!==(n=me(t,r)).charAt(0))throw new Re.ErrnoError(55);try{var c=Re.lookupNode(s,o)}catch(e){}if(u!==c){if(r=Re.isDir(u.mode),i=Re.qb(a,i,r))throw new Re.ErrnoError(i);if(i=c?Re.qb(s,o,r):Re.Lb(s,o))throw new Re.ErrnoError(i);if(!a.node_ops.rename)throw new Re.ErrnoError(63);if(Re.ab(u)||c&&Re.ab(c))throw new Re.ErrnoError(10);if(s!==a&&(i=Re.Za(a,"w")))throw new Re.ErrnoError(i);try{Re.Sa.willMovePath&&Re.Sa.willMovePath(e,t)}catch(r){y("FS.trackingDelegate['willMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}Re.fc(u);try{a.node_ops.rename(u,s,o)}catch(e){throw e}finally{Re.ec(u)}try{Re.Sa.onMovePath&&Re.Sa.onMovePath(e,t)}catch(r){y("FS.trackingDelegate['onMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}}},rmdir:function(e){var t=Re.lookupPath(e,{parent:!0}).node,r=_e(e),n=Re.lookupNode(t,r),i=Re.qb(t,r,!0);if(i)throw new Re.ErrnoError(i);if(!t.node_ops.rmdir)throw new Re.ErrnoError(63);if(Re.ab(n))throw new Re.ErrnoError(10);try{Re.Sa.willDeletePath&&Re.Sa.willDeletePath(e)}catch(t){y("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.rmdir(t,r),Re.Ab(n);try{Re.Sa.onDeletePath&&Re.Sa.onDeletePath(e)}catch(t){y("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readdir:function(e){if(!(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.readdir)throw new Re.ErrnoError(54);return e.node_ops.readdir(e)},unlink:function(e){var t=Re.lookupPath(e,{parent:!0}).node,r=_e(e),n=Re.lookupNode(t,r),i=Re.qb(t,r,!1);if(i)throw new Re.ErrnoError(i);if(!t.node_ops.unlink)throw new Re.ErrnoError(63);if(Re.ab(n))throw new Re.ErrnoError(10);try{Re.Sa.willDeletePath&&Re.Sa.willDeletePath(e)}catch(t){y("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.unlink(t,r),Re.Ab(n);try{Re.Sa.onDeletePath&&Re.Sa.onDeletePath(e)}catch(t){y("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readlink:function(e){if(!(e=Re.lookupPath(e).node))throw new Re.ErrnoError(44);if(!e.node_ops.readlink)throw new Re.ErrnoError(28);return ge(Re.Ya(e.parent),e.node_ops.readlink(e))},stat:function(e,t){if(!(e=Re.lookupPath(e,{Ta:!t}).node))throw new Re.ErrnoError(44);if(!e.node_ops.getattr)throw new Re.ErrnoError(63);return e.node_ops.getattr(e)},lstat:function(e){return Re.stat(e,!0)},chmod:function(e,t,r){if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!r}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);e.node_ops.setattr(e,{mode:4095&t|-4096&e.mode,timestamp:Date.now()})},lchmod:function(e,t){Re.chmod(e,t,!0)},fchmod:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);Re.chmod(e.node,t)},chown:function(e,t,r,n){if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!n}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);e.node_ops.setattr(e,{timestamp:Date.now()})},lchown:function(e,t,r){Re.chown(e,t,r,!0)},fchown:function(e,t,r){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);Re.chown(e.node,t,r)},truncate:function(e,t){if(0>t)throw new Re.ErrnoError(28);if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);if(Re.isDir(e.mode))throw new Re.ErrnoError(31);if(!Re.isFile(e.mode))throw new Re.ErrnoError(28);var r=Re.Za(e,"w");if(r)throw new Re.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(28);Re.truncate(e.node,t)},kd:function(e,t,r){(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,o){if(""===e)throw new Re.ErrnoError(44);if(r=64&(t="string"==typeof t?Re.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var s=e;else{e=he(e);try{s=Re.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(s){if(128&t)throw new Re.ErrnoError(20)}else s=Re.mknod(e,r,0),a=!0;if(!s)throw new Re.ErrnoError(44);if(Re.pb(s.mode)&&(t&=-513),65536&t&&!Re.isDir(s.mode))throw new Re.ErrnoError(54);if(!a&&(r=Re.Wc(s,t)))throw new Re.ErrnoError(r);512&t&&Re.truncate(s,0),t&=-131713,(n=Re.Jc({node:s,path:Re.Ya(s),flags:t,seekable:!0,position:0,stream_ops:s.stream_ops,jd:[],error:!1},n,o)).stream_ops.open&&n.stream_ops.open(n),!i.logReadFiles||1&t||(Re.Ob||(Re.Ob={}),e in Re.Ob||(Re.Ob[e]=1,y("FS.trackingDelegate error on read file: "+e)));try{Re.Sa.onOpenFile&&(o=0,1!=(2097155&t)&&(o|=Re.nc.kc.qc),0!=(2097155&t)&&(o|=Re.nc.kc.rc),Re.Sa.onOpenFile(e,o))}catch(t){y("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(Re.kb(e))throw new Re.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Re.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Re.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Re.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(1==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.read)throw new Re.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.write)throw new Re.ErrnoError(28);e.seekable&&1024&e.flags&&Re.llseek(e,0,2);var s=void 0!==i;if(s){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),s||(e.position+=t);try{e.path&&Re.Sa.onWriteToFile&&Re.Sa.onWriteToFile(e.path)}catch(t){y("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(0>t||0>=r)throw new Re.ErrnoError(28);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(!Re.isFile(e.node.mode)&&!Re.isDir(e.node.mode))throw new Re.ErrnoError(43);if(!e.stream_ops.allocate)throw new Re.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new Re.ErrnoError(2);if(1==(2097155&e.flags))throw new Re.ErrnoError(2);if(!e.stream_ops.mmap)throw new Re.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new Re.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=Re.open(e,t.flags);e=Re.stat(e).size;var i=new Uint8Array(e);return Re.read(n,i,0,e,0),"utf8"===t.encoding?r=U(i,0):"binary"===t.encoding&&(r=i),Re.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=Re.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array(J(t)+1);t=j(t,n,0,n.length),Re.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Re.write(e,t,0,t.byteLength,void 0,r.Bc)}Re.close(e)},cwd:function(){return Re.Wb},chdir:function(e){if(null===(e=Re.lookupPath(e,{Ta:!0})).node)throw new Re.ErrnoError(44);if(!Re.isDir(e.node.mode))throw new Re.ErrnoError(54);var t=Re.Za(e.node,"x");if(t)throw new Re.ErrnoError(t);Re.Wb=e.path},Fc:function(){Re.mkdir("/tmp"),Re.mkdir("/home"),Re.mkdir("/home/web_user")},Ec:function(){Re.mkdir("/dev"),Re.Qb(Re.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),Re.rb("/dev/null",Re.bb(1,3)),ye(Re.bb(5,0),Ee),ye(Re.bb(6,0),Oe),Re.rb("/dev/tty",Re.bb(5,0)),Re.rb("/dev/tty1",Re.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(g)try{var t=Et;return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){oe("randomDevice")}}();Re.Wa("/dev","random",e),Re.Wa("/dev","urandom",e),Re.mkdir("/dev/shm"),Re.mkdir("/dev/shm/tmp")},Hc:function(){Re.mkdir("/proc");var e=Re.mkdir("/proc/self");Re.mkdir("/proc/self/fd"),Re.mount({mount:function(){var t=Re.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=Re.$a(+t);if(!r)throw new Re.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){i.stdin?Re.Wa("/dev","stdin",i.stdin):Re.symlink("/dev/tty","/dev/stdin"),i.stdout?Re.Wa("/dev","stdout",null,i.stdout):Re.symlink("/dev/tty","/dev/stdout"),i.stderr?Re.Wa("/dev","stderr",null,i.stderr):Re.symlink("/dev/tty1","/dev/stderr"),Re.open("/dev/stdin",0),Re.open("/dev/stdout",1),Re.open("/dev/stderr",1)},Yb:function(){Re.ErrnoError||(Re.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},Re.ErrnoError.prototype=Error(),Re.ErrnoError.prototype.constructor=Re.ErrnoError,[44].forEach((function(e){Re.Db[e]=new Re.ErrnoError(e),Re.Db[e].stack="<generic error, no stack>"})))},lc:function(){Re.Yb(),Re.Ua=Array(4096),Re.mount(ke,{},"/"),Re.Fc(),Re.Ec(),Re.Hc(),Re.Lc={MEMFS:ke}},jb:function(e,t,r){Re.jb.Hb=!0,Re.Yb(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,Re.Ic()},wd:function(){Re.jb.Hb=!1;var e=i._fflush;for(e&&e(0),e=0;e<Re.streams.length;e++){var t=Re.streams[e];t&&Re.close(t)}},Eb:function(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r},od:function(e,t){return(e=Re.xb(e,t)).exists?e.object:null},xb:function(e,t){try{var r=Re.lookupPath(e,{Ta:!t});e=r.path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,ad:!1,cd:null,bd:null};try{r=Re.lookupPath(e,{parent:!0}),n.ad=!0,n.cd=r.path,n.bd=r.node,n.name=_e(e),r=Re.lookupPath(e,{Ta:!t}),n.exists=!0,n.path=r.path,n.object=r.node,n.name=r.node.name,n.isRoot="/"===r.path}catch(e){n.error=e.Oa}return n},md:function(e,t){for(e="string"==typeof e?e:Re.Ya(e),t=t.split("/").reverse();t.length;){var r=t.pop();if(r){var n=pe(e,r);try{Re.mkdir(n)}catch(e){}e=n}}return n},Gc:function(e,t,r,n,i){return e=pe("string"==typeof e?e:Re.Ya(e),t),Re.create(e,Re.Eb(n,i))},zb:function(e,t,r,n,i,o){if(e=t?pe("string"==typeof e?e:Re.Ya(e),t):e,n=Re.Eb(n,i),i=Re.create(e,n),r){if("string"==typeof r){e=Array(r.length),t=0;for(var s=r.length;t<s;++t)e[t]=r.charCodeAt(t);r=e}Re.chmod(i,146|n),e=Re.open(i,577),Re.write(e,r,0,r.length,0,o),Re.close(e),Re.chmod(i,n)}return i},Wa:function(e,t,r,n){e=pe("string"==typeof e?e:Re.Ya(e),t),t=Re.Eb(!!r,!!n),Re.Wa.Kb||(Re.Wa.Kb=64);var i=Re.bb(Re.Wa.Kb++,0);return Re.Qb(i,{open:function(e){e.seekable=!1},close:function(){n&&n.buffer&&n.buffer.length&&n(10)},read:function(e,t,n,i){for(var o=0,s=0;s<i;s++){try{var a=r()}catch(e){throw new Re.ErrnoError(29)}if(void 0===a&&0===o)throw new Re.ErrnoError(6);if(null==a)break;o++,t[n+s]=a}return o&&(e.node.timestamp=Date.now()),o},write:function(e,t,r,i){for(var o=0;o<i;o++)try{n(t[r+o])}catch(e){throw new Re.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),o}}),Re.rb(e,t,i)},ac:function(e){if(e.Ib||e.Sc||e.link||e.Na)return!0;if("undefined"!=typeof XMLHttpRequest)throw Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!u)throw Error("Cannot load without read() or XMLHttpRequest.");try{e.Na=De(u(e.url),!0),e.Ra=e.Na.length}catch(e){throw new Re.ErrnoError(29)}},ld:function(e,t,r,n,i){function o(){this.Jb=!1,this.ob=[]}if(o.prototype.get=function(e){if(!(e>this.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var s=this;s.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===s.ob[e]){var a=s.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):De(u.responseText||"",!0),a[e]=t}if(void 0===s.ob[e])throw Error("doXHR failed!");return s.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!p)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o;Object.defineProperties(s,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),s={Ib:!1,Na:s}}else s={Ib:!1,url:r};var a=Re.Gc(e,t,s,n,i);s.Na?a.Na=s.Na:s.url&&(a.Na=null,a.url=s.url),Object.defineProperties(a,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];u[e]=function(){return Re.ac(a),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(Re.ac(a),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o<n;o++)t[r+o]=e[i+o];else for(o=0;o<n;o++)t[r+o]=e.get(i+o);return n},a.stream_ops=u,a},nd:function(e,t,r,n,o,s,a,u,l,f){function h(r){function c(r){f&&f(),u||Re.zb(e,t,r,n,o,l),s&&s(),ie()}var h=!1;i.preloadPlugins.forEach((function(e){!h&&e.canHandle(d)&&(e.handle(r,d,c,(function(){a&&a(),ie()})),h=!0)})),h||c(r)}undefined.jb();var d=t?ge(pe(e,t)):e;ne(),"string"==typeof r?function(e,t,r){var n="al "+e;c(e,(function(r){x(r,'Loading data file "'+e+'" failed (no arrayBuffer).'),t(new Uint8Array(r)),n&&ie()}),(function(){if(!r)throw'Loading data file "'+e+'" failed.';r()})),n&&ne()}(r,(function(e){h(e)}),a):h(r)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Rb:function(){return"EM_FS_"+window.location.pathname},Sb:20,ib:"FILE_DATA",xd:function(e,t,r){t=t||function(){},r=r||function(){};var n=Re.indexedDB();try{var i=n.open(Re.Rb(),Re.Sb)}catch(e){return r(e)}i.onupgradeneeded=function(){v("creating db"),i.result.createObjectStore(Re.ib)},i.onsuccess=function(){var n=i.result.transaction([Re.ib],"readwrite"),o=n.objectStore(Re.ib),s=0,a=0,u=e.length;e.forEach((function(e){(e=o.put(Re.xb(e).object.Na,e)).onsuccess=function(){++s+a==u&&(0==a?t():r())},e.onerror=function(){a++,s+a==u&&(0==a?t():r())}})),n.onerror=r},i.onerror=r},rd:function(e,t,r){t=t||function(){},r=r||function(){};var n=Re.indexedDB();try{var i=n.open(Re.Rb(),Re.Sb)}catch(e){return r(e)}i.onupgradeneeded=r,i.onsuccess=function(){var n=i.result;try{var o=n.transaction([Re.ib],"readonly")}catch(e){return void r(e)}var s=o.objectStore(Re.ib),a=0,u=0,c=e.length;e.forEach((function(e){var n=s.get(e);n.onsuccess=function(){Re.xb(e).exists&&Re.unlink(e),Re.zb(de(e),_e(e),n.result,!0,!0,!0),++a+u==c&&(0==u?t():r())},n.onerror=function(){u++,a+u==c&&(0==u?t():r())}})),o.onerror=r},i.onerror=r}},Ne={};function Me(e,t,r){try{var n=e(t)}catch(e){if(e&&e.node&&he(t)!==he(Re.Ya(e.node)))return-54;throw e}return P[r>>2]=n.dev,P[r+4>>2]=0,P[r+8>>2]=n.ino,P[r+12>>2]=n.mode,P[r+16>>2]=n.nlink,P[r+20>>2]=n.uid,P[r+24>>2]=n.gid,P[r+28>>2]=n.rdev,P[r+32>>2]=0,Z=[n.size>>>0,(X=n.size,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+40>>2]=Z[0],P[r+44>>2]=Z[1],P[r+48>>2]=4096,P[r+52>>2]=n.blocks,P[r+56>>2]=n.atime.getTime()/1e3|0,P[r+60>>2]=0,P[r+64>>2]=n.mtime.getTime()/1e3|0,P[r+68>>2]=0,P[r+72>>2]=n.ctime.getTime()/1e3|0,P[r+76>>2]=0,Z=[n.ino>>>0,(X=n.ino,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+80>>2]=Z[0],P[r+84>>2]=Z[1],0}var xe,Ae=void 0;function Ie(){return P[(Ae+=4)-4>>2]}function Te(e){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);return e}xe=g?function(){var e=ae.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Ce,Fe={};function Be(){if(!Ce){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"};for(e in Fe)void 0===Fe[e]?delete t[e]:t[e]=Fe[e];var r=[];for(e in t)r.push(e+"="+t[e]);Ce=r}return Ce}function Pe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=Re.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function De(e,t){var r=Array(J(e)+1);return e=j(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Pe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return Re.isDir(this.mode)}},Ib:{get:function(){return Re.pb(this.mode)}}}),Re.FSNode=Pe,Re.lc();var $e={a:function(e,t,r,n){oe("Assertion failed: "+q(e)+", at: "+[t?q(t):"unknown filename",r,n?q(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!ee){ee=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);P[We()>>2]=60*o,P[ze()>>2]=Number(t!=i),r=e(r),n=e(n),r=z(r),n=z(n),i<t?(P[Je()>>2]=r,P[Je()+4>>2]=n):(P[Je()>>2]=n,P[Je()+4>>2]=r)}}(),e=new Date(1e3*P[e>>2]),P[t>>2]=e.getSeconds(),P[t+4>>2]=e.getMinutes(),P[t+8>>2]=e.getHours(),P[t+12>>2]=e.getDate(),P[t+16>>2]=e.getMonth(),P[t+20>>2]=e.getFullYear()-1900,P[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);P[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,P[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),P[t+32>>2]=e,e=P[Je()+(e?4:0)>>2],P[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=q(e),-8&t)var n=-28;else(r=Re.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&Re.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},A:function(e,t){try{return e=q(e),Re.chmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},H:function(e,t,r){try{return e=q(e),Re.chown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},B:function(e,t){try{return Re.fchmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},I:function(e,t,r){try{return Re.fchown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},b:function(e,t,r){Ae=r;try{var n=Te(e);switch(t){case 0:var i=Ie();return 0>i?-28:Re.open(n.path,n.flags,0,i).fd;case 1:case 2:case 13:case 14:return 0;case 3:return n.flags;case 4:return i=Ie(),n.flags|=i,0;case 12:return i=Ie(),B[i+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return P[Le()>>2]=28,-1}}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},E:function(e,t){try{var r=Te(e);return Me(Re.stat,r.path,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},n:function(e,t,r){try{return Re.Nc(e,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=Re.cwd();return t<J(r)+1?-68:(j(r,F,e,t),e)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},G:function(){return 0},d:function(){return 42},z:function(e,t){try{return e=q(e),Me(Re.lstat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},C:function(e,t){try{return"/"===(e=he(e=q(e)))[e.length-1]&&(e=e.substr(0,e.length-1)),Re.mkdir(e,t,0),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},y:function(e,t,r,n,i,o){try{e:{o<<=12;var s=!1;if(0!=(16&n)&&0!=e%65536)var a=-28;else{if(0!=(32&n)){var u=Se(t);if(!u){a=-48;break e}s=!0}else{var c=Re.$a(i);if(!c){a=-8;break e}var l=Re.mmap(c,e,t,o,r,n);u=l.ed,s=l.vb}Ne[u]={Uc:u,Tc:t,vb:s,fd:i,dd:r,flags:n,offset:o},a=u}}return a}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},x:function(e,t){try{var r=Ne[e];if(0!==t&&r){if(t===r.Tc){var n=Re.$a(r.fd);if(n&&2&r.dd){var i=r.flags,o=r.offset,s=F.slice(e,e+t);Re.msync(n,s,o,t,i)}Ne[e]=null,r.vb&&qe(r.Uc)}var a=0}else a=-28;return a}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},w:function(e,t,r){Ae=r;try{var n=q(e),i=r?Ie():0;return Re.open(n,t,i).fd}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},J:function(e,t,r){try{if(e=q(e),0>=r)var n=-28;else{var i=Re.readlink(e),o=Math.min(r,J(i)),s=C[t+o];j(i,F,t,r+1),C[t+o]=s,n=o}return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},F:function(e){try{return e=q(e),Re.rmdir(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},e:function(e,t){try{return e=q(e),Me(Re.stat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},i:function(e){try{return e=q(e),Re.unlink(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){F.copyWithin(e,t,t+r)},c:function(e){var t=F.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{N.grow(Math.min(2147483648,n)-T.byteLength+65535>>>16),W();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=xe();xe()-t<e;);},r:function(e,t){try{var r=0;return Be().forEach((function(n,i){var o=t+r;for(i=P[e+4*i>>2]=o,o=0;o<n.length;++o)C[i++>>0]=n.charCodeAt(o);C[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},s:function(e,t){try{var r=Be();P[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),P[t>>2]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},f:function(e){try{var t=Te(e);return Re.close(t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},q:function(e,t){try{var r=Te(e),n=r.tty?2:Re.isDir(r.mode)?3:Re.fb(r.mode)?7:4;return C[t>>0]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o<r;o++){var s=P[t+(8*o+4)>>2],a=Re.read(i,C,P[t+8*o>>2],s,void 0);if(0>a){var u=-1;break e}if(e+=a,a<s)break}u=e}return P[n>>2]=u,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},o:function(e,t,r,n,i){try{var o=Te(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(Re.llseek(o,e,n),Z=[o.position>>>0,(X=o.position,1<=+Math.abs(X)?0<X?(0|Math.min(+Math.floor(X/4294967296),4294967295))>>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[i>>2]=Z[0],P[i+4>>2]=Z[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},k:function(e){try{var t=Te(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o<r;o++){var s=Re.write(i,C,P[t+8*o>>2],P[t+(8*o+4)>>2],void 0);if(0>s){var a=-1;break e}e+=s}a=e}return P[n>>2]=a,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},h:function(e){var t=Date.now();return P[e>>2]=t/1e3|0,P[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(P[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*P[r>>2],t+=P[r+4>>2]/1e3}else t=Date.now();e=q(e);try{Re.kd(e,t,t);var n=0}catch(e){if(!(e instanceof Re.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw i.extraStackTrace&&(n+="\n"+i.extraStackTrace()),n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n),e+" : "+n}n=e.Oa,P[Le()>>2]=n,n=-1}return n}};!function(){function e(e){i.asm=e.exports,N=i.asm.L,W(),H=i.asm.Da,Y.unshift(i.asm.M),ie()}function t(t){e(t.instance)}function r(e){return function(){if(!w&&(_||p)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()})).catch((function(){return ce()}));if(c)return new Promise((function(e,t){c(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ce()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){y("failed to asynchronously prepare wasm: "+e),oe(e)}))}var n={a:$e};if(ne(),i.instantiateWasm)try{return i.instantiateWasm(n,e)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}w||"function"!=typeof WebAssembly.instantiateStreaming||se()||K.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.M).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.N).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.O).apply(null,arguments)};var Le=i.___errno_location=function(){return(Le=i.___errno_location=i.asm.P).apply(null,arguments)};i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.Q).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.R).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.S).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.T).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.U).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.V).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.W).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.X).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.Y).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.Z).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm._).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.$).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.aa).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.ba).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.ca).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.da).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.ea).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.fa).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.ga).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.ha).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.ia).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.ja).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.ka).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.la).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.ma).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.na).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.oa).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.pa).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.qa).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.ra).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sa).apply(null,arguments)},i._sqlite3_normalized_sql=function(){return(i._sqlite3_normalized_sql=i.asm.ta).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.ua).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.va).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.wa).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.xa).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.ya).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.za).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.Aa).apply(null,arguments)};var Ue=i._malloc=function(){return(Ue=i._malloc=i.asm.Ba).apply(null,arguments)},qe=i._free=function(){return(qe=i._free=i.asm.Ca).apply(null,arguments)};i._RegisterExtensionFunctions=function(){return(i._RegisterExtensionFunctions=i.asm.Ea).apply(null,arguments)},i._register_for_idb=function(){return(i._register_for_idb=i.asm.Fa).apply(null,arguments)};var je,Je=i.__get_tzname=function(){return(Je=i.__get_tzname=i.asm.Ga).apply(null,arguments)},ze=i.__get_daylight=function(){return(ze=i.__get_daylight=i.asm.Ha).apply(null,arguments)},We=i.__get_timezone=function(){return(We=i.__get_timezone=i.asm.Ia).apply(null,arguments)},He=i.stackSave=function(){return(He=i.stackSave=i.asm.Ja).apply(null,arguments)},Ge=i.stackRestore=function(){return(Ge=i.stackRestore=i.asm.Ka).apply(null,arguments)},Ye=i.stackAlloc=function(){return(Ye=i.stackAlloc=i.asm.La).apply(null,arguments)},Ve=i._memalign=function(){return(Ve=i._memalign=i.asm.Ma).apply(null,arguments)};function Qe(){function e(){if(!je&&(je=!0,i.calledRun=!0,!M)){if(i.noFSInit||Re.jb.Hb||Re.jb(),Re.hc=!1,le(Y),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;){var e=i.postRun.shift();V.unshift(e)}le(V)}}if(!(0<te)){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)Q();le(G),0<te||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),e()}),1)):e())}}if(i.cwrap=function(e,t,r,n){var i=(r=r||[]).every((function(e){return"number"===e}));return"string"!==t&&i&&!n?A(e):function(){return function(e,t,r,n){var i,o={string:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);t=Ye(r),j(e,F,t,r)}return t},array:function(e){var t=Ye(e.length);return C.set(e,t),t}},s=A(e),a=[];if(e=0,n)for(var u=0;u<n.length;u++){var c=o[r[u]];c?(0===e&&(e=He()),a[u]=c(n[u])):a[u]=n[u]}return r=s.apply(null,a),i=r,r="string"===t?q(i):"boolean"===t?!!i:i,0!==e&&Ge(e),r}(e,t,r,arguments)}},i.UTF8ToString=q,i.FS=Re,i.stackSave=He,i.stackRestore=Ge,i.stackAlloc=Ye,re=function e(){je||Qe(),je||(re=e)},i.run=Qe,i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();return Qe(),i})),r)};e.exports=n,e.exports.default=n}(ot);var Ot=p(ot.exports);const St=63,kt=44;const Rt=class{constructor(e,t){this.FS=e,this.backend=t,this.node_ops={getattr:t=>{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(kt)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.lock(t)}unlock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.unlock(t)}createNode(e,t,r,n){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(St);var i=this.FS.createNode(e,t,r,n);return this.FS.isDir(i.mode)?(i.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},i.stream_ops={},i.contents={}):this.FS.isFile(i.mode)&&(i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i.contents=this.backend.createFile(t)),e&&(e.contents[t]=i,e.timestamp=i.timestamp),i}};let Nt=1,Mt=2;function xt(e){return(e[16]<<8)+e[17]}function At(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function It(e,t,r,n){let i=At(t,r,n),o=0;return i.map((i=>{let s=0,a=t;r>i&&r<i+t&&(s=r-i),n>i&&n<i+t&&(a=n-i);let u=a-s,c=new ArrayBuffer(t);if(r>i+t||n<=i)return null;let l=e.byteOffset+o,f=e.buffer.byteLength-l;if(f<=0)return null;let h=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,h),s),o+=h,{pos:i,data:c,offset:s,length:h}})).filter(Boolean)}class Tt{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t<e.length;t++){let r=e[t];this.buffer.set(r.pos,r)}}open(){if(this.openHandles++,1===this.openHandles){this.ops.open();let e=this.ops.readMeta();null==this.meta&&(null==e&&(e={size:0}),this.meta=e)}return this.meta}close(){this.fsync(),this.openHandles=Math.max(this.openHandles-1,0),0===this.openHandles&&this.ops.close()}delete(){this.ops.delete()}load(e){let t=e.reduce(((e,t)=>{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e}),{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;t<r;t++)e[t]=0;return r}n=Math.max(n,0);let o=Math.min(r,this.meta.size-n),s=n,a=n+o,u=At(this.meta.blockSize,s,a),c=function(e,t,r){let n=new ArrayBuffer(r-t),i=new Uint8Array(n);for(let n=0;n<e.length;n++){let o=e[n];if("ArrayBuffer"!==o.data.constructor.name)throw new Error("Chunk data is not an ArrayBuffer");let s=0,a=o.data.byteLength;if(t>o.pos&&(s=t-o.pos),r<o.pos+o.data.byteLength&&(a=r-o.pos),s>o.data.byteLength||a<0)continue;let u=a-s;i.set(new Uint8Array(o.data,s,u),o.pos-t+s)}return n}(this.load(u),s,a);if(i.byteLength-t<c.byteLength)throw new Error("Buffer given to `read` is too small");let l=new Uint8Array(i);l.set(new Uint8Array(c),t);for(let e=o;e<r;e++)l[t+e]=0;return r}write(e,t,r,n){if(null==this.meta.blockSize){let r=xt(new Uint8Array(e.buffer,e.byteOffset+t));if(![512,1024,2048,4096,8192,16384,32768,65536].includes(r))throw new Error("File has invalid page size. (the first block of a new file must be written first)");this.setattr({blockSize:r})}let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(0===i.byteLength)return 0;r=Math.min(r,i.byteLength-t);let o=It(new Uint8Array(i,t,r),this.meta.blockSize,n,n+r),{partialWrites:s,fullWrites:a}=o.reduce(((e,t)=>(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e)),{fullWrites:[],partialWrites:[]}),u=[];s.length>0&&(u=this.load(s.map((e=>e.pos))));let c=a.concat(u.map((e=>{let t=s.find((t=>t.pos===e.pos));return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e})));return this.bufferChunks(c),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=Mt&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=xt(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(It(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}let Ct,Ft,Bt,Pt=3735928559;class Dt{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log(`waiting for ${e}`);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log(`resumed for ${e}`)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=new DataView(this.buffer,this.offset).getUint32(0)===Pt;return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e<r;e++)i.push(n.getUint16(2*e));let o=String.fromCharCode.apply(null,i);return this.log("string",o),this.offset+=t,null==this.peekOffset&&this.flip(),o}_int32(){let e=new DataView(this.buffer,this.offset).getInt32();return this.log("_int32",e),this.offset+=4,e}int32(){this.waitWrite("int32");let e=this._int32();return this.log("int32",e),null==this.peekOffset&&this.flip(),e}bytes(){this.waitWrite("bytes");let e=this._int32(),t=new ArrayBuffer(e);return new Uint8Array(t).set(new Uint8Array(this.buffer,this.offset,e)),this.log("bytes",t),this.offset+=e,null==this.peekOffset&&this.flip(),t}}class $t{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o,this.useAtomics?Atomics.store(this.atomicView,0,0):this.atomicView[0]=0}log(...e){this.debug&&console.log(`[writer: ${this.name}]`,...e)}waitRead(e){if(this.useAtomics){if(this.log(`waiting for ${e}`),0!==Atomics.compareExchange(this.atomicView,0,0,1))throw new Error("Wrote something into unwritable buffer! This is disastrous");for(Atomics.notify(this.atomicView,0);1===Atomics.load(this.atomicView,0);)Atomics.wait(this.atomicView,0,1,500);this.log(`resumed for ${e}`)}else this.atomicView[0]=1;this.offset=4}finalize(){this.log("finalizing"),new DataView(this.buffer,this.offset).setUint32(0,Pt),this.waitRead("finalize")}string(e){this.log("string",e);let t=2*e.length;this._int32(t);let r=new DataView(this.buffer,this.offset,t);for(let t=0;t<e.length;t++)r.setUint16(2*t,e.charCodeAt(t));this.offset+=t,this.waitRead("string")}_int32(e){new DataView(this.buffer,this.offset).setInt32(0,e),this.offset+=4}int32(e){this.log("int32",e),this._int32(e),this.waitRead("int32")}bytes(e){this.log("bytes",e);let t=e.byteLength;this._int32(t),new Uint8Array(this.buffer,this.offset).set(new Uint8Array(e)),this.offset+=t,this.waitRead("bytes")}}function Lt(e,t){return Math.round(e/t)}class Ut{constructor(e){this.filename=e}getStoreName(){return this.filename.replace(/\//g,"-")}invokeWorker(e,t){if(null==this.reader||null==this.writer)throw new Error(`Attempted ${e} on ${this.filename} but file not open`);let r=this.reader,n=this.writer;switch(e){case"readBlocks":{let{name:e,positions:i,blockSize:o}=t,s=[];for(let t of i){n.string("readBlock"),n.string(e),n.int32(Lt(t,o)),n.finalize();let i=r.bytes();r.done(),s.push({pos:t,data:0===i.byteLength?new ArrayBuffer(o):i})}return s}case"writeBlocks":{let{name:e,writes:i,blockSize:o}=t;n.string("writeBlocks"),n.string(e);for(let e of i)n.int32(Lt(e.pos,o)),n.bytes(e.data);n.finalize();let s=r.int32();return r.done(),s}case"readMeta":{n.string("readMeta"),n.string(t.name),n.finalize();let e=r.int32(),i=r.int32();return r.done(),-1===e?null:{size:e,blockSize:i}}case"writeMeta":{let{name:e,meta:i}=t;n.string("writeMeta"),n.string(e),n.int32(i.size),n.finalize();let o=r.int32();return r.done(),o}case"closeFile":{n.string("closeFile"),n.string(t.name),n.finalize();let e=r.int32();return r.done(),e}case"lockFile":{n.string("lockFile"),n.string(t.name),n.int32(t.lockType),n.finalize();let e=r.int32();return r.done(),0===e}case"unlockFile":{n.string("unlockFile"),n.string(t.name),n.int32(t.lockType),n.finalize();let e=r.int32();return r.done(),0===e}}}lock(e){return this.invokeWorker("lockFile",{name:this.getStoreName(),lockType:e})}unlock(e){return this.invokeWorker("unlockFile",{name:this.getStoreName(),lockType:e})}delete(){(this.reader||this.writer)&&this.close();let e=globalThis.indexedDB.deleteDatabase(this.getStoreName());e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new $t(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new Dt(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",(e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}}))}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function qt(e,t){return Math.round(e/t)}async function jt(e){return await function(){if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const r=()=>indexedDB.databases().finally(t);e=setInterval(r,100),r()})).finally((()=>clearInterval(e)))}(),new Promise(((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)}))}class Jt{constructor(e,t){this.dbName=e,this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=t}async getDb(){return this._openDb||(this._openDb=await jt(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise(((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}}))}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise(((o,s)=>{let a=i.get(0);a.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(a.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void s(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>s()},a.onerror=s}))}}class zt{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new Jt(this.dbName,t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>Nt&&e===Nt&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:xt(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(qt(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=qt(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=Nt&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>Nt),this.writeQueue=[]),this.cachedFirstBlock=null}}class Wt{constructor(e){this.onFallbackFailure=e}createFile(e){let t;t="undefined"!=typeof SharedArrayBuffer?new Ut(e):new zt(e,this.onFallbackFailure);let r=new Tt(e,t);return("production"!==ae.env.NODE_ENV||ae.env.PERF_BUILD)&&(null==this._files&&(this._files=new Set),this._files.add(r)),r}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}function Ht(e,t){if(Ct)return Ct;if(!e)throw new Error("must speciefic database file");return Ct=new Promise(((r,n)=>{const i=async function(e,t="/sql-wasm.wasm"){if(!Ft){Ft=await Ot({locateFile:()=>t});const e=new Rt(Ft.FS,new Wt);Ft.register_for_idb(e),Ft.FS.mkdir("/sql"),Ft.FS.mount(e,{},"/sql")}const r=`/sql/${e}`,n=new Ft.Database(r,{filename:!0});if("undefined"==typeof SharedArrayBuffer){const e=Ft.FS.open(r,"a+");await e.node.contents.readIfFallback(),Ft.FS.close(e)}return n.exec("\n PRAGMA page_size=8192;\n PRAGMA journal_mode=MEMORY;\n "),n}(e,t);i.then((e=>r(e))).catch((e=>n(e)))})),Ct}async function Gt(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));if(0===r.length)return M("");const n=function(e,t){const r=v.insert().into("local_conversations").setFieldsRows(t).toString();return e.exec(r)}(t,r);return M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}}async function Yt(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("temp_cache_local_chat_logs").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}}self.$RefreshReg$=()=>{},self.$RefreshSig$=()=>()=>{};const Vt=new Map,Qt=self,Kt=new h({event:new class{constructor(e){c(this,"_currentEndpoint"),c(this,"_targetEndpoint"),c(this,"_events"),c(this,"_originOnmessage"),c(this,"_receiveMessage"),c(this,"onerror",null),c(this,"config"),c(this,"sendAdapter"),c(this,"receiveAdapter"),this._events={},this._currentEndpoint=e.currentEndpoint,this._targetEndpoint=e.targetEndpoint,this._originOnmessage=null,this.config=e.config,this.receiveAdapter=e.receiveAdapter,this.sendAdapter=e.sendAdapter;const t=e=>{const t=this.receiveAdapter?this.receiveAdapter(e):e.data;if(t&&"string"==typeof t.event){const e=this._events[t.event]||[];if(e.length)return void e.forEach((e=>{e(...t.args||[])}));this.onerror&&this.onerror(u(a({},l.METHOD_NOT_FOUND),{data:t}))}};if(this._currentEndpoint.addEventListener)return"start"in this._currentEndpoint&&this._currentEndpoint.start&&this._currentEndpoint.start(),this._currentEndpoint.addEventListener("message",t,!1),void(this._receiveMessage=t);this._originOnmessage=this._currentEndpoint.onmessage,this._currentEndpoint.onmessage=e=>{this._originOnmessage&&this._originOnmessage(e),t(e)},this._receiveMessage=this._currentEndpoint.onmessage}emit(e,...t){const r={event:e,args:t},n=this.sendAdapter?this.sendAdapter(r,this._targetEndpoint):{data:r},i=n.data||r,o=this.config?"function"==typeof this.config?this.config(i,this._targetEndpoint)||{}:this.config||{}:{};Array.isArray(n.transfer)&&n.transfer.length&&(o.transfer=n.transfer),this._targetEndpoint.postMessage(i,o)}on(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}off(e,t){if(!this._events[e])return;if(!t)return void(this._events[e]=[]);const r=this._events[e]||[];this._events[e]=r.filter((e=>e!==t))}destroy(){if(this._currentEndpoint.removeEventListener)this._currentEndpoint.removeEventListener("message",this._receiveMessage,!1);else try{this._currentEndpoint.onmessage=this._originOnmessage}catch(e){console.warn(e)}}}({currentEndpoint:Qt,targetEndpoint:Qt})});Kt.registerMethod("fileMapSet",((e,t)=>(Vt.set(e,t),M(e)))),Kt.registerMethod("fileMapClear",(()=>(Vt.clear(),M("")))),Kt.registerMethod("wasmOpen",(e=>new Promise(((t,r)=>{const n=Vt.get(e);n?t(M(n.size)):r("file not found")})))),Kt.registerMethod("wasmClose",(async e=>new Promise((t=>{Vt.delete(e),t(M(e))})))),Kt.registerMethod("wasmRead",((e,t,r)=>{const n=Vt.get(e);if(!n)throw"file not found";const i=n.slice(t,t+r);return new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{t(r.error)},r.readAsArrayBuffer(i)}))})),Kt.registerMethod("getUpload",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_uploads where part_hash = '${t}' limit 1;\n `)}(await Ht(),e),r=F(t[0],"CamelCase");if(0===r.length)throw`no upload with partHash = ${e}`;return M(r[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_uploads").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_uploads").setFields(t).where(`part_hash = '${t.part_hash}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteUpload",(async function(e){try{const t=function(e,t){const r=v.delete().from("local_uploads").where(`part_hash = '${t}'`).toString();return e.exec(r)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setSqlWasmPath",(function(e){Bt=e})),Kt.registerMethod("initDB",(async function(e,t){try{const r=await Ht(`${t}${e}.sqlite`,Bt),n=[],i=function(e){return e.exec("\n create table if not exists 'local_uploads' (\n 'part_hash' text,\n 'upload_id' varchar(1000),\n 'upload_info' varchar(2000),\n 'expire_time' integer,\n 'create_time' integer,\n PRIMARY KEY ('part_hash')\n )\n ")}(r),o=function(e){return e.exec("\n create table if not exists 'local_stranger'\n (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n PRIMARY KEY ('user_id')\n )\n ")}(r),s=function(e){return e.exec("\n create table if not exists 'local_conversations' (\n 'conversation_id' char(128),\n 'conversation_type' integer,\n 'user_id' char(64),\n 'group_id' char(128),\n 'show_name' varchar(255),\n 'face_url' varchar(255),\n 'face_background_color' varchar(255),\n 'recv_msg_opt' integer,\n 'unread_count' integer,\n 'group_at_type' integer,\n 'latest_msg' varchar(1000),\n 'latest_msg_send_time' integer,\n 'draft_text' text,\n 'draft_text_time' integer,\n 'is_pinned' numeric,\n 'burn_duration' integer,\n 'is_private_chat' numeric,\n 'is_not_in_group' numeric,\n 'update_unread_count_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'max_seq' integer,\n 'min_seq' integer,\n 'has_read_seq' integer,\n 'msg_destruct_time' integer default 604800,\n 'is_msg_destruct' numeric default false,\n primary key ('conversation_id')\n )\n ")}(r),a=function(e){return e.exec("\n create table if not exists 'local_users' (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n primary key ('user_id')\n )\n ")}(r),u=function(e){return e.exec("\n create table if not exists 'local_blacks' (\n 'owner_user_id' varchar(64),\n 'block_user_id' varchar(64),\n 'nickname' varchar(255),\n 'face_url' varchar(255),\n 'gender' INTEGER,\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('owner_user_id', 'block_user_id')\n ) \n ")}(r),c=function(e){return e.exec("\n create table if not exists 'local_friends'\n (\n 'owner_user_id' varchar(64),\n 'friend_user_id' varchar(64),\n 'remark' varchar(255),\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'is_pinned' numeric,\n primary key ('owner_user_id', 'friend_user_id')\n ) \n ")}(r),l=function(e){return e.exec("\n create table if not exists 'local_groups'\n (\n 'group_id' varchar(64) PRIMARY KEY,\n 'name' TEXT,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' INTEGER,\n 'status' INTEGER,\n 'creator_user_id' varchar(64),\n 'group_type' INTEGER,\n 'owner_user_id' varchar(64),\n 'member_count' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' INTEGER,\n 'look_member_info' INTEGER,\n 'apply_member_friend' INTEGER,\n 'notification_update_time' INTEGER,\n 'notification_user_id' TEXT,\n 'display_is_read' numeric\n ) \n ")}(r),f=function(e){return e.exec('\n create table if not exists "local_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),h=function(e){return e.exec("\n create table if not exists 'local_group_members' (\n 'group_id' varchar(64),\n 'user_id' varchar(64),\n 'nickname' varchar(255),\n 'user_group_face_url' varchar(255),\n 'role_level' integer,\n 'join_time' integer,\n 'join_source' integer,\n 'inviter_user_id' text,\n 'mute_end_time' integer DEFAULT 0,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n PRIMARY KEY ('group_id', 'user_id')\n ) \n ")}(r),d=function(e){return e.exec('\n create table if not exists "local_admin_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),_=function(e){return e.exec("\n create table if not exists 'local_friend_requests'\n (\n 'from_user_id' varchar(64),\n 'from_nickname' varchar(255),\n 'from_face_url' varchar(255),\n 'to_user_id' varchar(64),\n 'to_nickname' varchar(255),\n 'to_face_url' varchar(255),\n 'handle_result' INTEGER,\n 'req_msg' varchar(255),\n 'create_time' INTEGER,\n 'handler_user_id' varchar(64),\n 'handle_msg' varchar(255),\n 'handle_time' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('from_user_id', 'to_user_id')\n ); \n ")}(r),p=function(e){return e.exec("\n create table if not exists 'local_super_groups' (\n 'group_id' varchar(64),\n 'name' text,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'status' integer,\n 'creator_user_id' varchar(64),\n 'group_type' integer,\n 'owner_user_id' varchar(64),\n 'member_count' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' integer,\n 'look_member_info' integer,\n 'apply_member_friend' integer,\n 'notification_update_time' integer,\n 'notification_user_id' text,\n primary key ('group_id')\n )\n ")}(r),g=function(e){return e.exec("\n create table if not exists 'temp_cache_local_chat_logs' (\n 'client_msg_id' char(64),\n 'server_msg_id' char(64),\n 'send_id' char(64),\n 'recv_id' char(64),\n 'sender_platform_id' integer,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'sender_facebackground_color' varchar(255),\n 'session_type' integer,\n 'msg_from' integer,\n 'content_type' integer,\n 'content' varchar(1000),\n 'is_read' numeric,\n 'status' integer,\n 'seq' integer DEFAULT 0,\n 'send_time' integer,\n 'create_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'envelope_claimed_info' varchar(1024),\n 'transfer_claimed_info' varchar(1024),\n PRIMARY KEY ('client_msg_id')\n );\n ")}(r),m=function(e){return e.exec("\n create table if not exists 'local_notification_seqs'\n (\n 'conversation_id' char(128),\n 'seq' integer,\n PRIMARY KEY ('conversation_id')\n )\n ")}(r),v=function(e){return e.exec("\n create table if not exists 'local_sending_messages'\n (\n conversation_id varchar(128),\n client_msg_id varchar(64),\n ex varchar(1024),\n PRIMARY KEY ('conversation_id', 'client_msg_id')\n );\n ")}(r),y=function(e){return e.exec("\n create table if not exists 'local_conversation_unread_messages' (\n 'conversation_id' char(128),\n 'client_msg_id' char(64),\n 'send_time' integer,\n 'ex' varchar(1024),\n primary key (\n 'conversation_id',\n 'client_msg_id'\n )\n );\n ")}(r),b=function(e){return e.exec("\n create table if not exists 'local_app_sdk_version' (\n 'version' varchar(255),\n primary key ('version')\n ) \n ")}(r),w=function(e){return e.exec("\n create table if not exists 'local_sync_version' (\n 'table_name' varchar(255),\n 'entity_id' varchar(255),\n 'version_id' text,\n 'version' integer,\n 'create_time' integer,\n 'id_list' text,\n primary key ('table_name','entity_id')\n ) \n ")}(r);return function(e){!function(e){try{e.exec("\n ALTER TABLE local_friends ADD COLUMN is_pinned numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_groups ADD COLUMN display_is_read numeric;\n ")}catch(e){}}(e),function(e){try{const t=e.exec("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'chat_logs_%';");t.length>0&&t[0].values&&t[0].values.forEach((t=>{const r=t[0];try{e.exec(`ALTER TABLE '${r}' ADD COLUMN sender_facebackground_color varchar(255);`)}catch(e){}}));try{e.exec("ALTER TABLE temp_cache_local_chat_logs ADD COLUMN sender_facebackground_color varchar(255);")}catch(e){}try{e.exec("ALTER TABLE local_conversations ADD COLUMN face_background_color varchar(255);")}catch(e){}t.length>0&&t[0].values&&t[0].values.forEach((t=>{const r=t[0];try{e.exec(`ALTER TABLE '${r}' ADD COLUMN envelope_claimed_info varchar(1024);`)}catch(e){}try{e.exec(`ALTER TABLE '${r}' ADD COLUMN transfer_claimed_info varchar(1024);`)}catch(e){}}));try{e.exec("ALTER TABLE temp_cache_local_chat_logs ADD COLUMN envelope_claimed_info varchar(1024);")}catch(e){}try{e.exec("ALTER TABLE temp_cache_local_chat_logs ADD COLUMN transfer_claimed_info varchar(1024);")}catch(e){}}catch(e){}}(e)}(r),n.push(i,o,s,a,p,y,u,c,l,h,_,f,d,g,m,v,b,w),M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("close",(async function(){try{return await async function(){if(!Ct)return;(await Ct).close(),Ct=void 0}(),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessage",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}' limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",d.ErrorNoRecord,`no message with id ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMultipleMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendingMessageList",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status = 1;\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessageTimeAndStatus",(async function(e,t,r,n,i){try{const o=await Ht(),s=function(e,t,r,n,i,o){return e.exec(`\n UPDATE 'chat_logs_${t}' SET server_msg_id = '${n}', send_time = ${i}, status = ${o} WHERE client_msg_id = '${r}' and seq=0;\n `)}(o,e,t,r,n,i);if(0===o.getRowsModified())throw"updateMessageTimeAndStatus no record updated";return M(s)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMessageBySeq",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`seq = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessageBySeq no record updated";return M(i)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertMessage",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFields(r).toString();return e.exec(n)}(r,e,B(JSON.parse(t)));return M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertMessageList",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){y(e,t);const n=v.insert().into(`'chat_logs_${t}'`).setFieldsRows(r).toString();return e.exec(n)}(r,e,JSON.parse(t).map((e=>B(e))));return M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageList",(async function(e,t,r,n=!1){try{const i=function(e,t,r,n,i){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${i?">":"<"} ${n} ORDER BY send_time ${i?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageListNoTime",(async function(e,t,r=!1){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' ORDER BY send_time ${n?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("messageIfExists",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}';\n `)}(await Ht(),e,t);return M(0!==r.length)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByKeyword",(async function(e,t,r,n,i,o,s,a){try{const u=function(e,t,r,n,i,o,s,a,u){const c=s||(new Date).getTime();let l="";const f=r.map((e=>`${e}`)).join(","),h=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(l+="And ("),t+1>=n.length?l+="content like '%"+n[t]+"%') ":l+="content like '%"+n[t]+"%' "+h})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${c} \n AND status <=3 \n And content_type IN (${f}) \n ${l}\n ORDER BY send_time DESC LIMIT ${u} OFFSET ${a};\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o,s,a);return M(F(u[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByContentType",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=i||(new Date).getTime();return e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${n} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ORDER BY send_time DESC LIMIT ${s} OFFSET ${o};\n `)}(await Ht(),e,JSON.parse(t),r,n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchMessageByContentTypeAndKeyword",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=s||(new Date).getTime();let c="";const l=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(c+="And ("),t+1>=n.length?c+="content like '%"+n[t]+"%') ":c+="content like '%"+n[t]+"%' "+l})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ${c}\n ORDER BY send_time DESC;\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateMsgSenderFaceURLAndSenderNickname",(async function(e,t,r,n,i){try{return function(e,t,r,n,i,o){y(e,t);const s=`sender_face_url = '${n}', sender_nick_name = '${i}'${o?`, sender_facebackground_color = '${o}'`:""}`;e.exec(`\n UPDATE 'chat_logs_${t}' SET ${s} WHERE send_id = '${r}';\n `)}(await Ht(),e,t,r,n,i),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAlreadyExistSeqList",(async function(e,t){var r;try{const n=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(null!==(r=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]).map((e=>e.seq)))&&void 0!==r?r:[])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessageBySeq",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq = ${r} limit 1;\n `)}(await Ht(),e,t);return 0===r.length?M("",d.ErrorNoRecord,`no message with seq ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessagesByClientMsgIDs",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return 0===r.length?M("",d.ErrorNoRecord,`no message with clientMsgIDListStr ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMessagesBySeqs",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationNormalMsgSeq",(async function(e){var t,r;try{const n=function(e,t){return y(e,t),e.exec(`\n SELECT seq FROM 'chat_logs_${t}' order by seq desc limit 1;\n `)}(await Ht(),e);return M(null!==(r=null===(t=F(n[0],"CamelCase")[0])||void 0===t?void 0:t.seq)&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationPeerNormalMsgSeq",(async function(e,t){var r,n;try{const i=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' where send_id != '${r}' order by seq desc limit 1;\n `)}(await Ht(),e,t);return M(null!==(n=null===(r=F(i[0],"CamelCase")[0])||void 0===r?void 0:r.seq)&&void 0!==n?n:0)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE 1=1;\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markDeleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n UPDATE 'chat_logs_${t}' SET status = 2 WHERE (1=1) and (conversation_id = '${t}')';\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getUnreadMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_id != '${r}' and is_read = 0;\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationMessageAsReadBySeqs",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){y(e,t);const i=r.map((e=>`${e}`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE seq IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationMessageAsRead",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=r.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE client_msg_id IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationMsgs",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`)).join(",");return e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE client_msg_id IN (${n});\n `)}(await Ht(),e,JSON.parse(t));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("markConversationAllMessageAsRead",(async function(e,t){try{const r=await Ht();return function(e,t,r){e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE is_read = 0 and send_id != '${r}';\n `)}(r,e,JSON.parse(t)),M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchAllMessageByContentType",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE content_type = ${r};\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertSendingMessage",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_sending_messages").setFields(t).toString();return e.exec(r)}(t,B(JSON.parse(e)));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteSendingMessage",(async function(e,t){try{const r=function(e,t,r){const n=v.delete().from("local_sending_messages").where(`conversation_id = '${t}'`).where(`client_msg_id = '${r}'`).toString();return e.exec(n)}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllSendingMessages",(async function(){try{const e=function(e){const t=v.select().from("local_sending_messages").toString();return e.exec(t)}(await Ht());return M(F(e[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getLatestActiveMessage",(async function(e,t){try{const r=function(e,t,r){y(e,t);const n=r?"ASC":"DESC";return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status < 4 ORDER BY send_time ${n};\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time > 0 order by case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) desc;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationListToSync",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getHiddenConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time = 0;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversation",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where conversation_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",d.ErrorNoRecord,`no conversation with id ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getMultipleConversation",(async function(e){try{const t=await Ht(),r=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select * from local_conversations where conversation_id in (${r.join(",")});\n `)}(t,JSON.parse(e));return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsConversation",(async function(e,t){try{const r=await Ht();let n=t;"string"==typeof t&&(n=B(P(JSON.parse(t))));const i=function(e,t,r){const n=v.update().table("local_conversations").setFields(r).where(`conversation_id = '${t}'`).toString();return e.exec(n)}(r,e,n);if(0===r.getRowsModified())throw"updateColumnsConversation no record updated";return M(i)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("decrConversationUnreadCount",(async function(e,t){try{const r=function(e,t,r){e.exec("begin"),e.exec(`\n update local_conversations set \n unread_count=unread_count-${r} \n where conversation_id = '${t}';\n `);const n=e.exec(`select unread_count from local_conversations where conversation_id = '${t}'`);return Number(n[0].values[0])<0&&e.exec(`\n update local_conversations set \n unread_count=0 \n where conversation_id = '${t}';\n `),e.exec("commit")}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertConversationList",Gt),Kt.registerMethod("getTotalUnreadMsgCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n select sum(unread_count) from local_conversations where recv_msg_opt < 2 and latest_msg_send_time > 0;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertConversation",(async function(e){return Gt(`[${e}]`)})),Kt.registerMethod("getConversationByUserID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where user_id = "${t}" limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",d.ErrorNoRecord,`no conversation with userID ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getConversationListSplit",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_conversations\n WHERE latest_msg_send_time > 0\n ORDER BY case\n when is_pinned = 1 then 0\n else 1 end, max(latest_msg_send_time, draft_text_time) DESC\n LIMIT ${r} OFFSET ${t}\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversation",(async function(e){try{return function(e,t){e.exec(`\n DELETE\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllConversation",(async function(){try{return function(e){e.exec("\n DELETE FROM local_conversations;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchUpdateConversationList",(async function(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));return 0===r.length||r.forEach((e=>{!function(e,t){const r=v.update().table("local_conversations").setFields(t).where(`conversation_id = '${t.conversation_id}'`).toString();e.exec(r)}(t,e)})),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("conversationIfExists",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT count(*)\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e);return M(0!==t.length)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("resetConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("resetAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("clearConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("clearAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setConversationDraft",(async function(e,t){try{return function(e,t,r){const n=(new Date).getTime();e.exec(`\n update local_conversations\n set draft_text='${r}',\n draft_text_time=${n},\n latest_msg_send_time=case when latest_msg_send_time = 0 then ${n} else latest_msg_send_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("removeConversationDraft",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set draft_text="${r}",\n draft_text_time=0\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("unPinConversation",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set is_pinned=${r},\n draft_text_time=case when draft_text = "" then 0 else draft_text_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("incrConversationUnreadCount",(async function(e){try{const t=function(e,t){return e.exec(`\n update local_conversations set \n unread_count=unread_count+1 \n where conversation_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setMultipleConversationRecvMsgOpt",(async function(e,t){try{return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE local_conversations\n SET recv_msg_opt=${r}\n WHERE conversation_id IN (${n})\n `)}(await Ht(),JSON.parse(e),t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllSingleConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where conversation_type = 1;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllConversations",(async function(){try{const e=function(e){return e.exec("\n SELECT * FROM local_conversations\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchConversations",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_conversations\n WHERE show_name LIKE '%${t}%'\n ORDER BY latest_msg_send_time DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getLoginUser",(async function(e){try{const t=function(e,t){return e.exec(`\n select *, name as nickname from local_users where user_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",d.ErrorNoRecord,`no login user with id ${e}`):M(F(t[0],"CamelCase",[],{name:"nickname"})[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_users").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_users").setFields(t).where(`user_id = '${t.user_id}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));if(0===t.getRowsModified())throw"updateLoginUser no record updated";return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getStrangerInfo",(async function(e){try{const t=await Ht();return M(F(k(t,JSON.parse(e))[0],"CamelCase",[],{name:"nickname"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setStrangerInfo",(function(e){try{return JSON.parse(e).map((e=>B(P(e,{nickname:"name"})))).map((e=>async function(e){try{const t=await Ht(),r=k(t,[e.user_id]);return F(r[0]).length?function(e,t){const r=v.update().table("local_stranger").setFields(t).where(`user_id = '${t.user_id}'`).toString();e.exec(r)}(t,e):function(e,t){const r=v.insert().into("local_stranger").setFields(t).toString();e.exec(r)}(t,e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}}(e))),Promise.resolve(M(""))}catch(e){return console.error(e),Promise.resolve(M(void 0,d.ErrorInit,JSON.stringify(e)))}})),Kt.registerMethod("getAppSDKVersion",(async function(){try{const e=R(await Ht());return 0===e.length?M("",d.ErrorNoRecord,"no app version with database"):M(F(e[0],"CamelCase",[])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setAppSDKVersion",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e))),n=F(R(t)[0],"CamelCase",[]);return n[0]&&n[0].version?(function(e,t,r){const n=v.update().table("local_app_sdk_version").setFields(r).where(`version = '${t}'`).toString();e.exec(n)}(t,n[0].version,r),M("")):(function(e,t){const r=v.insert().into("local_app_sdk_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getVersionSync",(async function(e,t){try{const r=N(await Ht(),e,t);if(0===r.length)return M("",d.ErrorNoRecord,`no sync version with tableName ${e}, entityID ${t}`);const n=F(r[0],"CamelCase",[],{id_list:"uidList"})[0];return n.uidList=JSON.parse(n.uidList),M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setVersionSync",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e)));r.id_list=JSON.stringify(r.uid_list),delete r.uid_list;const n=F(N(t,r.table_name,r.entity_id)[0],"CamelCase",[]);return n[0]&&n[0].tableName?(function(e,t,r,n){delete n.table;const i=v.update().table("local_sync_version").setFields(n).where(`table_name = '${t}' AND entity_id = '${r}'`).toString();e.exec(i)}(t,n[0].tableName,n[0].entityID,r),M("")):(function(e,t){delete t.table;const r=v.insert().into("local_sync_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteVersionSync",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}";\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedSuperGroupList",(async function(){try{const e=await Ht();return M(F(b(e)[0]))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedSuperGroupIDList",(async function(){try{const e=await Ht(),t=F(b(e)[0]);return M(t.map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSuperGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_super_groups where group_id = '${t}' LIMIT 1;\n `)}(await Ht(),e);return 0===t.length?M("",d.ErrorNoRecord,`no super group with id ${e}`):M(F(t[0])[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteSuperGroup",(async function(e){try{const t=function(e,t){return e.exec(`\n delete from local_super_groups where group_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertSuperGroup",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_super_groups").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{groupName:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateSuperGroup",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.update().table("local_super_groups").setFields(r).where(`group_id = '${t}'`).toString();return e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"})));if(0===r.getRowsModified())throw"updateSuperGroup no record updated";return M(n)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteConversationUnreadMessageList",(async function(e,t){try{const r=await Ht();!function(e,t,r){e.exec(`\n delete from local_conversation_unread_messages where conversation_id = '${t}' and send_time <= ${r};\n `)}(r,e,t);return M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertConversationUnreadMessageList",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_conversation_unread_messages").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackList",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{block_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackListUserID",(async function(){try{const e=function(e){return e.exec("\n SELECT block_user_id\n FROM local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackInfoByBlockUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_blacks\n WHERE owner_user_id = "${r}"\n AND block_user_id = "${t}"\n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBlackInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_blacks\n where block_user_id in (${r.join(",")})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_blacks").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"block_user_id",name:"nickname"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteBlack",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_blacks\n where owner_user_id = "${r}"\n and block_user_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_blacks").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and block_user_id = '${t.block_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_friend_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteFriendRequestBothUserID",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friend_requests").setFields(t).where(`from_user_id = '${t.from_user_id}' and to_user_id = '${t.to_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getRecvFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friend_requests\n where to_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_friend_requests\n where from_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendApplicationByBothID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n limit 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getBothFriendReq",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where (from_user_id = "${t}"\n and to_user_id = "${r}")\n or (from_user_id = "${r}"\n and to_user_id = "${t}")\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroup",(async function(e){try{const t=await Ht();return E(t,B(P(JSON.parse(e),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroup",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_groups \n WHERE group_id="${t}" \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroup",(async function(e,t){try{const r=await Ht();return function(e,t,r){const n=v.update().table("local_groups").setFields(r).where(`group_id = '${t}'`).toString();e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedGroupList",(async function(){try{const e=await Ht();return M(F(O(e)[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT *\n FROM local_groups\n WHERE group_id = "${t}"\n `)}(await Ht(),e);return 0===t.length?M("",d.ErrorNoRecord,`no group with id ${e}`):M(F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"})[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupInfoByGroupIDOrGroupName",(async function(e,t,r){try{const n=function(e,t,r,n){let i="";const o=`group_id like "%${t}%"`,s=`name like "%${t}%"`;return r&&(i=o),n&&(i=s),n&&r&&(i=o+" or "+s),e.exec(`\n select *\n from local_groups\n where ${i}\n order by create_time desc\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("subtractMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count-1 where group_id = '${t}'\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("addMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count+1 where group_id = '${t}' \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedWorkingGroupIDList",(async function(){try{const e=await Ht(),t=F(O(e)[0],"CamelCase",["displayIsRead"]),r=[];return t.forEach((e=>{2===e.groupType&&r.push(e.groupID)})),M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getJoinedWorkingGroupList",(async function(){try{const e=O(await Ht()),t=F(e[0],"CamelCase",["displayIsRead"],{name:"groupName"}).filter((e=>2===e.groupType));return M(JSON.stringify(t))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberAllGroupIDs",(async function(){try{const e=function(e){return e.exec("\n select distinct group_id from local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",["displayIsRead"]).map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroups",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select * from local_groups where group_id in (${r});\n `)}(await Ht(),JSON.parse(e)),r=F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"});return M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertGroup",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{groupName:"name"}));return E(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllGroup",(async function(){try{return function(e){e.exec("\n DELETE FROM local_groups;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberInfoByGroupIDUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_group_members\n WHERE group_id = "${t}" \n AND user_id = "${r}" \n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupMemberList",(async function(){try{const e=function(e){return e.exec("\n SELECT *\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllGroupMemberUserIDList",(async function(){try{const e=function(e){return e.exec("\n SELECT user_id\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberCount",(async function(e){var t,r;try{const n=function(e,t){return e.exec(`\n SELECT count(*) FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(null===(r=null===(t=n[0])||void 0===t?void 0:t.values[0])||void 0===r?void 0:r[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupSomeMemberInfo",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_group_members\n where group_id = "${t}"\n and user_id in (${n.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupAdminID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 3\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListSplit",(async function(e,t,r,n,i){try{const o=function(e,t,r,n,i,o){let s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `;return 1===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n LIMIT ${i} OFFSET ${n}\n `),2===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),3===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),4===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),5===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),6===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id != "${o}" \n LIMIT ${i} OFFSET ${n}\n `),e.exec(s)}(await Ht(),e,t,r,n,i);return M(F(o[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberOwnerAndAdmin",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1 \n ORDER BY role_level DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberOwner",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 2\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListSplitByJoinTimeFilter",(async function(e,t,r,n=0,i=1e11,o){try{const s=function(e,t,r,n,i=0,o=1e11,s){let a="";a=0===s.length?`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n And user_id NOT IN (${s.map((e=>`'${e}'`)).join(",")})\n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,JSON.parse(o));return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupOwnerAndAdminByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberUIDListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFieldsRows(t).toString();e.exec(r)}(t,(JSON.parse(e)||[]).map((e=>B(P(e,{faceURL:"user_group_face_url"}))))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupMember",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}" \n and user_id="${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupAllMembers",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_members").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupMemberField",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=v.update().table("local_group_members").setFields(n).where(`group_id = '${t}' and user_id = '${r}'`).toString();e.exec(i)}(n,e,t,B(P(JSON.parse(r),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchGroupMembers",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){let a="";a=r?n&&i?`\n SELECT * FROM local_group_members \n WHERE ( user_id like "%${t}%" or nickname like "%${t}%" ) \n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||i?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`}\n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n&&n?`\n SELECT * FROM local_group_members \n WHERE user_id like "%${t}%" or nickname like "%${t}%" \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||n?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`} \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,o);return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getUserJoinedGroupIDs",(async function(e){try{const t=function(e,t){return e.exec(`\n select group_id from local_group_members where user_id = "${t}";\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getGroupMemberListByUserIDs",(async function(e,t,r){try{const n=function(e,t,r,n){const i=n.map((e=>`'${e}'`));let o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `;return 1===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n And user_id IN (${i.join(",")})\n `),2===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),3===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),4===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),5===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),e.exec(o)}(await Ht(),e,t,JSON.parse(r));return M(F(n[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getSendGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_admin_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAdminGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_admin_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_admin_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAdminGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_admin_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("insertFriend",(async function(e){try{const t=await Ht();return w(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteFriend",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_friends \n WHERE owner_user_id="${r}" \n and friend_user_id="${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateFriend",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friends").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and friend_user_id = '${t.friend_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getAllFriendList",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${t}"\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("searchFriendList",(async function(e,t,r,n){try{const i=function(e,t,r,n,i){let o="";const s=`name like "%${t}%"`,a=`remark like "%${t}%"`;return r&&(o=`friend_user_id like "%${t}%"`),n&&(o=o?o+" or "+s:s),i&&(o=o?o+" or "+a:a),e.exec(`\n select *\n from local_friends\n where ${o}\n order by create_time desc\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendInfoByFriendUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${r}"\n and friend_user_id = "${t}"\n limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",d.ErrorNoRecord,`no friend with id ${e}`):M(F(r[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"})[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select *\n from local_friends\n where friend_user_id in (${r})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getPageFriendList",(async function(e,t,r){try{const n=function(e,t,r,n){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${n}"\n order by name\n limit ${r} offset ${t}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("updateColumnsFriend",(async function(e,t){try{const r=await Ht(),n=B(P(JSON.parse(t),{userID:"friend_user_id",nickname:"name"}));return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(","),i=v.update().table("local_friends").setFields(r).where(`friend_user_id IN (${n})`).toString();e.exec(i)}(r,JSON.parse(e),n),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getFriendListCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n SELECT COUNT(*) FROM local_friends;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertFriend",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{userID:"friend_user_id",nickname:"name"}));return w(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("deleteAllFriend",(async function(){try{return function(e){e.exec("\n DELETE FROM local_friends;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertTempCacheMessageList",Yt),Kt.registerMethod("InsertTempCacheMessage",(async function(e){return Yt(`[${e}]`)})),Kt.registerMethod("getNotificationAllSeqs",(async function(){try{const e=function(e){return e.exec("SELECT * from local_notification_seqs where 1 = 1;")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("batchInsertNotificationSeq",(async function(e){try{const t=JSON.parse(e),r=await Ht();return t.map((e=>{const{conversationID:t,seq:n}=e;S(r,t,n)})),M("")}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("setNotificationSeq",(async function(e,t){try{const r=await Ht();let n=function(e,t,r){return e.exec(`UPDATE local_notification_seqs set seq = ${r} where conversation_id = "${t}"`)}(r,e,t);return 0===r.getRowsModified()&&(n=S(r,e,t)),M(n[0])}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("getExistedTables",(async function(){try{const e=function(e){return e.exec('\n SELECT name FROM sqlite_master WHERE type="table";\n ')}(await Ht());return M(F(e[0],"CamelCase",[],{tbl_name:"tblName"}))}catch(e){return console.error(e),M(void 0,d.ErrorInit,JSON.stringify(e))}})),Kt.registerMethod("exec",(async e=>{const t=await Ht();try{const r=t.exec(e);console.info(`sql debug with exec sql = ${e.trim()} , return `,r)}catch(t){console.info(`sql debug with exec sql = ${e} , return `,t)}})),Kt.registerMethod("getRowsModified",(async()=>{const e=await Ht();try{const t=e.getRowsModified();console.info("sql debug with getRowsModified return ",t)}catch(e){console.info("sql debug with getRowsModified return ",e)}})),Kt.registerMethod("exportDB",(async()=>{const e=await Ht();try{const t=e.export(),r=new Blob([t]);return URL.createObjectURL(r)}catch(e){console.info("sql export error, return ",e)}}))}();
|