tinybase 6.5.0 → 6.5.2

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.
Files changed (39) hide show
  1. package/common/index.js +1 -1
  2. package/common/with-schemas/index.js +1 -1
  3. package/index.js +1 -1
  4. package/mergeable-store/index.js +1 -1
  5. package/mergeable-store/with-schemas/index.js +1 -1
  6. package/min/index.js +1 -1
  7. package/min/index.js.gz +0 -0
  8. package/min/mergeable-store/index.js +1 -1
  9. package/min/mergeable-store/index.js.gz +0 -0
  10. package/min/mergeable-store/with-schemas/index.js +1 -1
  11. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  12. package/min/omni/index.js +1 -1
  13. package/min/omni/index.js.gz +0 -0
  14. package/min/omni/with-schemas/index.js +1 -1
  15. package/min/omni/with-schemas/index.js.gz +0 -0
  16. package/min/synchronizers/synchronizer-ws-server/index.js +1 -1
  17. package/min/synchronizers/synchronizer-ws-server/index.js.gz +0 -0
  18. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  19. package/min/synchronizers/synchronizer-ws-server/with-schemas/index.js.gz +0 -0
  20. package/min/with-schemas/index.js +1 -1
  21. package/min/with-schemas/index.js.gz +0 -0
  22. package/omni/index.js +1 -1
  23. package/omni/with-schemas/index.js +1 -1
  24. package/package.json +5 -5
  25. package/readme.md +2 -2
  26. package/releases.md +16 -1
  27. package/synchronizers/index.js +1 -1
  28. package/synchronizers/synchronizer-broadcast-channel/index.js +1 -1
  29. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +1 -1
  30. package/synchronizers/synchronizer-local/index.js +1 -1
  31. package/synchronizers/synchronizer-local/with-schemas/index.js +1 -1
  32. package/synchronizers/synchronizer-ws-client/index.js +1 -1
  33. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +1 -1
  34. package/synchronizers/synchronizer-ws-server/index.js +1 -1
  35. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +1 -1
  36. package/synchronizers/synchronizer-ws-server-durable-object/index.js +1 -1
  37. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +1 -1
  38. package/synchronizers/with-schemas/index.js +1 -1
  39. package/with-schemas/index.js +1 -1
@@ -1 +1 @@
1
- const e=e=>typeof e,t="",s=e(t),n=e(!0),l=e(0),o=e(e),a="type",r="default",i="Listener",d="Result",c="add",u="Has",g="Ids",h="Table",f=h+"s",I=h+g,b="Row",w=b+"Count",L=b+g,C="Sorted"+b+g,R="Cell",T=R+g,v="Value",p=v+"s",S=v+g,y=e=>t+e,V=(e,t)=>e.startsWith(t),m=(e,t)=>e.endsWith(t),M=(e,s=t,n)=>e.split(s,n),E=globalThis,k=Math,D=k.max,H=k.min,J=k.floor,x=isFinite,F=e=>null==e,Q=(e,t,s)=>F(e)?s?.():t(e),z=e=>e==s||e==n,N=t=>e(t)==s,O=t=>e(t)==o,W=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),P=e=>e.length,j=()=>{},_=()=>{},B=async(e,t,s)=>{try{return await e()}catch(e){t?.(e)}},U=(e,t)=>e.includes(t),q=(e,t)=>e.every(t),G=(e,t)=>P(e)===P(t)&&q(e,(e,s)=>t[s]===e),K=(e,t)=>q(e,(s,n)=>0==n||t(e[n-1],s)<=0),X=(e,t)=>e.sort(t),Y=(e,t)=>e.forEach(t),Z=(e,t)=>e.map(t),$=e=>te(e,(e,t)=>e+t,0),ee=e=>0==P(e),te=(e,t,s)=>e.reduce(t,s),se=(e,...t)=>e.push(...t),ne=e=>e.pop(),le=e=>e.shift(),oe=t=>{const s=e(t);return z(s)||s==l&&x(t)?s:void 0},ae=e=>F(e)||!F(oe(e)),re=(e,t,s,n,l)=>F(l)?e.delCell(t,s,n,!0):e.setCell(t,s,n,l),ie=(e,t,s)=>F(s)?e.delValue(t):e.setValue(t,s),de=e=>t=>te(be(t),(t,s)=>t+e(s),0),ce=e=>e?.size??0,ue=de(ce),ge=de(ue),he=de(ge),fe=(e,t)=>e?.has(t)??!1,Ie=e=>F(e)||0==ce(e),be=e=>[...e?.values()??[]],we=e=>e.clear(),Le=(e,t)=>e?.forEach(t),Ce=(e,t)=>e?.delete(t),Re=Object,Te=e=>Re.getPrototypeOf(e),ve=Re.isFrozen,pe=Re.entries,Se=e=>!F(e)&&Q(Te(e),e=>e==Re.prototype||F(Te(e)),()=>!0),ye=Re.keys,Ve=Re.freeze,me=(e=[])=>Re.fromEntries(e),Me=(e,t)=>t in e,Ee=(e,t)=>(delete e[t],e),ke=(e,t)=>Y(pe(e),([e,s])=>t(s,e)),De=(e,t)=>me(((e,t)=>Z(pe(e),([e,s])=>t(s,e)))(e,(e,s)=>[s,t(e,s)])),He=e=>Se(e)&&0==(e=>P(ye(e)))(e),Je=(e,t,s)=>(Me(e,t)||(e[t]=s()),e[t]),xe=(e,t,s,n=0)=>F(e)||!Se(e)||!n&&He(e)||ve(e)?(s?.(),!1):(ke(e,(s,n)=>{t(s,n)||Ee(e,n)}),!!n||!He(e)),Fe=e=>new Map(e),Qe=e=>[...e?.keys()??[]],ze=(e,t)=>e?.get(t),Ne=(e,t)=>Le(e,(e,s)=>t(s,e)),Oe=(e,t,s)=>F(s)?(Ce(e,t),e):e?.set(t,s),We=(e,t,s,n)=>(fe(e,t)?n?.(ze(e,t)):Oe(e,t,s()),ze(e,t)),Ae=(e,t,s,n=Oe)=>(De(t,(t,n)=>s(e,n,t)),Ne(e,s=>Me(t,s)?0:n(e,s)),e),Pe=(e,t,s,n)=>{const l={};return Le(e,(e,o)=>{if(!s?.(e,o)){const s=t?t(e,o):e;n?.(s)||(l[o]=s)}}),l},je=(e,t,s)=>Pe(e,e=>Pe(e,t,s),Ie,He),_e=(e,t,s)=>Pe(e,e=>je(e,t,s),Ie,He),Be=(e,t)=>{const s=Fe();return Le(e,(e,n)=>s.set(n,t?.(e)??e)),s},Ue=e=>Be(e,Be),qe=e=>Be(e,Ue),Ge=(e,t,s,n,l=0)=>Q((s?We:ze)(e,t[l],l>P(t)-2?s:Fe),o=>{if(l>P(t)-2)return n?.(o)&&Oe(e,t[l]),o;const a=Ge(o,t,s,n,l+1);return Ie(o)&&Oe(e,t[l]),a}),Ke=e=>new Set(W(e)||F(e)?e:[e]),Xe=(e,t)=>e?.add(t),Ye=(e,t,s,n,l)=>{const o=e.hasRow,a=Fe(),r=Fe(),i=Fe(),d=Fe(),c=Fe(),u=Fe(),g=(t,s,...n)=>{const l=We(u,t,Ke);return Y(n,t=>Xe(l,t)&&s&&e.callListener(t)),n},h=(t,...s)=>Q(ze(u,t),n=>{Y(ee(s)?be(n):s,t=>{e.delListener(t),Ce(n,t)}),Ie(n)&&Oe(u,t)}),f=(e,s)=>{Oe(a,e,s),fe(r,e)||(Oe(r,e,t()),Oe(d,e,Fe()),Oe(c,e,Fe()),l(i))},I=e=>{Oe(a,e),Oe(r,e),Oe(d,e),Oe(c,e),h(e),l(i)};return[()=>e,()=>Qe(a),e=>Ne(r,e),e=>fe(r,e),e=>ze(a,e),e=>ze(r,e),(e,t)=>Oe(r,e,t),f,(t,n,l,a,r)=>{f(t,n);const i=Fe(),u=Fe(),I=ze(d,t),b=ze(c,t),w=t=>{const l=s=>e.getCell(n,t,s),d=ze(I,t),c=o(n,t)?s(a(l,t)):void 0;if(d===c||W(d)&&W(c)&&G(d,c)||Oe(i,t,[d,c]),!F(r)){const e=ze(b,t),s=o(n,t)?r(l,t):void 0;e!=s&&Oe(u,t,s)}},L=e=>{l(()=>{Le(i,([,e],t)=>Oe(I,t,e)),Le(u,(e,t)=>Oe(b,t,e))},i,u,I,b,e),we(i),we(u)};Ne(I,w),e.hasTable(n)&&Y(e.getRowIds(n),e=>{fe(I,e)||w(e)}),L(!0),h(t),g(t,0,e.addRowListener(n,null,(e,t,s)=>w(s)),e.addTableListener(n,()=>L()))},I,e=>n(e,i),()=>Ne(u,I),g,h]},Ze=(e,s)=>N(e)?t=>t(e):e??(()=>s??t),$e=(e,t)=>{const s=new WeakMap;return n=>{s.has(n)||s.set(n,e(n));const l=s.get(n);return t?.(l),l}},et=/^\d+$/,tt=()=>{const e=[];let s=0;return[n=>(n?le(e):null)??t+s++,t=>{et.test(t)&&P(e)<1e3&&se(e,t)}]},st=e=>{let s;const[n,l]=tt(),o=Fe();return[(l,a,r,i=[],d=()=>[])=>{s??=e();const c=n(1);return Oe(o,c,[l,a,r,i,d]),Xe(Ge(a,r??[t],Ke),c),c},(e,n,...l)=>Y(((e,s=[t])=>{const n=[],l=(e,t)=>t==P(s)?se(n,e):null===s[t]?Le(e,e=>l(e,t+1)):Y([s[t],null],s=>l(ze(e,s),t+1));return l(e,0),n})(e,n),e=>Le(e,e=>ze(o,e)[0](s,...n??[],...l))),e=>Q(ze(o,e),([,s,n])=>(Ge(s,n??[t],void 0,t=>(Ce(t,e),Ie(t)?1:0)),Oe(o,e),l(e),n)),e=>Q(ze(o,e),([e,,t=[],n,l])=>{const o=(...a)=>{const r=P(a);r==P(t)?e(s,...a,...l(a)):F(t[r])?Y(n[r]?.(...a)??[],e=>o(...a,e)):o(...a,t[r])};o()})]},nt=$e(e=>{let s,n,l,o=100,a=Fe(),r=Fe(),i=1;const d=Fe(),c=Fe(),[u,g,h]=st(()=>J),f=Fe(),I=Fe(),b=[],w=[],L=(t,s)=>{i=0,e.transaction(()=>{const[n,l]=ze(f,s);Le(n,(s,n)=>Le(s,(s,l)=>Le(s,(s,o)=>re(e,n,l,o,s[t])))),Le(l,(s,n)=>ie(e,n,s[t]))}),i=1},C=e=>{Oe(f,e),Oe(I,e),g(c,[e])},R=(e,t)=>Y(((e,t)=>e.splice(0,t))(e,t??P(e)),C),T=()=>R(b,P(b)-o),v=()=>Q(s,()=>{se(b,s),T(),R(w),s=void 0,l=1}),p=()=>{s=ne(b),l=1};let S,y;const V=(e=t)=>(F(s)&&(s=t+n++,Oe(f,s,[a,r]),D(s,e),a=Fe(),r=Fe(),l=1),s),m=()=>{ee(b)||(((e,...t)=>{e.unshift(...t)})(w,V()),L(0,s),s=ne(b),l=1)},M=()=>{ee(w)||(se(b,s),s=le(w),L(1,s),l=1)},E=()=>{l&&(g(d),l=0)},k=e=>{const t=V(e);return E(),t},D=(e,t)=>(H(e)&&ze(I,e)!==t&&(Oe(I,e,t),g(c,[e])),J),H=e=>fe(f,e),J={setSize:e=>(o=e,T(),J),addCheckpoint:k,setCheckpoint:D,getStore:()=>e,getCheckpointIds:()=>[[...b],s,[...w]],forEachCheckpoint:e=>Ne(I,e),hasCheckpoint:H,getCheckpoint:e=>ze(I,e),goBackward:()=>(m(),E(),J),goForward:()=>(M(),E(),J),goTo:e=>{const t=U(b,e)?m:U(w,e)?M:null;for(;!F(t)&&e!=s;)t();return E(),J},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),J),clear:()=>(R(b),R(w),F(s)||C(s),s=void 0,n=0,k(),J),clearForward:()=>(ee(w)||(R(w),g(d)),J),destroy:()=>{e.delListener(S),e.delListener(y)},getListenerStats:()=>({checkpointIds:ue(d),checkpoint:ue(c)}),_registerListeners:()=>{S=e.addCellListener(null,null,null,(e,t,s,n,l,o)=>{if(i){v();const e=We(a,t,Fe),r=We(e,s,Fe),i=We(r,n,()=>[o,void 0]);i[1]=l,i[0]===l&&Ie(Oe(r,n))&&Ie(Oe(e,s))&&Ie(Oe(a,t))&&p(),E()}}),y=e.addValueListener(null,(e,t,s,n)=>{if(i){v();const e=We(r,t,()=>[n,void 0]);e[1]=s,e[0]===s&&Ie(Oe(r,t))&&p(),E()}})}};return Ve(J.clear())},e=>e._registerListeners()),lt=M("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"),ot=Fe(Z(lt,(e,t)=>[e,t])),at=e=>lt[63&e],rt=(e,t)=>ze(ot,e[t])??0,it=E.crypto?e=>E.crypto.getRandomValues(e):e=>Z(e,()=>J(256*k.random())),dt=(e=16)=>te(it(new Uint8Array(e)),(e,t)=>e+at(t),""),ct=JSON.stringify,ut=JSON.parse,gt=e=>ct(e,(e,t)=>t instanceof Map?Re.fromEntries([...t]):t),ht=new E.TextEncoder,ft=e=>{let t=2166136261;return Y(ht.encode(e),e=>{t^=e,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)}),t>>>0},It=(e,t)=>(e^t)>>>0,bt=e=>te(pe(e),(e,[t,s])=>It(e,wt(t,s)^wt(t,0)),0),wt=(e,t)=>ft(e+":"+t),Lt=(e,t)=>ft(gt(e??null)+":"+t),Ct=Lt,Rt=wt,Tt=bt,vt=wt,pt=e=>te(pe(e),(e,[t,s])=>It(e,wt(t,s)),0),St=wt,yt=pt,Vt=2**36,mt=2**30,Mt=2**24,Et=2**18,kt=4096,Dt=e=>{const t=ft(e);return at(t/Mt)+at(t/Et)+at(t/kt)+at(t/64)+at(t)},Ht=(e,t=Date.now)=>{let s=0,n=-1;const l=Q(e,Dt,()=>dt(5)),o=e=>{const l=s,[o,a]=F(e)||""==e?[0,0]:r(e);s=D(l,o,t()),n=s==l?s==o?D(n,a):n:s==o?a:-1},a=(e,t,s)=>at(e/Vt)+at(e/mt)+at(e/Mt)+at(e/Et)+at(e/kt)+at(e/64)+at(e)+at(t/Et)+at(t/kt)+at(t/64)+at(t)+(F(s)?l:Dt(s)),r=e=>[rt(e,0)*Vt+rt(e,1)*mt+rt(e,2)*Mt+rt(e,3)*Et+rt(e,4)*kt+64*rt(e,5)+rt(e,6),rt(e,7)*Et+rt(e,8)*kt+64*rt(e,9)+rt(e,10),e.slice(11)];return[()=>(o(),a(s,++n)),o,a,r,()=>s,()=>n,()=>l]},Jt=(e,t)=>(e??0)<(t??0)?-1:1,xt=$e(e=>{const s=Fe(),n=Fe(),[l,o,a]=st(()=>C),[r,i,d,c,u,g,h,,f,I,b,w]=Ye(e,Fe,e=>F(e)?t:W(e)?Z(e,y):y(e),l,o),L=(t,s,n)=>{const l=u(t);Le(n,(t,n)=>s(n,s=>Le(t,t=>s(t,s=>e.forEachCell(l,t,s)))))},C={setIndexDefinition:(e,t,l,a,r,i=Jt)=>{const d=F(r)?void 0:([e],[t])=>r(e,t);return f(e,t,(t,l,r,c,u,f)=>{let I=0;const b=Ke(),w=Ke(),L=g(e);if(Le(l,([e,t],s)=>{const n=Ke(e),l=Ke(t);Le(n,e=>Ce(l,e)?Ce(n,e):0),Le(n,e=>{Xe(b,e),Q(ze(L,e),t=>{Ce(t,s),Ie(t)&&(Oe(L,e),I=1)})}),Le(l,e=>{Xe(b,e),fe(L,e)||(Oe(L,e,Ke()),I=1),Xe(ze(L,e),s),F(a)||Xe(w,e)})}),t(),Ie(u)||(f?Ne(L,e=>Xe(w,e)):Ne(r,e=>Q(ze(c,e),e=>Y(W(e)?e:[e],e=>Xe(w,e)))),Le(w,e=>{const t=(t,s)=>i(ze(u,t),ze(u,s),e),s=[...ze(L,e)];K(s,t)||(Oe(L,e,Ke(X(s,t))),Xe(b,e))})),(I||f)&&!F(d)){const t=[...L];K(t,d)||(h(e,Fe(X(t,d))),I=1)}I&&o(s,[e]),Le(b,t=>o(n,[e,t]))},Ze(l),Q(a,Ze)),C},delIndexDefinition:e=>(I(e),C),getStore:r,getIndexIds:i,forEachIndex:e=>d((t,s)=>e(t,e=>L(t,e,s))),forEachSlice:(e,t)=>L(e,t,g(e)),hasIndex:c,hasSlice:(e,t)=>fe(g(e),t),getTableId:u,getSliceIds:e=>Qe(g(e)),getSliceRowIds:(e,t)=>be(ze(g(e),t)),addIndexIdsListener:b,addSliceIdsListener:(e,t)=>l(t,s,[e]),addSliceRowIdsListener:(e,t,s)=>l(s,n,[e,t]),delListener:e=>(a(e),C),destroy:w,getListenerStats:()=>({sliceIds:ue(s),sliceRowIds:ge(n)})};return Ve(C)}),Ft=([e,t])=>zt(e,t),Qt=([e,t,s])=>[e,t,s],zt=(e,t)=>t?[e,t]:[e],Nt=(e,t,s)=>[e,t,s],Ot=e=>e[2],Wt=(e,t)=>t>e?(e?ft(e):0)^ft(t):0,At=(e,t)=>((e??"")>(t??"")?e:t)??"",Pt=(e,t,s)=>{t>e[1]&&(e[1]=t),e[2]=s>>>0},jt=(e=t)=>zt(me(),e),_t=(e=t)=>[Fe(),e,0],Bt=([e,t,s],n=Qt)=>[Pe(e,n),t,s],Ut=([e,t],s=Ft)=>zt(Pe(e,s),t),qt=(t,s)=>W(t)&&3==P(t)&&N(t[1])&&e(t[2])==l&&x(t[2])&&s(t[0]),Gt=e=>[e,e],Kt=(e,t=ue)=>t(e[0])+t(e[1]),Xt=()=>[Fe(),Fe()],Yt=e=>[...e],Zt=([e,t])=>e===t,$t=(e,t,s)=>Oe(e,t,ze(e,t)==-s?void 0:s),es=()=>{let e,t,s=!1,n=!1,o=0,d=[];const g=Fe(),C=Fe(),V=Fe(),m=Fe(),M=Fe(),E=Fe(),k=Fe(),D=Fe(),H=Fe(),J=Fe(),x=Fe(),N=Fe(),P=Fe(),j=Fe(),_=Ke(),q=Fe(),K=Fe(),$=Fe(),ee=Fe(),te=Xt(),ne=Xt(),le=Xt(),ae=Xt(),de=Xt(),be=Xt(),Re=Xt(),Te=Xt(),ve=Xt(),pe=Xt(),ye=Xt(),me=Xt(),ke=Xt(),Je=Xt(),Ge=Xt(),Ye=Xt(),Ze=Xt(),$e=Xt(),et=Xt(),nt=Xt(),lt=Xt(),ot=Xt(),at=Fe(),rt=Xt(),[it,dt,ct,ht]=st(()=>Ps),ft=e=>{if(!xe(e,(e,t)=>U([a,r],t)))return!1;const t=e[a];return!(!z(t)&&t!=l||(oe(e[r])!=t&&Ee(e,r),0))},It=W,bt=(t,s)=>(!e||fe(x,s)||Ut(s))&&xe(t,(e,t)=>wt(s,t,e),()=>Ut(s)),wt=(e,t,s,n)=>xe(n?s:Tt(s,e,t),(n,l)=>Q(Lt(e,t,l,n),e=>(s[l]=e,!0),()=>!1),()=>Ut(e,t)),Lt=(t,s,n,l)=>e?Q(ze(ze(x,t),n),e=>oe(l)!=e[a]?Ut(t,s,n,l,e[r]):l,()=>Ut(t,s,n,l)):F(oe(l))?Ut(t,s,n,l):l,Ct=(e,t)=>xe(t?e:vt(e),(t,s)=>Q(Rt(s,t),t=>(e[s]=t,!0),()=>!1),()=>qt()),Rt=(e,s)=>t?Q(ze(P,e),t=>oe(s)!=t[a]?qt(e,s,t[r]):s,()=>qt(e,s)):F(oe(s))?qt(e,s):s,Tt=(e,t,s)=>(Q(ze(N,t),([n,l])=>{Le(n,(t,s)=>{Me(e,s)||(e[s]=t)}),Le(l,n=>{Me(e,n)||Ut(t,s,n)})}),e),vt=e=>(t&&(Le(j,(t,s)=>{Me(e,s)||(e[s]=t)}),Le(_,t=>{Me(e,t)||qt(t)})),e),pt=e=>Ae(x,e,(e,t,s)=>{const n=Fe(),l=Ke();Ae(We(x,t,Fe),s,(e,t,s)=>{Oe(e,t,s),Q(s[r],e=>Oe(n,t,e),()=>Xe(l,t))}),Oe(N,t,[n,l])},(e,t)=>{Oe(x,t),Oe(N,t)}),St=e=>Ae(P,e,(e,t,s)=>{Oe(P,t,s),Q(s[r],e=>Oe(j,t,e),()=>Xe(_,t))},(e,t)=>{Oe(P,t),Oe(j,t),Ce(_,t)}),yt=e=>He(e)?Js():Ms(e),Vt=e=>Ae($,e,(e,t,s)=>mt(t,s),(e,t)=>Qt(t)),mt=(e,t)=>Ae(We($,e,()=>(Wt(e,1),Oe(q,e,tt()),Oe(K,e,Fe()),Fe())),t,(t,s,n)=>Mt(e,t,s,n),(t,s)=>zt(e,t,s)),Mt=(e,t,s,n,l)=>Ae(We(t,s,()=>(At(e,s,1),Fe())),n,(t,n,l)=>Et(e,s,t,n,l),(n,o)=>Nt(e,t,s,n,o,l)),Et=(e,t,s,n,l)=>{fe(s,n)||Pt(e,t,n,1);const o=ze(s,n);l!==o&&(jt(e,t,n,o,l),Oe(s,n,l))},kt=(e,t,s,n,l)=>Q(ze(t,s),t=>Et(e,s,t,n,l),()=>Mt(e,t,s,Tt({[n]:l},e,s))),Dt=e=>He(e)?Qs():Es(e),Ht=e=>Ae(ee,e,(e,t,s)=>xt(t,s),(e,t)=>Ot(t)),xt=(e,t)=>{fe(ee,e)||_t(e,1);const s=ze(ee,e);t!==s&&(Bt(e,s,t),Oe(ee,e,t))},Ft=e=>ze($,e)??mt(e,{}),Qt=e=>mt(e,{}),zt=(e,t,s)=>{const[,n]=ze(q,e);n(s),Mt(e,t,s,{},!0)},Nt=(e,t,s,n,l,o)=>{const a=ze(ze(N,e)?.[0],l);if(!F(a)&&!o)return Et(e,s,n,l,a);const r=t=>{jt(e,s,t,ze(n,t)),Pt(e,s,t,-1),Oe(n,t)};F(a)?r(l):Ne(n,r),Ie(n)&&(At(e,s,-1),Ie(Oe(t,s))&&(Wt(e,-1),Oe($,e),Oe(q,e),Oe(K,e)))},Ot=e=>{const t=ze(j,e);if(!F(t))return xt(e,t);Bt(e,ze(ee,e)),_t(e,-1),Oe(ee,e)},Wt=(e,t)=>$t(g,e,t),At=(e,t,s)=>$t(We(m,e,Fe),t,s)&&Oe(V,e,We(V,e,()=>0)+s),Pt=(e,t,s,n)=>{const l=ze(K,e),o=ze(l,s)??0;(0==o&&1==n||1==o&&-1==n)&&$t(We(C,e,Fe),s,n),Oe(l,s,o!=-n?o+n:null),$t(We(We(M,e,Fe),t,Fe),s,n)},jt=(e,t,s,n,l)=>{We(We(We(E,e,Fe),t,Fe),s,()=>[n,0])[1]=l,d[3]?.(e,t,s,l)},_t=(e,t)=>$t(k,e,t),Bt=(e,t,s)=>{We(D,e,()=>[t,0])[1]=s,d[4]?.(e,s)},Ut=(e,t,s,n,l)=>(se(We(We(We(H,e,Fe),t,Fe),s,()=>[]),n),l),qt=(e,t,s)=>(se(We(J,e,()=>[]),t),s),ts=(e,t,s)=>Q(ze(ze(ze(E,e),t),s),([e,t])=>[!0,e,t],()=>[!1,...Gt(ws(e,t,s))]),ss=e=>Q(ze(D,e),([e,t])=>[!0,e,t],()=>[!1,...Gt(Rs(e))]),ns=e=>Ie(H)||Ie(Ye[e])?0:Le(e?qe(H):H,(t,s)=>Le(t,(t,n)=>Le(t,(t,l)=>dt(Ye[e],[s,n,l],t)))),ls=e=>Ie(J)||Ie(Ze[e])?0:Le(e?Be(J):J,(t,s)=>dt(Ze[e],[s],t)),os=(e,t,s,n)=>{if(!Ie(e))return dt(t,n,()=>Pe(e)),Ne(e,(e,t)=>dt(s,[...n??[],e],1==t)),1},as=e=>{const t=Ts();t!=s&&dt(te[e],void 0,t);const n=Ie(pe[e]),l=Ie(ke[e])&&Ie(Je[e])&&Ie(ve[e])&&Ie(ye[e])&&Ie(be[e])&&Ie(Re[e])&&Ie(Te[e])&&n&&Ie(le[e])&&Ie(ae[e]),o=Ie(Ge[e])&&Ie(me[e])&&Ie(de[e])&&Ie(ne[e]);if(!l||!o){const t=e?[Be(g),Ue(C),Be(V),Ue(m),qe(M),qe(E)]:[g,C,V,m,M,E];if(!l){os(t[0],le[e],ae[e]),Le(t[1],(t,s)=>os(t,be[e],Re[e],[s])),Le(t[2],(t,s)=>{0!=t&&dt(Te[e],[s],hs(s))});const s=Ke();Le(t[3],(t,l)=>{os(t,ve[e],ye[e],[l])&&!n&&(dt(pe[e],[l,null]),Xe(s,l))}),n||Le(t[5],(t,n)=>{if(!fe(s,n)){const s=Ke();Le(t,e=>Le(e,([t,n],l)=>n!==t?Xe(s,l):Ce(e,l))),Le(s,t=>dt(pe[e],[n,t]))}}),Le(t[4],(t,s)=>Le(t,(t,n)=>os(t,ke[e],Je[e],[s,n])))}if(!o){let s;Le(t[5],(t,n)=>{let l;Le(t,(t,o)=>{let a;Le(t,([t,r],i)=>{r!==t&&(dt(Ge[e],[n,o,i],r,t,ts),s=l=a=1)}),a&&dt(me[e],[n,o],ts)}),l&&dt(de[e],[n],ts)}),s&&dt(ne[e],void 0,ts)}}},rs=e=>{const t=Vs();t!=n&&dt($e[e],void 0,t);const s=Ie(nt[e])&&Ie(lt[e]),l=Ie(ot[e])&&Ie(et[e]);if(!s||!l){const t=e?[Be(k),Be(D)]:[k,D];if(s||os(t[0],nt[e],lt[e]),!l){let s;Le(t[1],([t,n],l)=>{n!==t&&(dt(ot[e],[l],n,t,ss),s=1)}),s&&dt(et[e],void 0,ss)}}},is=(e,...t)=>(Os(()=>e(...Z(t,y))),Ps),ds=(e,t,s,n,l)=>{let o=Is(e,t,...s);return it(()=>{const l=Is(e,t,...s);G(l,o)||(o=l,n(Ps,e,t,...s,o))},pe[l?1:0],[e,t],[us])},cs=()=>_e($),us=()=>Qe($),gs=e=>Qe(ze(K,y(e))),hs=e=>ce(ze($,y(e))),fs=e=>Qe(ze($,y(e))),Is=(e,t,s,n=0,l)=>{return Se(e)?Is(e.tableId,e.cellId,e.descending,e.offset,e.limit):Z(A(X((o=ze($,y(e)),a=(e,s)=>[F(t)?s:ze(e,y(t)),s],Z([...o?.entries()??[]],([e,t])=>a(t,e))),([e],[t])=>Jt(e,t)*(s?-1:1)),n,F(l)?l:n+l),([,e])=>e);var o,a},bs=(e,t)=>Qe(ze(ze($,y(e)),y(t))),ws=(e,t,s)=>ze(ze(ze($,y(e)),y(t)),y(s)),Ls=()=>Pe(ee),Cs=()=>Qe(ee),Rs=e=>ze(ee,y(e)),Ts=()=>!Ie($),vs=e=>fe($,y(e)),ps=(e,t)=>fe(ze(K,y(e)),y(t)),Ss=(e,t)=>fe(ze($,y(e)),y(t)),ys=(e,t,s)=>fe(ze(ze($,y(e)),y(t)),y(s)),Vs=()=>!Ie(ee),ms=e=>fe(ee,y(e)),Ms=e=>is(()=>(e=>xe(e,bt,Ut))(e)?Vt(e):0),Es=e=>is(()=>Ct(e)?Ht(e):0),ks=e=>(B(()=>yt(ut(e))),Ps),Ds=t=>is(()=>{if((e=xe(t,e=>xe(e,ft)))&&(pt(t),!Ie($))){const e=cs();Js(),Ms(e)}}),Hs=e=>is(()=>{if(t=(e=>xe(e,ft))(e)){const s=Ls();Ns(),Qs(),t=!0,St(e),Es(s)}}),Js=()=>is(()=>Vt({})),xs=e=>is(e=>fe($,e)?Qt(e):0,e),Fs=(e,t)=>is((e,t)=>Q(ze($,e),s=>fe(s,t)?zt(e,s,t):0),e,t),Qs=()=>is(()=>Ht({})),zs=()=>is(()=>{pt({}),e=!1}),Ns=()=>is(()=>{St({}),t=!1}),Os=(e,t)=>{if(-1!=o){Ws();const s=e();return As(t),s}},Ws=()=>(-1!=o&&o++,1==o&&(d[0]?.(),dt(at)),Ps),As=e=>(o>0&&(o--,0==o&&(o=1,ns(1),Ie(E)||as(1),ls(1),Ie(D)||rs(1),e?.(Ps)&&(Le(E,(e,t)=>Le(e,(e,s)=>Le(e,([e],n)=>re(Ps,t,s,n,e)))),we(E),Le(D,([e],t)=>ie(Ps,t,e)),we(D)),dt(rt[0],void 0),o=-1,ns(0),Ie(E)||as(0),ls(0),Ie(D)||rs(0),d[1]?.(),dt(rt[1],void 0),d[2]?.(),o=0,s=Ts(),n=Vs(),Y([g,C,V,m,M,E,H,k,D,J],we))),Ps),Ps={getContent:()=>[cs(),Ls()],getTables:cs,getTableIds:us,getTable:e=>je(ze($,y(e))),getTableCellIds:gs,getRowCount:hs,getRowIds:fs,getSortedRowIds:Is,getRow:(e,t)=>Pe(ze(ze($,y(e)),y(t))),getCellIds:bs,getCell:ws,getValues:Ls,getValueIds:Cs,getValue:Rs,hasTables:Ts,hasTable:vs,hasTableCell:ps,hasRow:Ss,hasCell:ys,hasValues:Vs,hasValue:ms,getTablesJson:()=>gt($),getValuesJson:()=>gt(ee),getJson:()=>gt([$,ee]),getTablesSchemaJson:()=>gt(x),getValuesSchemaJson:()=>gt(P),getSchemaJson:()=>gt([x,P]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>is(()=>{const t=O(e)?e():e;It(t)&&(([e,t])=>{(He(e)?Js:Ms)(e),(He(t)?Qs:Es)(t)})(t)}),setTables:Ms,setTable:(e,t)=>is(e=>bt(t,e)?mt(e,t):0,e),setRow:(e,t,s)=>is((e,t)=>wt(e,t,s)?Mt(e,Ft(e),t,s):0,e,t),addRow:(e,t,s=!0)=>Os(()=>{let n;return wt(e,n,t)&&(e=y(e),Mt(e,Ft(e),n=((e,t)=>{const[s]=ze(q,e);let n;do{n=s(t)}while(fe(ze($,e),n));return n})(e,s?1:0),t)),n}),setPartialRow:(e,t,s)=>is((e,t)=>{if(wt(e,t,s,1)){const n=Ft(e);De(s,(s,l)=>kt(e,n,t,l,s))}},e,t),setCell:(e,t,s,n)=>is((e,t,s)=>Q(Lt(e,t,s,O(n)?n(ws(e,t,s)):n),n=>kt(e,Ft(e),t,s,n)),e,t,s),setValues:Es,setPartialValues:e=>is(()=>Ct(e,1)?De(e,(e,t)=>xt(t,e)):0),setValue:(e,t)=>is(e=>Q(Rt(e,O(t)?t(Rs(e)):t),t=>xt(e,t)),e),applyChanges:e=>is(()=>{De(e[0],(e,t)=>F(e)?xs(t):De(e,(e,s)=>F(e)?Fs(t,s):De(e,(e,n)=>re(Ps,t,s,n,e)))),De(e[1],(e,t)=>ie(Ps,t,e))}),setTablesJson:ks,setValuesJson:e=>(B(()=>Dt(ut(e))),Ps),setJson:e=>is(()=>B(()=>{const[t,s]=ut(e);yt(t),Dt(s)},()=>ks(e))),setTablesSchema:Ds,setValuesSchema:Hs,setSchema:(e,t)=>is(()=>{Ds(e),Hs(t)}),delTables:Js,delTable:xs,delRow:Fs,delCell:(e,t,s,n)=>is((e,t,s)=>Q(ze($,e),l=>Q(ze(l,t),o=>fe(o,s)?Nt(e,l,t,o,s,n):0)),e,t,s),delValues:Qs,delValue:e=>is(e=>fe(ee,e)?Ot(e):0,e),delTablesSchema:zs,delValuesSchema:Ns,delSchema:()=>is(()=>{zs(),Ns()}),transaction:Os,startTransaction:Ws,getTransactionChanges:()=>[Pe(E,(e,t)=>-1===ze(g,t)?void 0:Pe(e,(e,s)=>-1===ze(ze(m,t),s)?void 0:Pe(e,([,e])=>e,e=>Zt(e)),Ie,He),Ie,He),Pe(D,([,e])=>e,e=>Zt(e)),1],getTransactionLog:()=>[!Ie(E),!Ie(D),_e(E,Yt,Zt),_e(H),Pe(D,Yt,Zt),Pe(J),Pe(g),je(m),_e(M),Pe(k)],finishTransaction:As,forEachTable:e=>Le($,(t,s)=>e(s,e=>Le(t,(t,s)=>e(s,e=>Ne(t,e))))),forEachTableCell:(e,t)=>Ne(ze(K,y(e)),t),forEachRow:(e,t)=>Le(ze($,y(e)),(e,s)=>t(s,t=>Ne(e,t))),forEachCell:(e,t,s)=>Ne(ze(ze($,y(e)),y(t)),s),forEachValue:e=>Ne(ee,e),addSortedRowIdsListener:(e,t,s,n,l,o,a)=>Se(e)?ds(e.tableId,e.cellId,[e.descending??!1,e.offset??0,e.limit],t,s):ds(e,t,[s,n,l],o,a),addStartTransactionListener:e=>it(e,at),addWillFinishTransactionListener:e=>it(e,rt[0]),addDidFinishTransactionListener:e=>it(e,rt[1]),callListener:e=>(ht(e),Ps),delListener:e=>(ct(e),Ps),getListenerStats:()=>({hasTables:Kt(te),tables:Kt(ne),tableIds:Kt(le),hasTable:Kt(ae),table:Kt(de),tableCellIds:Kt(be),hasTableCell:Kt(Re,ge),rowCount:Kt(Te),rowIds:Kt(ve),sortedRowIds:Kt(pe),hasRow:Kt(ye,ge),row:Kt(me,ge),cellIds:Kt(ke,ge),hasCell:Kt(Je,he),cell:Kt(Ge,he),invalidCell:Kt(Ye,he),hasValues:Kt($e),values:Kt(et),valueIds:Kt(nt),hasValue:Kt(lt),value:Kt(ot),invalidValue:Kt(Ze),transaction:ue(at)+Kt(rt)}),isMergeable:()=>!1,createStore:es,addListener:it,callListeners:dt,setInternalListeners:(e,t,s,n,l)=>d=[e,t,s,n,l]};return De({[u+f]:[0,te,[],()=>[Ts()]],[f]:[0,ne],[I]:[0,le],[u+h]:[1,ae,[us],e=>[vs(...e)]],[h]:[1,de,[us]],[h+T]:[1,be,[us]],[u+h+R]:[2,Re,[us,gs],e=>[ps(...e)]],[w]:[1,Te,[us]],[L]:[1,ve,[us]],[u+b]:[2,ye,[us,fs],e=>[Ss(...e)]],[b]:[2,me,[us,fs]],[T]:[2,ke,[us,fs]],[u+R]:[3,Je,[us,fs,bs],e=>[ys(...e)]],[R]:[3,Ge,[us,fs,bs],e=>Gt(ws(...e))],InvalidCell:[3,Ye],[u+p]:[0,$e,[],()=>[Vs()]],[p]:[0,et],[S]:[0,nt],[u+v]:[1,lt,[Cs],e=>[ms(...e)]],[v]:[1,ot,[Cs],e=>Gt(Rs(e[0]))],InvalidValue:[1,Ze]},([e,t,s,n],l)=>{Ps[c+l+i]=(...l)=>it(l[e],t[l[e+1]?1:0],e>0?A(l,0,e):void 0,s,n)}),Ve(Ps)},ts={HasTable:1,Table:1,TableCellIds:1,HasTableCell:2,RowCount:1,RowIds:1,SortedRowIds:5,HasRow:2,Row:2,CellIds:2,HasCell:3,Cell:3,HasValue:1,Value:1,InvalidCell:3,InvalidValue:1},ss=(e=t)=>[_t(e),_t(e)],ns=(e,s)=>{let n=1,l=ss(),o=0;const a=Fe(),r=Ke(),[d,u]=Ht(e,s),g=es(),h=e=>{const t=n;return n=0,e(),n=t,R},f=(e,s=0)=>{const n={},o={},[[a,r=t,i=0],d]=e,[c,g]=l,[h,f,b]=c;let w=s?i:b,L=r;ke(a,([e,l=t,o=0],a)=>{const r=We(h,a,_t),[i,d,c]=r;let u=s?o:c,g=l;ke(e,(e,t)=>{const[l,o,r]=I(e,We(i,t,_t),Je(Je(n,a,me),t,me),s);u^=s?0:It(o?wt(t,o):0,wt(t,r)),g=At(g,l)}),u^=s?0:Wt(d,l),Pt(r,l,u),w^=s?0:It(c?wt(a,c):0,wt(a,r[2])),L=At(L,g)}),w^=s?0:Wt(f,r),Pt(c,r,w);const[C]=I(d,g,o,s);return u(At(L,C)),[n,o,1]},I=(e,s,n,l)=>{const[o,a=t,r=0]=e,[i,d,c]=s;let u=a,g=l?r:c;return ke(o,([e,s=t,o=0],a)=>{const r=We(i,a,()=>[void 0,t,0]),[,d,c]=r;(!d||s>d)&&(Pt(r,s,l?o:Lt(e,s)),r[0]=e,n[a]=e,g^=l?0:It(wt(a,c),wt(a,r[2])),u=At(u,s))}),g^=l?0:Wt(d,a),Pt(s,a,g),[u,c,s[2]]},b=_,w=_,L=()=>[Bt(l[0],e=>Bt(e,e=>Bt(e))),Bt(l[1])],C=e=>h(()=>g.applyChanges(f(e))),R={getMergeableContent:L,getMergeableContentHashes:()=>[l[0][2],l[1][2]],getMergeableTableHashes:()=>Pe(l[0][0],Ot),getMergeableTableDiff:e=>{const t=jt(l[0][1]),s={};return Ne(l[0][0],(n,[l,o,a])=>Me(e,n)?a!=e[n]?s[n]=a:0:t[0][n]=Ut([l,o],e=>Ut(e))),[t,s]},getMergeableRowHashes:e=>{const t={};return ke(e,(e,s)=>Q(ze(l[0][0],s),([n,,l])=>l!=e?Ne(n,(e,[,,n])=>Je(t,s,me)[e]=n):0)),t},getMergeableRowDiff:e=>{const t=jt(l[0][1]),s={};return ke(e,(e,n)=>Ne(ze(l[0][0],n)?.[0],(l,[o,a,r])=>Me(e,l)?r!==e[l]?Je(s,n,me)[l]=r:0:Je(t[0],n,jt)[0][l]=Ut([o,a]))),[t,s]},getMergeableCellHashes:e=>{const t={};return ke(e,(e,s)=>Q(ze(l[0][0],s),([n])=>ke(e,(e,l)=>Q(ze(n,l),([n,,o])=>o!==e?Ne(n,(e,[,,n])=>Je(Je(t,s,me),l,me)[e]=n):0)))),t},getMergeableCellDiff:e=>{const[[t,s]]=l,n={};return ke(e,(e,s)=>ke(e,(e,l)=>Q(ze(t,s),([t,o])=>Q(ze(t,l),([t,a])=>Ne(t,(t,[r,i,d])=>d!==e[t]?Je(Je(n,s,()=>jt(o))[0],l,()=>jt(a))[0][t]=[r,i]:0))))),zt(n,s)},getMergeableValueHashes:()=>Pe(l[1][0],Ot),getMergeableValueDiff:e=>{const[,[t,s]]=l,n=Pe(t,Ft,([,,t],s)=>t==e?.[s]);return zt(n,s)},setMergeableContent:e=>h(()=>(e=>W(e)&&2==P(e)&&qt(e[0],e=>xe(e,e=>qt(e,e=>xe(e,e=>qt(e,e=>xe(e,e=>qt(e,ae),void 0,1)),void 0,1)),void 0,1))&&qt(e[1],e=>xe(e,e=>qt(e,ae),void 0,1)))(e)?g.transaction(()=>{g.delTables().delValues(),l=ss(),g.applyChanges(f(e,1))}):0),setDefaultContent:e=>(g.transaction(()=>{o=1,g.setContent(e),o=0}),R),getTransactionMergeableChanges:(e=!1)=>{const[[t,s,n],[o,i,d]]=l,c=e?Nt:zt,u={};Le(a,(e,s)=>Q(ze(t,s),([t,n,l])=>{const o={};Le(e,(e,s)=>Q(ze(t,s),([t,n,l])=>{const a={};Le(e,e=>{Q(ze(t,e),([t,s,n])=>a[e]=c(t,s,n))}),o[s]=c(a,n,l)})),u[s]=c(o,n,l)}));const g={};return Le(r,e=>Q(ze(o,e),([t,s,n])=>g[e]=c(t,s,n))),[c(u,s,n),c(g,i,d),1]},applyMergeableChanges:C,merge:e=>{const t=L(),s=e.getMergeableContent();return e.applyMergeableChanges(t),C(s)}};return g.setInternalListeners(b,w,()=>{we(a),we(r)},(e,s,l,r)=>{Xe(We(We(a,e,Fe),s,Ke),l),n&&f([[{[e]:[{[s]:[{[l]:[r,o?t:d()]}]}]}],[{}],1])},(e,s)=>{Xe(r,e),n&&f([[{}],[{[e]:[s,o?t:d()]}],1])}),De(g,(e,t)=>R[t]=V(t,"set")||V(t,"del")||V(t,"apply")||m(t,"Transaction")||t=="call"+i?(...t)=>(e(...t),R):V(t,c)&&m(t,i)?(...s)=>{const n=ts[A(t,3,-8)]??0,l=s[n];return s[n]=(e,...t)=>l(R,...t),e(...s)}:"isMergeable"==t?()=>!0:e),Ve(R)},ls=Fe([["avg",[(e,t)=>$(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>D(...e),(e,t)=>D(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:D(t,e)]],["min",[e=>H(...e),(e,t)=>H(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:H(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),os=(e,t,s,n,l,o=!1)=>{if(Ie(s))return;const[a,r,i,d]=l;return o||=F(e),Le(n,([s,n])=>{o||(e=F(s)?r?.(e,n,t++):F(n)?i?.(e,s,t--):d?.(e,n,s,t),o||=F(e))}),o?a(be(s),ce(s)):e},as=$e(e=>{const s=Fe(),[n,l,o]=st(()=>w),[a,r,i,d,c,u,g,,h,f,I,b]=Ye(e,j,e=>isNaN(e)||F(e)||!0===e||!1===e||e===t?void 0:1*e,n,l),w={setMetricDefinition:(e,t,n,o,a,r,i)=>{const d=O(n)?[n,a,r,i]:ze(ls,n)??ze(ls,"sum");return h(e,t,(t,n,o,a,r,i)=>{const c=u(e),h=ce(a);i||=F(c),t();let f=os(c,h,a,n,d,i);x(f)||(f=void 0),f!=c&&(g(e,f),l(s,[e],f,c))},Ze(o,1)),w},delMetricDefinition:e=>(f(e),w),getStore:a,getMetricIds:r,forEachMetric:i,hasMetric:d,getTableId:c,getMetric:u,addMetricIdsListener:I,addMetricListener:(e,t)=>n(t,s,[e]),delListener:e=>(o(e),w),destroy:b,getListenerStats:()=>({metric:ue(s)})};return Ve(w)}),rs=$e(e=>{const s=e.createStore,n=s(),l=s(),o=Fe(),{addListener:a,callListeners:r,delListener:u}=l,[g,f,I,v,p,,,S,,y,V,m,M,E]=Ye(e,()=>!0,j,a,r),k=(e,t,...s)=>Y(s,s=>Xe(We(We(o,t,Fe),e,Ke),s)),D=e=>{Q(ze(o,e),e=>{Ne(e,(e,t)=>Le(t,t=>e.delListener(t))),we(e)}),Y([l,n],t=>t.delTable(e))},H=(e,t,s)=>k(t,e,t.addStartTransactionListener(s.startTransaction),t.addDidFinishTransactionListener(()=>s.finishTransaction())),J={setQueryDefinition:(s,o,a)=>{S(s,o),D(s);const r=[],i=[[null,[o,null,null,[],Fe()]]],d=[],c=[],u=[];a({select:(e,s)=>{const n=O(e)?[P(r)+t,e]:[F(s)?e:s,t=>t(e,s)];return se(r,n),{as:e=>n[0]=e}},join:(e,t,s)=>{const n=F(s)||O(t)?null:t,l=F(n)?t:s,o=[e,[e,n,O(l)?l:e=>e(l),[],Fe()]];return se(i,o),{as:e=>o[0]=e}},where:(e,t,s)=>se(d,O(e)?e:F(s)?s=>s(e)===t:n=>n(e,t)===s),group:(e,t,s,n,l)=>{const o=[e,[e,O(t)?[t,s,n,l]:ze(ls,t)??[(e,t)=>t]]];return se(c,o),{as:e=>o[0]=e}},having:(e,t)=>se(u,O(e)?e:s=>s(e)===t)});const g=Fe(r);if(Ie(g))return J;const h=Fe(i);Ne(h,(e,[,t])=>Q(ze(h,t),({3:t})=>F(e)?0:se(t,e)));const f=Fe(c);let I=n;if(Ie(f)&&ee(u))I=l;else{H(s,I,l);const e=Fe();Ne(f,(t,[s,n])=>Xe(We(e,s,Ke),[t,n]));const t=Ke();Ne(g,s=>fe(e,s)?0:Xe(t,s));const n=Fe(),o=(t,n,o,a)=>Q(t,([r,i,d,c])=>{Ne(n,(t,[s])=>{const n=We(r,t,Fe),l=ze(n,o),i=a?void 0:s;if(l!==i){const s=Ke([[l,i]]),a=ce(n);Oe(n,o,i),Le(ze(e,t),([e,t])=>{const l=os(c[e],a,n,s,t);c[e]=F(oe(l))?null:l})}}),Ie(i)||!q(u,e=>e(e=>c[e]))?l.delRow(s,d):F(d)?t[2]=l.addRow(s,c):l.setRow(s,d,c)});k(I,s,I.addRowListener(s,null,(l,a,r,i)=>{const d=[],c=[],u=Fe(),g=I.hasRow(s,r);let h=!g;Le(t,e=>{const[t,n,l]=i(s,r,e);se(d,n),se(c,l),h||=t}),Ne(e,e=>{const[t,,n]=i(s,r,e);(h||t)&&Oe(u,e,[n])}),h&&o(Ge(n,d,void 0,([,e])=>(Ce(e,r),Ie(e))),u,r,1),g&&o(Ge(n,c,()=>{const e={};return Le(t,t=>e[t]=I.getCell(s,r,t)),[Fe(),Ke(),void 0,e]},([,e])=>{Xe(e,r)}),u,r)}))}H(s,e,I);const b=(t,n,l,a)=>{const r=t=>e.getCell(n,l,t);Y(a,n=>{const[l,,o,a,i]=ze(h,n),d=o?.(r,t),[c,u]=ze(i,t)??[];d!=c&&(F(u)||E(s,u),Oe(i,t,F(d)?null:[d,...M(s,1,e.addRowListener(l,d,()=>b(t,l,d,a)))]))}),(t=>{const n=(s,n)=>e.getCell(...F(n)?[o,t,s]:s===o?[o,t,n]:[ze(h,s)?.[0],ze(ze(h,s)?.[4],t)?.[0],n]);I.transaction(()=>q(d,e=>e(n))?Ne(g,(e,l)=>re(I,s,t,e,l(n,t))):I.delRow(s,t))})(t)},{3:w}=ze(h,null);return I.transaction(()=>M(s,1,e.addRowListener(o,null,(t,n,l)=>{e.hasRow(o,l)?b(l,o,l,w):(I.delRow(s,l),Le(h,({4:e})=>Q(ze(e,l),([,t])=>{E(s,t),Oe(e,l)})))}))),J},delQueryDefinition:e=>(D(e),y(e),J),getStore:g,getQueryIds:f,forEachQuery:I,hasQuery:v,getTableId:p,addQueryIdsListener:e=>V(()=>e(J)),delListener:e=>(u(e),J),destroy:m,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:s,...n}=l.getListenerStats();return n}};return De({[h]:[1,1],[h+T]:[0,1],[w]:[0,1],[L]:[0,1],[C]:[0,5],[b]:[1,2],[T]:[0,2],[R]:[1,3]},([e,t],s)=>{Y(e?["get","has","forEach"]:["get"],e=>J[e+d+s]=(...t)=>l[e+s](...t)),J[c+d+s+i]=(...e)=>l[c+s+i](...A(e,0,t),(s,...n)=>e[t](J,...n),!0)}),Ve(J)}),is=$e(e=>{const s=Fe(),n=Fe(),l=Fe(),o=Fe(),[a,r,i]=st(()=>v),[d,c,u,g,h,f,,,I,b,w,L]=Ye(e,()=>[Fe(),Fe(),Fe(),Fe()],e=>F(e)?void 0:e+t,a,r),C=(e,t,s)=>Q(f(e),([n,,l])=>{if(!fe(l,t)){const o=Ke();if(h(e)!=T(e))Xe(o,t);else{let e=t;for(;!F(e)&&!fe(o,e);)Xe(o,e),e=ze(n,e)}if(s)return o;Oe(l,t,o)}return ze(l,t)}),R=(e,t)=>Q(f(e),([,,e])=>Oe(e,t)),T=e=>ze(s,e),v={setRelationshipDefinition:(e,t,a,i)=>(Oe(s,e,a),I(e,t,(t,s)=>{const a=Ke(),i=Ke(),d=Ke(),[c,u]=f(e);Le(s,([t,s],n)=>{F(t)||(Xe(i,t),Q(ze(u,t),e=>{Ce(e,n),Ie(e)&&Oe(u,t)})),F(s)||(Xe(i,s),fe(u,s)||Oe(u,s,Ke()),Xe(ze(u,s),n)),Xe(a,n),Oe(c,n,s),Ne(ze(o,e),t=>{fe(C(e,t),n)&&Xe(d,t)})}),t(),Le(a,t=>r(n,[e,t])),Le(i,t=>r(l,[e,t])),Le(d,t=>{R(e,t),r(o,[e,t])})},Ze(i)),v),delRelationshipDefinition:e=>(Oe(s,e),b(e),v),getStore:d,getRelationshipIds:c,forEachRelationship:t=>u(s=>t(s,t=>e.forEachRow(h(s),t))),hasRelationship:g,getLocalTableId:h,getRemoteTableId:T,getRemoteRowId:(e,t)=>ze(f(e)?.[0],t),getLocalRowIds:(e,t)=>be(ze(f(e)?.[1],t)),getLinkedRowIds:(e,t)=>F(f(e))?[t]:be(C(e,t,!0)),addRelationshipIdsListener:w,addRemoteRowIdListener:(e,t,s)=>a(s,n,[e,t]),addLocalRowIdsListener:(e,t,s)=>a(s,l,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(C(e,t),a(s,o,[e,t])),delListener:e=>(R(...i(e)??[]),v),destroy:L,getListenerStats:()=>({remoteRowId:ge(n),localRowIds:ge(l),linkedRowIds:ge(o)})};return Ve(v)});export{It as addOrRemoveHash,nt as createCheckpoints,xt as createIndexes,ns as createMergeableStore,as as createMetrics,rs as createQueries,is as createRelationships,es as createStore,Jt as defaultSorter,Ct as getCellHash,Rt as getCellInRowHash,ft as getHash,Ht as getHlcFunctions,Tt as getRowHash,vt as getRowInTableHash,pt as getTableHash,St as getTableInTablesHash,yt as getTablesHash,dt as getUniqueId,Lt as getValueHash,wt as getValueInValuesHash,bt as getValuesHash};
1
+ const e=e=>typeof e,t="",s=e(t),n=e(!0),l=e(0),o=e(e),a="type",r="default",i="Listener",d="Result",c="add",u="Has",g="Ids",h="Table",f=h+"s",I=h+g,b="Row",w=b+"Count",L=b+g,C="Sorted"+b+g,R="Cell",T=R+g,v="Value",p=v+"s",S=v+g,y=e=>t+e,V=(e,t)=>e.startsWith(t),m=(e,t)=>e.endsWith(t),M=(e,s=t,n)=>e.split(s,n),E=globalThis,k=Math,D=k.max,H=k.min,J=k.floor,x=isFinite,F=e=>null==e,Q=(e,t,s)=>F(e)?s?.():t(e),z=e=>e==s||e==n,N=t=>e(t)==s,O=t=>e(t)==o,W=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),P=e=>e.length,j=()=>{},_=()=>{},B=async(e,t,s)=>{try{return await e()}catch(e){t?.(e)}},U=(e,t)=>e.includes(t),q=(e,t)=>e.every(t),G=(e,t)=>P(e)===P(t)&&q(e,(e,s)=>t[s]===e),K=(e,t)=>q(e,(s,n)=>0==n||t(e[n-1],s)<=0),X=(e,t)=>e.sort(t),Y=(e,t)=>e.forEach(t),Z=(e,t)=>e.map(t),$=e=>te(e,(e,t)=>e+t,0),ee=e=>0==P(e),te=(e,t,s)=>e.reduce(t,s),se=(e,...t)=>e.push(...t),ne=e=>e.pop(),le=e=>e.shift(),oe=t=>{const s=e(t);return z(s)||s==l&&x(t)?s:void 0},ae=e=>F(e)||!F(oe(e)),re=(e,t,s,n,l)=>F(l)?e.delCell(t,s,n,!0):e.setCell(t,s,n,l),ie=(e,t,s)=>F(s)?e.delValue(t):e.setValue(t,s),de=e=>t=>te(be(t),(t,s)=>t+e(s),0),ce=e=>e?.size??0,ue=de(ce),ge=de(ue),he=de(ge),fe=(e,t)=>e?.has(t)??!1,Ie=e=>F(e)||0==ce(e),be=e=>[...e?.values()??[]],we=e=>e.clear(),Le=(e,t)=>e?.forEach(t),Ce=(e,t)=>e?.delete(t),Re=Object,Te=e=>Re.getPrototypeOf(e),ve=Re.isFrozen,pe=Re.entries,Se=e=>!F(e)&&Q(Te(e),e=>e==Re.prototype||F(Te(e)),()=>!0),ye=Re.keys,Ve=Re.freeze,me=(e=[])=>Re.fromEntries(e),Me=(e,t)=>t in e,Ee=(e,t)=>(delete e[t],e),ke=(e,t)=>Y(pe(e),([e,s])=>t(s,e)),De=(e,t)=>me(((e,t)=>Z(pe(e),([e,s])=>t(s,e)))(e,(e,s)=>[s,t(e,s)])),He=e=>Se(e)&&0==(e=>P(ye(e)))(e),Je=(e,t,s)=>(Me(e,t)||(e[t]=s()),e[t]),xe=(e,t,s,n=0)=>F(e)||!Se(e)||!n&&He(e)||ve(e)?(s?.(),!1):(ke(e,(s,n)=>{t(s,n)||Ee(e,n)}),!!n||!He(e)),Fe=e=>new Map(e),Qe=e=>[...e?.keys()??[]],ze=(e,t)=>e?.get(t),Ne=(e,t)=>Le(e,(e,s)=>t(s,e)),Oe=(e,t,s)=>F(s)?(Ce(e,t),e):e?.set(t,s),We=(e,t,s,n)=>(fe(e,t)?n?.(ze(e,t)):Oe(e,t,s()),ze(e,t)),Ae=(e,t,s,n=Oe)=>(De(t,(t,n)=>s(e,n,t)),Ne(e,s=>Me(t,s)?0:n(e,s)),e),Pe=(e,t,s,n)=>{const l={};return Le(e,(e,o)=>{if(!s?.(e,o)){const s=t?t(e,o):e;n?.(s)||(l[o]=s)}}),l},je=(e,t,s)=>Pe(e,e=>Pe(e,t,s),Ie,He),_e=(e,t,s)=>Pe(e,e=>je(e,t,s),Ie,He),Be=(e,t)=>{const s=Fe();return Le(e,(e,n)=>s.set(n,t?.(e)??e)),s},Ue=e=>Be(e,Be),qe=e=>Be(e,Ue),Ge=(e,t,s,n,l=0)=>Q((s?We:ze)(e,t[l],l>P(t)-2?s:Fe),o=>{if(l>P(t)-2)return n?.(o)&&Oe(e,t[l]),o;const a=Ge(o,t,s,n,l+1);return Ie(o)&&Oe(e,t[l]),a}),Ke=e=>new Set(W(e)||F(e)?e:[e]),Xe=(e,t)=>e?.add(t),Ye=(e,t,s,n,l)=>{const o=e.hasRow,a=Fe(),r=Fe(),i=Fe(),d=Fe(),c=Fe(),u=Fe(),g=(t,s,...n)=>{const l=We(u,t,Ke);return Y(n,t=>Xe(l,t)&&s&&e.callListener(t)),n},h=(t,...s)=>Q(ze(u,t),n=>{Y(ee(s)?be(n):s,t=>{e.delListener(t),Ce(n,t)}),Ie(n)&&Oe(u,t)}),f=(e,s)=>{Oe(a,e,s),fe(r,e)||(Oe(r,e,t()),Oe(d,e,Fe()),Oe(c,e,Fe()),l(i))},I=e=>{Oe(a,e),Oe(r,e),Oe(d,e),Oe(c,e),h(e),l(i)};return[()=>e,()=>Qe(a),e=>Ne(r,e),e=>fe(r,e),e=>ze(a,e),e=>ze(r,e),(e,t)=>Oe(r,e,t),f,(t,n,l,a,r)=>{f(t,n);const i=Fe(),u=Fe(),I=ze(d,t),b=ze(c,t),w=t=>{const l=s=>e.getCell(n,t,s),d=ze(I,t),c=o(n,t)?s(a(l,t)):void 0;if(d===c||W(d)&&W(c)&&G(d,c)||Oe(i,t,[d,c]),!F(r)){const e=ze(b,t),s=o(n,t)?r(l,t):void 0;e!=s&&Oe(u,t,s)}},L=e=>{l(()=>{Le(i,([,e],t)=>Oe(I,t,e)),Le(u,(e,t)=>Oe(b,t,e))},i,u,I,b,e),we(i),we(u)};Ne(I,w),e.hasTable(n)&&Y(e.getRowIds(n),e=>{fe(I,e)||w(e)}),L(!0),h(t),g(t,0,e.addRowListener(n,null,(e,t,s)=>w(s)),e.addTableListener(n,()=>L()))},I,e=>n(e,i),()=>Ne(u,I),g,h]},Ze=(e,s)=>N(e)?t=>t(e):e??(()=>s??t),$e=(e,t)=>{const s=new WeakMap;return n=>{s.has(n)||s.set(n,e(n));const l=s.get(n);return t?.(l),l}},et=/^\d+$/,tt=()=>{const e=[];let s=0;return[n=>(n?le(e):null)??t+s++,t=>{et.test(t)&&P(e)<1e3&&se(e,t)}]},st=e=>{let s;const[n,l]=tt(),o=Fe();return[(l,a,r,i=[],d=()=>[])=>{s??=e();const c=n(1);return Oe(o,c,[l,a,r,i,d]),Xe(Ge(a,r??[t],Ke),c),c},(e,n,...l)=>Y(((e,s=[t])=>{const n=[],l=(e,t)=>t==P(s)?se(n,e):null===s[t]?Le(e,e=>l(e,t+1)):Y([s[t],null],s=>l(ze(e,s),t+1));return l(e,0),n})(e,n),e=>Le(e,e=>ze(o,e)[0](s,...n??[],...l))),e=>Q(ze(o,e),([,s,n])=>(Ge(s,n??[t],void 0,t=>(Ce(t,e),Ie(t)?1:0)),Oe(o,e),l(e),n)),e=>Q(ze(o,e),([e,,t=[],n,l])=>{const o=(...a)=>{const r=P(a);r==P(t)?e(s,...a,...l(a)):F(t[r])?Y(n[r]?.(...a)??[],e=>o(...a,e)):o(...a,t[r])};o()})]},nt=$e(e=>{let s,n,l,o=100,a=Fe(),r=Fe(),i=1;const d=Fe(),c=Fe(),[u,g,h]=st(()=>J),f=Fe(),I=Fe(),b=[],w=[],L=(t,s)=>{i=0,e.transaction(()=>{const[n,l]=ze(f,s);Le(n,(s,n)=>Le(s,(s,l)=>Le(s,(s,o)=>re(e,n,l,o,s[t])))),Le(l,(s,n)=>ie(e,n,s[t]))}),i=1},C=e=>{Oe(f,e),Oe(I,e),g(c,[e])},R=(e,t)=>Y(((e,t)=>e.splice(0,t))(e,t??P(e)),C),T=()=>R(b,P(b)-o),v=()=>Q(s,()=>{se(b,s),T(),R(w),s=void 0,l=1}),p=()=>{s=ne(b),l=1};let S,y;const V=(e=t)=>(F(s)&&(s=t+n++,Oe(f,s,[a,r]),D(s,e),a=Fe(),r=Fe(),l=1),s),m=()=>{ee(b)||(((e,...t)=>{e.unshift(...t)})(w,V()),L(0,s),s=ne(b),l=1)},M=()=>{ee(w)||(se(b,s),s=le(w),L(1,s),l=1)},E=()=>{l&&(g(d),l=0)},k=e=>{const t=V(e);return E(),t},D=(e,t)=>(H(e)&&ze(I,e)!==t&&(Oe(I,e,t),g(c,[e])),J),H=e=>fe(f,e),J={setSize:e=>(o=e,T(),J),addCheckpoint:k,setCheckpoint:D,getStore:()=>e,getCheckpointIds:()=>[[...b],s,[...w]],forEachCheckpoint:e=>Ne(I,e),hasCheckpoint:H,getCheckpoint:e=>ze(I,e),goBackward:()=>(m(),E(),J),goForward:()=>(M(),E(),J),goTo:e=>{const t=U(b,e)?m:U(w,e)?M:null;for(;!F(t)&&e!=s;)t();return E(),J},addCheckpointIdsListener:e=>u(e,d),addCheckpointListener:(e,t)=>u(t,c,[e]),delListener:e=>(h(e),J),clear:()=>(R(b),R(w),F(s)||C(s),s=void 0,n=0,k(),J),clearForward:()=>(ee(w)||(R(w),g(d)),J),destroy:()=>{e.delListener(S),e.delListener(y)},getListenerStats:()=>({checkpointIds:ue(d),checkpoint:ue(c)}),_registerListeners:()=>{S=e.addCellListener(null,null,null,(e,t,s,n,l,o)=>{if(i){v();const e=We(a,t,Fe),r=We(e,s,Fe),i=We(r,n,()=>[o,void 0]);i[1]=l,i[0]===l&&Ie(Oe(r,n))&&Ie(Oe(e,s))&&Ie(Oe(a,t))&&p(),E()}}),y=e.addValueListener(null,(e,t,s,n)=>{if(i){v();const e=We(r,t,()=>[n,void 0]);e[1]=s,e[0]===s&&Ie(Oe(r,t))&&p(),E()}})}};return Ve(J.clear())},e=>e._registerListeners()),lt=M("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"),ot=Fe(Z(lt,(e,t)=>[e,t])),at=e=>lt[63&e],rt=(e,t)=>ze(ot,e[t])??0,it=E.crypto?e=>E.crypto.getRandomValues(e):e=>Z(e,()=>J(256*k.random())),dt=(e=16)=>te(it(new Uint8Array(e)),(e,t)=>e+at(t),t),ct=JSON.stringify,ut=JSON.parse,gt=e=>ct(e,(e,t)=>t instanceof Map?Re.fromEntries([...t]):t),ht=new E.TextEncoder,ft=e=>{let t=2166136261;return Y(ht.encode(e),e=>{t^=e,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)}),t>>>0},It=(e,t)=>(e^t)>>>0,bt=e=>te(pe(e),(e,[t,s])=>It(e,wt(t,s)^wt(t,0)),0),wt=(e,t)=>ft(e+":"+t),Lt=(e,t)=>ft(gt(e??null)+":"+t),Ct=Lt,Rt=wt,Tt=bt,vt=wt,pt=e=>te(pe(e),(e,[t,s])=>It(e,wt(t,s)),0),St=wt,yt=pt,Vt=2**36,mt=2**30,Mt=2**24,Et=2**18,kt=4096,Dt=e=>{const t=ft(e);return at(t/Mt)+at(t/Et)+at(t/kt)+at(t/64)+at(t)},Ht=(e,t=Date.now)=>{let s=0,n=-1;const l=Q(e,Dt,()=>dt(5)),o=e=>{const l=s,[o,a]=F(e)||""==e?[0,0]:r(e);s=D(l,o,t()),n=s==l?s==o?D(n,a):n:s==o?a:-1},a=(e,t,s)=>at(e/Vt)+at(e/mt)+at(e/Mt)+at(e/Et)+at(e/kt)+at(e/64)+at(e)+at(t/Et)+at(t/kt)+at(t/64)+at(t)+(F(s)?l:Dt(s)),r=e=>[rt(e,0)*Vt+rt(e,1)*mt+rt(e,2)*Mt+rt(e,3)*Et+rt(e,4)*kt+64*rt(e,5)+rt(e,6),rt(e,7)*Et+rt(e,8)*kt+64*rt(e,9)+rt(e,10),e.slice(11)];return[()=>(o(),a(s,++n)),o,a,r,()=>s,()=>n,()=>l]},Jt=(e,t)=>(e??0)<(t??0)?-1:1,xt=$e(e=>{const s=Fe(),n=Fe(),[l,o,a]=st(()=>C),[r,i,d,c,u,g,h,,f,I,b,w]=Ye(e,Fe,e=>F(e)?t:W(e)?Z(e,y):y(e),l,o),L=(t,s,n)=>{const l=u(t);Le(n,(t,n)=>s(n,s=>Le(t,t=>s(t,s=>e.forEachCell(l,t,s)))))},C={setIndexDefinition:(e,t,l,a,r,i=Jt)=>{const d=F(r)?void 0:([e],[t])=>r(e,t);return f(e,t,(t,l,r,c,u,f)=>{let I=0;const b=Ke(),w=Ke(),L=g(e);if(Le(l,([e,t],s)=>{const n=Ke(e),l=Ke(t);Le(n,e=>Ce(l,e)?Ce(n,e):0),Le(n,e=>{Xe(b,e),Q(ze(L,e),t=>{Ce(t,s),Ie(t)&&(Oe(L,e),I=1)})}),Le(l,e=>{Xe(b,e),fe(L,e)||(Oe(L,e,Ke()),I=1),Xe(ze(L,e),s),F(a)||Xe(w,e)})}),t(),Ie(u)||(f?Ne(L,e=>Xe(w,e)):Ne(r,e=>Q(ze(c,e),e=>Y(W(e)?e:[e],e=>Xe(w,e)))),Le(w,e=>{const t=(t,s)=>i(ze(u,t),ze(u,s),e),s=[...ze(L,e)];K(s,t)||(Oe(L,e,Ke(X(s,t))),Xe(b,e))})),(I||f)&&!F(d)){const t=[...L];K(t,d)||(h(e,Fe(X(t,d))),I=1)}I&&o(s,[e]),Le(b,t=>o(n,[e,t]))},Ze(l),Q(a,Ze)),C},delIndexDefinition:e=>(I(e),C),getStore:r,getIndexIds:i,forEachIndex:e=>d((t,s)=>e(t,e=>L(t,e,s))),forEachSlice:(e,t)=>L(e,t,g(e)),hasIndex:c,hasSlice:(e,t)=>fe(g(e),t),getTableId:u,getSliceIds:e=>Qe(g(e)),getSliceRowIds:(e,t)=>be(ze(g(e),t)),addIndexIdsListener:b,addSliceIdsListener:(e,t)=>l(t,s,[e]),addSliceRowIdsListener:(e,t,s)=>l(s,n,[e,t]),delListener:e=>(a(e),C),destroy:w,getListenerStats:()=>({sliceIds:ue(s),sliceRowIds:ge(n)})};return Ve(C)}),Ft=([e,t])=>zt(e,t),Qt=([e,t,s])=>[e,t,s],zt=(e,t)=>t?[e,t]:[e],Nt=(e,t,s)=>[e,t,s],Ot=e=>e[2],Wt=(e,t)=>t>e?(e?ft(e):0)^ft(t):0,At=(e,t)=>((e??"")>(t??"")?e:t)??"",Pt=(e,t,s)=>{t>e[1]&&(e[1]=t),e[2]=s>>>0},jt=(e=t)=>zt(me(),e),_t=(e=t)=>[Fe(),e,0],Bt=([e,t,s],n=Qt)=>[Pe(e,n),t,s],Ut=([e,t],s=Ft)=>zt(Pe(e,s),t),qt=(t,s)=>W(t)&&3==P(t)&&N(t[1])&&e(t[2])==l&&x(t[2])&&s(t[0]),Gt=e=>[e,e],Kt=(e,t=ue)=>t(e[0])+t(e[1]),Xt=()=>[Fe(),Fe()],Yt=e=>[...e],Zt=([e,t])=>e===t,$t=(e,t,s)=>Oe(e,t,ze(e,t)==-s?void 0:s),es=()=>{let e,t,s=!1,n=!1,o=0,d=[];const g=Fe(),C=Fe(),V=Fe(),m=Fe(),M=Fe(),E=Fe(),k=Fe(),D=Fe(),H=Fe(),J=Fe(),x=Fe(),N=Fe(),P=Fe(),j=Fe(),_=Ke(),q=Fe(),K=Fe(),$=Fe(),ee=Fe(),te=Xt(),ne=Xt(),le=Xt(),ae=Xt(),de=Xt(),be=Xt(),Re=Xt(),Te=Xt(),ve=Xt(),pe=Xt(),ye=Xt(),me=Xt(),ke=Xt(),Je=Xt(),Ge=Xt(),Ye=Xt(),Ze=Xt(),$e=Xt(),et=Xt(),nt=Xt(),lt=Xt(),ot=Xt(),at=Fe(),rt=Xt(),[it,dt,ct,ht]=st(()=>Ps),ft=e=>{if(!xe(e,(e,t)=>U([a,r],t)))return!1;const t=e[a];return!(!z(t)&&t!=l||(oe(e[r])!=t&&Ee(e,r),0))},It=W,bt=(t,s)=>(!e||fe(x,s)||Ut(s))&&xe(t,(e,t)=>wt(s,t,e),()=>Ut(s)),wt=(e,t,s,n)=>xe(n?s:Tt(s,e,t),(n,l)=>Q(Lt(e,t,l,n),e=>(s[l]=e,!0),()=>!1),()=>Ut(e,t)),Lt=(t,s,n,l)=>e?Q(ze(ze(x,t),n),e=>oe(l)!=e[a]?Ut(t,s,n,l,e[r]):l,()=>Ut(t,s,n,l)):F(oe(l))?Ut(t,s,n,l):l,Ct=(e,t)=>xe(t?e:vt(e),(t,s)=>Q(Rt(s,t),t=>(e[s]=t,!0),()=>!1),()=>qt()),Rt=(e,s)=>t?Q(ze(P,e),t=>oe(s)!=t[a]?qt(e,s,t[r]):s,()=>qt(e,s)):F(oe(s))?qt(e,s):s,Tt=(e,t,s)=>(Q(ze(N,t),([n,l])=>{Le(n,(t,s)=>{Me(e,s)||(e[s]=t)}),Le(l,n=>{Me(e,n)||Ut(t,s,n)})}),e),vt=e=>(t&&(Le(j,(t,s)=>{Me(e,s)||(e[s]=t)}),Le(_,t=>{Me(e,t)||qt(t)})),e),pt=e=>Ae(x,e,(e,t,s)=>{const n=Fe(),l=Ke();Ae(We(x,t,Fe),s,(e,t,s)=>{Oe(e,t,s),Q(s[r],e=>Oe(n,t,e),()=>Xe(l,t))}),Oe(N,t,[n,l])},(e,t)=>{Oe(x,t),Oe(N,t)}),St=e=>Ae(P,e,(e,t,s)=>{Oe(P,t,s),Q(s[r],e=>Oe(j,t,e),()=>Xe(_,t))},(e,t)=>{Oe(P,t),Oe(j,t),Ce(_,t)}),yt=e=>He(e)?Js():Ms(e),Vt=e=>Ae($,e,(e,t,s)=>mt(t,s),(e,t)=>Qt(t)),mt=(e,t)=>Ae(We($,e,()=>(Wt(e,1),Oe(q,e,tt()),Oe(K,e,Fe()),Fe())),t,(t,s,n)=>Mt(e,t,s,n),(t,s)=>zt(e,t,s)),Mt=(e,t,s,n,l)=>Ae(We(t,s,()=>(At(e,s,1),Fe())),n,(t,n,l)=>Et(e,s,t,n,l),(n,o)=>Nt(e,t,s,n,o,l)),Et=(e,t,s,n,l)=>{fe(s,n)||Pt(e,t,n,1);const o=ze(s,n);l!==o&&(jt(e,t,n,o,l),Oe(s,n,l))},kt=(e,t,s,n,l)=>Q(ze(t,s),t=>Et(e,s,t,n,l),()=>Mt(e,t,s,Tt({[n]:l},e,s))),Dt=e=>He(e)?Qs():Es(e),Ht=e=>Ae(ee,e,(e,t,s)=>xt(t,s),(e,t)=>Ot(t)),xt=(e,t)=>{fe(ee,e)||_t(e,1);const s=ze(ee,e);t!==s&&(Bt(e,s,t),Oe(ee,e,t))},Ft=e=>ze($,e)??mt(e,{}),Qt=e=>mt(e,{}),zt=(e,t,s)=>{const[,n]=ze(q,e);n(s),Mt(e,t,s,{},!0)},Nt=(e,t,s,n,l,o)=>{const a=ze(ze(N,e)?.[0],l);if(!F(a)&&!o)return Et(e,s,n,l,a);const r=t=>{jt(e,s,t,ze(n,t)),Pt(e,s,t,-1),Oe(n,t)};F(a)?r(l):Ne(n,r),Ie(n)&&(At(e,s,-1),Ie(Oe(t,s))&&(Wt(e,-1),Oe($,e),Oe(q,e),Oe(K,e)))},Ot=e=>{const t=ze(j,e);if(!F(t))return xt(e,t);Bt(e,ze(ee,e)),_t(e,-1),Oe(ee,e)},Wt=(e,t)=>$t(g,e,t),At=(e,t,s)=>$t(We(m,e,Fe),t,s)&&Oe(V,e,We(V,e,()=>0)+s),Pt=(e,t,s,n)=>{const l=ze(K,e),o=ze(l,s)??0;(0==o&&1==n||1==o&&-1==n)&&$t(We(C,e,Fe),s,n),Oe(l,s,o!=-n?o+n:null),$t(We(We(M,e,Fe),t,Fe),s,n)},jt=(e,t,s,n,l)=>{We(We(We(E,e,Fe),t,Fe),s,()=>[n,0])[1]=l,d[3]?.(e,t,s,l)},_t=(e,t)=>$t(k,e,t),Bt=(e,t,s)=>{We(D,e,()=>[t,0])[1]=s,d[4]?.(e,s)},Ut=(e,t,s,n,l)=>(se(We(We(We(H,e,Fe),t,Fe),s,()=>[]),n),l),qt=(e,t,s)=>(se(We(J,e,()=>[]),t),s),ts=(e,t,s)=>Q(ze(ze(ze(E,e),t),s),([e,t])=>[!0,e,t],()=>[!1,...Gt(ws(e,t,s))]),ss=e=>Q(ze(D,e),([e,t])=>[!0,e,t],()=>[!1,...Gt(Rs(e))]),ns=e=>Ie(H)||Ie(Ye[e])?0:Le(e?qe(H):H,(t,s)=>Le(t,(t,n)=>Le(t,(t,l)=>dt(Ye[e],[s,n,l],t)))),ls=e=>Ie(J)||Ie(Ze[e])?0:Le(e?Be(J):J,(t,s)=>dt(Ze[e],[s],t)),os=(e,t,s,n)=>{if(!Ie(e))return dt(t,n,()=>Pe(e)),Ne(e,(e,t)=>dt(s,[...n??[],e],1==t)),1},as=e=>{const t=Ts();t!=s&&dt(te[e],void 0,t);const n=Ie(pe[e]),l=Ie(ke[e])&&Ie(Je[e])&&Ie(ve[e])&&Ie(ye[e])&&Ie(be[e])&&Ie(Re[e])&&Ie(Te[e])&&n&&Ie(le[e])&&Ie(ae[e]),o=Ie(Ge[e])&&Ie(me[e])&&Ie(de[e])&&Ie(ne[e]);if(!l||!o){const t=e?[Be(g),Ue(C),Be(V),Ue(m),qe(M),qe(E)]:[g,C,V,m,M,E];if(!l){os(t[0],le[e],ae[e]),Le(t[1],(t,s)=>os(t,be[e],Re[e],[s])),Le(t[2],(t,s)=>{0!=t&&dt(Te[e],[s],hs(s))});const s=Ke();Le(t[3],(t,l)=>{os(t,ve[e],ye[e],[l])&&!n&&(dt(pe[e],[l,null]),Xe(s,l))}),n||Le(t[5],(t,n)=>{if(!fe(s,n)){const s=Ke();Le(t,e=>Le(e,([t,n],l)=>n!==t?Xe(s,l):Ce(e,l))),Le(s,t=>dt(pe[e],[n,t]))}}),Le(t[4],(t,s)=>Le(t,(t,n)=>os(t,ke[e],Je[e],[s,n])))}if(!o){let s;Le(t[5],(t,n)=>{let l;Le(t,(t,o)=>{let a;Le(t,([t,r],i)=>{r!==t&&(dt(Ge[e],[n,o,i],r,t,ts),s=l=a=1)}),a&&dt(me[e],[n,o],ts)}),l&&dt(de[e],[n],ts)}),s&&dt(ne[e],void 0,ts)}}},rs=e=>{const t=Vs();t!=n&&dt($e[e],void 0,t);const s=Ie(nt[e])&&Ie(lt[e]),l=Ie(ot[e])&&Ie(et[e]);if(!s||!l){const t=e?[Be(k),Be(D)]:[k,D];if(s||os(t[0],nt[e],lt[e]),!l){let s;Le(t[1],([t,n],l)=>{n!==t&&(dt(ot[e],[l],n,t,ss),s=1)}),s&&dt(et[e],void 0,ss)}}},is=(e,...t)=>(Os(()=>e(...Z(t,y))),Ps),ds=(e,t,s,n,l)=>{let o=Is(e,t,...s);return it(()=>{const l=Is(e,t,...s);G(l,o)||(o=l,n(Ps,e,t,...s,o))},pe[l?1:0],[e,t],[us])},cs=()=>_e($),us=()=>Qe($),gs=e=>Qe(ze(K,y(e))),hs=e=>ce(ze($,y(e))),fs=e=>Qe(ze($,y(e))),Is=(e,t,s,n=0,l)=>{return Se(e)?Is(e.tableId,e.cellId,e.descending,e.offset,e.limit):Z(A(X((o=ze($,y(e)),a=(e,s)=>[F(t)?s:ze(e,y(t)),s],Z([...o?.entries()??[]],([e,t])=>a(t,e))),([e],[t])=>Jt(e,t)*(s?-1:1)),n,F(l)?l:n+l),([,e])=>e);var o,a},bs=(e,t)=>Qe(ze(ze($,y(e)),y(t))),ws=(e,t,s)=>ze(ze(ze($,y(e)),y(t)),y(s)),Ls=()=>Pe(ee),Cs=()=>Qe(ee),Rs=e=>ze(ee,y(e)),Ts=()=>!Ie($),vs=e=>fe($,y(e)),ps=(e,t)=>fe(ze(K,y(e)),y(t)),Ss=(e,t)=>fe(ze($,y(e)),y(t)),ys=(e,t,s)=>fe(ze(ze($,y(e)),y(t)),y(s)),Vs=()=>!Ie(ee),ms=e=>fe(ee,y(e)),Ms=e=>is(()=>(e=>xe(e,bt,Ut))(e)?Vt(e):0),Es=e=>is(()=>Ct(e)?Ht(e):0),ks=e=>(B(()=>yt(ut(e))),Ps),Ds=t=>is(()=>{if((e=xe(t,e=>xe(e,ft)))&&(pt(t),!Ie($))){const e=cs();Js(),Ms(e)}}),Hs=e=>is(()=>{if(t=(e=>xe(e,ft))(e)){const s=Ls();Ns(),Qs(),t=!0,St(e),Es(s)}}),Js=()=>is(()=>Vt({})),xs=e=>is(e=>fe($,e)?Qt(e):0,e),Fs=(e,t)=>is((e,t)=>Q(ze($,e),s=>fe(s,t)?zt(e,s,t):0),e,t),Qs=()=>is(()=>Ht({})),zs=()=>is(()=>{pt({}),e=!1}),Ns=()=>is(()=>{St({}),t=!1}),Os=(e,t)=>{if(-1!=o){Ws();const s=e();return As(t),s}},Ws=()=>(-1!=o&&o++,1==o&&(d[0]?.(),dt(at)),Ps),As=e=>(o>0&&(o--,0==o&&(o=1,ns(1),Ie(E)||as(1),ls(1),Ie(D)||rs(1),e?.(Ps)&&(Le(E,(e,t)=>Le(e,(e,s)=>Le(e,([e],n)=>re(Ps,t,s,n,e)))),we(E),Le(D,([e],t)=>ie(Ps,t,e)),we(D)),dt(rt[0],void 0),o=-1,ns(0),Ie(E)||as(0),ls(0),Ie(D)||rs(0),d[1]?.(),dt(rt[1],void 0),d[2]?.(),o=0,s=Ts(),n=Vs(),Y([g,C,V,m,M,E,H,k,D,J],we))),Ps),Ps={getContent:()=>[cs(),Ls()],getTables:cs,getTableIds:us,getTable:e=>je(ze($,y(e))),getTableCellIds:gs,getRowCount:hs,getRowIds:fs,getSortedRowIds:Is,getRow:(e,t)=>Pe(ze(ze($,y(e)),y(t))),getCellIds:bs,getCell:ws,getValues:Ls,getValueIds:Cs,getValue:Rs,hasTables:Ts,hasTable:vs,hasTableCell:ps,hasRow:Ss,hasCell:ys,hasValues:Vs,hasValue:ms,getTablesJson:()=>gt($),getValuesJson:()=>gt(ee),getJson:()=>gt([$,ee]),getTablesSchemaJson:()=>gt(x),getValuesSchemaJson:()=>gt(P),getSchemaJson:()=>gt([x,P]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>is(()=>{const t=O(e)?e():e;It(t)&&(([e,t])=>{(He(e)?Js:Ms)(e),(He(t)?Qs:Es)(t)})(t)}),setTables:Ms,setTable:(e,t)=>is(e=>bt(t,e)?mt(e,t):0,e),setRow:(e,t,s)=>is((e,t)=>wt(e,t,s)?Mt(e,Ft(e),t,s):0,e,t),addRow:(e,t,s=!0)=>Os(()=>{let n;return wt(e,n,t)&&(e=y(e),Mt(e,Ft(e),n=((e,t)=>{const[s]=ze(q,e);let n;do{n=s(t)}while(fe(ze($,e),n));return n})(e,s?1:0),t)),n}),setPartialRow:(e,t,s)=>is((e,t)=>{if(wt(e,t,s,1)){const n=Ft(e);De(s,(s,l)=>kt(e,n,t,l,s))}},e,t),setCell:(e,t,s,n)=>is((e,t,s)=>Q(Lt(e,t,s,O(n)?n(ws(e,t,s)):n),n=>kt(e,Ft(e),t,s,n)),e,t,s),setValues:Es,setPartialValues:e=>is(()=>Ct(e,1)?De(e,(e,t)=>xt(t,e)):0),setValue:(e,t)=>is(e=>Q(Rt(e,O(t)?t(Rs(e)):t),t=>xt(e,t)),e),applyChanges:e=>is(()=>{De(e[0],(e,t)=>F(e)?xs(t):De(e,(e,s)=>F(e)?Fs(t,s):De(e,(e,n)=>re(Ps,t,s,n,e)))),De(e[1],(e,t)=>ie(Ps,t,e))}),setTablesJson:ks,setValuesJson:e=>(B(()=>Dt(ut(e))),Ps),setJson:e=>is(()=>B(()=>{const[t,s]=ut(e);yt(t),Dt(s)},()=>ks(e))),setTablesSchema:Ds,setValuesSchema:Hs,setSchema:(e,t)=>is(()=>{Ds(e),Hs(t)}),delTables:Js,delTable:xs,delRow:Fs,delCell:(e,t,s,n)=>is((e,t,s)=>Q(ze($,e),l=>Q(ze(l,t),o=>fe(o,s)?Nt(e,l,t,o,s,n):0)),e,t,s),delValues:Qs,delValue:e=>is(e=>fe(ee,e)?Ot(e):0,e),delTablesSchema:zs,delValuesSchema:Ns,delSchema:()=>is(()=>{zs(),Ns()}),transaction:Os,startTransaction:Ws,getTransactionChanges:()=>[Pe(E,(e,t)=>-1===ze(g,t)?void 0:Pe(e,(e,s)=>-1===ze(ze(m,t),s)?void 0:Pe(e,([,e])=>e,e=>Zt(e)),Ie,He),Ie,He),Pe(D,([,e])=>e,e=>Zt(e)),1],getTransactionLog:()=>[!Ie(E),!Ie(D),_e(E,Yt,Zt),_e(H),Pe(D,Yt,Zt),Pe(J),Pe(g),je(m),_e(M),Pe(k)],finishTransaction:As,forEachTable:e=>Le($,(t,s)=>e(s,e=>Le(t,(t,s)=>e(s,e=>Ne(t,e))))),forEachTableCell:(e,t)=>Ne(ze(K,y(e)),t),forEachRow:(e,t)=>Le(ze($,y(e)),(e,s)=>t(s,t=>Ne(e,t))),forEachCell:(e,t,s)=>Ne(ze(ze($,y(e)),y(t)),s),forEachValue:e=>Ne(ee,e),addSortedRowIdsListener:(e,t,s,n,l,o,a)=>Se(e)?ds(e.tableId,e.cellId,[e.descending??!1,e.offset??0,e.limit],t,s):ds(e,t,[s,n,l],o,a),addStartTransactionListener:e=>it(e,at),addWillFinishTransactionListener:e=>it(e,rt[0]),addDidFinishTransactionListener:e=>it(e,rt[1]),callListener:e=>(ht(e),Ps),delListener:e=>(ct(e),Ps),getListenerStats:()=>({hasTables:Kt(te),tables:Kt(ne),tableIds:Kt(le),hasTable:Kt(ae),table:Kt(de),tableCellIds:Kt(be),hasTableCell:Kt(Re,ge),rowCount:Kt(Te),rowIds:Kt(ve),sortedRowIds:Kt(pe),hasRow:Kt(ye,ge),row:Kt(me,ge),cellIds:Kt(ke,ge),hasCell:Kt(Je,he),cell:Kt(Ge,he),invalidCell:Kt(Ye,he),hasValues:Kt($e),values:Kt(et),valueIds:Kt(nt),hasValue:Kt(lt),value:Kt(ot),invalidValue:Kt(Ze),transaction:ue(at)+Kt(rt)}),isMergeable:()=>!1,createStore:es,addListener:it,callListeners:dt,setInternalListeners:(e,t,s,n,l)=>d=[e,t,s,n,l]};return De({[u+f]:[0,te,[],()=>[Ts()]],[f]:[0,ne],[I]:[0,le],[u+h]:[1,ae,[us],e=>[vs(...e)]],[h]:[1,de,[us]],[h+T]:[1,be,[us]],[u+h+R]:[2,Re,[us,gs],e=>[ps(...e)]],[w]:[1,Te,[us]],[L]:[1,ve,[us]],[u+b]:[2,ye,[us,fs],e=>[Ss(...e)]],[b]:[2,me,[us,fs]],[T]:[2,ke,[us,fs]],[u+R]:[3,Je,[us,fs,bs],e=>[ys(...e)]],[R]:[3,Ge,[us,fs,bs],e=>Gt(ws(...e))],InvalidCell:[3,Ye],[u+p]:[0,$e,[],()=>[Vs()]],[p]:[0,et],[S]:[0,nt],[u+v]:[1,lt,[Cs],e=>[ms(...e)]],[v]:[1,ot,[Cs],e=>Gt(Rs(e[0]))],InvalidValue:[1,Ze]},([e,t,s,n],l)=>{Ps[c+l+i]=(...l)=>it(l[e],t[l[e+1]?1:0],e>0?A(l,0,e):void 0,s,n)}),Ve(Ps)},ts={HasTable:1,Table:1,TableCellIds:1,HasTableCell:2,RowCount:1,RowIds:1,SortedRowIds:5,HasRow:2,Row:2,CellIds:2,HasCell:3,Cell:3,HasValue:1,Value:1,InvalidCell:3,InvalidValue:1},ss=(e=t)=>[_t(e),_t(e)],ns=(e,s)=>{let n=1,l=ss(),o=0;const a=Fe(),r=Ke(),[d,u]=Ht(e,s),g=es(),h=e=>{const t=n;return n=0,e(),n=t,R},f=(e,s=0)=>{const n={},o={},[[a,r=t,i=0],d]=e,[c,g]=l,[h,f,b]=c;let w=s?i:b,L=r;ke(a,([e,l=t,o=0],a)=>{const r=We(h,a,_t),[i,d,c]=r;let u=s?o:c,g=l;ke(e,(e,t)=>{const[l,o,r]=I(e,We(i,t,_t),Je(Je(n,a,me),t,me),s);u^=s?0:It(o?wt(t,o):0,wt(t,r)),g=At(g,l)}),u^=s?0:Wt(d,l),Pt(r,l,u),w^=s?0:It(c?wt(a,c):0,wt(a,r[2])),L=At(L,g)}),w^=s?0:Wt(f,r),Pt(c,r,w);const[C]=I(d,g,o,s);return u(At(L,C)),[n,o,1]},I=(e,s,n,l)=>{const[o,a=t,r=0]=e,[i,d,c]=s;let u=a,g=l?r:c;return ke(o,([e,s=t,o=0],a)=>{const r=We(i,a,()=>[void 0,t,0]),[,d,c]=r;(!d||s>d)&&(Pt(r,s,l?o:Lt(e,s)),r[0]=e,n[a]=e,g^=l?0:It(wt(a,c),wt(a,r[2])),u=At(u,s))}),g^=l?0:Wt(d,a),Pt(s,a,g),[u,c,s[2]]},b=_,w=_,L=()=>[Bt(l[0],e=>Bt(e,e=>Bt(e))),Bt(l[1])],C=e=>h(()=>g.applyChanges(f(e))),R={getMergeableContent:L,getMergeableContentHashes:()=>[l[0][2],l[1][2]],getMergeableTableHashes:()=>Pe(l[0][0],Ot),getMergeableTableDiff:e=>{const t=jt(l[0][1]),s={};return Ne(l[0][0],(n,[l,o,a])=>Me(e,n)?a!=e[n]?s[n]=a:0:t[0][n]=Ut([l,o],e=>Ut(e))),[t,s]},getMergeableRowHashes:e=>{const t={};return ke(e,(e,s)=>Q(ze(l[0][0],s),([n,,l])=>l!=e?Ne(n,(e,[,,n])=>Je(t,s,me)[e]=n):0)),t},getMergeableRowDiff:e=>{const t=jt(l[0][1]),s={};return ke(e,(e,n)=>Ne(ze(l[0][0],n)?.[0],(l,[o,a,r])=>Me(e,l)?r!==e[l]?Je(s,n,me)[l]=r:0:Je(t[0],n,jt)[0][l]=Ut([o,a]))),[t,s]},getMergeableCellHashes:e=>{const t={};return ke(e,(e,s)=>Q(ze(l[0][0],s),([n])=>ke(e,(e,l)=>Q(ze(n,l),([n,,o])=>o!==e?Ne(n,(e,[,,n])=>Je(Je(t,s,me),l,me)[e]=n):0)))),t},getMergeableCellDiff:e=>{const[[t,s]]=l,n={};return ke(e,(e,s)=>ke(e,(e,l)=>Q(ze(t,s),([t,o])=>Q(ze(t,l),([t,a])=>Ne(t,(t,[r,i,d])=>d!==e[t]?Je(Je(n,s,()=>jt(o))[0],l,()=>jt(a))[0][t]=[r,i]:0))))),zt(n,s)},getMergeableValueHashes:()=>Pe(l[1][0],Ot),getMergeableValueDiff:e=>{const[,[t,s]]=l,n=Pe(t,Ft,([,,t],s)=>t==e?.[s]);return zt(n,s)},setMergeableContent:e=>h(()=>(e=>W(e)&&2==P(e)&&qt(e[0],e=>xe(e,e=>qt(e,e=>xe(e,e=>qt(e,e=>xe(e,e=>qt(e,ae),void 0,1)),void 0,1)),void 0,1))&&qt(e[1],e=>xe(e,e=>qt(e,ae),void 0,1)))(e)?g.transaction(()=>{g.delTables().delValues(),l=ss(),g.applyChanges(f(e,1))}):0),setDefaultContent:e=>(g.transaction(()=>{o=1,g.setContent(e),o=0}),R),getTransactionMergeableChanges:(e=!1)=>{const[[t,s,n],[o,i,d]]=l,c=e?Nt:zt,u={};Le(a,(e,s)=>Q(ze(t,s),([t,n,l])=>{const o={};Le(e,(e,s)=>Q(ze(t,s),([t,n,l])=>{const a={};Le(e,e=>{Q(ze(t,e),([t,s,n])=>a[e]=c(t,s,n))}),o[s]=c(a,n,l)})),u[s]=c(o,n,l)}));const g={};return Le(r,e=>Q(ze(o,e),([t,s,n])=>g[e]=c(t,s,n))),[c(u,s,n),c(g,i,d),1]},applyMergeableChanges:C,merge:e=>{const t=L(),s=e.getMergeableContent();return e.applyMergeableChanges(t),C(s)}};return g.setInternalListeners(b,w,()=>{we(a),we(r)},(e,s,l,r)=>{Xe(We(We(a,e,Fe),s,Ke),l),n&&f([[{[e]:[{[s]:[{[l]:[r,o?t:d()]}]}]}],[{}],1])},(e,s)=>{Xe(r,e),n&&f([[{}],[{[e]:[s,o?t:d()]}],1])}),De(g,(e,t)=>R[t]=V(t,"set")||V(t,"del")||V(t,"apply")||m(t,"Transaction")||t=="call"+i?(...t)=>(e(...t),R):V(t,c)&&m(t,i)?(...s)=>{const n=ts[A(t,3,-8)]??0,l=s[n];return s[n]=(e,...t)=>l(R,...t),e(...s)}:"isMergeable"==t?()=>!0:e),Ve(R)},ls=Fe([["avg",[(e,t)=>$(e)/t,(e,t,s)=>e+(t-e)/(s+1),(e,t,s)=>e+(e-t)/(s-1),(e,t,s,n)=>e+(t-s)/n]],["max",[e=>D(...e),(e,t)=>D(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:D(t,e)]],["min",[e=>H(...e),(e,t)=>H(t,e),(e,t)=>t==e?void 0:e,(e,t,s)=>s==e?void 0:H(t,e)]],["sum",[e=>$(e),(e,t)=>e+t,(e,t)=>e-t,(e,t,s)=>e-s+t]]]),os=(e,t,s,n,l,o=!1)=>{if(Ie(s))return;const[a,r,i,d]=l;return o||=F(e),Le(n,([s,n])=>{o||(e=F(s)?r?.(e,n,t++):F(n)?i?.(e,s,t--):d?.(e,n,s,t),o||=F(e))}),o?a(be(s),ce(s)):e},as=$e(e=>{const s=Fe(),[n,l,o]=st(()=>w),[a,r,i,d,c,u,g,,h,f,I,b]=Ye(e,j,e=>isNaN(e)||F(e)||!0===e||!1===e||e===t?void 0:1*e,n,l),w={setMetricDefinition:(e,t,n,o,a,r,i)=>{const d=O(n)?[n,a,r,i]:ze(ls,n)??ze(ls,"sum");return h(e,t,(t,n,o,a,r,i)=>{const c=u(e),h=ce(a);i||=F(c),t();let f=os(c,h,a,n,d,i);x(f)||(f=void 0),f!=c&&(g(e,f),l(s,[e],f,c))},Ze(o,1)),w},delMetricDefinition:e=>(f(e),w),getStore:a,getMetricIds:r,forEachMetric:i,hasMetric:d,getTableId:c,getMetric:u,addMetricIdsListener:I,addMetricListener:(e,t)=>n(t,s,[e]),delListener:e=>(o(e),w),destroy:b,getListenerStats:()=>({metric:ue(s)})};return Ve(w)}),rs=$e(e=>{const s=e.createStore,n=s(),l=s(),o=Fe(),{addListener:a,callListeners:r,delListener:u}=l,[g,f,I,v,p,,,S,,y,V,m,M,E]=Ye(e,()=>!0,j,a,r),k=(e,t,...s)=>Y(s,s=>Xe(We(We(o,t,Fe),e,Ke),s)),D=e=>{Q(ze(o,e),e=>{Ne(e,(e,t)=>Le(t,t=>e.delListener(t))),we(e)}),Y([l,n],t=>t.delTable(e))},H=(e,t,s)=>k(t,e,t.addStartTransactionListener(s.startTransaction),t.addDidFinishTransactionListener(()=>s.finishTransaction())),J={setQueryDefinition:(s,o,a)=>{S(s,o),D(s);const r=[],i=[[null,[o,null,null,[],Fe()]]],d=[],c=[],u=[];a({select:(e,s)=>{const n=O(e)?[P(r)+t,e]:[F(s)?e:s,t=>t(e,s)];return se(r,n),{as:e=>n[0]=e}},join:(e,t,s)=>{const n=F(s)||O(t)?null:t,l=F(n)?t:s,o=[e,[e,n,O(l)?l:e=>e(l),[],Fe()]];return se(i,o),{as:e=>o[0]=e}},where:(e,t,s)=>se(d,O(e)?e:F(s)?s=>s(e)===t:n=>n(e,t)===s),group:(e,t,s,n,l)=>{const o=[e,[e,O(t)?[t,s,n,l]:ze(ls,t)??[(e,t)=>t]]];return se(c,o),{as:e=>o[0]=e}},having:(e,t)=>se(u,O(e)?e:s=>s(e)===t)});const g=Fe(r);if(Ie(g))return J;const h=Fe(i);Ne(h,(e,[,t])=>Q(ze(h,t),({3:t})=>F(e)?0:se(t,e)));const f=Fe(c);let I=n;if(Ie(f)&&ee(u))I=l;else{H(s,I,l);const e=Fe();Ne(f,(t,[s,n])=>Xe(We(e,s,Ke),[t,n]));const t=Ke();Ne(g,s=>fe(e,s)?0:Xe(t,s));const n=Fe(),o=(t,n,o,a)=>Q(t,([r,i,d,c])=>{Ne(n,(t,[s])=>{const n=We(r,t,Fe),l=ze(n,o),i=a?void 0:s;if(l!==i){const s=Ke([[l,i]]),a=ce(n);Oe(n,o,i),Le(ze(e,t),([e,t])=>{const l=os(c[e],a,n,s,t);c[e]=F(oe(l))?null:l})}}),Ie(i)||!q(u,e=>e(e=>c[e]))?l.delRow(s,d):F(d)?t[2]=l.addRow(s,c):l.setRow(s,d,c)});k(I,s,I.addRowListener(s,null,(l,a,r,i)=>{const d=[],c=[],u=Fe(),g=I.hasRow(s,r);let h=!g;Le(t,e=>{const[t,n,l]=i(s,r,e);se(d,n),se(c,l),h||=t}),Ne(e,e=>{const[t,,n]=i(s,r,e);(h||t)&&Oe(u,e,[n])}),h&&o(Ge(n,d,void 0,([,e])=>(Ce(e,r),Ie(e))),u,r,1),g&&o(Ge(n,c,()=>{const e={};return Le(t,t=>e[t]=I.getCell(s,r,t)),[Fe(),Ke(),void 0,e]},([,e])=>{Xe(e,r)}),u,r)}))}H(s,e,I);const b=(t,n,l,a)=>{const r=t=>e.getCell(n,l,t);Y(a,n=>{const[l,,o,a,i]=ze(h,n),d=o?.(r,t),[c,u]=ze(i,t)??[];d!=c&&(F(u)||E(s,u),Oe(i,t,F(d)?null:[d,...M(s,1,e.addRowListener(l,d,()=>b(t,l,d,a)))]))}),(t=>{const n=(s,n)=>e.getCell(...F(n)?[o,t,s]:s===o?[o,t,n]:[ze(h,s)?.[0],ze(ze(h,s)?.[4],t)?.[0],n]);I.transaction(()=>q(d,e=>e(n))?Ne(g,(e,l)=>re(I,s,t,e,l(n,t))):I.delRow(s,t))})(t)},{3:w}=ze(h,null);return I.transaction(()=>M(s,1,e.addRowListener(o,null,(t,n,l)=>{e.hasRow(o,l)?b(l,o,l,w):(I.delRow(s,l),Le(h,({4:e})=>Q(ze(e,l),([,t])=>{E(s,t),Oe(e,l)})))}))),J},delQueryDefinition:e=>(D(e),y(e),J),getStore:g,getQueryIds:f,forEachQuery:I,hasQuery:v,getTableId:p,addQueryIdsListener:e=>V(()=>e(J)),delListener:e=>(u(e),J),destroy:m,getListenerStats:()=>{const{tables:e,tableIds:t,transaction:s,...n}=l.getListenerStats();return n}};return De({[h]:[1,1],[h+T]:[0,1],[w]:[0,1],[L]:[0,1],[C]:[0,5],[b]:[1,2],[T]:[0,2],[R]:[1,3]},([e,t],s)=>{Y(e?["get","has","forEach"]:["get"],e=>J[e+d+s]=(...t)=>l[e+s](...t)),J[c+d+s+i]=(...e)=>l[c+s+i](...A(e,0,t),(s,...n)=>e[t](J,...n),!0)}),Ve(J)}),is=$e(e=>{const s=Fe(),n=Fe(),l=Fe(),o=Fe(),[a,r,i]=st(()=>v),[d,c,u,g,h,f,,,I,b,w,L]=Ye(e,()=>[Fe(),Fe(),Fe(),Fe()],e=>F(e)?void 0:e+t,a,r),C=(e,t,s)=>Q(f(e),([n,,l])=>{if(!fe(l,t)){const o=Ke();if(h(e)!=T(e))Xe(o,t);else{let e=t;for(;!F(e)&&!fe(o,e);)Xe(o,e),e=ze(n,e)}if(s)return o;Oe(l,t,o)}return ze(l,t)}),R=(e,t)=>Q(f(e),([,,e])=>Oe(e,t)),T=e=>ze(s,e),v={setRelationshipDefinition:(e,t,a,i)=>(Oe(s,e,a),I(e,t,(t,s)=>{const a=Ke(),i=Ke(),d=Ke(),[c,u]=f(e);Le(s,([t,s],n)=>{F(t)||(Xe(i,t),Q(ze(u,t),e=>{Ce(e,n),Ie(e)&&Oe(u,t)})),F(s)||(Xe(i,s),fe(u,s)||Oe(u,s,Ke()),Xe(ze(u,s),n)),Xe(a,n),Oe(c,n,s),Ne(ze(o,e),t=>{fe(C(e,t),n)&&Xe(d,t)})}),t(),Le(a,t=>r(n,[e,t])),Le(i,t=>r(l,[e,t])),Le(d,t=>{R(e,t),r(o,[e,t])})},Ze(i)),v),delRelationshipDefinition:e=>(Oe(s,e),b(e),v),getStore:d,getRelationshipIds:c,forEachRelationship:t=>u(s=>t(s,t=>e.forEachRow(h(s),t))),hasRelationship:g,getLocalTableId:h,getRemoteTableId:T,getRemoteRowId:(e,t)=>ze(f(e)?.[0],t),getLocalRowIds:(e,t)=>be(ze(f(e)?.[1],t)),getLinkedRowIds:(e,t)=>F(f(e))?[t]:be(C(e,t,!0)),addRelationshipIdsListener:w,addRemoteRowIdListener:(e,t,s)=>a(s,n,[e,t]),addLocalRowIdsListener:(e,t,s)=>a(s,l,[e,t]),addLinkedRowIdsListener:(e,t,s)=>(C(e,t),a(s,o,[e,t])),delListener:e=>(R(...i(e)??[]),v),destroy:L,getListenerStats:()=>({remoteRowId:ge(n),localRowIds:ge(l),linkedRowIds:ge(o)})};return Ve(v)});export{It as addOrRemoveHash,nt as createCheckpoints,xt as createIndexes,ns as createMergeableStore,as as createMetrics,rs as createQueries,is as createRelationships,es as createStore,Jt as defaultSorter,Ct as getCellHash,Rt as getCellInRowHash,ft as getHash,Ht as getHlcFunctions,Tt as getRowHash,vt as getRowInTableHash,pt as getTableHash,St as getTableInTablesHash,yt as getTablesHash,dt as getUniqueId,Lt as getValueHash,wt as getValueInValuesHash,bt as getValuesHash};
Binary file
package/omni/index.js CHANGED
@@ -856,7 +856,7 @@ const getUniqueId$1 = (length = 16) =>
856
856
  arrayReduce(
857
857
  getRandomValues(new Uint8Array(length)),
858
858
  (uniqueId, number) => uniqueId + encode(number),
859
- '',
859
+ EMPTY_STRING,
860
860
  );
861
861
 
862
862
  const jsonString = JSON.stringify;
@@ -856,7 +856,7 @@ const getUniqueId$1 = (length = 16) =>
856
856
  arrayReduce(
857
857
  getRandomValues(new Uint8Array(length)),
858
858
  (uniqueId, number) => uniqueId + encode(number),
859
- '',
859
+ EMPTY_STRING,
860
860
  );
861
861
 
862
862
  const jsonString = JSON.stringify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "6.5.0",
3
+ "version": "6.5.2",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -22,18 +22,18 @@
22
22
  "sideEffects": false,
23
23
  "peerDependencies": {
24
24
  "@automerge/automerge-repo": "^1.2.1",
25
- "@cloudflare/workers-types": "^4.20250724.0",
25
+ "@cloudflare/workers-types": "^4.20250813.0",
26
26
  "@electric-sql/pglite": "^0.2.17",
27
27
  "@libsql/client": "^0.15.10",
28
- "@powersync/common": "^1.34.0",
29
- "@sqlite.org/sqlite-wasm": "^3.50.3-build1",
28
+ "@powersync/common": "^1.36.0",
29
+ "@sqlite.org/sqlite-wasm": "^3.50.4-build1",
30
30
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
31
31
  "bun": "^1.2.19",
32
32
  "electric-sql": "^0.12.1",
33
33
  "expo": "^53.0.9",
34
34
  "expo-sqlite": "^15.2.14",
35
35
  "partykit": "^0.0.115",
36
- "partysocket": "^1.1.4",
36
+ "partysocket": "^1.1.5",
37
37
  "postgres": "^3.4.7",
38
38
  "react": "^19.0.0",
39
39
  "react-dom": "^19.0.0",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <link rel="preload" as="image" href="https://tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://tinybase.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://tinybase.org/guides/releases/#v6-4"><em>NEW!</em> v6.4 release</a></p><p><span id="one-with">&quot;The One With React Native SQLite!&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://tinybase.org/api/persister-browser">browser storage</a>, <a href="https://tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.7kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img src="https://tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img src="https://tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><p>(Baffled by all these logos? Check out our <a href="https://tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/6.4.2" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <link rel="preload" as="image" href="https://tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://tinybase.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://tinybase.org/guides/releases/#v6-5"><em>NEW!</em> v6.5 release</a></p><p><span id="one-with">&quot;The One With MMKV!&quot;</span></p><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://tinybase.org/api/persister-browser">browser storage</a>, <a href="https://tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.3kB - 11.7kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://tinybase.org/api/persister-partykit-client"><img src="https://tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://tinybase.org/api/persister-automerge"><img src="https://tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><p>(Baffled by all these logos? Check out our <a href="https://tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/6.5.1" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  import {createStore} from 'tinybase';
@@ -275,4 +275,4 @@ console.log(store.getCell('pets', 'felix', 'sold'));
275
275
  // -> false
276
276
  ```
277
277
 
278
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.7kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>5.1kB</em>, the ui-react-dom components are another <em>2.6kB</em>, and everything is super fast. Life is easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.3kB</td><td>53.6kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.7kB</td><td>122.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/ui-react/">ui-react</a></th><td>5.1kB</td><td>55.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>2.6kB</td><td>21.1kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,328</td><td>2,328</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,517</td><td>2,517</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>1,006</td><td>1,006</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>878</td><td>878</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,100</td></tr><tr><th class="right">Assertions</th><td colspan="3">32,900</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img src="https://github.com/beekeeb.png?size=48" title="beekeeb" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img src="https://github.com/cancelself.png?size=48" title="cancelself" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img src="https://github.com/arpitBhalla.png?size=48" title="arpitBhalla" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/behrends" target="_blank"><img src="https://github.com/behrends.png?size=48" title="behrends" width="48" height="48"></a><a href="https://github.com/betomoedano" target="_blank"><img src="https://github.com/betomoedano.png?size=48" title="betomoedano" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img src="https://github.com/brentvatne.png?size=48" title="brentvatne" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img src="https://github.com/byCedric.png?size=48" title="byCedric" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img src="https://github.com/circadian-risk.png?size=48" title="circadian-risk" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img src="https://github.com/cubecull.png?size=48" title="cubecull" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img src="https://github.com/erwinkn.png?size=48" title="erwinkn" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img src="https://github.com/ezra-en.png?size=48" title="ezra-en" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img src="https://github.com/feychenie.png?size=48" title="feychenie" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img src="https://github.com/flaming-codes.png?size=48" title="flaming-codes" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img src="https://github.com/fostertheweb.png?size=48" title="fostertheweb" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img src="https://github.com/Giulio987.png?size=48" title="Giulio987" width="48" height="48"></a><a href="https://github.com/hi-ogawa" target="_blank"><img src="https://github.com/hi-ogawa.png?size=48" title="hi-ogawa" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img src="https://github.com/itsdevcoffee.png?size=48" title="itsdevcoffee" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img src="https://github.com/jbolda.png?size=48" title="jbolda" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img src="https://github.com/Kayoo-asso.png?size=48" title="Kayoo-asso" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img src="https://github.com/kotofurumiya.png?size=48" title="kotofurumiya" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img src="https://github.com/Kudo.png?size=48" title="Kudo" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img src="https://github.com/learn-anything.png?size=48" title="learn-anything" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img src="https://github.com/lluc.png?size=48" title="lluc" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img src="https://github.com/marksteve.png?size=48" title="marksteve" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img src="https://github.com/miking-the-viking.png?size=48" title="miking-the-viking" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img src="https://github.com/mjamesderocher.png?size=48" title="mjamesderocher" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img src="https://github.com/mouktardev.png?size=48" title="mouktardev" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img src="https://github.com/nickmessing.png?size=48" title="nickmessing" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img src="https://github.com/nikitavoloboev.png?size=48" title="nikitavoloboev" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img src="https://github.com/nkzw-tech.png?size=48" title="nkzw-tech" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img src="https://github.com/palerdot.png?size=48" title="palerdot" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img src="https://github.com/PorcoRosso85.png?size=48" title="PorcoRosso85" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img src="https://github.com/primodiumxyz.png?size=48" title="primodiumxyz" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img src="https://github.com/shaneosullivan.png?size=48" title="shaneosullivan" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img src="https://github.com/sudo-self.png?size=48" title="sudo-self" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img src="https://github.com/SuperSonicHub1.png?size=48" title="SuperSonicHub1" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img src="https://github.com/threepointone.png?size=48" title="threepointone" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img src="https://github.com/uptonking.png?size=48" title="uptonking" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img src="https://github.com/ViktorZhurbin.png?size=48" title="ViktorZhurbin" width="48" height="48"></a><a href="https://github.com/wilkerlucio" target="_blank"><img src="https://github.com/wilkerlucio.png?size=48" title="wilkerlucio" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section id="family"><h2 id="meet-the-family">Meet the family</h2><p>TinyBase is part of a group of small libraries designed to help make rich client and local-first apps easier to build. Check out the others!</p><p><img src="https://tinybase.org/favicon.svg?asImg" width="48"><br><b>TinyBase</b><br>A reactive data store and sync engine.</p><p><a href="https://tinywidgets.org" target="_blank"><img src="https://tinywidgets.org/favicon.svg?asImg" width="48"><br><b>TinyWidgets</b></a><br>A collection of tiny, reusable, UI components.</p><p><a href="https://tinytick.org" target="_blank"><img src="https://tinytick.org/favicon.svg?asImg" width="48"><br><b>TinyTick</b></a><br>A tiny but very useful task orchestrator.</p></section><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
278
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.3kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.7kB</em>.</p><p>The optional <a href="https://tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>5.1kB</em>, the ui-react-dom components are another <em>2.6kB</em>, and everything is super fast. Life is easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.3kB</td><td>53.6kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.7kB</td><td>122.5kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/ui-react/">ui-react</a></th><td>5.1kB</td><td>55.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>2.6kB</td><td>21.1kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,328</td><td>2,328</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,517</td><td>2,517</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>1,006</td><td>1,006</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>878</td><td>878</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,099</td></tr><tr><th class="right">Assertions</th><td colspan="3">32,899</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img src="https://github.com/beekeeb.png?size=48" title="beekeeb" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img src="https://github.com/cancelself.png?size=48" title="cancelself" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img src="https://github.com/arpitBhalla.png?size=48" title="arpitBhalla" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/behrends" target="_blank"><img src="https://github.com/behrends.png?size=48" title="behrends" width="48" height="48"></a><a href="https://github.com/betomoedano" target="_blank"><img src="https://github.com/betomoedano.png?size=48" title="betomoedano" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img src="https://github.com/brentvatne.png?size=48" title="brentvatne" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img src="https://github.com/byCedric.png?size=48" title="byCedric" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img src="https://github.com/circadian-risk.png?size=48" title="circadian-risk" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img src="https://github.com/cubecull.png?size=48" title="cubecull" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img src="https://github.com/erwinkn.png?size=48" title="erwinkn" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img src="https://github.com/ezra-en.png?size=48" title="ezra-en" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img src="https://github.com/feychenie.png?size=48" title="feychenie" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img src="https://github.com/flaming-codes.png?size=48" title="flaming-codes" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img src="https://github.com/fostertheweb.png?size=48" title="fostertheweb" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img src="https://github.com/Giulio987.png?size=48" title="Giulio987" width="48" height="48"></a><a href="https://github.com/hi-ogawa" target="_blank"><img src="https://github.com/hi-ogawa.png?size=48" title="hi-ogawa" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img src="https://github.com/itsdevcoffee.png?size=48" title="itsdevcoffee" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img src="https://github.com/jbolda.png?size=48" title="jbolda" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img src="https://github.com/Kayoo-asso.png?size=48" title="Kayoo-asso" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img src="https://github.com/kotofurumiya.png?size=48" title="kotofurumiya" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img src="https://github.com/Kudo.png?size=48" title="Kudo" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img src="https://github.com/learn-anything.png?size=48" title="learn-anything" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img src="https://github.com/lluc.png?size=48" title="lluc" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img src="https://github.com/marksteve.png?size=48" title="marksteve" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img src="https://github.com/miking-the-viking.png?size=48" title="miking-the-viking" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img src="https://github.com/mjamesderocher.png?size=48" title="mjamesderocher" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img src="https://github.com/mouktardev.png?size=48" title="mouktardev" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img src="https://github.com/nickmessing.png?size=48" title="nickmessing" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img src="https://github.com/nikitavoloboev.png?size=48" title="nikitavoloboev" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img src="https://github.com/nkzw-tech.png?size=48" title="nkzw-tech" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img src="https://github.com/palerdot.png?size=48" title="palerdot" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img src="https://github.com/PorcoRosso85.png?size=48" title="PorcoRosso85" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img src="https://github.com/primodiumxyz.png?size=48" title="primodiumxyz" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img src="https://github.com/shaneosullivan.png?size=48" title="shaneosullivan" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img src="https://github.com/sudo-self.png?size=48" title="sudo-self" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img src="https://github.com/SuperSonicHub1.png?size=48" title="SuperSonicHub1" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img src="https://github.com/threepointone.png?size=48" title="threepointone" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img src="https://github.com/uptonking.png?size=48" title="uptonking" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img src="https://github.com/ViktorZhurbin.png?size=48" title="ViktorZhurbin" width="48" height="48"></a><a href="https://github.com/wilkerlucio" target="_blank"><img src="https://github.com/wilkerlucio.png?size=48" title="wilkerlucio" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a></section><hr><p><a class="start" href="https://tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://tinybase.org/demos/">Try the demos</a></p><p><a href="https://tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section id="family"><h2 id="meet-the-family">Meet the family</h2><p>TinyBase is part of a group of small libraries designed to help make rich client and local-first apps easier to build. Check out the others!</p><p><img src="https://tinybase.org/favicon.svg?asImg" width="48"><br><b>TinyBase</b><br>A reactive data store and sync engine.</p><p><a href="https://tinywidgets.org" target="_blank"><img src="https://tinywidgets.org/favicon.svg?asImg" width="48"><br><b>TinyWidgets</b></a><br>A collection of tiny, reusable, UI components.</p><p><a href="https://tinytick.org" target="_blank"><img src="https://tinytick.org/favicon.svg?asImg" width="48"><br><b>TinyTick</b></a><br>A tiny but very useful task orchestrator.</p></section><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://tinybase.org/youtube.webp"></a></section>
package/releases.md CHANGED
@@ -1,4 +1,19 @@
1
- <link rel="preload" as="image" href="https://tinybase.org/partykit.gif"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://tinybase.org/car-analysis.webp"><link rel="preload" as="image" href="https://tinybase.org/movie-database.webp"><p>This is a reverse chronological list of the major TinyBase releases, with highlighted features.</p><hr><h1 id="v6-4">v6.4</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-sqlite/"><code>persister-react-native-sqlite</code></a> module, which allows you to persist data in a React Native SQLite database via the <a href="https://github.com/andpor/react-native-sqlite-storage">react-native-sqlite-storage</a> library.</p><p>Usage should be as simple as this:</p>
1
+ <link rel="preload" as="image" href="https://tinybase.org/partykit.gif"><link rel="preload" as="image" href="https://tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://tinybase.org/store-inspector.webp"><link rel="preload" as="image" href="https://tinybase.org/car-analysis.webp"><link rel="preload" as="image" href="https://tinybase.org/movie-database.webp"><p>This is a reverse chronological list of the major TinyBase releases, with highlighted features.</p><hr><h1 id="v6-5">v6.5</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-mmkv/"><code>persister-react-native-mmkv</code></a> module, which allows you to persist data in a React Native MMKV store via the <a href="https://github.com/mrousavy/react-native-mmkv">react-native-mmkv</a> library.</p><p>Usage should be as simple as this:</p>
2
+
3
+ ```js yolo
4
+ import {MMKV} from 'react-native-mmkv';
5
+ import {createStore} from 'tinybase';
6
+ import {createReactNativeMmkvPersister} from 'tinybase/persisters/persister-react-native-mmkv';
7
+
8
+ const storage = new MMKV();
9
+ const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
10
+ const persister = createReactNativeMmkvPersister(store, storage);
11
+
12
+ await persister.save();
13
+ // Store will be saved to the MMKV store.
14
+ ```
15
+
16
+ <p>A huge shout out to <a href="https://github.com/JeremyBarbet">Jérémy Barbet</a> for this new persister!</p><hr><h1 id="v6-4">v6.4</h1><p>This release includes the new <a href="https://tinybase.org/api/persister-react-native-sqlite/"><code>persister-react-native-sqlite</code></a> module, which allows you to persist data in a React Native SQLite database via the <a href="https://github.com/andpor/react-native-sqlite-storage">react-native-sqlite-storage</a> library.</p><p>Usage should be as simple as this:</p>
2
17
 
3
18
  ```js yolo
4
19
  import {enablePromise, openDatabase} from 'react-native-sqlite-storage';
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -120,7 +120,7 @@ const getUniqueId = (length = 16) =>
120
120
  arrayReduce(
121
121
  getRandomValues(new Uint8Array(length)),
122
122
  (uniqueId, number) => uniqueId + encode(number),
123
- '',
123
+ EMPTY_STRING,
124
124
  );
125
125
 
126
126
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -120,7 +120,7 @@ const getUniqueId = (length = 16) =>
120
120
  arrayReduce(
121
121
  getRandomValues(new Uint8Array(length)),
122
122
  (uniqueId, number) => uniqueId + encode(number),
123
- '',
123
+ EMPTY_STRING,
124
124
  );
125
125
 
126
126
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -147,7 +147,7 @@ const getUniqueId = (length = 16) =>
147
147
  arrayReduce(
148
148
  getRandomValues(new Uint8Array(length)),
149
149
  (uniqueId, number) => uniqueId + encode(number),
150
- '',
150
+ EMPTY_STRING,
151
151
  );
152
152
 
153
153
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -147,7 +147,7 @@ const getUniqueId = (length = 16) =>
147
147
  arrayReduce(
148
148
  getRandomValues(new Uint8Array(length)),
149
149
  (uniqueId, number) => uniqueId + encode(number),
150
- '',
150
+ EMPTY_STRING,
151
151
  );
152
152
 
153
153
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -253,7 +253,7 @@ const getUniqueId = (length = 16) =>
253
253
  arrayReduce(
254
254
  getRandomValues(new Uint8Array(length)),
255
255
  (uniqueId, number) => uniqueId + encode(number),
256
- '',
256
+ EMPTY_STRING,
257
257
  );
258
258
 
259
259
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -253,7 +253,7 @@ const getUniqueId = (length = 16) =>
253
253
  arrayReduce(
254
254
  getRandomValues(new Uint8Array(length)),
255
255
  (uniqueId, number) => uniqueId + encode(number),
256
- '',
256
+ EMPTY_STRING,
257
257
  );
258
258
 
259
259
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -149,7 +149,7 @@ const getUniqueId = (length = 16) =>
149
149
  arrayReduce(
150
150
  getRandomValues(new Uint8Array(length)),
151
151
  (uniqueId, number) => uniqueId + encode(number),
152
- '',
152
+ EMPTY_STRING,
153
153
  );
154
154
 
155
155
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -149,7 +149,7 @@ const getUniqueId = (length = 16) =>
149
149
  arrayReduce(
150
150
  getRandomValues(new Uint8Array(length)),
151
151
  (uniqueId, number) => uniqueId + encode(number),
152
- '',
152
+ EMPTY_STRING,
153
153
  );
154
154
 
155
155
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -118,7 +118,7 @@ const getUniqueId = (length = 16) =>
118
118
  arrayReduce(
119
119
  getRandomValues(new Uint8Array(length)),
120
120
  (uniqueId, number) => uniqueId + encode(number),
121
- '',
121
+ EMPTY_STRING,
122
122
  );
123
123
 
124
124
  const stampNew = (value, hlc) => (hlc ? [value, hlc] : [value]);
@@ -782,7 +782,7 @@ const getUniqueId = (length = 16) =>
782
782
  arrayReduce(
783
783
  getRandomValues(new Uint8Array(length)),
784
784
  (uniqueId, number) => uniqueId + encode(number),
785
- '',
785
+ EMPTY_STRING,
786
786
  );
787
787
 
788
788
  const jsonString = JSON.stringify;