prostgles-client 4.0.88 → 4.0.90

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.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>(()=>{var e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),r="DEBUG_SYNCEDTABLE",s="undefined"!=typeof window;t.debug=function(...e){s&&window[r]&&window[r](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:a,onDebug:u,db:d,skipFirstTrigger:f=!1,select:h="*",storageType:p="object",patchText:m=!1,patchJSON:y=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map((e=>e.current)),s=[],o=[];if(this.columns&&this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter((e=>"text"===e.data_type));if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map((async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map((e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,i.getTextPatch)(l[e.name],c[e.name]))})),u&&this.wal&&(o.push(u),s.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)})))}}if(s.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(s))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter((e=>e))},this._notifySubscribers=(e=[])=>{if(!this.isSynced)return;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:r,delta:s})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,s)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(s),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((r=>{e.push({...r});const s=t.findIndex((e=>this.matchesIdObj(r,e)));i.push(n[s])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}}))}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter((t=>t._onChange!==e)),this.multiSubscriptions=this.multiSubscriptions.filter((t=>t._onChange!==e)),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&this.columns.length){const t=Object.keys({...e}).filter((e=>!this.columns.find((t=>t.name===e))));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";let s,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var r;let l={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(l),f=d.index,h=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(h)||(u=this.getDelta(h||{},u)),t||(u[this.synced_field]=Date.now());let p={...h,...u,...l};h&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(p=c({...h,...l},{...u})),s=h?h[this.synced_field]<p[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(p,f);let m={idObj:l,delta:u,oldItem:h,newItem:p,status:s,from_server:t};return t||a.push({initial:h,current:{...p}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=l(e);if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter((e=>!this.filter||!(0,i.getKeys)(this.filter).find((t=>e[t]!==this.filter[t])))).sort(((e,n)=>t.map((t=>e[t]<n[t]?-1:e[t]>n[t]?1:0)).find((e=>e))))}return l(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={offset:0,limit:void 0})=>{let r=this.getItems().map((e=>({...e}))).filter((n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t)));return(n||i)&&(r=r.splice(null!=n?n:0,i||r.length)),r},this.name=e,this.filter=n,this.select=h,this.onChange=r,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[p])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(s||p!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),p="object"),this.storageType=p,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:S=100,batch_size:O=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=O,this.throttle=S,this.skipFirstTrigger=f,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:S};d[this.name]._sync(n,{select:h},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;let t=this.getItems().map((e=>({...e})));this.setItems([]);const n=t.map((e=>({idObj:this.getIdObj(e),delta:{...e}})));await this.upsert(n,!0)}else if("data"in e){let t=e.data.map((e=>({idObj:this.getIdObj(e),delta:e})));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then((e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new i.WAL({..._,batch_size:O,onSendStart:()=>{s&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{s&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map((e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}})))}}),a()})),d[this.name].getColumns&&d[this.name].getColumns().then((e=>{this.columns=e})),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise(((t,n)=>{try{const n=new a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let r=[...n],s=[...i];return t&&(r=r.map(((n,i)=>{const r=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>r(this.getItem(i).data,i),$find:e=>r(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),s=this.getIdObj(n);return r(n,s)}))),e(r,s)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,r)=>{let s={...e};return n&&(s.$get=i.$get,s.$find=i.$find,s.$update=i.$update,s.$delete=i.$delete,s.$unsync=i.$unsync,s.$cloneSync=i.$cloneSync),t(s,r)}};return this.singleSubscriptions.push(r),setTimeout((()=>{let e=i.$get();e&&r.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.isEmpty)(this.filter)||!Object.keys(this.filter).find((t=>this.filter[t]!==e[t]))))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find((n=>e[n]!==t[n])))}getDelta(e,t){return(0,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let r={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(r=n):r=n}return{...n,...r}}),{})}deleteAll(){this.getItems().map((e=>this.delete(e)))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let t;return this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:l(t),index:-1}}setItem(e,t,n=!1,i=!1){const r=l(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),s&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(r)];else{let e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function c(e,t){const n=e?l(e):e,r=t?l(t):t;let s=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(r)&&Object.keys(r).forEach((e=>{(0,i.isObject)(r[e])?e in n?s[e]=c(n[e],r[e]):Object.assign(s,{[e]:r[e]}):Object.assign(s,{[e]:r[e]})})),s}function l(e){if(s&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>l(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=l(e[n])})),t}return e}t.SyncedTable=a,t.default=c,t.quickClone=l},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.useProstglesClient=t.asName=t.debug=void 0;const s=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(133),a=n(353),c="DEBUG_SYNCEDTABLE",l="undefined"!=typeof window;function u(e,n){const{socket:i,onReady:r,onDisconnect:o,onReconnect:c,onSchemaChange:u=!0,onReload:f,onDebug:h}=e;let p;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),e&&i.on(s.CHANNELS.SCHEMA_CHANGED,e)}const m=s.CHANNELS._preffix;let y,g,b={},v={},S={},O={};function _(e,n,r){return(0,t.debug)("_unsubscribe",{channelName:e,handler:r}),new Promise(((t,s)=>{const o=b[e];o?(o.handlers=o.handlers.filter((e=>e!==r)),o.handlers.length||(i.emit(n,{},((e,t)=>{e?console.error(e):s(e)})),i.removeListener(e,o.onCall),delete b[e]),t(!0)):t(!0)}))}function w({tableName:e,command:t,param1:n,param2:r},s){return new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:r}=t;i.emit(r,{onSyncRequest:s({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:r})}}))}))}function j({tableName:e,command:t,param1:n,param2:r}){return new Promise(((s,o)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{e?(console.error(e),o(e)):t&&s(t)}))}))}const E=new d((async function({tableName:e,command:n,param1:r,param2:s},o){const{onSyncRequest:a}=o;function c(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,r)=>{S[e]&&(S[e].triggers=S[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),S[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?r(e):t(n)})),i.removeListener(e,S[e].onCall),delete S[e]))}))}(e,o)},syncData:function(t,n,r){i.emit(e,{onSyncRequest:{...a({}),...{data:t}||{},...{deleted:n}||{}}},r?e=>{r(e)}:null)}})}const l=Object.keys(S).find((t=>{let i=S[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l)return S[l].triggers.push(o),c(l);{const u=await w({tableName:e,command:n,param1:r,param2:s},a),{channelName:d,synced_field:f,id_fields:h}=u;function p(t,n){t&&S[d]&&S[d].triggers.map((({onUpdates:i,onSyncRequest:r,onPullRequest:s})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(r(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(s(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return S[d]={tableName:e,command:n,param1:r,param2:s,triggers:[o],syncInfo:u,onCall:p},i.on(d,p),c(d)}}),(([{tableName:e}])=>e)),N=new d((async function(e,{tableName:t,command:n,param1:r,param2:s},o,a){function c(n,i){let s={unsubscribe:function(){return _(n,i,o)},filter:{...r}};return e[t].update&&(s={...s,update:function(n,i){return e[t].update(r,n,i)}}),e[t].delete&&(s={...s,delete:function(n){return e[t].delete(r,n)}}),Object.freeze(s)}const l=Object.entries(b).find((([e])=>{let i=b[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l){const e=l[0];return l[1].handlers.push(o),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==b?void 0:b[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==b?void 0:b[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:f}=await j({tableName:t,command:n,param1:r,param2:s}),h=function(e,t){const n=b[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},p=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,h),b[u]={lastData:void 0,tableName:t,command:n,param1:r,param2:s,onCall:h,unsubChannel:f,handlers:[o],errorHandlers:[p],destroy:async()=>{var e,t;for await(const n of null!==(t=null===(e=b[u])||void 0===e?void 0:e.handlers)&&void 0!==t?t:[])await _(u,f,n)}},i.emit(d,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function C(e,t,n,i){return N.run([e,t,n,i])}return new Promise(((e,u)=>{i.removeAllListeners(s.CHANNELS.CONNECTION),i.on(s.CHANNELS.CONNECTION,(e=>(u(e),"ok"))),o&&i.on("disconnect",(()=>{g="disconnected",o()})),c&&i.on("connect",(()=>{"disconnected"===g&&(g="reconnected")})),i.on(s.CHANNELS.SCHEMA,(async({schema:o,methods:d,tableSchema:_,auth:N,rawSQL:T,joinTables:x=[],err:P})=>{if(await(async()=>{(0,t.debug)("destroySyncs",{subscriptions:b,syncedTables:v}),await Promise.all(Object.values(b).map((e=>e.destroy()))),S={},Object.values(v).map((e=>{e&&e.destroy&&e.destroy()})),v={}})(),"connected"!==g&&"reconnected"!==g||!c)p={origin:"onReady",date:new Date};else{if(c(i,P),P)return void console.error(P);p={origin:"onReconnect",date:new Date}}if(P)throw u(P),P;const I="reconnected"===g;g="connected";let k=JSON.parse(JSON.stringify(o)),$=JSON.parse(JSON.stringify(d)),R={},D={};if(N){if(N.pathGuard&&l){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(f?f():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(s.CHANNELS.AUTHGUARD),i.on(s.CHANNELS.AUTHGUARD,(t=>{e(t)}))}D={...N},[s.CHANNELS.LOGIN,s.CHANNELS.LOGOUT,s.CHANNELS.REGISTER].map((e=>{N[e]&&(D[e]=function(t){return new Promise(((n,r)=>{i.emit(m+e,t,((e,t)=>{e?r(e):n(t)}))}))})}))}$.map((e=>{const t="string"==typeof e,n=t?e:e.name,r=async function(...e){return await(null==h?void 0:h({type:"method",command:n,data:{params:e}})),new Promise(((t,r)=>{i.emit(s.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?r(e):t(n)}))}))};R[n]=t?r:{...e,run:r}})),R=Object.freeze(R),T&&(k.sql=function(e,t,n){return new Promise(((r,o)=>{i.emit(s.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else{if("stream"===(null==n?void 0:n.returnType)){const{channel:e,unsubChannel:n}=t,s=t=>new Promise(((r,s)=>{i.on(e,t),i.emit(e,{},((t,o)=>{o?(s(o),i.removeAllListeners(e)):r({run:(t,n)=>new Promise(((r,s)=>{i.emit(e,{query:t,params:n},((e,t)=>{t?s(t):r(e)}))})),stop:e=>new Promise(((t,r)=>{i.emit(n,{terminate:e},((e,n)=>{n?r(n):t(e)}))}))})}))}));return r({channel:e,unsubChannel:n,start:s})}if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{y=y||{config:t,listeners:[]},y.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{y&&y.listeners&&y.listeners.length?y.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),y.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{y&&(y.listeners=y.listeners.filter((t=>t!==e)),!y.listeners.length&&y.config&&y.config.socketUnsubChannel&&i&&i.emit(y.config.socketUnsubChannel,{}))})(t)}),s={...e,addListener:n};r(s)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))r(t);else{const e=t,n=n=>(((e,t)=>{var n;O=O||{},O[t.notifChannel]?null===(n=O[t.notifChannel])||void 0===n||n.listeners.push(e):(O[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,r;(null===(n=O[t.notifChannel])||void 0===n?void 0:n.listeners.length)?O[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(r=O[t.notifChannel])||void 0===r?void 0:r.config.socketUnsubChannel,{})})))})(n,e),{...t,removeListener:()=>((e,t)=>{const n=O[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete O[t.notifChannel]))})(n,e)}),s={...t,addListener:n};r(s)}}}))}))});const A=(e,t,n,i)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.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"},J=["subscribe","subscribeOne"];(0,s.getKeys)(k).forEach((e=>{const t=Object.keys(k[e]),r=k[e];t.sort(((e,t)=>J.includes(e)-J.includes(t))).forEach((t=>{if("sync"===t){if(r._syncInfo={...r[t]},n){r.getSync=async(t,i={})=>(await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:h,filter:t,db:k,...i}));const t=async(t={},i={},r)=>{const s=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return v[s]||(v[s]=await n.create({...i,onDebug:h,name:e,filter:t,db:k,onError:r})),v[s]},i=async(n,i={handlesOnData:!0,select:"*"},r,s)=>{await(null==h?void 0:h({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.sync(r,i.handlesOnData)},s=async(n,i={handlesOnData:!0},r,s)=>{await(null==h?void 0:h({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.syncOne(n,r,i.handlesOnData)};r.sync=i,r.syncOne=s,r.useSync=(e,t)=>(0,a.useSync)(r.sync,e,t)}r._sync=async function(n,i,r){return await(null==h?void 0:h({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:r}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:i},r)}}else if(J.includes(t)){const n=async function(n={},i={},r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},r,s)};r[t]=n;const i="subscribeOne",s=function(e={},r={},s){return{start:o=>n(e,r,t!==i?o:e=>{o(e[0])},s),args:[e,r,s]}},o="subscribe"===t?"useSubscribe":"subscribeOne"===t?"useSubscribeOne":void 0;o&&(r[o]=(...e)=>(0,a.useSubscribe)(s(...e)),r[o+"V2"]=(e,r)=>(0,a.useSubscribeV2)(n,t===i,e,r)),t!==i&&J.includes(i)||(r[i]=async function(n,i,r,s){return await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},(e=>{r(e[0])}),s)})}else{const n=async function(n,r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:r,param3:s}})),new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r,param3:s},((e,t)=>{e?a(e):o(t)}))}))};r[t]=n;const s="findOne"===t?"useFindOne":"find"===t?"useFind":"count"===t?"useCount":"size"===t?"useSize":void 0;s&&(r[s]=(e,t,i)=>(0,a.usePromise)((()=>n(e,t,i)),[e,t,i]),r[s+"V2"]=(e,t,i)=>(0,a.useFetch)(n,[e,t,i])),["find","findOne"].includes(t)&&(r.getJoinedTables=function(){return(x||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))})}}))})),b&&Object.keys(b).length&&Object.keys(b).map((async e=>{try{let t=b[e];await j(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),S&&Object.keys(S).length&&(0,s.getKeys)(S).filter((e=>{var t;return null===(t=S[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=S[e];await w(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),x.flat().map((e=>{k.innerJoin=k.innerJoin||{},k.leftJoin=k.leftJoin||{},k.innerJoinOne=k.innerJoinOne||{},k.leftJoinOne=k.leftJoinOne||{};const t=(0,s.getJoinHandlers)(e);k.leftJoin[e]=t.leftJoin,k.innerJoin[e]=t.innerJoin,k.leftJoinOne[e]=t.leftJoinOne,k.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await r(k,R,_,D,I)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}e(k)})()}))}))}t.debug=function(...e){l&&window[c]&&window[c](...e)},r(n(353),t),t.useProstglesClient=e=>{const t=(0,a.getReact)(!0),[n,i]=t.useState(),r=(0,a.useIsMounted)();return(0,a.useAsyncEffectQueue)((async()=>{await u({...e,onReady:(...t)=>{if(!r())return;e.onReady(...t);const[n,s,o,a,c]=t;i({dbo:n,methods:s,tableSchema:o,auth:a,isReconnect:c})}},o.SyncedTable)}),[e]),n},t.prostgles=u;class d{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),n=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=[],n=[];this.queue.forEach((async(e,i)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:i,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},353:(e,t,n)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribeV2=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=t.getReact=void 0;const r=n(792);let s;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=s||(s=n(294))}catch(e){}if(e&&!s)throw new Error("Must install react");return s},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(i=s)&&void 0!==i?i:{};function f(){const e=u(!0),t=l((()=>e.current),[]);return c((()=>()=>{e.current=!1}),[]),t}t.isEqual=function(e,n){if(e===n)return!0;if("object"==typeof e&&null!=e&&"object"==typeof n&&null!=n){if(Object.keys(e).length!=Object.keys(n).length)return!1;for(const i in e){if(!n.hasOwnProperty(i))return!1;if(!(0,t.isEqual)(e[i],n[i]))return!1}return!0}return!1},t.useDeepCompareMemoize=e=>{const n=u();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{c(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const i={effect:e,deps:n,didCleanup:!1},r=u({activeEffect:void 0,latestEffect:i});r.current.latestEffect=i;const s=async e=>{var t,n,i;if(e.current.latestEffect&&(!e.current.activeEffect||e.current.activeEffect.resolvedCleanup)){if(await(null===(i=null===(n=null===(t=e.current.activeEffect)||void 0===t?void 0:t.resolvedCleanup)||void 0===n?void 0:n.run)||void 0===i?void 0:i.call(n)),e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,!e.current.activeEffect)return;const r=await e.current.activeEffect.effect();if(!e.current.activeEffect)return void await(null==r?void 0:r());e.current.activeEffect.resolvedCleanup={run:r},e.current.activeEffect.didCleanup&&o()}},o=async()=>{var e,t,n;await(null===(n=null===(t=null===(e=r.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)||void 0===t?void 0:t.run)||void 0===n?void 0:n.call(t)),r.current.activeEffect=void 0,s(r)};(0,t.useEffectDeep)((()=>(s(r),()=>{var t,n;(null===(t=r.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(r.current.activeEffect.didCleanup=!0,o()),(null===(n=r.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(r.current.latestEffect=void 0)})),n)},t.useEffectAsync=(e,n)=>{const i=u({cleanup:void 0,effect:e,cleanupEffect:void 0});i.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(i.current.cleanup=t,i.current.cleanupEffect===e&&t())})),()=>{var t,n;i.current.cleanupEffect=e,null===(n=(t=i.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=f,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},s=e=>{try{return(0,r.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,c]=d(s(e)?{}:void 0),l=f();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(s(e))t=await o(e);else{const n=await e();t=s(n)?await o(n):i(n)?await n():n}l()&&c(t)}),n),a},t.useSubscribe=e=>{const[n,i]=d(),r=f();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{r()&&i(e)}))).unsubscribe),e.args),n},t.useSubscribeV2=(e,n,i,r)=>{const s={data:void 0,error:void 0,isLoading:!0},[{data:o,error:a,isLoading:c},l]=d(s),u=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!u())return;l(s);const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(i,r,(e=>{u()&&l({data:n?e[0]:e,error:void 0,isLoading:!1})}),t)).unsubscribe}catch(e){t(e)}}),[e,i,r]),{data:o,error:a,isLoading:c}},t.useSync=(e,n,i)=>{const r={data:void 0,error:void 0,isLoading:!0},[{data:s,error:o,isLoading:a},c]=d(r),l=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!l())return;c(r);const t=e=>{l()&&c({data:void 0,error:e,isLoading:!1})};try{return(await e(n,i,(e=>{l()&&c({data:e,error:void 0,isLoading:!1})}),t)).$unsync()}catch(e){t(e)}}),[e,n,i]),{data:s,error:o,isLoading:a}},t.useFetch=(e,n=[])=>{const i={data:void 0,error:void 0,isLoading:!0},[{data:r,error:s,isLoading:o},a]=d(i),c=f();return(0,t.useAsyncEffectQueue)((async()=>{if(c()){a(i);try{const t=await e(...n);if(!c())return;a({data:t,error:void 0,isLoading:!1})}catch(e){if(!c())return;a({data:void 0,error:e,isLoading:!1})}}}),n),{data:r,error:s,isLoading:o}},t.__prglReactInstalled=()=>Boolean(s&&u)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 s={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(n(444),t),r(n(929),t),r(n(128),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:n,arrayOf:s,arrayOfType:o,description:a,nullable:c,oneOf:l,oneOfType:u,title:d,record:f,...h}="string"==typeof e?{type:e}:e;let p={};const m={...(h.enum||h.allowedValues?.length)&&{enum:h.allowedValues?.slice(0)??h.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(h.enum?.length&&(m.type=typeof h.enum[0]),"string"==typeof n||s||o){if(n&&"string"!=typeof n)throw"Not expected";p=s||o||n?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...h.allowedValues&&{enum:h.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?p={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:r(n[t])})),{})}:l||u?p={oneOf:(l||u.map((e=>({type:e})))).map((e=>r(e)))}:f&&(p={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:r(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?r(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};p.oneOf?p.oneOf.push(e):p.enum&&!p.enum.includes(null)?p.enum.push(null):p={oneOf:[p,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...p}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return r(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],c=e[2],l=e[3];n=r(n,i,c,l,t[0],7,-680876936),l=r(l,n,i,c,t[1],12,-389564586),c=r(c,l,n,i,t[2],17,606105819),i=r(i,c,l,n,t[3],22,-1044525330),n=r(n,i,c,l,t[4],7,-176418897),l=r(l,n,i,c,t[5],12,1200080426),c=r(c,l,n,i,t[6],17,-1473231341),i=r(i,c,l,n,t[7],22,-45705983),n=r(n,i,c,l,t[8],7,1770035416),l=r(l,n,i,c,t[9],12,-1958414417),c=r(c,l,n,i,t[10],17,-42063),i=r(i,c,l,n,t[11],22,-1990404162),n=r(n,i,c,l,t[12],7,1804603682),l=r(l,n,i,c,t[13],12,-40341101),c=r(c,l,n,i,t[14],17,-1502002290),n=s(n,i=r(i,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,i,c,t[6],9,-1069501632),c=s(c,l,n,i,t[11],14,643717713),i=s(i,c,l,n,t[0],20,-373897302),n=s(n,i,c,l,t[5],5,-701558691),l=s(l,n,i,c,t[10],9,38016083),c=s(c,l,n,i,t[15],14,-660478335),i=s(i,c,l,n,t[4],20,-405537848),n=s(n,i,c,l,t[9],5,568446438),l=s(l,n,i,c,t[14],9,-1019803690),c=s(c,l,n,i,t[3],14,-187363961),i=s(i,c,l,n,t[8],20,1163531501),n=s(n,i,c,l,t[13],5,-1444681467),l=s(l,n,i,c,t[2],9,-51403784),c=s(c,l,n,i,t[7],14,1735328473),n=o(n,i=s(i,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,i,c,t[8],11,-2022574463),c=o(c,l,n,i,t[11],16,1839030562),i=o(i,c,l,n,t[14],23,-35309556),n=o(n,i,c,l,t[1],4,-1530992060),l=o(l,n,i,c,t[4],11,1272893353),c=o(c,l,n,i,t[7],16,-155497632),i=o(i,c,l,n,t[10],23,-1094730640),n=o(n,i,c,l,t[13],4,681279174),l=o(l,n,i,c,t[0],11,-358537222),c=o(c,l,n,i,t[3],16,-722521979),i=o(i,c,l,n,t[6],23,76029189),n=o(n,i,c,l,t[9],4,-640364487),l=o(l,n,i,c,t[12],11,-421815835),c=o(c,l,n,i,t[15],16,530742520),n=a(n,i=o(i,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,i,c,t[7],10,1126891415),c=a(c,l,n,i,t[14],15,-1416354905),i=a(i,c,l,n,t[5],21,-57434055),n=a(n,i,c,l,t[12],6,1700485571),l=a(l,n,i,c,t[3],10,-1894986606),c=a(c,l,n,i,t[10],15,-1051523),i=a(i,c,l,n,t[1],21,-2054922799),n=a(n,i,c,l,t[8],6,1873313359),l=a(l,n,i,c,t[15],10,-30611744),c=a(c,l,n,i,t[6],15,-1560198380),i=a(i,c,l,n,t[13],21,1309151649),n=a(n,i,c,l,t[4],6,-145523070),l=a(l,n,i,c,t[11],10,-1120210379),c=a(c,l,n,i,t[2],15,718787259),i=a(i,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(i,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function i(e,t,n,i,r,s){return t=f(f(t,e),f(i,s)),f(t<<r|t>>>32-r,n)}function r(e,t,n,r,s,o,a){return i(t&n|~t&r,e,t,s,o,a)}function s(e,t,n,r,s,o,a){return i(t&r|n&~r,e,t,s,o,a)}function o(e,t,n,r,s,o,a){return i(t^n^r,e,t,s,o,a)}function a(e,t,n,r,s,o,a){return i(n^(t|~r),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.md5=t.md5cycle=void 0,t.md5cycle=n;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,i=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,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(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*i,n(r,s),r}(e))}function f(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function r(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.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let i={};return t.forEach((t=>{n&&void 0===e[t]||(i[t]=e[t])})),i}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},s={key:i,value:e[i]};return n(r,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(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(r&&r(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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,r=!1;for(;!r&&Math.abs(i)<=t.length;){const s=n<1?[i]:[0,i];e.slice(...s)!==t.slice(...s)?r=!0:i+=1*Math.sign(n)}return i}let r=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(r);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],s=+i-+r,o=i<r?-1:i==r?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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:r}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:i,delta:r}),this.changed[s].current={...this.changed[s].current,...i},this.changed[s].delta={...this.changed[s].delta,...r}})),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:r,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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],r=e.current[n];var s,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((s=i)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[n]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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}},t.isEmpty=o,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:n,...r(s,["path","select"]),select:i});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,n)=>{const i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const r=i[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var S=v.prototype=new b;S.constructor=v,m(S,g.prototype),S.isPureReactComponent=!0;var O=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,i){var r,s={},o=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,r)&&!j.hasOwnProperty(r)&&(s[r]=t[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:n,type:e,key:o,ref:a,props:s,_owner:w.current}}function N(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var C=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(e,t,r,s,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case i:c=!0}}if(c)return o=o(c=e),e=""===s?"."+T(c,0):s,O(o)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),x(o,t,r,"",(function(e){return e}))):null!=o&&(N(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(C,"$&/")+"/")+e)),t.push(o)),1;if(c=0,s=""===s?".":s+":",O(e))for(var l=0;l<e.length;l++){var u=s+T(a=e[l],l);c+=x(a,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=x(a=a.value,t,r,u=s+T(a,l++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var i=[],r=0;return x(e,i,"","",(function(e){return t.call(n,e,r++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},R={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=r,t.Profiler=o,t.PureComponent=v,t.StrictMode=s,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=R,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m({},e.props),s=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!j.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:n,type:e.type,key:s,ref:o,props:r,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=N,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=void 0;const t=n(274),r=n(133);e.prostgles=function(e){return(0,t.prostgles)(e,r.SyncedTable)}})(),i})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>(()=>{var e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),r="DEBUG_SYNCEDTABLE",s="undefined"!=typeof window;t.debug=function(...e){s&&window[r]&&window[r](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:a,onDebug:u,db:d,skipFirstTrigger:f=!1,select:h="*",storageType:p="object",patchText:m=!1,patchJSON:y=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map((e=>e.current)),s=[],o=[];if(this.columns&&this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter((e=>"text"===e.data_type));if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map((async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map((e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,i.getTextPatch)(l[e.name],c[e.name]))})),u&&this.wal&&(o.push(u),s.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)})))}}if(s.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(s))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter((e=>e))},this._notifySubscribers=(e=[])=>{if(!this.isSynced)return;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:r,delta:s})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,s)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(s),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((r=>{e.push({...r});const s=t.findIndex((e=>this.matchesIdObj(r,e)));i.push(n[s])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}}))}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter((t=>t._onChange!==e)),this.multiSubscriptions=this.multiSubscriptions.filter((t=>t._onChange!==e)),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&this.columns.length){const t=Object.keys({...e}).filter((e=>!this.columns.find((t=>t.name===e))));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";let s,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var r;let l={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(l),f=d.index,h=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(h)||(u=this.getDelta(h||{},u)),t||(u[this.synced_field]=Date.now());let p={...h,...u,...l};h&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(p=c({...h,...l},{...u})),s=h?h[this.synced_field]<p[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(p,f);let m={idObj:l,delta:u,oldItem:h,newItem:p,status:s,from_server:t};return t||a.push({initial:h,current:{...p}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=l(e);if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter((e=>!this.filter||!(0,i.getKeys)(this.filter).find((t=>e[t]!==this.filter[t])))).sort(((e,n)=>t.map((t=>e[t]<n[t]?-1:e[t]>n[t]?1:0)).find((e=>e))))}return l(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={offset:0,limit:void 0})=>{let r=this.getItems().map((e=>({...e}))).filter((n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t)));return(n||i)&&(r=r.splice(null!=n?n:0,i||r.length)),r},this.name=e,this.filter=n,this.select=h,this.onChange=r,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[p])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(s||p!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),p="object"),this.storageType=p,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:S=100,batch_size:O=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=O,this.throttle=S,this.skipFirstTrigger=f,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:S};d[this.name]._sync(n,{select:h},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;let t=this.getItems().map((e=>({...e})));this.setItems([]);const n=t.map((e=>({idObj:this.getIdObj(e),delta:{...e}})));await this.upsert(n,!0)}else if("data"in e){let t=e.data.map((e=>({idObj:this.getIdObj(e),delta:e})));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then((e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new i.WAL({..._,batch_size:O,onSendStart:()=>{s&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{s&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map((e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}})))}}),a()})),d[this.name].getColumns&&d[this.name].getColumns().then((e=>{this.columns=e})),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise(((t,n)=>{try{const n=new a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let r=[...n],s=[...i];return t&&(r=r.map(((n,i)=>{const r=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>r(this.getItem(i).data,i),$find:e=>r(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),s=this.getIdObj(n);return r(n,s)}))),e(r,s)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,r)=>{let s={...e};return n&&(s.$get=i.$get,s.$find=i.$find,s.$update=i.$update,s.$delete=i.$delete,s.$unsync=i.$unsync,s.$cloneSync=i.$cloneSync),t(s,r)}};return this.singleSubscriptions.push(r),setTimeout((()=>{let e=i.$get();e&&r.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.isEmpty)(this.filter)||!Object.keys(this.filter).find((t=>this.filter[t]!==e[t]))))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find((n=>e[n]!==t[n])))}getDelta(e,t){return(0,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let r={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(r=n):r=n}return{...n,...r}}),{})}deleteAll(){this.getItems().map((e=>this.delete(e)))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let t;return this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:l(t),index:-1}}setItem(e,t,n=!1,i=!1){const r=l(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),s&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(r)];else{let e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function c(e,t){const n=e?l(e):e,r=t?l(t):t;let s=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(r)&&Object.keys(r).forEach((e=>{(0,i.isObject)(r[e])?e in n?s[e]=c(n[e],r[e]):Object.assign(s,{[e]:r[e]}):Object.assign(s,{[e]:r[e]})})),s}function l(e){if(s&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>l(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=l(e[n])})),t}return e}t.SyncedTable=a,t.default=c,t.quickClone=l},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.useProstglesClient=t.asName=t.debug=void 0;const s=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(133),a=n(353),c="DEBUG_SYNCEDTABLE",l="undefined"!=typeof window;function u(e,n){const{socket:i,onReady:r,onDisconnect:o,onReconnect:c,onSchemaChange:u=!0,onReload:f,onDebug:h}=e;let p;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),e&&i.on(s.CHANNELS.SCHEMA_CHANGED,e)}const m=s.CHANNELS._preffix;let y,g,b={},v={},S={},O={};function _(e,n,r){return(0,t.debug)("_unsubscribe",{channelName:e,handler:r}),new Promise(((t,s)=>{const o=b[e];o?(o.handlers=o.handlers.filter((e=>e!==r)),o.handlers.length||(i.emit(n,{},((e,t)=>{e?console.error(e):s(e)})),i.removeListener(e,o.onCall),delete b[e]),t(!0)):t(!0)}))}function w({tableName:e,command:t,param1:n,param2:r},s){return new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:r}=t;i.emit(r,{onSyncRequest:s({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:r})}}))}))}function j({tableName:e,command:t,param1:n,param2:r}){return new Promise(((s,o)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{e?(console.error(e),o(e)):t&&s(t)}))}))}const E=new d((async function({tableName:e,command:n,param1:r,param2:s},o){const{onSyncRequest:a}=o;function c(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,r)=>{S[e]&&(S[e].triggers=S[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),S[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?r(e):t(n)})),i.removeListener(e,S[e].onCall),delete S[e]))}))}(e,o)},syncData:function(t,n,r){i.emit(e,{onSyncRequest:{...a({}),...{data:t}||{},...{deleted:n}||{}}},r?e=>{r(e)}:null)}})}const l=Object.keys(S).find((t=>{let i=S[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l)return S[l].triggers.push(o),c(l);{const u=await w({tableName:e,command:n,param1:r,param2:s},a),{channelName:d,synced_field:f,id_fields:h}=u;function p(t,n){t&&S[d]&&S[d].triggers.map((({onUpdates:i,onSyncRequest:r,onPullRequest:s})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(r(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(s(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return S[d]={tableName:e,command:n,param1:r,param2:s,triggers:[o],syncInfo:u,onCall:p},i.on(d,p),c(d)}}),(([{tableName:e}])=>e)),N=new d((async function(e,{tableName:t,command:n,param1:r,param2:s},o,a){function c(n,i){let s={unsubscribe:function(){return _(n,i,o)},filter:{...r}};return e[t].update&&(s={...s,update:function(n,i){return e[t].update(r,n,i)}}),e[t].delete&&(s={...s,delete:function(n){return e[t].delete(r,n)}}),Object.freeze(s)}const l=Object.entries(b).find((([e])=>{let i=b[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l){const e=l[0];return l[1].handlers.push(o),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==b?void 0:b[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==b?void 0:b[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:f}=await j({tableName:t,command:n,param1:r,param2:s}),h=function(e,t){const n=b[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},p=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,h),b[u]={lastData:void 0,tableName:t,command:n,param1:r,param2:s,onCall:h,unsubChannel:f,handlers:[o],errorHandlers:[p],destroy:async()=>{var e,t;for await(const n of null!==(t=null===(e=b[u])||void 0===e?void 0:e.handlers)&&void 0!==t?t:[])await _(u,f,n)}},i.emit(d,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function C(e,t,n,i){return N.run([e,t,n,i])}return new Promise(((e,u)=>{i.removeAllListeners(s.CHANNELS.CONNECTION),i.on(s.CHANNELS.CONNECTION,(e=>(u(e),"ok"))),o&&i.on("disconnect",(()=>{g="disconnected",o()})),c&&i.on("connect",(()=>{"disconnected"===g&&(g="reconnected")})),i.on(s.CHANNELS.SCHEMA,(async({schema:o,methods:d,tableSchema:_,auth:N,rawSQL:T,joinTables:x=[],err:P})=>{if(await(async()=>{(0,t.debug)("destroySyncs",{subscriptions:b,syncedTables:v}),await Promise.all(Object.values(b).map((e=>e.destroy()))),S={},Object.values(v).map((e=>{e&&e.destroy&&e.destroy()})),v={}})(),"connected"!==g&&"reconnected"!==g||!c)p={origin:"onReady",date:new Date};else{if(c(i,P),P)return void console.error(P);p={origin:"onReconnect",date:new Date}}if(P)throw u(P),P;const I="reconnected"===g;g="connected";let k=JSON.parse(JSON.stringify(o)),$=JSON.parse(JSON.stringify(d)),R={},D={};if(N){if(N.pathGuard&&l){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(f?f():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(s.CHANNELS.AUTHGUARD),i.on(s.CHANNELS.AUTHGUARD,(t=>{e(t)}))}D={...N},[s.CHANNELS.LOGIN,s.CHANNELS.LOGOUT,s.CHANNELS.REGISTER].map((e=>{N[e]&&(D[e]=function(t){return new Promise(((n,r)=>{i.emit(m+e,t,((e,t)=>{e?r(e):n(t)}))}))})}))}$.map((e=>{const t="string"==typeof e,n=t?e:e.name,r=async function(...e){return await(null==h?void 0:h({type:"method",command:n,data:{params:e}})),new Promise(((t,r)=>{i.emit(s.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?r(e):t(n)}))}))};R[n]=t?r:{...e,run:r}})),R=Object.freeze(R),T&&(k.sql=function(e,t,n){return new Promise(((r,o)=>{i.emit(s.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else{if("stream"===(null==n?void 0:n.returnType)){const{channel:e,unsubChannel:n}=t,s=t=>new Promise(((r,s)=>{i.on(e,t),i.emit(e,{},((t,o)=>{o?(s(o),i.removeAllListeners(e)):r({run:(t,n)=>new Promise(((r,s)=>{i.emit(e,{query:t,params:n},((e,t)=>{t?s(t):r(e)}))})),stop:e=>new Promise(((t,r)=>{i.emit(n,{terminate:e},((e,n)=>{n?r(n):t(e)}))}))})}))}));return r({channel:e,unsubChannel:n,start:s})}if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{y=y||{config:t,listeners:[]},y.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{y&&y.listeners&&y.listeners.length?y.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),y.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{y&&(y.listeners=y.listeners.filter((t=>t!==e)),!y.listeners.length&&y.config&&y.config.socketUnsubChannel&&i&&i.emit(y.config.socketUnsubChannel,{}))})(t)}),s={...e,addListener:n};r(s)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))r(t);else{const e=t,n=n=>(((e,t)=>{var n;O=O||{},O[t.notifChannel]?null===(n=O[t.notifChannel])||void 0===n||n.listeners.push(e):(O[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,r;(null===(n=O[t.notifChannel])||void 0===n?void 0:n.listeners.length)?O[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(r=O[t.notifChannel])||void 0===r?void 0:r.config.socketUnsubChannel,{})})))})(n,e),{...t,removeListener:()=>((e,t)=>{const n=O[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete O[t.notifChannel]))})(n,e)}),s={...t,addListener:n};r(s)}}}))}))});const A=(e,t,n,i)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.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"},J=["subscribe","subscribeOne"];(0,s.getKeys)(k).forEach((e=>{const t=Object.keys(k[e]),r=k[e];t.sort(((e,t)=>J.includes(e)-J.includes(t))).forEach((t=>{if("sync"===t){if(r._syncInfo={...r[t]},n){r.getSync=async(t,i={})=>(await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:h,filter:t,db:k,...i}));const t=async(t={},i={},r)=>{const s=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return v[s]||(v[s]=await n.create({...i,onDebug:h,name:e,filter:t,db:k,onError:r})),v[s]},i=async(n,i={handlesOnData:!0,select:"*"},r,s)=>{await(null==h?void 0:h({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.sync(r,i.handlesOnData)},s=async(n,i={handlesOnData:!0},r,s)=>{await(null==h?void 0:h({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.syncOne(n,r,i.handlesOnData)};r.sync=i,r.syncOne=s,r.useSync=(e,t)=>(0,a.useSync)(r.sync,e,t)}r._sync=async function(n,i,r){return await(null==h?void 0:h({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:r}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:i},r)}}else if(J.includes(t)){const n=async function(n={},i={},r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},r,s)};r[t]=n;const i="subscribeOne",s="subscribe"===t?"useSubscribe":"subscribeOne"===t?"useSubscribeOne":void 0;s&&(r[s]=(e,r)=>(0,a.useSubscribe)(n,t===i,e,r)),t!==i&&J.includes(i)||(r[i]=async function(n,i,r,s){return await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},(e=>{r(e[0])}),s)})}else{const n=async function(n,r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:r,param3:s}})),new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r,param3:s},((e,t)=>{e?a(e):o(t)}))}))};r[t]=n;const s="findOne"===t?"useFindOne":"find"===t?"useFind":"count"===t?"useCount":"size"===t?"useSize":void 0;s&&(r[s]=(e,t,i)=>(0,a.useFetch)(n,[e,t,i])),["find","findOne"].includes(t)&&(r.getJoinedTables=function(){return(x||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))})}}))})),b&&Object.keys(b).length&&Object.keys(b).map((async e=>{try{let t=b[e];await j(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),S&&Object.keys(S).length&&(0,s.getKeys)(S).filter((e=>{var t;return null===(t=S[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=S[e];await w(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),x.flat().map((e=>{k.innerJoin=k.innerJoin||{},k.leftJoin=k.leftJoin||{},k.innerJoinOne=k.innerJoinOne||{},k.leftJoinOne=k.leftJoinOne||{};const t=(0,s.getJoinHandlers)(e);k.leftJoin[e]=t.leftJoin,k.innerJoin[e]=t.innerJoin,k.leftJoinOne[e]=t.leftJoinOne,k.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await r(k,R,_,D,I)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}e(k)})()}))}))}t.debug=function(...e){l&&window[c]&&window[c](...e)},r(n(353),t),t.useProstglesClient=e=>{const t=(0,a.getReact)(!0),[n,i]=t.useState(),r=(0,a.useIsMounted)();return(0,a.useAsyncEffectQueue)((async()=>{await u({...e,onReady:(...t)=>{if(!r())return;e.onReady(...t);const[n,s,o,a,c]=t;i({dbo:n,methods:s,tableSchema:o,auth:a,isReconnect:c})}},o.SyncedTable)}),[e]),n},t.prostgles=u;class d{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),n=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=[],n=[];this.queue.forEach((async(e,i)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:i,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},353:(e,t,n)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=t.getReact=void 0;const r=n(792);let s;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=s||(s=n(294))}catch(e){}if(e&&!s)throw new Error("Must install react");return s},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(i=s)&&void 0!==i?i:{};function f(){const e=u(!0),t=l((()=>e.current),[]);return c((()=>()=>{e.current=!1}),[]),t}t.isEqual=function(e,n){if(e===n)return!0;if("object"==typeof e&&null!=e&&"object"==typeof n&&null!=n){if(Object.keys(e).length!=Object.keys(n).length)return!1;for(const i in e){if(!n.hasOwnProperty(i))return!1;if(!(0,t.isEqual)(e[i],n[i]))return!1}return!0}return!1},t.useDeepCompareMemoize=e=>{const n=u();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{c(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const i={effect:e,deps:n,didCleanup:!1},r=u({activeEffect:void 0,latestEffect:i});r.current.latestEffect=i;const s=async e=>{var t,n,i;if(e.current.latestEffect&&(!e.current.activeEffect||e.current.activeEffect.resolvedCleanup)){if(await(null===(i=null===(n=null===(t=e.current.activeEffect)||void 0===t?void 0:t.resolvedCleanup)||void 0===n?void 0:n.run)||void 0===i?void 0:i.call(n)),e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,!e.current.activeEffect)return;const r=await e.current.activeEffect.effect();if(!e.current.activeEffect)return void await(null==r?void 0:r());e.current.activeEffect.resolvedCleanup={run:r},e.current.activeEffect.didCleanup&&o()}},o=async()=>{var e,t,n;await(null===(n=null===(t=null===(e=r.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)||void 0===t?void 0:t.run)||void 0===n?void 0:n.call(t)),r.current.activeEffect=void 0,s(r)};(0,t.useEffectDeep)((()=>(s(r),()=>{var t,n;(null===(t=r.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(r.current.activeEffect.didCleanup=!0,o()),(null===(n=r.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(r.current.latestEffect=void 0)})),n)},t.useEffectAsync=(e,n)=>{const i=u({cleanup:void 0,effect:e,cleanupEffect:void 0});i.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(i.current.cleanup=t,i.current.cleanupEffect===e&&t())})),()=>{var t,n;i.current.cleanupEffect=e,null===(n=(t=i.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=f,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},s=e=>{try{return(0,r.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,c]=d(s(e)?{}:void 0),l=f();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(s(e))t=await o(e);else{const n=await e();t=s(n)?await o(n):i(n)?await n():n}l()&&c(t)}),n),a},t.useSubscribe=(e,n,i,r)=>{const s={data:void 0,error:void 0,isLoading:!0},[{data:o,error:a,isLoading:c},l]=d(s),u=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!u())return;l(s);const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(i,r,(e=>{u()&&l({data:n?e[0]:e,error:void 0,isLoading:!1})}),t)).unsubscribe}catch(e){t(e)}}),[e,i,r]),{data:o,error:a,isLoading:c}},t.useSync=(e,n,i)=>{const r={data:void 0,error:void 0,isLoading:!0},[{data:s,error:o,isLoading:a},c]=d(r),l=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!l())return;c(r);const t=e=>{l()&&c({data:void 0,error:e,isLoading:!1})};try{return(await e(n,i,(e=>{l()&&c({data:e,error:void 0,isLoading:!1})}),t)).$unsync()}catch(e){t(e)}}),[e,n,i]),{data:s,error:o,isLoading:a}},t.useFetch=(e,n=[])=>{const i={data:void 0,error:void 0,isLoading:!0},[{data:r,error:s,isLoading:o},a]=d(i),c=f();return(0,t.useAsyncEffectQueue)((async()=>{if(c()){a(i);try{const t=await e(...n);if(!c())return;a({data:t,error:void 0,isLoading:!1})}catch(e){if(!c())return;a({data:void 0,error:e,isLoading:!1})}}}),n),{data:r,error:s,isLoading:o}},t.__prglReactInstalled=()=>Boolean(s&&u)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 s={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(n(444),t),r(n(929),t),r(n(128),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:n,arrayOf:s,arrayOfType:o,description:a,nullable:c,oneOf:l,oneOfType:u,title:d,record:f,...h}="string"==typeof e?{type:e}:e;let p={};const m={...(h.enum||h.allowedValues?.length)&&{enum:h.allowedValues?.slice(0)??h.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(h.enum?.length&&(m.type=typeof h.enum[0]),"string"==typeof n||s||o){if(n&&"string"!=typeof n)throw"Not expected";p=s||o||n?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...h.allowedValues&&{enum:h.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?p={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:r(n[t])})),{})}:l||u?p={oneOf:(l||u.map((e=>({type:e})))).map((e=>r(e)))}:f&&(p={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:r(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?r(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};p.oneOf?p.oneOf.push(e):p.enum&&!p.enum.includes(null)?p.enum.push(null):p={oneOf:[p,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...p}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return r(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],c=e[2],l=e[3];n=r(n,i,c,l,t[0],7,-680876936),l=r(l,n,i,c,t[1],12,-389564586),c=r(c,l,n,i,t[2],17,606105819),i=r(i,c,l,n,t[3],22,-1044525330),n=r(n,i,c,l,t[4],7,-176418897),l=r(l,n,i,c,t[5],12,1200080426),c=r(c,l,n,i,t[6],17,-1473231341),i=r(i,c,l,n,t[7],22,-45705983),n=r(n,i,c,l,t[8],7,1770035416),l=r(l,n,i,c,t[9],12,-1958414417),c=r(c,l,n,i,t[10],17,-42063),i=r(i,c,l,n,t[11],22,-1990404162),n=r(n,i,c,l,t[12],7,1804603682),l=r(l,n,i,c,t[13],12,-40341101),c=r(c,l,n,i,t[14],17,-1502002290),n=s(n,i=r(i,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,i,c,t[6],9,-1069501632),c=s(c,l,n,i,t[11],14,643717713),i=s(i,c,l,n,t[0],20,-373897302),n=s(n,i,c,l,t[5],5,-701558691),l=s(l,n,i,c,t[10],9,38016083),c=s(c,l,n,i,t[15],14,-660478335),i=s(i,c,l,n,t[4],20,-405537848),n=s(n,i,c,l,t[9],5,568446438),l=s(l,n,i,c,t[14],9,-1019803690),c=s(c,l,n,i,t[3],14,-187363961),i=s(i,c,l,n,t[8],20,1163531501),n=s(n,i,c,l,t[13],5,-1444681467),l=s(l,n,i,c,t[2],9,-51403784),c=s(c,l,n,i,t[7],14,1735328473),n=o(n,i=s(i,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,i,c,t[8],11,-2022574463),c=o(c,l,n,i,t[11],16,1839030562),i=o(i,c,l,n,t[14],23,-35309556),n=o(n,i,c,l,t[1],4,-1530992060),l=o(l,n,i,c,t[4],11,1272893353),c=o(c,l,n,i,t[7],16,-155497632),i=o(i,c,l,n,t[10],23,-1094730640),n=o(n,i,c,l,t[13],4,681279174),l=o(l,n,i,c,t[0],11,-358537222),c=o(c,l,n,i,t[3],16,-722521979),i=o(i,c,l,n,t[6],23,76029189),n=o(n,i,c,l,t[9],4,-640364487),l=o(l,n,i,c,t[12],11,-421815835),c=o(c,l,n,i,t[15],16,530742520),n=a(n,i=o(i,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,i,c,t[7],10,1126891415),c=a(c,l,n,i,t[14],15,-1416354905),i=a(i,c,l,n,t[5],21,-57434055),n=a(n,i,c,l,t[12],6,1700485571),l=a(l,n,i,c,t[3],10,-1894986606),c=a(c,l,n,i,t[10],15,-1051523),i=a(i,c,l,n,t[1],21,-2054922799),n=a(n,i,c,l,t[8],6,1873313359),l=a(l,n,i,c,t[15],10,-30611744),c=a(c,l,n,i,t[6],15,-1560198380),i=a(i,c,l,n,t[13],21,1309151649),n=a(n,i,c,l,t[4],6,-145523070),l=a(l,n,i,c,t[11],10,-1120210379),c=a(c,l,n,i,t[2],15,718787259),i=a(i,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(i,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function i(e,t,n,i,r,s){return t=f(f(t,e),f(i,s)),f(t<<r|t>>>32-r,n)}function r(e,t,n,r,s,o,a){return i(t&n|~t&r,e,t,s,o,a)}function s(e,t,n,r,s,o,a){return i(t&r|n&~r,e,t,s,o,a)}function o(e,t,n,r,s,o,a){return i(t^n^r,e,t,s,o,a)}function a(e,t,n,r,s,o,a){return i(n^(t|~r),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.md5=t.md5cycle=void 0,t.md5cycle=n;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,i=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,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(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*i,n(r,s),r}(e))}function f(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function r(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.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let i={};return t.forEach((t=>{n&&void 0===e[t]||(i[t]=e[t])})),i}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},s={key:i,value:e[i]};return n(r,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(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(r&&r(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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,r=!1;for(;!r&&Math.abs(i)<=t.length;){const s=n<1?[i]:[0,i];e.slice(...s)!==t.slice(...s)?r=!0:i+=1*Math.sign(n)}return i}let r=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(r);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],s=+i-+r,o=i<r?-1:i==r?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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:r}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:i,delta:r}),this.changed[s].current={...this.changed[s].current,...i},this.changed[s].delta={...this.changed[s].delta,...r}})),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:r,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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],r=e.current[n];var s,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((s=i)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[n]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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}},t.isEmpty=o,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:n,...r(s,["path","select"]),select:i});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,n)=>{const i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const r=i[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var S=v.prototype=new b;S.constructor=v,m(S,g.prototype),S.isPureReactComponent=!0;var O=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,i){var r,s={},o=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,r)&&!j.hasOwnProperty(r)&&(s[r]=t[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:n,type:e,key:o,ref:a,props:s,_owner:w.current}}function N(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var C=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(e,t,r,s,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case i:c=!0}}if(c)return o=o(c=e),e=""===s?"."+T(c,0):s,O(o)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),x(o,t,r,"",(function(e){return e}))):null!=o&&(N(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(C,"$&/")+"/")+e)),t.push(o)),1;if(c=0,s=""===s?".":s+":",O(e))for(var l=0;l<e.length;l++){var u=s+T(a=e[l],l);c+=x(a,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=x(a=a.value,t,r,u=s+T(a,l++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var i=[],r=0;return x(e,i,"","",(function(e){return t.call(n,e,r++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},R={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=r,t.Profiler=o,t.PureComponent=v,t.StrictMode=s,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=R,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m({},e.props),s=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!j.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:n,type:e.type,key:s,ref:o,props:r,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=N,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}var i={};return(()=>{"use strict";var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.prostgles=void 0;const t=n(274),r=n(133);e.prostgles=function(e){return(0,t.prostgles)(e,r.SyncedTable)}})(),i})()));
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.no-sync.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>{return e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),r="DEBUG_SYNCEDTABLE",s="undefined"!=typeof window;t.debug=function(...e){s&&window[r]&&window[r](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:a,onDebug:u,db:d,skipFirstTrigger:f=!1,select:h="*",storageType:p="object",patchText:m=!1,patchJSON:y=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map((e=>e.current)),s=[],o=[];if(this.columns&&this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter((e=>"text"===e.data_type));if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map((async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map((e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,i.getTextPatch)(l[e.name],c[e.name]))})),u&&this.wal&&(o.push(u),s.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)})))}}if(s.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(s))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter((e=>e))},this._notifySubscribers=(e=[])=>{if(!this.isSynced)return;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:r,delta:s})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,s)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(s),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((r=>{e.push({...r});const s=t.findIndex((e=>this.matchesIdObj(r,e)));i.push(n[s])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}}))}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter((t=>t._onChange!==e)),this.multiSubscriptions=this.multiSubscriptions.filter((t=>t._onChange!==e)),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&this.columns.length){const t=Object.keys({...e}).filter((e=>!this.columns.find((t=>t.name===e))));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";let s,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var r;let l={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(l),f=d.index,h=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(h)||(u=this.getDelta(h||{},u)),t||(u[this.synced_field]=Date.now());let p={...h,...u,...l};h&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(p=c({...h,...l},{...u})),s=h?h[this.synced_field]<p[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(p,f);let m={idObj:l,delta:u,oldItem:h,newItem:p,status:s,from_server:t};return t||a.push({initial:h,current:{...p}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=l(e);if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter((e=>!this.filter||!(0,i.getKeys)(this.filter).find((t=>e[t]!==this.filter[t])))).sort(((e,n)=>t.map((t=>e[t]<n[t]?-1:e[t]>n[t]?1:0)).find((e=>e))))}return l(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={offset:0,limit:void 0})=>{let r=this.getItems().map((e=>({...e}))).filter((n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t)));return(n||i)&&(r=r.splice(null!=n?n:0,i||r.length)),r},this.name=e,this.filter=n,this.select=h,this.onChange=r,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[p])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(s||p!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),p="object"),this.storageType=p,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:S=100,batch_size:O=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=O,this.throttle=S,this.skipFirstTrigger=f,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:S};d[this.name]._sync(n,{select:h},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;let t=this.getItems().map((e=>({...e})));this.setItems([]);const n=t.map((e=>({idObj:this.getIdObj(e),delta:{...e}})));await this.upsert(n,!0)}else if("data"in e){let t=e.data.map((e=>({idObj:this.getIdObj(e),delta:e})));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then((e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new i.WAL({..._,batch_size:O,onSendStart:()=>{s&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{s&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map((e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}})))}}),a()})),d[this.name].getColumns&&d[this.name].getColumns().then((e=>{this.columns=e})),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise(((t,n)=>{try{const n=new a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let r=[...n],s=[...i];return t&&(r=r.map(((n,i)=>{const r=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>r(this.getItem(i).data,i),$find:e=>r(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),s=this.getIdObj(n);return r(n,s)}))),e(r,s)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,r)=>{let s={...e};return n&&(s.$get=i.$get,s.$find=i.$find,s.$update=i.$update,s.$delete=i.$delete,s.$unsync=i.$unsync,s.$cloneSync=i.$cloneSync),t(s,r)}};return this.singleSubscriptions.push(r),setTimeout((()=>{let e=i.$get();e&&r.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.isEmpty)(this.filter)||!Object.keys(this.filter).find((t=>this.filter[t]!==e[t]))))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find((n=>e[n]!==t[n])))}getDelta(e,t){return(0,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let r={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(r=n):r=n}return{...n,...r}}),{})}deleteAll(){this.getItems().map((e=>this.delete(e)))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let t;return this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:l(t),index:-1}}setItem(e,t,n=!1,i=!1){const r=l(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),s&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(r)];else{let e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function c(e,t){const n=e?l(e):e,r=t?l(t):t;let s=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(r)&&Object.keys(r).forEach((e=>{(0,i.isObject)(r[e])?e in n?s[e]=c(n[e],r[e]):Object.assign(s,{[e]:r[e]}):Object.assign(s,{[e]:r[e]})})),s}function l(e){if(s&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>l(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=l(e[n])})),t}return e}t.SyncedTable=a,t.default=c,t.quickClone=l},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.useProstglesClient=t.asName=t.debug=void 0;const s=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(133),a=n(353),c="DEBUG_SYNCEDTABLE",l="undefined"!=typeof window;function u(e,n){const{socket:i,onReady:r,onDisconnect:o,onReconnect:c,onSchemaChange:u=!0,onReload:f,onDebug:h}=e;let p;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),e&&i.on(s.CHANNELS.SCHEMA_CHANGED,e)}const m=s.CHANNELS._preffix;let y,g,b={},v={},S={},O={};function _(e,n,r){return(0,t.debug)("_unsubscribe",{channelName:e,handler:r}),new Promise(((t,s)=>{const o=b[e];o?(o.handlers=o.handlers.filter((e=>e!==r)),o.handlers.length||(i.emit(n,{},((e,t)=>{e?console.error(e):s(e)})),i.removeListener(e,o.onCall),delete b[e]),t(!0)):t(!0)}))}function w({tableName:e,command:t,param1:n,param2:r},s){return new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:r}=t;i.emit(r,{onSyncRequest:s({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:r})}}))}))}function j({tableName:e,command:t,param1:n,param2:r}){return new Promise(((s,o)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{e?(console.error(e),o(e)):t&&s(t)}))}))}const E=new d((async function({tableName:e,command:n,param1:r,param2:s},o){const{onSyncRequest:a}=o;function c(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,r)=>{S[e]&&(S[e].triggers=S[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),S[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?r(e):t(n)})),i.removeListener(e,S[e].onCall),delete S[e]))}))}(e,o)},syncData:function(t,n,r){i.emit(e,{onSyncRequest:{...a({}),...{data:t}||{},...{deleted:n}||{}}},r?e=>{r(e)}:null)}})}const l=Object.keys(S).find((t=>{let i=S[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l)return S[l].triggers.push(o),c(l);{const u=await w({tableName:e,command:n,param1:r,param2:s},a),{channelName:d,synced_field:f,id_fields:h}=u;function p(t,n){t&&S[d]&&S[d].triggers.map((({onUpdates:i,onSyncRequest:r,onPullRequest:s})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(r(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(s(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return S[d]={tableName:e,command:n,param1:r,param2:s,triggers:[o],syncInfo:u,onCall:p},i.on(d,p),c(d)}}),(([{tableName:e}])=>e)),N=new d((async function(e,{tableName:t,command:n,param1:r,param2:s},o,a){function c(n,i){let s={unsubscribe:function(){return _(n,i,o)},filter:{...r}};return e[t].update&&(s={...s,update:function(n,i){return e[t].update(r,n,i)}}),e[t].delete&&(s={...s,delete:function(n){return e[t].delete(r,n)}}),Object.freeze(s)}const l=Object.entries(b).find((([e])=>{let i=b[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l){const e=l[0];return l[1].handlers.push(o),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==b?void 0:b[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==b?void 0:b[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:f}=await j({tableName:t,command:n,param1:r,param2:s}),h=function(e,t){const n=b[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},p=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,h),b[u]={lastData:void 0,tableName:t,command:n,param1:r,param2:s,onCall:h,unsubChannel:f,handlers:[o],errorHandlers:[p],destroy:async()=>{var e,t;for await(const n of null!==(t=null===(e=b[u])||void 0===e?void 0:e.handlers)&&void 0!==t?t:[])await _(u,f,n)}},i.emit(d,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function C(e,t,n,i){return N.run([e,t,n,i])}return new Promise(((e,u)=>{i.removeAllListeners(s.CHANNELS.CONNECTION),i.on(s.CHANNELS.CONNECTION,(e=>(u(e),"ok"))),o&&i.on("disconnect",(()=>{g="disconnected",o()})),c&&i.on("connect",(()=>{"disconnected"===g&&(g="reconnected")})),i.on(s.CHANNELS.SCHEMA,(async({schema:o,methods:d,tableSchema:_,auth:N,rawSQL:T,joinTables:x=[],err:P})=>{if(await(async()=>{(0,t.debug)("destroySyncs",{subscriptions:b,syncedTables:v}),await Promise.all(Object.values(b).map((e=>e.destroy()))),S={},Object.values(v).map((e=>{e&&e.destroy&&e.destroy()})),v={}})(),"connected"!==g&&"reconnected"!==g||!c)p={origin:"onReady",date:new Date};else{if(c(i,P),P)return void console.error(P);p={origin:"onReconnect",date:new Date}}if(P)throw u(P),P;const I="reconnected"===g;g="connected";let k=JSON.parse(JSON.stringify(o)),$=JSON.parse(JSON.stringify(d)),R={},D={};if(N){if(N.pathGuard&&l){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(f?f():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(s.CHANNELS.AUTHGUARD),i.on(s.CHANNELS.AUTHGUARD,(t=>{e(t)}))}D={...N},[s.CHANNELS.LOGIN,s.CHANNELS.LOGOUT,s.CHANNELS.REGISTER].map((e=>{N[e]&&(D[e]=function(t){return new Promise(((n,r)=>{i.emit(m+e,t,((e,t)=>{e?r(e):n(t)}))}))})}))}$.map((e=>{const t="string"==typeof e,n=t?e:e.name,r=async function(...e){return await(null==h?void 0:h({type:"method",command:n,data:{params:e}})),new Promise(((t,r)=>{i.emit(s.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?r(e):t(n)}))}))};R[n]=t?r:{...e,run:r}})),R=Object.freeze(R),T&&(k.sql=function(e,t,n){return new Promise(((r,o)=>{i.emit(s.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else{if("stream"===(null==n?void 0:n.returnType)){const{channel:e,unsubChannel:n}=t,s=t=>new Promise(((r,s)=>{i.on(e,t),i.emit(e,{},((t,o)=>{o?(s(o),i.removeAllListeners(e)):r({run:(t,n)=>new Promise(((r,s)=>{i.emit(e,{query:t,params:n},((e,t)=>{t?s(t):r(e)}))})),stop:e=>new Promise(((t,r)=>{i.emit(n,{terminate:e},((e,n)=>{n?r(n):t(e)}))}))})}))}));return r({channel:e,unsubChannel:n,start:s})}if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{y=y||{config:t,listeners:[]},y.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{y&&y.listeners&&y.listeners.length?y.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),y.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{y&&(y.listeners=y.listeners.filter((t=>t!==e)),!y.listeners.length&&y.config&&y.config.socketUnsubChannel&&i&&i.emit(y.config.socketUnsubChannel,{}))})(t)}),s={...e,addListener:n};r(s)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))r(t);else{const e=t,n=n=>(((e,t)=>{var n;O=O||{},O[t.notifChannel]?null===(n=O[t.notifChannel])||void 0===n||n.listeners.push(e):(O[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,r;(null===(n=O[t.notifChannel])||void 0===n?void 0:n.listeners.length)?O[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(r=O[t.notifChannel])||void 0===r?void 0:r.config.socketUnsubChannel,{})})))})(n,e),{...t,removeListener:()=>((e,t)=>{const n=O[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete O[t.notifChannel]))})(n,e)}),s={...t,addListener:n};r(s)}}}))}))});const A=(e,t,n,i)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.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"},J=["subscribe","subscribeOne"];(0,s.getKeys)(k).forEach((e=>{const t=Object.keys(k[e]),r=k[e];t.sort(((e,t)=>J.includes(e)-J.includes(t))).forEach((t=>{if("sync"===t){if(r._syncInfo={...r[t]},n){r.getSync=async(t,i={})=>(await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:h,filter:t,db:k,...i}));const t=async(t={},i={},r)=>{const s=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return v[s]||(v[s]=await n.create({...i,onDebug:h,name:e,filter:t,db:k,onError:r})),v[s]},i=async(n,i={handlesOnData:!0,select:"*"},r,s)=>{await(null==h?void 0:h({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.sync(r,i.handlesOnData)},s=async(n,i={handlesOnData:!0},r,s)=>{await(null==h?void 0:h({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.syncOne(n,r,i.handlesOnData)};r.sync=i,r.syncOne=s,r.useSync=(e,t)=>(0,a.useSync)(r.sync,e,t)}r._sync=async function(n,i,r){return await(null==h?void 0:h({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:r}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:i},r)}}else if(J.includes(t)){const n=async function(n={},i={},r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},r,s)};r[t]=n;const i="subscribeOne",s=function(e={},r={},s){return{start:o=>n(e,r,t!==i?o:e=>{o(e[0])},s),args:[e,r,s]}},o="subscribe"===t?"useSubscribe":"subscribeOne"===t?"useSubscribeOne":void 0;o&&(r[o]=(...e)=>(0,a.useSubscribe)(s(...e)),r[o+"V2"]=(e,r)=>(0,a.useSubscribeV2)(n,t===i,e,r)),t!==i&&J.includes(i)||(r[i]=async function(n,i,r,s){return await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},(e=>{r(e[0])}),s)})}else{const n=async function(n,r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:r,param3:s}})),new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r,param3:s},((e,t)=>{e?a(e):o(t)}))}))};r[t]=n;const s="findOne"===t?"useFindOne":"find"===t?"useFind":"count"===t?"useCount":"size"===t?"useSize":void 0;s&&(r[s]=(e,t,i)=>(0,a.usePromise)((()=>n(e,t,i)),[e,t,i]),r[s+"V2"]=(e,t,i)=>(0,a.useFetch)(n,[e,t,i])),["find","findOne"].includes(t)&&(r.getJoinedTables=function(){return(x||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))})}}))})),b&&Object.keys(b).length&&Object.keys(b).map((async e=>{try{let t=b[e];await j(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),S&&Object.keys(S).length&&(0,s.getKeys)(S).filter((e=>{var t;return null===(t=S[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=S[e];await w(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),x.flat().map((e=>{k.innerJoin=k.innerJoin||{},k.leftJoin=k.leftJoin||{},k.innerJoinOne=k.innerJoinOne||{},k.leftJoinOne=k.leftJoinOne||{};const t=(0,s.getJoinHandlers)(e);k.leftJoin[e]=t.leftJoin,k.innerJoin[e]=t.innerJoin,k.leftJoinOne[e]=t.leftJoinOne,k.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await r(k,R,_,D,I)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}e(k)})()}))}))}t.debug=function(...e){l&&window[c]&&window[c](...e)},r(n(353),t),t.useProstglesClient=e=>{const t=(0,a.getReact)(!0),[n,i]=t.useState(),r=(0,a.useIsMounted)();return(0,a.useAsyncEffectQueue)((async()=>{await u({...e,onReady:(...t)=>{if(!r())return;e.onReady(...t);const[n,s,o,a,c]=t;i({dbo:n,methods:s,tableSchema:o,auth:a,isReconnect:c})}},o.SyncedTable)}),[e]),n},t.prostgles=u;class d{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),n=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=[],n=[];this.queue.forEach((async(e,i)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:i,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},353:(e,t,n)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribeV2=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=t.getReact=void 0;const r=n(792);let s;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=s||(s=n(294))}catch(e){}if(e&&!s)throw new Error("Must install react");return s},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(i=s)&&void 0!==i?i:{};function f(){const e=u(!0),t=l((()=>e.current),[]);return c((()=>()=>{e.current=!1}),[]),t}t.isEqual=function(e,n){if(e===n)return!0;if("object"==typeof e&&null!=e&&"object"==typeof n&&null!=n){if(Object.keys(e).length!=Object.keys(n).length)return!1;for(const i in e){if(!n.hasOwnProperty(i))return!1;if(!(0,t.isEqual)(e[i],n[i]))return!1}return!0}return!1},t.useDeepCompareMemoize=e=>{const n=u();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{c(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const i={effect:e,deps:n,didCleanup:!1},r=u({activeEffect:void 0,latestEffect:i});r.current.latestEffect=i;const s=async e=>{var t,n,i;if(e.current.latestEffect&&(!e.current.activeEffect||e.current.activeEffect.resolvedCleanup)){if(await(null===(i=null===(n=null===(t=e.current.activeEffect)||void 0===t?void 0:t.resolvedCleanup)||void 0===n?void 0:n.run)||void 0===i?void 0:i.call(n)),e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,!e.current.activeEffect)return;const r=await e.current.activeEffect.effect();if(!e.current.activeEffect)return void await(null==r?void 0:r());e.current.activeEffect.resolvedCleanup={run:r},e.current.activeEffect.didCleanup&&o()}},o=async()=>{var e,t,n;await(null===(n=null===(t=null===(e=r.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)||void 0===t?void 0:t.run)||void 0===n?void 0:n.call(t)),r.current.activeEffect=void 0,s(r)};(0,t.useEffectDeep)((()=>(s(r),()=>{var t,n;(null===(t=r.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(r.current.activeEffect.didCleanup=!0,o()),(null===(n=r.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(r.current.latestEffect=void 0)})),n)},t.useEffectAsync=(e,n)=>{const i=u({cleanup:void 0,effect:e,cleanupEffect:void 0});i.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(i.current.cleanup=t,i.current.cleanupEffect===e&&t())})),()=>{var t,n;i.current.cleanupEffect=e,null===(n=(t=i.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=f,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},s=e=>{try{return(0,r.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,c]=d(s(e)?{}:void 0),l=f();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(s(e))t=await o(e);else{const n=await e();t=s(n)?await o(n):i(n)?await n():n}l()&&c(t)}),n),a},t.useSubscribe=e=>{const[n,i]=d(),r=f();return(0,t.useAsyncEffectQueue)((async()=>(await e.start((e=>{r()&&i(e)}))).unsubscribe),e.args),n},t.useSubscribeV2=(e,n,i,r)=>{const s={data:void 0,error:void 0,isLoading:!0},[{data:o,error:a,isLoading:c},l]=d(s),u=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!u())return;l(s);const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(i,r,(e=>{u()&&l({data:n?e[0]:e,error:void 0,isLoading:!1})}),t)).unsubscribe}catch(e){t(e)}}),[e,i,r]),{data:o,error:a,isLoading:c}},t.useSync=(e,n,i)=>{const r={data:void 0,error:void 0,isLoading:!0},[{data:s,error:o,isLoading:a},c]=d(r),l=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!l())return;c(r);const t=e=>{l()&&c({data:void 0,error:e,isLoading:!1})};try{return(await e(n,i,(e=>{l()&&c({data:e,error:void 0,isLoading:!1})}),t)).$unsync()}catch(e){t(e)}}),[e,n,i]),{data:s,error:o,isLoading:a}},t.useFetch=(e,n=[])=>{const i={data:void 0,error:void 0,isLoading:!0},[{data:r,error:s,isLoading:o},a]=d(i),c=f();return(0,t.useAsyncEffectQueue)((async()=>{if(c()){a(i);try{const t=await e(...n);if(!c())return;a({data:t,error:void 0,isLoading:!1})}catch(e){if(!c())return;a({data:void 0,error:e,isLoading:!1})}}}),n),{data:r,error:s,isLoading:o}},t.__prglReactInstalled=()=>Boolean(s&&u)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 s={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(n(444),t),r(n(929),t),r(n(128),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:n,arrayOf:s,arrayOfType:o,description:a,nullable:c,oneOf:l,oneOfType:u,title:d,record:f,...h}="string"==typeof e?{type:e}:e;let p={};const m={...(h.enum||h.allowedValues?.length)&&{enum:h.allowedValues?.slice(0)??h.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(h.enum?.length&&(m.type=typeof h.enum[0]),"string"==typeof n||s||o){if(n&&"string"!=typeof n)throw"Not expected";p=s||o||n?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...h.allowedValues&&{enum:h.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?p={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:r(n[t])})),{})}:l||u?p={oneOf:(l||u.map((e=>({type:e})))).map((e=>r(e)))}:f&&(p={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:r(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?r(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};p.oneOf?p.oneOf.push(e):p.enum&&!p.enum.includes(null)?p.enum.push(null):p={oneOf:[p,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...p}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return r(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],c=e[2],l=e[3];n=r(n,i,c,l,t[0],7,-680876936),l=r(l,n,i,c,t[1],12,-389564586),c=r(c,l,n,i,t[2],17,606105819),i=r(i,c,l,n,t[3],22,-1044525330),n=r(n,i,c,l,t[4],7,-176418897),l=r(l,n,i,c,t[5],12,1200080426),c=r(c,l,n,i,t[6],17,-1473231341),i=r(i,c,l,n,t[7],22,-45705983),n=r(n,i,c,l,t[8],7,1770035416),l=r(l,n,i,c,t[9],12,-1958414417),c=r(c,l,n,i,t[10],17,-42063),i=r(i,c,l,n,t[11],22,-1990404162),n=r(n,i,c,l,t[12],7,1804603682),l=r(l,n,i,c,t[13],12,-40341101),c=r(c,l,n,i,t[14],17,-1502002290),n=s(n,i=r(i,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,i,c,t[6],9,-1069501632),c=s(c,l,n,i,t[11],14,643717713),i=s(i,c,l,n,t[0],20,-373897302),n=s(n,i,c,l,t[5],5,-701558691),l=s(l,n,i,c,t[10],9,38016083),c=s(c,l,n,i,t[15],14,-660478335),i=s(i,c,l,n,t[4],20,-405537848),n=s(n,i,c,l,t[9],5,568446438),l=s(l,n,i,c,t[14],9,-1019803690),c=s(c,l,n,i,t[3],14,-187363961),i=s(i,c,l,n,t[8],20,1163531501),n=s(n,i,c,l,t[13],5,-1444681467),l=s(l,n,i,c,t[2],9,-51403784),c=s(c,l,n,i,t[7],14,1735328473),n=o(n,i=s(i,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,i,c,t[8],11,-2022574463),c=o(c,l,n,i,t[11],16,1839030562),i=o(i,c,l,n,t[14],23,-35309556),n=o(n,i,c,l,t[1],4,-1530992060),l=o(l,n,i,c,t[4],11,1272893353),c=o(c,l,n,i,t[7],16,-155497632),i=o(i,c,l,n,t[10],23,-1094730640),n=o(n,i,c,l,t[13],4,681279174),l=o(l,n,i,c,t[0],11,-358537222),c=o(c,l,n,i,t[3],16,-722521979),i=o(i,c,l,n,t[6],23,76029189),n=o(n,i,c,l,t[9],4,-640364487),l=o(l,n,i,c,t[12],11,-421815835),c=o(c,l,n,i,t[15],16,530742520),n=a(n,i=o(i,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,i,c,t[7],10,1126891415),c=a(c,l,n,i,t[14],15,-1416354905),i=a(i,c,l,n,t[5],21,-57434055),n=a(n,i,c,l,t[12],6,1700485571),l=a(l,n,i,c,t[3],10,-1894986606),c=a(c,l,n,i,t[10],15,-1051523),i=a(i,c,l,n,t[1],21,-2054922799),n=a(n,i,c,l,t[8],6,1873313359),l=a(l,n,i,c,t[15],10,-30611744),c=a(c,l,n,i,t[6],15,-1560198380),i=a(i,c,l,n,t[13],21,1309151649),n=a(n,i,c,l,t[4],6,-145523070),l=a(l,n,i,c,t[11],10,-1120210379),c=a(c,l,n,i,t[2],15,718787259),i=a(i,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(i,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function i(e,t,n,i,r,s){return t=f(f(t,e),f(i,s)),f(t<<r|t>>>32-r,n)}function r(e,t,n,r,s,o,a){return i(t&n|~t&r,e,t,s,o,a)}function s(e,t,n,r,s,o,a){return i(t&r|n&~r,e,t,s,o,a)}function o(e,t,n,r,s,o,a){return i(t^n^r,e,t,s,o,a)}function a(e,t,n,r,s,o,a){return i(n^(t|~r),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.md5=t.md5cycle=void 0,t.md5cycle=n;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,i=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,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(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*i,n(r,s),r}(e))}function f(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function r(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.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let i={};return t.forEach((t=>{n&&void 0===e[t]||(i[t]=e[t])})),i}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},s={key:i,value:e[i]};return n(r,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(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(r&&r(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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,r=!1;for(;!r&&Math.abs(i)<=t.length;){const s=n<1?[i]:[0,i];e.slice(...s)!==t.slice(...s)?r=!0:i+=1*Math.sign(n)}return i}let r=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(r);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],s=+i-+r,o=i<r?-1:i==r?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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:r}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:i,delta:r}),this.changed[s].current={...this.changed[s].current,...i},this.changed[s].delta={...this.changed[s].delta,...r}})),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:r,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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],r=e.current[n];var s,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((s=i)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[n]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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}},t.isEmpty=o,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:n,...r(s,["path","select"]),select:i});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,n)=>{const i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const r=i[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var S=v.prototype=new b;S.constructor=v,m(S,g.prototype),S.isPureReactComponent=!0;var O=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,i){var r,s={},o=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,r)&&!j.hasOwnProperty(r)&&(s[r]=t[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:n,type:e,key:o,ref:a,props:s,_owner:w.current}}function N(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var C=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(e,t,r,s,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case i:c=!0}}if(c)return o=o(c=e),e=""===s?"."+T(c,0):s,O(o)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),x(o,t,r,"",(function(e){return e}))):null!=o&&(N(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(C,"$&/")+"/")+e)),t.push(o)),1;if(c=0,s=""===s?".":s+":",O(e))for(var l=0;l<e.length;l++){var u=s+T(a=e[l],l);c+=x(a,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=x(a=a.value,t,r,u=s+T(a,l++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var i=[],r=0;return x(e,i,"","",(function(e){return t.call(n,e,r++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},R={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=r,t.Profiler=o,t.PureComponent=v,t.StrictMode=s,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=R,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m({},e.props),s=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!j.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:n,type:e.type,key:s,ref:o,props:r,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=N,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={},function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(274);var e,t}));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this||window,(()=>{return e={133:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quickClone=t.SyncedTable=t.debug=void 0;const i=n(792),r="DEBUG_SYNCEDTABLE",s="undefined"!=typeof window;t.debug=function(...e){s&&window[r]&&window[r](...e)};const o={array:"array",localStorage:"localStorage",object:"object"};class a{set multiSubscriptions(e){(0,t.debug)(e,this._multiSubscriptions),this._multiSubscriptions=e.slice(0)}get multiSubscriptions(){return this._multiSubscriptions}set singleSubscriptions(e){(0,t.debug)(e,this._singleSubscriptions),this._singleSubscriptions=e.slice(0)}get singleSubscriptions(){return this._singleSubscriptions}constructor({name:e,filter:n,onChange:r,onReady:a,onDebug:u,db:d,skipFirstTrigger:f=!1,select:h="*",storageType:p="object",patchText:m=!1,patchJSON:y=!1,onError:g}){if(this.throttle=100,this.batch_size=50,this.skipFirstTrigger=!1,this.columns=[],this._multiSubscriptions=[],this._singleSubscriptions=[],this.items=[],this.itemsObj={},this.isSynced=!1,this.updatePatches=async e=>{var t,n;let r=e.map((e=>e.current)),s=[],o=[];if(this.columns&&this.columns.length&&(null===(t=this.tableHandler)||void 0===t?void 0:t.updateBatch)&&(this.patchText||this.patchJSON)){const t=this.columns.filter((e=>"text"===e.data_type));if(this.patchText&&t.length){r=[];const n=[this.synced_field,...this.id_fields];await Promise.all(e.slice(0).map((async(e,a)=>{const{current:c,initial:l}={...e};let u;l&&(t.map((e=>{!n.includes(e.name)&&e.name in c&&(null!=u||(u={...c}),u[e.name]=(0,i.getTextPatch)(l[e.name],c[e.name]))})),u&&this.wal&&(o.push(u),s.push([this.wal.getIdObj(u),this.wal.getDeltaObj(u)]))),u||r.push(c)})))}}if(s.length)try{await(null===(n=this.tableHandler)||void 0===n?void 0:n.updateBatch(s))}catch(e){console.log("failed to patch update",e),r=r.concat(o)}return r.filter((e=>e))},this._notifySubscribers=(e=[])=>{if(!this.isSynced)return;let t=[],n=[],i=[];if(e.map((({idObj:e,newItem:r,delta:s})=>{this.singleSubscriptions.filter((t=>this.matchesIdObj(t.idObj,e))).map((async e=>{try{await e.notify(r,s)}catch(e){console.error("SyncedTable failed to notify: ",e)}})),this.matchesFilter(r)&&(t.push(r),n.push(s),i.push(e))})),this.onChange||this.multiSubscriptions.length){let e=[],i=[];if(this.getItems().map((r=>{e.push({...r});const s=t.findIndex((e=>this.matchesIdObj(r,e)));i.push(n[s])})),this.onChange)try{this.onChange(e,i)}catch(e){console.error("SyncedTable failed to notify onChange: ",e)}this.multiSubscriptions.map((async t=>{try{await t.notify(e,i)}catch(e){console.error("SyncedTable failed to notify: ",e)}}))}},this.unsubscribe=e=>(this.singleSubscriptions=this.singleSubscriptions.filter((t=>t._onChange!==e)),this.multiSubscriptions=this.multiSubscriptions.filter((t=>t._onChange!==e)),(0,t.debug)("unsubscribe",this),"ok"),this.unsync=()=>{this.dbSync&&this.dbSync.unsync&&this.dbSync.unsync()},this.destroy=()=>{this.unsync(),this.multiSubscriptions=[],this.singleSubscriptions=[],this.itemsObj={},this.items=[],this.onChange=void 0},this.delete=async(e,t=!1)=>{var n;const i=this.getIdObj(e);return this.setItem(i,void 0,!0,!0),!t&&(null===(n=this.tableHandler)||void 0===n?void 0:n.delete)&&await this.tableHandler.delete(i),this._notifySubscribers(),!0},this.checkItemCols=e=>{if(this.columns&&this.columns.length){const t=Object.keys({...e}).filter((e=>!this.columns.find((t=>t.name===e))));if(t.length)throw"Unexpected columns in sync item update: "+t.join(", ")}},this.upsert=async(e,t=!1)=>{var n,r;if(!(e&&e.length||t))throw"No data provided for upsert";let s,o=[],a=[];await Promise.all(e.map((async(e,n)=>{var r;let l={...e.idObj},u={...e.delta};Object.keys(u).map((e=>{void 0===u[e]&&(u[e]=null)})),t||this.checkItemCols({...e.delta,...e.idObj});let d=this.getItem(l),f=d.index,h=d.data;!t&&!(0,i.isEmpty)(u)||(0,i.isEmpty)(h)||(u=this.getDelta(h||{},u)),t||(u[this.synced_field]=Date.now());let p={...h,...u,...l};h&&!t&&(null===(r=e.opts)||void 0===r?void 0:r.deepMerge)&&(p=c({...h,...l},{...u})),s=h?h[this.synced_field]<p[this.synced_field]?"updated":"unchanged":"inserted",this.setItem(p,f);let m={idObj:l,delta:u,oldItem:h,newItem:p,status:s,from_server:t};return t||a.push({initial:h,current:{...p}}),m.delta&&!(0,i.isEmpty)(m.delta)&&o.push(m),!0}))).catch((e=>{console.error("SyncedTable failed upsert: ",e)})),null===(n=this.notifyWal)||void 0===n||n.addData(o.map((e=>({initial:e.oldItem,current:e.newItem})))),!t&&a.length&&(null===(r=this.wal)||void 0===r||r.addData(a))},this.setItems=e=>{const t=l(e);if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";window.localStorage.setItem(this.name,JSON.stringify(t))}else this.storageType===o.array?this.items=t:this.itemsObj=t.reduce(((e,t)=>({...e,[this.getIdStr(t)]:{...t}})),{})},this.getItems=()=>{let e=[];if(this.storageType===o.localStorage){if(!s)throw"Cannot access window object. Choose another storage method (array OR object)";let t=window.localStorage.getItem(this.name);if(t)try{e=JSON.parse(t)}catch(e){console.error(e)}}else e=this.storageType===o.array?this.items.map((e=>({...e}))):Object.values({...this.itemsObj});if(!this.id_fields||!this.synced_field)throw"id_fields AND/OR synced_field missing";{const t=[this.synced_field,...this.id_fields.sort()];e=e.filter((e=>!this.filter||!(0,i.getKeys)(this.filter).find((t=>e[t]!==this.filter[t])))).sort(((e,n)=>t.map((t=>e[t]<n[t]?-1:e[t]>n[t]?1:0)).find((e=>e))))}return l(e)},this.getBatch=({from_synced:e,to_synced:t,offset:n,limit:i}={offset:0,limit:void 0})=>{let r=this.getItems().map((e=>({...e}))).filter((n=>(!Number.isFinite(e)||+n[this.synced_field]>=+e)&&(!Number.isFinite(t)||+n[this.synced_field]<=+t)));return(n||i)&&(r=r.splice(null!=n?n:0,i||r.length)),r},this.name=e,this.filter=n,this.select=h,this.onChange=r,u&&(this.onDebug=t=>u({...t,type:"sync",tableName:e},this)),!o[p])throw"Invalid storage type. Expecting one of: "+Object.keys(o).join(", ");if(s||p!==o.localStorage||(console.warn("Could not set storageType to localStorage: window object missing\nStorage changed to object"),p="object"),this.storageType=p,this.patchText=m,this.patchJSON=y,!d)throw"db missing";this.db=d;const{id_fields:b,synced_field:v,throttle:S=100,batch_size:O=50}=d[this.name]._syncInfo;if(!b||!v)throw"id_fields/synced_field missing";this.id_fields=b,this.synced_field=v,this.batch_size=O,this.throttle=S,this.skipFirstTrigger=f,this.multiSubscriptions=[],this.singleSubscriptions=[],this.onError=g||function(e){console.error("Sync internal error: ",e)};const _={id_fields:b,synced_field:v,throttle:S};d[this.name]._sync(n,{select:h},{onSyncRequest:e=>{var t;let n={c_lr:void 0,c_fr:void 0,c_count:0},i=this.getBatch(e);return i.length&&(n={c_fr:this.getRowSyncObj(i[0]),c_lr:this.getRowSyncObj(i[i.length-1]),c_count:i.length}),null===(t=this.onDebug)||void 0===t||t.call(this,{command:"onUpdates",data:{syncBatchParams:e,batch:i,clientSyncInfo:n}}),n},onPullRequest:async e=>{var t;const n=this.getBatch(e);return await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onPullRequest",data:{syncBatchParams:e,data:n}})),n},onUpdates:async e=>{var t,n;if(await(null===(t=this.onDebug)||void 0===t?void 0:t.call(this,{command:"onUpdates",data:{onUpdatesParams:e}})),"err"in e&&e.err)null===(n=this.onError)||void 0===n||n.call(this,e.err);else if("isSynced"in e&&e.isSynced&&!this.isSynced){this.isSynced=e.isSynced;let t=this.getItems().map((e=>({...e})));this.setItems([]);const n=t.map((e=>({idObj:this.getIdObj(e),delta:{...e}})));await this.upsert(n,!0)}else if("data"in e){let t=e.data.map((e=>({idObj:this.getIdObj(e),delta:e})));await this.upsert(t,!0)}else console.error("Unexpected onUpdates");return!0}}).then((e=>{function t(){return"Data may be lost. Are you sure?"}this.dbSync=e,this.wal=new i.WAL({..._,batch_size:O,onSendStart:()=>{s&&(window.onbeforeunload=t)},onSend:async(e,t)=>(await this.updatePatches(t)).length?this.dbSync.syncData(e):[],onSendEnd:()=>{s&&(window.onbeforeunload=null)}}),this.notifyWal=new i.WAL({..._,batch_size:1/0,throttle:5,onSend:async(e,t)=>{this._notifySubscribers(t.map((e=>{var t;return{delta:this.getDelta(null!==(t=e.initial)&&void 0!==t?t:{},e.current),idObj:this.getIdObj(e.current),newItem:e.current}})))}}),a()})),d[this.name].getColumns&&d[this.name].getColumns().then((e=>{this.columns=e})),this.onChange&&!this.skipFirstTrigger&&setTimeout(this.onChange,0),(0,t.debug)(this)}static create(e){return new Promise(((t,n)=>{try{const n=new a({...e,onReady:()=>{setTimeout((()=>{t(n)}),0)}})}catch(e){n(e)}}))}sync(e,t=!0){const n={$unsync:()=>this.unsubscribe(e),getItems:()=>this.getItems(),$upsert:e=>{if(e){const t=e=>({idObj:this.getIdObj(e),delta:e});Array.isArray(e)?this.upsert(e.map((e=>t(e)))):this.upsert([t(e)])}}},i={_onChange:e,handlesOnData:t,handles:n,notify:(n,i)=>{let r=[...n],s=[...i];return t&&(r=r.map(((n,i)=>{const r=(n,i)=>({...n,...this.makeSingleSyncHandles(i,e),$get:()=>r(this.getItem(i).data,i),$find:e=>r(this.getItem(e).data,e),$update:(e,t)=>this.upsert([{idObj:i,delta:e,opts:t}]).then((e=>!0)),$delete:async()=>this.delete(i),$cloneMultiSync:e=>this.sync(e,t)}),s=this.getIdObj(n);return r(n,s)}))),e(r,s)}};return this.multiSubscriptions.push(i),this.skipFirstTrigger||setTimeout((()=>{let e=this.getItems();i.notify(e,e)}),0),Object.freeze({...n})}makeSingleSyncHandles(e,n){if(!e||!n)throw"syncOne(idObj, onChange) -> MISSING idObj or onChange";const i={$get:()=>this.getItem(e).data,$find:e=>this.getItem(e).data,$unsync:()=>this.unsubscribe(n),$delete:()=>this.delete(e),$update:(n,i)=>{this.singleSubscriptions.length||this.multiSubscriptions.length||(console.warn("No sync listeners"),(0,t.debug)("nosync",this._singleSubscriptions,this._multiSubscriptions)),this.upsert([{idObj:e,delta:n,opts:i}])},$cloneSync:t=>this.syncOne(e,t),$cloneMultiSync:e=>this.sync(e,!0)};return i}syncOne(e,t,n=!0){const i=this.makeSingleSyncHandles(e,t),r={_onChange:t,idObj:e,handlesOnData:n,handles:i,notify:(e,r)=>{let s={...e};return n&&(s.$get=i.$get,s.$find=i.$find,s.$update=i.$update,s.$delete=i.$delete,s.$unsync=i.$unsync,s.$cloneSync=i.$cloneSync),t(s,r)}};return this.singleSubscriptions.push(r),setTimeout((()=>{let e=i.$get();e&&r.notify(e,e)}),0),Object.freeze({...i})}getIdStr(e){return this.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.id_fields.sort().map((n=>{t[n]=e[n]})),t}getRowSyncObj(e){let t={};return[this.synced_field,...this.id_fields].sort().map((n=>{t[n]=e[n]})),t}matchesFilter(e){return Boolean(e&&(!this.filter||(0,i.isEmpty)(this.filter)||!Object.keys(this.filter).find((t=>this.filter[t]!==e[t]))))}matchesIdObj(e,t){return Boolean(e&&t&&!this.id_fields.sort().find((n=>e[n]!==t[n])))}getDelta(e,t){return(0,i.isEmpty)(e)?{...t}:Object.keys({...e,...t}).filter((e=>!this.id_fields.includes(e))).reduce(((n,i)=>{let r={};if(i in t&&t[i]!==e[i]){let n={[i]:t[i]};t[i]&&e[i]&&"object"==typeof e[i]?JSON.stringify(t[i])!==JSON.stringify(e[i])&&(r=n):r=n}return{...n,...r}}),{})}deleteAll(){this.getItems().map((e=>this.delete(e)))}get tableHandler(){const e=this.db[this.name];if((null==e?void 0:e.update)&&e.updateBatch)return e}getItem(e){let t;return this.storageType===o.localStorage?t=this.getItems().find((t=>this.matchesIdObj(t,e))):this.storageType===o.array?t=this.items.find((t=>this.matchesIdObj(t,e))):(this.itemsObj=this.itemsObj||{},t={...this.itemsObj}[this.getIdStr(e)]),{data:l(t),index:-1}}setItem(e,t,n=!1,i=!1){const r=l(e);if(this.storageType===o.localStorage){let e=this.getItems();i?e=e.filter((e=>!this.matchesIdObj(e,r))):void 0!==t&&e[t]?e[t]=n?{...r}:{...e[t],...r}:e.push(r),s&&window.localStorage.setItem(this.name,JSON.stringify(e))}else if(this.storageType===o.array)i?this.items=this.items.filter((e=>!this.matchesIdObj(e,r))):void 0===t||this.items[t]?void 0!==t&&(this.items[t]=n?{...r}:{...this.items[t],...r}):this.items.push(r);else if(this.itemsObj=this.itemsObj||{},i)delete this.itemsObj[this.getIdStr(r)];else{let e=this.itemsObj[this.getIdStr(r)]||{};this.itemsObj[this.getIdStr(r)]=n?{...r}:{...e,...r}}}}function c(e,t){const n=e?l(e):e,r=t?l(t):t;let s=Object.assign({},n);return(0,i.isObject)(n)&&(0,i.isObject)(r)&&Object.keys(r).forEach((e=>{(0,i.isObject)(r[e])?e in n?s[e]=c(n[e],r[e]):Object.assign(s,{[e]:r[e]}):Object.assign(s,{[e]:r[e]})})),s}function l(e){if(s&&"structuredClone"in window&&"function"==typeof window.structuredClone)return window.structuredClone(e);if(Array.isArray(e))return e.slice(0).map((e=>l(e)));if((0,i.isObject)(e)){let t={};return(0,i.getKeys)(e).map((n=>{t[n]=l(e[n])})),t}return e}t.SyncedTable=a,t.default=c,t.quickClone=l},274:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.prostgles=t.useProstglesClient=t.asName=t.debug=void 0;const s=n(792);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return s.asName}});const o=n(133),a=n(353),c="DEBUG_SYNCEDTABLE",l="undefined"!=typeof window;function u(e,n){const{socket:i,onReady:r,onDisconnect:o,onReconnect:c,onSchemaChange:u=!0,onReload:f,onDebug:h}=e;let p;if((0,t.debug)("prostgles",{initOpts:e}),u){let e;"function"==typeof u&&(e=u),i.removeAllListeners(s.CHANNELS.SCHEMA_CHANGED),e&&i.on(s.CHANNELS.SCHEMA_CHANGED,e)}const m=s.CHANNELS._preffix;let y,g,b={},v={},S={},O={};function _(e,n,r){return(0,t.debug)("_unsubscribe",{channelName:e,handler:r}),new Promise(((t,s)=>{const o=b[e];o?(o.handlers=o.handlers.filter((e=>e!==r)),o.handlers.length||(i.emit(n,{},((e,t)=>{e?console.error(e):s(e)})),i.removeListener(e,o.onCall),delete b[e]),t(!0)):t(!0)}))}function w({tableName:e,command:t,param1:n,param2:r},s){return new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{if(e)console.error(e),a(e);else if(t){const{id_fields:e,synced_field:n,channelName:r}=t;i.emit(r,{onSyncRequest:s({})},(e=>{console.log(e)})),o({id_fields:e,synced_field:n,channelName:r})}}))}))}function j({tableName:e,command:t,param1:n,param2:r}){return new Promise(((s,o)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r},((e,t)=>{e?(console.error(e),o(e)):t&&s(t)}))}))}const E=new d((async function({tableName:e,command:n,param1:r,param2:s},o){const{onSyncRequest:a}=o;function c(e){return Object.freeze({unsync:function(){!function(e,n){(0,t.debug)("_unsync",{channelName:e,triggers:n}),new Promise(((t,r)=>{S[e]&&(S[e].triggers=S[e].triggers.filter((e=>e.onPullRequest!==n.onPullRequest&&e.onSyncRequest!==n.onSyncRequest&&e.onUpdates!==n.onUpdates)),S[e].triggers.length||(i.emit(e+"unsync",{},((e,n)=>{e?r(e):t(n)})),i.removeListener(e,S[e].onCall),delete S[e]))}))}(e,o)},syncData:function(t,n,r){i.emit(e,{onSyncRequest:{...a({}),...{data:t}||{},...{deleted:n}||{}}},r?e=>{r(e)}:null)}})}const l=Object.keys(S).find((t=>{let i=S[t];return i&&i.tableName===e&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l)return S[l].triggers.push(o),c(l);{const u=await w({tableName:e,command:n,param1:r,param2:s},a),{channelName:d,synced_field:f,id_fields:h}=u;function p(t,n){t&&S[d]&&S[d].triggers.map((({onUpdates:i,onSyncRequest:r,onPullRequest:s})=>{t.data?Promise.resolve(i(t)).then((()=>{n&&n({ok:!0})})).catch((t=>{n?n({err:t}):console.error(e+" onUpdates error",t)})):t.onSyncRequest?Promise.resolve(r(t.onSyncRequest)).then((e=>n({onSyncRequest:e}))).catch((t=>{n?n({err:t}):console.error(e+" onSyncRequest error",t)})):t.onPullRequest?Promise.resolve(s(t.onPullRequest)).then((e=>{n({data:e})})).catch((t=>{n?n({err:t}):console.error(e+" onPullRequest error",t)})):console.log("unexpected response")}))}return S[d]={tableName:e,command:n,param1:r,param2:s,triggers:[o],syncInfo:u,onCall:p},i.on(d,p),c(d)}}),(([{tableName:e}])=>e)),N=new d((async function(e,{tableName:t,command:n,param1:r,param2:s},o,a){function c(n,i){let s={unsubscribe:function(){return _(n,i,o)},filter:{...r}};return e[t].update&&(s={...s,update:function(n,i){return e[t].update(r,n,i)}}),e[t].delete&&(s={...s,delete:function(n){return e[t].delete(r,n)}}),Object.freeze(s)}const l=Object.entries(b).find((([e])=>{let i=b[e];return i&&i.tableName===t&&i.command===n&&JSON.stringify(i.param1||{})===JSON.stringify(r||{})&&JSON.stringify(i.param2||{})===JSON.stringify(s||{})}));if(l){const e=l[0];return l[1].handlers.push(o),l[1].errorHandlers.push(a),setTimeout((()=>{var t,n;o&&(null===(t=null==b?void 0:b[e])||void 0===t?void 0:t.lastData)&&o(null===(n=null==b?void 0:b[e])||void 0===n?void 0:n.lastData)}),10),c(e,l[1].unsubChannel)}const{channelName:u,channelNameReady:d,channelNameUnsubscribe:f}=await j({tableName:t,command:n,param1:r,param2:s}),h=function(e,t){const n=b[u];n?e.data?(n.lastData=e.data,n.handlers.forEach((t=>{t(e.data)}))):e.err?n.errorHandlers.forEach((t=>{null==t||t(e.err)})):console.error("INTERNAL ERROR: Unexpected data format from subscription: ",e):console.warn("Orphaned subscription: ",u)},p=a||function(e){console.error(`Uncaught error within running subscription \n ${u}`,e)};return i.on(u,h),b[u]={lastData:void 0,tableName:t,command:n,param1:r,param2:s,onCall:h,unsubChannel:f,handlers:[o],errorHandlers:[p],destroy:async()=>{var e,t;for await(const n of null!==(t=null===(e=b[u])||void 0===e?void 0:e.handlers)&&void 0!==t?t:[])await _(u,f,n)}},i.emit(d,{now:Date.now()}),c(u,f)}),(([e,{tableName:t}])=>t));async function C(e,t,n,i){return N.run([e,t,n,i])}return new Promise(((e,u)=>{i.removeAllListeners(s.CHANNELS.CONNECTION),i.on(s.CHANNELS.CONNECTION,(e=>(u(e),"ok"))),o&&i.on("disconnect",(()=>{g="disconnected",o()})),c&&i.on("connect",(()=>{"disconnected"===g&&(g="reconnected")})),i.on(s.CHANNELS.SCHEMA,(async({schema:o,methods:d,tableSchema:_,auth:N,rawSQL:T,joinTables:x=[],err:P})=>{if(await(async()=>{(0,t.debug)("destroySyncs",{subscriptions:b,syncedTables:v}),await Promise.all(Object.values(b).map((e=>e.destroy()))),S={},Object.values(v).map((e=>{e&&e.destroy&&e.destroy()})),v={}})(),"connected"!==g&&"reconnected"!==g||!c)p={origin:"onReady",date:new Date};else{if(c(i,P),P)return void console.error(P);p={origin:"onReconnect",date:new Date}}if(P)throw u(P),P;const I="reconnected"===g;g="connected";let k=JSON.parse(JSON.stringify(o)),$=JSON.parse(JSON.stringify(d)),R={},D={};if(N){if(N.pathGuard&&l){const e=e=>{var t,n;(null==e?void 0:e.shouldReload)&&(f?f():"undefined"!=typeof window&&(null===(n=null===(t=null===window||void 0===window?void 0:window.location)||void 0===t?void 0:t.reload)||void 0===n||n.call(t)))};i.emit(s.CHANNELS.AUTHGUARD,JSON.stringify(window.location),((t,n)=>{e(n)})),i.removeAllListeners(s.CHANNELS.AUTHGUARD),i.on(s.CHANNELS.AUTHGUARD,(t=>{e(t)}))}D={...N},[s.CHANNELS.LOGIN,s.CHANNELS.LOGOUT,s.CHANNELS.REGISTER].map((e=>{N[e]&&(D[e]=function(t){return new Promise(((n,r)=>{i.emit(m+e,t,((e,t)=>{e?r(e):n(t)}))}))})}))}$.map((e=>{const t="string"==typeof e,n=t?e:e.name,r=async function(...e){return await(null==h?void 0:h({type:"method",command:n,data:{params:e}})),new Promise(((t,r)=>{i.emit(s.CHANNELS.METHOD,{method:n,params:e},((e,n)=>{e?r(e):t(n)}))}))};R[n]=t?r:{...e,run:r}})),R=Object.freeze(R),T&&(k.sql=function(e,t,n){return new Promise(((r,o)=>{i.emit(s.CHANNELS.SQL,{query:e,params:t,options:n},((e,t)=>{if(e)o(e);else{if("stream"===(null==n?void 0:n.returnType)){const{channel:e,unsubChannel:n}=t,s=t=>new Promise(((r,s)=>{i.on(e,t),i.emit(e,{},((t,o)=>{o?(s(o),i.removeAllListeners(e)):r({run:(t,n)=>new Promise(((r,s)=>{i.emit(e,{query:t,params:n},((e,t)=>{t?s(t):r(e)}))})),stop:e=>new Promise(((t,r)=>{i.emit(n,{terminate:e},((e,n)=>{n?r(n):t(e)}))}))})}))}));return r({channel:e,unsubChannel:n,start:s})}if(n&&"noticeSubscription"===n.returnType&&t&&Object.keys(t).sort().join()===["socketChannel","socketUnsubChannel"].sort().join()&&!Object.values(t).find((e=>"string"!=typeof e))){const e=t,n=t=>(((e,t)=>{y=y||{config:t,listeners:[]},y.listeners.length||(i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{y&&y.listeners&&y.listeners.length?y.listeners.map((t=>{t(e)})):i.emit(t.socketUnsubChannel,{})}))),y.listeners.push(e)})(t,e),{...e,removeListener:()=>(e=>{y&&(y.listeners=y.listeners.filter((t=>t!==e)),!y.listeners.length&&y.config&&y.config.socketUnsubChannel&&i&&i.emit(y.config.socketUnsubChannel,{}))})(t)}),s={...e,addListener:n};r(s)}else if(n&&n.returnType&&"statement"===n.returnType||!t||Object.keys(t).sort().join()!==["socketChannel","socketUnsubChannel","notifChannel"].sort().join()||Object.values(t).find((e=>"string"!=typeof e)))r(t);else{const e=t,n=n=>(((e,t)=>{var n;O=O||{},O[t.notifChannel]?null===(n=O[t.notifChannel])||void 0===n||n.listeners.push(e):(O[t.notifChannel]={config:t,listeners:[e]},i.removeAllListeners(t.socketChannel),i.on(t.socketChannel,(e=>{var n,r;(null===(n=O[t.notifChannel])||void 0===n?void 0:n.listeners.length)?O[t.notifChannel].listeners.map((t=>{t(e)})):i.emit(null===(r=O[t.notifChannel])||void 0===r?void 0:r.config.socketUnsubChannel,{})})))})(n,e),{...t,removeListener:()=>((e,t)=>{const n=O[t.notifChannel];n&&(n.listeners=n.listeners.filter((t=>t!==e)),!n.listeners.length&&n.config&&n.config.socketUnsubChannel&&i&&(i.emit(n.config.socketUnsubChannel,{}),delete O[t.notifChannel]))})(n,e)}),s={...t,addListener:n};r(s)}}}))}))});const A=(e,t,n,i)=>{if(void 0!==e&&!(0,s.isObject)(e)||void 0!==t&&!(0,s.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"},J=["subscribe","subscribeOne"];(0,s.getKeys)(k).forEach((e=>{const t=Object.keys(k[e]),r=k[e];t.sort(((e,t)=>J.includes(e)-J.includes(t))).forEach((t=>{if("sync"===t){if(r._syncInfo={...r[t]},n){r.getSync=async(t,i={})=>(await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{filter:t,params:i}})),n.create({name:e,onDebug:h,filter:t,db:k,...i}));const t=async(t={},i={},r)=>{const s=`${e}.${JSON.stringify(t)}.${JSON.stringify(i)}`;return v[s]||(v[s]=await n.create({...i,onDebug:h,name:e,filter:t,db:k,onError:r})),v[s]},i=async(n,i={handlesOnData:!0,select:"*"},r,s)=>{await(null==h?void 0:h({type:"table",command:"sync",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.sync(r,i.handlesOnData)},s=async(n,i={handlesOnData:!0},r,s)=>{await(null==h?void 0:h({type:"table",command:"syncOne",tableName:e,data:{basicFilter:n,options:i}})),A(n,i,r,s);const o=await t(n,i,s);return await o.syncOne(n,r,i.handlesOnData)};r.sync=i,r.syncOne=s,r.useSync=(e,t)=>(0,a.useSync)(r.sync,e,t)}r._sync=async function(n,i,r){return await(null==h?void 0:h({type:"table",command:"_sync",tableName:e,data:{param1:n,param2:i,syncHandles:r}})),async function(e,t){return E.run([e,t])}({tableName:e,command:t,param1:n,param2:i},r)}}else if(J.includes(t)){const n=async function(n={},i={},r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},r,s)};r[t]=n;const i="subscribeOne",s="subscribe"===t?"useSubscribe":"subscribeOne"===t?"useSubscribeOne":void 0;s&&(r[s]=(e,r)=>(0,a.useSubscribe)(n,t===i,e,r)),t!==i&&J.includes(i)||(r[i]=async function(n,i,r,s){return await(null==h?void 0:h({type:"table",command:"getSync",tableName:e,data:{param1:n,param2:i,onChange:r,onError:s}})),A(n,i,r,s),C(k,{tableName:e,command:t,param1:n,param2:i},(e=>{r(e[0])}),s)})}else{const n=async function(n,r,s){return await(null==h?void 0:h({type:"table",command:t,tableName:e,data:{param1:n,param2:r,param3:s}})),new Promise(((o,a)=>{i.emit(m,{tableName:e,command:t,param1:n,param2:r,param3:s},((e,t)=>{e?a(e):o(t)}))}))};r[t]=n;const s="findOne"===t?"useFindOne":"find"===t?"useFind":"count"===t?"useCount":"size"===t?"useSize":void 0;s&&(r[s]=(e,t,i)=>(0,a.useFetch)(n,[e,t,i])),["find","findOne"].includes(t)&&(r.getJoinedTables=function(){return(x||[]).filter((t=>Array.isArray(t)&&t.includes(e))).flat().filter((t=>t!==e))})}}))})),b&&Object.keys(b).length&&Object.keys(b).map((async e=>{try{let t=b[e];await j(t),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting old subscriptions",e)}})),S&&Object.keys(S).length&&(0,s.getKeys)(S).filter((e=>{var t;return null===(t=S[e])||void 0===t?void 0:t.triggers.length})).map((async e=>{try{let t=S[e];await w(t,t.triggers[0].onSyncRequest),i.on(e,t.onCall)}catch(e){console.error("There was an issue reconnecting olf subscriptions",e)}})),x.flat().map((e=>{k.innerJoin=k.innerJoin||{},k.leftJoin=k.leftJoin||{},k.innerJoinOne=k.innerJoinOne||{},k.leftJoinOne=k.leftJoinOne||{};const t=(0,s.getJoinHandlers)(e);k.leftJoin[e]=t.leftJoin,k.innerJoin[e]=t.innerJoin,k.leftJoinOne[e]=t.leftJoinOne,k.innerJoinOne[e]=t.innerJoinOne})),(async()=>{try{await r(k,R,_,D,I)}catch(e){console.error("Prostgles: Error within onReady: \n",e),u(e)}e(k)})()}))}))}t.debug=function(...e){l&&window[c]&&window[c](...e)},r(n(353),t),t.useProstglesClient=e=>{const t=(0,a.getReact)(!0),[n,i]=t.useState(),r=(0,a.useIsMounted)();return(0,a.useAsyncEffectQueue)((async()=>{await u({...e,onReady:(...t)=>{if(!r())return;e.onReady(...t);const[n,s,o,a,c]=t;i({dbo:n,methods:s,tableSchema:o,auth:a,isReconnect:c})}},o.SyncedTable)}),[e]),n},t.prostgles=u;class d{constructor(e,t){this.queue=[],this.isRunning=!1,this.func=e,this.groupBy=t}async run(e){const t=new Promise(((t,n)=>{const i={arguments:e,onResult:t,onFail:n};this.queue.push(i)})),n=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=[],n=[];this.queue.forEach((async(e,i)=>{const r=this.groupBy(e.arguments);t.includes(r)||(t.push(r),n.push({index:i,item:e}))})),n.slice(0).reverse().forEach((e=>{this.queue.splice(e.index,1)})),await Promise.all(n.map((t=>e(t.item))))}else{const t=this.queue.shift();await e(t)}this.isRunning=!1,this.queue.length&&n()};return n(),t}}},353:(e,t,n)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.__prglReactInstalled=t.useFetch=t.useSync=t.useSubscribe=t.usePromise=t.useIsMounted=t.useEffectAsync=t.useAsyncEffectQueue=t.useEffectDeep=t.useDeepCompareMemoize=t.isEqual=t.getReact=void 0;const r=n(792);let s;const o=(...e)=>{throw"Must install react"},a=(...e)=>{throw"Must install react"};t.getReact=e=>{try{null!=s||(s=n(294))}catch(e){}if(e&&!s)throw new Error("Must install react");return s},(0,t.getReact)();const{useEffect:c=o,useCallback:l=o,useRef:u,useState:d=a}=null!==(i=s)&&void 0!==i?i:{};function f(){const e=u(!0),t=l((()=>e.current),[]);return c((()=>()=>{e.current=!1}),[]),t}t.isEqual=function(e,n){if(e===n)return!0;if("object"==typeof e&&null!=e&&"object"==typeof n&&null!=n){if(Object.keys(e).length!=Object.keys(n).length)return!1;for(const i in e){if(!n.hasOwnProperty(i))return!1;if(!(0,t.isEqual)(e[i],n[i]))return!1}return!0}return!1},t.useDeepCompareMemoize=e=>{const n=u();return(0,t.isEqual)(e,n.current)||(n.current=e),n.current},t.useEffectDeep=(e,n)=>{c(e,n.map(t.useDeepCompareMemoize))},t.useAsyncEffectQueue=(e,n)=>{const i={effect:e,deps:n,didCleanup:!1},r=u({activeEffect:void 0,latestEffect:i});r.current.latestEffect=i;const s=async e=>{var t,n,i;if(e.current.latestEffect&&(!e.current.activeEffect||e.current.activeEffect.resolvedCleanup)){if(await(null===(i=null===(n=null===(t=e.current.activeEffect)||void 0===t?void 0:t.resolvedCleanup)||void 0===n?void 0:n.run)||void 0===i?void 0:i.call(n)),e.current.activeEffect=e.current.latestEffect,e.current.latestEffect=void 0,!e.current.activeEffect)return;const r=await e.current.activeEffect.effect();if(!e.current.activeEffect)return void await(null==r?void 0:r());e.current.activeEffect.resolvedCleanup={run:r},e.current.activeEffect.didCleanup&&o()}},o=async()=>{var e,t,n;await(null===(n=null===(t=null===(e=r.current.activeEffect)||void 0===e?void 0:e.resolvedCleanup)||void 0===t?void 0:t.run)||void 0===n?void 0:n.call(t)),r.current.activeEffect=void 0,s(r)};(0,t.useEffectDeep)((()=>(s(r),()=>{var t,n;(null===(t=r.current.activeEffect)||void 0===t?void 0:t.effect)===e&&(r.current.activeEffect.didCleanup=!0,o()),(null===(n=r.current.latestEffect)||void 0===n?void 0:n.effect)===e&&(r.current.latestEffect=void 0)})),n)},t.useEffectAsync=(e,n)=>{const i=u({cleanup:void 0,effect:e,cleanupEffect:void 0});i.current.effect=e,(0,t.useEffectDeep)((()=>(e().then((t=>{"function"==typeof t&&(i.current.cleanup=t,i.current.cleanupEffect===e&&t())})),()=>{var t,n;i.current.cleanupEffect=e,null===(n=(t=i.current).cleanup)||void 0===n||n.call(t)})),n)},t.useIsMounted=f,t.usePromise=(e,n=[])=>{const i=e=>{try{return"function"==typeof e||e instanceof Promise}catch(e){console.error(e)}return!1},s=e=>{try{return(0,r.isObject)(e)&&!i(e)}catch(e){console.error(e)}return!1},o=async e=>{const t={},n=(0,r.getKeys)(e);for await(const i of n){const n=e[i];t[i]="function"==typeof n?await n():await n}return t},[a,c]=d(s(e)?{}:void 0),l=f();return(0,t.useAsyncEffectQueue)((async()=>{let t;if(s(e))t=await o(e);else{const n=await e();t=s(n)?await o(n):i(n)?await n():n}l()&&c(t)}),n),a},t.useSubscribe=(e,n,i,r)=>{const s={data:void 0,error:void 0,isLoading:!0},[{data:o,error:a,isLoading:c},l]=d(s),u=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!u())return;l(s);const t=e=>{u()&&l({data:void 0,error:e,isLoading:!1})};try{return(await e(i,r,(e=>{u()&&l({data:n?e[0]:e,error:void 0,isLoading:!1})}),t)).unsubscribe}catch(e){t(e)}}),[e,i,r]),{data:o,error:a,isLoading:c}},t.useSync=(e,n,i)=>{const r={data:void 0,error:void 0,isLoading:!0},[{data:s,error:o,isLoading:a},c]=d(r),l=f();return(0,t.useAsyncEffectQueue)((async()=>{if(!l())return;c(r);const t=e=>{l()&&c({data:void 0,error:e,isLoading:!1})};try{return(await e(n,i,(e=>{l()&&c({data:e,error:void 0,isLoading:!1})}),t)).$unsync()}catch(e){t(e)}}),[e,n,i]),{data:s,error:o,isLoading:a}},t.useFetch=(e,n=[])=>{const i={data:void 0,error:void 0,isLoading:!0},[{data:r,error:s,isLoading:o},a]=d(i),c=f();return(0,t.useAsyncEffectQueue)((async()=>{if(c()){a(i);try{const t=await e(...n);if(!c())return;a({data:t,error:void 0,isLoading:!1})}catch(e){if(!c())return;a({data:void 0,error:e,isLoading:!1})}}}),n),{data:r,error:s,isLoading:o}},t.__prglReactInstalled=()=>Boolean(s&&u)},792:function(e){var t;this||window,t=()=>(()=>{"use strict";var e={31:(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"]}},444:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const i=n(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],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,i.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.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=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_strings=void 0,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=["int2","int4","int8","float4","float8","numeric","money","oid"],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 s={string:[...t._PG_strings,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var a=n(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(n(444),t),r(n(929),t),r(n(128),t)},929:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const i=n(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:n,arrayOf:s,arrayOfType:o,description:a,nullable:c,oneOf:l,oneOfType:u,title:d,record:f,...h}="string"==typeof e?{type:e}:e;let p={};const m={...(h.enum||h.allowedValues?.length)&&{enum:h.allowedValues?.slice(0)??h.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(h.enum?.length&&(m.type=typeof h.enum[0]),"string"==typeof n||s||o){if(n&&"string"!=typeof n)throw"Not expected";p=s||o||n?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):n?.startsWith("any")?{type:void 0}:{type:n?.slice(0,-2),...h.allowedValues&&{enum:h.allowedValues.slice(0)}}}:{type:n}}else(0,i.isObject)(n)?p={type:"object",required:(0,i.getKeys)(n).filter((e=>{const t=n[e];return"string"==typeof t||!t.optional})),properties:(0,i.getKeys)(n).reduce(((e,t)=>({...e,[t]:r(n[t])})),{})}:l||u?p={oneOf:(l||u.map((e=>({type:e})))).map((e=>r(e)))}:f&&(p={type:"object",...f.values&&!f.keysEnum&&{additionalProperties:r(f.values)},...f.keysEnum&&{properties:f.keysEnum.reduce(((e,t)=>({...e,[t]:f.values?r(f.values):{type:{}}})),{})}});if(c){const e={type:"null"};p.oneOf?p.oneOf.push(e):p.enum&&!p.enum.includes(null)?p.enum.push(null):p={oneOf:[p,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...m,...p}};t.getJSONBSchemaAsJSONSchema=function(e,t,n){return r(n,{id:`${e}.${t}`})}},899:(e,t)=>{function n(e,t){var n=e[0],i=e[1],c=e[2],l=e[3];n=r(n,i,c,l,t[0],7,-680876936),l=r(l,n,i,c,t[1],12,-389564586),c=r(c,l,n,i,t[2],17,606105819),i=r(i,c,l,n,t[3],22,-1044525330),n=r(n,i,c,l,t[4],7,-176418897),l=r(l,n,i,c,t[5],12,1200080426),c=r(c,l,n,i,t[6],17,-1473231341),i=r(i,c,l,n,t[7],22,-45705983),n=r(n,i,c,l,t[8],7,1770035416),l=r(l,n,i,c,t[9],12,-1958414417),c=r(c,l,n,i,t[10],17,-42063),i=r(i,c,l,n,t[11],22,-1990404162),n=r(n,i,c,l,t[12],7,1804603682),l=r(l,n,i,c,t[13],12,-40341101),c=r(c,l,n,i,t[14],17,-1502002290),n=s(n,i=r(i,c,l,n,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,n,i,c,t[6],9,-1069501632),c=s(c,l,n,i,t[11],14,643717713),i=s(i,c,l,n,t[0],20,-373897302),n=s(n,i,c,l,t[5],5,-701558691),l=s(l,n,i,c,t[10],9,38016083),c=s(c,l,n,i,t[15],14,-660478335),i=s(i,c,l,n,t[4],20,-405537848),n=s(n,i,c,l,t[9],5,568446438),l=s(l,n,i,c,t[14],9,-1019803690),c=s(c,l,n,i,t[3],14,-187363961),i=s(i,c,l,n,t[8],20,1163531501),n=s(n,i,c,l,t[13],5,-1444681467),l=s(l,n,i,c,t[2],9,-51403784),c=s(c,l,n,i,t[7],14,1735328473),n=o(n,i=s(i,c,l,n,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,n,i,c,t[8],11,-2022574463),c=o(c,l,n,i,t[11],16,1839030562),i=o(i,c,l,n,t[14],23,-35309556),n=o(n,i,c,l,t[1],4,-1530992060),l=o(l,n,i,c,t[4],11,1272893353),c=o(c,l,n,i,t[7],16,-155497632),i=o(i,c,l,n,t[10],23,-1094730640),n=o(n,i,c,l,t[13],4,681279174),l=o(l,n,i,c,t[0],11,-358537222),c=o(c,l,n,i,t[3],16,-722521979),i=o(i,c,l,n,t[6],23,76029189),n=o(n,i,c,l,t[9],4,-640364487),l=o(l,n,i,c,t[12],11,-421815835),c=o(c,l,n,i,t[15],16,530742520),n=a(n,i=o(i,c,l,n,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,n,i,c,t[7],10,1126891415),c=a(c,l,n,i,t[14],15,-1416354905),i=a(i,c,l,n,t[5],21,-57434055),n=a(n,i,c,l,t[12],6,1700485571),l=a(l,n,i,c,t[3],10,-1894986606),c=a(c,l,n,i,t[10],15,-1051523),i=a(i,c,l,n,t[1],21,-2054922799),n=a(n,i,c,l,t[8],6,1873313359),l=a(l,n,i,c,t[15],10,-30611744),c=a(c,l,n,i,t[6],15,-1560198380),i=a(i,c,l,n,t[13],21,1309151649),n=a(n,i,c,l,t[4],6,-145523070),l=a(l,n,i,c,t[11],10,-1120210379),c=a(c,l,n,i,t[2],15,718787259),i=a(i,c,l,n,t[9],21,-343485551),e[0]=f(n,e[0]),e[1]=f(i,e[1]),e[2]=f(c,e[2]),e[3]=f(l,e[3])}function i(e,t,n,i,r,s){return t=f(f(t,e),f(i,s)),f(t<<r|t>>>32-r,n)}function r(e,t,n,r,s,o,a){return i(t&n|~t&r,e,t,s,o,a)}function s(e,t,n,r,s,o,a){return i(t&r|n&~r,e,t,s,o,a)}function o(e,t,n,r,s,o,a){return i(t^n^r,e,t,s,o,a)}function a(e,t,n,r,s,o,a){return i(n^(t|~r),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.md5=t.md5cycle=void 0,t.md5cycle=n;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,i=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(r,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(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*i,n(r,s),r}(e))}function f(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const i=n(899);function r(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.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=(e,t=[],n=!0)=>{if(!t.length)return{};if(e&&t.length){let i={};return t.forEach((t=>{n&&void 0===e[t]||(i[t]=e[t])})),i}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},s={key:i,value:e[i]};return n(r,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(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(r&&r(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,i.md5)(t)};function n(n=1){let i=n<1?-1:0,r=!1;for(;!r&&Math.abs(i)<=t.length;){const s=n<1?[i]:[0,i];e.slice(...s)!==t.slice(...s)?r=!0:i+=1*Math.sign(n)}return i}let r=n()-1,s=e.length+n(-1)+1,o=t.length+n(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,i.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:n,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,n)+s+e.slice(r);if(o&&(0,i.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},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 i=n.asc?e[n.fieldName]:t[n.fieldName],r=n.asc?t[n.fieldName]:e[n.fieldName],s=+i-+r,o=i<r?-1:i==r?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)],i=n?.[this.options.synced_field];if(n){if(!Number.isFinite(+i))throw"Provided historic item Synced field value is missing/invalid";if(+i==+t)return!0}return!1},this.addData=e=>{o(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:n,current:i,delta:r}={...e};if(!i)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(i);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:n,current:i,delta:r}),this.changed[s].current={...this.changed[s].current,...i},this.changed[s].delta={...this.changed[s].delta,...r}})),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:r,historyAgeSeconds:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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],r=e.current[n];var s,o;![this.options.synced_field,...this.options.id_fields].includes(n)&&((s=i)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[n]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),s&&(this.sentHistory={...this.sentHistory,...u},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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}},t.isEmpty=o,t.get=function(e,t){let n=t,i=e;return e?("string"==typeof n&&(n=n.split(".")),n.reduce(((e,t)=>e&&e[t]?e[t]:void 0),i)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=a,t.getKeys=c,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,n)=>(n,i,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:n,...r(s,["path","select"]),select:i});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,n)=>{const i=[{table:n,on:[{}]},...e??[]];return i.map(((e,n)=>{const r=i[n+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},t={};return function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(590)})(),e.exports=t()},408:(e,t)=>{"use strict";var n=Symbol.for("react.element"),i=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator,p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,y={};function g(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}function b(){}function v(e,t,n){this.props=e,this.context=t,this.refs=y,this.updater=n||p}g.prototype.isReactComponent={},g.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},g.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=g.prototype;var S=v.prototype=new b;S.constructor=v,m(S,g.prototype),S.isPureReactComponent=!0;var O=Array.isArray,_=Object.prototype.hasOwnProperty,w={current:null},j={key:!0,ref:!0,__self:!0,__source:!0};function E(e,t,i){var r,s={},o=null,a=null;if(null!=t)for(r in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,r)&&!j.hasOwnProperty(r)&&(s[r]=t[r]);var c=arguments.length-2;if(1===c)s.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];s.children=l}if(e&&e.defaultProps)for(r in c=e.defaultProps)void 0===s[r]&&(s[r]=c[r]);return{$$typeof:n,type:e,key:o,ref:a,props:s,_owner:w.current}}function N(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}var C=/\/+/g;function T(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function x(e,t,r,s,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case n:case i:c=!0}}if(c)return o=o(c=e),e=""===s?"."+T(c,0):s,O(o)?(r="",null!=e&&(r=e.replace(C,"$&/")+"/"),x(o,t,r,"",(function(e){return e}))):null!=o&&(N(o)&&(o=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(C,"$&/")+"/")+e)),t.push(o)),1;if(c=0,s=""===s?".":s+":",O(e))for(var l=0;l<e.length;l++){var u=s+T(a=e[l],l);c+=x(a,t,r,u,o)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=h&&e[h]||e["@@iterator"])?e:null}(e),"function"==typeof u)for(e=u.call(e),l=0;!(a=e.next()).done;)c+=x(a=a.value,t,r,u=s+T(a,l++),o);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function P(e,t,n){if(null==e)return e;var i=[],r=0;return x(e,i,"","",(function(e){return t.call(n,e,r++)})),i}function I(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var k={current:null},$={transition:null},R={ReactCurrentDispatcher:k,ReactCurrentBatchConfig:$,ReactCurrentOwner:w};t.Children={map:P,forEach:function(e,t,n){P(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return P(e,(function(){t++})),t},toArray:function(e){return P(e,(function(e){return e}))||[]},only:function(e){if(!N(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=g,t.Fragment=r,t.Profiler=o,t.PureComponent=v,t.StrictMode=s,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=R,t.cloneElement=function(e,t,i){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m({},e.props),s=e.key,o=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(o=t.ref,a=w.current),void 0!==t.key&&(s=""+t.key),e.type&&e.type.defaultProps)var c=e.type.defaultProps;for(l in t)_.call(t,l)&&!j.hasOwnProperty(l)&&(r[l]=void 0===t[l]&&void 0!==c?c[l]:t[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:n,type:e.type,key:s,ref:o,props:r,_owner:a}},t.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=E,t.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:l,render:e}},t.isValidElement=N,t.lazy=function(e){return{$$typeof:f,_payload:{_status:-1,_result:e},_init:I}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=$.transition;$.transition={};try{e()}finally{$.transition=t}},t.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")},t.useCallback=function(e,t){return k.current.useCallback(e,t)},t.useContext=function(e){return k.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return k.current.useDeferredValue(e)},t.useEffect=function(e,t){return k.current.useEffect(e,t)},t.useId=function(){return k.current.useId()},t.useImperativeHandle=function(e,t,n){return k.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.current.useMemo(e,t)},t.useReducer=function(e,t,n){return k.current.useReducer(e,t,n)},t.useRef=function(e){return k.current.useRef(e)},t.useState=function(e){return k.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.current.useTransition()},t.version="18.2.0"},294:(e,t,n)=>{"use strict";e.exports=n(408)}},t={},function n(i){var r=t[i];if(void 0!==r)return r.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,n),s.exports}(274);var e,t}));
@@ -1,5 +1,5 @@
1
- import { AnyObject, ClientSyncHandles, DBSchema, DBSchemaTable, DbJoinMaker, EqualityFilter, FullFilter, GetSelectReturnType, MethodHandler, OnError, SQLHandler, SQLResult, SelectParams, SubscribeParams, TableHandler, ViewHandler, asName } from "prostgles-types";
2
- import { SyncDataItem, SyncOptions, type Sync, type SyncOne, SyncOneOptions } from "./SyncedTable";
1
+ import { AnyObject, ClientSyncHandles, DBSchema, DBSchemaTable, DbJoinMaker, EqualityFilter, FullFilter, GetSelectReturnType, MethodHandler, SQLHandler, SQLResult, SelectParams, SubscribeParams, TableHandler, ViewHandler, asName } from "prostgles-types";
2
+ import { SyncDataItem, SyncOneOptions, SyncOptions, type Sync, type SyncOne } from "./SyncedTable";
3
3
  export declare const debug: any;
4
4
  export { MethodHandler, SQLResult, asName };
5
5
  export * from "./react-hooks";
@@ -29,44 +29,30 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
29
29
  error?: any;
30
30
  };
31
31
  _sync?: any;
32
- /**
33
- * Will return undefined while loading
34
- */
35
- useSubscribe: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams, onError?: OnError) => GetSelectReturnType<S, SubParams, T, false>[] | undefined;
36
- /**
37
- * Will return undefined while loading
38
- */
39
- useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams, onError?: OnError) => GetSelectReturnType<S, SubParams, T, false> | undefined;
40
- /**
41
- * Will return undefined while loading
42
- */
43
- useSubscribeV2: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
44
- data: GetSelectReturnType<S, SubParams, T, false>[] | undefined;
32
+ useSubscribe: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
33
+ data: GetSelectReturnType<S, SubParams, T, true>[] | undefined;
45
34
  error?: any;
46
35
  isLoading: boolean;
47
36
  };
48
37
  /**
49
38
  * Will return undefined while loading
50
39
  */
51
- useSubscribeOneV2: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
40
+ useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
52
41
  data: GetSelectReturnType<S, SubParams, T, false> | undefined;
53
42
  error?: any;
54
43
  isLoading: boolean;
55
44
  };
56
- useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => undefined | GetSelectReturnType<S, P, T, true>;
57
- useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => undefined | GetSelectReturnType<S, P, T, false>;
58
- useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => number | undefined;
59
- useFindV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
45
+ useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
60
46
  data: undefined | GetSelectReturnType<S, P, T, true>;
61
47
  isLoading: boolean;
62
48
  error?: any;
63
49
  };
64
- useFindOneV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
50
+ useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
65
51
  data: undefined | GetSelectReturnType<S, P, T, false>;
66
52
  isLoading: boolean;
67
53
  error?: any;
68
54
  };
69
- useCountV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
55
+ useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
70
56
  data: number | undefined;
71
57
  isLoading: boolean;
72
58
  error?: any;
@@ -74,8 +60,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
74
60
  /**
75
61
  * Returns result size in bits
76
62
  */
77
- useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => string | undefined;
78
- useSizeV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
63
+ useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
79
64
  data: string | undefined;
80
65
  isLoading: boolean;
81
66
  error?: any;
@@ -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
@@ -708,22 +708,12 @@ function prostgles(initOpts, syncedTable) {
708
708
  };
709
709
  dboTable[command] = subFunc;
710
710
  const SUBONE = "subscribeOne";
711
- const startHook = function (param1 = {}, param2 = {}, onError) {
712
- return {
713
- start: (onChange) => {
714
- const changeFunc = command !== SUBONE ? onChange : (rows) => { onChange(rows[0]); };
715
- return subFunc(param1, param2, changeFunc, onError);
716
- },
717
- args: [param1, param2, onError]
718
- };
719
- };
720
711
  /**
721
712
  * React hooks
722
713
  */
723
714
  const handlerName = command === "subscribe" ? "useSubscribe" : command === "subscribeOne" ? "useSubscribeOne" : undefined;
724
715
  if (handlerName) {
725
- dboTable[handlerName] = (...args) => (0, react_hooks_1.useSubscribe)(startHook(...args));
726
- dboTable[handlerName + "V2"] = (filter, options) => (0, react_hooks_1.useSubscribeV2)(subFunc, command === SUBONE, filter, options);
716
+ dboTable[handlerName] = (filter, options) => (0, react_hooks_1.useSubscribe)(subFunc, command === SUBONE, filter, options);
727
717
  }
728
718
  if (command === SUBONE || !sub_commands.includes(SUBONE)) {
729
719
  dboTable[SUBONE] = async function (param1, param2, onChange, onError) {
@@ -751,8 +741,7 @@ function prostgles(initOpts, syncedTable) {
751
741
  dboTable[command] = method;
752
742
  const methodName = command === "findOne" ? "useFindOne" : command === "find" ? "useFind" : command === "count" ? "useCount" : command === "size" ? "useSize" : undefined;
753
743
  if (methodName) {
754
- dboTable[methodName] = (param1, param2, param3) => (0, react_hooks_1.usePromise)(() => method(param1, param2, param3), [param1, param2, param3]);
755
- dboTable[methodName + "V2"] = (param1, param2, param3) => (0, react_hooks_1.useFetch)(method, [param1, param2, param3]);
744
+ dboTable[methodName] = (param1, param2, param3) => (0, react_hooks_1.useFetch)(method, [param1, param2, param3]);
756
745
  }
757
746
  if (["find", "findOne"].includes(command)) {
758
747
  dboTable.getJoinedTables = function () {
@@ -14,11 +14,7 @@ export declare function useIsMounted(): any;
14
14
  type PromiseFunc = () => Promise<any>;
15
15
  type NamedResult = Record<string, PromiseFunc>;
16
16
  export declare const usePromise: <F extends PromiseFunc | NamedResult>(f: F, deps?: any[]) => F extends NamedResult ? { [key in keyof F]: Awaited<ReturnType<F[key]>>; } : F extends PromiseFunc ? Awaited<ReturnType<F>> | undefined : undefined;
17
- export declare const useSubscribe: <SubHook extends {
18
- start: (newData: any) => Promise<SubscriptionHandler>;
19
- args: any[];
20
- }>(subHook: SubHook) => Parameters<Parameters<SubHook["start"]>[0]>[0] | undefined;
21
- export declare const useSubscribeV2: (subFunc: (filter: any, options: any, onData: any, onError: any) => Promise<SubscriptionHandler>, expectsOne: boolean, filter: any, options: any) => {
17
+ export declare const useSubscribe: (subFunc: (filter: any, options: any, onData: any, onError: any) => Promise<SubscriptionHandler>, expectsOne: boolean, filter: any, options: any) => {
22
18
  data: any;
23
19
  error: any;
24
20
  isLoading: any;
@@ -1 +1 @@
1
- {"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,mBAAmB,EAAqB,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAMjD,eAAO,MAAM,QAAQ,gBAAiB,OAAO,KAAG,cAAc,OAAO,CAQpE,CAAC;AAIF,eAAO,MAAM,OAAO,6BAqBnB,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,GAAG,cAQ/C,CAAA;AAED,eAAO,MAAM,aAAa,oCAKzB,CAAA;AAgBD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,GAAG,EAAE,SAkD1F,CAAA;AACD,eAAO,MAAM,cAAc,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,UAAU,GAAG,EAAE,SAsBvF,CAAA;AAED,wBAAgB,YAAY,QAS3B;AAED,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;AACrC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,qDAAqD,GAAG,EAAE,wJA6ChF,CAAA;AAOD,eAAO,MAAM,YAAY;qBAJN,GAAG,KAAK,QAAQ,mBAAmB,CAAC;UAC/C,GAAG,EAAE;kFAmBZ,CAAA;AAOD,eAAO,MAAM,cAAc,qBACP,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,QAAQ,mBAAmB,CAAC,cACnF,OAAO,UACX,GAAG,WACF,GAAG;;;;CA8Bb,CAAA;AAED,eAAO,MAAM,OAAO,SACZ,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,kBAAkB,CAAC,CAAC,SAAS,CAAC,eACvE,WAAW,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eACnD,WAAW,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;;;;CA4BjE,CAAA;AAED,eAAO,MAAM,QAAQ,wBAAyB,GAAG,KAAK,QAAQ,GAAG,CAAC,SAAQ,GAAG,EAAE;;;;CAiB9E,CAAA;AAED,eAAO,MAAM,oBAAoB,eAAiC,CAAC"}
1
+ {"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,mBAAmB,EAAqB,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAMjD,eAAO,MAAM,QAAQ,gBAAiB,OAAO,KAAG,cAAc,OAAO,CAQpE,CAAC;AAIF,eAAO,MAAM,OAAO,6BAqBnB,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,GAAG,cAQ/C,CAAA;AAED,eAAO,MAAM,aAAa,oCAKzB,CAAA;AAgBD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,GAAG,EAAE,SAkD1F,CAAA;AACD,eAAO,MAAM,cAAc,WAAY,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,UAAU,GAAG,EAAE,SAsBvF,CAAA;AAED,wBAAgB,YAAY,QAS3B;AAED,KAAK,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;AACrC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAE/C,eAAO,MAAM,UAAU,qDAAqD,GAAG,EAAE,wJA6ChF,CAAA;AAOD,eAAO,MAAM,YAAY,qBACL,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,QAAQ,mBAAmB,CAAC,cACnF,OAAO,UACX,GAAG,WACF,GAAG;;;;CA8Bb,CAAA;AAED,eAAO,MAAM,OAAO,SACZ,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,kBAAkB,CAAC,CAAC,SAAS,CAAC,eACvE,WAAW,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eACnD,WAAW,SAAS,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;;;;CA4BjE,CAAA;AAED,eAAO,MAAM,QAAQ,wBAAyB,GAAG,KAAK,QAAQ,GAAG,CAAC,SAAQ,GAAG,EAAE;;;;CAiB9E,CAAA;AAED,eAAO,MAAM,oBAAoB,eAAiC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.__prglReactInstalled = exports.useFetch = exports.useSync = exports.useSubscribeV2 = exports.useSubscribe = exports.usePromise = exports.useIsMounted = exports.useEffectAsync = exports.useAsyncEffectQueue = exports.useEffectDeep = exports.useDeepCompareMemoize = exports.isEqual = exports.getReact = void 0;
4
+ exports.__prglReactInstalled = exports.useFetch = exports.useSync = exports.useSubscribe = exports.usePromise = exports.useIsMounted = exports.useEffectAsync = exports.useAsyncEffectQueue = exports.useEffectDeep = exports.useDeepCompareMemoize = exports.isEqual = exports.getReact = void 0;
5
5
  const prostgles_types_1 = require("prostgles-types");
6
6
  let React;
7
7
  const alertNoReact = (...args) => { throw "Must install react"; };
@@ -192,21 +192,7 @@ const usePromise = (f, deps = []) => {
192
192
  return result;
193
193
  };
194
194
  exports.usePromise = usePromise;
195
- const useSubscribe = (subHook) => {
196
- const [data, setData] = useState();
197
- const getIsMounted = useIsMounted();
198
- (0, exports.useAsyncEffectQueue)(async () => {
199
- const sub = await subHook.start(newData => {
200
- if (!getIsMounted())
201
- return;
202
- setData(newData);
203
- });
204
- return sub.unsubscribe;
205
- }, subHook.args);
206
- return data;
207
- };
208
- exports.useSubscribe = useSubscribe;
209
- const useSubscribeV2 = (subFunc, expectsOne, filter, options) => {
195
+ const useSubscribe = (subFunc, expectsOne, filter, options) => {
210
196
  const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
211
197
  const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
212
198
  const getIsMounted = useIsMounted();
@@ -233,7 +219,7 @@ const useSubscribeV2 = (subFunc, expectsOne, filter, options) => {
233
219
  }, [subFunc, filter, options]);
234
220
  return { data, error, isLoading };
235
221
  };
236
- exports.useSubscribeV2 = useSubscribeV2;
222
+ exports.useSubscribe = useSubscribe;
237
223
  const useSync = (sync, basicFilter, syncOptions) => {
238
224
  const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
239
225
  const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
package/lib/prostgles.ts CHANGED
@@ -22,7 +22,6 @@ import {
22
22
  FullFilter,
23
23
  GetSelectReturnType,
24
24
  MethodHandler,
25
- OnError,
26
25
  SQLHandler,
27
26
  SQLResult,
28
27
  SelectParams,
@@ -40,8 +39,8 @@ import {
40
39
  isObject
41
40
  } from "prostgles-types";
42
41
 
43
- import { SyncDataItem, SyncOptions, SyncedTable, type DbTableSync, type Sync, type SyncOne, SyncOneOptions } from "./SyncedTable";
44
- import { getReact, useAsyncEffectQueue, useFetch, useIsMounted, usePromise, useSubscribe, useSubscribeV2, useSync } from "./react-hooks";
42
+ import { SyncDataItem, SyncOneOptions, SyncOptions, SyncedTable, type DbTableSync, type Sync, type SyncOne } from "./SyncedTable";
43
+ import { getReact, useAsyncEffectQueue, useFetch, useIsMounted, useSubscribe, useSync } from "./react-hooks";
45
44
 
46
45
  const DEBUG_KEY = "DEBUG_SYNCEDTABLE";
47
46
  const hasWnd = typeof window !== "undefined";
@@ -108,37 +107,18 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
108
107
  error?: any;
109
108
  };
110
109
  _sync?: any;
111
- /**
112
- * Will return undefined while loading
113
- */
114
110
  useSubscribe: <SubParams extends SubscribeParams<T, S>>(
115
111
  filter?: FullFilter<T, S>,
116
112
  options?: SubParams,
117
- onError?: OnError
118
- ) => GetSelectReturnType<S, SubParams, T, false>[] | undefined;
119
- /**
120
- * Will return undefined while loading
121
- */
122
- useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(
123
- filter?: FullFilter<T, S>,
124
- options?: SubParams,
125
- onError?: OnError
126
- ) => GetSelectReturnType<S, SubParams, T, false> | undefined;
127
- /**
128
- * Will return undefined while loading
129
- */
130
- useSubscribeV2: <SubParams extends SubscribeParams<T, S>>(
131
- filter?: FullFilter<T, S>,
132
- options?: SubParams,
133
113
  ) => {
134
- data: GetSelectReturnType<S, SubParams, T, false>[] | undefined;
114
+ data: GetSelectReturnType<S, SubParams, T, true>[] | undefined;
135
115
  error?: any;
136
116
  isLoading: boolean;
137
117
  }
138
118
  /**
139
119
  * Will return undefined while loading
140
120
  */
141
- useSubscribeOneV2: <SubParams extends SubscribeParams<T, S>>(
121
+ useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(
142
122
  filter?: FullFilter<T, S>,
143
123
  options?: SubParams,
144
124
  ) => {
@@ -146,17 +126,13 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
146
126
  error?: any;
147
127
  isLoading: boolean;
148
128
  };
149
- useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => undefined | GetSelectReturnType<S, P, T, true>;
150
- useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => undefined | GetSelectReturnType<S, P, T, false>;
151
- useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => number | undefined;
152
- useFindV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: undefined | GetSelectReturnType<S, P, T, true>; isLoading: boolean; error?: any; };
153
- useFindOneV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: undefined | GetSelectReturnType<S, P, T, false>; isLoading: boolean; error?: any; };
154
- useCountV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: number | undefined; isLoading: boolean; error?: any; };
129
+ useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: undefined | GetSelectReturnType<S, P, T, true>; isLoading: boolean; error?: any; };
130
+ useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: undefined | GetSelectReturnType<S, P, T, false>; isLoading: boolean; error?: any; };
131
+ useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: number | undefined; isLoading: boolean; error?: any; };
155
132
  /**
156
133
  * Returns result size in bits
157
134
  */
158
- useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => string | undefined;
159
- useSizeV2: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: string | undefined; isLoading: boolean; error?: any; };
135
+ useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => { data: string | undefined; isLoading: boolean; error?: any; };
160
136
  }
161
137
 
162
138
  export type TableHandlerClient<T extends AnyObject = AnyObject, S extends DBSchema | void = void> = ViewHandlerClient<T, S> & TableHandler<T, S> & {
@@ -959,23 +935,13 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
959
935
  };
960
936
  dboTable[command] = subFunc;
961
937
  const SUBONE = "subscribeOne";
962
- const startHook = function (param1 = {}, param2 = {}, onError?) {
963
- return {
964
- start: (onChange: any) => {
965
- const changeFunc = command !== SUBONE? onChange : (rows) => { onChange(rows[0]); };
966
- return subFunc(param1, param2, changeFunc, onError);
967
- },
968
- args: [param1, param2, onError]
969
- }
970
- }
971
-
938
+
972
939
  /**
973
940
  * React hooks
974
941
  */
975
942
  const handlerName = command === "subscribe" ? "useSubscribe" : command === "subscribeOne"? "useSubscribeOne" : undefined;
976
943
  if(handlerName){
977
- dboTable[handlerName] = (...args) => useSubscribe(startHook(...args) as any)
978
- dboTable[handlerName + "V2"] = (filter, options) => useSubscribeV2(subFunc, command === SUBONE, filter, options)
944
+ dboTable[handlerName] = (filter, options) => useSubscribe(subFunc, command === SUBONE, filter, options)
979
945
  }
980
946
 
981
947
  if (command === SUBONE || !sub_commands.includes(SUBONE)) {
@@ -1006,8 +972,7 @@ export function prostgles<DBSchema>(initOpts: InitOptions<DBSchema>, syncedTable
1006
972
 
1007
973
  const methodName = command === "findOne" ? "useFindOne" : command === "find" ? "useFind" : command === "count" ? "useCount" : command === "size" ? "useSize" : undefined;
1008
974
  if(methodName){
1009
- dboTable[methodName] = (param1, param2, param3?) => usePromise(() => method(param1, param2, param3) as any, [param1, param2, param3]);
1010
- dboTable[methodName + "V2"] = (param1, param2, param3?) => useFetch(method, [param1, param2, param3]);
975
+ dboTable[methodName] = (param1, param2, param3?) => useFetch(method, [param1, param2, param3]);
1011
976
  }
1012
977
  if (["find", "findOne"].includes(command)) {
1013
978
  dboTable.getJoinedTables = function () {
@@ -211,35 +211,12 @@ export const usePromise = <F extends PromiseFunc | NamedResult>(f: F, deps: any[
211
211
  return result as any;
212
212
  }
213
213
 
214
- type SubHooks = (param1?: {}, param2?: {}, onError?: any) => {
215
- start: (newData: any) => Promise<SubscriptionHandler>;
216
- args: any[];
217
- };
218
-
219
- export const useSubscribe = <SubHook extends ReturnType<SubHooks>>(
220
- subHook: SubHook
221
- ): undefined | Parameters<Parameters<SubHook["start"]>[0]>[0] => {
222
- const [data, setData] = useState<undefined | Parameters<Parameters<SubHook["start"]>[0]>[0]>();
223
-
224
- const getIsMounted = useIsMounted();
225
- useAsyncEffectQueue(async () => {
226
- const sub = await subHook.start(newData => {
227
- if (!getIsMounted()) return;
228
- setData(newData);
229
- });
230
-
231
- return sub.unsubscribe;
232
- }, subHook.args);
233
-
234
- return data;
235
- }
236
-
237
214
  type HookResult =
238
215
  | { data: any; error?: undefined; isLoading: false; }
239
216
  | { data?: undefined; error: any; isLoading: false; }
240
217
  | { data?: undefined; error?: undefined; isLoading: true; };
241
218
 
242
- export const useSubscribeV2 = (
219
+ export const useSubscribe = (
243
220
  subFunc: (filter: any, options: any, onData: any, onError: any) => Promise<SubscriptionHandler>,
244
221
  expectsOne: boolean,
245
222
  filter: any,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-client",
3
- "version": "4.0.88",
3
+ "version": "4.0.90",
4
4
  "description": "Reactive client for Postgres",
5
5
  "main": "dist/prostgles-full.js",
6
6
  "types": "dist/prostgles-full.d.ts",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "..": {
19
19
  "name": "prostgles-client",
20
- "version": "4.0.87",
20
+ "version": "4.0.89",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "prostgles-types": "^4.0.73"