prostgles-client 4.0.363 → 4.0.364

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/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(function(){try{return require("react")}catch(e){}}());else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(function(){try{return require("react")}catch(e){}}()):t(e.react);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(Object(this||window),e=>(()=>{var t={9515(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionQueuer=void 0,t.FunctionQueuer=class{queue=[];func;groupBy;constructor(e,t){this.func=e,this.groupBy=t}isRunning=!1;async run(e){const t=new Promise((t,n)=>{const r={arguments:e,onResult:t,onFail:n};this.queue.push(r)});return this.startQueueJob(),t}startQueueJob=async()=>{if(this.isRunning)return;this.isRunning=!0;const e=async e=>{if(e)try{const t=await this.func(...e.arguments);e.onResult(t)}catch(t){e.onFail(t)}};if(this.groupBy){const t=new Set,n=[];this.queue.forEach(e=>{const r=this.groupBy(e.arguments);t.has(r)||(t.add(r),n.push(e))}),n.slice(0).reverse().forEach(e=>{this.queue.splice(this.queue.indexOf(e),1)}),await Promise.all(n.map(t=>e(t)))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&this.startQueueJob()}}},3333(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.mergeDeep=void 0;const r=n(3316),i="undefined"!=typeof window;t.mergeDeep=(e,n)=>{const i=e?(0,t.quickClone)(e):e,s=n?(0,t.quickClone)(n):n,o=(0,r.isObject)(i)?{...i}:{};return(0,r.isObject)(i)&&(0,r.isObject)(s)&&Object.keys(s).forEach(e=>{const n=s[e],a=i[e];(0,r.isObject)(n)&&(0,r.isObject)(a)?o[e]=(0,t.mergeDeep)(a,n):o[e]=(0,t.quickClone)(n)}),o},t.quickClone=e=>{if(i&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map(e=>(0,t.quickClone)(e));if((0,r.isObject)(e)){const n={};return(0,r.getKeys)(e).map(r=>{n[r]=(0,t.quickClone)(e[r])}),n}return e}},2400(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSync=void 0;const r=n(3316),i=n(9889),s=n(9331),o=n(4114),a=n(8838),c=n(3333);t.createSync=async(e,t)=>{const n=(0,o.createSyncStateUtils)(e,t),{state:u,onDebug:d,id_fields:p,synced_field:h,throttle:f,batch_size:y,columns:m,_syncInfo:g,initializeSync:b,filter:_}=n,v=(0,s.createSyncDataStore)({...g,columns:m,filter:_}),O={id_fields:p,synced_field:h,throttle:f},S=await b({onSyncRequest:e=>{let t={c_lr:void 0,c_fr:void 0,c_count:0};const n=v.getBatch(e),r=n[0],i=n[n.length-1];return r&&i&&(t={c_fr:v.getRowSyncObj(r),c_lr:v.getRowSyncObj(i),c_count:n.length}),d({command:"onUpdates",data:{syncBatchParams:e,batch:n,clientSyncInfo:t}}),t},onPullRequest:async e=>{const t=v.getBatch(e);return await d({command:"onPullRequest",data:{syncBatchParams:e,data:t}}),{data:t}},onUpdates:async e=>{if(await d({command:"onUpdates",data:{onUpdatesParams:e}}),"err"in e&&e.err)t=e.err,console.error("Sync internal error: ",t);else if("isSynced"in e&&e.isSynced&&!u.isSynced){u.isSynced=e.isSynced;const t=v.getItems().map(e=>({...e}));v.setItems([]);const n=t.map(e=>({idObj:v.getIdObj(e),delta:{...e}}));await E(n,!0)}else if("data"in e){const t=e.data.map(e=>({idObj:v.getIdObj(e),delta:e}));await E(t,!0)}else console.error("Unexpected onUpdates");var t;return!0}}),w=new i.WAL({...O,batch_size:y,onSendStart:()=>{l&&(window.onbeforeunload=function(){return"Data may be lost. Are you sure?"})},onSend:async(e,t)=>t.map(e=>e.current).length?S.syncData(e):[],onSendEnd:()=>{l&&(window.onbeforeunload=null)}}),E=async(e,t=!1)=>{if(!(e&&e.length||t))throw"No data provided for upsert";const n=[];let i;const s=[];await Promise.all(e.map(async(e,o)=>{const a={...e.idObj};let l={...e.delta};Object.keys(l).map(e=>{void 0===l[e]&&(l[e]=null)}),t||v.checkItemCols({...e.delta,...e.idObj});const u=v.getItem(a);!t&&!(0,r.isEmpty)(l)||(0,r.isEmpty)(u)||(l=v.getDelta(u||{},l)),t||(l[h]=Date.now());let d={...u,...l,...a};u&&!t&&e.opts?.deepMerge&&(d=(0,c.mergeDeep)({...u,...a},{...l})),i=u?u[h]<d[h]?"updated":"unchanged":"inserted",v.setItem(d);const p={idObj:a,delta:l,oldItem:u,newItem:d,status:i,from_server:t};return t||s.push({initial:u,current:{...d}}),(0,r.isEmpty)(p.delta)||n.push(p),!0})).catch(e=>{console.error("SyncedTable failed upsert: ",e)}),T.notifyWal.addData(n.map(e=>({initial:e.oldItem,current:e.newItem}))),!t&&s.length&&w.addData(s)},T=(0,a.createSyncSubscriptionManager)({id_fields:p,synced_field:h},v,n,E);return v.setItems(S.syncInfo.data),S.syncInfo.isSynced?u.isSynced=!0:S.syncData(),T};const l="undefined"!=typeof window},9331(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncDataStore=void 0;const r=n(3316),i=n(3333);t.createSyncDataStore=({id_fields:e,synced_field:t,filter:n,columns:s})=>{const o=new Map,a=e.sort(),c=[t,...e].sort(),l=e=>a.map(t=>`${e[t]||""}`).join("."),u=()=>{let s=[];s=Array.from(o.values()).map(e=>({...e}));const a=[t,...e.sort()];return s=s.filter(e=>!n||!(0,r.getKeys)(n).find(t=>e[t]!==n[t])).sort((e,t)=>a.map(n=>e[n]<t[n]?-1:e[n]>t[n]?1:0).find(e=>e)),(0,i.quickClone)(s)};return{getItems:u,getBatch:({from_synced:e,to_synced:n,offset:r,limit:i}={offset:0,limit:void 0})=>{let s=u().map(e=>({...e})).filter(r=>(!Number.isFinite(e)||+r[t]>=+e)&&(!Number.isFinite(n)||+r[t]<=+n));return(r||i)&&(s=s.splice(r??0,i||s.length)),s},getIdObj:e=>{const t={};return a.map(n=>{t[n]=e[n]}),t},getRowSyncObj:e=>{const t={};return c.map(n=>{t[n]=e[n]}),t},getDelta:(t,n)=>(0,r.isEmpty)(t)?{...n}:Object.fromEntries(Object.entries({...n}).filter(([t])=>!e.includes(t)).map(([e,n])=>{if(!(0,r.isEqual)(n,t[e]))return[e,(0,r.isObject)(n)?{...n}:Array.isArray(n)?n.slice(0):n]}).filter(r.isDefined)),setItems:e=>{const t=(0,i.quickClone)(e);o.clear(),t.forEach(e=>{const t=l(e);o.set(t,{...e})})},checkItemCols:e=>{if(s.length){const t=Object.keys({...e}).filter(e=>!s.find(t=>t.name===e));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},setItem:(e,t=!1,n=!1)=>{const r=(0,i.quickClone)(e),s=l(r);if(n)o.delete(s);else{const e=o.get(s)??{};o.set(s,t?{...r}:{...e,...r})}},getItem:e=>{const t=o.get(l(e));return(0,i.quickClone)(t)},matchesIdObj:(t,n)=>Boolean(t&&n&&!e.sort().find(e=>t[e]!==n[e])),matchesFilter:e=>Boolean(e&&(!n||(0,r.isEmpty)(n)||!Object.keys(n).find(t=>n[t]!==e[t])))}}},4114(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncStateUtils=void 0;const r=n(3316);t.createSyncStateUtils=(e,t)=>{const{db:n,name:i,select:s="*",filter:o={},columns:a}=t,c=(0,r.getSyncChannelName)({filter:o,select:s,tableName:i}),l=e=>t.onDebug?.({...e,type:"sync",tableName:i,channelName:c,options:t});l({command:"create",data:{name:i,filter:o,select:s}});const u=n[i];if(!u)throw`${i} table not found in db`;const{_syncInfo:d}=u;if(!d)throw`${i} table does not support sync`;const{id_fields:p,synced_field:h,throttle:f=100,batch_size:y=50}=d;if(!p.length||!h)throw"id_fields/synced_field missing";return{state:{isSynced:!1},onDebug:l,id_fields:p,synced_field:h,throttle:f,batch_size:y,columns:a,_syncInfo:d,initializeSync:async t=>{const n=await new Promise((t,n)=>{e.emit(r.CHANNEL_PREFIX,{tableName:i,command:"sync",param1:o,param2:{select:s}},(e,r)=>{e?(console.error(e),n(e)):r&&t(r)})}),a=function(e,n){if(!e)return;const{onUpdates:r,onSyncRequest:i,onPullRequest:s}=t;l({command:e.data?"onUpdates":e.onSyncRequest?"onSyncRequest":"onPullRequest",data:e}),e.data?Promise.resolve(r(e)).then(()=>{n({ok:!0})}).catch(e=>{n({err:e})}):e.onSyncRequest?Promise.resolve(i(e.onSyncRequest)).then(e=>n({onSyncRequest:e})).catch(e=>{n({err:e})}):e.onPullRequest?Promise.resolve(s(e.onPullRequest)).then(e=>{n(e)}).catch(e=>{n({err:e})}):console.log("unexpected response")};return e.on(c,a),{syncInfo:n,unsync:()=>new Promise((t,n)=>{e.emit(c+"unsync",{},(e,r)=>{e?n(e):t(r)}),e.removeListener(c,a)}),syncData:function(n,r,i){e.emit(c,{onSyncRequest:{...t.onSyncRequest({}),data:n,deleted:r}},i?e=>{i(e)}:null)}}},filter:o,select:s,tableHandler:u}}},8838(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncSubscriptionManager=void 0;const r=n(9889);t.createSyncSubscriptionManager=({id_fields:e,synced_field:t},n,i,s)=>{let o=[],a=[];const c=e=>(a=a.filter(t=>t._onChange!==e),o=o.filter(t=>t._onChange!==e),"ok"),{state:l,onDebug:u}=i,d=(e=[])=>{if(!l.isSynced)return void u({command:"notifySubscribers",data:[],info:"not synced yet"});u({command:"notifySubscribers",data:e});const t=[],r=[],i=[];if(e.map(({idObj:e,newItem:s,delta:o})=>{a.filter(t=>n.matchesIdObj(t.idObj,e)).map(async e=>{try{await e.notify(s,o)}catch(e){console.error("SyncedTable failed to notify: ",e)}}),n.matchesFilter(s)&&(t.push(s),r.push(o),i.push(e))}),o.length){const e=[],i=[];n.getItems().map(s=>{e.push({...s});const o=t.findIndex(e=>n.matchesIdObj(s,e));i.push(r[o])}),o.map(async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}})}},p=new r.WAL({id_fields:e,synced_field:t,batch_size:1/0,throttle:5,onSend:async(e,t)=>{d(t.map(e=>({delta:n.getDelta(e.initial??{},e.current),idObj:n.getIdObj(e.current),newItem:e.current})))}}),h=async(e,t=!1)=>{const r=n.getIdObj(e);return n.setItem(r,!0,!0),t||await(i.tableHandler.delete?.(r)),d(),!0},f=({onChange:e,handlesOnData:t})=>{const r={$unsync:()=>c(e),getItems:()=>n.getItems(),$upsert:e=>{if(!e)throw"No data provided for upsert";const t=e=>({idObj:n.getIdObj(e),delta:e});Array.isArray(e)?s(e.map(e=>t(e))):s([t(e)])}};return{sub:{_onChange:e,handlesOnData:t,handles:r,notify:(r,i)=>{let o=[...r];const a=[...i];return t&&(o=o.map((r,i)=>{const o=(r,i)=>({...r,...m(i,e),$get:()=>o(n.getItem(i),i),$find:e=>o(n.getItem(e),e),$update:(e,t)=>s([{idObj:i,delta:e,opts:t}]),$delete:async()=>h(i),$cloneMultiSync:e=>y(e,t)}),a=n.getIdObj(r);return o(r,a)})),e(o,a)}},handles:r}},y=(e,t=!0)=>{const{sub:r,handles:i}=f.bind(this)({onChange:e,handlesOnData:t});return o.push(r),setTimeout(()=>{const e=n.getItems();r.notify(e,e)},0),Object.freeze({...i})},m=(e,t)=>{const r={$get:()=>n.getItem(e),$find:e=>n.getItem(e),$unsync:()=>c(t),$delete:()=>h(e),$update:(t,n)=>(a.length||o.length||console.warn("No sync listeners"),s([{idObj:e,delta:t,opts:n}])),$cloneSync:t=>g(e,t),$cloneMultiSync:e=>y(e,!0)};return r},g=(e,t,n=!0)=>{const r=m(e,t),i={_onChange:t,idObj:e,handlesOnData:n,handles:r,notify:(e,i)=>{const s={...e};return n&&(s.$get=r.$get,s.$find=r.$find,s.$update=r.$update,s.$delete=r.$delete,s.$unsync=r.$unsync,s.$cloneSync=r.$cloneSync),t(s,i)}};return a.push(i),setTimeout(()=>{const e=r.$get();e&&i.notify(e,e)},0),Object.freeze({...r})};return{sync:y,syncOne:g,notifyWal:p}}},2886(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const r=n(3316),i=n(9653);t.getAuthHandler=({authData:e,socket:n,onReload:s,endpoint:o,...a})=>{const c=e=>{const{search:t}=window.location;let n=e+t;return o&&(n=`${o}${n}`),n};if(e?.pathGuard&&i.isClientSide){const e=e=>{e?.shouldReload&&(s?s():i.isClientSide&&(console.log("prostgles page reload due to auth guard",e),setTimeout(()=>{window.location.reload()},200)))};n.emit(r.CHANNELS.AUTH_GUARD,JSON.stringify(window.location),(t,n)=>{e(n)}),n.removeAllListeners(r.CHANNELS.AUTH_GUARD),n.on(r.CHANNELS.AUTH_GUARD,t=>{e(t)})}const l={loginType:e?.login?.mode,login:void 0,preferredLogin:e?.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,confirmEmail:void 0,providers:e?.providers};if(e){const{providers:n,signupWithEmailAndPassword:i,login:s}=e;l.loginWithProvider=(0,r.isEmpty)(n)?void 0:n&&Object.entries(n).reduce((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e),{}),l.login=s&&(async e=>(0,t.authRequest)(c(s.loginRoute),e,"POST",a)),l.signupWithEmailAndPassword=i&&(e=>(0,t.authRequest)(c(i.url),e,"POST",a)),l.confirmEmail=i&&(e=>(0,t.authRequest)(c(i.emailConfirmationRoute),e,"POST",a))}return e?.user?{isLoggedin:!0,user:e.user,logout:async()=>{const{logoutRoute:n}=e.login??{};if(!n)throw new Error("Unexpected");return(0,t.authRequest)(c(n),{},"POST",a)},...l}:{isLoggedin:!1,user:void 0,...l}},t.authRequest=async(e,t,n,{credentials:r,redirect:i})=>{const s=await fetch(e,{method:n,headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)},credentials:r,redirect:i});if(!s.ok){const e=await s.json().catch(()=>s.text()).catch(()=>s.statusText);return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const o=await s.json().catch(async()=>({message:await s.text()})).catch(()=>({message:s.statusText}));return s.redirected?{...o,success:!0,redirect_url:s.url}:o}},9930(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDB=void 0;const r=n(3316),i=n(8552),s=n(1632),o=n(6469),a=n(3333),c=r.CHANNELS._preffix;t.getDB=({tableSchema:e,onDebug:t,syncHandlerV2:n,subscriptionHandler:l,socket:u})=>{const d=(e,t,n,i)=>{if(void 0!==e&&!(0,r.isObject)(e)||void 0!==t&&!(0,r.isObject)(t)||"function"!=typeof n||void 0!==i&&"function"!=typeof i)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},p=["subscribe","subscribeOne"],h={};return((0,a.quickClone)(e)??[]).forEach(({name:a,publishInfo:f,columns:y})=>{const m=(0,r.getAllowedTableMethods)({publishInfo:f});h[a]={};const g=h[a];m.sort((e,t)=>Number((0,r.includes)(p,e))-Number((0,r.includes)(p,t))).forEach(r=>{if("sync"===r){const e=f.select?.syncConfig;if(!e)throw`Table ${a} does not have syncConfig in publishInfo.select`;g._syncInfo={...e};const r=async(e,r={handlesOnData:!0},i)=>(await(t?.({type:"table",command:"syncOne",tableName:a,data:{basicFilter:e,options:r}})),d(e,r,i),(await n.getTableSyncFunctions({db:h,tableName:a,columns:y})).addSyncOne(e,r,i)),i=async(e,r={handlesOnData:!0},i)=>(await(t?.({type:"table",command:"sync",tableName:a,data:{basicFilter:e,options:r}})),d(e,r,i),(await n.getTableSyncFunctions({db:h,tableName:a,columns:y})).addSync(e,r,i));g.sync=i,g.syncOne=r,g.useSync=(e,t,n)=>(0,o.useSync)(i,e,t,n),g.useSyncOne=(e,t,n)=>(0,o.useSync)(r,e,t,n)}else if(p.includes(r)){const e=async function(e={},n={},i,s){return await(t?.({type:"table",command:r,tableName:a,data:{param1:e,param2:n,onChange:i,onError:s}})),d(e,n,i,s),l.addSub(h,{tableName:a,command:r,param1:e,param2:n},i,s)};g[r]=e;const n="subscribeOne",i="subscribe"===r?"useSubscribe":"subscribeOne"===r?"useSubscribeOne":void 0;i&&(g[i]=(t,i,o)=>(0,s.useSubscribe)(e,r===n,t,i,o)),r!==n&&p.includes(n)||(g[n]=async function(e,i,s){return await(t?.({type:"table",command:n,tableName:a,data:{param1:e,param2:i,onChange:s}})),d(e,i,s),l.addSub(h,{tableName:a,command:r,param1:e,param2:i},e=>{s(e[0])})})}else{const n=async function(n,i,s){if("getColumns"===r&&!n&&!i&&!s){const t=e?.find(e=>e.name===a)?.columns;if(t)return t}return await(t?.({type:"table",command:r,tableName:a,data:{param1:n,param2:i,param3:s}})),new Promise((e,t)=>{u.emit(c,{tableName:a,command:r,param1:n,param2:i,param3:s},(n,r)=>{n?t(n):e(r)})})};g[r]=n;const s="findOne"===r?"useFindOne":"find"===r?"useFind":"count"===r?"useCount":"size"===r?"useSize":void 0;s&&(g[s]=(e,t,r)=>(0,i.useFetch)(n,[e,t],r))}})}),{db:h}}},7030(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const r=n(3316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let i={};const s={};return JSON.parse(JSON.stringify(t)).map(({name:t,description:o,input:a,output:c})=>{const l=async function(i){return await(e?.({type:"method",command:t,data:{params:i}})),new Promise((e,s)=>{n.emit(r.CHANNELS.METHOD,{name:t,input:i},(t,n)=>{t?s(t):e(n)})})};i[t]={description:o,input:a,output:c,run:l},s[t]=l}),i=Object.freeze(i),{methodSchema:i,methodHandlers:s}}},3382(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const r=n(3316);t.getSqlHandler=({socket:e})=>{let t;const n={};return{sql:function(i,s,o){return new Promise((a,c)=>{e.emit(r.CHANNELS.SQL,{query:i,params:s,options:o},(r,i)=>{if(r)return c(r);if("stream"===o?.returnType){const{channel:t,unsubChannel:n}=i,r=r=>new Promise((i,s)=>{e.on(t,r),e.emit(t,{},(r,o)=>{o?(s(o),e.removeAllListeners(t)):i({pid:r,run:(n,r)=>new Promise((i,s)=>{e.emit(t,{query:n,params:r},(e,t)=>{t?s(t):i(e)})}),stop:t=>new Promise((r,i)=>{e.emit(n,{terminate:t},(e,t)=>{t?i(t):r(e)})})})})});return a({channel:t,unsubChannel:n,start:r})}if(o&&"noticeSubscription"===o.returnType&&i&&Object.keys(i).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(i).find(e=>"string"!=typeof e)){const n=i,r=r=>(((e,n,r)=>{t??={config:n,listeners:[]},t.listeners.length||(r.removeAllListeners(n.socketChannel),r.on(n.socketChannel,e=>{t&&t.listeners.length?t.listeners.map(t=>{t(e)}):r.emit(n.socketUnsubChannel,{})})),t.listeners.push(e)})(r,n,e),{...n,removeListener:()=>((e,n)=>{t&&(t.listeners=t.listeners.filter(t=>t!==e),!t.listeners.length&&t.config.socketUnsubChannel&&n&&n.emit(t.config.socketUnsubChannel,{}))})(r,e)}),s={...n,addListener:r};a(s)}else if(o&&o.returnType&&"statement"===o.returnType||!i||Object.keys(i).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(i).find(e=>"string"!=typeof e))a(i);else{const t=i,r=r=>(((e,t,r)=>{n[t.notifChannel]?n[t.notifChannel]?.listeners.push(e):(n[t.notifChannel]={config:t,listeners:[e]},r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,e=>{n[t.notifChannel]?.listeners.length?n[t.notifChannel].listeners.map(t=>{t(e)}):r.emit(n[t.notifChannel]?.config.socketUnsubChannel,{})}))})(r,t,e),{...i,removeListener:()=>((e,t,r)=>{const i=n[t.notifChannel];i&&(i.listeners=i.listeners.filter(t=>t!==e),!i.listeners.length&&i.config.socketUnsubChannel&&r&&(r.emit(i.config.socketUnsubChannel,{}),delete n[t.notifChannel]))})(r,t,e)}),s={...i,addListener:r};a(s)}})})}}}},395(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriptionHandler=void 0;const r=n(3316),i=n(9653),s=n(9515),o=r.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a=new Map,c=e=>new Promise((n,r)=>{t.emit(e,{},(e,t)=>{e?(console.error(e),r(e)):n(t)})});function l(e,r,s){return(0,i.debug)("_unsubscribe",{channelName:e,handler:s}),new Promise(i=>{const o=a.get(e);o?(o.handlers=o.handlers.filter(e=>e!==s),n?.({type:"table",command:"unsubscribe",tableName:o.tableName,unsubChannel:r,handlers:o.handlers}),o.handlers.length||(c(r),t.removeListener(e,o.onCall),a.delete(e)),i(!0)):i(!0)})}function u({tableName:e,command:n,param1:r,param2:i}){return new Promise((s,a)=>{t.emit(o,{tableName:e,command:n,param1:r,param2:i},(e,t)=>{e?(console.error(e),a(e)):t&&s(t)})})}const d=new s.FunctionQueuer(async function(e,{tableName:n,command:i,param1:s,param2:o},d){const p=(t,r)=>{let i={unsubscribe:function(){return l(t,r,d)},filter:{...s}};return e[n].update&&(i={...i,update:function(t,r){return e[n].update(s,t,r)}}),e[n].delete&&(i={...i,delete:function(t){return e[n].delete(s,t)}}),Object.freeze(i)},h=Array.from(a.entries()).find(([e,t])=>t.tableName===n&&t.command===i&&(0,r.isEqual)(t.param1||{},s||{})&&(0,r.isEqual)(t.param2||{},o||{}));if(h){const[e,t]=h;return t.handlers.push(d),setTimeout(()=>{const t=a.get(e);t?.lastData&&d(t.lastData)},10),p(e,t.unsubChannel)}const{channelName:f,channelNameReady:y,channelNameUnsubscribe:m}=await u({tableName:n,command:i,param1:s,param2:o}),g=function(e){const t=a.get(f),{data:n,err:r}=e;t?void 0!==n||void 0!==r?(t.lastData=n,t.handlers.forEach(e=>{void 0!==r&&console.error(`Error within running subscription \n ${f}`,r),e(n??[],r)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",f)};return t.on(f,g),a.set(f,{lastData:void 0,tableName:n,command:i,param1:s,param2:o,onCall:g,unsubChannel:m,handlers:[d],reAttach:async()=>{await c(m).catch(console.error),await u({tableName:n,command:i,param1:s,param2:o}),t.emit(y,{now:Date.now()})}}),t.emit(y,{now:Date.now()}),p(f,m)},([e,{tableName:t}])=>t);return{addSub:async(e,t,n,r)=>d.run([e,t,n]),subscriptions:a,addServerSub:u,_unsubscribe:l,reAttachAll:async()=>{await(n?.({type:"subscriptions",command:"reAttachAll.start",subscriptions:a}));for await(const e of Array.from(a.values()))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),e.onCall({data:[],err:t})}await(n?.({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},1953(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandlerV2=void 0;const r=n(3316),i=n(2400);t.getSyncHandlerV2=({socket:e,onDebug:t})=>{const n=new Map,s=async(s,o,a,c,l)=>{const u=(0,r.getSyncChannelName)({filter:c,select:l,tableName:a});return n.set(u,n.get(u)??{options:{tableName:a,filter:c,select:l},sync:(0,i.createSync)(e,{name:a,filter:c,select:l,onDebug:t,db:s,columns:o})}),n.get(u).sync};return{getTableSyncFunctions:async({db:e,tableName:t,columns:n})=>({addSync:async(r,i,o)=>{const{sync:a}=await s(e,n,t,r,i.select);return a(o,i.handlesOnData)},addSyncOne:async(r,i,o)=>{const{syncOne:a}=await s(e,n,t,r,i.select);return a(r,o,i.handlesOnData)}})}}},4926(e,t,n){"use strict";let r;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.reactImports=t.getReact=void 0;const i=(...e)=>{throw"Must install react"},s=(...e)=>{throw"Must install react"};t.getReact=e=>{try{r??=n(9155)}catch(e){}if(e&&!r)throw new Error("Must install react");return r},(0,t.getReact)();const{useEffect:o=i,useCallback:a=i,useRef:c,useState:l=s}=r??{},u={useEffect:o,useCallback:a,useRef:c,useState:l,getReact:()=>r};t.reactImports=u,t.__prglReactInstalled=()=>Boolean(r&&c)},7566(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useAsyncEffectQueue=void 0;const r=n(9501),i=n(4926),{useRef:s}=i.reactImports;t.useAsyncEffectQueue=(e,t,n)=>{const i=s(0),o=s(!0),a=s(),c=s(),l=async()=>{if("resolved"===c.current?.state){const{cleanup:e,effect:t,id:n}=c.current;c.current={id:n,state:"cleaning",effect:t},await e().catch(console.error),c.current={id:n,state:"cleaned",effect:t}}if(a.current&&(!c.current||"cleaned"===c.current.state)&&c.current?.id!==a.current.id){const e=a.current,{effect:t,id:n}=e;c.current={id:n,state:"resolving",effect:t};const r=await t().then(e=>async()=>{await(e?.())}).catch(e=>(console.error(e),async()=>{}));c.current={id:n,state:"resolved",effect:t,cleanup:r},o.current&&e===a.current&&c.current.id===a.current.id||l()}},u=s(null),d=()=>{n?(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l()},n)):l()};(0,r.useEffectDeep)(()=>(o.current=!0,a.current={effect:e,deps:t,id:++i.current},d(),()=>{o.current=!1,d()}),t)}},9501(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=void 0;const r=n(3316),i=n(4926),{getReact:s,useEffect:o,useRef:a}=i.reactImports,c=s();t.useDeepCompareMemoize=e=>{const t=a();return(0,r.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>c.useMemo(e,n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{o(e,n?.map(t.useDeepCompareMemoize))}},8552(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useFetch=void 0;const r=n(4926),{useState:i}=r.reactImports,s=n(7566),o=n(6912);t.useFetch=(e,t=[],n)=>{const{skip:r,deps:a=[]}=n??{},c={data:void 0,error:void 0,isLoading:!0},[{data:l,error:u,isLoading:d},p]=i(c),h=(0,o.useIsMounted)();return(0,s.useAsyncEffectQueue)(async()=>{if(h()&&!r){p(c);try{const n=await e(...t);if(!h())return;p({data:n,error:void 0,isLoading:!1})}catch(e){if(!h())return;p({data:void 0,error:e,isLoading:!1})}}},[e,...t,...a]),{data:l,error:u,isLoading:d}}},6912(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsMounted=void 0;const r=n(4926),{useEffect:i,useRef:s,useCallback:o}=r.reactImports;t.useIsMounted=()=>{const e=s(!0),t=o(()=>e.current,[]);return i(()=>(e.current=!0,()=>{e.current=!1}),[]),t}},1044(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=t.getIO=void 0;const r=n(9653),i=n(4926),s=n(7566),o=n(6912);t.getIO=(e=!1)=>{try{return n(8007)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useProstglesClient=({skip:e,socketOptions:n,endpoint:a,token:c,...l}={})=>{const{useRef:u,useState:d}=(0,i.getReact)(!0),[p,h]=d({isLoading:!0,hasError:!1}),f=(0,o.useIsMounted)(),y=u();return(0,s.useAsyncEffectQueue)(async()=>{if(e)return;y.current?.disconnect();const i=(0,t.getIO)(),s="string"==typeof n?{path:n}:n,o={withCredentials:l.credentials&&"omit"!==l.credentials,...s,reconnectionDelay:1e3,reconnection:!0};o.path??="/ws-api",c&&(o.auth={token:c});const u=a?i(a,o):i(o);return y.current=u,await(0,r.prostgles)({socket:u,endpoint:a,...l,onReady:e=>{f()?(l.onDebug?.({type:"onReady",data:e}),h({...e,hasError:!1,isLoading:!1})):l.onDebug?.({type:"onReady.notMounted",data:e})}}).catch(e=>{f()&&h({isLoading:!1,error:e,hasError:!0})}),()=>{u.disconnect(),u.emit=()=>{throw"Socket disconnected"}}},[l,n,e],80),p}},1632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSubscribe=void 0;const r=n(3316),i=n(4926),{useRef:s,useState:o}=i.reactImports,a=n(6912),c=n(7566);t.useSubscribe=(e,t,n,i,l)=>{const{skip:u}=l??{},d={data:void 0,error:void 0,isLoading:!0},[p,h]=o(d),f=s(p);f.current=p;const y=(0,a.useIsMounted)();return(0,c.useAsyncEffectQueue)(async()=>{if(!y()||u)return;(0,r.isEqual)(f.current,d)||h(d);const s=e=>{y()&&h({data:void 0,error:e,isLoading:!1})};try{const r=await e(n,i,e=>{y()&&h({data:t?e[0]:e,error:void 0,isLoading:!1})},s);return()=>{r.unsubscribe()}}catch(e){s(e)}},[e,n,i,u]),p}},6469(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSync=void 0;const r=n(4926),{useState:i}=r.reactImports,s=n(7566),o=n(6912);t.useSync=(e,t,n,r)=>{const{skip:a}=r??{},[{data:c,error:l,isLoading:u},d]=i({data:void 0,error:void 0,isLoading:!0}),p=(0,o.useIsMounted)();return(0,s.useAsyncEffectQueue)(async()=>{if(!p()||a)return;const r=e=>{p()&&d({data:void 0,error:e,isLoading:!1})};try{return(await e(t,n,e=>{p()&&d({data:e,error:void 0,isLoading:!1})},r)).$unsync}catch(e){r(e)}},[e,t,n,a]),{data:c,error:l,isLoading:u}}},9653(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.asName=t.debug=t.isClientSide=void 0,t.prostgles=function(e){const{endpoint:n,socket:r,onReady:i,onDisconnect:p,onReconnect:h,onSchemaChange:f,onReload:y,onDebug:m,credentials:g,redirect:b}=e;let _;(0,t.debug)("prostgles",{initOpts:e}),f&&(r.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),r.on(s.CHANNELS.SCHEMA_CHANGED,f));const v=(0,u.getSubscriptionHandler)(e),O=(0,d.getSyncHandlerV2)(e);let S;return new Promise((t,u)=>{r.removeAllListeners("connect_error"),r.on("connect_error",e=>{u(e)}),r.removeAllListeners(s.CHANNELS.CONNECTION),r.on(s.CHANNELS.CONNECTION,e=>(u(e),"ok")),p&&r.on("disconnect",()=>{S="disconnected",p()}),h&&r.on("connect",()=>{"disconnected"===S&&(S="reconnected")}),r.on(s.CHANNELS.SCHEMA,async d=>{await(m?.({type:"schemaChanged",data:d,state:S}));const{joinTables:p=[],...f}=d,{methods:w,tableSchema:E,auth:T,rawSQL:j,err:k}=f;if(_?.clientSchema&&(0,s.isEqual)(_.clientSchema,f)||console.warn("syncHandler.destroySyncs()"),k&&console.error("Error on schema change:",k),"connected"!==S&&"reconnected"!==S||!h)_={origin:"onReady",date:new Date,clientSchema:f};else{if(h(r,k),k)return;_={origin:"onReconnect",date:new Date,clientSchema:f}}if(k)return void u(k);const C="reconnected"===S;S="connected";const P=(0,o.getAuthHandler)({authData:T,socket:r,onReload:y,endpoint:n,credentials:g,redirect:b}),{methodHandlers:N,methodSchema:A}=(0,c.getMethods)({onDebug:m,methods:w,socket:r}),{db:x}=(0,a.getDB)({onDebug:m,syncHandlerV2:O,subscriptionHandler:v,socket:r,tableSchema:E}),R=j?(0,l.getSqlHandler)(e).sql:void 0;v.reAttachAll(),console.warn("syncHandler.reAttachAll()"),(async()=>{try{const e={db:x,sql:R,methods:N,methodSchema:A,tableSchema:E,auth:P,socket:r,isReconnect:C};await(m?.({type:"onReady.call",data:e,state:S})),await i(e)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}t(x)})()})})};const s=n(3316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(2886),a=n(9930),c=n(7030),l=n(3382),u=n(395),d=n(1953),p="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[p]&&window[p](...e)},i(n(9501),t),i(n(1044),t)},7833(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(736)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736(e,t,n){e.exports=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n}),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e,t){let n=0,r=0,i=-1,s=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(i=r,s=n,r++):(n++,r++);else{if(-1===i)return!1;r=i+1,s++,n=s}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=n(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},6585(e){var t=1e3,n=60*t,r=60*n,i=24*r,s=7*i;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,a){a=a||{};var c,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*s;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&isFinite(e))return a.long?(c=e,(l=Math.abs(c))>=i?o(c,l,i,"day"):l>=r?o(c,l,r,"hour"):l>=n?o(c,l,n,"minute"):l>=t?o(c,l,t,"second"):c+" ms"):function(e){var s=Math.abs(e);return s>=i?Math.round(e/i)+"d":s>=r?Math.round(e/r)+"h":s>=n?Math.round(e/n)+"m":s>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4357(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(8349);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},2602(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(8349),i=n(6867),s=n(3860);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const o=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:o,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&o(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},c=(0,r.getKeys)(a),l=(e,n,o=[],d)=>{const p=`${o.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,h=(0,t.getFieldTypeObj)(n),{type:f,allowedValues:y,nullable:m,optional:g}=h;if(m&&null===e)return;if(g&&void 0===e)return;if(y){if("string"!=typeof f)throw new Error("allowedValues is only supported for primitive types");const t=f.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=y.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${o.join(".")}[${e}]`:o.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(f){if((0,r.isObject)(f)){if(!(0,r.isObject)(e))return p;for(const t of(0,i.safeGetKeys)(f)){const n=(0,i.safeGetProperty)(f,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...o,t].join(".")} is missing but required`;const s=l((0,i.safeGetProperty)(e,t),n,[...o,t],d);if(void 0!==s)return s}if(!d?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(f),r=t.filter(e=>!n.includes(e));if(r.length)return`${o.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,s.includes)(c,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(f,h);return t(e,h)?void 0:p}if(h.enum){const t=[];return h.nullable&&t.push(null),h.optional&&t.push(void 0),h.enum.includes(e)?void 0:p}const b=h.arrayOf??(h.arrayOfType?{type:h.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return p+" an array";const t=e.map((e,t)=>l(e,b,[...o,`${t}`],d)).filter(r.isDefined)[0];return void 0!==t?`${p}. Error at index ${o.length>0?o.join(".")+".":""}\n\n${t}`:void 0}const _=h.oneOf??h.oneOfType?.map(e=>({type:e}));if(_){if(!_.length)return p+"to not be empty";let t;if(_.find(n=>{const r=l(e,n,o,d);return t??(t=r),void 0===r}))return;return p}if(h.record){const{keysEnum:t,partial:n,values:s}=h.record;if(!(0,r.isObject)(e))return p+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),c=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==c)return`${p} to have key ${c}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${p} has extra keys: ${u}`;if(s)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=l(n,s,[...o,t],d);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(h)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:s,optional:o,record:a}=n,c=n.oneOf??n.oneOfType?.map(e=>({type:e})),l=[];if(s&&l.push("null"),o&&l.push("undefined"),"string"==typeof i)l.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),l.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?l.push("null"):void 0===e?l.push("undefined"):"string"==typeof e?l.push(JSON.stringify(e)):l.push(e)}),c?.forEach(e=>{const t=u(e);l.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?l.push(`{ [${e.join(" | ")}]${r}: ${i} }`):l.push(`{ [key: string]${r}: ${i} }`)}return l.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,s)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=l(t,{type:e},[],s);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=l(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===s},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(s)throw new Error(s)}},4538(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(8349),i=n(6867),s=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:p,title:h,record:f,...y}="string"==typeof e?{type:e}:e;let m={};const g={...(y.enum||y.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:y.allowedValues?.slice(0)??y.enum.slice(0)},...!!l&&{description:l},...!!h&&{title:h}};if(y.enum?.length){const e=typeof y.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";m=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:s(o)?.type,...y.allowedValues&&{enum:y.allowedValues.slice(0)}}}:{type:s(o)?.type}}else if((0,r.isObject)(o))m={type:"object",required:(0,i.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(o).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})};else if(d||p){const e=d||p.map(e=>({type:e}));m={oneOf:e.map(e=>(0,t.getJSONSchemaObject)(e))}}else f&&(m={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...m}}},2129(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(6173),i=n(2602),s=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,i.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let s=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;s=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${s}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return d+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return d+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:s}=u,c=a?" ":" ";let p=` {${c}`+(0,r.getObjectEntries)(s).map(([r,s])=>{const a=(0,i.getFieldTypeObj)(s),u=o(r)?r:JSON.stringify(r);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(p=n(p)),a&&(p=p.split("\n").join("")),d+p}if(u.enum)return d+u.enum.map(e=>s(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,o=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>s(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},6867(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},9889(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(6173);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],s=+r-+i,o=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(s)?s:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:r,delta:i}),this.changed[s].current={...this.changed[s].current,...r},this.changed[s].delta={...this.changed[s].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:s,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],s=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,s)||(t[n]=s)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},s)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),(0,r.isEmpty)(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},4211(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4674(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},7178(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(8349);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},6173(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const s=n(8349),o=n(3860);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,s.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const s=i.columns.filter(e=>r.includes(e.name));return s.length?{ref:e,fcolsInfo:s}:void 0}).filter(s.isDefined),[i,...o]=r??[];if(!o.length)return i?.ref;const[a,...c]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(4211),t);var c=n(4674);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return c.CONTENT_TYPE_TO_EXT}}),i(n(7178),t),i(n(8428),t),i(n(4538),t),i(n(2129),t),i(n(4357),t),i(n(2602),t),i(n(367),t),i(n(8349),t),i(n(9889),t),i(n(1805),t)},3316(e){var t;Object(this||window),t=()=>(()=>{"use strict";var e={994(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(472);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(472),i=n(704),s=n(441);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const o=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:o,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&o(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},c=(0,r.getKeys)(a),l=(e,n,o=[],d)=>{const p=`${o.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,h=(0,t.getFieldTypeObj)(n),{type:f,allowedValues:y,nullable:m,optional:g}=h;if(m&&null===e)return;if(g&&void 0===e)return;if(y){if("string"!=typeof f)throw new Error("allowedValues is only supported for primitive types");const t=f.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=y.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${o.join(".")}[${e}]`:o.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(f){if((0,r.isObject)(f)){if(!(0,r.isObject)(e))return p;for(const t of(0,i.safeGetKeys)(f)){const n=(0,i.safeGetProperty)(f,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...o,t].join(".")} is missing but required`;const s=l((0,i.safeGetProperty)(e,t),n,[...o,t],d);if(void 0!==s)return s}if(!d?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(f),r=t.filter(e=>!n.includes(e));if(r.length)return`${o.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,s.includes)(c,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(f,h);return t(e,h)?void 0:p}if(h.enum){const t=[];return h.nullable&&t.push(null),h.optional&&t.push(void 0),h.enum.includes(e)?void 0:p}const b=h.arrayOf??(h.arrayOfType?{type:h.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return p+" an array";const t=e.map((e,t)=>l(e,b,[...o,`${t}`],d)).filter(r.isDefined)[0];return void 0!==t?`${p}. Error at index ${o.length>0?o.join(".")+".":""}\n\n${t}`:void 0}const _=h.oneOf??h.oneOfType?.map(e=>({type:e}));if(_){if(!_.length)return p+"to not be empty";let t;if(_.find(n=>{const r=l(e,n,o,d);return t??(t=r),void 0===r}))return;return p}if(h.record){const{keysEnum:t,partial:n,values:s}=h.record;if(!(0,r.isObject)(e))return p+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),c=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==c)return`${p} to have key ${c}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${p} has extra keys: ${u}`;if(s)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=l(n,s,[...o,t],d);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(h)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:s,optional:o,record:a}=n,c=n.oneOf??n.oneOfType?.map(e=>({type:e})),l=[];if(s&&l.push("null"),o&&l.push("undefined"),"string"==typeof i)l.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),l.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?l.push("null"):void 0===e?l.push("undefined"):"string"==typeof e?l.push(JSON.stringify(e)):l.push(e)}),c?.forEach(e=>{const t=u(e);l.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?l.push(`{ [${e.join(" | ")}]${r}: ${i} }`):l.push(`{ [key: string]${r}: ${i} }`)}return l.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,s)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=l(t,{type:e},[],s);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=l(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===s},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(s)throw new Error(s)}},699(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(472),i=n(704),s=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:p,title:h,record:f,...y}="string"==typeof e?{type:e}:e;let m={};const g={...(y.enum||y.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:y.allowedValues?.slice(0)??y.enum.slice(0)},...!!l&&{description:l},...!!h&&{title:h}};if(y.enum?.length){const e=typeof y.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";m=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:s(o)?.type,...y.allowedValues&&{enum:y.allowedValues.slice(0)}}}:{type:s(o)?.type}}else(0,r.isObject)(o)?m={type:"object",required:(0,i.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(o).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})}:d||p?m={oneOf:(d||p.map(e=>({type:e}))).map(e=>(0,t.getJSONSchemaObject)(e))}:f&&(m={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...m}}},394(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(806),i=n(897),s=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,i.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let s=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;s=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${s}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return d+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return d+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:s}=u,c=a?" ":" ";let p=` {${c}`+(0,r.getObjectEntries)(s).map(([r,s])=>{const a=(0,i.getFieldTypeObj)(s),u=o(r)?r:JSON.stringify(r);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(p=n(p)),a&&(p=p.split("\n").join("")),d+p}if(u.enum)return d+u.enum.map(e=>s(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,o=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>s(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704(e,t){t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},502(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(806);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],s=+r-+i,o=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(s)?s:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:r,delta:i}),this.changed[s].current={...this.changed[s].current,...r},this.changed[s].delta={...this.changed[s].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:s,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],s=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,s)||(t[n]=s)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},s)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),(0,r.isEmpty)(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},618(e,t){Object.defineProperty(t,"__esModule",{value:!0})},521(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(472);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const s=n(472),o=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,s.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const s=i.columns.filter(e=>r.includes(e.name));return s.length?{ref:e,fcolsInfo:s}:void 0}).filter(s.isDefined),[i,...o]=r??[];if(!o.length)return i?.ref;const[a,...c]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(618),t);var c=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return c.CONTENT_TYPE_TO_EXT}}),i(n(209),t),i(n(319),t),i(n(699),t),i(n(394),t),i(n(994),t),i(n(897),t),i(n(164),t),i(n(472),t),i(n(502),t),i(n(778),t)},319(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(472),i=(e="$leftJoin")=>(t,n,i,s={})=>({[e]:s.path??t,filter:n,...(0,r.omitKeys)(s,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},666(e,t){function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=s(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,r,c,t[6],9,-1069501632),c=s(c,l,n,r,t[11],14,643717713),r=s(r,c,l,n,t[0],20,-373897302),n=s(n,r,c,l,t[5],5,-701558691),l=s(l,n,r,c,t[10],9,38016083),c=s(c,l,n,r,t[15],14,-660478335),r=s(r,c,l,n,t[4],20,-405537848),n=s(n,r,c,l,t[9],5,568446438),l=s(l,n,r,c,t[14],9,-1019803690),c=s(c,l,n,r,t[3],14,-187363961),r=s(r,c,l,n,t[8],20,1163531501),n=s(n,r,c,l,t[13],5,-1444681467),l=s(l,n,r,c,t[2],9,-51403784),c=s(c,l,n,r,t[7],14,1735328473),n=o(n,r=s(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,r,c,t[8],11,-2022574463),c=o(c,l,n,r,t[11],16,1839030562),r=o(r,c,l,n,t[14],23,-35309556),n=o(n,r,c,l,t[1],4,-1530992060),l=o(l,n,r,c,t[4],11,1272893353),c=o(c,l,n,r,t[7],16,-155497632),r=o(r,c,l,n,t[10],23,-1094730640),n=o(n,r,c,l,t[13],4,681279174),l=o(l,n,r,c,t[0],11,-358537222),c=o(c,l,n,r,t[3],16,-722521979),r=o(r,c,l,n,t[6],23,76029189),n=o(n,r,c,l,t[9],4,-640364487),l=o(l,n,r,c,t[12],11,-421815835),c=o(c,l,n,r,t[15],16,530742520),n=a(n,r=o(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=p(n,e[0]),e[1]=p(r,e[1]),e[2]=p(c,e[2]),e[3]=p(l,e[3])}function r(e,t,n,r,i,s){return t=p(p(t,e),p(r,s)),p(t<<i|t>>>32-i,n)}function i(e,t,n,i,s,o,a){return r(t&n|~t&i,e,t,s,o,a)}function s(e,t,n,i,s,o,a){return r(t&i|n&~i,e,t,s,o,a)}function o(e,t,n,i,s,o,a){return r(t^n^i,e,t,s,o,a)}function a(e,t,n,i,s,o,a){return r(n^(t|~i),e,t,s,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(i,s),t=0;t<16;t++)s[t]=0;return s[14]=8*r,n(i,s),i}(e))}function p(e,t){return e+t&4294967295}d("hello")},164(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncChannelName=void 0;const r=n(806);t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join(".")},472(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},s={key:r,value:e[r]};return n(i,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const s=n<1?[r]:[0,r];e.slice(...s)!==t.slice(...s)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:i,to:s,text:t.slice(i,o),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(i);if(o&&(0,r.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const r=n(666);function i(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function s(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),s=JSON.parse((0,t.safeStringify)(r));return n?s:i(s,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])}},441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(102),t),i(n(436),t),i(n(441),t)},102(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let s=r.get(e);if(s?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(s||(s=new WeakSet,r.set(e,s)),s.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s],r,i))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const s of c){if(!(s in t))return!1;{const o=e[s],a=t[s];if(!n(o,a,r,i))return!1}}return!0}},436(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}(806)})(),e.exports=t()},8428(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(8349),i=(e="$leftJoin")=>(t,n,i,s={})=>({[e]:s.path??t,filter:n,...(0,r.omitKeys)(s,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},7913(e,t){"use strict";function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=s(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,r,c,t[6],9,-1069501632),c=s(c,l,n,r,t[11],14,643717713),r=s(r,c,l,n,t[0],20,-373897302),n=s(n,r,c,l,t[5],5,-701558691),l=s(l,n,r,c,t[10],9,38016083),c=s(c,l,n,r,t[15],14,-660478335),r=s(r,c,l,n,t[4],20,-405537848),n=s(n,r,c,l,t[9],5,568446438),l=s(l,n,r,c,t[14],9,-1019803690),c=s(c,l,n,r,t[3],14,-187363961),r=s(r,c,l,n,t[8],20,1163531501),n=s(n,r,c,l,t[13],5,-1444681467),l=s(l,n,r,c,t[2],9,-51403784),c=s(c,l,n,r,t[7],14,1735328473),n=o(n,r=s(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,r,c,t[8],11,-2022574463),c=o(c,l,n,r,t[11],16,1839030562),r=o(r,c,l,n,t[14],23,-35309556),n=o(n,r,c,l,t[1],4,-1530992060),l=o(l,n,r,c,t[4],11,1272893353),c=o(c,l,n,r,t[7],16,-155497632),r=o(r,c,l,n,t[10],23,-1094730640),n=o(n,r,c,l,t[13],4,681279174),l=o(l,n,r,c,t[0],11,-358537222),c=o(c,l,n,r,t[3],16,-722521979),r=o(r,c,l,n,t[6],23,76029189),n=o(n,r,c,l,t[9],4,-640364487),l=o(l,n,r,c,t[12],11,-421815835),c=o(c,l,n,r,t[15],16,530742520),n=a(n,r=o(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=p(n,e[0]),e[1]=p(r,e[1]),e[2]=p(c,e[2]),e[3]=p(l,e[3])}function r(e,t,n,r,i,s){return t=p(p(t,e),p(r,s)),p(t<<i|t>>>32-i,n)}function i(e,t,n,i,s,o,a){return r(t&n|~t&i,e,t,s,o,a)}function s(e,t,n,i,s,o,a){return r(t&i|n&~i,e,t,s,o,a)}function o(e,t,n,i,s,o,a){return r(t^n^i,e,t,s,o,a)}function a(e,t,n,i,s,o,a){return r(n^(t|~i),e,t,s,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.md5cycle=n,t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(i,s),t=0;t<16;t++)s[t]=0;return s[14]=8*r,n(i,s),i}(e))}function p(e,t){return e+t&4294967295}d("hello")},367(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncChannelName=void 0;const r=n(6173);t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join(".")},8349(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},s={key:r,value:e[r]};return n(i,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const s=n<1?[r]:[0,r];e.slice(...s)!==t.slice(...s)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:i,to:s,text:t.slice(i,o),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(i);if(o&&(0,r.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const r=n(7913);function i(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function s(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),s=JSON.parse((0,t.safeStringify)(r));return n?s:i(s,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])}},3860(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},1805(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(569),t),i(n(5485),t),i(n(3860),t)},569(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let s=r.get(e);if(s?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(s||(s=new WeakSet,r.set(e,s)),s.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s],r,i))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const s of c){if(!(s in t))return!1;{const o=e[s],a=t[s];if(!n(o,a,r,i))return!1}}return!0}},5485(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}},9155(t){"use strict";if(void 0===e){var n=new Error("Cannot find module 'react'");throw n.code="MODULE_NOT_FOUND",n}t.exports=e},4110(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},8661(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}},1015(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,i=e.indexOf("["),s=e.indexOf("]");-1!=i&&-1!=s&&(e=e.substring(0,i)+e.substring(i,s).replace(/:/g,";")+e.substring(s,e.length));let o=n.exec(e||""),a={},c=14;for(;c--;)a[r[c]]=o[c]||"";return-1!=i&&-1!=s&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}(0,a.query),a};const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},4624(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.globalThisShim=t.nextTick=void 0,t.createCookieJar=function(){},t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),t.defaultBinaryType="arraybuffer"},4956(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.SocketWithUpgrade=t.SocketWithoutUpgrade=t.Socket=void 0;const r=n(8223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return r.Socket}});var i=n(8223);Object.defineProperty(t,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return i.SocketWithoutUpgrade}}),Object.defineProperty(t,"SocketWithUpgrade",{enumerable:!0,get:function(){return i.SocketWithUpgrade}}),t.protocol=r.Socket.protocol;var s=n(4689);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return s.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return s.TransportError}});var o=n(9419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(5374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(1015);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(4624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(8209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(2071);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var p=n(2071);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return p.XHR}});var h=n(8716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return h.WS}});var f=n(8716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var y=n(4480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return y.WT}})},8223(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const i=n(9419),s=n(5374),o=n(8661),a=n(1015),c=n(4454),l=n(6376),u=n(4624),d=(0,r(n(7833)).default)("engine.io-client:socket"),p="function"==typeof addEventListener&&"function"==typeof removeEventListener,h=[];p&&addEventListener("offline",()=>{d("closing %d connection(s) because the network was lost",h.length),h.forEach(e=>e())},!1);class f extends c.Emitter{constructor(e,t){if(super(),this.binaryType=u.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=(0,a.parse)(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,s.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),p&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(d("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},h.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,u.createCookieJar)()),this._open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",n),new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){d("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=(0,s.byteLength)(n)),t>0&&e>this._maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(d("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,u.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(d("socket error %j",e),f.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return d("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),p&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=h.indexOf(this._offlineEventListener);-1!==e&&(d("removing listener for the 'offline' event"),h.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=f,f.protocol=l.protocol;class y extends f{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),n=!1;f.priorWebsocketSuccess=!1;const r=()=>{n||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",r=>{if(!n)if("pong"===r.type&&"probe"===r.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{d('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}const s=n=>{const r=new Error("probe error: "+n);r.transport=t.name,i(),d('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),i())}const l=()=>{t.removeListener("open",r),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}t.SocketWithUpgrade=y,t.Socket=class extends y{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>i.transports[e]).filter(e=>!!e)),super(e,n)}}},4689(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const i=n(6376),s=n(4454),o=n(5374),a=n(8661),c=(0,r(n(7833)).default)("engine.io-client:transport");class l extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}t.TransportError=l;class u extends s.Emitter{constructor(e){super(),this.writable=!1,(0,o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new l(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):c("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,i.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,a.encode)(e);return t.length?"?"+t:""}}t.Transport=u},9419(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const r=n(2071),i=n(8716),s=n(4480);t.transports={websocket:i.WS,webtransport:s.WT,polling:r.XHR}},8209(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const r=n(528);class i extends r.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(e=>this.onData(e))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()}).catch(e=>{this.onError("fetch write error",e)})}_fetch(e){var t;const n=void 0!==e,r=new Headers(this.opts.extraHeaders);return n&&r.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(r),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:r,credentials:this.opts.withCredentials?"include":"omit"}).then(e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e})}}t.Fetch=i},2071(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const i=n(528),s=n(4454),o=n(5374),a=n(4624),c=n(4110),l=(0,r(n(7833)).default)("engine.io-client:polling");function u(){}class d extends i.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){l("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}t.BaseXHR=d;class p extends s.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{l("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},l("xhr data %s",this._data),n.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=p.requestsCount++,p.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=u,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete p.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=p,p.requestsCount=0,p.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",h);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,h,!1)}function h(){for(let e in p.requests)p.requests.hasOwnProperty(e)&&p.requests[e].abort()}const f=function(){const e=y({xdomain:!1});return e&&null!==e.responseType}();function y(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||c.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends d{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new p(y,this.uri(),e)}}},528(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;const i=n(4689),s=n(5374),o=n(6376),a=(0,r(n(7833)).default)("engine.io-client:polling");class c extends i.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{a("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(a("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){a("pre-pause polling complete"),--e||t()})),this.writable||(a("we are currently writing - waiting to pause"),e++,this.once("drain",function(){a("pre-pause writing complete"),--e||t()}))}else t()}_poll(){a("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){a("polling got data %s",e),(0,o.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this._poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),e()):(a("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.randomString)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}t.Polling=c},8716(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=t.BaseWS=void 0;const i=n(4689),s=n(5374),o=n(6376),a=n(4624),c=(0,r(n(7833)).default)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class u extends i.Transport{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=l?{}:(0,s.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;(0,o.encodePacket)(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){c("websocket closed before onclose event")}r&&(0,a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}t.BaseWS=u;const d=a.globalThisShim.WebSocket||a.globalThisShim.MozWebSocket;t.WS=class extends u{createSocket(e,t,n){return l?new d(e,t,n):t?new d(e,t):new d(e)}doWrite(e,t){this.ws.send(t)}}},4480(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const i=n(4689),s=n(4624),o=n(6376),a=(0,r(n(7833)).default)("engine.io-client:webtransport");class c extends i.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{a("transport closed gracefully"),this.onClose()}).catch(e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=(0,o.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=(0,o.createPacketEncoderStream)();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{n.read().then(({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),i())}).catch(e=>{a("an error occurred while reading: %s",e)})};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&(0,s.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}}t.WT=c},5374(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=i.bind(r.globalThisShim),e.clearTimeoutFn=s.bind(r.globalThisShim)):(e.setTimeoutFn=r.globalThisShim.setTimeout.bind(r.globalThisShim),e.clearTimeoutFn=r.globalThisShim.clearTimeout.bind(r.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const r=n(4624),i=r.globalThisShim.setTimeout,s=r.globalThisShim.clearTimeout},2046(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const r=Object.create(null);t.PACKET_TYPES_REVERSE=r,Object.keys(n).forEach(e=>{r[n[e]]=e}),t.ERROR_PACKET={type:"error",data:"parser error"}},2745(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)r[n.charCodeAt(e)]=e;t.encode=e=>{let t,r=new Uint8Array(e),i=r.length,s="";for(t=0;t<i;t+=3)s+=n[r[t]>>2],s+=n[(3&r[t])<<4|r[t+1]>>4],s+=n[(15&r[t+1])<<2|r[t+2]>>6],s+=n[63&r[t+2]];return i%3==2?s=s.substring(0,s.length-1)+"=":i%3==1&&(s=s.substring(0,s.length-2)+"=="),s},t.decode=e=>{let t,n,i,s,o,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const u=new ArrayBuffer(a),d=new Uint8Array(u);for(t=0;t<c;t+=4)n=r[e.charCodeAt(t)],i=r[e.charCodeAt(t+1)],s=r[e.charCodeAt(t+2)],o=r[e.charCodeAt(t+3)],d[l++]=n<<2|i>>4,d[l++]=(15&i)<<4|s>>2,d[l++]=(3&s)<<6|63&o;return u}},2662(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const r=n(2046),i=n(2745),s="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:o(e.substring(1),t)}:r.PACKET_TYPES_REVERSE[n]?e.length>1?{type:r.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:r.PACKET_TYPES_REVERSE[n]}:r.ERROR_PACKET};const o=(e,t)=>{if(s){const n=(0,i.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},2686(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=void 0,t.encodePacketToBinary=function(e,t){return i&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):s&&(e.data instanceof ArrayBuffer||o(e.data))?t(l(e.data)):void a(e,!1,e=>{u||(u=new TextEncoder),t(u.encode(e))})};const r=n(2046),i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),s="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>i&&t instanceof Blob?n?a(t):c(t,a):s&&(t instanceof ArrayBuffer||o(t))?n?a(t):c(new Blob([t]),a):a(r.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u},6376(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=void 0,t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,r.encodePacketToBinary)(e,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let r=0,o=-1,u=!1;return new TransformStream({transform(d,p){for(n.push(d);;){if(0===r){if(c(n)<1)break;const e=l(n,1);u=!(128&~e[0]),o=127&e[0],r=o<126?3:126===o?1:2}else if(1===r){if(c(n)<2)break;const e=l(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(c(n)<8)break;const e=l(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){p.enqueue(s.ERROR_PACKET);break}o=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(c(n)<o)break;const e=l(n,o);p.enqueue((0,i.decodePacket)(u?e:a.decode(e),t)),r=0}if(0===o||o>e){p.enqueue(s.ERROR_PACKET);break}}}})};const r=n(2686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const i=n(2662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return i.decodePacket}});const s=n(2046),o=String.fromCharCode(30);let a;function c(e){return e.reduce((e,t)=>e+t.length,0)}function l(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}t.encodePayload=(e,t)=>{const n=e.length,i=new Array(n);let s=0;e.forEach((e,a)=>{(0,r.encodePacket)(e,!1,e=>{i[a]=e,++s===n&&t(i.join(o))})})},t.decodePayload=(e,t)=>{const n=e.split(o),r=[];for(let e=0;e<n.length;e++){const s=(0,i.decodePacket)(n[e],t);if(r.push(s),"error"===s.type)break}return r},t.protocol=4},7743(e,t){"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=l,t.connect=l,t.default=l;const i=n(6894),s=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return s.Manager}});const o=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,r(n(7833)).default)("socket.io-client"),c={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=(0,i.url)(e,t.path||"/socket.io"),r=n.source,o=n.id,l=n.path,u=c[o]&&l in c[o].nsps;let d;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(a("ignoring socket cache for %s",r),d=new s.Manager(r,t)):(c[o]||(a("new io instance for %s",r),c[o]=new s.Manager(r,t)),d=c[o]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(l,{Manager:s.Manager,Socket:o.Socket,io:l,connect:l});var u=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(4956);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return d.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return d.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return d.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return d.WebTransport}}),e.exports=l},3776(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),l=s(n(4627)),u=n(5942),d=n(7743),p=n(4454),h=(0,o(n(7833)).default)("socket.io-client:manager");class f extends p.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,(0,a.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new d.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||l;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(h("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=(0,u.on)(t,"open",function(){n.onopen(),e&&e()}),i=t=>{h("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=(0,u.on)(t,"error",i);if(!1!==this._timeout){const e=this._timeout;h("connect attempt will timeout after %d",e);const n=this.setTimeoutFn(()=>{h("connect attempt timed out after %d",e),r(),i(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){h("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push((0,u.on)(e,"ping",this.onping.bind(this)),(0,u.on)(e,"data",this.ondata.bind(this)),(0,u.on)(e,"error",this.onerror.bind(this)),(0,u.on)(e,"close",this.onclose.bind(this)),(0,u.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){(0,a.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){h("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void h("socket %s is still active, skipping close",e);this._close()}_packet(e){h("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){h("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){h("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;h("closed due to %s",e),this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();h("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(h("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(h("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(h("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=f},5942(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},6214(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const i=n(4627),s=n(5942),o=n(4454),a=(0,r(n(7833)).default)("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class l extends o.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,s.on)(e,"open",this.onopen.bind(this)),(0,s.on)(e,"packet",this.onpacket.bind(this)),(0,s.on)(e,"error",this.onerror.bind(this)),(0,s.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,r,s;if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:i.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const n=t.pop();this._registerAckCallback(e,n),o.id=e}const l=null===(r=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===r?void 0:r.writable,u=this.connected&&!(null===(s=this.io.engine)||void 0===s?void 0:s._hasPingExpired());return this.flags.volatile&&!l?a("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r),s=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,e)};s.withError=!0,this.acks[e]=s}emitWithAck(e,...t){return new Promise((n,r)=>{const i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>n!==this._queue[0]?a("packet [%d] already acknowledged",n.id):(null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:i.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case i.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case i.PacketType.EVENT:case i.PacketType.BINARY_EVENT:this.onevent(e);break;case i.PacketType.ACK:case i.PacketType.BINARY_ACK:this.onack(e);break;case i.PacketType.DISCONNECT:this.ondisconnect();break;case i.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,a("sending ack %j",r),t.packet({type:i.PacketType.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:i.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}t.Socket=l},6894(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(s("protocol-less url %s",e),e=void 0!==n?n.protocol+"//"+e:"https://"+e),s("parse %s",e),r=(0,i.parse)(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r};const i=n(4956),s=(0,r(n(7833)).default)("socket.io-client:url")},2545(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deconstructPacket=function(e){const t=[],n=e.data,r=e;return r.data=i(n,t),r.attachments=t.length,{packet:r,buffers:t}},t.reconstructPacket=function(e,t){return e.data=s(e.data,t),delete e.attachments,e};const r=n(9133);function i(e,t){if(!e)return e;if((0,r.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=i(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=i(e[r],t));return n}return e}function s(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=s(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=s(e[n],t));return e}},4627(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0,t.isPacketValid=function(e){return"string"==typeof e.nsp&&(void 0===(t=e.id)||d(t))&&function(e,t){switch(e){case c.CONNECT:return void 0===t||p(t);case c.DISCONNECT:return void 0===t;case c.EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:return Array.isArray(t);case c.CONNECT_ERROR:return"string"==typeof t||p(t);default:return!1}}(e.type,e.data);var t};const r=n(4454),i=n(2545),s=n(9133),o=(0,n(7833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c||(t.PacketType=c={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return o("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,s.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),o("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,i.deconstructPacket)(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}};class l extends r.Emitter{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},"function"==typeof e?{reviver:e}:e)}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new u(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,s.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");const s=Number(i);if(!d(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=s}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!l.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return o("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return p(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||p(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=l;class u{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,i.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function p(e){return"[object Object]"===Object.prototype.toString.call(e)}},9133(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBinary=o,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1};const n="function"==typeof ArrayBuffer,r=Object.prototype.toString,i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);function o(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||i&&e instanceof Blob||s&&e instanceof File}},4454(e,t,n){"use strict";function r(e){if(e)return function(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>r}),r.prototype.on=r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},r.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},r.prototype.emitReserved=r.prototype.emit,r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}};return t[e].call(s.exports,s,s.exports,r),s.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=function(e){return(0,t.prostgles)(e)};const t=r(9653)})(),i})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(function(){try{return require("react")}catch(e){}}());else if("function"==typeof define&&define.amd)define(["react"],t);else{var n="object"==typeof exports?t(function(){try{return require("react")}catch(e){}}()):t(e.react);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(Object(this||window),e=>(()=>{var t={9515(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionQueuer=void 0,t.FunctionQueuer=class{queue=[];func;groupBy;constructor(e,t){this.func=e,this.groupBy=t}isRunning=!1;async run(e){const t=new Promise((t,n)=>{const r={arguments:e,onResult:t,onFail:n};this.queue.push(r)});return this.startQueueJob(),t}startQueueJob=async()=>{if(this.isRunning)return;this.isRunning=!0;const e=async e=>{if(e)try{const t=await this.func(...e.arguments);e.onResult(t)}catch(t){e.onFail(t)}};if(this.groupBy){const t=new Set,n=[];this.queue.forEach(e=>{const r=this.groupBy(e.arguments);t.has(r)||(t.add(r),n.push(e))}),n.slice(0).reverse().forEach(e=>{this.queue.splice(this.queue.indexOf(e),1)}),await Promise.all(n.map(t=>e(t)))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&this.startQueueJob()}}},3333(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.mergeDeep=void 0;const r=n(3316),i="undefined"!=typeof window;t.mergeDeep=(e,n)=>{const i=e?(0,t.quickClone)(e):e,s=n?(0,t.quickClone)(n):n,o=(0,r.isObject)(i)?{...i}:{};return(0,r.isObject)(i)&&(0,r.isObject)(s)&&Object.keys(s).forEach(e=>{const n=s[e],a=i[e];(0,r.isObject)(n)&&(0,r.isObject)(a)?o[e]=(0,t.mergeDeep)(a,n):o[e]=(0,t.quickClone)(n)}),o},t.quickClone=e=>{if(i&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map(e=>(0,t.quickClone)(e));if((0,r.isObject)(e)){const n={};return(0,r.getKeys)(e).map(r=>{n[r]=(0,t.quickClone)(e[r])}),n}return e}},2400(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSync=void 0;const r=n(3316),i=n(9889),s=n(9331),o=n(4114),a=n(8838),c=n(3333);t.createSync=async(e,t)=>{const n=(0,o.createSyncStateUtils)(e,t),{state:u,onDebug:d,id_fields:p,synced_field:h,throttle:f,batch_size:y,columns:m,_syncInfo:g,initializeSync:b,filter:_}=n,v=(0,s.createSyncDataStore)({...g,columns:m,filter:_}),O={id_fields:p,synced_field:h,throttle:f},S=await b({onSyncRequest:e=>{let t={c_lr:void 0,c_fr:void 0,c_count:0};const n=v.getBatch(e),r=n[0],i=n[n.length-1];return r&&i&&(t={c_fr:v.getRowSyncObj(r),c_lr:v.getRowSyncObj(i),c_count:n.length}),d({command:"onUpdates",data:{syncBatchParams:e,batch:n,clientSyncInfo:t}}),t},onPullRequest:async e=>{const t=v.getBatch(e);return await d({command:"onPullRequest",data:{syncBatchParams:e,data:t}}),{data:t}},onUpdates:async e=>{if(await d({command:"onUpdates",data:{onUpdatesParams:e}}),"err"in e&&e.err)t=e.err,console.error("Sync internal error: ",t);else if("isSynced"in e&&e.isSynced&&!u.isSynced){u.isSynced=e.isSynced;const t=v.getItems().map(e=>({...e}));v.setItems([]);const n=t.map(e=>({idObj:v.getIdObj(e),delta:{...e}}));await E(n,!0)}else if("data"in e){const t=e.data.map(e=>({idObj:v.getIdObj(e),delta:e}));await E(t,!0)}else console.error("Unexpected onUpdates");var t;return!0}}),w=new i.WAL({...O,batch_size:y,onSendStart:()=>{l&&(window.onbeforeunload=function(){return"Data may be lost. Are you sure?"})},onSend:async(e,t)=>t.map(e=>e.current).length?S.syncData(e):[],onSendEnd:()=>{l&&(window.onbeforeunload=null)}}),E=async(e,t=!1)=>{if(!(e&&e.length||t))throw"No data provided for upsert";const n=[];let i;const s=[];await Promise.all(e.map(async(e,o)=>{const a={...e.idObj};let l={...e.delta};Object.keys(l).map(e=>{void 0===l[e]&&(l[e]=null)}),t||v.checkItemCols({...e.delta,...e.idObj});const u=v.getItem(a);!t&&!(0,r.isEmpty)(l)||(0,r.isEmpty)(u)||(l=v.getDelta(u||{},l)),t||(l[h]=Date.now());let d={...u,...l,...a};u&&!t&&e.opts?.deepMerge&&(d=(0,c.mergeDeep)({...u,...a},{...l})),i=u?u[h]<d[h]?"updated":"unchanged":"inserted",v.setItem(d);const p={idObj:a,delta:l,oldItem:u,newItem:d,status:i,from_server:t};return t||s.push({initial:u,current:{...d}}),(0,r.isEmpty)(p.delta)||n.push(p),!0})).catch(e=>{console.error("SyncedTable failed upsert: ",e)}),T.notifyWal.addData(n.map(e=>({initial:e.oldItem,current:e.newItem}))),!t&&s.length&&w.addData(s)},T=(0,a.createSyncSubscriptionManager)({id_fields:p,synced_field:h},v,n,E);return v.setItems(S.syncInfo.data),S.syncInfo.isSynced?u.isSynced=!0:S.syncData(),T};const l="undefined"!=typeof window},9331(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncDataStore=void 0;const r=n(3316),i=n(3333);t.createSyncDataStore=({id_fields:e,synced_field:t,filter:n,columns:s})=>{const o=new Map,a=e.sort(),c=[t,...e].sort(),l=e=>a.map(t=>`${e[t]||""}`).join("."),u=()=>{let s=[];s=Array.from(o.values()).map(e=>({...e}));const a=[t,...e.sort()];return s=s.filter(e=>!n||!(0,r.getKeys)(n).find(t=>e[t]!==n[t])).sort((e,t)=>a.map(n=>e[n]<t[n]?-1:e[n]>t[n]?1:0).find(e=>e)),(0,i.quickClone)(s)};return{getItems:u,getBatch:({from_synced:e,to_synced:n,offset:r,limit:i}={offset:0,limit:void 0})=>{let s=u().map(e=>({...e})).filter(r=>(!Number.isFinite(e)||+r[t]>=+e)&&(!Number.isFinite(n)||+r[t]<=+n));return(r||i)&&(s=s.splice(r??0,i||s.length)),s},getIdObj:e=>{const t={};return a.map(n=>{t[n]=e[n]}),t},getRowSyncObj:e=>{const t={};return c.map(n=>{t[n]=e[n]}),t},getDelta:(t,n)=>(0,r.isEmpty)(t)?{...n}:Object.fromEntries(Object.entries({...n}).filter(([t])=>!e.includes(t)).map(([e,n])=>{if(!(0,r.isEqual)(n,t[e]))return[e,(0,r.isObject)(n)?{...n}:Array.isArray(n)?n.slice(0):n]}).filter(r.isDefined)),setItems:e=>{const t=(0,i.quickClone)(e);o.clear(),t.forEach(e=>{const t=l(e);o.set(t,{...e})})},checkItemCols:e=>{if(s.length){const t=Object.keys({...e}).filter(e=>!s.find(t=>t.name===e));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},setItem:(e,t=!1,n=!1)=>{const r=(0,i.quickClone)(e),s=l(r);if(n)o.delete(s);else{const e=o.get(s)??{};o.set(s,t?{...r}:{...e,...r})}},getItem:e=>{const t=o.get(l(e));return(0,i.quickClone)(t)},matchesIdObj:(t,n)=>Boolean(t&&n&&!e.sort().find(e=>t[e]!==n[e])),matchesFilter:e=>Boolean(e&&(!n||(0,r.isEmpty)(n)||!Object.keys(n).find(t=>n[t]!==e[t])))}}},4114(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncStateUtils=void 0;const r=n(3316);t.createSyncStateUtils=(e,t)=>{const{db:n,name:i,select:s="*",filter:o={},columns:a}=t,c=(0,r.getSyncChannelName)({filter:o,select:s,tableName:i}),l=e=>t.onDebug?.({...e,type:"sync",tableName:i,channelName:c,options:t});l({command:"create",data:{name:i,filter:o,select:s}});const u=n[i];if(!u)throw`${i} table not found in db`;const{_syncInfo:d}=u;if(!d)throw`${i} table does not support sync`;const{id_fields:p,synced_field:h,throttle:f=100,batch_size:y=50}=d;if(!p.length||!h)throw"id_fields/synced_field missing";return{state:{isSynced:!1},onDebug:l,id_fields:p,synced_field:h,throttle:f,batch_size:y,columns:a,_syncInfo:d,initializeSync:async t=>{const n=await new Promise((t,n)=>{e.emit(r.CHANNEL_PREFIX,{tableName:i,command:"sync",param1:o,param2:{select:s}},(e,r)=>{e?(console.error(e),n(e)):r&&t(r)})}),a=function(e,n){if(!e)return;const{onUpdates:r,onSyncRequest:i,onPullRequest:s}=t;l({command:e.data?"onUpdates":e.onSyncRequest?"onSyncRequest":"onPullRequest",data:e}),e.data?Promise.resolve(r(e)).then(()=>{n({ok:!0})}).catch(e=>{n({err:e})}):e.onSyncRequest?Promise.resolve(i(e.onSyncRequest)).then(e=>n({onSyncRequest:e})).catch(e=>{n({err:e})}):e.onPullRequest?Promise.resolve(s(e.onPullRequest)).then(e=>{n(e)}).catch(e=>{n({err:e})}):console.log("unexpected response")};return e.on(c,a),{syncInfo:n,unsync:()=>new Promise((t,n)=>{e.emit(c+"unsync",{},(e,r)=>{e?n(e):t(r)}),e.removeListener(c,a)}),syncData:function(n,r,i){e.emit(c,{onSyncRequest:{...t.onSyncRequest({}),data:n,deleted:r}},i?e=>{i(e)}:null)}}},filter:o,select:s,tableHandler:u}}},8838(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSyncSubscriptionManager=void 0;const r=n(9889);t.createSyncSubscriptionManager=({id_fields:e,synced_field:t},n,i,s)=>{let o=[],a=[];const c=e=>(a=a.filter(t=>t._onChange!==e),o=o.filter(t=>t._onChange!==e),"ok"),{state:l,onDebug:u}=i,d=(e=[])=>{if(!l.isSynced)return void u({command:"notifySubscribers",data:[],info:"not synced yet"});u({command:"notifySubscribers",data:e});const t=[],r=[],i=[];if(e.map(({idObj:e,newItem:s,delta:o})=>{a.filter(t=>n.matchesIdObj(t.idObj,e)).map(async e=>{try{await e.notify(s,o)}catch(e){console.error("SyncedTable failed to notify: ",e)}}),n.matchesFilter(s)&&(t.push(s),r.push(o),i.push(e))}),o.length){const e=[],i=[];n.getItems().map(s=>{e.push({...s});const o=t.findIndex(e=>n.matchesIdObj(s,e));i.push(r[o])}),o.map(async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}})}},p=new r.WAL({id_fields:e,synced_field:t,batch_size:1/0,throttle:5,onSend:async(e,t)=>{d(t.map(e=>({delta:n.getDelta(e.initial??{},e.current),idObj:n.getIdObj(e.current),newItem:e.current})))}}),h=async(e,t=!1)=>{const r=n.getIdObj(e);return n.setItem(r,!0,!0),t||await(i.tableHandler.delete?.(r)),d(),!0},f=({onChange:e,handlesOnData:t})=>{const r={$unsync:()=>c(e),getItems:()=>n.getItems(),$upsert:e=>{if(!e)throw"No data provided for upsert";const t=e=>({idObj:n.getIdObj(e),delta:e});Array.isArray(e)?s(e.map(e=>t(e))):s([t(e)])}};return{sub:{_onChange:e,handlesOnData:t,handles:r,notify:(r,i)=>{let o=[...r];const a=[...i];return t&&(o=o.map((r,i)=>{const o=(r,i)=>({...r,...m(i,e),$get:()=>o(n.getItem(i),i),$find:e=>o(n.getItem(e),e),$update:(e,t)=>s([{idObj:i,delta:e,opts:t}]),$delete:async()=>h(i),$cloneMultiSync:e=>y(e,t)}),a=n.getIdObj(r);return o(r,a)})),e(o,a)}},handles:r}},y=(e,t=!0)=>{const{sub:r,handles:i}=f.bind(this)({onChange:e,handlesOnData:t});return o.push(r),setTimeout(()=>{const e=n.getItems();r.notify(e,e)},0),Object.freeze({...i})},m=(e,t)=>{const r={$get:()=>n.getItem(e),$find:e=>n.getItem(e),$unsync:()=>c(t),$delete:()=>h(e),$update:(t,n)=>(a.length||o.length||console.warn("No sync listeners"),s([{idObj:e,delta:t,opts:n}])),$cloneSync:t=>g(e,t),$cloneMultiSync:e=>y(e,!0)};return r},g=(e,t,n=!0)=>{const r=m(e,t),i={_onChange:t,idObj:e,handlesOnData:n,handles:r,notify:(e,i)=>{const s={...e};return n&&(s.$get=r.$get,s.$find=r.$find,s.$update=r.$update,s.$delete=r.$delete,s.$unsync=r.$unsync,s.$cloneSync=r.$cloneSync),t(s,i)}};return a.push(i),setTimeout(()=>{const e=r.$get();e&&i.notify(e,e)},0),Object.freeze({...r})};return{sync:y,syncOne:g,notifyWal:p}}},2886(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.authRequest=t.getAuthHandler=void 0;const r=n(3316),i=n(9653);t.getAuthHandler=({authData:e,socket:n,onReload:s,endpoint:o,...a})=>{const c=e=>{const{search:t}=window.location;let n=e+t;return o&&(n=`${o}${n}`),n};if(e?.pathGuard&&i.isClientSide){const e=e=>{e?.shouldReload&&(s?s():i.isClientSide&&(console.log("prostgles page reload due to auth guard",e),setTimeout(()=>{window.location.reload()},200)))};n.emit(r.CHANNELS.AUTH_GUARD,JSON.stringify(window.location),(t,n)=>{e(n)}),n.removeAllListeners(r.CHANNELS.AUTH_GUARD),n.on(r.CHANNELS.AUTH_GUARD,t=>{e(t)})}const l={loginType:e?.login?.mode,login:void 0,preferredLogin:e?.preferredLogin,loginWithProvider:void 0,signupWithEmailAndPassword:void 0,confirmEmail:void 0,providers:e?.providers};if(e){const{providers:n,signupWithEmailAndPassword:i,login:s}=e;l.loginWithProvider=(0,r.isEmpty)(n)?void 0:n&&Object.entries(n).reduce((e,[t,{url:n}])=>(e[t]=()=>{window.location.assign(n)},e),{}),l.login=s&&(async e=>(0,t.authRequest)(c(s.loginRoute),e,"POST",a)),l.signupWithEmailAndPassword=i&&(e=>(0,t.authRequest)(c(i.url),e,"POST",a)),l.confirmEmail=i&&(e=>(0,t.authRequest)(c(i.emailConfirmationRoute),e,"POST",a))}return e?.user?{isLoggedin:!0,user:e.user,logout:async()=>{const{logoutRoute:n}=e.login??{};if(!n)throw new Error("Unexpected");return(0,t.authRequest)(c(n),{},"POST",a)},...l}:{isLoggedin:!1,user:void 0,...l}},t.authRequest=async(e,t,n,{credentials:r,redirect:i})=>{const s=await fetch(e,{method:n,headers:{Accept:"application/json","Content-Type":"application/json"},..."GET"!==n&&{body:JSON.stringify(t)},credentials:r,redirect:i});if(!s.ok){const e=await s.json().catch(()=>s.text()).catch(()=>s.statusText);return"string"==typeof e?{success:!1,code:"something-went-wrong",message:e}:e}const o=await s.json().catch(async()=>({message:await s.text()})).catch(()=>({message:s.statusText}));return s.redirected?{...o,success:!0,redirect_url:s.url}:o}},9930(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDB=void 0;const r=n(3316),i=n(8552),s=n(1632),o=n(6469),a=n(3333),c=r.CHANNELS._preffix;t.getDB=({tableSchema:e,onDebug:t,syncHandlerV2:n,subscriptionHandler:l,socket:u})=>{const d=(e,t,n,i)=>{if(void 0!==e&&!(0,r.isObject)(e)||void 0!==t&&!(0,r.isObject)(t)||"function"!=typeof n||void 0!==i&&"function"!=typeof i)throw"Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else"},p=["subscribe","subscribeOne"],h={};return((0,a.quickClone)(e)??[]).forEach(({name:a,publishInfo:f,columns:y})=>{const m=(0,r.getAllowedTableMethods)({publishInfo:f});h[a]={};const g=h[a];m.sort((e,t)=>Number((0,r.includes)(p,e))-Number((0,r.includes)(p,t))).forEach(r=>{if("sync"===r){const e=f.select?.syncConfig;if(!e)throw`Table ${a} does not have syncConfig in publishInfo.select`;g._syncInfo={...e};const r=async(e,r={handlesOnData:!0},i)=>(await(t?.({type:"table",command:"syncOne",tableName:a,data:{basicFilter:e,options:r}})),d(e,r,i),(await n.getTableSyncFunctions({db:h,tableName:a,columns:y})).addSyncOne(e,r,i)),i=async(e,r={handlesOnData:!0},i)=>(await(t?.({type:"table",command:"sync",tableName:a,data:{basicFilter:e,options:r}})),d(e,r,i),(await n.getTableSyncFunctions({db:h,tableName:a,columns:y})).addSync(e,r,i));g.sync=i,g.syncOne=r,g.useSync=(e,t,n)=>(0,o.useSync)(i,e,t,n),g.useSyncOne=(e,t,n)=>(0,o.useSync)(r,e,t,n)}else if(p.includes(r)){const e=async function(e={},n={},i,s){return await(t?.({type:"table",command:r,tableName:a,data:{param1:e,param2:n,onChange:i,onError:s}})),d(e,n,i,s),l.addSub(h,{tableName:a,command:r,param1:e,param2:n},i,s)};g[r]=e;const n="subscribeOne",i="subscribe"===r?"useSubscribe":"subscribeOne"===r?"useSubscribeOne":void 0;i&&(g[i]=(t,i,o)=>(0,s.useSubscribe)(e,r===n,t,i,o)),r!==n&&p.includes(n)||(g[n]=async function(e,i,s){return await(t?.({type:"table",command:n,tableName:a,data:{param1:e,param2:i,onChange:s}})),d(e,i,s),l.addSub(h,{tableName:a,command:r,param1:e,param2:i},e=>{s(e[0])})})}else{const n=async function(n,i,s){if("getColumns"===r&&!n&&!i&&!s){const t=e?.find(e=>e.name===a)?.columns;if(t)return t}return await(t?.({type:"table",command:r,tableName:a,data:{param1:n,param2:i,param3:s}})),new Promise((e,t)=>{u.emit(c,{tableName:a,command:r,param1:n,param2:i,param3:s},(n,r)=>{n?t(n):e(r)})})};g[r]=n;const s="findOne"===r?"useFindOne":"find"===r?"useFind":"count"===r?"useCount":"size"===r?"useSize":void 0;s&&(g[s]=(e,t,r)=>(0,i.useFetch)(n,[e,t],r))}})}),{db:h}}},7030(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=void 0;const r=n(3316);t.getMethods=({onDebug:e,methods:t,socket:n})=>{let i={};const s={};return JSON.parse(JSON.stringify(t)).map(({name:t,description:o,input:a,output:c})=>{const l=async function(i){return await(e?.({type:"method",command:t,data:{params:i}})),new Promise((e,s)=>{n.emit(r.CHANNELS.METHOD,{name:t,input:i},(t,n)=>{t?s(t):e(n)})})};i[t]={description:o,input:a,output:c,run:l},s[t]=l}),i=Object.freeze(i),{methodSchema:i,methodHandlers:s}}},3382(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSqlHandler=void 0;const r=n(3316);t.getSqlHandler=({socket:e})=>{let t;const n={};return{sql:function(i,s,o){return new Promise((a,c)=>{e.emit(r.CHANNELS.SQL,{query:i,params:s,options:o},(r,i)=>{if(r)return c(r);if("stream"===o?.returnType){const{channel:t,unsubChannel:n}=i,r=r=>new Promise((i,s)=>{e.on(t,r),e.emit(t,{},(r,o)=>{o?(s(o),e.removeAllListeners(t)):i({pid:r,run:(n,r)=>new Promise((i,s)=>{e.emit(t,{query:n,params:r},(e,t)=>{t?s(t):i(e)})}),stop:t=>new Promise((r,i)=>{e.emit(n,{terminate:t},(e,t)=>{t?i(t):r(e)})})})})});return a({channel:t,unsubChannel:n,start:r})}if(o&&"noticeSubscription"===o.returnType&&i&&Object.keys(i).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(i).find(e=>"string"!=typeof e)){const n=i,r=r=>(((e,n,r)=>{t??={config:n,listeners:[]},t.listeners.length||(r.removeAllListeners(n.socketChannel),r.on(n.socketChannel,e=>{t&&t.listeners.length?t.listeners.map(t=>{t(e)}):r.emit(n.socketUnsubChannel,{})})),t.listeners.push(e)})(r,n,e),{...n,removeListener:()=>((e,n)=>{t&&(t.listeners=t.listeners.filter(t=>t!==e),!t.listeners.length&&t.config.socketUnsubChannel&&n&&n.emit(t.config.socketUnsubChannel,{}))})(r,e)}),s={...n,addListener:r};a(s)}else if(o&&o.returnType&&"statement"===o.returnType||!i||Object.keys(i).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(i).find(e=>"string"!=typeof e))a(i);else{const t=i,r=r=>(((e,t,r)=>{n[t.notifChannel]?n[t.notifChannel]?.listeners.push(e):(n[t.notifChannel]={config:t,listeners:[e]},r.removeAllListeners(t.socketChannel),r.on(t.socketChannel,e=>{n[t.notifChannel]?.listeners.length?n[t.notifChannel].listeners.map(t=>{t(e)}):r.emit(n[t.notifChannel]?.config.socketUnsubChannel,{})}))})(r,t,e),{...i,removeListener:()=>((e,t,r)=>{const i=n[t.notifChannel];i&&(i.listeners=i.listeners.filter(t=>t!==e),!i.listeners.length&&i.config.socketUnsubChannel&&r&&(r.emit(i.config.socketUnsubChannel,{}),delete n[t.notifChannel]))})(r,t,e)}),s={...i,addListener:r};a(s)}})})}}}},395(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSubscriptionHandler=void 0;const r=n(3316),i=n(9653),s=n(9515),o=r.CHANNELS._preffix;t.getSubscriptionHandler=e=>{const{socket:t,onDebug:n}=e,a=new Map,c=e=>new Promise((n,r)=>{t.emit(e,{},(e,t)=>{e?(console.error(e),r(e)):n(t)})});function l(e,r,s){return(0,i.debug)("_unsubscribe",{channelName:e,handler:s}),new Promise(i=>{const o=a.get(e);o?(o.handlers=o.handlers.filter(e=>e!==s),n?.({type:"table",command:"unsubscribe",tableName:o.tableName,unsubChannel:r,handlers:o.handlers}),o.handlers.length||(c(r),t.removeListener(e,o.onCall),a.delete(e)),i(!0)):i(!0)})}function u({tableName:e,command:n,param1:r,param2:i}){return new Promise((s,a)=>{t.emit(o,{tableName:e,command:n,param1:r,param2:i},(e,t)=>{e?(console.error(e),a(e)):t&&s(t)})})}const d=new s.FunctionQueuer(async function(e,{tableName:n,command:i,param1:s,param2:o},d){const p=(t,r)=>{let i={unsubscribe:function(){return l(t,r,d)},filter:{...s}};return e[n].update&&(i={...i,update:function(t,r){return e[n].update(s,t,r)}}),e[n].delete&&(i={...i,delete:function(t){return e[n].delete(s,t)}}),Object.freeze(i)},h=Array.from(a.entries()).find(([e,t])=>t.tableName===n&&t.command===i&&(0,r.isEqual)(t.param1||{},s||{})&&(0,r.isEqual)(t.param2||{},o||{}));if(h){const[e,t]=h;return t.handlers.push(d),setTimeout(()=>{const t=a.get(e);t?.lastData&&d(t.lastData)},10),p(e,t.unsubChannel)}const{channelName:f,channelNameReady:y,channelNameUnsubscribe:m}=await u({tableName:n,command:i,param1:s,param2:o}),g=function(e){const t=a.get(f),{data:n,err:r}=e;t?void 0!==n||void 0!==r?(t.lastData=n,t.handlers.forEach(e=>{void 0!==r&&console.error(`Error within running subscription \n ${f}`,r),e(n??[],r)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",f)};return t.on(f,g),a.set(f,{lastData:void 0,tableName:n,command:i,param1:s,param2:o,onCall:g,unsubChannel:m,handlers:[d],reAttach:async()=>{await c(m).catch(console.error),await u({tableName:n,command:i,param1:s,param2:o}),t.emit(y,{now:Date.now()})}}),t.emit(y,{now:Date.now()}),p(f,m)},([e,{tableName:t}])=>t);return{addSub:async(e,t,n,r)=>d.run([e,t,n]),subscriptions:a,addServerSub:u,_unsubscribe:l,reAttachAll:async()=>{await(n?.({type:"subscriptions",command:"reAttachAll.start",subscriptions:a}));for await(const e of Array.from(a.values()))try{await e.reAttach()}catch(t){console.error("There was an issue reconnecting old subscriptions",t,e),e.onCall({data:[],err:t})}await(n?.({type:"subscriptions",command:"reAttachAll.end",subscriptions:a}))}}}},1953(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncHandlerV2=void 0;const r=n(3316),i=n(2400);t.getSyncHandlerV2=({socket:e,onDebug:t})=>{const n=new Map,s=async(s,o,a,c,l)=>{const u=(0,r.getSyncChannelName)({filter:c,select:l,tableName:a});return n.set(u,n.get(u)??{options:{tableName:a,filter:c,select:l},sync:(0,i.createSync)(e,{name:a,filter:c,select:l,onDebug:t,db:s,columns:o})}),n.get(u).sync};return{getTableSyncFunctions:async({db:e,tableName:t,columns:n})=>({addSync:async(r,i,o)=>{const{sync:a}=await s(e,n,t,r,i.select);return a(o,i.handlesOnData)},addSyncOne:async(r,i,o)=>{const{syncOne:a}=await s(e,n,t,r,i.select);return a(r,o,i.handlesOnData)}})}}},4926(e,t,n){"use strict";let r;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.reactImports=t.getReact=void 0;const i=(...e)=>{throw"Must install react"},s=(...e)=>{throw"Must install react"};t.getReact=e=>{try{r??=n(9155)}catch(e){}if(e&&!r)throw new Error("Must install react");return r},(0,t.getReact)();const{useEffect:o=i,useCallback:a=i,useRef:c,useState:l=s}=r??{},u={useEffect:o,useCallback:a,useRef:c,useState:l,getReact:()=>r};t.reactImports=u,t.__prglReactInstalled=()=>Boolean(r&&c)},7566(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useAsyncEffectQueue=void 0;const r=n(9501),i=n(4926),{useRef:s}=i.reactImports;t.useAsyncEffectQueue=(e,t,n)=>{const i=s(0),o=s(!0),a=s(),c=s(),l=async()=>{if("resolved"===c.current?.state){const{cleanup:e,effect:t,id:n}=c.current;c.current={id:n,state:"cleaning",effect:t},await e().catch(console.error),c.current={id:n,state:"cleaned",effect:t}}if(a.current&&(!c.current||"cleaned"===c.current.state)&&c.current?.id!==a.current.id){const e=a.current,{effect:t,id:n}=e;c.current={id:n,state:"resolving",effect:t};const r=await t().then(e=>async()=>{await(e?.())}).catch(e=>(console.error(e),async()=>{}));c.current={id:n,state:"resolved",effect:t,cleanup:r},o.current&&e===a.current&&c.current.id===a.current.id||l()}},u=s(null),d=()=>{n?(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{l()},n)):l()};(0,r.useEffectDeep)(()=>(o.current=!0,a.current={effect:e,deps:t,id:++i.current},d(),()=>{o.current=!1,d()}),t)}},9501(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useEffectDeep=t.useMemoDeep=t.useDeepCompareMemoize=void 0;const r=n(3316),i=n(4926),{getReact:s,useEffect:o,useRef:a}=i.reactImports,c=s();t.useDeepCompareMemoize=e=>{const t=a();return(0,r.isEqual)(e,t.current)||(t.current=e),t.current},t.useMemoDeep=(e,n)=>c.useMemo(e,n.map(t.useDeepCompareMemoize)),t.useEffectDeep=(e,n)=>{o(e,n?.map(t.useDeepCompareMemoize))}},8552(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useFetch=void 0;const r=n(4926),{useState:i}=r.reactImports,s=n(7566),o=n(6912);t.useFetch=(e,t=[],n)=>{const{skip:r,deps:a=[]}=n??{},c={data:void 0,error:void 0,isLoading:!0},[{data:l,error:u,isLoading:d},p]=i(c),h=(0,o.useIsMounted)();return(0,s.useAsyncEffectQueue)(async()=>{if(h()&&!r){p(c);try{const n=await e(...t);if(!h())return;p({data:n,error:void 0,isLoading:!1})}catch(e){if(!h())return;p({data:void 0,error:e,isLoading:!1})}}},[e,...t,...a]),{data:l,error:u,isLoading:d}}},6912(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useIsMounted=void 0;const r=n(4926),{useEffect:i,useRef:s,useCallback:o}=r.reactImports;t.useIsMounted=()=>{const e=s(!0),t=o(()=>e.current,[]);return i(()=>(e.current=!0,()=>{e.current=!1}),[]),t}},1044(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useProstglesClient=t.getIO=void 0;const r=n(9653),i=n(4926),s=n(7566),o=n(6912);t.getIO=(e=!1)=>{try{return n(8007)}catch(e){}if(e)throw new Error("Must install socket.io-client");return{}},t.useProstglesClient=({skip:e,socketOptions:n,endpoint:a,token:c,...l}={})=>{const{useRef:u,useState:d}=(0,i.getReact)(!0),[p,h]=d({isLoading:!0,hasError:!1}),f=(0,o.useIsMounted)(),y=u();return(0,s.useAsyncEffectQueue)(async()=>{if(e)return;y.current?.disconnect();const i=(0,t.getIO)(),s="string"==typeof n?{path:n}:n,o={withCredentials:l.credentials&&"omit"!==l.credentials,...s,reconnectionDelay:1e3,reconnection:!0};o.path??="/ws-api",c&&(o.auth={token:c});const u=a?i(a,o):i(o);return y.current=u,await(0,r.prostgles)({socket:u,endpoint:a,...l,onReady:e=>{f()?(l.onDebug?.({type:"onReady",data:e}),h({...e,hasError:!1,isLoading:!1})):l.onDebug?.({type:"onReady.notMounted",data:e})}}).catch(e=>{f()&&h({isLoading:!1,error:e,hasError:!0})}),()=>{u.disconnect(),u.emit=()=>{throw"Socket disconnected"}}},[l,n,e],80),p}},1632(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSubscribe=void 0;const r=n(3316),i=n(4926),{useRef:s,useState:o}=i.reactImports,a=n(6912),c=n(7566);t.useSubscribe=(e,t,n,i,l)=>{const{skip:u}=l??{},d={data:void 0,error:void 0,isLoading:!0},[p,h]=o(d),f=s(p);f.current=p;const y=(0,a.useIsMounted)();return(0,c.useAsyncEffectQueue)(async()=>{if(!y()||u)return;(0,r.isEqual)(f.current,d)||h(d);const s=e=>{y()&&h({data:void 0,error:e,isLoading:!1})};try{const r=await e(n,i,e=>{y()&&h({data:t?e[0]:e,error:void 0,isLoading:!1})},s);return()=>{r.unsubscribe()}}catch(e){s(e)}},[e,n,i,u]),p}},6469(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useSync=void 0;const r=n(4926),{useState:i}=r.reactImports,s=n(7566),o=n(6912);t.useSync=(e,t,n,r)=>{const{skip:a}=r??{},[{data:c,error:l,isLoading:u},d]=i({data:void 0,error:void 0,isLoading:!0}),p=(0,o.useIsMounted)();return(0,s.useAsyncEffectQueue)(async()=>{if(!p()||a)return;const r=e=>{p()&&d({data:void 0,error:e,isLoading:!1})};try{return(await e(t,n,e=>{p()&&d({data:e,error:void 0,isLoading:!1})},r)).$unsync}catch(e){r(e)}},[e,t,n,a]),{data:c,error:l,isLoading:u}}},9653(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.asName=t.debug=t.isClientSide=void 0,t.prostgles=function(e){const{endpoint:n,socket:r,onReady:i,onDisconnect:p,onReconnect:h,onSchemaChange:f,onReload:y,onDebug:m,credentials:g,redirect:b}=e;let _;(0,t.debug)("prostgles",{initOpts:e}),f&&(r.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),r.on(s.CHANNELS.SCHEMA_CHANGED,f));const v=(0,u.getSubscriptionHandler)(e),O=(0,d.getSyncHandlerV2)(e);let S;return new Promise((t,u)=>{r.removeAllListeners("connect_error"),r.on("connect_error",e=>{u(e)}),r.removeAllListeners(s.CHANNELS.CONNECTION),r.on(s.CHANNELS.CONNECTION,e=>(u(e),"ok")),p&&r.on("disconnect",()=>{S="disconnected",p()}),h&&r.on("connect",()=>{"disconnected"===S&&(S="reconnected")}),r.on(s.CHANNELS.SCHEMA,async d=>{await(m?.({type:"schemaChanged",data:d,state:S}));const{joinTables:p=[],...f}=d,{methods:w,tableSchema:E,auth:T,rawSQL:j,err:k}=f;if(_?.clientSchema&&!(0,s.isEqual)(_.clientSchema,f)&&console.warn("syncHandler.destroySyncs()"),k&&console.error("Error on schema change:",k),"connected"!==S&&"reconnected"!==S||!h)_={origin:"onReady",date:new Date,clientSchema:f};else{if(h(r,k),k)return;_={origin:"onReconnect",date:new Date,clientSchema:f}}if(k)return void u(k);const C="reconnected"===S;S="connected";const P=(0,o.getAuthHandler)({authData:T,socket:r,onReload:y,endpoint:n,credentials:g,redirect:b}),{methodHandlers:N,methodSchema:A}=(0,c.getMethods)({onDebug:m,methods:w,socket:r}),{db:x}=(0,a.getDB)({onDebug:m,syncHandlerV2:O,subscriptionHandler:v,socket:r,tableSchema:E}),R=j?(0,l.getSqlHandler)(e).sql:void 0;v.reAttachAll(),console.warn("syncHandler.reAttachAll()"),(async()=>{try{const e={db:x,sql:R,methods:N,methodSchema:A,tableSchema:E,auth:P,socket:r,isReconnect:C};await(m?.({type:"onReady.call",data:e,state:S})),await i(e)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}t(x)})()})})};const s=n(3316);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(2886),a=n(9930),c=n(7030),l=n(3382),u=n(395),d=n(1953),p="DEBUG_SYNCEDTABLE";t.isClientSide="undefined"!=typeof window,t.debug=function(...e){t.isClientSide&&window[p]&&window[p](...e)},i(n(9501),t),i(n(1044),t)},7833(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(736)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},736(e,t,n){e.exports=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n}),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e,t){let n=0,r=0,i=-1,s=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(i=r,s=n,r++):(n++,r++);else{if(-1===i)return!1;r=i+1,s++,n=s}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(i(e,n))return!1;for(const n of t.names)if(i(e,n))return!0;return!1},t.humanize=n(6585),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},6585(e){var t=1e3,n=60*t,r=60*n,i=24*r,s=7*i;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,a){a=a||{};var c,l,u=typeof e;if("string"===u&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var a=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*s;case"days":case"day":case"d":return a*i;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(e);if("number"===u&&isFinite(e))return a.long?(c=e,(l=Math.abs(c))>=i?o(c,l,i,"day"):l>=r?o(c,l,r,"hour"):l>=n?o(c,l,n,"minute"):l>=t?o(c,l,t,"second"):c+" ms"):function(e){var s=Math.abs(e);return s>=i?Math.round(e/i)+"d":s>=r?Math.round(e/r)+"h":s>=n?Math.round(e/n)+"m":s>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},4357(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(8349);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},2602(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(8349),i=n(6867),s=n(3860);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const o=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:o,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&o(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},c=(0,r.getKeys)(a),l=(e,n,o=[],d)=>{const p=`${o.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,h=(0,t.getFieldTypeObj)(n),{type:f,allowedValues:y,nullable:m,optional:g}=h;if(m&&null===e)return;if(g&&void 0===e)return;if(y){if("string"!=typeof f)throw new Error("allowedValues is only supported for primitive types");const t=f.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=y.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${o.join(".")}[${e}]`:o.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(f){if((0,r.isObject)(f)){if(!(0,r.isObject)(e))return p;for(const t of(0,i.safeGetKeys)(f)){const n=(0,i.safeGetProperty)(f,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...o,t].join(".")} is missing but required`;const s=l((0,i.safeGetProperty)(e,t),n,[...o,t],d);if(void 0!==s)return s}if(!d?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(f),r=t.filter(e=>!n.includes(e));if(r.length)return`${o.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,s.includes)(c,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(f,h);return t(e,h)?void 0:p}if(h.enum){const t=[];return h.nullable&&t.push(null),h.optional&&t.push(void 0),h.enum.includes(e)?void 0:p}const b=h.arrayOf??(h.arrayOfType?{type:h.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return p+" an array";const t=e.map((e,t)=>l(e,b,[...o,`${t}`],d)).filter(r.isDefined)[0];return void 0!==t?`${p}. Error at index ${o.length>0?o.join(".")+".":""}\n\n${t}`:void 0}const _=h.oneOf??h.oneOfType?.map(e=>({type:e}));if(_){if(!_.length)return p+"to not be empty";let t;if(_.find(n=>{const r=l(e,n,o,d);return t??(t=r),void 0===r}))return;return p}if(h.record){const{keysEnum:t,partial:n,values:s}=h.record;if(!(0,r.isObject)(e))return p+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),c=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==c)return`${p} to have key ${c}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${p} has extra keys: ${u}`;if(s)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=l(n,s,[...o,t],d);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(h)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:s,optional:o,record:a}=n,c=n.oneOf??n.oneOfType?.map(e=>({type:e})),l=[];if(s&&l.push("null"),o&&l.push("undefined"),"string"==typeof i)l.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),l.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?l.push("null"):void 0===e?l.push("undefined"):"string"==typeof e?l.push(JSON.stringify(e)):l.push(e)}),c?.forEach(e=>{const t=u(e);l.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?l.push(`{ [${e.join(" | ")}]${r}: ${i} }`):l.push(`{ [key: string]${r}: ${i} }`)}return l.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,s)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=l(t,{type:e},[],s);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=l(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===s},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(s)throw new Error(s)}},4538(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(8349),i=n(6867),s=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:p,title:h,record:f,...y}="string"==typeof e?{type:e}:e;let m={};const g={...(y.enum||y.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:y.allowedValues?.slice(0)??y.enum.slice(0)},...!!l&&{description:l},...!!h&&{title:h}};if(y.enum?.length){const e=typeof y.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";m=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:s(o)?.type,...y.allowedValues&&{enum:y.allowedValues.slice(0)}}}:{type:s(o)?.type}}else if((0,r.isObject)(o))m={type:"object",required:(0,i.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(o).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})};else if(d||p){const e=d||p.map(e=>({type:e}));m={oneOf:e.map(e=>(0,t.getJSONSchemaObject)(e))}}else f&&(m={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...m}}},2129(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(6173),i=n(2602),s=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,i.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let s=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;s=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${s}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return d+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return d+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:s}=u,c=a?" ":" ";let p=` {${c}`+(0,r.getObjectEntries)(s).map(([r,s])=>{const a=(0,i.getFieldTypeObj)(s),u=o(r)?r:JSON.stringify(r);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(p=n(p)),a&&(p=p.split("\n").join("")),d+p}if(u.enum)return d+u.enum.map(e=>s(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,o=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>s(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},6867(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},9889(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(6173);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],s=+r-+i,o=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(s)?s:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:r,delta:i}),this.changed[s].current={...this.changed[s].current,...r},this.changed[s].delta={...this.changed[s].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:s,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],s=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,s)||(t[n]=s)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},s)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),(0,r.isEmpty)(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},4211(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4674(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},7178(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(8349);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},6173(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const s=n(8349),o=n(3860);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,s.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const s=i.columns.filter(e=>r.includes(e.name));return s.length?{ref:e,fcolsInfo:s}:void 0}).filter(s.isDefined),[i,...o]=r??[];if(!o.length)return i?.ref;const[a,...c]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(4211),t);var c=n(4674);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return c.CONTENT_TYPE_TO_EXT}}),i(n(7178),t),i(n(8428),t),i(n(4538),t),i(n(2129),t),i(n(4357),t),i(n(2602),t),i(n(367),t),i(n(8349),t),i(n(9889),t),i(n(1805),t)},3316(e){var t;Object(this||window),t=()=>(()=>{"use strict";var e={994(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=t.PrimitiveTypesObj=void 0;const r=n(472);t.PrimitiveTypesObj={boolean:1,number:1,integer:1,string:1,Date:1,time:1,timestamp:1,Blob:1,FileLike:1,any:1,unknown:1},t.PrimitiveTypes=(0,r.getKeys)(t.PrimitiveTypesObj),t.PrimitiveArrayTypes=t.PrimitiveTypes.map(e=>`${e}[]`),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes]},897(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.assertJSONBObjectAgainstSchema=t.validateJSONBObjectAgainstSchema=t.getJSONBSchemaValidationError=t.getJSONBObjectSchemaValidationError=t.getFieldTypeObj=void 0;const r=n(472),i=n(704),s=n(441);t.getFieldTypeObj=e=>"string"==typeof e?{type:e}:e;const o=e=>e instanceof Blob||"undefined"!=typeof Buffer&&e instanceof Buffer||"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer,a={string:e=>"string"==typeof e,number:e=>"number"==typeof e&&Number.isFinite(e),integer:e=>"number"==typeof e&&Number.isInteger(e),boolean:e=>"boolean"==typeof e,time:e=>"string"==typeof e,timestamp:e=>"string"==typeof e,any:e=>"function"!=typeof e&&"symbol"!=typeof e,unknown:e=>"function"!=typeof e&&"symbol"!=typeof e,Date:e=>"string"==typeof e,Lookup:e=>{throw new Error("Lookup type is not supported for validation")},Blob:o,FileLike:(e,t)=>{if("FileLike"!==t.type)throw new Error("FileLike type must have type 'FileLike'");const n=(0,r.isObject)(e)&&"string"==typeof e.name&&"string"==typeof e.type&&o(e.data);if(n&&t.mimeTypes&&!Object.keys(t.mimeTypes).some(t=>e.type===t))throw new Error(`Invalid FileLike type. Expected one of: ${Object.keys(t.mimeTypes).join(", ")}`);return n}},c=(0,r.getKeys)(a),l=(e,n,o=[],d)=>{const p=`${o.join(".")} is of invalid type. Expecting ${u(n).replaceAll("\n","")}`,h=(0,t.getFieldTypeObj)(n),{type:f,allowedValues:y,nullable:m,optional:g}=h;if(m&&null===e)return;if(g&&void 0===e)return;if(y){if("string"!=typeof f)throw new Error("allowedValues is only supported for primitive types");const t=f.endsWith("[]"),n=t&&Array.isArray(e)?e:[e],i=y.map(e=>(0,r.isObject)(e)?e.value:e);for(const[e,r]of n.entries())if(!i.includes(r))return`${t?`${o.join(".")}[${e}]`:o.join(".")} is of invalid type. Expecting ${i.map(e=>"string"==typeof e?JSON.stringify(e):String(e)).join(" | ")} But got ${JSON.stringify(r)}`}if(f){if((0,r.isObject)(f)){if(!(0,r.isObject)(e))return p;for(const t of(0,i.safeGetKeys)(f)){const n=(0,i.safeGetProperty)(f,t);if(!((0,r.isObject)(n)&&n.optional||(0,i.safeHasOwn)(e,t)))return`${[...o,t].join(".")} is missing but required`;const s=l((0,i.safeGetProperty)(e,t),n,[...o,t],d);if(void 0!==s)return s}if(!d?.allowExtraProperties){const t=(0,i.safeGetKeys)(e),n=(0,i.safeGetKeys)(f),r=t.filter(e=>!n.includes(e));if(r.length)return`${o.join(".")} has extra properties: ${r.join(", ")}`}return}const{validator:t}=((e,t)=>{const n=(e=>{if("string"==typeof e&&e.endsWith("[]")){const t=e.slice(0,-2);if(!(0,s.includes)(c,t))throw new Error(`Invalid array field type ${e}`);return t}})(e);if(n){const e=a[n];return{isArray:!0,validator:n=>Array.isArray(n)&&n.every(n=>e(n,t))}}const r=a[e];if(!r)throw new Error(`Unknown field type ${e}`);return{isArray:!1,validator:r}})(f,h);return t(e,h)?void 0:p}if(h.enum){const t=[];return h.nullable&&t.push(null),h.optional&&t.push(void 0),h.enum.includes(e)?void 0:p}const b=h.arrayOf??(h.arrayOfType?{type:h.arrayOfType}:void 0);if(b){if(!Array.isArray(e))return p+" an array";const t=e.map((e,t)=>l(e,b,[...o,`${t}`],d)).filter(r.isDefined)[0];return void 0!==t?`${p}. Error at index ${o.length>0?o.join(".")+".":""}\n\n${t}`:void 0}const _=h.oneOf??h.oneOfType?.map(e=>({type:e}));if(_){if(!_.length)return p+"to not be empty";let t;if(_.find(n=>{const r=l(e,n,o,d);return t??(t=r),void 0===r}))return;return p}if(h.record){const{keysEnum:t,partial:n,values:s}=h.record;if(!(0,r.isObject)(e))return p+"object";if(n&&(0,r.isEmpty)(e))return;const a=(0,r.getKeys)(e),c=n?void 0:t?.find(e=>!a.includes(e));if(void 0!==c)return`${p} to have key ${c}`;const u=t&&a.filter(e=>!t.includes(e));if(u?.length)return`${p} has extra keys: ${u}`;if(s)for(const t of(0,i.safeGetKeys)(e)){const n=(0,i.safeGetProperty)(e,t),r=l(n,s,[...o,t],d);if(void 0!==r)return`${r}`}return}return`Could not validate field type. Some logic might be missing: ${JSON.stringify(h)}`},u=e=>{const n=(0,t.getFieldTypeObj)(e),{type:i,nullable:s,optional:o,record:a}=n,c=n.oneOf??n.oneOfType?.map(e=>({type:e})),l=[];if(s&&l.push("null"),o&&l.push("undefined"),"string"==typeof i)l.push(i);else if(i&&(0,r.isObject)(i)){const e=[];Object.entries(i).forEach(([t,n])=>{e.push(`${t}: ${u(n)}`)}),l.push(`{ ${e.join("; ")} }`)}if(n.enum?.forEach(e=>{null===e?l.push("null"):void 0===e?l.push("undefined"):"string"==typeof e?l.push(JSON.stringify(e)):l.push(e)}),c?.forEach(e=>{const t=u(e);l.push(t)}),a){const{keysEnum:e,partial:t,values:n}=a,r=t?"?":"",i=n?u(n):"any";e?l.push(`{ [${e.join(" | ")}]${r}: ${i} }`):l.push(`{ [key: string]${r}: ${i} }`)}return l.join(" | ")};t.getJSONBObjectSchemaValidationError=(e,t,n="input",i=!1,s)=>{if(void 0===t&&!i)return{error:`Expecting ${n} to be defined`};if(!(0,r.isObject)(t))return{error:`Expecting ${n} to be an object`};const o=l(t,{type:e},[],s);return o?{error:o}:{data:t}},t.getJSONBSchemaValidationError=(e,t,n)=>{const r=l(t,e,void 0,n);return r?{error:r}:{data:t}},t.validateJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);return void 0===s},t.assertJSONBObjectAgainstSchema=(e,n,r,i=!1)=>{const{error:s}=(0,t.getJSONBObjectSchemaValidationError)(e,n,r,i);if(s)throw new Error(s)}},699(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONSchemaObject=void 0,t.getJSONBSchemaAsJSONSchema=function(e,n,r){return(0,t.getJSONSchemaObject)(r,{id:`${e}.${n}`})};const r=n(472),i=n(704),s=e=>{if(!e)return;const t=e.endsWith("[]")?e.slice(0,-2):e;return{type:"integer"===t?"integer":"boolean"===t?"boolean":"number"===t?"number":"any"===t||"unknown"===t||"Lookup"===t||"Blob"===t||"FileLike"===t?void 0:"string",isArray:e.endsWith("[]")}};t.getJSONSchemaObject=(e,n)=>{const{type:o,arrayOf:a,arrayOfType:c,description:l,nullable:u,oneOf:d,oneOfType:p,title:h,record:f,...y}="string"==typeof e?{type:e}:e;let m={};const g={...(y.enum||y.allowedValues?.length&&("string"!=typeof o||!o.endsWith("[]")))&&{enum:y.allowedValues?.slice(0)??y.enum.slice(0)},...!!l&&{description:l},...!!h&&{title:h}};if(y.enum?.length){const e=typeof y.enum[0];g.type="number"===e?"number":"boolean"===e?"boolean":"string"}if("string"==typeof o||a||c){if(o&&"string"!=typeof o)throw"Not expected";m=a||c||o?.endsWith("[]")?{type:"array",items:a||c?(0,t.getJSONSchemaObject)(a||{type:c}):o?.startsWith("any")?{type:void 0}:{type:s(o)?.type,...y.allowedValues&&{enum:y.allowedValues.slice(0)}}}:{type:s(o)?.type}}else(0,r.isObject)(o)?m={type:"object",required:(0,i.safeGetKeys)(o).filter(e=>{const t=o[e];return"string"==typeof t||!t.optional}),properties:(0,r.getObjectEntries)(o).reduce((e,[n,r])=>({...e,[n]:(0,t.getJSONSchemaObject)(r)}),{})}:d||p?m={oneOf:(d||p.map(e=>({type:e}))).map(e=>(0,t.getJSONSchemaObject)(e))}:f&&(m={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:(0,t.getJSONSchemaObject)(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce((e,n)=>({...e,[n]:f.values?(0,t.getJSONSchemaObject)(f.values):{type:{}}}),{})}});if(u){const e={type:"null"};m.oneOf?m.oneOf.push(e):m.enum&&!m.enum.includes(null)?m.enum.push(null):m={oneOf:[m,e]}}return{...n?{$id:n?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...g,...m}}},394(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBTSTypes=void 0,t.getJSONBSchemaTSTypes=function(e,n,r="",i){return(0,t.getJSONBTSTypes)(i,{...e,nullable:n.nullable},void 0,r)};const r=n(806),i=n(897),s=e=>null===e?"null":void 0===e?"undefined":"string"==typeof e?JSON.stringify(e):String(e);t.getJSONBTSTypes=(e,n,a=!1,c="",l=0)=>{const u=(0,i.getFieldTypeObj)(n),d=u.nullable?"null | ":"";if(u.lookup){const n=u.lookup;if("data-def"===n.type)return`${u.nullable?"null |":""} ${(0,t.getJSONBTSTypes)(e,{type:{table:"string",column:"string",filter:{record:{},optional:!0},isArray:{type:"boolean",optional:!0},searchColumns:{type:"string[]",optional:!0},isFullRow:{optional:!0,type:{displayColumns:{type:"string[]",optional:!0}}},showInRowCard:{optional:!0,record:{}}}})}`;const i="schema"===n.type;let s=i?"table"===n.object?"string":'{ "table": string; "column": string; }':"";if(!i){const t=e.find(e=>e.name===n.table)?.columns;s=n.isFullRow?t?`{ ${t.map(e=>`${JSON.stringify(e.name)}: ${e.is_nullable?"null | ":""} ${(0,r.postgresToTsType)(e.udt_name)}; `).join(" ")} }`:"any":(0,r.postgresToTsType)(t?.find(e=>e.name===n.column)?.udt_name??"text")}return`${u.nullable?"null | ":""}${s}${n.isArray?"[]":""}`}if("string"==typeof u.type){if(u.type.toLowerCase().includes("lookup"))throw new Error("getJSONBTSTypes: Lookup type not handled correctly");const e=u.type.replace("integer","number").replace("time","string").replace("timestamp","string").replace("FileLike","{ name: string; type: string; data: Blob; }").replace("Date","string");if(u.allowedValues){const e=u.type.endsWith("[]")?"[]":"";return d+` (${u.allowedValues.map(e=>JSON.stringify((0,r.isObject)(e)?e.value:e)).join(" | ")})${e}`}return d+e}if((0,r.isObject)(u.type)){const n=e=>e.trim().endsWith(";")?e:e.trim()+";",{type:s}=u,c=a?" ":" ";let p=` {${c}`+(0,r.getObjectEntries)(s).map(([r,s])=>{const a=(0,i.getFieldTypeObj)(s),u=o(r)?r:JSON.stringify(r);return`${c}${u}${a.optional?"?":""}: `+n((0,t.getJSONBTSTypes)(e,a,!0,void 0,l+1))}).join(" ")+`${c}}`;return a||(p=n(p)),a&&(p=p.split("\n").join("")),d+p}if(u.enum)return d+u.enum.map(e=>s(e)).join(" | ");if(u.oneOf||u.oneOfType){const n=u.oneOf||u.oneOfType.map(e=>({type:e}));return(u.nullable?`\n${c} | null`:"")+n.map(n=>`\n${c} | `+(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)).join("")}if(u.arrayOf||u.arrayOfType){const n=u.arrayOf||{type:u.arrayOfType};return`${u.nullable?"null | ":""} ( ${(0,t.getJSONBTSTypes)(e,n,!0,void 0,l+1)} )[]`}if(u.record){const{keysEnum:n,values:r,partial:i}=u.record,o=e=>i?`Partial<Record<${e}>>`:`Record<${e}>`;return`${u.nullable?"null |":""} ${o(`${n?.map(e=>s(e)).join(" | ")??"string"}, ${r?(0,t.getJSONBTSTypes)(e,r,!0,void 0,l+1):"any"}`)}`}throw"Unexpected getSchemaTSTypes: "+JSON.stringify({fieldType:u},null,2)};const o=e=>/^[A-Za-z$_][A-Za-z0-9$_]*$/.test(e)},704(e,t){t.safeGetKeys=t.safeGetProperty=t.safeHasOwn=void 0;const n=["__proto__","constructor","prototype"];t.safeHasOwn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t.safeGetProperty=(e,t)=>{if(n.includes(t)){const n=Object.getOwnPropertyDescriptor(e,t);return n?.value}return e[t]},t.safeGetKeys=e=>{const r=Object.keys(e);for(const i of n)(0,t.safeHasOwn)(e,i)&&!r.includes(i)&&r.push(i);return r}},502(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.WAL=void 0;const r=n(806);t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:n}=this.options;return n&&e&&t&&n.map(n=>{if(!(n.fieldName in e)||!(n.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let r=n.asc?e[n.fieldName]:t[n.fieldName],i=n.asc?t[n.fieldName]:e[n.fieldName],s=+r-+i,o=r<i?-1:r==i?0:1;return"number"===n.tsDataType&&Number.isFinite(s)?s:o}).find(e=>e)||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const n=this.sentHistory[this.getIdStr(e)],r=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+r))throw"Provided historic item Synced field value is missing/invalid";if(+r===+t)return!0}return!1},this.addData=e=>((0,r.isEmpty)(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map(e=>{var t;const{initial:n,current:r,delta:i}={...e};if(!r)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(r);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:r,delta:i}),this.changed[s].current={...this.changed[s].current,...r},this.changed[s].delta={...this.changed[s].delta,...i}}),this.sendItems()),this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:n,batch_size:i,throttle:s,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!(0,r.isEmpty)(this.sending))return;if(!this.changed||(0,r.isEmpty)(this.changed))return;let a,c=[],l=[],u={};Object.keys(this.changed).sort((e,t)=>this.sort(this.changed[e].current,this.changed[t].current)).slice(0,i).map(e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),u[e]={...t.current},delete this.changed[e]}),c=l.map(e=>{let t={};return Object.keys(e.current).map(n=>{const i=e.initial?.[n],s=e.current[n];![this.options.synced_field,...this.options.id_fields].includes(n)&&(0,r.isEqual)(i,s)||(t[n]=s)}),t}),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout(()=>{this.isSendingTimeout=void 0,(0,r.isEmpty)(this.changed)||this.sendItems()},s)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout(()=>{this.willDeleteHistory=void 0,this.sentHistory={}},1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach((t,n)=>{t.idStrs=t.idStrs.filter(t=>e.includes(t)),t.idStrs.length||t.cb(a)}),this.callbacks=this.callbacks.filter(e=>e.idStrs.length)}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),(0,r.isEmpty)(this.changed)?n&&n(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:n}=e;this.options.orderBy=[t,...n.sort()].map(e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0}))}}isSending(){const e=this.isOnSending||!((0,r.isEmpty)(this.sending)&&(0,r.isEmpty)(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map(t=>`${e[t]||""}`).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map(n=>{t[n]=e[n]}),t}getDeltaObj(e){let t={};return Object.keys(e).map(n=>{this.options.id_fields.includes(n)||(t[n]=e[n])}),t}}},618(e,t){Object.defineProperty(t,"__esModule",{value:!0})},521(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},209(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const r=n(472);t.CompareFilterKeys=["=","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",Description:"Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",Description:"Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,r.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],t.COMPLEX_FILTER_KEY="$filter"},806(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getPossibleNestedInsert=t.SQL_COMMAND_TABLE_METHODS=t.CHANNELS=t.CHANNEL_PREFIX=t.JOIN_PARAMS=t.JOIN_KEYS=t.getAllowedTableMethods=t.postgresToTsType=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=t._PG_strings=void 0;const s=n(472),o=n(441);t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const a={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...a,"number[]":a.number.map(e=>`_${e}`),"boolean[]":a.boolean.map(e=>`_${e}`),"string[]":a.string.map(e=>`_${e}`),"any[]":a.any.map(e=>`_${e}`)},t.postgresToTsType=e=>(0,s.getKeys)(t.TS_PG_Types).find(n=>(0,o.includes)(t.TS_PG_Types[n],e))??"any",t.getAllowedTableMethods=({publishInfo:e})=>{let n=[...e.select||e.insert||e.delete||e.update?t.SQL_COMMAND_TABLE_METHODS.schema:[],...t.SQL_COMMAND_TABLE_METHODS.select.filter(t=>"sync"===t?void 0!==e.select?.syncConfig:e.select&&!Object.keys(e.select.disabledMethods??{}).includes(t)),...t.SQL_COMMAND_TABLE_METHODS.update.filter(t=>e.update&&!Object.keys(e.update.disabledMethods??{}).includes(t)),...e.insert?t.SQL_COMMAND_TABLE_METHODS.insert:[],...e.delete?t.SQL_COMMAND_TABLE_METHODS.delete:[]];const r=new Map;return Object.values(t.SQL_COMMAND_TABLE_METHODS).forEach(e=>{e.forEach(e=>{r.set(e,(r.get(e)??0)+1)})}),r.forEach((e,t)=>{n.filter(e=>e===t).length!==e&&r.delete(t)}),Array.from(r.keys())},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"],t.CHANNEL_PREFIX="_psqlWS_.",t.CHANNELS={SCHEMA_CHANGED:t.CHANNEL_PREFIX+"schema-changed",SCHEMA:t.CHANNEL_PREFIX+"schema",DEFAULT:t.CHANNEL_PREFIX,SQL:`${t.CHANNEL_PREFIX}sql`,SQL_STREAM:`${t.CHANNEL_PREFIX}sql-stream`,METHOD:`${t.CHANNEL_PREFIX}method`,NOTICE_EV:`${t.CHANNEL_PREFIX}notice`,LISTEN_EV:`${t.CHANNEL_PREFIX}listen`,REGISTER:`${t.CHANNEL_PREFIX}register`,LOGIN:`${t.CHANNEL_PREFIX}login`,LOGOUT:`${t.CHANNEL_PREFIX}logout`,AUTH_GUARD:`${t.CHANNEL_PREFIX}authguard`,CONNECTION:`${t.CHANNEL_PREFIX}connection`,_preffix:t.CHANNEL_PREFIX},t.SQL_COMMAND_TABLE_METHODS={schema:["getColumns","getInfo"],insert:["insert","insertMany","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size","subscribe","subscribeOne","sync"],delete:["delete","remove"]},t.getPossibleNestedInsert=(e,t,n=!0)=>{const r=(e.references??[]).map(e=>{const{ftable:n,fcols:r}=e,i=t.find(e=>e.name===n);if(!i)return;const s=i.columns.filter(e=>r.includes(e.name));return s.length?{ref:e,fcolsInfo:s}:void 0}).filter(s.isDefined),[i,...o]=r??[];if(!o.length)return i?.ref;const[a,...c]=r.filter(e=>e.fcolsInfo.some(e=>e.is_pkey));if(!c.length)return a?.ref;if(!n)throw["Cannot do a nested insert on column that references multiple tables.","Expecting only one reference to a single primary key fcol"].join("\n")},i(n(618),t);var c=n(521);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return c.CONTENT_TYPE_TO_EXT}}),i(n(209),t),i(n(319),t),i(n(699),t),i(n(394),t),i(n(994),t),i(n(897),t),i(n(164),t),i(n(472),t),i(n(502),t),i(n(778),t)},319(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(472),i=(e="$leftJoin")=>(t,n,i,s={})=>({[e]:s.path??t,filter:n,...(0,r.omitKeys)(s,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},666(e,t){function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=s(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,r,c,t[6],9,-1069501632),c=s(c,l,n,r,t[11],14,643717713),r=s(r,c,l,n,t[0],20,-373897302),n=s(n,r,c,l,t[5],5,-701558691),l=s(l,n,r,c,t[10],9,38016083),c=s(c,l,n,r,t[15],14,-660478335),r=s(r,c,l,n,t[4],20,-405537848),n=s(n,r,c,l,t[9],5,568446438),l=s(l,n,r,c,t[14],9,-1019803690),c=s(c,l,n,r,t[3],14,-187363961),r=s(r,c,l,n,t[8],20,1163531501),n=s(n,r,c,l,t[13],5,-1444681467),l=s(l,n,r,c,t[2],9,-51403784),c=s(c,l,n,r,t[7],14,1735328473),n=o(n,r=s(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,r,c,t[8],11,-2022574463),c=o(c,l,n,r,t[11],16,1839030562),r=o(r,c,l,n,t[14],23,-35309556),n=o(n,r,c,l,t[1],4,-1530992060),l=o(l,n,r,c,t[4],11,1272893353),c=o(c,l,n,r,t[7],16,-155497632),r=o(r,c,l,n,t[10],23,-1094730640),n=o(n,r,c,l,t[13],4,681279174),l=o(l,n,r,c,t[0],11,-358537222),c=o(c,l,n,r,t[3],16,-722521979),r=o(r,c,l,n,t[6],23,76029189),n=o(n,r,c,l,t[9],4,-640364487),l=o(l,n,r,c,t[12],11,-421815835),c=o(c,l,n,r,t[15],16,530742520),n=a(n,r=o(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=p(n,e[0]),e[1]=p(r,e[1]),e[2]=p(c,e[2]),e[3]=p(l,e[3])}function r(e,t,n,r,i,s){return t=p(p(t,e),p(r,s)),p(t<<i|t>>>32-i,n)}function i(e,t,n,i,s,o,a){return r(t&n|~t&i,e,t,s,o,a)}function s(e,t,n,i,s,o,a){return r(t&i|n&~i,e,t,s,o,a)}function o(e,t,n,i,s,o,a){return r(t^n^i,e,t,s,o,a)}function a(e,t,n,i,s,o,a){return r(n^(t|~i),e,t,s,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(i,s),t=0;t<16;t++)s[t]=0;return s[14]=8*r,n(i,s),i}(e))}function p(e,t){return e+t&4294967295}d("hello")},164(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncChannelName=void 0;const r=n(806);t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join(".")},472(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},s={key:r,value:e[r]};return n(i,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const s=n<1?[r]:[0,r];e.slice(...s)!==t.slice(...s)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:i,to:s,text:t.slice(i,o),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(i);if(o&&(0,r.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const r=n(666);function i(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function s(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),s=JSON.parse((0,t.safeStringify)(r));return n?s:i(s,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])}},441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},778(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(102),t),i(n(436),t),i(n(441),t)},102(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let s=r.get(e);if(s?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(s||(s=new WeakSet,r.set(e,s)),s.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s],r,i))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const s of c){if(!(s in t))return!1;{const o=e[s],a=t[s];if(!n(o,a,r,i))return!1}}return!0}},436(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}}},t={};return function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}(806)})(),e.exports=t()},8428(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.leftJoin=t.innerJoin=void 0;const r=n(8349),i=(e="$leftJoin")=>(t,n,i,s={})=>({[e]:s.path??t,filter:n,...(0,r.omitKeys)(s,["path","select"]),select:i});t.innerJoin=i("$innerJoin"),t.leftJoin=i("$leftJoin")},7913(e,t){"use strict";function n(e,t){var n=e[0],r=e[1],c=e[2],l=e[3];n=i(n,r,c,l,t[0],7,-680876936),l=i(l,n,r,c,t[1],12,-389564586),c=i(c,l,n,r,t[2],17,606105819),r=i(r,c,l,n,t[3],22,-1044525330),n=i(n,r,c,l,t[4],7,-176418897),l=i(l,n,r,c,t[5],12,1200080426),c=i(c,l,n,r,t[6],17,-1473231341),r=i(r,c,l,n,t[7],22,-45705983),n=i(n,r,c,l,t[8],7,1770035416),l=i(l,n,r,c,t[9],12,-1958414417),c=i(c,l,n,r,t[10],17,-42063),r=i(r,c,l,n,t[11],22,-1990404162),n=i(n,r,c,l,t[12],7,1804603682),l=i(l,n,r,c,t[13],12,-40341101),c=i(c,l,n,r,t[14],17,-1502002290),n=s(n,r=i(r,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,r,c,t[6],9,-1069501632),c=s(c,l,n,r,t[11],14,643717713),r=s(r,c,l,n,t[0],20,-373897302),n=s(n,r,c,l,t[5],5,-701558691),l=s(l,n,r,c,t[10],9,38016083),c=s(c,l,n,r,t[15],14,-660478335),r=s(r,c,l,n,t[4],20,-405537848),n=s(n,r,c,l,t[9],5,568446438),l=s(l,n,r,c,t[14],9,-1019803690),c=s(c,l,n,r,t[3],14,-187363961),r=s(r,c,l,n,t[8],20,1163531501),n=s(n,r,c,l,t[13],5,-1444681467),l=s(l,n,r,c,t[2],9,-51403784),c=s(c,l,n,r,t[7],14,1735328473),n=o(n,r=s(r,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,r,c,t[8],11,-2022574463),c=o(c,l,n,r,t[11],16,1839030562),r=o(r,c,l,n,t[14],23,-35309556),n=o(n,r,c,l,t[1],4,-1530992060),l=o(l,n,r,c,t[4],11,1272893353),c=o(c,l,n,r,t[7],16,-155497632),r=o(r,c,l,n,t[10],23,-1094730640),n=o(n,r,c,l,t[13],4,681279174),l=o(l,n,r,c,t[0],11,-358537222),c=o(c,l,n,r,t[3],16,-722521979),r=o(r,c,l,n,t[6],23,76029189),n=o(n,r,c,l,t[9],4,-640364487),l=o(l,n,r,c,t[12],11,-421815835),c=o(c,l,n,r,t[15],16,530742520),n=a(n,r=o(r,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,r,c,t[7],10,1126891415),c=a(c,l,n,r,t[14],15,-1416354905),r=a(r,c,l,n,t[5],21,-57434055),n=a(n,r,c,l,t[12],6,1700485571),l=a(l,n,r,c,t[3],10,-1894986606),c=a(c,l,n,r,t[10],15,-1051523),r=a(r,c,l,n,t[1],21,-2054922799),n=a(n,r,c,l,t[8],6,1873313359),l=a(l,n,r,c,t[15],10,-30611744),c=a(c,l,n,r,t[6],15,-1560198380),r=a(r,c,l,n,t[13],21,1309151649),n=a(n,r,c,l,t[4],6,-145523070),l=a(l,n,r,c,t[11],10,-1120210379),c=a(c,l,n,r,t[2],15,718787259),r=a(r,c,l,n,t[9],21,-343485551),e[0]=p(n,e[0]),e[1]=p(r,e[1]),e[2]=p(c,e[2]),e[3]=p(l,e[3])}function r(e,t,n,r,i,s){return t=p(p(t,e),p(r,s)),p(t<<i|t>>>32-i,n)}function i(e,t,n,i,s,o,a){return r(t&n|~t&i,e,t,s,o,a)}function s(e,t,n,i,s,o,a){return r(t&i|n&~i,e,t,s,o,a)}function o(e,t,n,i,s,o,a){return r(t^n^i,e,t,s,o,a)}function a(e,t,n,i,s,o,a){return r(n^(t|~i),e,t,s,o,a)}function c(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.md5cycle=n,t.md5=d;var l="0123456789abcdef".split("");function u(e){for(var t="",n=0;n<4;n++)t+=l[e>>8*n+4&15]+l[e>>8*n&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=u(e[t]);return e.join("")}(function(e){var t,r=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,c(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(i,s),t=0;t<16;t++)s[t]=0;return s[14]=8*r,n(i,s),i}(e))}function p(e,t){return e+t&4294967295}d("hello")},367(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSyncChannelName=void 0;const r=n(6173);t.getSyncChannelName=({tableName:e,filter:t={},select:n="*"})=>[r.CHANNEL_PREFIX,e,"sync",(0,r.stableStringify)(t),"string"==typeof n?n:(0,r.stableStringify)(n)].join(".")},8349(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=t.getProperty=t.getSerialisableError=t.safeStringify=t.extractTypeUtil=t.reverseParsedPath=t.reverseJoinOn=t.tryCatch=t.getObjectEntries=t.isNotEmpty=t.pickKeys=void 0,t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.omitKeys=i,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.stableStringify=function(e,t={}){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},s={key:r,value:e[r]};return n(i,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,o;if(Array.isArray(t)){for(o="[",n=0;n<t.length;n++)n&&(o+=","),o+=e(t[n])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(i&&i(t));for(o="",n=0;n<c.length;n++){var l=c[n],u=e(t[l]);u&&(o&&(o+=","),o+=JSON.stringify(l)+":"+u)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,r.md5)(t)};function n(n=1){let r=n<1?-1:0,i=!1;for(;!i&&Math.abs(r)<=t.length;){const s=n<1?[r]:[0,r];e.slice(...s)!==t.slice(...s)?i=!0:r+=1*Math.sign(n)}return r}let i=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:i,to:s,text:t.slice(i,o),md5:(0,r.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:i,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(i);if(o&&(0,r.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.isEmpty=o,t.get=function(e,t){let n=t,r=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce((e,t)=>e&&e[t]?e[t]:void 0,r)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c;const r=n(7913);function i(e,n){return(0,t.pickKeys)(e,c(e).filter(e=>!n.includes(e)))}function s(e,t){return e.filter(e=>Object.entries(t).every(([t,n])=>e[t]===n))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function c(e){return Object.keys(e)}t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let r={};return t.forEach(t=>{n&&void 0===e[t]||(r[t]=e[t])}),r}return e},t.isNotEmpty=e=>!o(e),t.getObjectEntries=e=>Object.entries(e),t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}},t.reverseJoinOn=e=>e.map(e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))),t.reverseParsedPath=(e,n)=>{const r=[{table:n,on:[{}]},...e??[]];return r.map((e,n)=>{const i=r[n+1];if(i)return{table:e.table,on:(0,t.reverseJoinOn)(i.on)}}).filter(a).reverse()},t.extractTypeUtil=(e,t)=>{if(Object.entries(t).every(([t,n])=>e[t]===n))return e},t.safeStringify=e=>{const t=new WeakSet;return JSON.stringify(e,(e,n)=>{if("object"==typeof n&&null!==n){if(t.has(n))return"[Circular]";t.add(n)}return n})},t.getSerialisableError=(e,n=!1)=>{if(null==e)return e;if("string"==typeof e||"boolean"==typeof e||"bigint"==typeof e||void 0===e||"number"==typeof e)return e?.toString();if(e instanceof DOMException)return{name:e.name,message:e.message,code:e.code,...n?{stack:e.stack}:{}};if(e instanceof Error){const r=Object.getOwnPropertyNames(e).reduce((t,n)=>({...t,[n]:e[n]}),{}),s=JSON.parse((0,t.safeStringify)(r));return n?s:i(s,["stack"])}return Array.isArray(e)?e.map(e=>(0,t.getSerialisableError)(e,n)):e},t.getProperty=(e,t)=>{if(Object.keys(e).includes(t))return e[t]},t.withTimeout=(e,t)=>{const n=new Promise((e,n)=>setTimeout(()=>n(new Error(`Timed out after ${t}ms`)),t));return Promise.race([e,n])}},3860(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includes=function(e,t){return e.some(e=>e===t)}},1805(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(569),t),i(n(5485),t),i(n(3860),t)},569(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEqual=void 0,t.isEqual=(e,t,r="trace")=>n(e,t,void 0,r);const n=(e,t,r=new WeakMap,i)=>{if(e===t)return!0;if(typeof e!=typeof t)return!1;if(null===e||null===t)return!1;if("object"!=typeof e||"object"!=typeof t)return e!=e&&t!=t;let s=r.get(e);if(s?.has(t)){if("quiet"!==i&&console.trace("Circular reference detected in isEqual",e,t),"error"===i)throw new Error("Circular reference detected in isEqual");return"return-true"===i}if(s||(s=new WeakSet,r.set(e,s)),s.add(t),e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;const o=Array.isArray(e),a=Array.isArray(t);if(o&&a){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!n(e[s],t[s],r,i))return!1;return!0}if(o!==a)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}if(e instanceof ArrayBuffer&&t instanceof ArrayBuffer){if(e.byteLength!==t.byteLength)return!1;const n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}const c=Object.keys(e);if(c.length!==Object.keys(t).length)return!1;for(const s of c){if(!(s in t))return!1;{const o=e[s],a=t[s];if(!n(o,a,r,i))return!1}}return!0}},5485(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatchV2=void 0,t.tryCatchV2=e=>{const t=Date.now();try{const n=e();return n instanceof Promise?new Promise(async(e,r)=>{e({...await n.then(e=>({data:e})).catch(e=>({error:e,hasError:!0})),duration:Date.now()-t})}):{data:n,duration:Date.now()-t}}catch(e){return{error:e,hasError:!0,duration:Date.now()-t}}}},9155(t){"use strict";if(void 0===e){var n=new Error("Cannot find module 'react'");throw n.code="MODULE_NOT_FOUND",n}t.exports=e},4110(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasCORS=void 0;let n=!1;try{n="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}t.hasCORS=n},8661(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}},1015(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parse=function(e){if(e.length>8e3)throw"URI too long";const t=e,i=e.indexOf("["),s=e.indexOf("]");-1!=i&&-1!=s&&(e=e.substring(0,i)+e.substring(i,s).replace(/:/g,";")+e.substring(s,e.length));let o=n.exec(e||""),a={},c=14;for(;c--;)a[r[c]]=o[c]||"";return-1!=i&&-1!=s&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){const n=t.replace(/\/{2,9}/g,"/").split("/");return"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1),"/"==t.slice(-1)&&n.splice(n.length-1,1),n}(0,a.path),a.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}(0,a.query),a};const n=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"]},4624(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultBinaryType=t.globalThisShim=t.nextTick=void 0,t.createCookieJar=function(){},t.nextTick="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),t.globalThisShim="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),t.defaultBinaryType="arraybuffer"},4956(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.nextTick=t.parse=t.installTimerFunctions=t.transports=t.TransportError=t.Transport=t.protocol=t.SocketWithUpgrade=t.SocketWithoutUpgrade=t.Socket=void 0;const r=n(8223);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return r.Socket}});var i=n(8223);Object.defineProperty(t,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return i.SocketWithoutUpgrade}}),Object.defineProperty(t,"SocketWithUpgrade",{enumerable:!0,get:function(){return i.SocketWithUpgrade}}),t.protocol=r.Socket.protocol;var s=n(4689);Object.defineProperty(t,"Transport",{enumerable:!0,get:function(){return s.Transport}}),Object.defineProperty(t,"TransportError",{enumerable:!0,get:function(){return s.TransportError}});var o=n(9419);Object.defineProperty(t,"transports",{enumerable:!0,get:function(){return o.transports}});var a=n(5374);Object.defineProperty(t,"installTimerFunctions",{enumerable:!0,get:function(){return a.installTimerFunctions}});var c=n(1015);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return c.parse}});var l=n(4624);Object.defineProperty(t,"nextTick",{enumerable:!0,get:function(){return l.nextTick}});var u=n(8209);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return u.Fetch}});var d=n(2071);Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.XHR}});var p=n(2071);Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return p.XHR}});var h=n(8716);Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return h.WS}});var f=n(8716);Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return f.WS}});var y=n(4480);Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return y.WT}})},8223(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=t.SocketWithUpgrade=t.SocketWithoutUpgrade=void 0;const i=n(9419),s=n(5374),o=n(8661),a=n(1015),c=n(4454),l=n(6376),u=n(4624),d=(0,r(n(7833)).default)("engine.io-client:socket"),p="function"==typeof addEventListener&&"function"==typeof removeEventListener,h=[];p&&addEventListener("offline",()=>{d("closing %d connection(s) because the network was lost",h.length),h.forEach(e=>e())},!1);class f extends c.Emitter{constructor(e,t){if(super(),this.binaryType=u.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=(0,a.parse)(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,a.parse)(t.host).host);(0,s.installTimerFunctions)(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=(0,o.decode)(this.opts.query)),p&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(d("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},h.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,u.createCookieJar)()),this._open()}createTransport(e){d('creating transport "%s"',e);const t=Object.assign({},this.opts.query);t.EIO=l.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return d("options: %j",n),new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){d("setting transport %s",e.name),this.transport&&(d("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){d("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(d('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}else d('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();d("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=(0,s.byteLength)(n)),t>0&&e>this._maxPayload)return d("only send %d out of %d packets",t,this.writeBuffer.length),this.writeBuffer.slice(0,t);e+=2}return d("payload size is %d (max: %d)",e,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(d("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,u.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),d("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(d("socket error %j",e),f.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return d("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(d('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),p&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=h.indexOf(this._offlineEventListener);-1!==e&&(d("removing listener for the 'offline' event"),h.splice(e,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}t.SocketWithoutUpgrade=f,f.protocol=l.protocol;class y extends f{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade){d("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){d('probing transport "%s"',e);let t=this.createTransport(e),n=!1;f.priorWebsocketSuccess=!1;const r=()=>{n||(d('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",r=>{if(!n)if("pong"===r.type&&"probe"===r.data){if(d('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,d('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||"closed"!==this.readyState&&(d("changing transport and sending upgrade packet"),l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{d('probe transport "%s" failed',e);const n=new Error("probe error");n.transport=t.name,this.emitReserved("upgradeError",n)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}const s=n=>{const r=new Error("probe error: "+n);r.transport=t.name,i(),d('probe transport "%s" failed because of error: %s',e,n),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&(d('"%s" works - aborting "%s"',e.name,t.name),i())}const l=()=>{t.removeListener("open",r),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}t.SocketWithUpgrade=y,t.Socket=class extends y{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>i.transports[e]).filter(e=>!!e)),super(e,n)}}},4689(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Transport=t.TransportError=void 0;const i=n(6376),s=n(4454),o=n(5374),a=n(8661),c=(0,r(n(7833)).default)("engine.io-client:transport");class l extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}t.TransportError=l;class u extends s.Emitter{constructor(e){super(),this.writable=!1,(0,o.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new l(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState?this.write(e):c("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,i.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&443!==Number(this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=(0,a.encode)(e);return t.length?"?"+t:""}}t.Transport=u},9419(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.transports=void 0;const r=n(2071),i=n(8716),s=n(4480);t.transports={websocket:i.WS,webtransport:s.WT,polling:r.XHR}},8209(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fetch=void 0;const r=n(528);class i extends r.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(e=>this.onData(e))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(e=>{if(!e.ok)return this.onError("fetch write error",e.status,e);t()}).catch(e=>{this.onError("fetch write error",e)})}_fetch(e){var t;const n=void 0!==e,r=new Headers(this.opts.extraHeaders);return n&&r.set("content-type","text/plain;charset=UTF-8"),null===(t=this.socket._cookieJar)||void 0===t||t.appendCookies(r),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:r,credentials:this.opts.withCredentials?"include":"omit"}).then(e=>{var t;return null===(t=this.socket._cookieJar)||void 0===t||t.parseCookies(e.headers.getSetCookie()),e})}}t.Fetch=i},2071(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.XHR=t.Request=t.BaseXHR=void 0;const i=n(528),s=n(4454),o=n(5374),a=n(4624),c=n(4110),l=(0,r(n(7833)).default)("engine.io-client:polling");function u(){}class d extends i.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){l("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}t.BaseXHR=d;class p extends s.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,o.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var e;const t=(0,o.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{l("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(e){}if("POST"===this._method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this._opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(n.getResponseHeader("set-cookie"))),4===n.readyState&&(200===n.status||1223===n.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof n.status?n.status:0)},0))},l("xhr data %s",this._data),n.send(this._data)}catch(e){return void this.setTimeoutFn(()=>{this._onError(e)},0)}"undefined"!=typeof document&&(this._index=p.requestsCount++,p.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=u,e)try{this._xhr.abort()}catch(e){}"undefined"!=typeof document&&delete p.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(t.Request=p,p.requestsCount=0,p.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",h);else if("function"==typeof addEventListener){const e="onpagehide"in a.globalThisShim?"pagehide":"unload";addEventListener(e,h,!1)}function h(){for(let e in p.requests)p.requests.hasOwnProperty(e)&&p.requests[e].abort()}const f=function(){const e=y({xdomain:!1});return e&&null!==e.responseType}();function y(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||c.hasCORS))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.globalThisShim[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}t.XHR=class extends d{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new p(y,this.uri(),e)}}},528(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Polling=void 0;const i=n(4689),s=n(5374),o=n(6376),a=(0,r(n(7833)).default)("engine.io-client:polling");class c extends i.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{a("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(a("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){a("pre-pause polling complete"),--e||t()})),this.writable||(a("we are currently writing - waiting to pause"),e++,this.once("drain",function(){a("pre-pause writing complete"),--e||t()}))}else t()}_poll(){a("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){a("polling got data %s",e),(0,o.decodePayload)(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this._poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const e=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),e()):(a("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,o.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.randomString)()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}t.Polling=c},8716(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WS=t.BaseWS=void 0;const i=n(4689),s=n(5374),o=n(6376),a=n(4624),c=(0,r(n(7833)).default)("engine.io-client:websocket"),l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class u extends i.Transport{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=l?{}:(0,s.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;(0,o.encodePacket)(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(e){c("websocket closed before onclose event")}r&&(0,a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,s.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}t.BaseWS=u;const d=a.globalThisShim.WebSocket||a.globalThisShim.MozWebSocket;t.WS=class extends u{createSocket(e,t,n){return l?new d(e,t,n):t?new d(e,t):new d(e)}doWrite(e,t){this.ws.send(t)}}},4480(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WT=void 0;const i=n(4689),s=n(4624),o=n(6376),a=(0,r(n(7833)).default)("engine.io-client:webtransport");class c extends i.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{a("transport closed gracefully"),this.onClose()}).catch(e=>{a("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=(0,o.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=(0,o.createPacketEncoderStream)();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const i=()=>{n.read().then(({done:e,value:t})=>{e?a("session is closed"):(a("received chunk: %o",t),this.onPacket(t),i())}).catch(e=>{a("an error occurred while reading: %s",e)})};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&(0,s.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}}t.WT=c},5374(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pick=function(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})},t.installTimerFunctions=function(e,t){t.useNativeTimers?(e.setTimeoutFn=i.bind(r.globalThisShim),e.clearTimeoutFn=s.bind(r.globalThisShim)):(e.setTimeoutFn=r.globalThisShim.setTimeout.bind(r.globalThisShim),e.clearTimeoutFn=r.globalThisShim.clearTimeout.bind(r.globalThisShim))},t.byteLength=function(e){return"string"==typeof e?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))},t.randomString=function(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)};const r=n(4624),i=r.globalThisShim.setTimeout,s=r.globalThisShim.clearTimeout},2046(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_PACKET=t.PACKET_TYPES_REVERSE=t.PACKET_TYPES=void 0;const n=Object.create(null);t.PACKET_TYPES=n,n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const r=Object.create(null);t.PACKET_TYPES_REVERSE=r,Object.keys(n).forEach(e=>{r[n[e]]=e}),t.ERROR_PACKET={type:"error",data:"parser error"}},2745(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=void 0;const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)r[n.charCodeAt(e)]=e;t.encode=e=>{let t,r=new Uint8Array(e),i=r.length,s="";for(t=0;t<i;t+=3)s+=n[r[t]>>2],s+=n[(3&r[t])<<4|r[t+1]>>4],s+=n[(15&r[t+1])<<2|r[t+2]>>6],s+=n[63&r[t+2]];return i%3==2?s=s.substring(0,s.length-1)+"=":i%3==1&&(s=s.substring(0,s.length-2)+"=="),s},t.decode=e=>{let t,n,i,s,o,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);const u=new ArrayBuffer(a),d=new Uint8Array(u);for(t=0;t<c;t+=4)n=r[e.charCodeAt(t)],i=r[e.charCodeAt(t+1)],s=r[e.charCodeAt(t+2)],o=r[e.charCodeAt(t+3)],d[l++]=n<<2|i>>4,d[l++]=(15&i)<<4|s>>2,d[l++]=(3&s)<<6|63&o;return u}},2662(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePacket=void 0;const r=n(2046),i=n(2745),s="function"==typeof ArrayBuffer;t.decodePacket=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const n=e.charAt(0);return"b"===n?{type:"message",data:o(e.substring(1),t)}:r.PACKET_TYPES_REVERSE[n]?e.length>1?{type:r.PACKET_TYPES_REVERSE[n],data:e.substring(1)}:{type:r.PACKET_TYPES_REVERSE[n]}:r.ERROR_PACKET};const o=(e,t)=>{if(s){const n=(0,i.decode)(e);return a(n,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer},2686(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodePacket=void 0,t.encodePacketToBinary=function(e,t){return i&&e.data instanceof Blob?e.data.arrayBuffer().then(l).then(t):s&&(e.data instanceof ArrayBuffer||o(e.data))?t(l(e.data)):void a(e,!1,e=>{u||(u=new TextEncoder),t(u.encode(e))})};const r=n(2046),i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),s="function"==typeof ArrayBuffer,o=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,a=({type:e,data:t},n,a)=>i&&t instanceof Blob?n?a(t):c(t,a):s&&(t instanceof ArrayBuffer||o(t))?n?a(t):c(new Blob([t]),a):a(r.PACKET_TYPES[e]+(t||""));t.encodePacket=a;const c=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function l(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let u},6376(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodePayload=t.decodePacket=t.encodePayload=t.encodePacket=t.protocol=void 0,t.createPacketEncoderStream=function(){return new TransformStream({transform(e,t){(0,r.encodePacketToBinary)(e,n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})},t.createPacketDecoderStream=function(e,t){a||(a=new TextDecoder);const n=[];let r=0,o=-1,u=!1;return new TransformStream({transform(d,p){for(n.push(d);;){if(0===r){if(c(n)<1)break;const e=l(n,1);u=!(128&~e[0]),o=127&e[0],r=o<126?3:126===o?1:2}else if(1===r){if(c(n)<2)break;const e=l(n,2);o=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(c(n)<8)break;const e=l(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),i=t.getUint32(0);if(i>Math.pow(2,21)-1){p.enqueue(s.ERROR_PACKET);break}o=i*Math.pow(2,32)+t.getUint32(4),r=3}else{if(c(n)<o)break;const e=l(n,o);p.enqueue((0,i.decodePacket)(u?e:a.decode(e),t)),r=0}if(0===o||o>e){p.enqueue(s.ERROR_PACKET);break}}}})};const r=n(2686);Object.defineProperty(t,"encodePacket",{enumerable:!0,get:function(){return r.encodePacket}});const i=n(2662);Object.defineProperty(t,"decodePacket",{enumerable:!0,get:function(){return i.decodePacket}});const s=n(2046),o=String.fromCharCode(30);let a;function c(e){return e.reduce((e,t)=>e+t.length,0)}function l(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}t.encodePayload=(e,t)=>{const n=e.length,i=new Array(n);let s=0;e.forEach((e,a)=>{(0,r.encodePacket)(e,!1,e=>{i[a]=e,++s===n&&t(i.join(o))})})},t.decodePayload=(e,t)=>{const n=e.split(o),r=[];for(let e=0;e<n.length;e++){const s=(0,i.decodePacket)(n[e],t);if(r.push(s),"error"===s.type)break}return r},t.protocol=4},7743(e,t){"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebTransport=t.WebSocket=t.NodeWebSocket=t.XHR=t.NodeXHR=t.Fetch=t.Socket=t.Manager=t.protocol=void 0,t.io=l,t.connect=l,t.default=l;const i=n(6894),s=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return s.Manager}});const o=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return o.Socket}});const a=(0,r(n(7833)).default)("socket.io-client"),c={};function l(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=(0,i.url)(e,t.path||"/socket.io"),r=n.source,o=n.id,l=n.path,u=c[o]&&l in c[o].nsps;let d;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?(a("ignoring socket cache for %s",r),d=new s.Manager(r,t)):(c[o]||(a("new io instance for %s",r),c[o]=new s.Manager(r,t)),d=c[o]),n.query&&!t.query&&(t.query=n.queryKey),d.socket(n.path,t)}Object.assign(l,{Manager:s.Manager,Socket:o.Socket,io:l,connect:l});var u=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return u.protocol}});var d=n(4956);Object.defineProperty(t,"Fetch",{enumerable:!0,get:function(){return d.Fetch}}),Object.defineProperty(t,"NodeXHR",{enumerable:!0,get:function(){return d.NodeXHR}}),Object.defineProperty(t,"XHR",{enumerable:!0,get:function(){return d.XHR}}),Object.defineProperty(t,"NodeWebSocket",{enumerable:!0,get:function(){return d.NodeWebSocket}}),Object.defineProperty(t,"WebSocket",{enumerable:!0,get:function(){return d.WebSocket}}),Object.defineProperty(t,"WebTransport",{enumerable:!0,get:function(){return d.WebTransport}}),e.exports=l},3776(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),l=s(n(4627)),u=n(5942),d=n(7743),p=n(4454),h=(0,o(n(7833)).default)("socket.io-client:manager");class f extends p.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,(0,a.installTimerFunctions)(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new d.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||l;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(h("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=(0,u.on)(t,"open",function(){n.onopen(),e&&e()}),i=t=>{h("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=(0,u.on)(t,"error",i);if(!1!==this._timeout){const e=this._timeout;h("connect attempt will timeout after %d",e);const n=this.setTimeoutFn(()=>{h("connect attempt timed out after %d",e),r(),i(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){h("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push((0,u.on)(e,"ping",this.onping.bind(this)),(0,u.on)(e,"data",this.ondata.bind(this)),(0,u.on)(e,"error",this.onerror.bind(this)),(0,u.on)(e,"close",this.onclose.bind(this)),(0,u.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){(0,a.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){h("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void h("socket %s is still active, skipping close",e);this._close()}_packet(e){h("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){h("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){h("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;h("closed due to %s",e),this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();h("will wait %dms before reconnect attempt",t),this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(h("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(h("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):(h("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}t.Manager=f},5942(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.on=function(e,t,n){return e.on(t,n),function(){e.off(t,n)}}},6214(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Socket=void 0;const i=n(4627),s=n(5942),o=n(4454),a=(0,r(n(7833)).default)("socket.io-client:socket"),c=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class l extends o.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[(0,s.on)(e,"open",this.onopen.bind(this)),(0,s.on)(e,"packet",this.onpacket.bind(this)),(0,s.on)(e,"error",this.onerror.bind(this)),(0,s.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,r,s;if(c.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:i.PacketType.EVENT,data:t,options:{}};if(o.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++;a("emitting packet with ack id %d",e);const n=t.pop();this._registerAckCallback(e,n),o.id=e}const l=null===(r=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===r?void 0:r.writable,u=this.connected&&!(null===(s=this.io.engine)||void 0===s?void 0:s._hasPingExpired());return this.flags.volatile&&!l?a("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&(a("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(t,1));a("event with ack id %d has timed out after %d ms",e,r),t.call(this,new Error("operation has timed out"))},r),s=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,e)};s.withError=!0,this.acks[e]=s}emitWithAck(e,...t){return new Promise((n,r)=>{const i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>n!==this._queue[0]?a("packet [%d] already acknowledged",n.id):(null!==e?n.tryCount>this._opts.retries&&(a("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(e)):(a("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(a("draining queue"),!this.connected||0===this._queue.length)return;const t=this._queue[0];!t.pending||e?(t.pending=!0,t.tryCount++,a("sending packet [%d] (try n°%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)):a("packet [%d] has already been sent and is waiting for an ack",t.id)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){a("transport is open - connecting"),"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:i.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){a("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case i.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case i.PacketType.EVENT:case i.PacketType.BINARY_EVENT:this.onevent(e);break;case i.PacketType.ACK:case i.PacketType.BINARY_ACK:this.onack(e);break;case i.PacketType.DISCONNECT:this.ondisconnect();break;case i.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,a("sending ack %j",r),t.packet({type:i.PacketType.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t?(delete this.acks[e.id],a("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)):a("bad ack %s",e.id)}onconnect(e,t){a("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:i.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}t.Socket=l},6894(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.url=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(s("protocol-less url %s",e),e=void 0!==n?n.protocol+"//"+e:"https://"+e),s("parse %s",e),r=(0,i.parse)(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const o=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+o+":"+r.port+t,r.href=r.protocol+"://"+o+(n&&n.port===r.port?"":":"+r.port),r};const i=n(4956),s=(0,r(n(7833)).default)("socket.io-client:url")},2545(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deconstructPacket=function(e){const t=[],n=e.data,r=e;return r.data=i(n,t),r.attachments=t.length,{packet:r,buffers:t}},t.reconstructPacket=function(e,t){return e.data=s(e.data,t),delete e.attachments,e};const r=n(9133);function i(e,t){if(!e)return e;if((0,r.isBinary)(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=i(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=i(e[r],t));return n}return e}function s(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=s(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=s(e[n],t));return e}},4627(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Decoder=t.Encoder=t.PacketType=t.protocol=void 0,t.isPacketValid=function(e){return"string"==typeof e.nsp&&(void 0===(t=e.id)||d(t))&&function(e,t){switch(e){case c.CONNECT:return void 0===t||p(t);case c.DISCONNECT:return void 0===t;case c.EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:return Array.isArray(t);case c.CONNECT_ERROR:return"string"==typeof t||p(t);default:return!1}}(e.type,e.data);var t};const r=n(4454),i=n(2545),s=n(9133),o=(0,n(7833).default)("socket.io-parser"),a=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;t.protocol=5,function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(c||(t.PacketType=c={})),t.Encoder=class{constructor(e){this.replacer=e}encode(e){return o("encoding packet %j",e),e.type!==c.EVENT&&e.type!==c.ACK||!(0,s.hasBinary)(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),o("encoded %j as %s",e,t),t}encodeAsBinary(e){const t=(0,i.deconstructPacket)(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}};class l extends r.Emitter{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},"function"==typeof e?{reviver:e}:e)}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new u(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!(0,s.isBinary)(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===c[n.type])throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");const s=Number(i);if(!d(s)||s<0)throw new Error("Illegal attachments");if(s>this.opts.maxAttachments)throw new Error("too many attachments");n.attachments=s}if("/"===e.charAt(t+1)){const r=t+1;for(;++t&&","!==e.charAt(t)&&t!==e.length;);n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!l.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return o("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return p(t);case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||p(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===a.indexOf(t[0]));case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}t.Decoder=l;class u{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=(0,i.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function p(e){return"[object Object]"===Object.prototype.toString.call(e)}},9133(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBinary=o,t.hasBinary=function e(t,n){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if(o(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return!0;return!1};const n="function"==typeof ArrayBuffer,r=Object.prototype.toString,i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);function o(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||i&&e instanceof Blob||s&&e instanceof File}},4454(e,t,n){"use strict";function r(e){if(e)return function(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}(e)}n.r(t),n.d(t,{Emitter:()=>r}),r.prototype.on=r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},r.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},r.prototype.emitReserved=r.prototype.emit,r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}}},n={};function r(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}};return t[e].call(s.exports,s,s.exports,r),s.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=function(e){return(0,t.prostgles)(e)};const t=r(9653)})(),i})());
@@ -1 +1 @@
1
- {"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"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"}
package/dist/prostgles.js CHANGED
@@ -36,7 +36,7 @@ __exportStar(require("./hooks/useEffectDeep"), exports);
36
36
  __exportStar(require("./hooks/useProstglesClient"), exports);
37
37
  function prostgles(initOpts) {
38
38
  const { endpoint, socket, onReady, onDisconnect, onReconnect, onSchemaChange, onReload, onDebug, credentials, redirect, } = initOpts;
39
- let schemaAge;
39
+ let currentClientSchema;
40
40
  (0, exports.debug)("prostgles", { initOpts });
41
41
  if (onSchemaChange) {
42
42
  socket.removeAllListeners(prostgles_types_1.CHANNELS.SCHEMA_CHANGED);
@@ -75,8 +75,9 @@ function prostgles(initOpts) {
75
75
  const { joinTables = [], ...clientSchema } = args;
76
76
  const { methods, tableSchema, auth: authConfig, rawSQL, err } = clientSchema;
77
77
  /** Only destroy existing syncs if schema changed */
78
- const schemaDidNotChange = schemaAge?.clientSchema && (0, prostgles_types_1.isEqual)(schemaAge.clientSchema, clientSchema);
79
- if (!schemaDidNotChange) {
78
+ const schemaChanged = currentClientSchema?.clientSchema &&
79
+ !(0, prostgles_types_1.isEqual)(currentClientSchema.clientSchema, clientSchema);
80
+ if (schemaChanged) {
80
81
  console.warn("syncHandler.destroySyncs()");
81
82
  // syncHandler
82
83
  // .destroySyncs()
@@ -90,10 +91,10 @@ function prostgles(initOpts) {
90
91
  if (err) {
91
92
  return;
92
93
  }
93
- schemaAge = { origin: "onReconnect", date: new Date(), clientSchema };
94
+ currentClientSchema = { origin: "onReconnect", date: new Date(), clientSchema };
94
95
  }
95
96
  else {
96
- schemaAge = { origin: "onReady", date: new Date(), clientSchema };
97
+ currentClientSchema = { origin: "onReady", date: new Date(), clientSchema };
97
98
  }
98
99
  if (err) {
99
100
  reject(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-client",
3
- "version": "4.0.363",
3
+ "version": "4.0.364",
4
4
  "description": "Reactive client for Postgres",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",