tinybase 5.2.1 → 5.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/es6/min/ui-react/index.cjs +1 -1
- package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react-inspector/index.cjs +1 -1
- package/cjs/es6/min/ui-react-inspector/index.cjs.gz +0 -0
- package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
- package/cjs/es6/ui-react/index.cjs +10 -1
- package/cjs/es6/ui-react/with-schemas/index.cjs +10 -1
- package/cjs/es6/ui-react-inspector/index.cjs +1 -1
- package/cjs/es6/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/cjs/min/ui-react/index.cjs +1 -1
- package/cjs/min/ui-react/index.cjs.gz +0 -0
- package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
- package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
- package/cjs/min/ui-react-inspector/index.cjs +1 -1
- package/cjs/min/ui-react-inspector/index.cjs.gz +0 -0
- package/cjs/min/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/cjs/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
- package/cjs/ui-react/index.cjs +10 -1
- package/cjs/ui-react/with-schemas/index.cjs +10 -1
- package/cjs/ui-react-inspector/index.cjs +1 -1
- package/cjs/ui-react-inspector/with-schemas/index.cjs +1 -1
- package/es6/min/ui-react/index.js +1 -1
- package/es6/min/ui-react/index.js.gz +0 -0
- package/es6/min/ui-react/with-schemas/index.js +1 -1
- package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/index.js +1 -1
- package/es6/min/ui-react-inspector/index.js.gz +0 -0
- package/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/es6/ui-react/index.js +10 -1
- package/es6/ui-react/with-schemas/index.js +10 -1
- package/es6/ui-react-inspector/index.js +1 -1
- package/es6/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react/index.js +1 -1
- package/min/ui-react/index.js.gz +0 -0
- package/min/ui-react/with-schemas/index.js +1 -1
- package/min/ui-react/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/package.json +1 -1
- package/readme.md +13 -13
- package/releases.md +23 -23
- package/ui-react/index.js +10 -1
- package/ui-react/with-schemas/index.js +10 -1
- package/ui-react-inspector/index.js +1 -1
- package/ui-react-inspector/with-schemas/index.js +1 -1
- package/umd/es6/min/ui-react/index.js +1 -1
- package/umd/es6/min/ui-react/index.js.gz +0 -0
- package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
- package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
- package/umd/es6/min/ui-react-inspector/index.js +1 -1
- package/umd/es6/min/ui-react-inspector/index.js.gz +0 -0
- package/umd/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/umd/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/umd/es6/ui-react/index.js +12 -1
- package/umd/es6/ui-react/with-schemas/index.js +12 -1
- package/umd/es6/ui-react-inspector/index.js +2 -1
- package/umd/es6/ui-react-inspector/with-schemas/index.js +2 -1
- package/umd/min/ui-react/index.js +1 -1
- package/umd/min/ui-react/index.js.gz +0 -0
- package/umd/min/ui-react/with-schemas/index.js +1 -1
- package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
- package/umd/min/ui-react-inspector/index.js +1 -1
- package/umd/min/ui-react-inspector/index.js.gz +0 -0
- package/umd/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/umd/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/umd/ui-react/index.js +12 -1
- package/umd/ui-react/with-schemas/index.js +12 -1
- package/umd/ui-react-inspector/index.js +2 -1
- package/umd/ui-react-inspector/with-schemas/index.js +2 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const getTypeOf = (thing) => typeof thing;
|
|
6
|
+
const TINYBASE = 'tinybase';
|
|
6
7
|
const EMPTY_STRING = '';
|
|
7
8
|
const STRING = getTypeOf(EMPTY_STRING);
|
|
8
9
|
const FUNCTION = getTypeOf(getTypeOf);
|
|
@@ -26,6 +27,7 @@ const VALUE = 'Value';
|
|
|
26
27
|
const VALUES = VALUE + 's';
|
|
27
28
|
const VALUE_IDS = VALUE + IDS;
|
|
28
29
|
|
|
30
|
+
const GLOBAL = globalThis;
|
|
29
31
|
const isUndefined = (thing) => thing == void 0;
|
|
30
32
|
const ifNotUndefined = (value, then, otherwise) =>
|
|
31
33
|
isUndefined(value) ? (otherwise == null ? void 0 : otherwise()) : then(value);
|
|
@@ -59,6 +61,7 @@ const isObject = (obj) =>
|
|
|
59
61
|
);
|
|
60
62
|
const objIds = object.keys;
|
|
61
63
|
const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
|
|
64
|
+
const objHas = (obj, id) => id in obj;
|
|
62
65
|
const objDel = (obj, id) => {
|
|
63
66
|
delete obj[id];
|
|
64
67
|
return obj;
|
|
@@ -77,9 +80,15 @@ const objIsEqual = (obj1, obj2) => {
|
|
|
77
80
|
)
|
|
78
81
|
);
|
|
79
82
|
};
|
|
83
|
+
const objEnsure = (obj, id, getDefaultValue) => {
|
|
84
|
+
if (!objHas(obj, id)) {
|
|
85
|
+
obj[id] = getDefaultValue();
|
|
86
|
+
}
|
|
87
|
+
return obj[id];
|
|
88
|
+
};
|
|
80
89
|
|
|
81
90
|
const {createContext, useContext: useContext$1, useEffect: useEffect$1} = React;
|
|
82
|
-
const Context = createContext([]);
|
|
91
|
+
const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () => createContext([]));
|
|
83
92
|
const useThing = (id, offset) => {
|
|
84
93
|
var _a;
|
|
85
94
|
const contextValue = useContext$1(Context);
|
|
@@ -162,7 +162,7 @@ const POSITION_VALUE = 'position';
|
|
|
162
162
|
const OPEN_VALUE = OPEN_CELL;
|
|
163
163
|
const EDITABLE_CELL = 'editable';
|
|
164
164
|
const getUniqueId = (...args) => jsonStringWithMap(args);
|
|
165
|
-
const sortedIdsMap = (ids, callback) => arrayMap(arraySort(ids), callback);
|
|
165
|
+
const sortedIdsMap = (ids, callback) => arrayMap(arraySort([...ids]), callback);
|
|
166
166
|
const useEditable = (uniqueId, s) => [
|
|
167
167
|
!!uiReact.useCell(STATE_TABLE, uniqueId, EDITABLE_CELL, s),
|
|
168
168
|
useCallback$1(
|
|
@@ -162,7 +162,7 @@ const POSITION_VALUE = 'position';
|
|
|
162
162
|
const OPEN_VALUE = OPEN_CELL;
|
|
163
163
|
const EDITABLE_CELL = 'editable';
|
|
164
164
|
const getUniqueId = (...args) => jsonStringWithMap(args);
|
|
165
|
-
const sortedIdsMap = (ids, callback) => arrayMap(arraySort(ids), callback);
|
|
165
|
+
const sortedIdsMap = (ids, callback) => arrayMap(arraySort([...ids]), callback);
|
|
166
166
|
const useEditable = (uniqueId, s) => [
|
|
167
167
|
!!uiReact.useCell(STATE_TABLE, uniqueId, EDITABLE_CELL, s),
|
|
168
168
|
useCallback$1(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r=s(s),u="Listener",l="Result",n="Has",d="Ids",p="Table",a=p+"s",i=p+d,x="Row",c=x+"Count",I=x+d,C="Sorted"+x+d,b="Cell",w=b+d,R="Value",k=R+"s",g=R+d,L=e=>null==e,h=(e,s,t)=>L(e)?t?.():s(e),y=e=>s(e)==o,m=e=>s(e)==r,S=e=>e.length,V=()=>{},T=(e,s)=>e.every(s),v=(e,s)=>S(e)===S(s)&&T(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),f=Object,q=e=>f.getPrototypeOf(e),B=f.entries,H=e=>!L(e)&&h(q(e),(e=>e==f.prototype||L(q(e))),(()=>!0)),M=f.keys,D=(e,s)=>h(e,(e=>e[s])),F=(e,s)=>(delete e[s],e),O=(e,s)=>{const t=B(e);return S(t)===S(M(s))&&T(t,(([e,t])=>H(t)?!!H(s[e])&&O(s[e],t):s[e]===t))},{createContext:Q,useContext:E,useEffect:A}=e,G=Q([]),W=(e,s)=>{const t=E(G);return L(e)?t[s]:y(e)?D(t[s+1]??{},e):e},j=(e,s)=>{const t=W(e,s);return L(e)||y(e)?t:e},z=e=>M(E(G)[e]??{}),U=e=>j(e,0),J=e=>j(e,2),K=e=>j(e,4),N=e=>j(e,6),X=e=>j(e,8),Y=e=>j(e,10),Z=e=>e.toLowerCase();Z(u);const $="Transaction";Z($);const{useCallback:_,useEffect:ee,useMemo:se,useLayoutEffect:te,useRef:oe,useState:re,useSyncExternalStore:ue}=e,le=[],ne=[{},[],[le,void 0,le],void 0,!1,0],de=[O,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],pe=(e,s)=>e===s,ae=(e,s,t=le)=>{const[,o]=re(),[r,u]=re();return ee((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},ie=(e,s,...t)=>{const o=e?.["add"+s+u]?.(...t);return()=>e?.delListener(o)},xe=(e,s,o,r=le)=>{const u=oe(ne[o]),l=_((()=>{const t=s?.[(4==o?"has":"get")+e]?.(...r)??ne[o];return(de[o]??pe)(t,u.current)?u.current:u.current=t}),[s,o,e,...r]),d=_((u=>ie(s,(4==o?n:t)+e,...r,u)),[s,o,e,...r]);return ue(d,l)},ce=(e,s,t,o=le,r=le,...u)=>te((()=>ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),Ie=(e,s,t,o=le,r=V,u=le,...l)=>{const n=U(e);return _((e=>h(n,(o=>h(t(e,o),(t=>r(o["set"+s](...Ce(l,o,e),t),t)))))),[n,s,...o,...u,...be(l)])},Ce=(e,s,t)=>P(e,(e=>m(e)?e(t,s):e)),be=e=>{return s=e=>!m(e),e.filter(s);var s},we=(e,s,t=V,o=le,...r)=>{const u=U(e);return _((e=>t(u?.["del"+s](...Ce(r,u,e)))),[u,s,...o,...be(r)])},Re=(e,s,t)=>{const o=Y(e);return _((()=>o?.[s](t)),[o,s,t])},ke=e=>xe(i,U(e),1),ge=(e,s)=>xe(I,U(s),1,[e]),Le=(e,s,t,o=0,r,u)=>xe(C,U(u),1,[e,s,t,o,r]),he=(e,s,t)=>xe(w,U(t),1,[e,s]),ye=(e,s,t,o)=>xe(b,U(o),3,[e,s,t]),me=e=>xe(g,U(e),1),Se=(e,s)=>xe(R,U(s),3,[e]),Ve=(e,s)=>xe("Metric",J(s),3,[e]),Te=(e,s)=>xe("SliceIds",K(s),1,[e]),ve=(e,s,t)=>xe("Slice"+I,K(t),1,[e,s]),Pe=(e,s,t)=>xe("RemoteRowId",N(t),3,[e,s]),fe=(e,s,t)=>xe("Local"+I,N(t),1,[e,s]),qe=(e,s,t)=>xe("Linked"+I,N(t),1,[e,s]),Be=(e,s)=>xe(l+I,X(s),1,[e]),He=(e,s,t,o=0,r,u)=>xe(l+C,X(u),1,[e,s,t,o,r]),Me=(e,s,t)=>xe(l+w,X(t),1,[e,s]),De=(e,s,t,o)=>xe(l+b,X(o),3,[e,s,t]),Fe=e=>xe("CheckpointIds",Y(e),2),Oe=(e,s)=>xe("Checkpoint",Y(s),3,[e]),Qe=e=>Re(e,"goBackward"),Ee=e=>Re(e,"goForward"),{PureComponent:Ae,Fragment:Ge,createElement:We,useCallback:je,useLayoutEffect:ze,useRef:Ue,useState:Je}=e,Ke=(e,...s)=>L(e)?{}:e(...s),Ne=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Xe,useContext:Ye,useMemo:Ze,useState:$e}=e,_e=({tableId:e,store:s,rowComponent:t=us,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>os(P(n,(u=>We(t,{...Ke(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),es=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>os(P(l,(r=>We(t,{...Ke(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ss=({relationshipId:e,relationships:s,rowComponent:t=us,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,p,a]=Ne(N(s),e),i=l(e,n,d);return os(P(i,(e=>We(t,{...Ke(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:u}))),r,u,n)},ts=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Y(s);return os(P(e(Fe(l)),(e=>We(t,{...Ke(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},os=(e,s,t,o)=>{const r=L(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},rs=({tableId:e,rowId:s,cellId:o,store:r,debugIds:u})=>os(t+(ye(e,s,o,r)??t),void 0,u,o),us=({tableId:e,rowId:s,store:t,cellComponent:o=rs,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>os(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>We(o,{...Ke(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ls=e=>_e(e,ge(e.tableId,e.store)),ns=({valueId:e,store:s,debugIds:o})=>os(t+(Se(e,s)??t),void 0,o,e),ds=({indexId:e,sliceId:s,indexes:t,rowComponent:o=us,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,p]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(K(t),e),a=ve(e,s,n);return os(P(a,(e=>We(o,{...Ke(r,e),key:e,tableId:p,rowId:e,store:d,debugIds:l}))),u,l,s)},ps=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:u})=>os(t+(De(e,s,o,r)??t),void 0,u,o),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ps,getResultCellComponentProps:r,separator:u,debugIds:l})=>os(P(Me(e,s,t),(u=>We(o,{...Ke(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:o})=>os(Oe(s,e)??t,void 0,o,s),xs=ts((e=>e[0])),cs=ts((e=>L(e[1])?[]:[e[1]])),Is=ts((e=>e[2]));exports.BackwardCheckpointsView=xs,exports.CellView=rs,exports.CheckpointView=is,exports.CurrentCheckpointView=cs,exports.ForwardCheckpointsView=Is,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=ds,getSliceComponentProps:o,separator:r,debugIds:u})=>os(P(Te(e,s),(r=>We(t,{...Ke(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),exports.LinkedRowsView=e=>ss(e,qe,e.firstRowId),exports.LocalRowsView=e=>ss(e,fe,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>os(Ve(e,s)??t,void 0,o,e),exports.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:p,checkpoints:a,checkpointsById:i,children:x})=>{const c=Ye(G),[I,C]=$e({}),b=Xe(((e,s)=>C((t=>D(t,e)==s?t:{...t,[e]:s}))),[]),w=Xe((e=>C((s=>({...F(s,e)})))),[]);return We(G.Provider,{value:Ze((()=>[e??c[0],{...c[1],...s,...I},t??c[2],{...c[3],...o},r??c[4],{...c[5],...u},l??c[6],{...c[7],...n},d??c[8],{...c[9],...p},a??c[10],{...c[11],...i},b,w]),[e,s,I,t,o,r,u,l,n,d,p,a,i,c,b,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=us,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ne(N(t),e),p=Pe(e,s,l);return os(L(d)||L(p)?null:We(o,{...Ke(r,p),key:p,tableId:d,rowId:p,store:n,debugIds:u}),void 0,u,s)},exports.ResultCellView=ps,exports.ResultRowView=as,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,He(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>es(e,Be(e.queryId,e.queries)),exports.RowView=us,exports.SliceView=ds,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Le(r.tableId,e,s,t,o,r.store)),exports.TableView=ls,exports.TablesView=({store:e,tableComponent:s=ls,getTableComponentProps:t,separator:o,debugIds:r})=>os(P(ke(e),(o=>We(s,{...Ke(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=ns,exports.ValuesView=({store:e,valueComponent:s=ns,getValueComponentProps:t,separator:o,debugIds:r})=>os(P(me(e),(o=>We(s,{...Ke(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.useAddRowCallback=(e,s,t=le,o,r=V,u=le,l=!0)=>{const n=U(o);return _((t=>h(n,(o=>h(s(t,o),(s=>r(o.addRow(m(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},exports.useCell=ye,exports.useCellIds=he,exports.useCellIdsListener=(e,s,t,o,r,u)=>ce(w,U(u),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,u,l)=>ce(b,U(l),o,r,[e,s,t],u),exports.useCheckpoint=Oe,exports.useCheckpointIds=Fe,exports.useCheckpointIdsListener=(e,s,t)=>ce("CheckpointIds",Y(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>ce("Checkpoint",Y(o),s,t,[e]),exports.useCheckpoints=e=>W(e,10),exports.useCheckpointsIds=()=>z(11),exports.useCheckpointsOrCheckpointsById=Y,exports.useCreateCheckpoints=(e,s,t)=>ae(e,s,t),exports.useCreateIndexes=(e,s,t)=>ae(e,s,t),exports.useCreateMergeableStore=(e,s=le)=>se(e,s),exports.useCreateMetrics=(e,s,t)=>ae(e,s,t),exports.useCreatePersister=(e,s,t=le,o,r=le,u,l=le)=>{const[,n]=re(),[d,p]=re();return ee((()=>{(async()=>{const t=e?await s(e):void 0;p(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ee((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},exports.useCreateQueries=(e,s,t)=>ae(e,s,t),exports.useCreateRelationships=(e,s,t)=>ae(e,s,t),exports.useCreateStore=(e,s=le)=>se(e,s),exports.useCreateSynchronizer=(e,s,t=le,o,r=le)=>{const[u,l]=re();return ee((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ee((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},exports.useDelCellCallback=(e,s,t,o,r,u,l)=>we(r,b,u,l,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>we(t,x,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>we(s,p,t,o,e),exports.useDelTablesCallback=(e,s,t)=>we(e,a,s,t),exports.useDelValueCallback=(e,s,t,o)=>we(s,R,t,o,e),exports.useDelValuesCallback=(e,s,t)=>we(e,k,s,t),exports.useDidFinishTransactionListener=(e,s,t)=>ce("DidFinish"+$,U(t),e,s),exports.useGoBackwardCallback=Qe,exports.useGoForwardCallback=Ee,exports.useGoToCallback=(e,s=le,t,o=V,r=le)=>{const u=Y(t);return _((s=>h(u,(t=>h(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},exports.useHasCell=(e,s,t,o)=>xe(b,U(o),4,[e,s,t]),exports.useHasCellListener=(e,s,t,o,r,u,l)=>ce(n+b,U(l),o,r,[e,s,t],u),exports.useHasRow=(e,s,t)=>xe(x,U(t),4,[e,s]),exports.useHasRowListener=(e,s,t,o,r,u)=>ce(n+x,U(u),t,o,[e,s],r),exports.useHasTable=(e,s)=>xe(p,U(s),4,[e]),exports.useHasTableCell=(e,s,t)=>xe(p+b,U(t),4,[e,s]),exports.useHasTableCellListener=(e,s,t,o,r,u)=>ce(n+p+b,U(u),t,o,[e,s],r),exports.useHasTableListener=(e,s,t,o,r)=>ce(n+p,U(r),s,t,[e],o),exports.useHasTables=e=>xe(a,U(e),4,[]),exports.useHasTablesListener=(e,s,t,o)=>ce(n+a,U(o),e,s,[],t),exports.useHasValue=(e,s)=>xe(R,U(s),4,[e]),exports.useHasValueListener=(e,s,t,o,r)=>ce(n+R,U(r),s,t,[e],o),exports.useHasValues=e=>xe(k,U(e),4,[]),exports.useHasValuesListener=(e,s,t,o)=>ce(n+k,U(o),e,s,[],t),exports.useIndexIds=e=>xe("IndexIds",K(e),1),exports.useIndexes=e=>W(e,4),exports.useIndexesIds=()=>z(5),exports.useIndexesOrIndexesById=K,exports.useLinkedRowIds=qe,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>ce("Linked"+I,N(r),t,o,[e,s]),exports.useLocalRowIds=fe,exports.useLocalRowIdsListener=(e,s,t,o,r)=>ce("Local"+I,N(r),t,o,[e,s]),exports.useMetric=Ve,exports.useMetricIds=e=>xe("MetricIds",J(e),1),exports.useMetricListener=(e,s,t,o)=>ce("Metric",J(o),s,t,[e]),exports.useMetrics=e=>W(e,2),exports.useMetricsIds=()=>z(3),exports.useMetricsOrMetricsById=J,exports.useProvideStore=(e,s)=>{const{12:t,13:o}=E(G);A((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},exports.useQueries=e=>W(e,8),exports.useQueriesIds=()=>z(9),exports.useQueriesOrQueriesById=X,exports.useQueryIds=e=>xe("QueryIds",X(e),1),exports.useRedoInformation=e=>{const s=Y(e),[,,[o]]=Fe(s);return[!L(o),Ee(s),o,h(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationshipIds=e=>xe("RelationshipIds",N(e),1),exports.useRelationships=e=>W(e,6),exports.useRelationshipsIds=()=>z(7),exports.useRelationshipsOrRelationshipsById=N,exports.useRemoteRowId=Pe,exports.useRemoteRowIdListener=(e,s,t,o,r)=>ce("RemoteRowId",N(r),t,o,[e,s]),exports.useResultCell=De,exports.useResultCellIds=Me,exports.useResultCellIdsListener=(e,s,t,o,r)=>ce(l+w,X(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,u)=>ce(l+b,X(u),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>xe(l+x,X(t),0,[e,s]),exports.useResultRowCount=(e,s)=>xe(l+c,X(s),5,[e]),exports.useResultRowCountListener=(e,s,t,o)=>ce(l+c,X(o),s,t,[e]),exports.useResultRowIds=Be,exports.useResultRowIdsListener=(e,s,t,o)=>ce(l+I,X(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>ce(l+x,X(r),t,o,[e,s]),exports.useResultSortedRowIds=He,exports.useResultSortedRowIdsListener=(e,s,t,o,r,u,n,d)=>ce(l+C,X(d),u,n,[e,s,t,o,r]),exports.useResultTable=(e,s)=>xe(l+p,X(s),0,[e]),exports.useResultTableCellIds=(e,s)=>xe(l+p+w,X(s),1,[e]),exports.useResultTableCellIdsListener=(e,s,t,o)=>ce(l+p+w,X(o),s,t,[e]),exports.useResultTableListener=(e,s,t,o)=>ce(l+p,X(o),s,t,[e]),exports.useRow=(e,s,t)=>xe(x,U(t),0,[e,s]),exports.useRowCount=(e,s)=>xe(c,U(s),5,[e]),exports.useRowCountListener=(e,s,t,o,r)=>ce(c,U(r),s,t,[e],o),exports.useRowIds=ge,exports.useRowIdsListener=(e,s,t,o,r)=>ce(I,U(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,u)=>ce(x,U(u),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,u,l,n)=>Ie(u,b,o,r,l,n,e,s,t),exports.useSetCheckpointCallback=(e=V,s=le,t,o=V,r=le)=>{const u=Y(t);return _((s=>h(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>Ie(r,"PartialRow",t,o,u,l,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Ie(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,u,l)=>Ie(r,x,t,o,u,l,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Ie(o,p,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Ie(t,a,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,u)=>Ie(o,R,s,t,r,u,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Ie(t,k,e,s,o,r),exports.useSliceIds=Te,exports.useSliceIdsListener=(e,s,t,o)=>ce("SliceIds",K(o),s,t,[e]),exports.useSliceRowIds=ve,exports.useSliceRowIdsListener=(e,s,t,o,r)=>ce("Slice"+I,K(r),t,o,[e,s]),exports.useSortedRowIds=Le,exports.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ce(C,U(d),u,l,[e,s,t,o,r],n),exports.useStartTransactionListener=(e,s,t)=>ce("Start"+$,U(t),e,s),exports.useStore=e=>W(e,0),exports.useStoreIds=()=>z(1),exports.useStoreOrStoreById=U,exports.useTable=(e,s)=>xe(p,U(s),0,[e]),exports.useTableCellIds=(e,s)=>xe(p+w,U(s),1,[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>ce(p+w,U(r),s,t,[e],o),exports.useTableIds=ke,exports.useTableIdsListener=(e,s,t,o)=>ce(i,U(o),e,s,le,t),exports.useTableListener=(e,s,t,o,r)=>ce(p,U(r),s,t,[e],o),exports.useTables=e=>xe(a,U(e),0),exports.useTablesListener=(e,s,t,o)=>ce(a,U(o),e,s,le,t),exports.useUndoInformation=e=>{const s=Y(e),[o,r]=Fe(s);return[(u=o,!(0==S(u))),Qe(s),r,h(r,(e=>s?.getCheckpoint(e)))??t];var u},exports.useValue=Se,exports.useValueIds=me,exports.useValueIdsListener=(e,s,t,o)=>ce(g,U(o),e,s,le,t),exports.useValueListener=(e,s,t,o,r)=>ce(R,U(r),s,t,[e],o),exports.useValues=e=>xe(k,U(e),0),exports.useValuesListener=(e,s,t,o)=>ce(k,U(o),e,s,le,t),exports.useWillFinishTransactionListener=(e,s,t)=>ce("WillFinish"+$,U(t),e,s);
|
|
1
|
+
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r=s(s),u="Listener",l="Result",n="Has",d="Ids",p="Table",a=p+"s",i=p+d,x="Row",c=x+"Count",I=x+d,C="Sorted"+x+d,b="Cell",w=b+d,R="Value",k=R+"s",g=R+d,L=globalThis,h=e=>null==e,y=(e,s,t)=>h(e)?t?.():s(e),m=e=>s(e)==o,S=e=>s(e)==r,V=e=>e.length,T=()=>{},v=(e,s)=>e.every(s),P=(e,s)=>V(e)===V(s)&&v(e,((e,t)=>s[t]===e)),f=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!h(e)&&y(B(e),(e=>e==q.prototype||h(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>y(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&v(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=e,W=(U=()=>E([]),((e,s)=>s in e)(j=L,z="tinybase_uirc")||(j[z]=U()),j[z]);var j,z,U;const _=(e,s)=>{const t=A(W);return h(e)?t[s]:m(e)?F(t[s+1]??{},e):e},J=(e,s)=>{const t=_(e,s);return h(e)||m(e)?t:e},K=e=>D(A(W)[e]??{}),N=e=>J(e,0),X=e=>J(e,2),Y=e=>J(e,4),Z=e=>J(e,6),$=e=>J(e,8),ee=e=>J(e,10),se=e=>e.toLowerCase();se(u);const te="Transaction";se(te);const{useCallback:oe,useEffect:re,useMemo:ue,useLayoutEffect:le,useRef:ne,useState:de,useSyncExternalStore:pe}=e,ae=[],ie=[{},[],[ae,void 0,ae],void 0,!1,0],xe=[Q,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],ce=(e,s)=>e===s,Ie=(e,s,t=ae)=>{const[,o]=de(),[r,u]=de();return re((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ce=(e,s,...t)=>{const o=e?.["add"+s+u]?.(...t);return()=>e?.delListener(o)},be=(e,s,o,r=ae)=>{const u=ne(ie[o]),l=oe((()=>{const t=s?.[(4==o?"has":"get")+e]?.(...r)??ie[o];return(xe[o]??ce)(t,u.current)?u.current:u.current=t}),[s,o,e,...r]),d=oe((u=>Ce(s,(4==o?n:t)+e,...r,u)),[s,o,e,...r]);return pe(d,l)},we=(e,s,t,o=ae,r=ae,...u)=>le((()=>Ce(s,e,...r,t,...u)),[s,e,...r,...o,...u]),Re=(e,s,t,o=ae,r=T,u=ae,...l)=>{const n=N(e);return oe((e=>y(n,(o=>y(t(e,o),(t=>r(o["set"+s](...ke(l,o,e),t),t)))))),[n,s,...o,...u,...ge(l)])},ke=(e,s,t)=>f(e,(e=>S(e)?e(t,s):e)),ge=e=>{return s=e=>!S(e),e.filter(s);var s},Le=(e,s,t=T,o=ae,...r)=>{const u=N(e);return oe((e=>t(u?.["del"+s](...ke(r,u,e)))),[u,s,...o,...ge(r)])},he=(e,s,t)=>{const o=ee(e);return oe((()=>o?.[s](t)),[o,s,t])},ye=e=>be(i,N(e),1),me=(e,s)=>be(I,N(s),1,[e]),Se=(e,s,t,o=0,r,u)=>be(C,N(u),1,[e,s,t,o,r]),Ve=(e,s,t)=>be(w,N(t),1,[e,s]),Te=(e,s,t,o)=>be(b,N(o),3,[e,s,t]),ve=e=>be(g,N(e),1),Pe=(e,s)=>be(R,N(s),3,[e]),fe=(e,s)=>be("Metric",X(s),3,[e]),qe=(e,s)=>be("SliceIds",Y(s),1,[e]),Be=(e,s,t)=>be("Slice"+I,Y(t),1,[e,s]),He=(e,s,t)=>be("RemoteRowId",Z(t),3,[e,s]),Me=(e,s,t)=>be("Local"+I,Z(t),1,[e,s]),De=(e,s,t)=>be("Linked"+I,Z(t),1,[e,s]),Fe=(e,s)=>be(l+I,$(s),1,[e]),Oe=(e,s,t,o=0,r,u)=>be(l+C,$(u),1,[e,s,t,o,r]),Qe=(e,s,t)=>be(l+w,$(t),1,[e,s]),Ee=(e,s,t,o)=>be(l+b,$(o),3,[e,s,t]),Ae=e=>be("CheckpointIds",ee(e),2),Ge=(e,s)=>be("Checkpoint",ee(s),3,[e]),We=e=>he(e,"goBackward"),je=e=>he(e,"goForward"),{PureComponent:ze,Fragment:Ue,createElement:_e,useCallback:Je,useLayoutEffect:Ke,useRef:Ne,useState:Xe}=e,Ye=(e,...s)=>h(e)?{}:e(...s),Ze=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:$e,useContext:es,useMemo:ss,useState:ts}=e,os=({tableId:e,store:s,rowComponent:t=ps,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ns(f(n,(u=>_e(t,{...Ye(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),rs=({queryId:e,queries:s,resultRowComponent:t=Is,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ns(f(l,(r=>_e(t,{...Ye(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),us=({relationshipId:e,relationships:s,rowComponent:t=ps,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,p,a]=Ze(Z(s),e),i=l(e,n,d);return ns(f(i,(e=>_e(t,{...Ye(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:u}))),r,u,n)},ls=e=>({checkpoints:s,checkpointComponent:t=Cs,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=ee(s);return ns(f(e(Ae(l)),(e=>_e(t,{...Ye(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ns=(e,s,t,o)=>{const r=h(s)||!Array.isArray(e)?e:f(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},ds=({tableId:e,rowId:s,cellId:o,store:r,debugIds:u})=>ns(t+(Te(e,s,o,r)??t),void 0,u,o),ps=({tableId:e,rowId:s,store:t,cellComponent:o=ds,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ns(f(((e,s,t,o)=>{const r=Ve(s,t,o);return e??r})(u,e,s,t),(u=>_e(o,{...Ye(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),as=e=>os(e,me(e.tableId,e.store)),is=({valueId:e,store:s,debugIds:o})=>ns(t+(Pe(e,s)??t),void 0,o,e),xs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ps,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,p]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Y(t),e),a=Be(e,s,n);return ns(f(a,(e=>_e(o,{...Ye(r,e),key:e,tableId:p,rowId:e,store:d,debugIds:l}))),u,l,s)},cs=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:u})=>ns(t+(Ee(e,s,o,r)??t),void 0,u,o),Is=({queryId:e,rowId:s,queries:t,resultCellComponent:o=cs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ns(f(Qe(e,s,t),(u=>_e(o,{...Ye(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Cs=({checkpoints:e,checkpointId:s,debugIds:o})=>ns(Ge(s,e)??t,void 0,o,s),bs=ls((e=>e[0])),ws=ls((e=>h(e[1])?[]:[e[1]])),Rs=ls((e=>e[2]));exports.BackwardCheckpointsView=bs,exports.CellView=ds,exports.CheckpointView=Cs,exports.CurrentCheckpointView=ws,exports.ForwardCheckpointsView=Rs,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=xs,getSliceComponentProps:o,separator:r,debugIds:u})=>ns(f(qe(e,s),(r=>_e(t,{...Ye(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),exports.LinkedRowsView=e=>us(e,De,e.firstRowId),exports.LocalRowsView=e=>us(e,Me,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>ns(fe(e,s)??t,void 0,o,e),exports.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:p,checkpoints:a,checkpointsById:i,children:x})=>{const c=es(W),[I,C]=ts({}),b=$e(((e,s)=>C((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),w=$e((e=>C((s=>({...O(s,e)})))),[]);return _e(W.Provider,{value:ss((()=>[e??c[0],{...c[1],...s,...I},t??c[2],{...c[3],...o},r??c[4],{...c[5],...u},l??c[6],{...c[7],...n},d??c[8],{...c[9],...p},a??c[10],{...c[11],...i},b,w]),[e,s,I,t,o,r,u,l,n,d,p,a,i,c,b,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ps,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ze(Z(t),e),p=He(e,s,l);return ns(h(d)||h(p)?null:_e(o,{...Ye(r,p),key:p,tableId:d,rowId:p,store:n,debugIds:u}),void 0,u,s)},exports.ResultCellView=cs,exports.ResultRowView=Is,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Oe(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>rs(e,Fe(e.queryId,e.queries)),exports.RowView=ps,exports.SliceView=xs,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>os(r,Se(r.tableId,e,s,t,o,r.store)),exports.TableView=as,exports.TablesView=({store:e,tableComponent:s=as,getTableComponentProps:t,separator:o,debugIds:r})=>ns(f(ye(e),(o=>_e(s,{...Ye(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=is,exports.ValuesView=({store:e,valueComponent:s=is,getValueComponentProps:t,separator:o,debugIds:r})=>ns(f(ve(e),(o=>_e(s,{...Ye(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.useAddRowCallback=(e,s,t=ae,o,r=T,u=ae,l=!0)=>{const n=N(o);return oe((t=>y(n,(o=>y(s(t,o),(s=>r(o.addRow(S(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},exports.useCell=Te,exports.useCellIds=Ve,exports.useCellIdsListener=(e,s,t,o,r,u)=>we(w,N(u),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,u,l)=>we(b,N(l),o,r,[e,s,t],u),exports.useCheckpoint=Ge,exports.useCheckpointIds=Ae,exports.useCheckpointIdsListener=(e,s,t)=>we("CheckpointIds",ee(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>we("Checkpoint",ee(o),s,t,[e]),exports.useCheckpoints=e=>_(e,10),exports.useCheckpointsIds=()=>K(11),exports.useCheckpointsOrCheckpointsById=ee,exports.useCreateCheckpoints=(e,s,t)=>Ie(e,s,t),exports.useCreateIndexes=(e,s,t)=>Ie(e,s,t),exports.useCreateMergeableStore=(e,s=ae)=>ue(e,s),exports.useCreateMetrics=(e,s,t)=>Ie(e,s,t),exports.useCreatePersister=(e,s,t=ae,o,r=ae,u,l=ae)=>{const[,n]=de(),[d,p]=de();return re((()=>{(async()=>{const t=e?await s(e):void 0;p(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),re((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},exports.useCreateQueries=(e,s,t)=>Ie(e,s,t),exports.useCreateRelationships=(e,s,t)=>Ie(e,s,t),exports.useCreateStore=(e,s=ae)=>ue(e,s),exports.useCreateSynchronizer=(e,s,t=ae,o,r=ae)=>{const[u,l]=de();return re((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),re((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},exports.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,b,u,l,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>Le(t,x,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>Le(s,p,t,o,e),exports.useDelTablesCallback=(e,s,t)=>Le(e,a,s,t),exports.useDelValueCallback=(e,s,t,o)=>Le(s,R,t,o,e),exports.useDelValuesCallback=(e,s,t)=>Le(e,k,s,t),exports.useDidFinishTransactionListener=(e,s,t)=>we("DidFinish"+te,N(t),e,s),exports.useGoBackwardCallback=We,exports.useGoForwardCallback=je,exports.useGoToCallback=(e,s=ae,t,o=T,r=ae)=>{const u=ee(t);return oe((s=>y(u,(t=>y(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},exports.useHasCell=(e,s,t,o)=>be(b,N(o),4,[e,s,t]),exports.useHasCellListener=(e,s,t,o,r,u,l)=>we(n+b,N(l),o,r,[e,s,t],u),exports.useHasRow=(e,s,t)=>be(x,N(t),4,[e,s]),exports.useHasRowListener=(e,s,t,o,r,u)=>we(n+x,N(u),t,o,[e,s],r),exports.useHasTable=(e,s)=>be(p,N(s),4,[e]),exports.useHasTableCell=(e,s,t)=>be(p+b,N(t),4,[e,s]),exports.useHasTableCellListener=(e,s,t,o,r,u)=>we(n+p+b,N(u),t,o,[e,s],r),exports.useHasTableListener=(e,s,t,o,r)=>we(n+p,N(r),s,t,[e],o),exports.useHasTables=e=>be(a,N(e),4,[]),exports.useHasTablesListener=(e,s,t,o)=>we(n+a,N(o),e,s,[],t),exports.useHasValue=(e,s)=>be(R,N(s),4,[e]),exports.useHasValueListener=(e,s,t,o,r)=>we(n+R,N(r),s,t,[e],o),exports.useHasValues=e=>be(k,N(e),4,[]),exports.useHasValuesListener=(e,s,t,o)=>we(n+k,N(o),e,s,[],t),exports.useIndexIds=e=>be("IndexIds",Y(e),1),exports.useIndexes=e=>_(e,4),exports.useIndexesIds=()=>K(5),exports.useIndexesOrIndexesById=Y,exports.useLinkedRowIds=De,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>we("Linked"+I,Z(r),t,o,[e,s]),exports.useLocalRowIds=Me,exports.useLocalRowIdsListener=(e,s,t,o,r)=>we("Local"+I,Z(r),t,o,[e,s]),exports.useMetric=fe,exports.useMetricIds=e=>be("MetricIds",X(e),1),exports.useMetricListener=(e,s,t,o)=>we("Metric",X(o),s,t,[e]),exports.useMetrics=e=>_(e,2),exports.useMetricsIds=()=>K(3),exports.useMetricsOrMetricsById=X,exports.useProvideStore=(e,s)=>{const{12:t,13:o}=A(W);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},exports.useQueries=e=>_(e,8),exports.useQueriesIds=()=>K(9),exports.useQueriesOrQueriesById=$,exports.useQueryIds=e=>be("QueryIds",$(e),1),exports.useRedoInformation=e=>{const s=ee(e),[,,[o]]=Ae(s);return[!h(o),je(s),o,y(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationshipIds=e=>be("RelationshipIds",Z(e),1),exports.useRelationships=e=>_(e,6),exports.useRelationshipsIds=()=>K(7),exports.useRelationshipsOrRelationshipsById=Z,exports.useRemoteRowId=He,exports.useRemoteRowIdListener=(e,s,t,o,r)=>we("RemoteRowId",Z(r),t,o,[e,s]),exports.useResultCell=Ee,exports.useResultCellIds=Qe,exports.useResultCellIdsListener=(e,s,t,o,r)=>we(l+w,$(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,u)=>we(l+b,$(u),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>be(l+x,$(t),0,[e,s]),exports.useResultRowCount=(e,s)=>be(l+c,$(s),5,[e]),exports.useResultRowCountListener=(e,s,t,o)=>we(l+c,$(o),s,t,[e]),exports.useResultRowIds=Fe,exports.useResultRowIdsListener=(e,s,t,o)=>we(l+I,$(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>we(l+x,$(r),t,o,[e,s]),exports.useResultSortedRowIds=Oe,exports.useResultSortedRowIdsListener=(e,s,t,o,r,u,n,d)=>we(l+C,$(d),u,n,[e,s,t,o,r]),exports.useResultTable=(e,s)=>be(l+p,$(s),0,[e]),exports.useResultTableCellIds=(e,s)=>be(l+p+w,$(s),1,[e]),exports.useResultTableCellIdsListener=(e,s,t,o)=>we(l+p+w,$(o),s,t,[e]),exports.useResultTableListener=(e,s,t,o)=>we(l+p,$(o),s,t,[e]),exports.useRow=(e,s,t)=>be(x,N(t),0,[e,s]),exports.useRowCount=(e,s)=>be(c,N(s),5,[e]),exports.useRowCountListener=(e,s,t,o,r)=>we(c,N(r),s,t,[e],o),exports.useRowIds=me,exports.useRowIdsListener=(e,s,t,o,r)=>we(I,N(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,u)=>we(x,N(u),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,u,l,n)=>Re(u,b,o,r,l,n,e,s,t),exports.useSetCheckpointCallback=(e=T,s=ae,t,o=T,r=ae)=>{const u=ee(t);return oe((s=>y(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>Re(r,"PartialRow",t,o,u,l,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Re(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,u,l)=>Re(r,x,t,o,u,l,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Re(o,p,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Re(t,a,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,u)=>Re(o,R,s,t,r,u,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Re(t,k,e,s,o,r),exports.useSliceIds=qe,exports.useSliceIdsListener=(e,s,t,o)=>we("SliceIds",Y(o),s,t,[e]),exports.useSliceRowIds=Be,exports.useSliceRowIdsListener=(e,s,t,o,r)=>we("Slice"+I,Y(r),t,o,[e,s]),exports.useSortedRowIds=Se,exports.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>we(C,N(d),u,l,[e,s,t,o,r],n),exports.useStartTransactionListener=(e,s,t)=>we("Start"+te,N(t),e,s),exports.useStore=e=>_(e,0),exports.useStoreIds=()=>K(1),exports.useStoreOrStoreById=N,exports.useTable=(e,s)=>be(p,N(s),0,[e]),exports.useTableCellIds=(e,s)=>be(p+w,N(s),1,[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>we(p+w,N(r),s,t,[e],o),exports.useTableIds=ye,exports.useTableIdsListener=(e,s,t,o)=>we(i,N(o),e,s,ae,t),exports.useTableListener=(e,s,t,o,r)=>we(p,N(r),s,t,[e],o),exports.useTables=e=>be(a,N(e),0),exports.useTablesListener=(e,s,t,o)=>we(a,N(o),e,s,ae,t),exports.useUndoInformation=e=>{const s=ee(e),[o,r]=Ae(s);return[(u=o,!(0==V(u))),We(s),r,y(r,(e=>s?.getCheckpoint(e)))??t];var u},exports.useValue=Pe,exports.useValueIds=ve,exports.useValueIdsListener=(e,s,t,o)=>we(g,N(o),e,s,ae,t),exports.useValueListener=(e,s,t,o,r)=>we(R,N(r),s,t,[e],o),exports.useValues=e=>be(k,N(e),0),exports.useValuesListener=(e,s,t,o)=>we(k,N(o),e,s,ae,t),exports.useWillFinishTransactionListener=(e,s,t)=>we("WillFinish"+te,N(t),e,s);
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r=s(s),u="Listener",l="Result",n="Has",d="Ids",p="Table",a=p+"s",i=p+d,x="Row",c=x+"Count",I=x+d,C="Sorted"+x+d,b="Cell",w=b+d,R="Value",k=R+"s",g=R+d,L=e=>null==e,h=(e,s,t)=>L(e)?t?.():s(e),y=e=>s(e)==o,m=e=>s(e)==r,S=e=>e.length,V=()=>{},T=(e,s)=>e.every(s),v=(e,s)=>S(e)===S(s)&&T(e,((e,t)=>s[t]===e)),P=(e,s)=>e.map(s),f=Object,q=e=>f.getPrototypeOf(e),B=f.entries,H=e=>!L(e)&&h(q(e),(e=>e==f.prototype||L(q(e))),(()=>!0)),M=f.keys,D=(e,s)=>h(e,(e=>e[s])),F=(e,s)=>(delete e[s],e),O=(e,s)=>{const t=B(e);return S(t)===S(M(s))&&T(t,(([e,t])=>H(t)?!!H(s[e])&&O(s[e],t):s[e]===t))},{createContext:Q,useContext:E,useEffect:A}=e,G=Q([]),W=(e,s)=>{const t=E(G);return L(e)?t[s]:y(e)?D(t[s+1]??{},e):e},j=(e,s)=>{const t=W(e,s);return L(e)||y(e)?t:e},z=e=>M(E(G)[e]??{}),U=e=>j(e,0),J=e=>j(e,2),K=e=>j(e,4),N=e=>j(e,6),X=e=>j(e,8),Y=e=>j(e,10),Z=e=>e.toLowerCase();Z(u);const $="Transaction";Z($);const{useCallback:_,useEffect:ee,useMemo:se,useLayoutEffect:te,useRef:oe,useState:re,useSyncExternalStore:ue}=e,le=[],ne=[{},[],[le,void 0,le],void 0,!1,0],de=[O,v,([e,s,t],[o,r,u])=>s===r&&v(e,o)&&v(t,u)],pe=(e,s)=>e===s,ae=(e,s,t=le)=>{const[,o]=re(),[r,u]=re();return ee((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},ie=(e,s,...t)=>{const o=e?.["add"+s+u]?.(...t);return()=>e?.delListener(o)},xe=(e,s,o,r=le)=>{const u=oe(ne[o]),l=_((()=>{const t=s?.[(4==o?"has":"get")+e]?.(...r)??ne[o];return(de[o]??pe)(t,u.current)?u.current:u.current=t}),[s,o,e,...r]),d=_((u=>ie(s,(4==o?n:t)+e,...r,u)),[s,o,e,...r]);return ue(d,l)},ce=(e,s,t,o=le,r=le,...u)=>te((()=>ie(s,e,...r,t,...u)),[s,e,...r,...o,...u]),Ie=(e,s,t,o=le,r=V,u=le,...l)=>{const n=U(e);return _((e=>h(n,(o=>h(t(e,o),(t=>r(o["set"+s](...Ce(l,o,e),t),t)))))),[n,s,...o,...u,...be(l)])},Ce=(e,s,t)=>P(e,(e=>m(e)?e(t,s):e)),be=e=>{return s=e=>!m(e),e.filter(s);var s},we=(e,s,t=V,o=le,...r)=>{const u=U(e);return _((e=>t(u?.["del"+s](...Ce(r,u,e)))),[u,s,...o,...be(r)])},Re=(e,s,t)=>{const o=Y(e);return _((()=>o?.[s](t)),[o,s,t])},ke=e=>xe(i,U(e),1),ge=(e,s)=>xe(I,U(s),1,[e]),Le=(e,s,t,o=0,r,u)=>xe(C,U(u),1,[e,s,t,o,r]),he=(e,s,t)=>xe(w,U(t),1,[e,s]),ye=(e,s,t,o)=>xe(b,U(o),3,[e,s,t]),me=e=>xe(g,U(e),1),Se=(e,s)=>xe(R,U(s),3,[e]),Ve=(e,s)=>xe("Metric",J(s),3,[e]),Te=(e,s)=>xe("SliceIds",K(s),1,[e]),ve=(e,s,t)=>xe("Slice"+I,K(t),1,[e,s]),Pe=(e,s,t)=>xe("RemoteRowId",N(t),3,[e,s]),fe=(e,s,t)=>xe("Local"+I,N(t),1,[e,s]),qe=(e,s,t)=>xe("Linked"+I,N(t),1,[e,s]),Be=(e,s)=>xe(l+I,X(s),1,[e]),He=(e,s,t,o=0,r,u)=>xe(l+C,X(u),1,[e,s,t,o,r]),Me=(e,s,t)=>xe(l+w,X(t),1,[e,s]),De=(e,s,t,o)=>xe(l+b,X(o),3,[e,s,t]),Fe=e=>xe("CheckpointIds",Y(e),2),Oe=(e,s)=>xe("Checkpoint",Y(s),3,[e]),Qe=e=>Re(e,"goBackward"),Ee=e=>Re(e,"goForward"),{PureComponent:Ae,Fragment:Ge,createElement:We,useCallback:je,useLayoutEffect:ze,useRef:Ue,useState:Je}=e,Ke=(e,...s)=>L(e)?{}:e(...s),Ne=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:Xe,useContext:Ye,useMemo:Ze,useState:$e}=e,_e=({tableId:e,store:s,rowComponent:t=us,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>os(P(n,(u=>We(t,{...Ke(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),es=({queryId:e,queries:s,resultRowComponent:t=as,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>os(P(l,(r=>We(t,{...Ke(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),ss=({relationshipId:e,relationships:s,rowComponent:t=us,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,p,a]=Ne(N(s),e),i=l(e,n,d);return os(P(i,(e=>We(t,{...Ke(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:u}))),r,u,n)},ts=e=>({checkpoints:s,checkpointComponent:t=is,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=Y(s);return os(P(e(Fe(l)),(e=>We(t,{...Ke(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},os=(e,s,t,o)=>{const r=L(s)||!Array.isArray(e)?e:P(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},rs=({tableId:e,rowId:s,cellId:o,store:r,debugIds:u})=>os(t+(ye(e,s,o,r)??t),void 0,u,o),us=({tableId:e,rowId:s,store:t,cellComponent:o=rs,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>os(P(((e,s,t,o)=>{const r=he(s,t,o);return e??r})(u,e,s,t),(u=>We(o,{...Ke(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),ls=e=>_e(e,ge(e.tableId,e.store)),ns=({valueId:e,store:s,debugIds:o})=>os(t+(Se(e,s)??t),void 0,o,e),ds=({indexId:e,sliceId:s,indexes:t,rowComponent:o=us,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,p]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(K(t),e),a=ve(e,s,n);return os(P(a,(e=>We(o,{...Ke(r,e),key:e,tableId:p,rowId:e,store:d,debugIds:l}))),u,l,s)},ps=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:u})=>os(t+(De(e,s,o,r)??t),void 0,u,o),as=({queryId:e,rowId:s,queries:t,resultCellComponent:o=ps,getResultCellComponentProps:r,separator:u,debugIds:l})=>os(P(Me(e,s,t),(u=>We(o,{...Ke(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),is=({checkpoints:e,checkpointId:s,debugIds:o})=>os(Oe(s,e)??t,void 0,o,s),xs=ts((e=>e[0])),cs=ts((e=>L(e[1])?[]:[e[1]])),Is=ts((e=>e[2]));exports.BackwardCheckpointsView=xs,exports.CellView=rs,exports.CheckpointView=is,exports.CurrentCheckpointView=cs,exports.ForwardCheckpointsView=Is,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=ds,getSliceComponentProps:o,separator:r,debugIds:u})=>os(P(Te(e,s),(r=>We(t,{...Ke(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),exports.LinkedRowsView=e=>ss(e,qe,e.firstRowId),exports.LocalRowsView=e=>ss(e,fe,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>os(Ve(e,s)??t,void 0,o,e),exports.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:p,checkpoints:a,checkpointsById:i,children:x})=>{const c=Ye(G),[I,C]=$e({}),b=Xe(((e,s)=>C((t=>D(t,e)==s?t:{...t,[e]:s}))),[]),w=Xe((e=>C((s=>({...F(s,e)})))),[]);return We(G.Provider,{value:Ze((()=>[e??c[0],{...c[1],...s,...I},t??c[2],{...c[3],...o},r??c[4],{...c[5],...u},l??c[6],{...c[7],...n},d??c[8],{...c[9],...p},a??c[10],{...c[11],...i},b,w]),[e,s,I,t,o,r,u,l,n,d,p,a,i,c,b,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=us,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ne(N(t),e),p=Pe(e,s,l);return os(L(d)||L(p)?null:We(o,{...Ke(r,p),key:p,tableId:d,rowId:p,store:n,debugIds:u}),void 0,u,s)},exports.ResultCellView=ps,exports.ResultRowView=as,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>es(r,He(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>es(e,Be(e.queryId,e.queries)),exports.RowView=us,exports.SliceView=ds,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>_e(r,Le(r.tableId,e,s,t,o,r.store)),exports.TableView=ls,exports.TablesView=({store:e,tableComponent:s=ls,getTableComponentProps:t,separator:o,debugIds:r})=>os(P(ke(e),(o=>We(s,{...Ke(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=ns,exports.ValuesView=({store:e,valueComponent:s=ns,getValueComponentProps:t,separator:o,debugIds:r})=>os(P(me(e),(o=>We(s,{...Ke(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.useAddRowCallback=(e,s,t=le,o,r=V,u=le,l=!0)=>{const n=U(o);return _((t=>h(n,(o=>h(s(t,o),(s=>r(o.addRow(m(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},exports.useCell=ye,exports.useCellIds=he,exports.useCellIdsListener=(e,s,t,o,r,u)=>ce(w,U(u),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,u,l)=>ce(b,U(l),o,r,[e,s,t],u),exports.useCheckpoint=Oe,exports.useCheckpointIds=Fe,exports.useCheckpointIdsListener=(e,s,t)=>ce("CheckpointIds",Y(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>ce("Checkpoint",Y(o),s,t,[e]),exports.useCheckpoints=e=>W(e,10),exports.useCheckpointsIds=()=>z(11),exports.useCheckpointsOrCheckpointsById=Y,exports.useCreateCheckpoints=(e,s,t)=>ae(e,s,t),exports.useCreateIndexes=(e,s,t)=>ae(e,s,t),exports.useCreateMergeableStore=(e,s=le)=>se(e,s),exports.useCreateMetrics=(e,s,t)=>ae(e,s,t),exports.useCreatePersister=(e,s,t=le,o,r=le,u,l=le)=>{const[,n]=re(),[d,p]=re();return ee((()=>{(async()=>{const t=e?await s(e):void 0;p(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),ee((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},exports.useCreateQueries=(e,s,t)=>ae(e,s,t),exports.useCreateRelationships=(e,s,t)=>ae(e,s,t),exports.useCreateStore=(e,s=le)=>se(e,s),exports.useCreateSynchronizer=(e,s,t=le,o,r=le)=>{const[u,l]=re();return ee((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),ee((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},exports.useDelCellCallback=(e,s,t,o,r,u,l)=>we(r,b,u,l,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>we(t,x,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>we(s,p,t,o,e),exports.useDelTablesCallback=(e,s,t)=>we(e,a,s,t),exports.useDelValueCallback=(e,s,t,o)=>we(s,R,t,o,e),exports.useDelValuesCallback=(e,s,t)=>we(e,k,s,t),exports.useDidFinishTransactionListener=(e,s,t)=>ce("DidFinish"+$,U(t),e,s),exports.useGoBackwardCallback=Qe,exports.useGoForwardCallback=Ee,exports.useGoToCallback=(e,s=le,t,o=V,r=le)=>{const u=Y(t);return _((s=>h(u,(t=>h(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},exports.useHasCell=(e,s,t,o)=>xe(b,U(o),4,[e,s,t]),exports.useHasCellListener=(e,s,t,o,r,u,l)=>ce(n+b,U(l),o,r,[e,s,t],u),exports.useHasRow=(e,s,t)=>xe(x,U(t),4,[e,s]),exports.useHasRowListener=(e,s,t,o,r,u)=>ce(n+x,U(u),t,o,[e,s],r),exports.useHasTable=(e,s)=>xe(p,U(s),4,[e]),exports.useHasTableCell=(e,s,t)=>xe(p+b,U(t),4,[e,s]),exports.useHasTableCellListener=(e,s,t,o,r,u)=>ce(n+p+b,U(u),t,o,[e,s],r),exports.useHasTableListener=(e,s,t,o,r)=>ce(n+p,U(r),s,t,[e],o),exports.useHasTables=e=>xe(a,U(e),4,[]),exports.useHasTablesListener=(e,s,t,o)=>ce(n+a,U(o),e,s,[],t),exports.useHasValue=(e,s)=>xe(R,U(s),4,[e]),exports.useHasValueListener=(e,s,t,o,r)=>ce(n+R,U(r),s,t,[e],o),exports.useHasValues=e=>xe(k,U(e),4,[]),exports.useHasValuesListener=(e,s,t,o)=>ce(n+k,U(o),e,s,[],t),exports.useIndexIds=e=>xe("IndexIds",K(e),1),exports.useIndexes=e=>W(e,4),exports.useIndexesIds=()=>z(5),exports.useIndexesOrIndexesById=K,exports.useLinkedRowIds=qe,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>ce("Linked"+I,N(r),t,o,[e,s]),exports.useLocalRowIds=fe,exports.useLocalRowIdsListener=(e,s,t,o,r)=>ce("Local"+I,N(r),t,o,[e,s]),exports.useMetric=Ve,exports.useMetricIds=e=>xe("MetricIds",J(e),1),exports.useMetricListener=(e,s,t,o)=>ce("Metric",J(o),s,t,[e]),exports.useMetrics=e=>W(e,2),exports.useMetricsIds=()=>z(3),exports.useMetricsOrMetricsById=J,exports.useProvideStore=(e,s)=>{const{12:t,13:o}=E(G);A((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},exports.useQueries=e=>W(e,8),exports.useQueriesIds=()=>z(9),exports.useQueriesOrQueriesById=X,exports.useQueryIds=e=>xe("QueryIds",X(e),1),exports.useRedoInformation=e=>{const s=Y(e),[,,[o]]=Fe(s);return[!L(o),Ee(s),o,h(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationshipIds=e=>xe("RelationshipIds",N(e),1),exports.useRelationships=e=>W(e,6),exports.useRelationshipsIds=()=>z(7),exports.useRelationshipsOrRelationshipsById=N,exports.useRemoteRowId=Pe,exports.useRemoteRowIdListener=(e,s,t,o,r)=>ce("RemoteRowId",N(r),t,o,[e,s]),exports.useResultCell=De,exports.useResultCellIds=Me,exports.useResultCellIdsListener=(e,s,t,o,r)=>ce(l+w,X(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,u)=>ce(l+b,X(u),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>xe(l+x,X(t),0,[e,s]),exports.useResultRowCount=(e,s)=>xe(l+c,X(s),5,[e]),exports.useResultRowCountListener=(e,s,t,o)=>ce(l+c,X(o),s,t,[e]),exports.useResultRowIds=Be,exports.useResultRowIdsListener=(e,s,t,o)=>ce(l+I,X(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>ce(l+x,X(r),t,o,[e,s]),exports.useResultSortedRowIds=He,exports.useResultSortedRowIdsListener=(e,s,t,o,r,u,n,d)=>ce(l+C,X(d),u,n,[e,s,t,o,r]),exports.useResultTable=(e,s)=>xe(l+p,X(s),0,[e]),exports.useResultTableCellIds=(e,s)=>xe(l+p+w,X(s),1,[e]),exports.useResultTableCellIdsListener=(e,s,t,o)=>ce(l+p+w,X(o),s,t,[e]),exports.useResultTableListener=(e,s,t,o)=>ce(l+p,X(o),s,t,[e]),exports.useRow=(e,s,t)=>xe(x,U(t),0,[e,s]),exports.useRowCount=(e,s)=>xe(c,U(s),5,[e]),exports.useRowCountListener=(e,s,t,o,r)=>ce(c,U(r),s,t,[e],o),exports.useRowIds=ge,exports.useRowIdsListener=(e,s,t,o,r)=>ce(I,U(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,u)=>ce(x,U(u),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,u,l,n)=>Ie(u,b,o,r,l,n,e,s,t),exports.useSetCheckpointCallback=(e=V,s=le,t,o=V,r=le)=>{const u=Y(t);return _((s=>h(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>Ie(r,"PartialRow",t,o,u,l,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Ie(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,u,l)=>Ie(r,x,t,o,u,l,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Ie(o,p,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Ie(t,a,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,u)=>Ie(o,R,s,t,r,u,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Ie(t,k,e,s,o,r),exports.useSliceIds=Te,exports.useSliceIdsListener=(e,s,t,o)=>ce("SliceIds",K(o),s,t,[e]),exports.useSliceRowIds=ve,exports.useSliceRowIdsListener=(e,s,t,o,r)=>ce("Slice"+I,K(r),t,o,[e,s]),exports.useSortedRowIds=Le,exports.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>ce(C,U(d),u,l,[e,s,t,o,r],n),exports.useStartTransactionListener=(e,s,t)=>ce("Start"+$,U(t),e,s),exports.useStore=e=>W(e,0),exports.useStoreIds=()=>z(1),exports.useStoreOrStoreById=U,exports.useTable=(e,s)=>xe(p,U(s),0,[e]),exports.useTableCellIds=(e,s)=>xe(p+w,U(s),1,[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>ce(p+w,U(r),s,t,[e],o),exports.useTableIds=ke,exports.useTableIdsListener=(e,s,t,o)=>ce(i,U(o),e,s,le,t),exports.useTableListener=(e,s,t,o,r)=>ce(p,U(r),s,t,[e],o),exports.useTables=e=>xe(a,U(e),0),exports.useTablesListener=(e,s,t,o)=>ce(a,U(o),e,s,le,t),exports.useUndoInformation=e=>{const s=Y(e),[o,r]=Fe(s);return[(u=o,!(0==S(u))),Qe(s),r,h(r,(e=>s?.getCheckpoint(e)))??t];var u},exports.useValue=Se,exports.useValueIds=me,exports.useValueIdsListener=(e,s,t,o)=>ce(g,U(o),e,s,le,t),exports.useValueListener=(e,s,t,o,r)=>ce(R,U(r),s,t,[e],o),exports.useValues=e=>xe(k,U(e),0),exports.useValuesListener=(e,s,t,o)=>ce(k,U(o),e,s,le,t),exports.useWillFinishTransactionListener=(e,s,t)=>ce("WillFinish"+$,U(t),e,s);
|
|
1
|
+
"use strict";var e=require("react");const s=e=>typeof e,t="",o=s(t),r=s(s),u="Listener",l="Result",n="Has",d="Ids",p="Table",a=p+"s",i=p+d,x="Row",c=x+"Count",I=x+d,C="Sorted"+x+d,b="Cell",w=b+d,R="Value",k=R+"s",g=R+d,L=globalThis,h=e=>null==e,y=(e,s,t)=>h(e)?t?.():s(e),m=e=>s(e)==o,S=e=>s(e)==r,V=e=>e.length,T=()=>{},v=(e,s)=>e.every(s),P=(e,s)=>V(e)===V(s)&&v(e,((e,t)=>s[t]===e)),f=(e,s)=>e.map(s),q=Object,B=e=>q.getPrototypeOf(e),H=q.entries,M=e=>!h(e)&&y(B(e),(e=>e==q.prototype||h(B(e))),(()=>!0)),D=q.keys,F=(e,s)=>y(e,(e=>e[s])),O=(e,s)=>(delete e[s],e),Q=(e,s)=>{const t=H(e);return V(t)===V(D(s))&&v(t,(([e,t])=>M(t)?!!M(s[e])&&Q(s[e],t):s[e]===t))},{createContext:E,useContext:A,useEffect:G}=e,W=(U=()=>E([]),((e,s)=>s in e)(j=L,z="tinybase_uirc")||(j[z]=U()),j[z]);var j,z,U;const _=(e,s)=>{const t=A(W);return h(e)?t[s]:m(e)?F(t[s+1]??{},e):e},J=(e,s)=>{const t=_(e,s);return h(e)||m(e)?t:e},K=e=>D(A(W)[e]??{}),N=e=>J(e,0),X=e=>J(e,2),Y=e=>J(e,4),Z=e=>J(e,6),$=e=>J(e,8),ee=e=>J(e,10),se=e=>e.toLowerCase();se(u);const te="Transaction";se(te);const{useCallback:oe,useEffect:re,useMemo:ue,useLayoutEffect:le,useRef:ne,useState:de,useSyncExternalStore:pe}=e,ae=[],ie=[{},[],[ae,void 0,ae],void 0,!1,0],xe=[Q,P,([e,s,t],[o,r,u])=>s===r&&P(e,o)&&P(t,u)],ce=(e,s)=>e===s,Ie=(e,s,t=ae)=>{const[,o]=de(),[r,u]=de();return re((()=>{const t=e?s(e):void 0;return u(t),o([]),t?.destroy}),[e,...t]),r},Ce=(e,s,...t)=>{const o=e?.["add"+s+u]?.(...t);return()=>e?.delListener(o)},be=(e,s,o,r=ae)=>{const u=ne(ie[o]),l=oe((()=>{const t=s?.[(4==o?"has":"get")+e]?.(...r)??ie[o];return(xe[o]??ce)(t,u.current)?u.current:u.current=t}),[s,o,e,...r]),d=oe((u=>Ce(s,(4==o?n:t)+e,...r,u)),[s,o,e,...r]);return pe(d,l)},we=(e,s,t,o=ae,r=ae,...u)=>le((()=>Ce(s,e,...r,t,...u)),[s,e,...r,...o,...u]),Re=(e,s,t,o=ae,r=T,u=ae,...l)=>{const n=N(e);return oe((e=>y(n,(o=>y(t(e,o),(t=>r(o["set"+s](...ke(l,o,e),t),t)))))),[n,s,...o,...u,...ge(l)])},ke=(e,s,t)=>f(e,(e=>S(e)?e(t,s):e)),ge=e=>{return s=e=>!S(e),e.filter(s);var s},Le=(e,s,t=T,o=ae,...r)=>{const u=N(e);return oe((e=>t(u?.["del"+s](...ke(r,u,e)))),[u,s,...o,...ge(r)])},he=(e,s,t)=>{const o=ee(e);return oe((()=>o?.[s](t)),[o,s,t])},ye=e=>be(i,N(e),1),me=(e,s)=>be(I,N(s),1,[e]),Se=(e,s,t,o=0,r,u)=>be(C,N(u),1,[e,s,t,o,r]),Ve=(e,s,t)=>be(w,N(t),1,[e,s]),Te=(e,s,t,o)=>be(b,N(o),3,[e,s,t]),ve=e=>be(g,N(e),1),Pe=(e,s)=>be(R,N(s),3,[e]),fe=(e,s)=>be("Metric",X(s),3,[e]),qe=(e,s)=>be("SliceIds",Y(s),1,[e]),Be=(e,s,t)=>be("Slice"+I,Y(t),1,[e,s]),He=(e,s,t)=>be("RemoteRowId",Z(t),3,[e,s]),Me=(e,s,t)=>be("Local"+I,Z(t),1,[e,s]),De=(e,s,t)=>be("Linked"+I,Z(t),1,[e,s]),Fe=(e,s)=>be(l+I,$(s),1,[e]),Oe=(e,s,t,o=0,r,u)=>be(l+C,$(u),1,[e,s,t,o,r]),Qe=(e,s,t)=>be(l+w,$(t),1,[e,s]),Ee=(e,s,t,o)=>be(l+b,$(o),3,[e,s,t]),Ae=e=>be("CheckpointIds",ee(e),2),Ge=(e,s)=>be("Checkpoint",ee(s),3,[e]),We=e=>he(e,"goBackward"),je=e=>he(e,"goForward"),{PureComponent:ze,Fragment:Ue,createElement:_e,useCallback:Je,useLayoutEffect:Ke,useRef:Ne,useState:Xe}=e,Ye=(e,...s)=>h(e)?{}:e(...s),Ze=(e,s)=>[e,e?.getStore(),e?.getLocalTableId(s),e?.getRemoteTableId(s)],{useCallback:$e,useContext:es,useMemo:ss,useState:ts}=e,os=({tableId:e,store:s,rowComponent:t=ps,getRowComponentProps:o,customCellIds:r,separator:u,debugIds:l},n)=>ns(f(n,(u=>_e(t,{...Ye(o,u),key:u,tableId:e,rowId:u,customCellIds:r,store:s,debugIds:l}))),u,l,e),rs=({queryId:e,queries:s,resultRowComponent:t=Is,getResultRowComponentProps:o,separator:r,debugIds:u},l)=>ns(f(l,(r=>_e(t,{...Ye(o,r),key:r,queryId:e,rowId:r,queries:s,debugIds:u}))),r,u,e),us=({relationshipId:e,relationships:s,rowComponent:t=ps,getRowComponentProps:o,separator:r,debugIds:u},l,n)=>{const[d,p,a]=Ze(Z(s),e),i=l(e,n,d);return ns(f(i,(e=>_e(t,{...Ye(o,e),key:e,tableId:a,rowId:e,store:p,debugIds:u}))),r,u,n)},ls=e=>({checkpoints:s,checkpointComponent:t=Cs,getCheckpointComponentProps:o,separator:r,debugIds:u})=>{const l=ee(s);return ns(f(e(Ae(l)),(e=>_e(t,{...Ye(o,e),key:e,checkpoints:l,checkpointId:e,debugIds:u}))),r)},ns=(e,s,t,o)=>{const r=h(s)||!Array.isArray(e)?e:f(e,((e,t)=>t>0?[s,e]:e));return t?[o,":{",r,"}"]:r},ds=({tableId:e,rowId:s,cellId:o,store:r,debugIds:u})=>ns(t+(Te(e,s,o,r)??t),void 0,u,o),ps=({tableId:e,rowId:s,store:t,cellComponent:o=ds,getCellComponentProps:r,customCellIds:u,separator:l,debugIds:n})=>ns(f(((e,s,t,o)=>{const r=Ve(s,t,o);return e??r})(u,e,s,t),(u=>_e(o,{...Ye(r,u),key:u,tableId:e,rowId:s,cellId:u,store:t,debugIds:n}))),l,n,s),as=e=>os(e,me(e.tableId,e.store)),is=({valueId:e,store:s,debugIds:o})=>ns(t+(Pe(e,s)??t),void 0,o,e),xs=({indexId:e,sliceId:s,indexes:t,rowComponent:o=ps,getRowComponentProps:r,separator:u,debugIds:l})=>{const[n,d,p]=((e,s)=>[e,e?.getStore(),e?.getTableId(s)])(Y(t),e),a=Be(e,s,n);return ns(f(a,(e=>_e(o,{...Ye(r,e),key:e,tableId:p,rowId:e,store:d,debugIds:l}))),u,l,s)},cs=({queryId:e,rowId:s,cellId:o,queries:r,debugIds:u})=>ns(t+(Ee(e,s,o,r)??t),void 0,u,o),Is=({queryId:e,rowId:s,queries:t,resultCellComponent:o=cs,getResultCellComponentProps:r,separator:u,debugIds:l})=>ns(f(Qe(e,s,t),(u=>_e(o,{...Ye(r,u),key:u,queryId:e,rowId:s,cellId:u,queries:t,debugIds:l}))),u,l,s),Cs=({checkpoints:e,checkpointId:s,debugIds:o})=>ns(Ge(s,e)??t,void 0,o,s),bs=ls((e=>e[0])),ws=ls((e=>h(e[1])?[]:[e[1]])),Rs=ls((e=>e[2]));exports.BackwardCheckpointsView=bs,exports.CellView=ds,exports.CheckpointView=Cs,exports.CurrentCheckpointView=ws,exports.ForwardCheckpointsView=Rs,exports.IndexView=({indexId:e,indexes:s,sliceComponent:t=xs,getSliceComponentProps:o,separator:r,debugIds:u})=>ns(f(qe(e,s),(r=>_e(t,{...Ye(o,r),key:r,indexId:e,sliceId:r,indexes:s,debugIds:u}))),r,u,e),exports.LinkedRowsView=e=>us(e,De,e.firstRowId),exports.LocalRowsView=e=>us(e,Me,e.remoteRowId),exports.MetricView=({metricId:e,metrics:s,debugIds:o})=>ns(fe(e,s)??t,void 0,o,e),exports.Provider=({store:e,storesById:s,metrics:t,metricsById:o,indexes:r,indexesById:u,relationships:l,relationshipsById:n,queries:d,queriesById:p,checkpoints:a,checkpointsById:i,children:x})=>{const c=es(W),[I,C]=ts({}),b=$e(((e,s)=>C((t=>F(t,e)==s?t:{...t,[e]:s}))),[]),w=$e((e=>C((s=>({...O(s,e)})))),[]);return _e(W.Provider,{value:ss((()=>[e??c[0],{...c[1],...s,...I},t??c[2],{...c[3],...o},r??c[4],{...c[5],...u},l??c[6],{...c[7],...n},d??c[8],{...c[9],...p},a??c[10],{...c[11],...i},b,w]),[e,s,I,t,o,r,u,l,n,d,p,a,i,c,b,w])},x)},exports.RemoteRowView=({relationshipId:e,localRowId:s,relationships:t,rowComponent:o=ps,getRowComponentProps:r,debugIds:u})=>{const[l,n,,d]=Ze(Z(t),e),p=He(e,s,l);return ns(h(d)||h(p)?null:_e(o,{...Ye(r,p),key:p,tableId:d,rowId:p,store:n,debugIds:u}),void 0,u,s)},exports.ResultCellView=cs,exports.ResultRowView=Is,exports.ResultSortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>rs(r,Oe(r.queryId,e,s,t,o,r.queries)),exports.ResultTableView=e=>rs(e,Fe(e.queryId,e.queries)),exports.RowView=ps,exports.SliceView=xs,exports.SortedTableView=({cellId:e,descending:s,offset:t,limit:o,...r})=>os(r,Se(r.tableId,e,s,t,o,r.store)),exports.TableView=as,exports.TablesView=({store:e,tableComponent:s=as,getTableComponentProps:t,separator:o,debugIds:r})=>ns(f(ye(e),(o=>_e(s,{...Ye(t,o),key:o,tableId:o,store:e,debugIds:r}))),o),exports.ValueView=is,exports.ValuesView=({store:e,valueComponent:s=is,getValueComponentProps:t,separator:o,debugIds:r})=>ns(f(ve(e),(o=>_e(s,{...Ye(t,o),key:o,valueId:o,store:e,debugIds:r}))),o),exports.useAddRowCallback=(e,s,t=ae,o,r=T,u=ae,l=!0)=>{const n=N(o);return oe((t=>y(n,(o=>y(s(t,o),(s=>r(o.addRow(S(e)?e(t,o):e,s,l),o,s)))))),[n,e,...t,...u,l])},exports.useCell=Te,exports.useCellIds=Ve,exports.useCellIdsListener=(e,s,t,o,r,u)=>we(w,N(u),t,o,[e,s],r),exports.useCellListener=(e,s,t,o,r,u,l)=>we(b,N(l),o,r,[e,s,t],u),exports.useCheckpoint=Ge,exports.useCheckpointIds=Ae,exports.useCheckpointIdsListener=(e,s,t)=>we("CheckpointIds",ee(t),e,s),exports.useCheckpointListener=(e,s,t,o)=>we("Checkpoint",ee(o),s,t,[e]),exports.useCheckpoints=e=>_(e,10),exports.useCheckpointsIds=()=>K(11),exports.useCheckpointsOrCheckpointsById=ee,exports.useCreateCheckpoints=(e,s,t)=>Ie(e,s,t),exports.useCreateIndexes=(e,s,t)=>Ie(e,s,t),exports.useCreateMergeableStore=(e,s=ae)=>ue(e,s),exports.useCreateMetrics=(e,s,t)=>Ie(e,s,t),exports.useCreatePersister=(e,s,t=ae,o,r=ae,u,l=ae)=>{const[,n]=de(),[d,p]=de();return re((()=>{(async()=>{const t=e?await s(e):void 0;p(t),t&&o&&(async()=>{await o(t),n([])})()})()}),[e,...t,...r]),re((()=>()=>{d&&(d.destroy(),u?.(d))}),[d,...l]),d},exports.useCreateQueries=(e,s,t)=>Ie(e,s,t),exports.useCreateRelationships=(e,s,t)=>Ie(e,s,t),exports.useCreateStore=(e,s=ae)=>ue(e,s),exports.useCreateSynchronizer=(e,s,t=ae,o,r=ae)=>{const[u,l]=de();return re((()=>{(async()=>{const t=e?await s(e):void 0;l(t)})()}),[e,...t]),re((()=>()=>{u&&(u.destroy(),o?.(u))}),[u,...r]),u},exports.useDelCellCallback=(e,s,t,o,r,u,l)=>Le(r,b,u,l,e,s,t,o),exports.useDelRowCallback=(e,s,t,o,r)=>Le(t,x,o,r,e,s),exports.useDelTableCallback=(e,s,t,o)=>Le(s,p,t,o,e),exports.useDelTablesCallback=(e,s,t)=>Le(e,a,s,t),exports.useDelValueCallback=(e,s,t,o)=>Le(s,R,t,o,e),exports.useDelValuesCallback=(e,s,t)=>Le(e,k,s,t),exports.useDidFinishTransactionListener=(e,s,t)=>we("DidFinish"+te,N(t),e,s),exports.useGoBackwardCallback=We,exports.useGoForwardCallback=je,exports.useGoToCallback=(e,s=ae,t,o=T,r=ae)=>{const u=ee(t);return oe((s=>y(u,(t=>y(e(s),(e=>o(t.goTo(e),e)))))),[u,...s,...r])},exports.useHasCell=(e,s,t,o)=>be(b,N(o),4,[e,s,t]),exports.useHasCellListener=(e,s,t,o,r,u,l)=>we(n+b,N(l),o,r,[e,s,t],u),exports.useHasRow=(e,s,t)=>be(x,N(t),4,[e,s]),exports.useHasRowListener=(e,s,t,o,r,u)=>we(n+x,N(u),t,o,[e,s],r),exports.useHasTable=(e,s)=>be(p,N(s),4,[e]),exports.useHasTableCell=(e,s,t)=>be(p+b,N(t),4,[e,s]),exports.useHasTableCellListener=(e,s,t,o,r,u)=>we(n+p+b,N(u),t,o,[e,s],r),exports.useHasTableListener=(e,s,t,o,r)=>we(n+p,N(r),s,t,[e],o),exports.useHasTables=e=>be(a,N(e),4,[]),exports.useHasTablesListener=(e,s,t,o)=>we(n+a,N(o),e,s,[],t),exports.useHasValue=(e,s)=>be(R,N(s),4,[e]),exports.useHasValueListener=(e,s,t,o,r)=>we(n+R,N(r),s,t,[e],o),exports.useHasValues=e=>be(k,N(e),4,[]),exports.useHasValuesListener=(e,s,t,o)=>we(n+k,N(o),e,s,[],t),exports.useIndexIds=e=>be("IndexIds",Y(e),1),exports.useIndexes=e=>_(e,4),exports.useIndexesIds=()=>K(5),exports.useIndexesOrIndexesById=Y,exports.useLinkedRowIds=De,exports.useLinkedRowIdsListener=(e,s,t,o,r)=>we("Linked"+I,Z(r),t,o,[e,s]),exports.useLocalRowIds=Me,exports.useLocalRowIdsListener=(e,s,t,o,r)=>we("Local"+I,Z(r),t,o,[e,s]),exports.useMetric=fe,exports.useMetricIds=e=>be("MetricIds",X(e),1),exports.useMetricListener=(e,s,t,o)=>we("Metric",X(o),s,t,[e]),exports.useMetrics=e=>_(e,2),exports.useMetricsIds=()=>K(3),exports.useMetricsOrMetricsById=X,exports.useProvideStore=(e,s)=>{const{12:t,13:o}=A(W);G((()=>(t?.(e,s),()=>o?.(e))),[t,e,s,o])},exports.useQueries=e=>_(e,8),exports.useQueriesIds=()=>K(9),exports.useQueriesOrQueriesById=$,exports.useQueryIds=e=>be("QueryIds",$(e),1),exports.useRedoInformation=e=>{const s=ee(e),[,,[o]]=Ae(s);return[!h(o),je(s),o,y(o,(e=>s?.getCheckpoint(e)))??t]},exports.useRelationshipIds=e=>be("RelationshipIds",Z(e),1),exports.useRelationships=e=>_(e,6),exports.useRelationshipsIds=()=>K(7),exports.useRelationshipsOrRelationshipsById=Z,exports.useRemoteRowId=He,exports.useRemoteRowIdListener=(e,s,t,o,r)=>we("RemoteRowId",Z(r),t,o,[e,s]),exports.useResultCell=Ee,exports.useResultCellIds=Qe,exports.useResultCellIdsListener=(e,s,t,o,r)=>we(l+w,$(r),t,o,[e,s]),exports.useResultCellListener=(e,s,t,o,r,u)=>we(l+b,$(u),o,r,[e,s,t]),exports.useResultRow=(e,s,t)=>be(l+x,$(t),0,[e,s]),exports.useResultRowCount=(e,s)=>be(l+c,$(s),5,[e]),exports.useResultRowCountListener=(e,s,t,o)=>we(l+c,$(o),s,t,[e]),exports.useResultRowIds=Fe,exports.useResultRowIdsListener=(e,s,t,o)=>we(l+I,$(o),s,t,[e]),exports.useResultRowListener=(e,s,t,o,r)=>we(l+x,$(r),t,o,[e,s]),exports.useResultSortedRowIds=Oe,exports.useResultSortedRowIdsListener=(e,s,t,o,r,u,n,d)=>we(l+C,$(d),u,n,[e,s,t,o,r]),exports.useResultTable=(e,s)=>be(l+p,$(s),0,[e]),exports.useResultTableCellIds=(e,s)=>be(l+p+w,$(s),1,[e]),exports.useResultTableCellIdsListener=(e,s,t,o)=>we(l+p+w,$(o),s,t,[e]),exports.useResultTableListener=(e,s,t,o)=>we(l+p,$(o),s,t,[e]),exports.useRow=(e,s,t)=>be(x,N(t),0,[e,s]),exports.useRowCount=(e,s)=>be(c,N(s),5,[e]),exports.useRowCountListener=(e,s,t,o,r)=>we(c,N(r),s,t,[e],o),exports.useRowIds=me,exports.useRowIdsListener=(e,s,t,o,r)=>we(I,N(r),s,t,[e],o),exports.useRowListener=(e,s,t,o,r,u)=>we(x,N(u),t,o,[e,s],r),exports.useSetCellCallback=(e,s,t,o,r,u,l,n)=>Re(u,b,o,r,l,n,e,s,t),exports.useSetCheckpointCallback=(e=T,s=ae,t,o=T,r=ae)=>{const u=ee(t);return oe((s=>y(u,(t=>{const r=e(s);o(t.addCheckpoint(r),t,r)}))),[u,...s,...r])},exports.useSetPartialRowCallback=(e,s,t,o,r,u,l)=>Re(r,"PartialRow",t,o,u,l,e,s),exports.useSetPartialValuesCallback=(e,s,t,o,r)=>Re(t,"PartialValues",e,s,o,r),exports.useSetRowCallback=(e,s,t,o,r,u,l)=>Re(r,x,t,o,u,l,e,s),exports.useSetTableCallback=(e,s,t,o,r,u)=>Re(o,p,s,t,r,u,e),exports.useSetTablesCallback=(e,s,t,o,r)=>Re(t,a,e,s,o,r),exports.useSetValueCallback=(e,s,t,o,r,u)=>Re(o,R,s,t,r,u,e),exports.useSetValuesCallback=(e,s,t,o,r)=>Re(t,k,e,s,o,r),exports.useSliceIds=qe,exports.useSliceIdsListener=(e,s,t,o)=>we("SliceIds",Y(o),s,t,[e]),exports.useSliceRowIds=Be,exports.useSliceRowIdsListener=(e,s,t,o,r)=>we("Slice"+I,Y(r),t,o,[e,s]),exports.useSortedRowIds=Se,exports.useSortedRowIdsListener=(e,s,t,o,r,u,l,n,d)=>we(C,N(d),u,l,[e,s,t,o,r],n),exports.useStartTransactionListener=(e,s,t)=>we("Start"+te,N(t),e,s),exports.useStore=e=>_(e,0),exports.useStoreIds=()=>K(1),exports.useStoreOrStoreById=N,exports.useTable=(e,s)=>be(p,N(s),0,[e]),exports.useTableCellIds=(e,s)=>be(p+w,N(s),1,[e]),exports.useTableCellIdsListener=(e,s,t,o,r)=>we(p+w,N(r),s,t,[e],o),exports.useTableIds=ye,exports.useTableIdsListener=(e,s,t,o)=>we(i,N(o),e,s,ae,t),exports.useTableListener=(e,s,t,o,r)=>we(p,N(r),s,t,[e],o),exports.useTables=e=>be(a,N(e),0),exports.useTablesListener=(e,s,t,o)=>we(a,N(o),e,s,ae,t),exports.useUndoInformation=e=>{const s=ee(e),[o,r]=Ae(s);return[(u=o,!(0==V(u))),We(s),r,y(r,(e=>s?.getCheckpoint(e)))??t];var u},exports.useValue=Pe,exports.useValueIds=ve,exports.useValueIdsListener=(e,s,t,o)=>we(g,N(o),e,s,ae,t),exports.useValueListener=(e,s,t,o,r)=>we(R,N(r),s,t,[e],o),exports.useValues=e=>be(k,N(e),0),exports.useValuesListener=(e,s,t,o)=>we(k,N(o),e,s,ae,t),exports.useWillFinishTransactionListener=(e,s,t)=>we("WillFinish"+te,N(t),e,s);
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("../ui-react/index.cjs");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Has",c="Ids",h="Table",m=h+"s",g=h+c,b="Row",p=b+"Count",I=b+c,f="Cell",y=f+c,w="Value",C=w+"s",v=w+c,k="currentTarget",S="value",x=e=>l+e,T=globalThis.window,V=Math,R=V.min,q=V.floor,M=isFinite,N=e=>null==e,L=(e,t,s)=>N(e)?s?.():t(e),E=e=>e==a||e==n,z=e=>s(e)==o,O=e=>Array.isArray(e),$=(e,t,s)=>e.slice(t,s),A=e=>e.length,F=e=>{throw Error(e)},{PureComponent:J,Fragment:P,createElement:B,useCallback:D,useLayoutEffect:Q,useRef:j,useState:H}=e,W=(e,...t)=>N(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),U=(e,t)=>e.map(t),X=e=>0==A(e),Y=(e,...t)=>e.push(...t),Z=e=>e.shift(),_=Object,ee=e=>_.getPrototypeOf(e),te=_.entries,se=_.isFrozen,le=e=>!N(e)&&L(ee(e),(e=>e==_.prototype||N(ee(e))),(()=>!0)),ae=_.keys,ne=_.freeze,re=(e=[])=>_.fromEntries(e),oe=(e,t)=>t in e,ie=(e,t)=>(delete e[t],e),de=(e,t)=>U(te(e),(([e,s])=>t(s,e))),ue=e=>le(e)&&0==(e=>A(ae(e)))(e),ce=(e,t,s,l=0)=>N(e)||!le(e)||!l&&ue(e)||se(e)?(s?.(),!1):(de(e,((s,l)=>{t(s,l)||ie(e,l)})),!!l||!ue(e)),he=JSON.stringify,me=JSON.parse,ge=e=>he(e,((e,t)=>t instanceof Map?_.fromEntries([...t]):t)),be="tinybaseInspector",pe="TinyBase Inspector",Ie=["left","top","bottom","right","full"],fe="state",ye="sort",we="open",Ce="position",ve=we,ke="editable",Se=(...e)=>ge(e),xe=(e,t)=>U(G(e),t),Te=(e,s)=>[!!t.useCell(fe,e,ke,s),D((t=>{s.setCell(fe,e,ke,(e=>!e)),t.preventDefault()}),[s,e])],Ve="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Re='content:url("',qe=Re+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Me='</svg>")',Ne=Re+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Le=U([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>qe+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Me)),Ee=qe+"<path d='M20 20l60 60M20 80l60-60' />"+Me,ze=qe+`<path d='${Ve}' />`+Me,Oe=qe+`<path d='${Ve}M20 20l60 60' />`+Me,$e="*::-webkit-scrollbar",Ae=((e,t="")=>e.join(t))(de({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[$e]:"width:0.5rem;height:0.5rem;",[$e+"-track"]:"background:#111",[$e+"-thumb"]:"background:#999;border:1px solid #111",[$e+"-thumb:hover"]:"background:#fff",[$e+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ne,...re(U(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...re(U(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ne,"header>img:nth-of-type(6)":Ee,...re(U(Le,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":ze,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Fe=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!0),[],e);return t.useValue(ve,e)?null:B("img",{onClick:l,title:pe,"data-position":s})},Je=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(fe,e,we,r),i=t.useSetCellCallback(fe,e,we,(e=>e[k].open),[],r);return B("details",{open:o,onToggle:i},B("summary",null,s,a?B("img",{onClick:a,className:l?"done":"edit"}):null),n)},Pe=e=>{const t=s(e);return E(t)||t==r&&M(e)?t:void 0},Be=(e,t,s,l,a)=>N(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),De=(e,t,s)=>N(s)?e.delValue(t):e.setValue(t,s),Qe=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:je,useMemo:He,useState:We}=e,Ge="editable",Ke=(e,s)=>U(t.useTableCellIds(e,s),(t=>e+"."+t)),Ue=(e,t,s)=>{const l=je(e,t);return s?l:void 0},Xe=(...e)=>He((()=>e),e),Ye=(e,t)=>He((()=>({store:e,tableId:t})),[e,t]),Ze=(e,t)=>He((()=>({queries:e,queryId:t})),[e,t]),_e=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=We([e,t,l]),h=je((e=>{c(e),o?.(e)}),[o]),m=Ue((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=je((e=>h([i,d,e])),[h,i,d]),b=!0===r?ht:r;return[[i,d,u],m,He((()=>!1===r?null:B(b,{offset:u,limit:a,total:n,onChange:g})),[r,b,u,a,n,g])]},et=(e,t,l)=>He((()=>{const n=t??e;return r=O(n)?re(U(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)};var n},re(de(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,l,e]),tt=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>B("table",{className:e},i?B("caption",null,i):null,!1===t?null:B("thead",null,B("tr",null,!1===s?null:B(st,{sort:r??[],label:"Id",onClick:o}),de(l,(({label:e},t)=>B(st,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),B("tbody",null,U(n,(e=>B("tr",{key:e},!1===s?null:B("th",null,e),de(l,(({component:t,getComponentProps:s},l)=>B("td",{key:l},B(t,{...W(s,e,l),...a,rowId:e,cellId:l}))))))))),st=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>B("th",{onClick:Ue((()=>n?.(e)),[n,e],n),className:N(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},N(s)||t!=e?null:(s?"↓":"↑")+" ",a),lt=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return B("tr",null,!1===l?null:B(e.Fragment,null,B("th",null,s),B("th",null,u)),de(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return N(i)?null:B("td",{key:l},B(e,{...W(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:o=!0})=>{const[i,d]=We(),[u,c]=We(),[h,m]=We(),[g,b]=We(),[p,I]=We();u!==e&&(d(Pe(e)),c(e),m(e+""),b(Number(e)||0),I(!!e));const f=je(((e,s)=>{s(e),c(e),t(e)}),[t]),y=je((()=>{if(!l?.()){const e=Qe(i,r,n,a),s=Qe(e,h,g,p);d(e),c(s),t(s)}}),[l,t,h,g,p,i]);return B("div",{className:s},o?B("button",{className:i,onClick:y},i):null,Qe(i,B("input",{key:i,value:h,onChange:je((e=>f(e[k][S]+"",m)),[f])}),B("input",{key:i,type:"number",value:g,onChange:je((e=>f(Number(e[k][S]||0),b)),[f])}),B("input",{key:i,type:"checkbox",checked:p,onChange:je((e=>f(!!e[k].checked,I)),[f])})))},nt=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,b]=_e(s,l,i,a,n,t.useRowCount(e,r),d,u);return B(tt,{...h,params:Xe(et(t.useTableCellIds(e,r),c,o?ut:t.CellView),Ye(r,e),t.useSortedRowIds(e,...m,n,r),m,g,b)})},rt=({store:e,editable:s=!1,valueComponent:l=(s?ct:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>B("table",{className:n},!1===r?null:B("thead",null,B("tr",null,!1===o?null:B("th",null,"Id"),B("th",null,w))),B("tbody",null,U(t.useValueIds(e),(t=>B("tr",{key:t},!1===o?null:B("th",null,t),B("td",null,B(l,{...W(a,t),valueId:t,store:e}))))))),ot=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return B(tt,{...r,params:Xe(et(t.useTableCellIds(d,i),n,a?ut:t.CellView),Ye(i,d),t.useSliceRowIds(e,s,o))})},it=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=et([...Ke(c,u),...Ke(h,u)],n,a?ut:t.CellView),g=Xe(i,m,c,h,s,d,u);return B("table",{className:r},!1===o?null:B("thead",null,B("tr",null,!1===i?null:B(e.Fragment,null,B("th",null,c,".Id"),B("th",null,h,".Id")),de(m,(({label:e},t)=>B("th",{key:t},e))))),B("tbody",null,U(t.useRowIds(c,u),(e=>B(lt,{key:e,localRowId:e,params:g})))))},dt=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=_e(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return B(tt,{...c,params:Xe(et(t.useResultTableCellIds(e,r),d,t.ResultCellView),Ze(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,g)})},ut=({tableId:e,rowId:s,cellId:l,store:a,className:n,showType:r})=>B(at,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Ge+f,showType:r,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),ct=({valueId:e,store:s,className:l,showType:a})=>B(at,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Ge+w,showType:a,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),ht=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Ue((()=>t(l-a)),[t,l,a],l>0),i=Ue((()=>t(l+a)),[t,l,a],l+a<s);return B(e.Fragment,null,s>a&&B(e.Fragment,null,B("button",{className:"previous",disabled:0==l,onClick:o},"←"),B("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",R(s,l+a)," of "),s," ",1!=s?r:n)},mt=({indexes:e,indexesId:s,indexId:l,s:a})=>B(Je,{uniqueId:Se("i",s,l),summary:"Index: "+l,s:a},U(t.useSliceIds(l,e),(t=>B(gt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a,key:t})))),gt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Se("i",t,s,l),[r,o]=Te(n,a);return B(Je,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},B(ot,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return N(l)?null:B(Je,{uniqueId:Se("i",e),summary:"Indexes: "+(e??d),s:s},X(a)?"No indexes defined":xe(a,(t=>B(mt,{indexes:l,indexesId:e,indexId:t,s:s,key:t}))))},pt=({metrics:e,metricId:s})=>B("tr",null,B("th",null,s),B("td",null,e?.getTableId(s)),B("td",null,t.useMetric(s,e))),It=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return N(l)?null:B(Je,{uniqueId:Se("m",e),summary:"Metrics: "+(e??d),s:s},X(a)?"No metrics defined":B("table",null,B("thead",null,B("th",null,"Metric Id"),B("th",null,"Table Id"),B("th",null,"Metric")),B("tbody",null,U(a,(e=>B(pt,{metrics:l,metricId:e,key:e}))))))},ft=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=Se("q",s,l),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a);return B(Je,{uniqueId:n,summary:"Query: "+l,s:a},B(dt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},yt=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return N(l)?null:B(Je,{uniqueId:Se("q",e),summary:"Queries: "+(e??d),s:s},X(a)?"No queries defined":xe(a,(t=>B(ft,{queries:l,queriesId:e,queryId:t,s:s,key:t}))))},wt=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Se("r",t,s),[n,r]=Te(a,l);return B(Je,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},B(it,{relationshipId:s,relationships:e,editable:n}))},Ct=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return N(l)?null:B(Je,{uniqueId:Se("r",e),summary:"Relationships: "+(e??d),s:s},X(a)?"No relationships defined":xe(a,(t=>B(wt,{relationships:l,relationshipsId:e,relationshipId:t,s:s,key:t}))))},vt=({tableId:e,store:s,storeId:l,s:a})=>{const n=Se("t",l,e),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a),[u,c]=Te(n,a);return B(Je,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},B(nt,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},kt=({store:e,storeId:s,s:l})=>{const a=Se("v",s),[n,r]=Te(a,l);return X(t.useValueIds(e))?null:B(Je,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},B(rt,{store:e,editable:n}))},St=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return N(l)?null:B(Je,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??d),s:s},B(kt,{storeId:e,store:l,s:s}),xe(a,(t=>B(vt,{store:l,storeId:e,tableId:t,s:s,key:t}))))},xt=({s:e})=>{const s=j(null),l=j(0),[a,n]=H(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);Q((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=q(r)+e.clientWidth&&e.scrollHeight>=q(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=D((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),g=t.useIndexesIds(),b=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return N(d)&&X(u)&&N(c)&&X(h)&&N(m)&&X(g)&&N(b)&&X(p)&&N(I)&&X(f)?B("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):B("article",{ref:s,onScroll:i},B(St,{s:e}),U(u,(t=>B(St,{storeId:t,s:e,key:t}))),B(It,{s:e}),U(h,(t=>B(It,{metricsId:t,s:e,key:t}))),B(bt,{s:e}),U(g,(t=>B(bt,{indexesId:t,s:e,key:t}))),B(Ct,{s:e}),U(p,(t=>B(Ct,{relationshipsId:t,s:e,key:t}))),B(yt,{s:e}),U(f,(t=>B(yt,{queriesId:t,s:e,key:t}))))};class Tt extends J{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?B("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Vt=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!1),[],e),a=t.useSetValueCallback(Ce,(e=>Number(e[k].dataset.id)),[],e);return B("header",null,B("img",{title:pe}),B("span",null,pe),U(Ie,((e,t)=>t==s?null:B("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),B("img",{onClick:l,title:"Close"}))},Rt=({s:e})=>{const s=t.useValue(Ce,e)??1;return t.useValue(ve,e)?B("main",{"data-position":s},B(Vt,{s:e}),B(Tt,null,B(xt,{s:e}))):null},qt=e=>t=>{return s=(t,s)=>t+e(s),$t(t).reduce(s,0);var s},Mt=e=>e?.size??0,Nt=qt(Mt),Lt=qt(Nt),Et=qt(Lt),zt=(e,t)=>e?.has(t)??!1,Ot=e=>N(e)||0==Mt(e),$t=e=>[...e?.values()??[]],At=e=>e.clear(),Ft=(e,t)=>e?.forEach(t),Jt=(e,t)=>e?.delete(t),Pt=e=>new Map(e),Bt=e=>[...e?.keys()??[]],Dt=(e,t)=>e?.get(t),Qt=(e,t)=>Ft(e,((e,s)=>t(s,e))),jt=(e,t,s)=>N(s)?(Jt(e,t),e):e?.set(t,s),Ht=(e,t,s,l)=>(zt(e,t)?l?.(Dt(e,t)):jt(e,t,s()),Dt(e,t)),Wt=(e,t,s,l=jt)=>(de(t,((t,l)=>s(e,l,t))),Qt(e,(s=>oe(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const a={};return Ft(e,((e,n)=>{if(!s?.(e,n)){const s=t?t(e,n):e;l?.(s)||(a[n]=s)}})),a},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),Ot,ue),Ut=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),Ot,ue),Xt=(e,t)=>{const s=Pt();return Ft(e,((e,l)=>s.set(l,t?.(e)??e))),s},Yt=e=>Xt(e,Xt),Zt=e=>Xt(e,Yt),_t=(e,t,s,l,a=0)=>L((s?Ht:Dt)(e,t[a],a>A(t)-2?s:Pt),(n=>{if(a>A(t)-2)return l?.(n)&&jt(e,t[a]),n;const r=_t(n,t,s,l,a+1);return Ot(n)&&jt(e,t[a]),r})),es=Pt(),ts=Pt(),ss="storage",ls=e=>new Set(O(e)||N(e)?e:[e]),as=(e,t)=>e?.add(t),ns=/^\d+$/,rs=()=>{const e=[];let t=0;return[s=>(s?Z(e):null)??l+t++,t=>{ns.test(t)&&A(e)<1e3&&Y(e,t)}]},os=e=>[e,e],is=(e,t=Nt)=>t(e[0])+t(e[1]),ds=()=>[Pt(),Pt()],us=e=>[...e],cs=([e,t])=>e===t;Pt(U("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(l),((e,t)=>[e,t])));const hs=(e,t,s)=>jt(e,t,Dt(e,t)==-s?void 0:s),ms=()=>{let e,t,s=!1,a=!1,n=0,o=[];const c=Pt(),k=Pt(),S=Pt(),T=Pt(),V=Pt(),R=Pt(),q=Pt(),M=Pt(),F=Pt(),J=Pt(),P=Pt(),B=Pt(),D=Pt(),Q=Pt(),j=ls(),H=Pt(),W=Pt(),X=Pt(),Z=Pt(),_=ds(),ee=ds(),te=ds(),se=ds(),le=ds(),ae=ds(),re=ds(),he=ds(),be=ds(),pe=ds(),Ie=ds(),fe=ds(),ye=ds(),we=ds(),Ce=ds(),ve=ds(),ke=ds(),Se=ds(),xe=ds(),Te=ds(),Ve=ds(),Re=ds(),qe=Pt(),Me=ds(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=rs(),a=Pt();return[(s,n,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return jt(a,d,[s,n,r,o,i]),as(_t(n,r??[l],ls),d),d},(t,s,...n)=>K(((e,t=[l])=>{const s=[],a=(e,l)=>l==A(t)?Y(s,e):null===t[l]?Ft(e,(e=>a(e,l+1))):K([t[l],null],(t=>a(Dt(e,t),l+1)));return a(e,0),s})(t,s),(t=>Ft(t,(t=>Dt(a,t)[0](e,...s??[],...n))))),e=>L(Dt(a,e),(([,t,n])=>(_t(t,n??[l],void 0,(t=>(Jt(t,e),Ot(t)?1:0))),jt(a,e),s(e),n))),t=>L(Dt(a,t),(([t,,s=[],l,a])=>{const n=(...r)=>{const o=A(r);o==A(s)?t(e,...r,...a(r)):N(s[o])?K(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Oe=e=>{if(!ce(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!E(t)&&t!=r||(Pe(e[d])!=t&&ie(e,d),0))},$e=O,Ae=(t,s)=>(!e||zt(P,s)||pt(s))&&ce(t,((e,t)=>Fe(s,t,e)),(()=>pt(s))),Fe=(e,t,s,l)=>ce(l?s:He(s,e,t),((l,a)=>L(Je(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>pt(e,t))),Je=(t,s,l,a)=>e?L(Dt(Dt(P,t),l),(e=>Pe(a)!=e[i]?pt(t,s,l,a,e[d]):a),(()=>pt(t,s,l,a))):N(Pe(a))?pt(t,s,l,a):a,Qe=(e,t)=>ce(t?e:We(e),((t,s)=>L(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?L(Dt(D,e),(t=>Pe(s)!=t[i]?It(e,s,t[d]):s),(()=>It(e,s))):N(Pe(s))?It(e,s):s,He=(e,t,s)=>(L(Dt(B,t),(([l,a])=>{Ft(l,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(a,(l=>{oe(e,l)||pt(t,s,l)}))})),e),We=e=>(t&&(Ft(Q,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(j,(t=>{oe(e,t)||It(t)}))),e),Ge=e=>Wt(P,e,((e,t,s)=>{const l=Pt(),a=ls();Wt(Ht(P,t,Pt),s,((e,t,s)=>{jt(e,t,s),L(s[d],(e=>jt(l,t,e)),(()=>as(a,t)))})),jt(B,t,[l,a])}),((e,t)=>{jt(P,t),jt(B,t)})),Ke=e=>Wt(D,e,((e,t,s)=>{jt(D,t,s),L(s[d],(e=>jt(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{jt(D,t),jt(Q,t),Jt(j,t)})),Ue=e=>ue(e)?Rs():ks(e),Xe=e=>Wt(X,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Wt(Ht(X,e,(()=>(ut(e,1),jt(H,e,rs()),jt(W,e,Pt()),Pt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,a)=>Wt(Ht(t,s,(()=>(ct(e,s,1),Pt()))),l,((t,l,a)=>_e(e,s,t,l,a)),((l,n)=>it(e,t,s,l,n,a))),_e=(e,t,s,l,a)=>{zt(s,l)||ht(e,t,l,1);const n=Dt(s,l);a!==n&&(mt(e,t,l,n,a),jt(s,l,a))},et=(e,t,s,l,a)=>L(Dt(t,s),(t=>_e(e,s,t,l,a)),(()=>Ze(e,t,s,He({[l]:a},e,s)))),tt=e=>ue(e)?Ns():Ss(e),st=e=>Wt(Z,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{zt(Z,e)||gt(e,1);const s=Dt(Z,e);t!==s&&(bt(e,s,t),jt(Z,e,t))},at=(e,t)=>{const[s]=Dt(H,e),l=s(t);return zt(Dt(X,e),l)?at(e,t):l},nt=e=>Dt(X,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Dt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,a,n)=>{const r=Dt(Dt(B,e)?.[0],a);if(!N(r)&&!n)return _e(e,s,l,a,r);const o=t=>{mt(e,s,t,Dt(l,t)),ht(e,s,t,-1),jt(l,t)};N(r)?o(a):Qt(l,o),Ot(l)&&(ct(e,s,-1),Ot(jt(t,s))&&(ut(e,-1),jt(X,e),jt(H,e),jt(W,e)))},dt=e=>{const t=Dt(Q,e);if(!N(t))return lt(e,t);bt(e,Dt(Z,e)),gt(e,-1),jt(Z,e)},ut=(e,t)=>hs(c,e,t),ct=(e,t,s)=>hs(Ht(T,e,Pt),t,s)&&jt(S,e,Ht(S,e,(()=>0))+s),ht=(e,t,s,l)=>{const a=Dt(W,e),n=Dt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&hs(Ht(k,e,Pt),s,l),jt(a,s,n!=-l?n+l:null),hs(Ht(Ht(V,e,Pt),t,Pt),s,l)},mt=(e,t,s,l,a)=>{Ht(Ht(Ht(R,e,Pt),t,Pt),s,(()=>[l,0]))[1]=a,o[3]?.(e,t,s,a)},gt=(e,t)=>hs(q,e,t),bt=(e,t,s)=>{Ht(M,e,(()=>[t,0]))[1]=s,o[4]?.(e,s)},pt=(e,t,s,l,a)=>(Y(Ht(Ht(Ht(F,e,Pt),t,Pt),s,(()=>[])),l),a),It=(e,t,s)=>(Y(Ht(J,e,(()=>[])),t),s),ft=(e,t,s)=>L(Dt(Dt(Dt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...os(ss(e,t,s))])),yt=e=>L(Dt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...os(bs(e))])),wt=e=>Ot(F)||Ot(ve[e])?0:Ft(e?Zt(F):F,((t,s)=>Ft(t,((t,l)=>Ft(t,((t,a)=>Le(ve[e],[s,l,a],t))))))),Ct=e=>Ot(J)||Ot(ke[e])?0:Ft(e?Xt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!Ot(e))return Le(t,l,(()=>Gt(e))),Qt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=ps();t!=s&&Le(_[e],void 0,t);const l=Ot(pe[e]),a=Ot(ye[e])&&Ot(we[e])&&Ot(be[e])&&Ot(Ie[e])&&Ot(ae[e])&&Ot(re[e])&&Ot(he[e])&&l&&Ot(te[e])&&Ot(se[e]),n=Ot(Ce[e])&&Ot(fe[e])&&Ot(le[e])&&Ot(ee[e]);if(!a||!n){const t=e?[Xt(c),Yt(k),Xt(S),Yt(T),Zt(V),Zt(R)]:[c,k,S,T,V,R];if(!a){vt(t[0],te[e],se[e]),Ft(t[1],((t,s)=>vt(t,ae[e],re[e],[s]))),Ft(t[2],((t,s)=>{0!=t&&Le(he[e],[s],qt(s))}));const s=ls();Ft(t[3],((t,a)=>{vt(t,be[e],Ie[e],[a])&&!l&&(Le(pe[e],[a,null]),as(s,a))})),l||Ft(t[5],((t,l)=>{if(!zt(s,l)){const s=ls();Ft(t,(e=>Ft(e,(([t,l],a)=>l!==t?as(s,a):Jt(e,a))))),Ft(s,(t=>Le(pe[e],[l,t])))}})),Ft(t[4],((t,s)=>Ft(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!n){let s;Ft(t[5],((t,l)=>{let a;Ft(t,((t,n)=>{let r;Ft(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,n,i],o,t,ft),s=a=r=1)})),r&&Le(fe[e],[l,n],ft)})),a&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},St=e=>{const t=Cs();t!=a&&Le(Se[e],void 0,t);const s=Ot(Te[e])&&Ot(Ve[e]),l=Ot(Re[e])&&Ot(xe[e]);if(!s||!l){const t=e?[Xt(q),Xt(M)]:[q,M];if(s||vt(t[0],Te[e],Ve[e]),!l){let s;Ft(t[1],(([t,l],a)=>{l!==t&&(Le(Re[e],[a],l,t,yt),s=1)})),s&&Le(xe[e],void 0,yt)}}},xt=(e,...t)=>(zs((()=>e(...U(t,x)))),As),Tt=()=>Ut(X),Vt=()=>Bt(X),Rt=e=>Bt(Dt(W,x(e))),qt=e=>Mt(Dt(X,x(e))),$t=e=>Bt(Dt(X,x(e))),es=(e,t,s,l=0,a)=>{return U($(G((n=Dt(X,x(e)),r=(e,s)=>[N(t)?s:Dt(e,x(t)),s],U([...n?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,N(a)?a:l+a),(([,e])=>e));var n,r},ts=(e,t)=>Bt(Dt(Dt(X,x(e)),x(t))),ss=(e,t,s)=>Dt(Dt(Dt(X,x(e)),x(t)),x(s)),ns=()=>Gt(Z),gs=()=>Bt(Z),bs=e=>Dt(Z,x(e)),ps=()=>!Ot(X),Is=e=>zt(X,x(e)),fs=(e,t)=>zt(Dt(W,x(e)),x(t)),ys=(e,t)=>zt(Dt(X,x(e)),x(t)),ws=(e,t,s)=>zt(Dt(Dt(X,x(e)),x(t)),x(s)),Cs=()=>!Ot(Z),vs=e=>zt(Z,x(e)),ks=e=>xt((()=>(e=>ce(e,Ae,pt))(e)?Xe(e):0)),Ss=e=>xt((()=>Qe(e)?st(e):0)),xs=e=>{try{Ue(me(e))}catch{}return As},Ts=t=>xt((()=>{if((e=ce(t,(e=>ce(e,Oe))))&&(Ge(t),!Ot(X))){const e=Tt();Rs(),ks(e)}})),Vs=e=>xt((()=>{if(t=(e=>ce(e,Oe))(e)){const s=ns();Es(),Ns(),t=!0,Ke(e),Ss(s)}})),Rs=()=>xt((()=>Xe({}))),qs=e=>xt((e=>zt(X,e)?rt(e):0),e),Ms=(e,t)=>xt(((e,t)=>L(Dt(X,e),(s=>zt(s,t)?ot(e,s,t):0))),e,t),Ns=()=>xt((()=>st({}))),Ls=()=>xt((()=>{Ge({}),e=!1})),Es=()=>xt((()=>{Ke({}),t=!1})),zs=(e,t)=>{if(-1!=n){Os();const s=e();return $s(t),s}},Os=()=>(-1!=n&&n++,1==n&&(o[0]?.(),Le(qe)),As),$s=e=>(n>0&&(n--,0==n&&(n=1,wt(1),Ot(R)||kt(1),Ct(1),Ot(M)||St(1),e?.(As)&&(Ft(R,((e,t)=>Ft(e,((e,s)=>Ft(e,(([e],l)=>Be(As,t,s,l,e))))))),At(R),Ft(M,(([e],t)=>De(As,t,e))),At(M)),Le(Me[0],void 0),n=-1,wt(0),Ot(R)||kt(0),Ct(0),Ot(M)||St(0),o[1]?.(),Le(Me[1],void 0),o[2]?.(),n=0,s=ps(),a=Cs(),K([c,k,S,T,V,R,F,q,M,J],At))),As),As={getContent:()=>[Tt(),ns()],getTables:Tt,getTableIds:Vt,getTable:e=>Kt(Dt(X,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:$t,getSortedRowIds:es,getRow:(e,t)=>Gt(Dt(Dt(X,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ns,getValueIds:gs,getValue:bs,hasTables:ps,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>ge(X),getValuesJson:()=>ge(Z),getJson:()=>ge([X,Z]),getTablesSchemaJson:()=>ge(P),getValuesSchemaJson:()=>ge(D),getSchemaJson:()=>ge([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>xt((()=>$e(e)?(([e,t])=>{(ue(e)?Rs:ks)(e),(ue(t)?Ns:Ss)(t)})(e):0)),setTables:ks,setTable:(e,t)=>xt((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>xt(((e,t)=>Fe(e,t,s)?Ze(e,nt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,nt(e),l=at(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>xt(((e,t)=>{if(Fe(e,t,s,1)){const l=nt(e);de(s,((s,a)=>et(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>xt(((e,t,s)=>L(Je(e,t,s,z(l)?l(ss(e,t,s)):l),(l=>et(e,nt(e),t,s,l)))),e,t,s),setValues:Ss,setPartialValues:e=>xt((()=>Qe(e,1)?de(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>xt((e=>L(je(e,z(t)?t(bs(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>xt((()=>{de(e[0],((e,t)=>N(e)?qs(t):de(e,((e,s)=>N(e)?Ms(t,s):de(e,((e,l)=>Be(As,t,s,l,e))))))),de(e[1],((e,t)=>De(As,t,e)))})),setTablesJson:xs,setValuesJson:e=>{try{tt(me(e))}catch{}return As},setJson:e=>xt((()=>{try{const[t,s]=me(e);Ue(t),tt(s)}catch{xs(e)}})),setTablesSchema:Ts,setValuesSchema:Vs,setSchema:(e,t)=>xt((()=>{Ts(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>xt(((e,t,s)=>L(Dt(X,e),(a=>L(Dt(a,t),(n=>zt(n,s)?it(e,a,t,n,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>xt((e=>zt(Z,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>xt((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Dt(c,t)?void 0:Gt(e,((e,s)=>-1===Dt(Dt(T,t),s)?void 0:Gt(e,(([,e])=>e),(e=>cs(e)))),Ot,ue)),Ot,ue),Gt(M,(([,e])=>e),(e=>cs(e))),1],getTransactionLog:()=>[!Ot(R),!Ot(M),Ut(R,us,cs),Ut(F),Gt(M,us,cs),Gt(J),Gt(c),Kt(T),Ut(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Ft(X,((t,s)=>e(s,(e=>Ft(t,((t,s)=>e(s,(e=>Qt(t,e))))))))),forEachTableCell:(e,t)=>Qt(Dt(W,x(e)),t),forEachRow:(e,t)=>Ft(Dt(X,x(e)),((e,s)=>t(s,(t=>Qt(e,t))))),forEachCell:(e,t,s)=>Qt(Dt(Dt(X,x(e)),x(t)),s),forEachValue:e=>Qt(Z,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=es(e,t,s,l,a);return Ne((()=>{const r=es(e,t,s,l,a);var i,d,u;d=o,A(i=r)===A(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(As,e,t,s,l,a,o))}),pe[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:is(_),tables:is(ee),tableIds:is(te),hasTable:is(se),table:is(le),tableCellIds:is(ae),hasTableCell:is(re,Lt),rowCount:is(he),rowIds:is(be),sortedRowIds:is(pe),hasRow:is(Ie,Lt),row:is(fe,Lt),cellIds:is(ye,Lt),hasCell:is(we,Et),cell:is(Ce,Et),invalidCell:is(ve,Et),hasValues:is(Se),values:is(xe),valueIds:is(Te),hasValue:is(Ve),value:is(Re),invalidValue:is(ke),transaction:Nt(qe)+is(Me)}),isMergeable:()=>!1,createStore:ms,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,a)=>o=[e,t,s,l,a]};return de({[u+m]:[0,_,[],()=>[ps()]],[m]:[0,ee],[g]:[0,te],[u+h]:[1,se,[Vt],e=>[Is(...e)]],[h]:[1,le,[Vt]],[h+y]:[1,ae,[Vt]],[u+h+f]:[2,re,[Vt,Rt],e=>[fs(...e)]],[p]:[1,he,[Vt]],[I]:[1,be,[Vt]],[u+b]:[2,Ie,[Vt,$t],e=>[ys(...e)]],[b]:[2,fe,[Vt,$t]],[y]:[2,ye,[Vt,$t]],[u+f]:[3,we,[Vt,$t,ts],e=>[ws(...e)]],[f]:[3,Ce,[Vt,$t,ts],e=>os(ss(...e))],InvalidCell:[3,ve],[u+C]:[0,Se,[],()=>[Cs()]],[C]:[0,xe],[v]:[0,Te],[u+w]:[1,Ve,[gs],e=>[vs(...e)]],[w]:[1,Re,[gs],e=>os(bs(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],a)=>{As["add"+a+"Listener"]=(...a)=>Ne(a[e],t[a[e+1]?1:0],e>0?$(a,0,e):void 0,s,l)})),ne(As)};exports.Inspector=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(ms),a=Ie.indexOf(e);return t.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,a,n,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Ht(es,i,(()=>0)),Ht(ts,i,(()=>[]));const[b,p,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ue(e)||!ue(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ue(e)||!ue(t),t.setContent]:F("Store type not supported by this Persister"))(r,e),w=t=>{(b&&O(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await x((async()=>{try{const e=await t();O(e)?w(e):F("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),T),v=()=>(u&&(a(u),u=void 0),T),k=async e=>(1!=h&&(h=2,g++,await x((async()=>{try{await s(p,e)}catch(e){}h=0}))),T),S=()=>(L(c,e.delListener),c=void 0,T),x=async(...e)=>(Y(Dt(ts,i),...e),await(async()=>{if(!Dt(es,i)){for(jt(es,i,1);!N(d=Z(Dt(ts,i)));)try{await d()}catch(e){}jt(es,i,0)}})(),T),T={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return T},stopAutoLoad:v,isAutoLoading:()=>!N(u),save:k,startAutoSave:async()=>(await S().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),T),stopAutoSave:S,isAutoSaving:()=>!N(c),schedule:x,getStore:()=>e,destroy:()=>(Dt(ts,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return ne(T)})(e,(async()=>{return e=s.getItem(t),me(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),he(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(me(l.newValue))}catch{e()}};return T.addEventListener(ss,l),l}),(e=>T.removeEventListener(ss,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==a?1:a,open:!!s}]),await e.startAutoSave()})),B(P,null,B("aside",{id:be},B(Fe,{s:l}),B(Rt,{s:l})),B("style",null,Ae))};
|
|
1
|
+
"use strict";var e=require("react"),t=require("../ui-react/index.cjs");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Has",c="Ids",h="Table",m=h+"s",g=h+c,b="Row",p=b+"Count",I=b+c,f="Cell",y=f+c,w="Value",C=w+"s",v=w+c,k="currentTarget",S="value",x=e=>l+e,T=globalThis.window,V=Math,R=V.min,q=V.floor,M=isFinite,N=e=>null==e,L=(e,t,s)=>N(e)?s?.():t(e),E=e=>e==a||e==n,z=e=>s(e)==o,O=e=>Array.isArray(e),$=(e,t,s)=>e.slice(t,s),A=e=>e.length,F=e=>{throw Error(e)},{PureComponent:J,Fragment:P,createElement:B,useCallback:D,useLayoutEffect:Q,useRef:j,useState:H}=e,W=(e,...t)=>N(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),U=(e,t)=>e.map(t),X=e=>0==A(e),Y=(e,...t)=>e.push(...t),Z=e=>e.shift(),_=Object,ee=e=>_.getPrototypeOf(e),te=_.entries,se=_.isFrozen,le=e=>!N(e)&&L(ee(e),(e=>e==_.prototype||N(ee(e))),(()=>!0)),ae=_.keys,ne=_.freeze,re=(e=[])=>_.fromEntries(e),oe=(e,t)=>t in e,ie=(e,t)=>(delete e[t],e),de=(e,t)=>U(te(e),(([e,s])=>t(s,e))),ue=e=>le(e)&&0==(e=>A(ae(e)))(e),ce=(e,t,s,l=0)=>N(e)||!le(e)||!l&&ue(e)||se(e)?(s?.(),!1):(de(e,((s,l)=>{t(s,l)||ie(e,l)})),!!l||!ue(e)),he=JSON.stringify,me=JSON.parse,ge=e=>he(e,((e,t)=>t instanceof Map?_.fromEntries([...t]):t)),be="tinybaseInspector",pe="TinyBase Inspector",Ie=["left","top","bottom","right","full"],fe="state",ye="sort",we="open",Ce="position",ve=we,ke="editable",Se=(...e)=>ge(e),xe=(e,t)=>U(G([...e]),t),Te=(e,s)=>[!!t.useCell(fe,e,ke,s),D((t=>{s.setCell(fe,e,ke,(e=>!e)),t.preventDefault()}),[s,e])],Ve="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Re='content:url("',qe=Re+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Me='</svg>")',Ne=Re+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Le=U([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>qe+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Me)),Ee=qe+"<path d='M20 20l60 60M20 80l60-60' />"+Me,ze=qe+`<path d='${Ve}' />`+Me,Oe=qe+`<path d='${Ve}M20 20l60 60' />`+Me,$e="*::-webkit-scrollbar",Ae=((e,t="")=>e.join(t))(de({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[$e]:"width:0.5rem;height:0.5rem;",[$e+"-track"]:"background:#111",[$e+"-thumb"]:"background:#999;border:1px solid #111",[$e+"-thumb:hover"]:"background:#fff",[$e+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ne,...re(U(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...re(U(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ne,"header>img:nth-of-type(6)":Ee,...re(U(Le,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":ze,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Fe=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!0),[],e);return t.useValue(ve,e)?null:B("img",{onClick:l,title:pe,"data-position":s})},Je=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(fe,e,we,r),i=t.useSetCellCallback(fe,e,we,(e=>e[k].open),[],r);return B("details",{open:o,onToggle:i},B("summary",null,s,a?B("img",{onClick:a,className:l?"done":"edit"}):null),n)},Pe=e=>{const t=s(e);return E(t)||t==r&&M(e)?t:void 0},Be=(e,t,s,l,a)=>N(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),De=(e,t,s)=>N(s)?e.delValue(t):e.setValue(t,s),Qe=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:je,useMemo:He,useState:We}=e,Ge="editable",Ke=(e,s)=>U(t.useTableCellIds(e,s),(t=>e+"."+t)),Ue=(e,t,s)=>{const l=je(e,t);return s?l:void 0},Xe=(...e)=>He((()=>e),e),Ye=(e,t)=>He((()=>({store:e,tableId:t})),[e,t]),Ze=(e,t)=>He((()=>({queries:e,queryId:t})),[e,t]),_e=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=We([e,t,l]),h=je((e=>{c(e),o?.(e)}),[o]),m=Ue((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=je((e=>h([i,d,e])),[h,i,d]),b=!0===r?ht:r;return[[i,d,u],m,He((()=>!1===r?null:B(b,{offset:u,limit:a,total:n,onChange:g})),[r,b,u,a,n,g])]},et=(e,t,l)=>He((()=>{const n=t??e;return r=O(n)?re(U(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)};var n},re(de(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,l,e]),tt=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>B("table",{className:e},i?B("caption",null,i):null,!1===t?null:B("thead",null,B("tr",null,!1===s?null:B(st,{sort:r??[],label:"Id",onClick:o}),de(l,(({label:e},t)=>B(st,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),B("tbody",null,U(n,(e=>B("tr",{key:e},!1===s?null:B("th",null,e),de(l,(({component:t,getComponentProps:s},l)=>B("td",{key:l},B(t,{...W(s,e,l),...a,rowId:e,cellId:l}))))))))),st=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>B("th",{onClick:Ue((()=>n?.(e)),[n,e],n),className:N(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},N(s)||t!=e?null:(s?"↓":"↑")+" ",a),lt=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return B("tr",null,!1===l?null:B(e.Fragment,null,B("th",null,s),B("th",null,u)),de(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return N(i)?null:B("td",{key:l},B(e,{...W(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:o=!0})=>{const[i,d]=We(),[u,c]=We(),[h,m]=We(),[g,b]=We(),[p,I]=We();u!==e&&(d(Pe(e)),c(e),m(e+""),b(Number(e)||0),I(!!e));const f=je(((e,s)=>{s(e),c(e),t(e)}),[t]),y=je((()=>{if(!l?.()){const e=Qe(i,r,n,a),s=Qe(e,h,g,p);d(e),c(s),t(s)}}),[l,t,h,g,p,i]);return B("div",{className:s},o?B("button",{className:i,onClick:y},i):null,Qe(i,B("input",{key:i,value:h,onChange:je((e=>f(e[k][S]+"",m)),[f])}),B("input",{key:i,type:"number",value:g,onChange:je((e=>f(Number(e[k][S]||0),b)),[f])}),B("input",{key:i,type:"checkbox",checked:p,onChange:je((e=>f(!!e[k].checked,I)),[f])})))},nt=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,b]=_e(s,l,i,a,n,t.useRowCount(e,r),d,u);return B(tt,{...h,params:Xe(et(t.useTableCellIds(e,r),c,o?ut:t.CellView),Ye(r,e),t.useSortedRowIds(e,...m,n,r),m,g,b)})},rt=({store:e,editable:s=!1,valueComponent:l=(s?ct:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>B("table",{className:n},!1===r?null:B("thead",null,B("tr",null,!1===o?null:B("th",null,"Id"),B("th",null,w))),B("tbody",null,U(t.useValueIds(e),(t=>B("tr",{key:t},!1===o?null:B("th",null,t),B("td",null,B(l,{...W(a,t),valueId:t,store:e}))))))),ot=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return B(tt,{...r,params:Xe(et(t.useTableCellIds(d,i),n,a?ut:t.CellView),Ye(i,d),t.useSliceRowIds(e,s,o))})},it=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=et([...Ke(c,u),...Ke(h,u)],n,a?ut:t.CellView),g=Xe(i,m,c,h,s,d,u);return B("table",{className:r},!1===o?null:B("thead",null,B("tr",null,!1===i?null:B(e.Fragment,null,B("th",null,c,".Id"),B("th",null,h,".Id")),de(m,(({label:e},t)=>B("th",{key:t},e))))),B("tbody",null,U(t.useRowIds(c,u),(e=>B(lt,{key:e,localRowId:e,params:g})))))},dt=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=_e(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return B(tt,{...c,params:Xe(et(t.useResultTableCellIds(e,r),d,t.ResultCellView),Ze(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,g)})},ut=({tableId:e,rowId:s,cellId:l,store:a,className:n,showType:r})=>B(at,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Ge+f,showType:r,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),ct=({valueId:e,store:s,className:l,showType:a})=>B(at,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Ge+w,showType:a,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),ht=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Ue((()=>t(l-a)),[t,l,a],l>0),i=Ue((()=>t(l+a)),[t,l,a],l+a<s);return B(e.Fragment,null,s>a&&B(e.Fragment,null,B("button",{className:"previous",disabled:0==l,onClick:o},"←"),B("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",R(s,l+a)," of "),s," ",1!=s?r:n)},mt=({indexes:e,indexesId:s,indexId:l,s:a})=>B(Je,{uniqueId:Se("i",s,l),summary:"Index: "+l,s:a},U(t.useSliceIds(l,e),(t=>B(gt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a,key:t})))),gt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Se("i",t,s,l),[r,o]=Te(n,a);return B(Je,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},B(ot,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return N(l)?null:B(Je,{uniqueId:Se("i",e),summary:"Indexes: "+(e??d),s:s},X(a)?"No indexes defined":xe(a,(t=>B(mt,{indexes:l,indexesId:e,indexId:t,s:s,key:t}))))},pt=({metrics:e,metricId:s})=>B("tr",null,B("th",null,s),B("td",null,e?.getTableId(s)),B("td",null,t.useMetric(s,e))),It=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return N(l)?null:B(Je,{uniqueId:Se("m",e),summary:"Metrics: "+(e??d),s:s},X(a)?"No metrics defined":B("table",null,B("thead",null,B("th",null,"Metric Id"),B("th",null,"Table Id"),B("th",null,"Metric")),B("tbody",null,U(a,(e=>B(pt,{metrics:l,metricId:e,key:e}))))))},ft=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=Se("q",s,l),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a);return B(Je,{uniqueId:n,summary:"Query: "+l,s:a},B(dt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},yt=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return N(l)?null:B(Je,{uniqueId:Se("q",e),summary:"Queries: "+(e??d),s:s},X(a)?"No queries defined":xe(a,(t=>B(ft,{queries:l,queriesId:e,queryId:t,s:s,key:t}))))},wt=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Se("r",t,s),[n,r]=Te(a,l);return B(Je,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},B(it,{relationshipId:s,relationships:e,editable:n}))},Ct=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return N(l)?null:B(Je,{uniqueId:Se("r",e),summary:"Relationships: "+(e??d),s:s},X(a)?"No relationships defined":xe(a,(t=>B(wt,{relationships:l,relationshipsId:e,relationshipId:t,s:s,key:t}))))},vt=({tableId:e,store:s,storeId:l,s:a})=>{const n=Se("t",l,e),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a),[u,c]=Te(n,a);return B(Je,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},B(nt,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},kt=({store:e,storeId:s,s:l})=>{const a=Se("v",s),[n,r]=Te(a,l);return X(t.useValueIds(e))?null:B(Je,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},B(rt,{store:e,editable:n}))},St=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return N(l)?null:B(Je,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??d),s:s},B(kt,{storeId:e,store:l,s:s}),xe(a,(t=>B(vt,{store:l,storeId:e,tableId:t,s:s,key:t}))))},xt=({s:e})=>{const s=j(null),l=j(0),[a,n]=H(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);Q((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=q(r)+e.clientWidth&&e.scrollHeight>=q(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=D((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),g=t.useIndexesIds(),b=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return N(d)&&X(u)&&N(c)&&X(h)&&N(m)&&X(g)&&N(b)&&X(p)&&N(I)&&X(f)?B("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):B("article",{ref:s,onScroll:i},B(St,{s:e}),U(u,(t=>B(St,{storeId:t,s:e,key:t}))),B(It,{s:e}),U(h,(t=>B(It,{metricsId:t,s:e,key:t}))),B(bt,{s:e}),U(g,(t=>B(bt,{indexesId:t,s:e,key:t}))),B(Ct,{s:e}),U(p,(t=>B(Ct,{relationshipsId:t,s:e,key:t}))),B(yt,{s:e}),U(f,(t=>B(yt,{queriesId:t,s:e,key:t}))))};class Tt extends J{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?B("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Vt=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!1),[],e),a=t.useSetValueCallback(Ce,(e=>Number(e[k].dataset.id)),[],e);return B("header",null,B("img",{title:pe}),B("span",null,pe),U(Ie,((e,t)=>t==s?null:B("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),B("img",{onClick:l,title:"Close"}))},Rt=({s:e})=>{const s=t.useValue(Ce,e)??1;return t.useValue(ve,e)?B("main",{"data-position":s},B(Vt,{s:e}),B(Tt,null,B(xt,{s:e}))):null},qt=e=>t=>{return s=(t,s)=>t+e(s),$t(t).reduce(s,0);var s},Mt=e=>e?.size??0,Nt=qt(Mt),Lt=qt(Nt),Et=qt(Lt),zt=(e,t)=>e?.has(t)??!1,Ot=e=>N(e)||0==Mt(e),$t=e=>[...e?.values()??[]],At=e=>e.clear(),Ft=(e,t)=>e?.forEach(t),Jt=(e,t)=>e?.delete(t),Pt=e=>new Map(e),Bt=e=>[...e?.keys()??[]],Dt=(e,t)=>e?.get(t),Qt=(e,t)=>Ft(e,((e,s)=>t(s,e))),jt=(e,t,s)=>N(s)?(Jt(e,t),e):e?.set(t,s),Ht=(e,t,s,l)=>(zt(e,t)?l?.(Dt(e,t)):jt(e,t,s()),Dt(e,t)),Wt=(e,t,s,l=jt)=>(de(t,((t,l)=>s(e,l,t))),Qt(e,(s=>oe(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const a={};return Ft(e,((e,n)=>{if(!s?.(e,n)){const s=t?t(e,n):e;l?.(s)||(a[n]=s)}})),a},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),Ot,ue),Ut=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),Ot,ue),Xt=(e,t)=>{const s=Pt();return Ft(e,((e,l)=>s.set(l,t?.(e)??e))),s},Yt=e=>Xt(e,Xt),Zt=e=>Xt(e,Yt),_t=(e,t,s,l,a=0)=>L((s?Ht:Dt)(e,t[a],a>A(t)-2?s:Pt),(n=>{if(a>A(t)-2)return l?.(n)&&jt(e,t[a]),n;const r=_t(n,t,s,l,a+1);return Ot(n)&&jt(e,t[a]),r})),es=Pt(),ts=Pt(),ss="storage",ls=e=>new Set(O(e)||N(e)?e:[e]),as=(e,t)=>e?.add(t),ns=/^\d+$/,rs=()=>{const e=[];let t=0;return[s=>(s?Z(e):null)??l+t++,t=>{ns.test(t)&&A(e)<1e3&&Y(e,t)}]},os=e=>[e,e],is=(e,t=Nt)=>t(e[0])+t(e[1]),ds=()=>[Pt(),Pt()],us=e=>[...e],cs=([e,t])=>e===t;Pt(U("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(l),((e,t)=>[e,t])));const hs=(e,t,s)=>jt(e,t,Dt(e,t)==-s?void 0:s),ms=()=>{let e,t,s=!1,a=!1,n=0,o=[];const c=Pt(),k=Pt(),S=Pt(),T=Pt(),V=Pt(),R=Pt(),q=Pt(),M=Pt(),F=Pt(),J=Pt(),P=Pt(),B=Pt(),D=Pt(),Q=Pt(),j=ls(),H=Pt(),W=Pt(),X=Pt(),Z=Pt(),_=ds(),ee=ds(),te=ds(),se=ds(),le=ds(),ae=ds(),re=ds(),he=ds(),be=ds(),pe=ds(),Ie=ds(),fe=ds(),ye=ds(),we=ds(),Ce=ds(),ve=ds(),ke=ds(),Se=ds(),xe=ds(),Te=ds(),Ve=ds(),Re=ds(),qe=Pt(),Me=ds(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=rs(),a=Pt();return[(s,n,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return jt(a,d,[s,n,r,o,i]),as(_t(n,r??[l],ls),d),d},(t,s,...n)=>K(((e,t=[l])=>{const s=[],a=(e,l)=>l==A(t)?Y(s,e):null===t[l]?Ft(e,(e=>a(e,l+1))):K([t[l],null],(t=>a(Dt(e,t),l+1)));return a(e,0),s})(t,s),(t=>Ft(t,(t=>Dt(a,t)[0](e,...s??[],...n))))),e=>L(Dt(a,e),(([,t,n])=>(_t(t,n??[l],void 0,(t=>(Jt(t,e),Ot(t)?1:0))),jt(a,e),s(e),n))),t=>L(Dt(a,t),(([t,,s=[],l,a])=>{const n=(...r)=>{const o=A(r);o==A(s)?t(e,...r,...a(r)):N(s[o])?K(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Oe=e=>{if(!ce(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!E(t)&&t!=r||(Pe(e[d])!=t&&ie(e,d),0))},$e=O,Ae=(t,s)=>(!e||zt(P,s)||pt(s))&&ce(t,((e,t)=>Fe(s,t,e)),(()=>pt(s))),Fe=(e,t,s,l)=>ce(l?s:He(s,e,t),((l,a)=>L(Je(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>pt(e,t))),Je=(t,s,l,a)=>e?L(Dt(Dt(P,t),l),(e=>Pe(a)!=e[i]?pt(t,s,l,a,e[d]):a),(()=>pt(t,s,l,a))):N(Pe(a))?pt(t,s,l,a):a,Qe=(e,t)=>ce(t?e:We(e),((t,s)=>L(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?L(Dt(D,e),(t=>Pe(s)!=t[i]?It(e,s,t[d]):s),(()=>It(e,s))):N(Pe(s))?It(e,s):s,He=(e,t,s)=>(L(Dt(B,t),(([l,a])=>{Ft(l,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(a,(l=>{oe(e,l)||pt(t,s,l)}))})),e),We=e=>(t&&(Ft(Q,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(j,(t=>{oe(e,t)||It(t)}))),e),Ge=e=>Wt(P,e,((e,t,s)=>{const l=Pt(),a=ls();Wt(Ht(P,t,Pt),s,((e,t,s)=>{jt(e,t,s),L(s[d],(e=>jt(l,t,e)),(()=>as(a,t)))})),jt(B,t,[l,a])}),((e,t)=>{jt(P,t),jt(B,t)})),Ke=e=>Wt(D,e,((e,t,s)=>{jt(D,t,s),L(s[d],(e=>jt(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{jt(D,t),jt(Q,t),Jt(j,t)})),Ue=e=>ue(e)?Rs():ks(e),Xe=e=>Wt(X,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Wt(Ht(X,e,(()=>(ut(e,1),jt(H,e,rs()),jt(W,e,Pt()),Pt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,a)=>Wt(Ht(t,s,(()=>(ct(e,s,1),Pt()))),l,((t,l,a)=>_e(e,s,t,l,a)),((l,n)=>it(e,t,s,l,n,a))),_e=(e,t,s,l,a)=>{zt(s,l)||ht(e,t,l,1);const n=Dt(s,l);a!==n&&(mt(e,t,l,n,a),jt(s,l,a))},et=(e,t,s,l,a)=>L(Dt(t,s),(t=>_e(e,s,t,l,a)),(()=>Ze(e,t,s,He({[l]:a},e,s)))),tt=e=>ue(e)?Ns():Ss(e),st=e=>Wt(Z,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{zt(Z,e)||gt(e,1);const s=Dt(Z,e);t!==s&&(bt(e,s,t),jt(Z,e,t))},at=(e,t)=>{const[s]=Dt(H,e),l=s(t);return zt(Dt(X,e),l)?at(e,t):l},nt=e=>Dt(X,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Dt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,a,n)=>{const r=Dt(Dt(B,e)?.[0],a);if(!N(r)&&!n)return _e(e,s,l,a,r);const o=t=>{mt(e,s,t,Dt(l,t)),ht(e,s,t,-1),jt(l,t)};N(r)?o(a):Qt(l,o),Ot(l)&&(ct(e,s,-1),Ot(jt(t,s))&&(ut(e,-1),jt(X,e),jt(H,e),jt(W,e)))},dt=e=>{const t=Dt(Q,e);if(!N(t))return lt(e,t);bt(e,Dt(Z,e)),gt(e,-1),jt(Z,e)},ut=(e,t)=>hs(c,e,t),ct=(e,t,s)=>hs(Ht(T,e,Pt),t,s)&&jt(S,e,Ht(S,e,(()=>0))+s),ht=(e,t,s,l)=>{const a=Dt(W,e),n=Dt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&hs(Ht(k,e,Pt),s,l),jt(a,s,n!=-l?n+l:null),hs(Ht(Ht(V,e,Pt),t,Pt),s,l)},mt=(e,t,s,l,a)=>{Ht(Ht(Ht(R,e,Pt),t,Pt),s,(()=>[l,0]))[1]=a,o[3]?.(e,t,s,a)},gt=(e,t)=>hs(q,e,t),bt=(e,t,s)=>{Ht(M,e,(()=>[t,0]))[1]=s,o[4]?.(e,s)},pt=(e,t,s,l,a)=>(Y(Ht(Ht(Ht(F,e,Pt),t,Pt),s,(()=>[])),l),a),It=(e,t,s)=>(Y(Ht(J,e,(()=>[])),t),s),ft=(e,t,s)=>L(Dt(Dt(Dt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...os(ss(e,t,s))])),yt=e=>L(Dt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...os(bs(e))])),wt=e=>Ot(F)||Ot(ve[e])?0:Ft(e?Zt(F):F,((t,s)=>Ft(t,((t,l)=>Ft(t,((t,a)=>Le(ve[e],[s,l,a],t))))))),Ct=e=>Ot(J)||Ot(ke[e])?0:Ft(e?Xt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!Ot(e))return Le(t,l,(()=>Gt(e))),Qt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=ps();t!=s&&Le(_[e],void 0,t);const l=Ot(pe[e]),a=Ot(ye[e])&&Ot(we[e])&&Ot(be[e])&&Ot(Ie[e])&&Ot(ae[e])&&Ot(re[e])&&Ot(he[e])&&l&&Ot(te[e])&&Ot(se[e]),n=Ot(Ce[e])&&Ot(fe[e])&&Ot(le[e])&&Ot(ee[e]);if(!a||!n){const t=e?[Xt(c),Yt(k),Xt(S),Yt(T),Zt(V),Zt(R)]:[c,k,S,T,V,R];if(!a){vt(t[0],te[e],se[e]),Ft(t[1],((t,s)=>vt(t,ae[e],re[e],[s]))),Ft(t[2],((t,s)=>{0!=t&&Le(he[e],[s],qt(s))}));const s=ls();Ft(t[3],((t,a)=>{vt(t,be[e],Ie[e],[a])&&!l&&(Le(pe[e],[a,null]),as(s,a))})),l||Ft(t[5],((t,l)=>{if(!zt(s,l)){const s=ls();Ft(t,(e=>Ft(e,(([t,l],a)=>l!==t?as(s,a):Jt(e,a))))),Ft(s,(t=>Le(pe[e],[l,t])))}})),Ft(t[4],((t,s)=>Ft(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!n){let s;Ft(t[5],((t,l)=>{let a;Ft(t,((t,n)=>{let r;Ft(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,n,i],o,t,ft),s=a=r=1)})),r&&Le(fe[e],[l,n],ft)})),a&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},St=e=>{const t=Cs();t!=a&&Le(Se[e],void 0,t);const s=Ot(Te[e])&&Ot(Ve[e]),l=Ot(Re[e])&&Ot(xe[e]);if(!s||!l){const t=e?[Xt(q),Xt(M)]:[q,M];if(s||vt(t[0],Te[e],Ve[e]),!l){let s;Ft(t[1],(([t,l],a)=>{l!==t&&(Le(Re[e],[a],l,t,yt),s=1)})),s&&Le(xe[e],void 0,yt)}}},xt=(e,...t)=>(zs((()=>e(...U(t,x)))),As),Tt=()=>Ut(X),Vt=()=>Bt(X),Rt=e=>Bt(Dt(W,x(e))),qt=e=>Mt(Dt(X,x(e))),$t=e=>Bt(Dt(X,x(e))),es=(e,t,s,l=0,a)=>{return U($(G((n=Dt(X,x(e)),r=(e,s)=>[N(t)?s:Dt(e,x(t)),s],U([...n?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,N(a)?a:l+a),(([,e])=>e));var n,r},ts=(e,t)=>Bt(Dt(Dt(X,x(e)),x(t))),ss=(e,t,s)=>Dt(Dt(Dt(X,x(e)),x(t)),x(s)),ns=()=>Gt(Z),gs=()=>Bt(Z),bs=e=>Dt(Z,x(e)),ps=()=>!Ot(X),Is=e=>zt(X,x(e)),fs=(e,t)=>zt(Dt(W,x(e)),x(t)),ys=(e,t)=>zt(Dt(X,x(e)),x(t)),ws=(e,t,s)=>zt(Dt(Dt(X,x(e)),x(t)),x(s)),Cs=()=>!Ot(Z),vs=e=>zt(Z,x(e)),ks=e=>xt((()=>(e=>ce(e,Ae,pt))(e)?Xe(e):0)),Ss=e=>xt((()=>Qe(e)?st(e):0)),xs=e=>{try{Ue(me(e))}catch{}return As},Ts=t=>xt((()=>{if((e=ce(t,(e=>ce(e,Oe))))&&(Ge(t),!Ot(X))){const e=Tt();Rs(),ks(e)}})),Vs=e=>xt((()=>{if(t=(e=>ce(e,Oe))(e)){const s=ns();Es(),Ns(),t=!0,Ke(e),Ss(s)}})),Rs=()=>xt((()=>Xe({}))),qs=e=>xt((e=>zt(X,e)?rt(e):0),e),Ms=(e,t)=>xt(((e,t)=>L(Dt(X,e),(s=>zt(s,t)?ot(e,s,t):0))),e,t),Ns=()=>xt((()=>st({}))),Ls=()=>xt((()=>{Ge({}),e=!1})),Es=()=>xt((()=>{Ke({}),t=!1})),zs=(e,t)=>{if(-1!=n){Os();const s=e();return $s(t),s}},Os=()=>(-1!=n&&n++,1==n&&(o[0]?.(),Le(qe)),As),$s=e=>(n>0&&(n--,0==n&&(n=1,wt(1),Ot(R)||kt(1),Ct(1),Ot(M)||St(1),e?.(As)&&(Ft(R,((e,t)=>Ft(e,((e,s)=>Ft(e,(([e],l)=>Be(As,t,s,l,e))))))),At(R),Ft(M,(([e],t)=>De(As,t,e))),At(M)),Le(Me[0],void 0),n=-1,wt(0),Ot(R)||kt(0),Ct(0),Ot(M)||St(0),o[1]?.(),Le(Me[1],void 0),o[2]?.(),n=0,s=ps(),a=Cs(),K([c,k,S,T,V,R,F,q,M,J],At))),As),As={getContent:()=>[Tt(),ns()],getTables:Tt,getTableIds:Vt,getTable:e=>Kt(Dt(X,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:$t,getSortedRowIds:es,getRow:(e,t)=>Gt(Dt(Dt(X,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ns,getValueIds:gs,getValue:bs,hasTables:ps,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>ge(X),getValuesJson:()=>ge(Z),getJson:()=>ge([X,Z]),getTablesSchemaJson:()=>ge(P),getValuesSchemaJson:()=>ge(D),getSchemaJson:()=>ge([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>xt((()=>$e(e)?(([e,t])=>{(ue(e)?Rs:ks)(e),(ue(t)?Ns:Ss)(t)})(e):0)),setTables:ks,setTable:(e,t)=>xt((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>xt(((e,t)=>Fe(e,t,s)?Ze(e,nt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,nt(e),l=at(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>xt(((e,t)=>{if(Fe(e,t,s,1)){const l=nt(e);de(s,((s,a)=>et(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>xt(((e,t,s)=>L(Je(e,t,s,z(l)?l(ss(e,t,s)):l),(l=>et(e,nt(e),t,s,l)))),e,t,s),setValues:Ss,setPartialValues:e=>xt((()=>Qe(e,1)?de(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>xt((e=>L(je(e,z(t)?t(bs(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>xt((()=>{de(e[0],((e,t)=>N(e)?qs(t):de(e,((e,s)=>N(e)?Ms(t,s):de(e,((e,l)=>Be(As,t,s,l,e))))))),de(e[1],((e,t)=>De(As,t,e)))})),setTablesJson:xs,setValuesJson:e=>{try{tt(me(e))}catch{}return As},setJson:e=>xt((()=>{try{const[t,s]=me(e);Ue(t),tt(s)}catch{xs(e)}})),setTablesSchema:Ts,setValuesSchema:Vs,setSchema:(e,t)=>xt((()=>{Ts(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>xt(((e,t,s)=>L(Dt(X,e),(a=>L(Dt(a,t),(n=>zt(n,s)?it(e,a,t,n,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>xt((e=>zt(Z,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>xt((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Dt(c,t)?void 0:Gt(e,((e,s)=>-1===Dt(Dt(T,t),s)?void 0:Gt(e,(([,e])=>e),(e=>cs(e)))),Ot,ue)),Ot,ue),Gt(M,(([,e])=>e),(e=>cs(e))),1],getTransactionLog:()=>[!Ot(R),!Ot(M),Ut(R,us,cs),Ut(F),Gt(M,us,cs),Gt(J),Gt(c),Kt(T),Ut(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Ft(X,((t,s)=>e(s,(e=>Ft(t,((t,s)=>e(s,(e=>Qt(t,e))))))))),forEachTableCell:(e,t)=>Qt(Dt(W,x(e)),t),forEachRow:(e,t)=>Ft(Dt(X,x(e)),((e,s)=>t(s,(t=>Qt(e,t))))),forEachCell:(e,t,s)=>Qt(Dt(Dt(X,x(e)),x(t)),s),forEachValue:e=>Qt(Z,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=es(e,t,s,l,a);return Ne((()=>{const r=es(e,t,s,l,a);var i,d,u;d=o,A(i=r)===A(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(As,e,t,s,l,a,o))}),pe[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:is(_),tables:is(ee),tableIds:is(te),hasTable:is(se),table:is(le),tableCellIds:is(ae),hasTableCell:is(re,Lt),rowCount:is(he),rowIds:is(be),sortedRowIds:is(pe),hasRow:is(Ie,Lt),row:is(fe,Lt),cellIds:is(ye,Lt),hasCell:is(we,Et),cell:is(Ce,Et),invalidCell:is(ve,Et),hasValues:is(Se),values:is(xe),valueIds:is(Te),hasValue:is(Ve),value:is(Re),invalidValue:is(ke),transaction:Nt(qe)+is(Me)}),isMergeable:()=>!1,createStore:ms,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,a)=>o=[e,t,s,l,a]};return de({[u+m]:[0,_,[],()=>[ps()]],[m]:[0,ee],[g]:[0,te],[u+h]:[1,se,[Vt],e=>[Is(...e)]],[h]:[1,le,[Vt]],[h+y]:[1,ae,[Vt]],[u+h+f]:[2,re,[Vt,Rt],e=>[fs(...e)]],[p]:[1,he,[Vt]],[I]:[1,be,[Vt]],[u+b]:[2,Ie,[Vt,$t],e=>[ys(...e)]],[b]:[2,fe,[Vt,$t]],[y]:[2,ye,[Vt,$t]],[u+f]:[3,we,[Vt,$t,ts],e=>[ws(...e)]],[f]:[3,Ce,[Vt,$t,ts],e=>os(ss(...e))],InvalidCell:[3,ve],[u+C]:[0,Se,[],()=>[Cs()]],[C]:[0,xe],[v]:[0,Te],[u+w]:[1,Ve,[gs],e=>[vs(...e)]],[w]:[1,Re,[gs],e=>os(bs(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],a)=>{As["add"+a+"Listener"]=(...a)=>Ne(a[e],t[a[e+1]?1:0],e>0?$(a,0,e):void 0,s,l)})),ne(As)};exports.Inspector=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(ms),a=Ie.indexOf(e);return t.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,a,n,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Ht(es,i,(()=>0)),Ht(ts,i,(()=>[]));const[b,p,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ue(e)||!ue(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ue(e)||!ue(t),t.setContent]:F("Store type not supported by this Persister"))(r,e),w=t=>{(b&&O(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await x((async()=>{try{const e=await t();O(e)?w(e):F("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),T),v=()=>(u&&(a(u),u=void 0),T),k=async e=>(1!=h&&(h=2,g++,await x((async()=>{try{await s(p,e)}catch(e){}h=0}))),T),S=()=>(L(c,e.delListener),c=void 0,T),x=async(...e)=>(Y(Dt(ts,i),...e),await(async()=>{if(!Dt(es,i)){for(jt(es,i,1);!N(d=Z(Dt(ts,i)));)try{await d()}catch(e){}jt(es,i,0)}})(),T),T={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return T},stopAutoLoad:v,isAutoLoading:()=>!N(u),save:k,startAutoSave:async()=>(await S().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),T),stopAutoSave:S,isAutoSaving:()=>!N(c),schedule:x,getStore:()=>e,destroy:()=>(Dt(ts,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return ne(T)})(e,(async()=>{return e=s.getItem(t),me(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),he(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(me(l.newValue))}catch{e()}};return T.addEventListener(ss,l),l}),(e=>T.removeEventListener(ss,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==a?1:a,open:!!s}]),await e.startAutoSave()})),B(P,null,B("aside",{id:be},B(Fe,{s:l}),B(Rt,{s:l})),B("style",null,Ae))};
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("../../ui-react/with-schemas/index.cjs");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Has",c="Ids",h="Table",m=h+"s",g=h+c,b="Row",p=b+"Count",I=b+c,f="Cell",y=f+c,w="Value",C=w+"s",v=w+c,k="currentTarget",S="value",x=e=>l+e,T=globalThis.window,V=Math,R=V.min,q=V.floor,M=isFinite,N=e=>null==e,L=(e,t,s)=>N(e)?s?.():t(e),E=e=>e==a||e==n,z=e=>s(e)==o,O=e=>Array.isArray(e),$=(e,t,s)=>e.slice(t,s),A=e=>e.length,F=e=>{throw Error(e)},{PureComponent:J,Fragment:P,createElement:B,useCallback:D,useLayoutEffect:Q,useRef:j,useState:H}=e,W=(e,...t)=>N(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),U=(e,t)=>e.map(t),X=e=>0==A(e),Y=(e,...t)=>e.push(...t),Z=e=>e.shift(),_=Object,ee=e=>_.getPrototypeOf(e),te=_.entries,se=_.isFrozen,le=e=>!N(e)&&L(ee(e),(e=>e==_.prototype||N(ee(e))),(()=>!0)),ae=_.keys,ne=_.freeze,re=(e=[])=>_.fromEntries(e),oe=(e,t)=>t in e,ie=(e,t)=>(delete e[t],e),de=(e,t)=>U(te(e),(([e,s])=>t(s,e))),ue=e=>le(e)&&0==(e=>A(ae(e)))(e),ce=(e,t,s,l=0)=>N(e)||!le(e)||!l&&ue(e)||se(e)?(s?.(),!1):(de(e,((s,l)=>{t(s,l)||ie(e,l)})),!!l||!ue(e)),he=JSON.stringify,me=JSON.parse,ge=e=>he(e,((e,t)=>t instanceof Map?_.fromEntries([...t]):t)),be="tinybaseInspector",pe="TinyBase Inspector",Ie=["left","top","bottom","right","full"],fe="state",ye="sort",we="open",Ce="position",ve=we,ke="editable",Se=(...e)=>ge(e),xe=(e,t)=>U(G(e),t),Te=(e,s)=>[!!t.useCell(fe,e,ke,s),D((t=>{s.setCell(fe,e,ke,(e=>!e)),t.preventDefault()}),[s,e])],Ve="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Re='content:url("',qe=Re+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Me='</svg>")',Ne=Re+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Le=U([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>qe+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Me)),Ee=qe+"<path d='M20 20l60 60M20 80l60-60' />"+Me,ze=qe+`<path d='${Ve}' />`+Me,Oe=qe+`<path d='${Ve}M20 20l60 60' />`+Me,$e="*::-webkit-scrollbar",Ae=((e,t="")=>e.join(t))(de({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[$e]:"width:0.5rem;height:0.5rem;",[$e+"-track"]:"background:#111",[$e+"-thumb"]:"background:#999;border:1px solid #111",[$e+"-thumb:hover"]:"background:#fff",[$e+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ne,...re(U(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...re(U(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ne,"header>img:nth-of-type(6)":Ee,...re(U(Le,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":ze,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Fe=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!0),[],e);return t.useValue(ve,e)?null:B("img",{onClick:l,title:pe,"data-position":s})},Je=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(fe,e,we,r),i=t.useSetCellCallback(fe,e,we,(e=>e[k].open),[],r);return B("details",{open:o,onToggle:i},B("summary",null,s,a?B("img",{onClick:a,className:l?"done":"edit"}):null),n)},Pe=e=>{const t=s(e);return E(t)||t==r&&M(e)?t:void 0},Be=(e,t,s,l,a)=>N(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),De=(e,t,s)=>N(s)?e.delValue(t):e.setValue(t,s),Qe=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:je,useMemo:He,useState:We}=e,Ge="editable",Ke=(e,s)=>U(t.useTableCellIds(e,s),(t=>e+"."+t)),Ue=(e,t,s)=>{const l=je(e,t);return s?l:void 0},Xe=(...e)=>He((()=>e),e),Ye=(e,t)=>He((()=>({store:e,tableId:t})),[e,t]),Ze=(e,t)=>He((()=>({queries:e,queryId:t})),[e,t]),_e=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=We([e,t,l]),h=je((e=>{c(e),o?.(e)}),[o]),m=Ue((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=je((e=>h([i,d,e])),[h,i,d]),b=!0===r?ht:r;return[[i,d,u],m,He((()=>!1===r?null:B(b,{offset:u,limit:a,total:n,onChange:g})),[r,b,u,a,n,g])]},et=(e,t,l)=>He((()=>{const n=t??e;return r=O(n)?re(U(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)};var n},re(de(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,l,e]),tt=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>B("table",{className:e},i?B("caption",null,i):null,!1===t?null:B("thead",null,B("tr",null,!1===s?null:B(st,{sort:r??[],label:"Id",onClick:o}),de(l,(({label:e},t)=>B(st,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),B("tbody",null,U(n,(e=>B("tr",{key:e},!1===s?null:B("th",null,e),de(l,(({component:t,getComponentProps:s},l)=>B("td",{key:l},B(t,{...W(s,e,l),...a,rowId:e,cellId:l}))))))))),st=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>B("th",{onClick:Ue((()=>n?.(e)),[n,e],n),className:N(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},N(s)||t!=e?null:(s?"↓":"↑")+" ",a),lt=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return B("tr",null,!1===l?null:B(e.Fragment,null,B("th",null,s),B("th",null,u)),de(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return N(i)?null:B("td",{key:l},B(e,{...W(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:o=!0})=>{const[i,d]=We(),[u,c]=We(),[h,m]=We(),[g,b]=We(),[p,I]=We();u!==e&&(d(Pe(e)),c(e),m(e+""),b(Number(e)||0),I(!!e));const f=je(((e,s)=>{s(e),c(e),t(e)}),[t]),y=je((()=>{if(!l?.()){const e=Qe(i,r,n,a),s=Qe(e,h,g,p);d(e),c(s),t(s)}}),[l,t,h,g,p,i]);return B("div",{className:s},o?B("button",{className:i,onClick:y},i):null,Qe(i,B("input",{key:i,value:h,onChange:je((e=>f(e[k][S]+"",m)),[f])}),B("input",{key:i,type:"number",value:g,onChange:je((e=>f(Number(e[k][S]||0),b)),[f])}),B("input",{key:i,type:"checkbox",checked:p,onChange:je((e=>f(!!e[k].checked,I)),[f])})))},nt=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,b]=_e(s,l,i,a,n,t.useRowCount(e,r),d,u);return B(tt,{...h,params:Xe(et(t.useTableCellIds(e,r),c,o?ut:t.CellView),Ye(r,e),t.useSortedRowIds(e,...m,n,r),m,g,b)})},rt=({store:e,editable:s=!1,valueComponent:l=(s?ct:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>B("table",{className:n},!1===r?null:B("thead",null,B("tr",null,!1===o?null:B("th",null,"Id"),B("th",null,w))),B("tbody",null,U(t.useValueIds(e),(t=>B("tr",{key:t},!1===o?null:B("th",null,t),B("td",null,B(l,{...W(a,t),valueId:t,store:e}))))))),ot=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return B(tt,{...r,params:Xe(et(t.useTableCellIds(d,i),n,a?ut:t.CellView),Ye(i,d),t.useSliceRowIds(e,s,o))})},it=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=et([...Ke(c,u),...Ke(h,u)],n,a?ut:t.CellView),g=Xe(i,m,c,h,s,d,u);return B("table",{className:r},!1===o?null:B("thead",null,B("tr",null,!1===i?null:B(e.Fragment,null,B("th",null,c,".Id"),B("th",null,h,".Id")),de(m,(({label:e},t)=>B("th",{key:t},e))))),B("tbody",null,U(t.useRowIds(c,u),(e=>B(lt,{key:e,localRowId:e,params:g})))))},dt=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=_e(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return B(tt,{...c,params:Xe(et(t.useResultTableCellIds(e,r),d,t.ResultCellView),Ze(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,g)})},ut=({tableId:e,rowId:s,cellId:l,store:a,className:n,showType:r})=>B(at,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Ge+f,showType:r,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),ct=({valueId:e,store:s,className:l,showType:a})=>B(at,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Ge+w,showType:a,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),ht=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Ue((()=>t(l-a)),[t,l,a],l>0),i=Ue((()=>t(l+a)),[t,l,a],l+a<s);return B(e.Fragment,null,s>a&&B(e.Fragment,null,B("button",{className:"previous",disabled:0==l,onClick:o},"←"),B("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",R(s,l+a)," of "),s," ",1!=s?r:n)},mt=({indexes:e,indexesId:s,indexId:l,s:a})=>B(Je,{uniqueId:Se("i",s,l),summary:"Index: "+l,s:a},U(t.useSliceIds(l,e),(t=>B(gt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a,key:t})))),gt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Se("i",t,s,l),[r,o]=Te(n,a);return B(Je,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},B(ot,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return N(l)?null:B(Je,{uniqueId:Se("i",e),summary:"Indexes: "+(e??d),s:s},X(a)?"No indexes defined":xe(a,(t=>B(mt,{indexes:l,indexesId:e,indexId:t,s:s,key:t}))))},pt=({metrics:e,metricId:s})=>B("tr",null,B("th",null,s),B("td",null,e?.getTableId(s)),B("td",null,t.useMetric(s,e))),It=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return N(l)?null:B(Je,{uniqueId:Se("m",e),summary:"Metrics: "+(e??d),s:s},X(a)?"No metrics defined":B("table",null,B("thead",null,B("th",null,"Metric Id"),B("th",null,"Table Id"),B("th",null,"Metric")),B("tbody",null,U(a,(e=>B(pt,{metrics:l,metricId:e,key:e}))))))},ft=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=Se("q",s,l),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a);return B(Je,{uniqueId:n,summary:"Query: "+l,s:a},B(dt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},yt=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return N(l)?null:B(Je,{uniqueId:Se("q",e),summary:"Queries: "+(e??d),s:s},X(a)?"No queries defined":xe(a,(t=>B(ft,{queries:l,queriesId:e,queryId:t,s:s,key:t}))))},wt=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Se("r",t,s),[n,r]=Te(a,l);return B(Je,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},B(it,{relationshipId:s,relationships:e,editable:n}))},Ct=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return N(l)?null:B(Je,{uniqueId:Se("r",e),summary:"Relationships: "+(e??d),s:s},X(a)?"No relationships defined":xe(a,(t=>B(wt,{relationships:l,relationshipsId:e,relationshipId:t,s:s,key:t}))))},vt=({tableId:e,store:s,storeId:l,s:a})=>{const n=Se("t",l,e),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a),[u,c]=Te(n,a);return B(Je,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},B(nt,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},kt=({store:e,storeId:s,s:l})=>{const a=Se("v",s),[n,r]=Te(a,l);return X(t.useValueIds(e))?null:B(Je,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},B(rt,{store:e,editable:n}))},St=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return N(l)?null:B(Je,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??d),s:s},B(kt,{storeId:e,store:l,s:s}),xe(a,(t=>B(vt,{store:l,storeId:e,tableId:t,s:s,key:t}))))},xt=({s:e})=>{const s=j(null),l=j(0),[a,n]=H(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);Q((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=q(r)+e.clientWidth&&e.scrollHeight>=q(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=D((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),g=t.useIndexesIds(),b=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return N(d)&&X(u)&&N(c)&&X(h)&&N(m)&&X(g)&&N(b)&&X(p)&&N(I)&&X(f)?B("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):B("article",{ref:s,onScroll:i},B(St,{s:e}),U(u,(t=>B(St,{storeId:t,s:e,key:t}))),B(It,{s:e}),U(h,(t=>B(It,{metricsId:t,s:e,key:t}))),B(bt,{s:e}),U(g,(t=>B(bt,{indexesId:t,s:e,key:t}))),B(Ct,{s:e}),U(p,(t=>B(Ct,{relationshipsId:t,s:e,key:t}))),B(yt,{s:e}),U(f,(t=>B(yt,{queriesId:t,s:e,key:t}))))};class Tt extends J{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?B("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Vt=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!1),[],e),a=t.useSetValueCallback(Ce,(e=>Number(e[k].dataset.id)),[],e);return B("header",null,B("img",{title:pe}),B("span",null,pe),U(Ie,((e,t)=>t==s?null:B("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),B("img",{onClick:l,title:"Close"}))},Rt=({s:e})=>{const s=t.useValue(Ce,e)??1;return t.useValue(ve,e)?B("main",{"data-position":s},B(Vt,{s:e}),B(Tt,null,B(xt,{s:e}))):null},qt=e=>t=>{return s=(t,s)=>t+e(s),$t(t).reduce(s,0);var s},Mt=e=>e?.size??0,Nt=qt(Mt),Lt=qt(Nt),Et=qt(Lt),zt=(e,t)=>e?.has(t)??!1,Ot=e=>N(e)||0==Mt(e),$t=e=>[...e?.values()??[]],At=e=>e.clear(),Ft=(e,t)=>e?.forEach(t),Jt=(e,t)=>e?.delete(t),Pt=e=>new Map(e),Bt=e=>[...e?.keys()??[]],Dt=(e,t)=>e?.get(t),Qt=(e,t)=>Ft(e,((e,s)=>t(s,e))),jt=(e,t,s)=>N(s)?(Jt(e,t),e):e?.set(t,s),Ht=(e,t,s,l)=>(zt(e,t)?l?.(Dt(e,t)):jt(e,t,s()),Dt(e,t)),Wt=(e,t,s,l=jt)=>(de(t,((t,l)=>s(e,l,t))),Qt(e,(s=>oe(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const a={};return Ft(e,((e,n)=>{if(!s?.(e,n)){const s=t?t(e,n):e;l?.(s)||(a[n]=s)}})),a},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),Ot,ue),Ut=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),Ot,ue),Xt=(e,t)=>{const s=Pt();return Ft(e,((e,l)=>s.set(l,t?.(e)??e))),s},Yt=e=>Xt(e,Xt),Zt=e=>Xt(e,Yt),_t=(e,t,s,l,a=0)=>L((s?Ht:Dt)(e,t[a],a>A(t)-2?s:Pt),(n=>{if(a>A(t)-2)return l?.(n)&&jt(e,t[a]),n;const r=_t(n,t,s,l,a+1);return Ot(n)&&jt(e,t[a]),r})),es=Pt(),ts=Pt(),ss="storage",ls=e=>new Set(O(e)||N(e)?e:[e]),as=(e,t)=>e?.add(t),ns=/^\d+$/,rs=()=>{const e=[];let t=0;return[s=>(s?Z(e):null)??l+t++,t=>{ns.test(t)&&A(e)<1e3&&Y(e,t)}]},os=e=>[e,e],is=(e,t=Nt)=>t(e[0])+t(e[1]),ds=()=>[Pt(),Pt()],us=e=>[...e],cs=([e,t])=>e===t;Pt(U("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(l),((e,t)=>[e,t])));const hs=(e,t,s)=>jt(e,t,Dt(e,t)==-s?void 0:s),ms=()=>{let e,t,s=!1,a=!1,n=0,o=[];const c=Pt(),k=Pt(),S=Pt(),T=Pt(),V=Pt(),R=Pt(),q=Pt(),M=Pt(),F=Pt(),J=Pt(),P=Pt(),B=Pt(),D=Pt(),Q=Pt(),j=ls(),H=Pt(),W=Pt(),X=Pt(),Z=Pt(),_=ds(),ee=ds(),te=ds(),se=ds(),le=ds(),ae=ds(),re=ds(),he=ds(),be=ds(),pe=ds(),Ie=ds(),fe=ds(),ye=ds(),we=ds(),Ce=ds(),ve=ds(),ke=ds(),Se=ds(),xe=ds(),Te=ds(),Ve=ds(),Re=ds(),qe=Pt(),Me=ds(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=rs(),a=Pt();return[(s,n,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return jt(a,d,[s,n,r,o,i]),as(_t(n,r??[l],ls),d),d},(t,s,...n)=>K(((e,t=[l])=>{const s=[],a=(e,l)=>l==A(t)?Y(s,e):null===t[l]?Ft(e,(e=>a(e,l+1))):K([t[l],null],(t=>a(Dt(e,t),l+1)));return a(e,0),s})(t,s),(t=>Ft(t,(t=>Dt(a,t)[0](e,...s??[],...n))))),e=>L(Dt(a,e),(([,t,n])=>(_t(t,n??[l],void 0,(t=>(Jt(t,e),Ot(t)?1:0))),jt(a,e),s(e),n))),t=>L(Dt(a,t),(([t,,s=[],l,a])=>{const n=(...r)=>{const o=A(r);o==A(s)?t(e,...r,...a(r)):N(s[o])?K(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Oe=e=>{if(!ce(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!E(t)&&t!=r||(Pe(e[d])!=t&&ie(e,d),0))},$e=O,Ae=(t,s)=>(!e||zt(P,s)||pt(s))&&ce(t,((e,t)=>Fe(s,t,e)),(()=>pt(s))),Fe=(e,t,s,l)=>ce(l?s:He(s,e,t),((l,a)=>L(Je(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>pt(e,t))),Je=(t,s,l,a)=>e?L(Dt(Dt(P,t),l),(e=>Pe(a)!=e[i]?pt(t,s,l,a,e[d]):a),(()=>pt(t,s,l,a))):N(Pe(a))?pt(t,s,l,a):a,Qe=(e,t)=>ce(t?e:We(e),((t,s)=>L(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?L(Dt(D,e),(t=>Pe(s)!=t[i]?It(e,s,t[d]):s),(()=>It(e,s))):N(Pe(s))?It(e,s):s,He=(e,t,s)=>(L(Dt(B,t),(([l,a])=>{Ft(l,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(a,(l=>{oe(e,l)||pt(t,s,l)}))})),e),We=e=>(t&&(Ft(Q,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(j,(t=>{oe(e,t)||It(t)}))),e),Ge=e=>Wt(P,e,((e,t,s)=>{const l=Pt(),a=ls();Wt(Ht(P,t,Pt),s,((e,t,s)=>{jt(e,t,s),L(s[d],(e=>jt(l,t,e)),(()=>as(a,t)))})),jt(B,t,[l,a])}),((e,t)=>{jt(P,t),jt(B,t)})),Ke=e=>Wt(D,e,((e,t,s)=>{jt(D,t,s),L(s[d],(e=>jt(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{jt(D,t),jt(Q,t),Jt(j,t)})),Ue=e=>ue(e)?Rs():ks(e),Xe=e=>Wt(X,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Wt(Ht(X,e,(()=>(ut(e,1),jt(H,e,rs()),jt(W,e,Pt()),Pt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,a)=>Wt(Ht(t,s,(()=>(ct(e,s,1),Pt()))),l,((t,l,a)=>_e(e,s,t,l,a)),((l,n)=>it(e,t,s,l,n,a))),_e=(e,t,s,l,a)=>{zt(s,l)||ht(e,t,l,1);const n=Dt(s,l);a!==n&&(mt(e,t,l,n,a),jt(s,l,a))},et=(e,t,s,l,a)=>L(Dt(t,s),(t=>_e(e,s,t,l,a)),(()=>Ze(e,t,s,He({[l]:a},e,s)))),tt=e=>ue(e)?Ns():Ss(e),st=e=>Wt(Z,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{zt(Z,e)||gt(e,1);const s=Dt(Z,e);t!==s&&(bt(e,s,t),jt(Z,e,t))},at=(e,t)=>{const[s]=Dt(H,e),l=s(t);return zt(Dt(X,e),l)?at(e,t):l},nt=e=>Dt(X,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Dt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,a,n)=>{const r=Dt(Dt(B,e)?.[0],a);if(!N(r)&&!n)return _e(e,s,l,a,r);const o=t=>{mt(e,s,t,Dt(l,t)),ht(e,s,t,-1),jt(l,t)};N(r)?o(a):Qt(l,o),Ot(l)&&(ct(e,s,-1),Ot(jt(t,s))&&(ut(e,-1),jt(X,e),jt(H,e),jt(W,e)))},dt=e=>{const t=Dt(Q,e);if(!N(t))return lt(e,t);bt(e,Dt(Z,e)),gt(e,-1),jt(Z,e)},ut=(e,t)=>hs(c,e,t),ct=(e,t,s)=>hs(Ht(T,e,Pt),t,s)&&jt(S,e,Ht(S,e,(()=>0))+s),ht=(e,t,s,l)=>{const a=Dt(W,e),n=Dt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&hs(Ht(k,e,Pt),s,l),jt(a,s,n!=-l?n+l:null),hs(Ht(Ht(V,e,Pt),t,Pt),s,l)},mt=(e,t,s,l,a)=>{Ht(Ht(Ht(R,e,Pt),t,Pt),s,(()=>[l,0]))[1]=a,o[3]?.(e,t,s,a)},gt=(e,t)=>hs(q,e,t),bt=(e,t,s)=>{Ht(M,e,(()=>[t,0]))[1]=s,o[4]?.(e,s)},pt=(e,t,s,l,a)=>(Y(Ht(Ht(Ht(F,e,Pt),t,Pt),s,(()=>[])),l),a),It=(e,t,s)=>(Y(Ht(J,e,(()=>[])),t),s),ft=(e,t,s)=>L(Dt(Dt(Dt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...os(ss(e,t,s))])),yt=e=>L(Dt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...os(bs(e))])),wt=e=>Ot(F)||Ot(ve[e])?0:Ft(e?Zt(F):F,((t,s)=>Ft(t,((t,l)=>Ft(t,((t,a)=>Le(ve[e],[s,l,a],t))))))),Ct=e=>Ot(J)||Ot(ke[e])?0:Ft(e?Xt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!Ot(e))return Le(t,l,(()=>Gt(e))),Qt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=ps();t!=s&&Le(_[e],void 0,t);const l=Ot(pe[e]),a=Ot(ye[e])&&Ot(we[e])&&Ot(be[e])&&Ot(Ie[e])&&Ot(ae[e])&&Ot(re[e])&&Ot(he[e])&&l&&Ot(te[e])&&Ot(se[e]),n=Ot(Ce[e])&&Ot(fe[e])&&Ot(le[e])&&Ot(ee[e]);if(!a||!n){const t=e?[Xt(c),Yt(k),Xt(S),Yt(T),Zt(V),Zt(R)]:[c,k,S,T,V,R];if(!a){vt(t[0],te[e],se[e]),Ft(t[1],((t,s)=>vt(t,ae[e],re[e],[s]))),Ft(t[2],((t,s)=>{0!=t&&Le(he[e],[s],qt(s))}));const s=ls();Ft(t[3],((t,a)=>{vt(t,be[e],Ie[e],[a])&&!l&&(Le(pe[e],[a,null]),as(s,a))})),l||Ft(t[5],((t,l)=>{if(!zt(s,l)){const s=ls();Ft(t,(e=>Ft(e,(([t,l],a)=>l!==t?as(s,a):Jt(e,a))))),Ft(s,(t=>Le(pe[e],[l,t])))}})),Ft(t[4],((t,s)=>Ft(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!n){let s;Ft(t[5],((t,l)=>{let a;Ft(t,((t,n)=>{let r;Ft(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,n,i],o,t,ft),s=a=r=1)})),r&&Le(fe[e],[l,n],ft)})),a&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},St=e=>{const t=Cs();t!=a&&Le(Se[e],void 0,t);const s=Ot(Te[e])&&Ot(Ve[e]),l=Ot(Re[e])&&Ot(xe[e]);if(!s||!l){const t=e?[Xt(q),Xt(M)]:[q,M];if(s||vt(t[0],Te[e],Ve[e]),!l){let s;Ft(t[1],(([t,l],a)=>{l!==t&&(Le(Re[e],[a],l,t,yt),s=1)})),s&&Le(xe[e],void 0,yt)}}},xt=(e,...t)=>(zs((()=>e(...U(t,x)))),As),Tt=()=>Ut(X),Vt=()=>Bt(X),Rt=e=>Bt(Dt(W,x(e))),qt=e=>Mt(Dt(X,x(e))),$t=e=>Bt(Dt(X,x(e))),es=(e,t,s,l=0,a)=>{return U($(G((n=Dt(X,x(e)),r=(e,s)=>[N(t)?s:Dt(e,x(t)),s],U([...n?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,N(a)?a:l+a),(([,e])=>e));var n,r},ts=(e,t)=>Bt(Dt(Dt(X,x(e)),x(t))),ss=(e,t,s)=>Dt(Dt(Dt(X,x(e)),x(t)),x(s)),ns=()=>Gt(Z),gs=()=>Bt(Z),bs=e=>Dt(Z,x(e)),ps=()=>!Ot(X),Is=e=>zt(X,x(e)),fs=(e,t)=>zt(Dt(W,x(e)),x(t)),ys=(e,t)=>zt(Dt(X,x(e)),x(t)),ws=(e,t,s)=>zt(Dt(Dt(X,x(e)),x(t)),x(s)),Cs=()=>!Ot(Z),vs=e=>zt(Z,x(e)),ks=e=>xt((()=>(e=>ce(e,Ae,pt))(e)?Xe(e):0)),Ss=e=>xt((()=>Qe(e)?st(e):0)),xs=e=>{try{Ue(me(e))}catch{}return As},Ts=t=>xt((()=>{if((e=ce(t,(e=>ce(e,Oe))))&&(Ge(t),!Ot(X))){const e=Tt();Rs(),ks(e)}})),Vs=e=>xt((()=>{if(t=(e=>ce(e,Oe))(e)){const s=ns();Es(),Ns(),t=!0,Ke(e),Ss(s)}})),Rs=()=>xt((()=>Xe({}))),qs=e=>xt((e=>zt(X,e)?rt(e):0),e),Ms=(e,t)=>xt(((e,t)=>L(Dt(X,e),(s=>zt(s,t)?ot(e,s,t):0))),e,t),Ns=()=>xt((()=>st({}))),Ls=()=>xt((()=>{Ge({}),e=!1})),Es=()=>xt((()=>{Ke({}),t=!1})),zs=(e,t)=>{if(-1!=n){Os();const s=e();return $s(t),s}},Os=()=>(-1!=n&&n++,1==n&&(o[0]?.(),Le(qe)),As),$s=e=>(n>0&&(n--,0==n&&(n=1,wt(1),Ot(R)||kt(1),Ct(1),Ot(M)||St(1),e?.(As)&&(Ft(R,((e,t)=>Ft(e,((e,s)=>Ft(e,(([e],l)=>Be(As,t,s,l,e))))))),At(R),Ft(M,(([e],t)=>De(As,t,e))),At(M)),Le(Me[0],void 0),n=-1,wt(0),Ot(R)||kt(0),Ct(0),Ot(M)||St(0),o[1]?.(),Le(Me[1],void 0),o[2]?.(),n=0,s=ps(),a=Cs(),K([c,k,S,T,V,R,F,q,M,J],At))),As),As={getContent:()=>[Tt(),ns()],getTables:Tt,getTableIds:Vt,getTable:e=>Kt(Dt(X,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:$t,getSortedRowIds:es,getRow:(e,t)=>Gt(Dt(Dt(X,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ns,getValueIds:gs,getValue:bs,hasTables:ps,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>ge(X),getValuesJson:()=>ge(Z),getJson:()=>ge([X,Z]),getTablesSchemaJson:()=>ge(P),getValuesSchemaJson:()=>ge(D),getSchemaJson:()=>ge([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>xt((()=>$e(e)?(([e,t])=>{(ue(e)?Rs:ks)(e),(ue(t)?Ns:Ss)(t)})(e):0)),setTables:ks,setTable:(e,t)=>xt((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>xt(((e,t)=>Fe(e,t,s)?Ze(e,nt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,nt(e),l=at(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>xt(((e,t)=>{if(Fe(e,t,s,1)){const l=nt(e);de(s,((s,a)=>et(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>xt(((e,t,s)=>L(Je(e,t,s,z(l)?l(ss(e,t,s)):l),(l=>et(e,nt(e),t,s,l)))),e,t,s),setValues:Ss,setPartialValues:e=>xt((()=>Qe(e,1)?de(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>xt((e=>L(je(e,z(t)?t(bs(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>xt((()=>{de(e[0],((e,t)=>N(e)?qs(t):de(e,((e,s)=>N(e)?Ms(t,s):de(e,((e,l)=>Be(As,t,s,l,e))))))),de(e[1],((e,t)=>De(As,t,e)))})),setTablesJson:xs,setValuesJson:e=>{try{tt(me(e))}catch{}return As},setJson:e=>xt((()=>{try{const[t,s]=me(e);Ue(t),tt(s)}catch{xs(e)}})),setTablesSchema:Ts,setValuesSchema:Vs,setSchema:(e,t)=>xt((()=>{Ts(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>xt(((e,t,s)=>L(Dt(X,e),(a=>L(Dt(a,t),(n=>zt(n,s)?it(e,a,t,n,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>xt((e=>zt(Z,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>xt((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Dt(c,t)?void 0:Gt(e,((e,s)=>-1===Dt(Dt(T,t),s)?void 0:Gt(e,(([,e])=>e),(e=>cs(e)))),Ot,ue)),Ot,ue),Gt(M,(([,e])=>e),(e=>cs(e))),1],getTransactionLog:()=>[!Ot(R),!Ot(M),Ut(R,us,cs),Ut(F),Gt(M,us,cs),Gt(J),Gt(c),Kt(T),Ut(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Ft(X,((t,s)=>e(s,(e=>Ft(t,((t,s)=>e(s,(e=>Qt(t,e))))))))),forEachTableCell:(e,t)=>Qt(Dt(W,x(e)),t),forEachRow:(e,t)=>Ft(Dt(X,x(e)),((e,s)=>t(s,(t=>Qt(e,t))))),forEachCell:(e,t,s)=>Qt(Dt(Dt(X,x(e)),x(t)),s),forEachValue:e=>Qt(Z,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=es(e,t,s,l,a);return Ne((()=>{const r=es(e,t,s,l,a);var i,d,u;d=o,A(i=r)===A(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(As,e,t,s,l,a,o))}),pe[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:is(_),tables:is(ee),tableIds:is(te),hasTable:is(se),table:is(le),tableCellIds:is(ae),hasTableCell:is(re,Lt),rowCount:is(he),rowIds:is(be),sortedRowIds:is(pe),hasRow:is(Ie,Lt),row:is(fe,Lt),cellIds:is(ye,Lt),hasCell:is(we,Et),cell:is(Ce,Et),invalidCell:is(ve,Et),hasValues:is(Se),values:is(xe),valueIds:is(Te),hasValue:is(Ve),value:is(Re),invalidValue:is(ke),transaction:Nt(qe)+is(Me)}),isMergeable:()=>!1,createStore:ms,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,a)=>o=[e,t,s,l,a]};return de({[u+m]:[0,_,[],()=>[ps()]],[m]:[0,ee],[g]:[0,te],[u+h]:[1,se,[Vt],e=>[Is(...e)]],[h]:[1,le,[Vt]],[h+y]:[1,ae,[Vt]],[u+h+f]:[2,re,[Vt,Rt],e=>[fs(...e)]],[p]:[1,he,[Vt]],[I]:[1,be,[Vt]],[u+b]:[2,Ie,[Vt,$t],e=>[ys(...e)]],[b]:[2,fe,[Vt,$t]],[y]:[2,ye,[Vt,$t]],[u+f]:[3,we,[Vt,$t,ts],e=>[ws(...e)]],[f]:[3,Ce,[Vt,$t,ts],e=>os(ss(...e))],InvalidCell:[3,ve],[u+C]:[0,Se,[],()=>[Cs()]],[C]:[0,xe],[v]:[0,Te],[u+w]:[1,Ve,[gs],e=>[vs(...e)]],[w]:[1,Re,[gs],e=>os(bs(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],a)=>{As["add"+a+"Listener"]=(...a)=>Ne(a[e],t[a[e+1]?1:0],e>0?$(a,0,e):void 0,s,l)})),ne(As)};exports.Inspector=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(ms),a=Ie.indexOf(e);return t.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,a,n,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Ht(es,i,(()=>0)),Ht(ts,i,(()=>[]));const[b,p,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ue(e)||!ue(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ue(e)||!ue(t),t.setContent]:F("Store type not supported by this Persister"))(r,e),w=t=>{(b&&O(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await x((async()=>{try{const e=await t();O(e)?w(e):F("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),T),v=()=>(u&&(a(u),u=void 0),T),k=async e=>(1!=h&&(h=2,g++,await x((async()=>{try{await s(p,e)}catch(e){}h=0}))),T),S=()=>(L(c,e.delListener),c=void 0,T),x=async(...e)=>(Y(Dt(ts,i),...e),await(async()=>{if(!Dt(es,i)){for(jt(es,i,1);!N(d=Z(Dt(ts,i)));)try{await d()}catch(e){}jt(es,i,0)}})(),T),T={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return T},stopAutoLoad:v,isAutoLoading:()=>!N(u),save:k,startAutoSave:async()=>(await S().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),T),stopAutoSave:S,isAutoSaving:()=>!N(c),schedule:x,getStore:()=>e,destroy:()=>(Dt(ts,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return ne(T)})(e,(async()=>{return e=s.getItem(t),me(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),he(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(me(l.newValue))}catch{e()}};return T.addEventListener(ss,l),l}),(e=>T.removeEventListener(ss,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==a?1:a,open:!!s}]),await e.startAutoSave()})),B(P,null,B("aside",{id:be},B(Fe,{s:l}),B(Rt,{s:l})),B("style",null,Ae))};
|
|
1
|
+
"use strict";var e=require("react"),t=require("../../ui-react/with-schemas/index.cjs");const s=e=>typeof e,l="",a=s(l),n=s(!0),r=s(0),o=s(s),i="type",d="default",u="Has",c="Ids",h="Table",m=h+"s",g=h+c,b="Row",p=b+"Count",I=b+c,f="Cell",y=f+c,w="Value",C=w+"s",v=w+c,k="currentTarget",S="value",x=e=>l+e,T=globalThis.window,V=Math,R=V.min,q=V.floor,M=isFinite,N=e=>null==e,L=(e,t,s)=>N(e)?s?.():t(e),E=e=>e==a||e==n,z=e=>s(e)==o,O=e=>Array.isArray(e),$=(e,t,s)=>e.slice(t,s),A=e=>e.length,F=e=>{throw Error(e)},{PureComponent:J,Fragment:P,createElement:B,useCallback:D,useLayoutEffect:Q,useRef:j,useState:H}=e,W=(e,...t)=>N(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),U=(e,t)=>e.map(t),X=e=>0==A(e),Y=(e,...t)=>e.push(...t),Z=e=>e.shift(),_=Object,ee=e=>_.getPrototypeOf(e),te=_.entries,se=_.isFrozen,le=e=>!N(e)&&L(ee(e),(e=>e==_.prototype||N(ee(e))),(()=>!0)),ae=_.keys,ne=_.freeze,re=(e=[])=>_.fromEntries(e),oe=(e,t)=>t in e,ie=(e,t)=>(delete e[t],e),de=(e,t)=>U(te(e),(([e,s])=>t(s,e))),ue=e=>le(e)&&0==(e=>A(ae(e)))(e),ce=(e,t,s,l=0)=>N(e)||!le(e)||!l&&ue(e)||se(e)?(s?.(),!1):(de(e,((s,l)=>{t(s,l)||ie(e,l)})),!!l||!ue(e)),he=JSON.stringify,me=JSON.parse,ge=e=>he(e,((e,t)=>t instanceof Map?_.fromEntries([...t]):t)),be="tinybaseInspector",pe="TinyBase Inspector",Ie=["left","top","bottom","right","full"],fe="state",ye="sort",we="open",Ce="position",ve=we,ke="editable",Se=(...e)=>ge(e),xe=(e,t)=>U(G([...e]),t),Te=(e,s)=>[!!t.useCell(fe,e,ke,s),D((t=>{s.setCell(fe,e,ke,(e=>!e)),t.preventDefault()}),[s,e])],Ve="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",Re='content:url("',qe=Re+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Me='</svg>")',Ne=Re+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Le=U([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>qe+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Me)),Ee=qe+"<path d='M20 20l60 60M20 80l60-60' />"+Me,ze=qe+`<path d='${Ve}' />`+Me,Oe=qe+`<path d='${Ve}M20 20l60 60' />`+Me,$e="*::-webkit-scrollbar",Ae=((e,t="")=>e.join(t))(de({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[$e]:"width:0.5rem;height:0.5rem;",[$e+"-track"]:"background:#111",[$e+"-thumb"]:"background:#999;border:1px solid #111",[$e+"-thumb:hover"]:"background:#fff",[$e+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Ne,...re(U(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...re(U(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Ne,"header>img:nth-of-type(6)":Ee,...re(U(Le,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":ze,"details[open]>summary img.done":Oe,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Fe=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!0),[],e);return t.useValue(ve,e)?null:B("img",{onClick:l,title:pe,"data-position":s})},Je=({uniqueId:e,summary:s,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!t.useCell(fe,e,we,r),i=t.useSetCellCallback(fe,e,we,(e=>e[k].open),[],r);return B("details",{open:o,onToggle:i},B("summary",null,s,a?B("img",{onClick:a,className:l?"done":"edit"}):null),n)},Pe=e=>{const t=s(e);return E(t)||t==r&&M(e)?t:void 0},Be=(e,t,s,l,a)=>N(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),De=(e,t,s)=>N(s)?e.delValue(t):e.setValue(t,s),Qe=(e,t,s,l)=>e==a?t:e==r?s:l,{useCallback:je,useMemo:He,useState:We}=e,Ge="editable",Ke=(e,s)=>U(t.useTableCellIds(e,s),(t=>e+"."+t)),Ue=(e,t,s)=>{const l=je(e,t);return s?l:void 0},Xe=(...e)=>He((()=>e),e),Ye=(e,t)=>He((()=>({store:e,tableId:t})),[e,t]),Ze=(e,t)=>He((()=>({queries:e,queryId:t})),[e,t]),_e=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=We([e,t,l]),h=je((e=>{c(e),o?.(e)}),[o]),m=Ue((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=je((e=>h([i,d,e])),[h,i,d]),b=!0===r?ht:r;return[[i,d,u],m,He((()=>!1===r?null:B(b,{offset:u,limit:a,total:n,onChange:g})),[r,b,u,a,n,g])]},et=(e,t,l)=>He((()=>{const n=t??e;return r=O(n)?re(U(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:l,...(n=e,s(n)==a?{label:e}:e)};var n},re(de(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,l,e]),tt=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>B("table",{className:e},i?B("caption",null,i):null,!1===t?null:B("thead",null,B("tr",null,!1===s?null:B(st,{sort:r??[],label:"Id",onClick:o}),de(l,(({label:e},t)=>B(st,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),B("tbody",null,U(n,(e=>B("tr",{key:e},!1===s?null:B("th",null,e),de(l,(({component:t,getComponentProps:s},l)=>B("td",{key:l},B(t,{...W(s,e,l),...a,rowId:e,cellId:l}))))))))),st=({cellId:e,sort:[t,s],label:a=e??l,onClick:n})=>B("th",{onClick:Ue((()=>n?.(e)),[n,e],n),className:N(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},N(s)||t!=e?null:(s?"↓":"↑")+" ",a),lt=({localRowId:s,params:[l,a,n,r,o,i,d]})=>{const u=t.useRemoteRowId(o,s,i);return B("tr",null,!1===l?null:B(e.Fragment,null,B("th",null,s),B("th",null,u)),de(a,(({component:e,getComponentProps:t},l)=>{const[a,o]=l.split(".",2),i=a===n?s:a===r?u:null;return N(i)?null:B("td",{key:l},B(e,{...W(t,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:o=!0})=>{const[i,d]=We(),[u,c]=We(),[h,m]=We(),[g,b]=We(),[p,I]=We();u!==e&&(d(Pe(e)),c(e),m(e+""),b(Number(e)||0),I(!!e));const f=je(((e,s)=>{s(e),c(e),t(e)}),[t]),y=je((()=>{if(!l?.()){const e=Qe(i,r,n,a),s=Qe(e,h,g,p);d(e),c(s),t(s)}}),[l,t,h,g,p,i]);return B("div",{className:s},o?B("button",{className:i,onClick:y},i):null,Qe(i,B("input",{key:i,value:h,onChange:je((e=>f(e[k][S]+"",m)),[f])}),B("input",{key:i,type:"number",value:g,onChange:je((e=>f(Number(e[k][S]||0),b)),[f])}),B("input",{key:i,type:"checkbox",checked:p,onChange:je((e=>f(!!e[k].checked,I)),[f])})))},nt=({tableId:e,cellId:s,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,b]=_e(s,l,i,a,n,t.useRowCount(e,r),d,u);return B(tt,{...h,params:Xe(et(t.useTableCellIds(e,r),c,o?ut:t.CellView),Ye(r,e),t.useSortedRowIds(e,...m,n,r),m,g,b)})},rt=({store:e,editable:s=!1,valueComponent:l=(s?ct:t.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>B("table",{className:n},!1===r?null:B("thead",null,B("tr",null,!1===o?null:B("th",null,"Id"),B("th",null,w))),B("tbody",null,U(t.useValueIds(e),(t=>B("tr",{key:t},!1===o?null:B("th",null,t),B("td",null,B(l,{...W(a,t),valueId:t,store:e}))))))),ot=({indexId:e,sliceId:s,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(t.useIndexesOrIndexesById(l),e);return B(tt,{...r,params:Xe(et(t.useTableCellIds(d,i),n,a?ut:t.CellView),Ye(i,d),t.useSliceRowIds(e,s,o))})},it=({relationshipId:s,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(t.useRelationshipsOrRelationshipsById(l),s),m=et([...Ke(c,u),...Ke(h,u)],n,a?ut:t.CellView),g=Xe(i,m,c,h,s,d,u);return B("table",{className:r},!1===o?null:B("thead",null,B("tr",null,!1===i?null:B(e.Fragment,null,B("th",null,c,".Id"),B("th",null,h,".Id")),de(m,(({label:e},t)=>B("th",{key:t},e))))),B("tbody",null,U(t.useRowIds(c,u),(e=>B(lt,{key:e,localRowId:e,params:g})))))},dt=({queryId:e,cellId:s,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=_e(s,l,o,a,n,t.useResultRowCount(e,r),i,u);return B(tt,{...c,params:Xe(et(t.useResultTableCellIds(e,r),d,t.ResultCellView),Ze(r,e),t.useResultSortedRowIds(e,...h,n,r),h,m,g)})},ut=({tableId:e,rowId:s,cellId:l,store:a,className:n,showType:r})=>B(at,{thing:t.useCell(e,s,l,a),onThingChange:t.useSetCellCallback(e,s,l,(e=>e),[],a),className:n??Ge+f,showType:r,hasSchema:t.useStoreOrStoreById(a)?.hasTablesSchema}),ct=({valueId:e,store:s,className:l,showType:a})=>B(at,{thing:t.useValue(e,s),onThingChange:t.useSetValueCallback(e,(e=>e),[],s),className:l??Ge+w,showType:a,hasSchema:t.useStoreOrStoreById(s)?.hasValuesSchema}),ht=({onChange:t,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,t(0));const o=Ue((()=>t(l-a)),[t,l,a],l>0),i=Ue((()=>t(l+a)),[t,l,a],l+a<s);return B(e.Fragment,null,s>a&&B(e.Fragment,null,B("button",{className:"previous",disabled:0==l,onClick:o},"←"),B("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",R(s,l+a)," of "),s," ",1!=s?r:n)},mt=({indexes:e,indexesId:s,indexId:l,s:a})=>B(Je,{uniqueId:Se("i",s,l),summary:"Index: "+l,s:a},U(t.useSliceIds(l,e),(t=>B(gt,{indexes:e,indexesId:s,indexId:l,sliceId:t,s:a,key:t})))),gt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Se("i",t,s,l),[r,o]=Te(n,a);return B(Je,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},B(ot,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:s})=>{const l=t.useIndexes(e),a=t.useIndexIds(l);return N(l)?null:B(Je,{uniqueId:Se("i",e),summary:"Indexes: "+(e??d),s:s},X(a)?"No indexes defined":xe(a,(t=>B(mt,{indexes:l,indexesId:e,indexId:t,s:s,key:t}))))},pt=({metrics:e,metricId:s})=>B("tr",null,B("th",null,s),B("td",null,e?.getTableId(s)),B("td",null,t.useMetric(s,e))),It=({metricsId:e,s:s})=>{const l=t.useMetrics(e),a=t.useMetricIds(l);return N(l)?null:B(Je,{uniqueId:Se("m",e),summary:"Metrics: "+(e??d),s:s},X(a)?"No metrics defined":B("table",null,B("thead",null,B("th",null,"Metric Id"),B("th",null,"Table Id"),B("th",null,"Metric")),B("tbody",null,U(a,(e=>B(pt,{metrics:l,metricId:e,key:e}))))))},ft=({queries:e,queriesId:s,queryId:l,s:a})=>{const n=Se("q",s,l),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a);return B(Je,{uniqueId:n,summary:"Query: "+l,s:a},B(dt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},yt=({queriesId:e,s:s})=>{const l=t.useQueries(e),a=t.useQueryIds(l);return N(l)?null:B(Je,{uniqueId:Se("q",e),summary:"Queries: "+(e??d),s:s},X(a)?"No queries defined":xe(a,(t=>B(ft,{queries:l,queriesId:e,queryId:t,s:s,key:t}))))},wt=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Se("r",t,s),[n,r]=Te(a,l);return B(Je,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},B(it,{relationshipId:s,relationships:e,editable:n}))},Ct=({relationshipsId:e,s:s})=>{const l=t.useRelationships(e),a=t.useRelationshipIds(l);return N(l)?null:B(Je,{uniqueId:Se("r",e),summary:"Relationships: "+(e??d),s:s},X(a)?"No relationships defined":xe(a,(t=>B(wt,{relationships:l,relationshipsId:e,relationshipId:t,s:s,key:t}))))},vt=({tableId:e,store:s,storeId:l,s:a})=>{const n=Se("t",l,e),[r,o,i]=me(t.useCell(fe,n,ye,a)??"[]"),d=t.useSetCellCallback(fe,n,ye,ge,[],a),[u,c]=Te(n,a);return B(Je,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},B(nt,{tableId:e,store:s,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},kt=({store:e,storeId:s,s:l})=>{const a=Se("v",s),[n,r]=Te(a,l);return X(t.useValueIds(e))?null:B(Je,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},B(rt,{store:e,editable:n}))},St=({storeId:e,s:s})=>{const l=t.useStore(e),a=t.useTableIds(l);return N(l)?null:B(Je,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??d),s:s},B(kt,{storeId:e,store:l,s:s}),xe(a,(t=>B(vt,{store:l,storeId:e,tableId:t,s:s,key:t}))))},xt=({s:e})=>{const s=j(null),l=j(0),[a,n]=H(!1),{scrollLeft:r,scrollTop:o}=t.useValues(e);Q((()=>{const e=s.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=q(r)+e.clientWidth&&e.scrollHeight>=q(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=D((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=t.useStore(),u=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),g=t.useIndexesIds(),b=t.useRelationships(),p=t.useRelationshipsIds(),I=t.useQueries(),f=t.useQueriesIds();return N(d)&&X(u)&&N(c)&&X(h)&&N(m)&&X(g)&&N(b)&&X(p)&&N(I)&&X(f)?B("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):B("article",{ref:s,onScroll:i},B(St,{s:e}),U(u,(t=>B(St,{storeId:t,s:e,key:t}))),B(It,{s:e}),U(h,(t=>B(It,{metricsId:t,s:e,key:t}))),B(bt,{s:e}),U(g,(t=>B(bt,{indexesId:t,s:e,key:t}))),B(Ct,{s:e}),U(p,(t=>B(Ct,{relationshipsId:t,s:e,key:t}))),B(yt,{s:e}),U(f,(t=>B(yt,{queriesId:t,s:e,key:t}))))};class Tt extends J{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?B("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Vt=({s:e})=>{const s=t.useValue(Ce,e)??1,l=t.useSetValueCallback(ve,(()=>!1),[],e),a=t.useSetValueCallback(Ce,(e=>Number(e[k].dataset.id)),[],e);return B("header",null,B("img",{title:pe}),B("span",null,pe),U(Ie,((e,t)=>t==s?null:B("img",{onClick:a,"data-id":t,title:"Dock to "+e,key:t}))),B("img",{onClick:l,title:"Close"}))},Rt=({s:e})=>{const s=t.useValue(Ce,e)??1;return t.useValue(ve,e)?B("main",{"data-position":s},B(Vt,{s:e}),B(Tt,null,B(xt,{s:e}))):null},qt=e=>t=>{return s=(t,s)=>t+e(s),$t(t).reduce(s,0);var s},Mt=e=>e?.size??0,Nt=qt(Mt),Lt=qt(Nt),Et=qt(Lt),zt=(e,t)=>e?.has(t)??!1,Ot=e=>N(e)||0==Mt(e),$t=e=>[...e?.values()??[]],At=e=>e.clear(),Ft=(e,t)=>e?.forEach(t),Jt=(e,t)=>e?.delete(t),Pt=e=>new Map(e),Bt=e=>[...e?.keys()??[]],Dt=(e,t)=>e?.get(t),Qt=(e,t)=>Ft(e,((e,s)=>t(s,e))),jt=(e,t,s)=>N(s)?(Jt(e,t),e):e?.set(t,s),Ht=(e,t,s,l)=>(zt(e,t)?l?.(Dt(e,t)):jt(e,t,s()),Dt(e,t)),Wt=(e,t,s,l=jt)=>(de(t,((t,l)=>s(e,l,t))),Qt(e,(s=>oe(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const a={};return Ft(e,((e,n)=>{if(!s?.(e,n)){const s=t?t(e,n):e;l?.(s)||(a[n]=s)}})),a},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),Ot,ue),Ut=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),Ot,ue),Xt=(e,t)=>{const s=Pt();return Ft(e,((e,l)=>s.set(l,t?.(e)??e))),s},Yt=e=>Xt(e,Xt),Zt=e=>Xt(e,Yt),_t=(e,t,s,l,a=0)=>L((s?Ht:Dt)(e,t[a],a>A(t)-2?s:Pt),(n=>{if(a>A(t)-2)return l?.(n)&&jt(e,t[a]),n;const r=_t(n,t,s,l,a+1);return Ot(n)&&jt(e,t[a]),r})),es=Pt(),ts=Pt(),ss="storage",ls=e=>new Set(O(e)||N(e)?e:[e]),as=(e,t)=>e?.add(t),ns=/^\d+$/,rs=()=>{const e=[];let t=0;return[s=>(s?Z(e):null)??l+t++,t=>{ns.test(t)&&A(e)<1e3&&Y(e,t)}]},os=e=>[e,e],is=(e,t=Nt)=>t(e[0])+t(e[1]),ds=()=>[Pt(),Pt()],us=e=>[...e],cs=([e,t])=>e===t;Pt(U("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(l),((e,t)=>[e,t])));const hs=(e,t,s)=>jt(e,t,Dt(e,t)==-s?void 0:s),ms=()=>{let e,t,s=!1,a=!1,n=0,o=[];const c=Pt(),k=Pt(),S=Pt(),T=Pt(),V=Pt(),R=Pt(),q=Pt(),M=Pt(),F=Pt(),J=Pt(),P=Pt(),B=Pt(),D=Pt(),Q=Pt(),j=ls(),H=Pt(),W=Pt(),X=Pt(),Z=Pt(),_=ds(),ee=ds(),te=ds(),se=ds(),le=ds(),ae=ds(),re=ds(),he=ds(),be=ds(),pe=ds(),Ie=ds(),fe=ds(),ye=ds(),we=ds(),Ce=ds(),ve=ds(),ke=ds(),Se=ds(),xe=ds(),Te=ds(),Ve=ds(),Re=ds(),qe=Pt(),Me=ds(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=rs(),a=Pt();return[(s,n,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return jt(a,d,[s,n,r,o,i]),as(_t(n,r??[l],ls),d),d},(t,s,...n)=>K(((e,t=[l])=>{const s=[],a=(e,l)=>l==A(t)?Y(s,e):null===t[l]?Ft(e,(e=>a(e,l+1))):K([t[l],null],(t=>a(Dt(e,t),l+1)));return a(e,0),s})(t,s),(t=>Ft(t,(t=>Dt(a,t)[0](e,...s??[],...n))))),e=>L(Dt(a,e),(([,t,n])=>(_t(t,n??[l],void 0,(t=>(Jt(t,e),Ot(t)?1:0))),jt(a,e),s(e),n))),t=>L(Dt(a,t),(([t,,s=[],l,a])=>{const n=(...r)=>{const o=A(r);o==A(s)?t(e,...r,...a(r)):N(s[o])?K(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Oe=e=>{if(!ce(e,((e,t)=>[i,d].includes(t))))return!1;const t=e[i];return!(!E(t)&&t!=r||(Pe(e[d])!=t&&ie(e,d),0))},$e=O,Ae=(t,s)=>(!e||zt(P,s)||pt(s))&&ce(t,((e,t)=>Fe(s,t,e)),(()=>pt(s))),Fe=(e,t,s,l)=>ce(l?s:He(s,e,t),((l,a)=>L(Je(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>pt(e,t))),Je=(t,s,l,a)=>e?L(Dt(Dt(P,t),l),(e=>Pe(a)!=e[i]?pt(t,s,l,a,e[d]):a),(()=>pt(t,s,l,a))):N(Pe(a))?pt(t,s,l,a):a,Qe=(e,t)=>ce(t?e:We(e),((t,s)=>L(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?L(Dt(D,e),(t=>Pe(s)!=t[i]?It(e,s,t[d]):s),(()=>It(e,s))):N(Pe(s))?It(e,s):s,He=(e,t,s)=>(L(Dt(B,t),(([l,a])=>{Ft(l,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(a,(l=>{oe(e,l)||pt(t,s,l)}))})),e),We=e=>(t&&(Ft(Q,((t,s)=>{oe(e,s)||(e[s]=t)})),Ft(j,(t=>{oe(e,t)||It(t)}))),e),Ge=e=>Wt(P,e,((e,t,s)=>{const l=Pt(),a=ls();Wt(Ht(P,t,Pt),s,((e,t,s)=>{jt(e,t,s),L(s[d],(e=>jt(l,t,e)),(()=>as(a,t)))})),jt(B,t,[l,a])}),((e,t)=>{jt(P,t),jt(B,t)})),Ke=e=>Wt(D,e,((e,t,s)=>{jt(D,t,s),L(s[d],(e=>jt(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{jt(D,t),jt(Q,t),Jt(j,t)})),Ue=e=>ue(e)?Rs():ks(e),Xe=e=>Wt(X,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Wt(Ht(X,e,(()=>(ut(e,1),jt(H,e,rs()),jt(W,e,Pt()),Pt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,a)=>Wt(Ht(t,s,(()=>(ct(e,s,1),Pt()))),l,((t,l,a)=>_e(e,s,t,l,a)),((l,n)=>it(e,t,s,l,n,a))),_e=(e,t,s,l,a)=>{zt(s,l)||ht(e,t,l,1);const n=Dt(s,l);a!==n&&(mt(e,t,l,n,a),jt(s,l,a))},et=(e,t,s,l,a)=>L(Dt(t,s),(t=>_e(e,s,t,l,a)),(()=>Ze(e,t,s,He({[l]:a},e,s)))),tt=e=>ue(e)?Ns():Ss(e),st=e=>Wt(Z,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{zt(Z,e)||gt(e,1);const s=Dt(Z,e);t!==s&&(bt(e,s,t),jt(Z,e,t))},at=(e,t)=>{const[s]=Dt(H,e),l=s(t);return zt(Dt(X,e),l)?at(e,t):l},nt=e=>Dt(X,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Dt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,a,n)=>{const r=Dt(Dt(B,e)?.[0],a);if(!N(r)&&!n)return _e(e,s,l,a,r);const o=t=>{mt(e,s,t,Dt(l,t)),ht(e,s,t,-1),jt(l,t)};N(r)?o(a):Qt(l,o),Ot(l)&&(ct(e,s,-1),Ot(jt(t,s))&&(ut(e,-1),jt(X,e),jt(H,e),jt(W,e)))},dt=e=>{const t=Dt(Q,e);if(!N(t))return lt(e,t);bt(e,Dt(Z,e)),gt(e,-1),jt(Z,e)},ut=(e,t)=>hs(c,e,t),ct=(e,t,s)=>hs(Ht(T,e,Pt),t,s)&&jt(S,e,Ht(S,e,(()=>0))+s),ht=(e,t,s,l)=>{const a=Dt(W,e),n=Dt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&hs(Ht(k,e,Pt),s,l),jt(a,s,n!=-l?n+l:null),hs(Ht(Ht(V,e,Pt),t,Pt),s,l)},mt=(e,t,s,l,a)=>{Ht(Ht(Ht(R,e,Pt),t,Pt),s,(()=>[l,0]))[1]=a,o[3]?.(e,t,s,a)},gt=(e,t)=>hs(q,e,t),bt=(e,t,s)=>{Ht(M,e,(()=>[t,0]))[1]=s,o[4]?.(e,s)},pt=(e,t,s,l,a)=>(Y(Ht(Ht(Ht(F,e,Pt),t,Pt),s,(()=>[])),l),a),It=(e,t,s)=>(Y(Ht(J,e,(()=>[])),t),s),ft=(e,t,s)=>L(Dt(Dt(Dt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...os(ss(e,t,s))])),yt=e=>L(Dt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...os(bs(e))])),wt=e=>Ot(F)||Ot(ve[e])?0:Ft(e?Zt(F):F,((t,s)=>Ft(t,((t,l)=>Ft(t,((t,a)=>Le(ve[e],[s,l,a],t))))))),Ct=e=>Ot(J)||Ot(ke[e])?0:Ft(e?Xt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!Ot(e))return Le(t,l,(()=>Gt(e))),Qt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=ps();t!=s&&Le(_[e],void 0,t);const l=Ot(pe[e]),a=Ot(ye[e])&&Ot(we[e])&&Ot(be[e])&&Ot(Ie[e])&&Ot(ae[e])&&Ot(re[e])&&Ot(he[e])&&l&&Ot(te[e])&&Ot(se[e]),n=Ot(Ce[e])&&Ot(fe[e])&&Ot(le[e])&&Ot(ee[e]);if(!a||!n){const t=e?[Xt(c),Yt(k),Xt(S),Yt(T),Zt(V),Zt(R)]:[c,k,S,T,V,R];if(!a){vt(t[0],te[e],se[e]),Ft(t[1],((t,s)=>vt(t,ae[e],re[e],[s]))),Ft(t[2],((t,s)=>{0!=t&&Le(he[e],[s],qt(s))}));const s=ls();Ft(t[3],((t,a)=>{vt(t,be[e],Ie[e],[a])&&!l&&(Le(pe[e],[a,null]),as(s,a))})),l||Ft(t[5],((t,l)=>{if(!zt(s,l)){const s=ls();Ft(t,(e=>Ft(e,(([t,l],a)=>l!==t?as(s,a):Jt(e,a))))),Ft(s,(t=>Le(pe[e],[l,t])))}})),Ft(t[4],((t,s)=>Ft(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!n){let s;Ft(t[5],((t,l)=>{let a;Ft(t,((t,n)=>{let r;Ft(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,n,i],o,t,ft),s=a=r=1)})),r&&Le(fe[e],[l,n],ft)})),a&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},St=e=>{const t=Cs();t!=a&&Le(Se[e],void 0,t);const s=Ot(Te[e])&&Ot(Ve[e]),l=Ot(Re[e])&&Ot(xe[e]);if(!s||!l){const t=e?[Xt(q),Xt(M)]:[q,M];if(s||vt(t[0],Te[e],Ve[e]),!l){let s;Ft(t[1],(([t,l],a)=>{l!==t&&(Le(Re[e],[a],l,t,yt),s=1)})),s&&Le(xe[e],void 0,yt)}}},xt=(e,...t)=>(zs((()=>e(...U(t,x)))),As),Tt=()=>Ut(X),Vt=()=>Bt(X),Rt=e=>Bt(Dt(W,x(e))),qt=e=>Mt(Dt(X,x(e))),$t=e=>Bt(Dt(X,x(e))),es=(e,t,s,l=0,a)=>{return U($(G((n=Dt(X,x(e)),r=(e,s)=>[N(t)?s:Dt(e,x(t)),s],U([...n?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,N(a)?a:l+a),(([,e])=>e));var n,r},ts=(e,t)=>Bt(Dt(Dt(X,x(e)),x(t))),ss=(e,t,s)=>Dt(Dt(Dt(X,x(e)),x(t)),x(s)),ns=()=>Gt(Z),gs=()=>Bt(Z),bs=e=>Dt(Z,x(e)),ps=()=>!Ot(X),Is=e=>zt(X,x(e)),fs=(e,t)=>zt(Dt(W,x(e)),x(t)),ys=(e,t)=>zt(Dt(X,x(e)),x(t)),ws=(e,t,s)=>zt(Dt(Dt(X,x(e)),x(t)),x(s)),Cs=()=>!Ot(Z),vs=e=>zt(Z,x(e)),ks=e=>xt((()=>(e=>ce(e,Ae,pt))(e)?Xe(e):0)),Ss=e=>xt((()=>Qe(e)?st(e):0)),xs=e=>{try{Ue(me(e))}catch{}return As},Ts=t=>xt((()=>{if((e=ce(t,(e=>ce(e,Oe))))&&(Ge(t),!Ot(X))){const e=Tt();Rs(),ks(e)}})),Vs=e=>xt((()=>{if(t=(e=>ce(e,Oe))(e)){const s=ns();Es(),Ns(),t=!0,Ke(e),Ss(s)}})),Rs=()=>xt((()=>Xe({}))),qs=e=>xt((e=>zt(X,e)?rt(e):0),e),Ms=(e,t)=>xt(((e,t)=>L(Dt(X,e),(s=>zt(s,t)?ot(e,s,t):0))),e,t),Ns=()=>xt((()=>st({}))),Ls=()=>xt((()=>{Ge({}),e=!1})),Es=()=>xt((()=>{Ke({}),t=!1})),zs=(e,t)=>{if(-1!=n){Os();const s=e();return $s(t),s}},Os=()=>(-1!=n&&n++,1==n&&(o[0]?.(),Le(qe)),As),$s=e=>(n>0&&(n--,0==n&&(n=1,wt(1),Ot(R)||kt(1),Ct(1),Ot(M)||St(1),e?.(As)&&(Ft(R,((e,t)=>Ft(e,((e,s)=>Ft(e,(([e],l)=>Be(As,t,s,l,e))))))),At(R),Ft(M,(([e],t)=>De(As,t,e))),At(M)),Le(Me[0],void 0),n=-1,wt(0),Ot(R)||kt(0),Ct(0),Ot(M)||St(0),o[1]?.(),Le(Me[1],void 0),o[2]?.(),n=0,s=ps(),a=Cs(),K([c,k,S,T,V,R,F,q,M,J],At))),As),As={getContent:()=>[Tt(),ns()],getTables:Tt,getTableIds:Vt,getTable:e=>Kt(Dt(X,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:$t,getSortedRowIds:es,getRow:(e,t)=>Gt(Dt(Dt(X,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ns,getValueIds:gs,getValue:bs,hasTables:ps,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>ge(X),getValuesJson:()=>ge(Z),getJson:()=>ge([X,Z]),getTablesSchemaJson:()=>ge(P),getValuesSchemaJson:()=>ge(D),getSchemaJson:()=>ge([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>xt((()=>$e(e)?(([e,t])=>{(ue(e)?Rs:ks)(e),(ue(t)?Ns:Ss)(t)})(e):0)),setTables:ks,setTable:(e,t)=>xt((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>xt(((e,t)=>Fe(e,t,s)?Ze(e,nt(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,nt(e),l=at(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>xt(((e,t)=>{if(Fe(e,t,s,1)){const l=nt(e);de(s,((s,a)=>et(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>xt(((e,t,s)=>L(Je(e,t,s,z(l)?l(ss(e,t,s)):l),(l=>et(e,nt(e),t,s,l)))),e,t,s),setValues:Ss,setPartialValues:e=>xt((()=>Qe(e,1)?de(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>xt((e=>L(je(e,z(t)?t(bs(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>xt((()=>{de(e[0],((e,t)=>N(e)?qs(t):de(e,((e,s)=>N(e)?Ms(t,s):de(e,((e,l)=>Be(As,t,s,l,e))))))),de(e[1],((e,t)=>De(As,t,e)))})),setTablesJson:xs,setValuesJson:e=>{try{tt(me(e))}catch{}return As},setJson:e=>xt((()=>{try{const[t,s]=me(e);Ue(t),tt(s)}catch{xs(e)}})),setTablesSchema:Ts,setValuesSchema:Vs,setSchema:(e,t)=>xt((()=>{Ts(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>xt(((e,t,s)=>L(Dt(X,e),(a=>L(Dt(a,t),(n=>zt(n,s)?it(e,a,t,n,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>xt((e=>zt(Z,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>xt((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Dt(c,t)?void 0:Gt(e,((e,s)=>-1===Dt(Dt(T,t),s)?void 0:Gt(e,(([,e])=>e),(e=>cs(e)))),Ot,ue)),Ot,ue),Gt(M,(([,e])=>e),(e=>cs(e))),1],getTransactionLog:()=>[!Ot(R),!Ot(M),Ut(R,us,cs),Ut(F),Gt(M,us,cs),Gt(J),Gt(c),Kt(T),Ut(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Ft(X,((t,s)=>e(s,(e=>Ft(t,((t,s)=>e(s,(e=>Qt(t,e))))))))),forEachTableCell:(e,t)=>Qt(Dt(W,x(e)),t),forEachRow:(e,t)=>Ft(Dt(X,x(e)),((e,s)=>t(s,(t=>Qt(e,t))))),forEachCell:(e,t,s)=>Qt(Dt(Dt(X,x(e)),x(t)),s),forEachValue:e=>Qt(Z,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=es(e,t,s,l,a);return Ne((()=>{const r=es(e,t,s,l,a);var i,d,u;d=o,A(i=r)===A(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(As,e,t,s,l,a,o))}),pe[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:is(_),tables:is(ee),tableIds:is(te),hasTable:is(se),table:is(le),tableCellIds:is(ae),hasTableCell:is(re,Lt),rowCount:is(he),rowIds:is(be),sortedRowIds:is(pe),hasRow:is(Ie,Lt),row:is(fe,Lt),cellIds:is(ye,Lt),hasCell:is(we,Et),cell:is(Ce,Et),invalidCell:is(ve,Et),hasValues:is(Se),values:is(xe),valueIds:is(Te),hasValue:is(Ve),value:is(Re),invalidValue:is(ke),transaction:Nt(qe)+is(Me)}),isMergeable:()=>!1,createStore:ms,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,a)=>o=[e,t,s,l,a]};return de({[u+m]:[0,_,[],()=>[ps()]],[m]:[0,ee],[g]:[0,te],[u+h]:[1,se,[Vt],e=>[Is(...e)]],[h]:[1,le,[Vt]],[h+y]:[1,ae,[Vt]],[u+h+f]:[2,re,[Vt,Rt],e=>[fs(...e)]],[p]:[1,he,[Vt]],[I]:[1,be,[Vt]],[u+b]:[2,Ie,[Vt,$t],e=>[ys(...e)]],[b]:[2,fe,[Vt,$t]],[y]:[2,ye,[Vt,$t]],[u+f]:[3,we,[Vt,$t,ts],e=>[ws(...e)]],[f]:[3,Ce,[Vt,$t,ts],e=>os(ss(...e))],InvalidCell:[3,ve],[u+C]:[0,Se,[],()=>[Cs()]],[C]:[0,xe],[v]:[0,Te],[u+w]:[1,Ve,[gs],e=>[vs(...e)]],[w]:[1,Re,[gs],e=>os(bs(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],a)=>{As["add"+a+"Listener"]=(...a)=>Ne(a[e],t[a[e+1]?1:0],e>0?$(a,0,e):void 0,s,l)})),ne(As)};exports.Inspector=({position:e="right",open:s=!1})=>{const l=t.useCreateStore(ms),a=Ie.indexOf(e);return t.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,a,n,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Ht(es,i,(()=>0)),Ht(ts,i,(()=>[]));const[b,p,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ue(e)||!ue(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ue(e)||!ue(t),t.setContent]:F("Store type not supported by this Persister"))(r,e),w=t=>{(b&&O(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await x((async()=>{try{const e=await t();O(e)?w(e):F("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),T),v=()=>(u&&(a(u),u=void 0),T),k=async e=>(1!=h&&(h=2,g++,await x((async()=>{try{await s(p,e)}catch(e){}h=0}))),T),S=()=>(L(c,e.delListener),c=void 0,T),x=async(...e)=>(Y(Dt(ts,i),...e),await(async()=>{if(!Dt(es,i)){for(jt(es,i,1);!N(d=Z(Dt(ts,i)));)try{await d()}catch(e){}jt(es,i,0)}})(),T),T={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return T},stopAutoLoad:v,isAutoLoading:()=>!N(u),save:k,startAutoSave:async()=>(await S().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),T),stopAutoSave:S,isAutoSaving:()=>!N(c),schedule:x,getStore:()=>e,destroy:()=>(Dt(ts,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return ne(T)})(e,(async()=>{return e=s.getItem(t),me(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),he(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(me(l.newValue))}catch{e()}};return T.addEventListener(ss,l),l}),(e=>T.removeEventListener(ss,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==a?1:a,open:!!s}]),await e.startAutoSave()})),B(P,null,B("aside",{id:be},B(Fe,{s:l}),B(Rt,{s:l})),B("style",null,Ae))};
|
|
Binary file
|
package/cjs/ui-react/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
5
|
const getTypeOf = (thing) => typeof thing;
|
|
6
|
+
const TINYBASE = 'tinybase';
|
|
6
7
|
const EMPTY_STRING = '';
|
|
7
8
|
const STRING = getTypeOf(EMPTY_STRING);
|
|
8
9
|
const FUNCTION = getTypeOf(getTypeOf);
|
|
@@ -26,6 +27,7 @@ const VALUE = 'Value';
|
|
|
26
27
|
const VALUES = VALUE + 's';
|
|
27
28
|
const VALUE_IDS = VALUE + IDS;
|
|
28
29
|
|
|
30
|
+
const GLOBAL = globalThis;
|
|
29
31
|
const isUndefined = (thing) => thing == void 0;
|
|
30
32
|
const ifNotUndefined = (value, then, otherwise) =>
|
|
31
33
|
isUndefined(value) ? otherwise?.() : then(value);
|
|
@@ -59,6 +61,7 @@ const isObject = (obj) =>
|
|
|
59
61
|
);
|
|
60
62
|
const objIds = object.keys;
|
|
61
63
|
const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
|
|
64
|
+
const objHas = (obj, id) => id in obj;
|
|
62
65
|
const objDel = (obj, id) => {
|
|
63
66
|
delete obj[id];
|
|
64
67
|
return obj;
|
|
@@ -77,9 +80,15 @@ const objIsEqual = (obj1, obj2) => {
|
|
|
77
80
|
)
|
|
78
81
|
);
|
|
79
82
|
};
|
|
83
|
+
const objEnsure = (obj, id, getDefaultValue) => {
|
|
84
|
+
if (!objHas(obj, id)) {
|
|
85
|
+
obj[id] = getDefaultValue();
|
|
86
|
+
}
|
|
87
|
+
return obj[id];
|
|
88
|
+
};
|
|
80
89
|
|
|
81
90
|
const {createContext, useContext: useContext$1, useEffect: useEffect$1} = React;
|
|
82
|
-
const Context = createContext([]);
|
|
91
|
+
const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () => createContext([]));
|
|
83
92
|
const useThing = (id, offset) => {
|
|
84
93
|
const contextValue = useContext$1(Context);
|
|
85
94
|
return isUndefined(id)
|