tinybase 5.2.1 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/cjs/es6/min/ui-react/index.cjs +1 -1
  2. package/cjs/es6/min/ui-react/index.cjs.gz +0 -0
  3. package/cjs/es6/min/ui-react/with-schemas/index.cjs +1 -1
  4. package/cjs/es6/min/ui-react/with-schemas/index.cjs.gz +0 -0
  5. package/cjs/es6/min/ui-react-inspector/index.cjs +1 -1
  6. package/cjs/es6/min/ui-react-inspector/index.cjs.gz +0 -0
  7. package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs +1 -1
  8. package/cjs/es6/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
  9. package/cjs/es6/ui-react/index.cjs +10 -1
  10. package/cjs/es6/ui-react/with-schemas/index.cjs +10 -1
  11. package/cjs/es6/ui-react-inspector/index.cjs +1 -1
  12. package/cjs/es6/ui-react-inspector/with-schemas/index.cjs +1 -1
  13. package/cjs/min/ui-react/index.cjs +1 -1
  14. package/cjs/min/ui-react/index.cjs.gz +0 -0
  15. package/cjs/min/ui-react/with-schemas/index.cjs +1 -1
  16. package/cjs/min/ui-react/with-schemas/index.cjs.gz +0 -0
  17. package/cjs/min/ui-react-inspector/index.cjs +1 -1
  18. package/cjs/min/ui-react-inspector/index.cjs.gz +0 -0
  19. package/cjs/min/ui-react-inspector/with-schemas/index.cjs +1 -1
  20. package/cjs/min/ui-react-inspector/with-schemas/index.cjs.gz +0 -0
  21. package/cjs/ui-react/index.cjs +10 -1
  22. package/cjs/ui-react/with-schemas/index.cjs +10 -1
  23. package/cjs/ui-react-inspector/index.cjs +1 -1
  24. package/cjs/ui-react-inspector/with-schemas/index.cjs +1 -1
  25. package/es6/min/ui-react/index.js +1 -1
  26. package/es6/min/ui-react/index.js.gz +0 -0
  27. package/es6/min/ui-react/with-schemas/index.js +1 -1
  28. package/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  29. package/es6/min/ui-react-inspector/index.js +1 -1
  30. package/es6/min/ui-react-inspector/index.js.gz +0 -0
  31. package/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
  32. package/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  33. package/es6/ui-react/index.js +10 -1
  34. package/es6/ui-react/with-schemas/index.js +10 -1
  35. package/es6/ui-react-inspector/index.js +1 -1
  36. package/es6/ui-react-inspector/with-schemas/index.js +1 -1
  37. package/min/ui-react/index.js +1 -1
  38. package/min/ui-react/index.js.gz +0 -0
  39. package/min/ui-react/with-schemas/index.js +1 -1
  40. package/min/ui-react/with-schemas/index.js.gz +0 -0
  41. package/min/ui-react-inspector/index.js +1 -1
  42. package/min/ui-react-inspector/index.js.gz +0 -0
  43. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  44. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  45. package/package.json +1 -1
  46. package/readme.md +13 -13
  47. package/releases.md +23 -23
  48. package/ui-react/index.js +10 -1
  49. package/ui-react/with-schemas/index.js +10 -1
  50. package/ui-react-inspector/index.js +1 -1
  51. package/ui-react-inspector/with-schemas/index.js +1 -1
  52. package/umd/es6/min/ui-react/index.js +1 -1
  53. package/umd/es6/min/ui-react/index.js.gz +0 -0
  54. package/umd/es6/min/ui-react/with-schemas/index.js +1 -1
  55. package/umd/es6/min/ui-react/with-schemas/index.js.gz +0 -0
  56. package/umd/es6/min/ui-react-inspector/index.js +1 -1
  57. package/umd/es6/min/ui-react-inspector/index.js.gz +0 -0
  58. package/umd/es6/min/ui-react-inspector/with-schemas/index.js +1 -1
  59. package/umd/es6/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  60. package/umd/es6/ui-react/index.js +12 -1
  61. package/umd/es6/ui-react/with-schemas/index.js +12 -1
  62. package/umd/es6/ui-react-inspector/index.js +2 -1
  63. package/umd/es6/ui-react-inspector/with-schemas/index.js +2 -1
  64. package/umd/min/ui-react/index.js +1 -1
  65. package/umd/min/ui-react/index.js.gz +0 -0
  66. package/umd/min/ui-react/with-schemas/index.js +1 -1
  67. package/umd/min/ui-react/with-schemas/index.js.gz +0 -0
  68. package/umd/min/ui-react-inspector/index.js +1 -1
  69. package/umd/min/ui-react-inspector/index.js.gz +0 -0
  70. package/umd/min/ui-react-inspector/with-schemas/index.js +1 -1
  71. package/umd/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  72. package/umd/ui-react/index.js +12 -1
  73. package/umd/ui-react/with-schemas/index.js +12 -1
  74. package/umd/ui-react-inspector/index.js +2 -1
  75. package/umd/ui-react-inspector/with-schemas/index.js +2 -1
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,n="",a=l(n),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Has",h="Ids",m="Table",g=m+"s",p=m+h,b="Row",I=b+"Count",f=b+h,y="Cell",w=y+h,C="Value",v=C+"s",k=C+h,T="currentTarget",S="value",x=e=>n+e,V=globalThis.window,R=Math,q=R.min,M=R.floor,N=isFinite,L=e=>null==e,E=(e,t,s)=>L(e)?s?.():t(e),z=e=>e==a||e==r,O=e=>l(e)==i,$=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),F=e=>e.length,J=e=>{throw Error(e)},{PureComponent:P,Fragment:B,createElement:D,useCallback:Q,useLayoutEffect:j,useRef:H,useState:W}=t,U=(e,...t)=>L(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),X=(e,t)=>e.map(t),Y=e=>0==F(e),Z=(e,...t)=>e.push(...t),_=e=>e.shift(),ee=Object,te=e=>ee.getPrototypeOf(e),se=ee.entries,le=ee.isFrozen,ne=e=>!L(e)&&E(te(e),(e=>e==ee.prototype||L(te(e))),(()=>!0)),ae=ee.keys,re=ee.freeze,oe=(e=[])=>ee.fromEntries(e),ie=(e,t)=>t in e,de=(e,t)=>(delete e[t],e),ue=(e,t)=>X(se(e),(([e,s])=>t(s,e))),ce=e=>ne(e)&&0==(e=>F(ae(e)))(e),he=(e,t,s,l=0)=>L(e)||!ne(e)||!l&&ce(e)||le(e)?(s?.(),!1):(ue(e,((s,l)=>{t(s,l)||de(e,l)})),!!l||!ce(e)),me=JSON.stringify,ge=JSON.parse,pe=e=>me(e,((e,t)=>t instanceof Map?ee.fromEntries([...t]):t)),be="tinybaseInspector",Ie="TinyBase Inspector",fe=["left","top","bottom","right","full"],ye="state",we="sort",Ce="open",ve="position",ke=Ce,Te="editable",Se=(...e)=>pe(e),xe=(e,t)=>X(G(e),t),Ve=(e,t)=>[!!s.useCell(ye,e,Te,t),Q((s=>{t.setCell(ye,e,Te,(e=>!e)),s.preventDefault()}),[t,e])],Re="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",qe='content:url("',Me=qe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ne='</svg>")',Le=qe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Ee=X([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Me+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Ne)),ze=Me+"<path d='M20 20l60 60M20 80l60-60' />"+Ne,Oe=Me+`<path d='${Re}' />`+Ne,$e=Me+`<path d='${Re}M20 20l60 60' />`+Ne,Ae="*::-webkit-scrollbar",Fe=((e,t="")=>e.join(t))(ue({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Le,...oe(X(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...oe(X(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Le,"header>img:nth-of-type(6)":ze,...oe(X(Ee,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Oe,"details[open]>summary img.done":$e,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Je=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!0),[],e);return s.useValue(ke,e)?null:D("img",{onClick:l,title:Ie,"data-position":t})},Pe=({uniqueId:e,summary:t,editable:l,handleEditable:n,children:a,s:r})=>{const o=!!s.useCell(ye,e,Ce,r),i=s.useSetCellCallback(ye,e,Ce,(e=>e[T].open),[],r);return D("details",{open:o,onToggle:i},D("summary",null,t,n?D("img",{onClick:n,className:l?"done":"edit"}):null),a)},Be=e=>{const t=l(e);return z(t)||t==o&&N(e)?t:void 0},De=(e,t,s,l,n)=>L(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Qe=(e,t,s)=>L(s)?e.delValue(t):e.setValue(t,s),je=(e,t,s,l)=>e==a?t:e==o?s:l,{useCallback:He,useMemo:We,useState:Ue}=t,Ge="editable",Ke=(e,t)=>X(s.useTableCellIds(e,t),(t=>e+"."+t)),Xe=(e,t,s)=>{const l=He(e,t);return s?l:void 0},Ye=(...e)=>We((()=>e),e),Ze=(e,t)=>We((()=>({store:e,tableId:t})),[e,t]),_e=(e,t)=>We((()=>({queries:e,queryId:t})),[e,t]),et=(e,t=!1,s,l=0,n,a,r,o)=>{const[[i,d,u],c]=Ue([e,t,l]),h=He((e=>{c(e),o?.(e)}),[o]),m=Xe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=He((e=>h([i,d,e])),[h,i,d]),p=!0===r?mt:r;return[[i,d,u],m,We((()=>!1===r?null:D(p,{offset:u,limit:n,total:a,onChange:g})),[r,p,u,n,a,g])]},tt=(e,t,s)=>We((()=>{const n=t??e;return r=$(n)?oe(X(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:s,...(n=e,l(n)==a?{label:e}:e)};var n},oe(ue(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,s,e]),st=({className:e,headerRow:t,idColumn:s,params:[l,n,a,r,o,i]})=>D("table",{className:e},i?D("caption",null,i):null,!1===t?null:D("thead",null,D("tr",null,!1===s?null:D(lt,{sort:r??[],label:"Id",onClick:o}),ue(l,(({label:e},t)=>D(lt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),D("tbody",null,X(a,(e=>D("tr",{key:e},!1===s?null:D("th",null,e),ue(l,(({component:t,getComponentProps:s},l)=>D("td",{key:l},D(t,{...U(s,e,l),...n,rowId:e,cellId:l}))))))))),lt=({cellId:e,sort:[t,s],label:l=e??n,onClick:a})=>D("th",{onClick:Xe((()=>a?.(e)),[a,e],a),className:L(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},L(s)||t!=e?null:(s?"↓":"↑")+" ",l),nt=({localRowId:e,params:[l,n,a,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return D("tr",null,!1===l?null:D(t.Fragment,null,D("th",null,e),D("th",null,u)),ue(n,(({component:t,getComponentProps:s},l)=>{const[n,o]=l.split(".",2),i=n===a?e:n===r?u:null;return L(i)?null:D("td",{key:l},D(t,{...U(s,i,o),store:d,tableId:n,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:n=!0})=>{const[i,d]=Ue(),[u,c]=Ue(),[h,m]=Ue(),[g,p]=Ue(),[b,I]=Ue();u!==e&&(d(Be(e)),c(e),m(e+""),p(Number(e)||0),I(!!e));const f=He(((e,s)=>{s(e),c(e),t(e)}),[t]),y=He((()=>{if(!l?.()){const e=je(i,o,r,a),s=je(e,h,g,b);d(e),c(s),t(s)}}),[l,t,h,g,b,i]);return D("div",{className:s},n?D("button",{className:i,onClick:y},i):null,je(i,D("input",{key:i,value:h,onChange:He((e=>f(e[T][S]+"",m)),[f])}),D("input",{key:i,type:"number",value:g,onChange:He((e=>f(Number(e[T][S]||0),p)),[f])}),D("input",{key:i,type:"checkbox",checked:b,onChange:He((e=>f(!!e[T].checked,I)),[f])})))},rt=({tableId:e,cellId:t,descending:l,offset:n,limit:a,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,p]=et(t,l,i,n,a,s.useRowCount(e,r),d,u);return D(st,{...h,params:Ye(tt(s.useTableCellIds(e,r),c,o?ct:s.CellView),Ze(r,e),s.useSortedRowIds(e,...m,a,r),m,g,p)})},ot=({store:e,editable:t=!1,valueComponent:l=(t?ht:s.ValueView),getValueComponentProps:n,className:a,headerRow:r,idColumn:o})=>D("table",{className:a},!1===r?null:D("thead",null,D("tr",null,!1===o?null:D("th",null,"Id"),D("th",null,C))),D("tbody",null,X(s.useValueIds(e),(t=>D("tr",{key:t},!1===o?null:D("th",null,t),D("td",null,D(l,{...U(n,t),valueId:t,store:e}))))))),it=({indexId:e,sliceId:t,indexes:l,editable:n,customCells:a,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return D(st,{...r,params:Ye(tt(s.useTableCellIds(d,i),a,n?ct:s.CellView),Ze(i,d),s.useSliceRowIds(e,t,o))})},dt=({relationshipId:e,relationships:l,editable:n,customCells:a,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=tt([...Ke(c,u),...Ke(h,u)],a,n?ct:s.CellView),g=Ye(i,m,c,h,e,d,u);return D("table",{className:r},!1===o?null:D("thead",null,D("tr",null,!1===i?null:D(t.Fragment,null,D("th",null,c,".Id"),D("th",null,h,".Id")),ue(m,(({label:e},t)=>D("th",{key:t},e))))),D("tbody",null,X(s.useRowIds(c,u),(e=>D(nt,{key:e,localRowId:e,params:g})))))},ut=({queryId:e,cellId:t,descending:l,offset:n,limit:a,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=et(t,l,o,n,a,s.useResultRowCount(e,r),i,u);return D(st,{...c,params:Ye(tt(s.useResultTableCellIds(e,r),d,s.ResultCellView),_e(r,e),s.useResultSortedRowIds(e,...h,a,r),h,m,g)})},ct=({tableId:e,rowId:t,cellId:l,store:n,className:a,showType:r})=>D(at,{thing:s.useCell(e,t,l,n),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],n),className:a??Ge+y,showType:r,hasSchema:s.useStoreOrStoreById(n)?.hasTablesSchema}),ht=({valueId:e,store:t,className:l,showType:n})=>D(at,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Ge+C,showType:n,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),mt=({onChange:e,total:s,offset:l=0,limit:n=s,singular:a="row",plural:r=a+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Xe((()=>e(l-n)),[e,l,n],l>0),i=Xe((()=>e(l+n)),[e,l,n],l+n<s);return D(t.Fragment,null,s>n&&D(t.Fragment,null,D("button",{className:"previous",disabled:0==l,onClick:o},"←"),D("button",{className:"next",disabled:l+n>=s,onClick:i},"→"),l+1," to ",q(s,l+n)," of "),s," ",1!=s?r:a)},gt=({indexes:e,indexesId:t,indexId:l,s:n})=>D(Pe,{uniqueId:Se("i",t,l),summary:"Index: "+l,s:n},X(s.useSliceIds(l,e),(s=>D(pt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:n,key:s})))),pt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:n})=>{const a=Se("i",t,s,l),[r,o]=Ve(a,n);return D(Pe,{uniqueId:a,summary:"Slice: "+l,editable:r,handleEditable:o,s:n},D(it,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),n=s.useIndexIds(l);return L(l)?null:D(Pe,{uniqueId:Se("i",e),summary:"Indexes: "+(e??u),s:t},Y(n)?"No indexes defined":xe(n,(s=>D(gt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},It=({metrics:e,metricId:t})=>D("tr",null,D("th",null,t),D("td",null,e?.getTableId(t)),D("td",null,s.useMetric(t,e))),ft=({metricsId:e,s:t})=>{const l=s.useMetrics(e),n=s.useMetricIds(l);return L(l)?null:D(Pe,{uniqueId:Se("m",e),summary:"Metrics: "+(e??u),s:t},Y(n)?"No metrics defined":D("table",null,D("thead",null,D("th",null,"Metric Id"),D("th",null,"Table Id"),D("th",null,"Metric")),D("tbody",null,X(n,(e=>D(It,{metrics:l,metricId:e,key:e}))))))},yt=({queries:e,queriesId:t,queryId:l,s:n})=>{const a=Se("q",t,l),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n);return D(Pe,{uniqueId:a,summary:"Query: "+l,s:n},D(ut,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},wt=({queriesId:e,s:t})=>{const l=s.useQueries(e),n=s.useQueryIds(l);return L(l)?null:D(Pe,{uniqueId:Se("q",e),summary:"Queries: "+(e??u),s:t},Y(n)?"No queries defined":xe(n,(s=>D(yt,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},Ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const n=Se("r",t,s),[a,r]=Ve(n,l);return D(Pe,{uniqueId:n,summary:"Relationship: "+s,editable:a,handleEditable:r,s:l},D(dt,{relationshipId:s,relationships:e,editable:a}))},vt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),n=s.useRelationshipIds(l);return L(l)?null:D(Pe,{uniqueId:Se("r",e),summary:"Relationships: "+(e??u),s:t},Y(n)?"No relationships defined":xe(n,(s=>D(Ct,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},kt=({tableId:e,store:t,storeId:l,s:n})=>{const a=Se("t",l,e),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n),[u,c]=Ve(a,n);return D(Pe,{uniqueId:a,summary:m+": "+e,editable:u,handleEditable:c,s:n},D(rt,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},Tt=({store:e,storeId:t,s:l})=>{const n=Se("v",t),[a,r]=Ve(n,l);return Y(s.useValueIds(e))?null:D(Pe,{uniqueId:n,summary:v,editable:a,handleEditable:r,s:l},D(ot,{store:e,editable:a}))},St=({storeId:e,s:t})=>{const l=s.useStore(e),n=s.useTableIds(l);return L(l)?null:D(Pe,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??u),s:t},D(Tt,{storeId:e,store:l,s:t}),xe(n,(s=>D(kt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},xt=({s:e})=>{const t=H(null),l=H(0),[n,a]=W(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);j((()=>{const e=t.current;if(e&&!n){const t=new MutationObserver((()=>{e.scrollWidth>=M(r)+e.clientWidth&&e.scrollHeight>=M(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[n,r,o]);const i=Q((t=>{const{scrollLeft:s,scrollTop:n}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{a(!0),e.setPartialValues({scrollLeft:s,scrollTop:n})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),g=s.useIndexesIds(),p=s.useRelationships(),b=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return L(d)&&Y(u)&&L(c)&&Y(h)&&L(m)&&Y(g)&&L(p)&&Y(b)&&L(I)&&Y(f)?D("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):D("article",{ref:t,onScroll:i},D(St,{s:e}),X(u,(t=>D(St,{storeId:t,s:e,key:t}))),D(ft,{s:e}),X(h,(t=>D(ft,{metricsId:t,s:e,key:t}))),D(bt,{s:e}),X(g,(t=>D(bt,{indexesId:t,s:e,key:t}))),D(vt,{s:e}),X(b,(t=>D(vt,{relationshipsId:t,s:e,key:t}))),D(wt,{s:e}),X(f,(t=>D(wt,{queriesId:t,s:e,key:t}))))};class Vt extends P{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?D("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Rt=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!1),[],e),n=s.useSetValueCallback(ve,(e=>Number(e[T].dataset.id)),[],e);return D("header",null,D("img",{title:Ie}),D("span",null,Ie),X(fe,((e,s)=>s==t?null:D("img",{onClick:n,"data-id":s,title:"Dock to "+e,key:s}))),D("img",{onClick:l,title:"Close"}))},qt=({s:e})=>{const t=s.useValue(ve,e)??1;return s.useValue(ke,e)?D("main",{"data-position":t},D(Rt,{s:e}),D(Vt,null,D(xt,{s:e}))):null},Mt=e=>t=>{return s=(t,s)=>t+e(s),At(t).reduce(s,0);var s},Nt=e=>e?.size??0,Lt=Mt(Nt),Et=Mt(Lt),zt=Mt(Et),Ot=(e,t)=>e?.has(t)??!1,$t=e=>L(e)||0==Nt(e),At=e=>[...e?.values()??[]],Ft=e=>e.clear(),Jt=(e,t)=>e?.forEach(t),Pt=(e,t)=>e?.delete(t),Bt=e=>new Map(e),Dt=e=>[...e?.keys()??[]],Qt=(e,t)=>e?.get(t),jt=(e,t)=>Jt(e,((e,s)=>t(s,e))),Ht=(e,t,s)=>L(s)?(Pt(e,t),e):e?.set(t,s),Wt=(e,t,s,l)=>(Ot(e,t)?l?.(Qt(e,t)):Ht(e,t,s()),Qt(e,t)),Ut=(e,t,s,l=Ht)=>(ue(t,((t,l)=>s(e,l,t))),jt(e,(s=>ie(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const n={};return Jt(e,((e,a)=>{if(!s?.(e,a)){const s=t?t(e,a):e;l?.(s)||(n[a]=s)}})),n},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),$t,ce),Xt=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),$t,ce),Yt=(e,t)=>{const s=Bt();return Jt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Zt=e=>Yt(e,Yt),_t=e=>Yt(e,Zt),es=(e,t,s,l,n=0)=>E((s?Wt:Qt)(e,t[n],n>F(t)-2?s:Bt),(a=>{if(n>F(t)-2)return l?.(a)&&Ht(e,t[n]),a;const r=es(a,t,s,l,n+1);return $t(a)&&Ht(e,t[n]),r})),ts=Bt(),ss=Bt(),ls="storage",ns=e=>new Set($(e)||L(e)?e:[e]),as=(e,t)=>e?.add(t),rs=/^\d+$/,os=()=>{const e=[];let t=0;return[s=>(s?_(e):null)??n+t++,t=>{rs.test(t)&&F(e)<1e3&&Z(e,t)}]},is=e=>[e,e],ds=(e,t=Lt)=>t(e[0])+t(e[1]),us=()=>[Bt(),Bt()],cs=e=>[...e],hs=([e,t])=>e===t;Bt(X("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(n),((e,t)=>[e,t])));const ms=(e,t,s)=>Ht(e,t,Qt(e,t)==-s?void 0:s),gs=()=>{let e,t,s=!1,l=!1,a=0,r=[];const i=Bt(),h=Bt(),T=Bt(),S=Bt(),V=Bt(),R=Bt(),q=Bt(),M=Bt(),N=Bt(),J=Bt(),P=Bt(),B=Bt(),D=Bt(),Q=Bt(),j=ns(),H=Bt(),W=Bt(),U=Bt(),Y=Bt(),_=us(),ee=us(),te=us(),se=us(),le=us(),ne=us(),ae=us(),oe=us(),me=us(),be=us(),Ie=us(),fe=us(),ye=us(),we=us(),Ce=us(),ve=us(),ke=us(),Te=us(),Se=us(),xe=us(),Ve=us(),Re=us(),qe=Bt(),Me=us(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=os(),l=Bt();return[(s,a,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return Ht(l,d,[s,a,r,o,i]),as(es(a,r??[n],ns),d),d},(t,s,...a)=>K(((e,t=[n])=>{const s=[],l=(e,n)=>n==F(t)?Z(s,e):null===t[n]?Jt(e,(e=>l(e,n+1))):K([t[n],null],(t=>l(Qt(e,t),n+1)));return l(e,0),s})(t,s),(t=>Jt(t,(t=>Qt(l,t)[0](e,...s??[],...a))))),e=>E(Qt(l,e),(([,t,a])=>(es(t,a??[n],void 0,(t=>(Pt(t,e),$t(t)?1:0))),Ht(l,e),s(e),a))),t=>E(Qt(l,t),(([t,,s=[],l,n])=>{const a=(...r)=>{const o=F(r);o==F(s)?t(e,...r,...n(r)):L(s[o])?K(l[o]?.(...r)??[],(e=>a(...r,e))):a(...r,s[o])};a()}))]})(),Oe=e=>{if(!he(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!z(t)&&t!=o||(Be(e[u])!=t&&de(e,u),0))},$e=$,Ae=(t,s)=>(!e||Ot(P,s)||bt(s))&&he(t,((e,t)=>Fe(s,t,e)),(()=>bt(s))),Fe=(e,t,s,l)=>he(l?s:He(s,e,t),((l,n)=>E(Je(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>bt(e,t))),Je=(t,s,l,n)=>e?E(Qt(Qt(P,t),l),(e=>Be(n)!=e[d]?bt(t,s,l,n,e[u]):n),(()=>bt(t,s,l,n))):L(Be(n))?bt(t,s,l,n):n,Pe=(e,t)=>he(t?e:We(e),((t,s)=>E(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?E(Qt(D,e),(t=>Be(s)!=t[d]?It(e,s,t[u]):s),(()=>It(e,s))):L(Be(s))?It(e,s):s,He=(e,t,s)=>(E(Qt(B,t),(([l,n])=>{Jt(l,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(n,(l=>{ie(e,l)||bt(t,s,l)}))})),e),We=e=>(t&&(Jt(Q,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(j,(t=>{ie(e,t)||It(t)}))),e),Ue=e=>Ut(P,e,((e,t,s)=>{const l=Bt(),n=ns();Ut(Wt(P,t,Bt),s,((e,t,s)=>{Ht(e,t,s),E(s[u],(e=>Ht(l,t,e)),(()=>as(n,t)))})),Ht(B,t,[l,n])}),((e,t)=>{Ht(P,t),Ht(B,t)})),Ge=e=>Ut(D,e,((e,t,s)=>{Ht(D,t,s),E(s[u],(e=>Ht(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{Ht(D,t),Ht(Q,t),Pt(j,t)})),Ke=e=>ce(e)?Rs():ks(e),Xe=e=>Ut(U,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Ut(Wt(U,e,(()=>(ut(e,1),Ht(H,e,os()),Ht(W,e,Bt()),Bt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,n)=>Ut(Wt(t,s,(()=>(ct(e,s,1),Bt()))),l,((t,l,n)=>_e(e,s,t,l,n)),((l,a)=>it(e,t,s,l,a,n))),_e=(e,t,s,l,n)=>{Ot(s,l)||ht(e,t,l,1);const a=Qt(s,l);n!==a&&(mt(e,t,l,a,n),Ht(s,l,n))},et=(e,t,s,l,n)=>E(Qt(t,s),(t=>_e(e,s,t,l,n)),(()=>Ze(e,t,s,He({[l]:n},e,s)))),tt=e=>ce(e)?Ns():Ts(e),st=e=>Ut(Y,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{Ot(Y,e)||gt(e,1);const s=Qt(Y,e);t!==s&&(pt(e,s,t),Ht(Y,e,t))},nt=(e,t)=>{const[s]=Qt(H,e),l=s(t);return Ot(Qt(U,e),l)?nt(e,t):l},at=e=>Qt(U,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Qt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,n,a)=>{const r=Qt(Qt(B,e)?.[0],n);if(!L(r)&&!a)return _e(e,s,l,n,r);const o=t=>{mt(e,s,t,Qt(l,t)),ht(e,s,t,-1),Ht(l,t)};L(r)?o(n):jt(l,o),$t(l)&&(ct(e,s,-1),$t(Ht(t,s))&&(ut(e,-1),Ht(U,e),Ht(H,e),Ht(W,e)))},dt=e=>{const t=Qt(Q,e);if(!L(t))return lt(e,t);pt(e,Qt(Y,e)),gt(e,-1),Ht(Y,e)},ut=(e,t)=>ms(i,e,t),ct=(e,t,s)=>ms(Wt(S,e,Bt),t,s)&&Ht(T,e,Wt(T,e,(()=>0))+s),ht=(e,t,s,l)=>{const n=Qt(W,e),a=Qt(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&ms(Wt(h,e,Bt),s,l),Ht(n,s,a!=-l?a+l:null),ms(Wt(Wt(V,e,Bt),t,Bt),s,l)},mt=(e,t,s,l,n)=>{Wt(Wt(Wt(R,e,Bt),t,Bt),s,(()=>[l,0]))[1]=n,r[3]?.(e,t,s,n)},gt=(e,t)=>ms(q,e,t),pt=(e,t,s)=>{Wt(M,e,(()=>[t,0]))[1]=s,r[4]?.(e,s)},bt=(e,t,s,l,n)=>(Z(Wt(Wt(Wt(N,e,Bt),t,Bt),s,(()=>[])),l),n),It=(e,t,s)=>(Z(Wt(J,e,(()=>[])),t),s),ft=(e,t,s)=>E(Qt(Qt(Qt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ss(e,t,s))])),yt=e=>E(Qt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ps(e))])),wt=e=>$t(N)||$t(ve[e])?0:Jt(e?_t(N):N,((t,s)=>Jt(t,((t,l)=>Jt(t,((t,n)=>Le(ve[e],[s,l,n],t))))))),Ct=e=>$t(J)||$t(ke[e])?0:Jt(e?Yt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!$t(e))return Le(t,l,(()=>Gt(e))),jt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=bs();t!=s&&Le(_[e],void 0,t);const l=$t(be[e]),n=$t(ye[e])&&$t(we[e])&&$t(me[e])&&$t(Ie[e])&&$t(ne[e])&&$t(ae[e])&&$t(oe[e])&&l&&$t(te[e])&&$t(se[e]),a=$t(Ce[e])&&$t(fe[e])&&$t(le[e])&&$t(ee[e]);if(!n||!a){const t=e?[Yt(i),Zt(h),Yt(T),Zt(S),_t(V),_t(R)]:[i,h,T,S,V,R];if(!n){vt(t[0],te[e],se[e]),Jt(t[1],((t,s)=>vt(t,ne[e],ae[e],[s]))),Jt(t[2],((t,s)=>{0!=t&&Le(oe[e],[s],qt(s))}));const s=ns();Jt(t[3],((t,n)=>{vt(t,me[e],Ie[e],[n])&&!l&&(Le(be[e],[n,null]),as(s,n))})),l||Jt(t[5],((t,l)=>{if(!Ot(s,l)){const s=ns();Jt(t,(e=>Jt(e,(([t,l],n)=>l!==t?as(s,n):Pt(e,n))))),Jt(s,(t=>Le(be[e],[l,t])))}})),Jt(t[4],((t,s)=>Jt(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!a){let s;Jt(t[5],((t,l)=>{let n;Jt(t,((t,a)=>{let r;Jt(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,a,i],o,t,ft),s=n=r=1)})),r&&Le(fe[e],[l,a],ft)})),n&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},Tt=e=>{const t=Cs();t!=l&&Le(Te[e],void 0,t);const s=$t(xe[e])&&$t(Ve[e]),n=$t(Re[e])&&$t(Se[e]);if(!s||!n){const t=e?[Yt(q),Yt(M)]:[q,M];if(s||vt(t[0],xe[e],Ve[e]),!n){let s;Jt(t[1],(([t,l],n)=>{l!==t&&(Le(Re[e],[n],l,t,yt),s=1)})),s&&Le(Se[e],void 0,yt)}}},St=(e,...t)=>(zs((()=>e(...X(t,x)))),As),xt=()=>Xt(U),Vt=()=>Dt(U),Rt=e=>Dt(Qt(W,x(e))),qt=e=>Nt(Qt(U,x(e))),Mt=e=>Dt(Qt(U,x(e))),At=(e,t,s,l=0,n)=>{return X(A(G((a=Qt(U,x(e)),r=(e,s)=>[L(t)?s:Qt(e,x(t)),s],X([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,L(n)?n:l+n),(([,e])=>e));var a,r},ts=(e,t)=>Dt(Qt(Qt(U,x(e)),x(t))),ss=(e,t,s)=>Qt(Qt(Qt(U,x(e)),x(t)),x(s)),ls=()=>Gt(Y),rs=()=>Dt(Y),ps=e=>Qt(Y,x(e)),bs=()=>!$t(U),Is=e=>Ot(U,x(e)),fs=(e,t)=>Ot(Qt(W,x(e)),x(t)),ys=(e,t)=>Ot(Qt(U,x(e)),x(t)),ws=(e,t,s)=>Ot(Qt(Qt(U,x(e)),x(t)),x(s)),Cs=()=>!$t(Y),vs=e=>Ot(Y,x(e)),ks=e=>St((()=>(e=>he(e,Ae,bt))(e)?Xe(e):0)),Ts=e=>St((()=>Pe(e)?st(e):0)),Ss=e=>{try{Ke(ge(e))}catch{}return As},xs=t=>St((()=>{if((e=he(t,(e=>he(e,Oe))))&&(Ue(t),!$t(U))){const e=xt();Rs(),ks(e)}})),Vs=e=>St((()=>{if(t=(e=>he(e,Oe))(e)){const s=ls();Es(),Ns(),t=!0,Ge(e),Ts(s)}})),Rs=()=>St((()=>Xe({}))),qs=e=>St((e=>Ot(U,e)?rt(e):0),e),Ms=(e,t)=>St(((e,t)=>E(Qt(U,e),(s=>Ot(s,t)?ot(e,s,t):0))),e,t),Ns=()=>St((()=>st({}))),Ls=()=>St((()=>{Ue({}),e=!1})),Es=()=>St((()=>{Ge({}),t=!1})),zs=(e,t)=>{if(-1!=a){Os();const s=e();return $s(t),s}},Os=()=>(-1!=a&&a++,1==a&&(r[0]?.(),Le(qe)),As),$s=e=>(a>0&&(a--,0==a&&(a=1,wt(1),$t(R)||kt(1),Ct(1),$t(M)||Tt(1),e?.(As)&&(Jt(R,((e,t)=>Jt(e,((e,s)=>Jt(e,(([e],l)=>De(As,t,s,l,e))))))),Ft(R),Jt(M,(([e],t)=>Qe(As,t,e))),Ft(M)),Le(Me[0],void 0),a=-1,wt(0),$t(R)||kt(0),Ct(0),$t(M)||Tt(0),r[1]?.(),Le(Me[1],void 0),r[2]?.(),a=0,s=bs(),l=Cs(),K([i,h,T,S,V,R,N,q,M,J],Ft))),As),As={getContent:()=>[xt(),ls()],getTables:xt,getTableIds:Vt,getTable:e=>Kt(Qt(U,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:Mt,getSortedRowIds:At,getRow:(e,t)=>Gt(Qt(Qt(U,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ls,getValueIds:rs,getValue:ps,hasTables:bs,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>pe(U),getValuesJson:()=>pe(Y),getJson:()=>pe([U,Y]),getTablesSchemaJson:()=>pe(P),getValuesSchemaJson:()=>pe(D),getSchemaJson:()=>pe([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>St((()=>$e(e)?(([e,t])=>{(ce(e)?Rs:ks)(e),(ce(t)?Ns:Ts)(t)})(e):0)),setTables:ks,setTable:(e,t)=>St((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>St(((e,t)=>Fe(e,t,s)?Ze(e,at(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,at(e),l=nt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>St(((e,t)=>{if(Fe(e,t,s,1)){const l=at(e);ue(s,((s,n)=>et(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>St(((e,t,s)=>E(Je(e,t,s,O(l)?l(ss(e,t,s)):l),(l=>et(e,at(e),t,s,l)))),e,t,s),setValues:Ts,setPartialValues:e=>St((()=>Pe(e,1)?ue(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>St((e=>E(je(e,O(t)?t(ps(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>St((()=>{ue(e[0],((e,t)=>L(e)?qs(t):ue(e,((e,s)=>L(e)?Ms(t,s):ue(e,((e,l)=>De(As,t,s,l,e))))))),ue(e[1],((e,t)=>Qe(As,t,e)))})),setTablesJson:Ss,setValuesJson:e=>{try{tt(ge(e))}catch{}return As},setJson:e=>St((()=>{try{const[t,s]=ge(e);Ke(t),tt(s)}catch{Ss(e)}})),setTablesSchema:xs,setValuesSchema:Vs,setSchema:(e,t)=>St((()=>{xs(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>St(((e,t,s)=>E(Qt(U,e),(n=>E(Qt(n,t),(a=>Ot(a,s)?it(e,n,t,a,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>St((e=>Ot(Y,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>St((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Qt(i,t)?void 0:Gt(e,((e,s)=>-1===Qt(Qt(S,t),s)?void 0:Gt(e,(([,e])=>e),(e=>hs(e)))),$t,ce)),$t,ce),Gt(M,(([,e])=>e),(e=>hs(e))),1],getTransactionLog:()=>[!$t(R),!$t(M),Xt(R,cs,hs),Xt(N),Gt(M,cs,hs),Gt(J),Gt(i),Kt(S),Xt(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Jt(U,((t,s)=>e(s,(e=>Jt(t,((t,s)=>e(s,(e=>jt(t,e))))))))),forEachTableCell:(e,t)=>jt(Qt(W,x(e)),t),forEachRow:(e,t)=>Jt(Qt(U,x(e)),((e,s)=>t(s,(t=>jt(e,t))))),forEachCell:(e,t,s)=>jt(Qt(Qt(U,x(e)),x(t)),s),forEachValue:e=>jt(Y,e),addSortedRowIdsListener:(e,t,s,l,n,a,r)=>{let o=At(e,t,s,l,n);return Ne((()=>{const r=At(e,t,s,l,n);var i,d,u;d=o,F(i=r)===F(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,a(As,e,t,s,l,n,o))}),be[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:ds(_),tables:ds(ee),tableIds:ds(te),hasTable:ds(se),table:ds(le),tableCellIds:ds(ne),hasTableCell:ds(ae,Et),rowCount:ds(oe),rowIds:ds(me),sortedRowIds:ds(be),hasRow:ds(Ie,Et),row:ds(fe,Et),cellIds:ds(ye,Et),hasCell:ds(we,zt),cell:ds(Ce,zt),invalidCell:ds(ve,zt),hasValues:ds(Te),values:ds(Se),valueIds:ds(xe),hasValue:ds(Ve),value:ds(Re),invalidValue:ds(ke),transaction:Lt(qe)+ds(Me)}),isMergeable:()=>!1,createStore:gs,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,n)=>r=[e,t,s,l,n]};return ue({[c+g]:[0,_,[],()=>[bs()]],[g]:[0,ee],[p]:[0,te],[c+m]:[1,se,[Vt],e=>[Is(...e)]],[m]:[1,le,[Vt]],[m+w]:[1,ne,[Vt]],[c+m+y]:[2,ae,[Vt,Rt],e=>[fs(...e)]],[I]:[1,oe,[Vt]],[f]:[1,me,[Vt]],[c+b]:[2,Ie,[Vt,Mt],e=>[ys(...e)]],[b]:[2,fe,[Vt,Mt]],[w]:[2,ye,[Vt,Mt]],[c+y]:[3,we,[Vt,Mt,ts],e=>[ws(...e)]],[y]:[3,Ce,[Vt,Mt,ts],e=>is(ss(...e))],InvalidCell:[3,ve],[c+v]:[0,Te,[],()=>[Cs()]],[v]:[0,Se],[k]:[0,xe],[c+C]:[1,Ve,[rs],e=>[vs(...e)]],[C]:[1,Re,[rs],e=>is(ps(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],n)=>{As["add"+n+"Listener"]=(...n)=>Ne(n[e],t[n[e+1]?1:0],e>0?A(n,0,e):void 0,s,l)})),re(As)};e.Inspector=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(gs),n=fe.indexOf(e);return s.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,n,a,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Wt(ts,i,(()=>0)),Wt(ss,i,(()=>[]));const[p,b,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ce(e)||!ce(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ce(e)||!ce(t),t.setContent]:J("Store type not supported by this Persister"))(r,e),w=t=>{(p&&$(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await S((async()=>{try{const e=await t();$(e)?w(e):J("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),x),v=()=>(u&&(n(u),u=void 0),x),k=async e=>(1!=h&&(h=2,g++,await S((async()=>{try{await s(b,e)}catch(e){}h=0}))),x),T=()=>(E(c,e.delListener),c=void 0,x),S=async(...e)=>(Z(Qt(ss,i),...e),await(async()=>{if(!Qt(ts,i)){for(Ht(ts,i,1);!L(d=_(Qt(ss,i)));)try{await d()}catch(e){}Ht(ts,i,0)}})(),x),x={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return x},stopAutoLoad:v,isAutoLoading:()=>!L(u),save:k,startAutoSave:async()=>(await T().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),x),stopAutoSave:T,isAutoSaving:()=>!L(c),schedule:S,getStore:()=>e,destroy:()=>(Qt(ss,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return re(x)})(e,(async()=>{return e=s.getItem(t),ge(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),me(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(ge(l.newValue))}catch{e()}};return V.addEventListener(ls,l),l}),(e=>V.removeEventListener(ls,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==n?1:n,open:!!t}]),await e.startAutoSave()})),D(B,null,D("aside",{id:be},D(Je,{s:l}),D(qt,{s:l})),D("style",null,Fe))}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("../ui-react/index.js")):"function"==typeof define&&define.amd?define(["exports","react","../ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactInspector={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,n="",a=l(n),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Has",h="Ids",m="Table",g=m+"s",p=m+h,b="Row",I=b+"Count",f=b+h,y="Cell",w=y+h,C="Value",v=C+"s",k=C+h,T="currentTarget",S="value",x=e=>n+e,V=globalThis.window,R=Math,q=R.min,M=R.floor,N=isFinite,L=e=>null==e,E=(e,t,s)=>L(e)?s?.():t(e),z=e=>e==a||e==r,O=e=>l(e)==i,$=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),F=e=>e.length,J=e=>{throw Error(e)},{PureComponent:P,Fragment:B,createElement:D,useCallback:Q,useLayoutEffect:j,useRef:H,useState:W}=t,U=(e,...t)=>L(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),X=(e,t)=>e.map(t),Y=e=>0==F(e),Z=(e,...t)=>e.push(...t),_=e=>e.shift(),ee=Object,te=e=>ee.getPrototypeOf(e),se=ee.entries,le=ee.isFrozen,ne=e=>!L(e)&&E(te(e),(e=>e==ee.prototype||L(te(e))),(()=>!0)),ae=ee.keys,re=ee.freeze,oe=(e=[])=>ee.fromEntries(e),ie=(e,t)=>t in e,de=(e,t)=>(delete e[t],e),ue=(e,t)=>X(se(e),(([e,s])=>t(s,e))),ce=e=>ne(e)&&0==(e=>F(ae(e)))(e),he=(e,t,s,l=0)=>L(e)||!ne(e)||!l&&ce(e)||le(e)?(s?.(),!1):(ue(e,((s,l)=>{t(s,l)||de(e,l)})),!!l||!ce(e)),me=JSON.stringify,ge=JSON.parse,pe=e=>me(e,((e,t)=>t instanceof Map?ee.fromEntries([...t]):t)),be="tinybaseInspector",Ie="TinyBase Inspector",fe=["left","top","bottom","right","full"],ye="state",we="sort",Ce="open",ve="position",ke=Ce,Te="editable",Se=(...e)=>pe(e),xe=(e,t)=>X(G([...e]),t),Ve=(e,t)=>[!!s.useCell(ye,e,Te,t),Q((s=>{t.setCell(ye,e,Te,(e=>!e)),s.preventDefault()}),[t,e])],Re="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",qe='content:url("',Me=qe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ne='</svg>")',Le=qe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Ee=X([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Me+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Ne)),ze=Me+"<path d='M20 20l60 60M20 80l60-60' />"+Ne,Oe=Me+`<path d='${Re}' />`+Ne,$e=Me+`<path d='${Re}M20 20l60 60' />`+Ne,Ae="*::-webkit-scrollbar",Fe=((e,t="")=>e.join(t))(ue({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Le,...oe(X(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...oe(X(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Le,"header>img:nth-of-type(6)":ze,...oe(X(Ee,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Oe,"details[open]>summary img.done":$e,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Je=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!0),[],e);return s.useValue(ke,e)?null:D("img",{onClick:l,title:Ie,"data-position":t})},Pe=({uniqueId:e,summary:t,editable:l,handleEditable:n,children:a,s:r})=>{const o=!!s.useCell(ye,e,Ce,r),i=s.useSetCellCallback(ye,e,Ce,(e=>e[T].open),[],r);return D("details",{open:o,onToggle:i},D("summary",null,t,n?D("img",{onClick:n,className:l?"done":"edit"}):null),a)},Be=e=>{const t=l(e);return z(t)||t==o&&N(e)?t:void 0},De=(e,t,s,l,n)=>L(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Qe=(e,t,s)=>L(s)?e.delValue(t):e.setValue(t,s),je=(e,t,s,l)=>e==a?t:e==o?s:l,{useCallback:He,useMemo:We,useState:Ue}=t,Ge="editable",Ke=(e,t)=>X(s.useTableCellIds(e,t),(t=>e+"."+t)),Xe=(e,t,s)=>{const l=He(e,t);return s?l:void 0},Ye=(...e)=>We((()=>e),e),Ze=(e,t)=>We((()=>({store:e,tableId:t})),[e,t]),_e=(e,t)=>We((()=>({queries:e,queryId:t})),[e,t]),et=(e,t=!1,s,l=0,n,a,r,o)=>{const[[i,d,u],c]=Ue([e,t,l]),h=He((e=>{c(e),o?.(e)}),[o]),m=Xe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=He((e=>h([i,d,e])),[h,i,d]),p=!0===r?mt:r;return[[i,d,u],m,We((()=>!1===r?null:D(p,{offset:u,limit:n,total:a,onChange:g})),[r,p,u,n,a,g])]},tt=(e,t,s)=>We((()=>{const n=t??e;return r=$(n)?oe(X(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:s,...(n=e,l(n)==a?{label:e}:e)};var n},oe(ue(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,s,e]),st=({className:e,headerRow:t,idColumn:s,params:[l,n,a,r,o,i]})=>D("table",{className:e},i?D("caption",null,i):null,!1===t?null:D("thead",null,D("tr",null,!1===s?null:D(lt,{sort:r??[],label:"Id",onClick:o}),ue(l,(({label:e},t)=>D(lt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),D("tbody",null,X(a,(e=>D("tr",{key:e},!1===s?null:D("th",null,e),ue(l,(({component:t,getComponentProps:s},l)=>D("td",{key:l},D(t,{...U(s,e,l),...n,rowId:e,cellId:l}))))))))),lt=({cellId:e,sort:[t,s],label:l=e??n,onClick:a})=>D("th",{onClick:Xe((()=>a?.(e)),[a,e],a),className:L(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},L(s)||t!=e?null:(s?"↓":"↑")+" ",l),nt=({localRowId:e,params:[l,n,a,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return D("tr",null,!1===l?null:D(t.Fragment,null,D("th",null,e),D("th",null,u)),ue(n,(({component:t,getComponentProps:s},l)=>{const[n,o]=l.split(".",2),i=n===a?e:n===r?u:null;return L(i)?null:D("td",{key:l},D(t,{...U(s,i,o),store:d,tableId:n,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:n=!0})=>{const[i,d]=Ue(),[u,c]=Ue(),[h,m]=Ue(),[g,p]=Ue(),[b,I]=Ue();u!==e&&(d(Be(e)),c(e),m(e+""),p(Number(e)||0),I(!!e));const f=He(((e,s)=>{s(e),c(e),t(e)}),[t]),y=He((()=>{if(!l?.()){const e=je(i,o,r,a),s=je(e,h,g,b);d(e),c(s),t(s)}}),[l,t,h,g,b,i]);return D("div",{className:s},n?D("button",{className:i,onClick:y},i):null,je(i,D("input",{key:i,value:h,onChange:He((e=>f(e[T][S]+"",m)),[f])}),D("input",{key:i,type:"number",value:g,onChange:He((e=>f(Number(e[T][S]||0),p)),[f])}),D("input",{key:i,type:"checkbox",checked:b,onChange:He((e=>f(!!e[T].checked,I)),[f])})))},rt=({tableId:e,cellId:t,descending:l,offset:n,limit:a,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,p]=et(t,l,i,n,a,s.useRowCount(e,r),d,u);return D(st,{...h,params:Ye(tt(s.useTableCellIds(e,r),c,o?ct:s.CellView),Ze(r,e),s.useSortedRowIds(e,...m,a,r),m,g,p)})},ot=({store:e,editable:t=!1,valueComponent:l=(t?ht:s.ValueView),getValueComponentProps:n,className:a,headerRow:r,idColumn:o})=>D("table",{className:a},!1===r?null:D("thead",null,D("tr",null,!1===o?null:D("th",null,"Id"),D("th",null,C))),D("tbody",null,X(s.useValueIds(e),(t=>D("tr",{key:t},!1===o?null:D("th",null,t),D("td",null,D(l,{...U(n,t),valueId:t,store:e}))))))),it=({indexId:e,sliceId:t,indexes:l,editable:n,customCells:a,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return D(st,{...r,params:Ye(tt(s.useTableCellIds(d,i),a,n?ct:s.CellView),Ze(i,d),s.useSliceRowIds(e,t,o))})},dt=({relationshipId:e,relationships:l,editable:n,customCells:a,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=tt([...Ke(c,u),...Ke(h,u)],a,n?ct:s.CellView),g=Ye(i,m,c,h,e,d,u);return D("table",{className:r},!1===o?null:D("thead",null,D("tr",null,!1===i?null:D(t.Fragment,null,D("th",null,c,".Id"),D("th",null,h,".Id")),ue(m,(({label:e},t)=>D("th",{key:t},e))))),D("tbody",null,X(s.useRowIds(c,u),(e=>D(nt,{key:e,localRowId:e,params:g})))))},ut=({queryId:e,cellId:t,descending:l,offset:n,limit:a,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=et(t,l,o,n,a,s.useResultRowCount(e,r),i,u);return D(st,{...c,params:Ye(tt(s.useResultTableCellIds(e,r),d,s.ResultCellView),_e(r,e),s.useResultSortedRowIds(e,...h,a,r),h,m,g)})},ct=({tableId:e,rowId:t,cellId:l,store:n,className:a,showType:r})=>D(at,{thing:s.useCell(e,t,l,n),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],n),className:a??Ge+y,showType:r,hasSchema:s.useStoreOrStoreById(n)?.hasTablesSchema}),ht=({valueId:e,store:t,className:l,showType:n})=>D(at,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Ge+C,showType:n,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),mt=({onChange:e,total:s,offset:l=0,limit:n=s,singular:a="row",plural:r=a+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Xe((()=>e(l-n)),[e,l,n],l>0),i=Xe((()=>e(l+n)),[e,l,n],l+n<s);return D(t.Fragment,null,s>n&&D(t.Fragment,null,D("button",{className:"previous",disabled:0==l,onClick:o},"←"),D("button",{className:"next",disabled:l+n>=s,onClick:i},"→"),l+1," to ",q(s,l+n)," of "),s," ",1!=s?r:a)},gt=({indexes:e,indexesId:t,indexId:l,s:n})=>D(Pe,{uniqueId:Se("i",t,l),summary:"Index: "+l,s:n},X(s.useSliceIds(l,e),(s=>D(pt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:n,key:s})))),pt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:n})=>{const a=Se("i",t,s,l),[r,o]=Ve(a,n);return D(Pe,{uniqueId:a,summary:"Slice: "+l,editable:r,handleEditable:o,s:n},D(it,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),n=s.useIndexIds(l);return L(l)?null:D(Pe,{uniqueId:Se("i",e),summary:"Indexes: "+(e??u),s:t},Y(n)?"No indexes defined":xe(n,(s=>D(gt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},It=({metrics:e,metricId:t})=>D("tr",null,D("th",null,t),D("td",null,e?.getTableId(t)),D("td",null,s.useMetric(t,e))),ft=({metricsId:e,s:t})=>{const l=s.useMetrics(e),n=s.useMetricIds(l);return L(l)?null:D(Pe,{uniqueId:Se("m",e),summary:"Metrics: "+(e??u),s:t},Y(n)?"No metrics defined":D("table",null,D("thead",null,D("th",null,"Metric Id"),D("th",null,"Table Id"),D("th",null,"Metric")),D("tbody",null,X(n,(e=>D(It,{metrics:l,metricId:e,key:e}))))))},yt=({queries:e,queriesId:t,queryId:l,s:n})=>{const a=Se("q",t,l),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n);return D(Pe,{uniqueId:a,summary:"Query: "+l,s:n},D(ut,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},wt=({queriesId:e,s:t})=>{const l=s.useQueries(e),n=s.useQueryIds(l);return L(l)?null:D(Pe,{uniqueId:Se("q",e),summary:"Queries: "+(e??u),s:t},Y(n)?"No queries defined":xe(n,(s=>D(yt,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},Ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const n=Se("r",t,s),[a,r]=Ve(n,l);return D(Pe,{uniqueId:n,summary:"Relationship: "+s,editable:a,handleEditable:r,s:l},D(dt,{relationshipId:s,relationships:e,editable:a}))},vt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),n=s.useRelationshipIds(l);return L(l)?null:D(Pe,{uniqueId:Se("r",e),summary:"Relationships: "+(e??u),s:t},Y(n)?"No relationships defined":xe(n,(s=>D(Ct,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},kt=({tableId:e,store:t,storeId:l,s:n})=>{const a=Se("t",l,e),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n),[u,c]=Ve(a,n);return D(Pe,{uniqueId:a,summary:m+": "+e,editable:u,handleEditable:c,s:n},D(rt,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},Tt=({store:e,storeId:t,s:l})=>{const n=Se("v",t),[a,r]=Ve(n,l);return Y(s.useValueIds(e))?null:D(Pe,{uniqueId:n,summary:v,editable:a,handleEditable:r,s:l},D(ot,{store:e,editable:a}))},St=({storeId:e,s:t})=>{const l=s.useStore(e),n=s.useTableIds(l);return L(l)?null:D(Pe,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??u),s:t},D(Tt,{storeId:e,store:l,s:t}),xe(n,(s=>D(kt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},xt=({s:e})=>{const t=H(null),l=H(0),[n,a]=W(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);j((()=>{const e=t.current;if(e&&!n){const t=new MutationObserver((()=>{e.scrollWidth>=M(r)+e.clientWidth&&e.scrollHeight>=M(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[n,r,o]);const i=Q((t=>{const{scrollLeft:s,scrollTop:n}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{a(!0),e.setPartialValues({scrollLeft:s,scrollTop:n})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),g=s.useIndexesIds(),p=s.useRelationships(),b=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return L(d)&&Y(u)&&L(c)&&Y(h)&&L(m)&&Y(g)&&L(p)&&Y(b)&&L(I)&&Y(f)?D("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):D("article",{ref:t,onScroll:i},D(St,{s:e}),X(u,(t=>D(St,{storeId:t,s:e,key:t}))),D(ft,{s:e}),X(h,(t=>D(ft,{metricsId:t,s:e,key:t}))),D(bt,{s:e}),X(g,(t=>D(bt,{indexesId:t,s:e,key:t}))),D(vt,{s:e}),X(b,(t=>D(vt,{relationshipsId:t,s:e,key:t}))),D(wt,{s:e}),X(f,(t=>D(wt,{queriesId:t,s:e,key:t}))))};class Vt extends P{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?D("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Rt=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!1),[],e),n=s.useSetValueCallback(ve,(e=>Number(e[T].dataset.id)),[],e);return D("header",null,D("img",{title:Ie}),D("span",null,Ie),X(fe,((e,s)=>s==t?null:D("img",{onClick:n,"data-id":s,title:"Dock to "+e,key:s}))),D("img",{onClick:l,title:"Close"}))},qt=({s:e})=>{const t=s.useValue(ve,e)??1;return s.useValue(ke,e)?D("main",{"data-position":t},D(Rt,{s:e}),D(Vt,null,D(xt,{s:e}))):null},Mt=e=>t=>{return s=(t,s)=>t+e(s),At(t).reduce(s,0);var s},Nt=e=>e?.size??0,Lt=Mt(Nt),Et=Mt(Lt),zt=Mt(Et),Ot=(e,t)=>e?.has(t)??!1,$t=e=>L(e)||0==Nt(e),At=e=>[...e?.values()??[]],Ft=e=>e.clear(),Jt=(e,t)=>e?.forEach(t),Pt=(e,t)=>e?.delete(t),Bt=e=>new Map(e),Dt=e=>[...e?.keys()??[]],Qt=(e,t)=>e?.get(t),jt=(e,t)=>Jt(e,((e,s)=>t(s,e))),Ht=(e,t,s)=>L(s)?(Pt(e,t),e):e?.set(t,s),Wt=(e,t,s,l)=>(Ot(e,t)?l?.(Qt(e,t)):Ht(e,t,s()),Qt(e,t)),Ut=(e,t,s,l=Ht)=>(ue(t,((t,l)=>s(e,l,t))),jt(e,(s=>ie(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const n={};return Jt(e,((e,a)=>{if(!s?.(e,a)){const s=t?t(e,a):e;l?.(s)||(n[a]=s)}})),n},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),$t,ce),Xt=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),$t,ce),Yt=(e,t)=>{const s=Bt();return Jt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Zt=e=>Yt(e,Yt),_t=e=>Yt(e,Zt),es=(e,t,s,l,n=0)=>E((s?Wt:Qt)(e,t[n],n>F(t)-2?s:Bt),(a=>{if(n>F(t)-2)return l?.(a)&&Ht(e,t[n]),a;const r=es(a,t,s,l,n+1);return $t(a)&&Ht(e,t[n]),r})),ts=Bt(),ss=Bt(),ls="storage",ns=e=>new Set($(e)||L(e)?e:[e]),as=(e,t)=>e?.add(t),rs=/^\d+$/,os=()=>{const e=[];let t=0;return[s=>(s?_(e):null)??n+t++,t=>{rs.test(t)&&F(e)<1e3&&Z(e,t)}]},is=e=>[e,e],ds=(e,t=Lt)=>t(e[0])+t(e[1]),us=()=>[Bt(),Bt()],cs=e=>[...e],hs=([e,t])=>e===t;Bt(X("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(n),((e,t)=>[e,t])));const ms=(e,t,s)=>Ht(e,t,Qt(e,t)==-s?void 0:s),gs=()=>{let e,t,s=!1,l=!1,a=0,r=[];const i=Bt(),h=Bt(),T=Bt(),S=Bt(),V=Bt(),R=Bt(),q=Bt(),M=Bt(),N=Bt(),J=Bt(),P=Bt(),B=Bt(),D=Bt(),Q=Bt(),j=ns(),H=Bt(),W=Bt(),U=Bt(),Y=Bt(),_=us(),ee=us(),te=us(),se=us(),le=us(),ne=us(),ae=us(),oe=us(),me=us(),be=us(),Ie=us(),fe=us(),ye=us(),we=us(),Ce=us(),ve=us(),ke=us(),Te=us(),Se=us(),xe=us(),Ve=us(),Re=us(),qe=Bt(),Me=us(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=os(),l=Bt();return[(s,a,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return Ht(l,d,[s,a,r,o,i]),as(es(a,r??[n],ns),d),d},(t,s,...a)=>K(((e,t=[n])=>{const s=[],l=(e,n)=>n==F(t)?Z(s,e):null===t[n]?Jt(e,(e=>l(e,n+1))):K([t[n],null],(t=>l(Qt(e,t),n+1)));return l(e,0),s})(t,s),(t=>Jt(t,(t=>Qt(l,t)[0](e,...s??[],...a))))),e=>E(Qt(l,e),(([,t,a])=>(es(t,a??[n],void 0,(t=>(Pt(t,e),$t(t)?1:0))),Ht(l,e),s(e),a))),t=>E(Qt(l,t),(([t,,s=[],l,n])=>{const a=(...r)=>{const o=F(r);o==F(s)?t(e,...r,...n(r)):L(s[o])?K(l[o]?.(...r)??[],(e=>a(...r,e))):a(...r,s[o])};a()}))]})(),Oe=e=>{if(!he(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!z(t)&&t!=o||(Be(e[u])!=t&&de(e,u),0))},$e=$,Ae=(t,s)=>(!e||Ot(P,s)||bt(s))&&he(t,((e,t)=>Fe(s,t,e)),(()=>bt(s))),Fe=(e,t,s,l)=>he(l?s:He(s,e,t),((l,n)=>E(Je(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>bt(e,t))),Je=(t,s,l,n)=>e?E(Qt(Qt(P,t),l),(e=>Be(n)!=e[d]?bt(t,s,l,n,e[u]):n),(()=>bt(t,s,l,n))):L(Be(n))?bt(t,s,l,n):n,Pe=(e,t)=>he(t?e:We(e),((t,s)=>E(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?E(Qt(D,e),(t=>Be(s)!=t[d]?It(e,s,t[u]):s),(()=>It(e,s))):L(Be(s))?It(e,s):s,He=(e,t,s)=>(E(Qt(B,t),(([l,n])=>{Jt(l,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(n,(l=>{ie(e,l)||bt(t,s,l)}))})),e),We=e=>(t&&(Jt(Q,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(j,(t=>{ie(e,t)||It(t)}))),e),Ue=e=>Ut(P,e,((e,t,s)=>{const l=Bt(),n=ns();Ut(Wt(P,t,Bt),s,((e,t,s)=>{Ht(e,t,s),E(s[u],(e=>Ht(l,t,e)),(()=>as(n,t)))})),Ht(B,t,[l,n])}),((e,t)=>{Ht(P,t),Ht(B,t)})),Ge=e=>Ut(D,e,((e,t,s)=>{Ht(D,t,s),E(s[u],(e=>Ht(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{Ht(D,t),Ht(Q,t),Pt(j,t)})),Ke=e=>ce(e)?Rs():ks(e),Xe=e=>Ut(U,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Ut(Wt(U,e,(()=>(ut(e,1),Ht(H,e,os()),Ht(W,e,Bt()),Bt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,n)=>Ut(Wt(t,s,(()=>(ct(e,s,1),Bt()))),l,((t,l,n)=>_e(e,s,t,l,n)),((l,a)=>it(e,t,s,l,a,n))),_e=(e,t,s,l,n)=>{Ot(s,l)||ht(e,t,l,1);const a=Qt(s,l);n!==a&&(mt(e,t,l,a,n),Ht(s,l,n))},et=(e,t,s,l,n)=>E(Qt(t,s),(t=>_e(e,s,t,l,n)),(()=>Ze(e,t,s,He({[l]:n},e,s)))),tt=e=>ce(e)?Ns():Ts(e),st=e=>Ut(Y,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{Ot(Y,e)||gt(e,1);const s=Qt(Y,e);t!==s&&(pt(e,s,t),Ht(Y,e,t))},nt=(e,t)=>{const[s]=Qt(H,e),l=s(t);return Ot(Qt(U,e),l)?nt(e,t):l},at=e=>Qt(U,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Qt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,n,a)=>{const r=Qt(Qt(B,e)?.[0],n);if(!L(r)&&!a)return _e(e,s,l,n,r);const o=t=>{mt(e,s,t,Qt(l,t)),ht(e,s,t,-1),Ht(l,t)};L(r)?o(n):jt(l,o),$t(l)&&(ct(e,s,-1),$t(Ht(t,s))&&(ut(e,-1),Ht(U,e),Ht(H,e),Ht(W,e)))},dt=e=>{const t=Qt(Q,e);if(!L(t))return lt(e,t);pt(e,Qt(Y,e)),gt(e,-1),Ht(Y,e)},ut=(e,t)=>ms(i,e,t),ct=(e,t,s)=>ms(Wt(S,e,Bt),t,s)&&Ht(T,e,Wt(T,e,(()=>0))+s),ht=(e,t,s,l)=>{const n=Qt(W,e),a=Qt(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&ms(Wt(h,e,Bt),s,l),Ht(n,s,a!=-l?a+l:null),ms(Wt(Wt(V,e,Bt),t,Bt),s,l)},mt=(e,t,s,l,n)=>{Wt(Wt(Wt(R,e,Bt),t,Bt),s,(()=>[l,0]))[1]=n,r[3]?.(e,t,s,n)},gt=(e,t)=>ms(q,e,t),pt=(e,t,s)=>{Wt(M,e,(()=>[t,0]))[1]=s,r[4]?.(e,s)},bt=(e,t,s,l,n)=>(Z(Wt(Wt(Wt(N,e,Bt),t,Bt),s,(()=>[])),l),n),It=(e,t,s)=>(Z(Wt(J,e,(()=>[])),t),s),ft=(e,t,s)=>E(Qt(Qt(Qt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ss(e,t,s))])),yt=e=>E(Qt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ps(e))])),wt=e=>$t(N)||$t(ve[e])?0:Jt(e?_t(N):N,((t,s)=>Jt(t,((t,l)=>Jt(t,((t,n)=>Le(ve[e],[s,l,n],t))))))),Ct=e=>$t(J)||$t(ke[e])?0:Jt(e?Yt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!$t(e))return Le(t,l,(()=>Gt(e))),jt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=bs();t!=s&&Le(_[e],void 0,t);const l=$t(be[e]),n=$t(ye[e])&&$t(we[e])&&$t(me[e])&&$t(Ie[e])&&$t(ne[e])&&$t(ae[e])&&$t(oe[e])&&l&&$t(te[e])&&$t(se[e]),a=$t(Ce[e])&&$t(fe[e])&&$t(le[e])&&$t(ee[e]);if(!n||!a){const t=e?[Yt(i),Zt(h),Yt(T),Zt(S),_t(V),_t(R)]:[i,h,T,S,V,R];if(!n){vt(t[0],te[e],se[e]),Jt(t[1],((t,s)=>vt(t,ne[e],ae[e],[s]))),Jt(t[2],((t,s)=>{0!=t&&Le(oe[e],[s],qt(s))}));const s=ns();Jt(t[3],((t,n)=>{vt(t,me[e],Ie[e],[n])&&!l&&(Le(be[e],[n,null]),as(s,n))})),l||Jt(t[5],((t,l)=>{if(!Ot(s,l)){const s=ns();Jt(t,(e=>Jt(e,(([t,l],n)=>l!==t?as(s,n):Pt(e,n))))),Jt(s,(t=>Le(be[e],[l,t])))}})),Jt(t[4],((t,s)=>Jt(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!a){let s;Jt(t[5],((t,l)=>{let n;Jt(t,((t,a)=>{let r;Jt(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,a,i],o,t,ft),s=n=r=1)})),r&&Le(fe[e],[l,a],ft)})),n&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},Tt=e=>{const t=Cs();t!=l&&Le(Te[e],void 0,t);const s=$t(xe[e])&&$t(Ve[e]),n=$t(Re[e])&&$t(Se[e]);if(!s||!n){const t=e?[Yt(q),Yt(M)]:[q,M];if(s||vt(t[0],xe[e],Ve[e]),!n){let s;Jt(t[1],(([t,l],n)=>{l!==t&&(Le(Re[e],[n],l,t,yt),s=1)})),s&&Le(Se[e],void 0,yt)}}},St=(e,...t)=>(zs((()=>e(...X(t,x)))),As),xt=()=>Xt(U),Vt=()=>Dt(U),Rt=e=>Dt(Qt(W,x(e))),qt=e=>Nt(Qt(U,x(e))),Mt=e=>Dt(Qt(U,x(e))),At=(e,t,s,l=0,n)=>{return X(A(G((a=Qt(U,x(e)),r=(e,s)=>[L(t)?s:Qt(e,x(t)),s],X([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,L(n)?n:l+n),(([,e])=>e));var a,r},ts=(e,t)=>Dt(Qt(Qt(U,x(e)),x(t))),ss=(e,t,s)=>Qt(Qt(Qt(U,x(e)),x(t)),x(s)),ls=()=>Gt(Y),rs=()=>Dt(Y),ps=e=>Qt(Y,x(e)),bs=()=>!$t(U),Is=e=>Ot(U,x(e)),fs=(e,t)=>Ot(Qt(W,x(e)),x(t)),ys=(e,t)=>Ot(Qt(U,x(e)),x(t)),ws=(e,t,s)=>Ot(Qt(Qt(U,x(e)),x(t)),x(s)),Cs=()=>!$t(Y),vs=e=>Ot(Y,x(e)),ks=e=>St((()=>(e=>he(e,Ae,bt))(e)?Xe(e):0)),Ts=e=>St((()=>Pe(e)?st(e):0)),Ss=e=>{try{Ke(ge(e))}catch{}return As},xs=t=>St((()=>{if((e=he(t,(e=>he(e,Oe))))&&(Ue(t),!$t(U))){const e=xt();Rs(),ks(e)}})),Vs=e=>St((()=>{if(t=(e=>he(e,Oe))(e)){const s=ls();Es(),Ns(),t=!0,Ge(e),Ts(s)}})),Rs=()=>St((()=>Xe({}))),qs=e=>St((e=>Ot(U,e)?rt(e):0),e),Ms=(e,t)=>St(((e,t)=>E(Qt(U,e),(s=>Ot(s,t)?ot(e,s,t):0))),e,t),Ns=()=>St((()=>st({}))),Ls=()=>St((()=>{Ue({}),e=!1})),Es=()=>St((()=>{Ge({}),t=!1})),zs=(e,t)=>{if(-1!=a){Os();const s=e();return $s(t),s}},Os=()=>(-1!=a&&a++,1==a&&(r[0]?.(),Le(qe)),As),$s=e=>(a>0&&(a--,0==a&&(a=1,wt(1),$t(R)||kt(1),Ct(1),$t(M)||Tt(1),e?.(As)&&(Jt(R,((e,t)=>Jt(e,((e,s)=>Jt(e,(([e],l)=>De(As,t,s,l,e))))))),Ft(R),Jt(M,(([e],t)=>Qe(As,t,e))),Ft(M)),Le(Me[0],void 0),a=-1,wt(0),$t(R)||kt(0),Ct(0),$t(M)||Tt(0),r[1]?.(),Le(Me[1],void 0),r[2]?.(),a=0,s=bs(),l=Cs(),K([i,h,T,S,V,R,N,q,M,J],Ft))),As),As={getContent:()=>[xt(),ls()],getTables:xt,getTableIds:Vt,getTable:e=>Kt(Qt(U,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:Mt,getSortedRowIds:At,getRow:(e,t)=>Gt(Qt(Qt(U,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ls,getValueIds:rs,getValue:ps,hasTables:bs,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>pe(U),getValuesJson:()=>pe(Y),getJson:()=>pe([U,Y]),getTablesSchemaJson:()=>pe(P),getValuesSchemaJson:()=>pe(D),getSchemaJson:()=>pe([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>St((()=>$e(e)?(([e,t])=>{(ce(e)?Rs:ks)(e),(ce(t)?Ns:Ts)(t)})(e):0)),setTables:ks,setTable:(e,t)=>St((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>St(((e,t)=>Fe(e,t,s)?Ze(e,at(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,at(e),l=nt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>St(((e,t)=>{if(Fe(e,t,s,1)){const l=at(e);ue(s,((s,n)=>et(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>St(((e,t,s)=>E(Je(e,t,s,O(l)?l(ss(e,t,s)):l),(l=>et(e,at(e),t,s,l)))),e,t,s),setValues:Ts,setPartialValues:e=>St((()=>Pe(e,1)?ue(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>St((e=>E(je(e,O(t)?t(ps(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>St((()=>{ue(e[0],((e,t)=>L(e)?qs(t):ue(e,((e,s)=>L(e)?Ms(t,s):ue(e,((e,l)=>De(As,t,s,l,e))))))),ue(e[1],((e,t)=>Qe(As,t,e)))})),setTablesJson:Ss,setValuesJson:e=>{try{tt(ge(e))}catch{}return As},setJson:e=>St((()=>{try{const[t,s]=ge(e);Ke(t),tt(s)}catch{Ss(e)}})),setTablesSchema:xs,setValuesSchema:Vs,setSchema:(e,t)=>St((()=>{xs(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>St(((e,t,s)=>E(Qt(U,e),(n=>E(Qt(n,t),(a=>Ot(a,s)?it(e,n,t,a,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>St((e=>Ot(Y,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>St((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Qt(i,t)?void 0:Gt(e,((e,s)=>-1===Qt(Qt(S,t),s)?void 0:Gt(e,(([,e])=>e),(e=>hs(e)))),$t,ce)),$t,ce),Gt(M,(([,e])=>e),(e=>hs(e))),1],getTransactionLog:()=>[!$t(R),!$t(M),Xt(R,cs,hs),Xt(N),Gt(M,cs,hs),Gt(J),Gt(i),Kt(S),Xt(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Jt(U,((t,s)=>e(s,(e=>Jt(t,((t,s)=>e(s,(e=>jt(t,e))))))))),forEachTableCell:(e,t)=>jt(Qt(W,x(e)),t),forEachRow:(e,t)=>Jt(Qt(U,x(e)),((e,s)=>t(s,(t=>jt(e,t))))),forEachCell:(e,t,s)=>jt(Qt(Qt(U,x(e)),x(t)),s),forEachValue:e=>jt(Y,e),addSortedRowIdsListener:(e,t,s,l,n,a,r)=>{let o=At(e,t,s,l,n);return Ne((()=>{const r=At(e,t,s,l,n);var i,d,u;d=o,F(i=r)===F(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,a(As,e,t,s,l,n,o))}),be[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:ds(_),tables:ds(ee),tableIds:ds(te),hasTable:ds(se),table:ds(le),tableCellIds:ds(ne),hasTableCell:ds(ae,Et),rowCount:ds(oe),rowIds:ds(me),sortedRowIds:ds(be),hasRow:ds(Ie,Et),row:ds(fe,Et),cellIds:ds(ye,Et),hasCell:ds(we,zt),cell:ds(Ce,zt),invalidCell:ds(ve,zt),hasValues:ds(Te),values:ds(Se),valueIds:ds(xe),hasValue:ds(Ve),value:ds(Re),invalidValue:ds(ke),transaction:Lt(qe)+ds(Me)}),isMergeable:()=>!1,createStore:gs,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,n)=>r=[e,t,s,l,n]};return ue({[c+g]:[0,_,[],()=>[bs()]],[g]:[0,ee],[p]:[0,te],[c+m]:[1,se,[Vt],e=>[Is(...e)]],[m]:[1,le,[Vt]],[m+w]:[1,ne,[Vt]],[c+m+y]:[2,ae,[Vt,Rt],e=>[fs(...e)]],[I]:[1,oe,[Vt]],[f]:[1,me,[Vt]],[c+b]:[2,Ie,[Vt,Mt],e=>[ys(...e)]],[b]:[2,fe,[Vt,Mt]],[w]:[2,ye,[Vt,Mt]],[c+y]:[3,we,[Vt,Mt,ts],e=>[ws(...e)]],[y]:[3,Ce,[Vt,Mt,ts],e=>is(ss(...e))],InvalidCell:[3,ve],[c+v]:[0,Te,[],()=>[Cs()]],[v]:[0,Se],[k]:[0,xe],[c+C]:[1,Ve,[rs],e=>[vs(...e)]],[C]:[1,Re,[rs],e=>is(ps(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],n)=>{As["add"+n+"Listener"]=(...n)=>Ne(n[e],t[n[e+1]?1:0],e>0?A(n,0,e):void 0,s,l)})),re(As)};e.Inspector=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(gs),n=fe.indexOf(e);return s.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,n,a,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Wt(ts,i,(()=>0)),Wt(ss,i,(()=>[]));const[p,b,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ce(e)||!ce(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ce(e)||!ce(t),t.setContent]:J("Store type not supported by this Persister"))(r,e),w=t=>{(p&&$(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await S((async()=>{try{const e=await t();$(e)?w(e):J("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),x),v=()=>(u&&(n(u),u=void 0),x),k=async e=>(1!=h&&(h=2,g++,await S((async()=>{try{await s(b,e)}catch(e){}h=0}))),x),T=()=>(E(c,e.delListener),c=void 0,x),S=async(...e)=>(Z(Qt(ss,i),...e),await(async()=>{if(!Qt(ts,i)){for(Ht(ts,i,1);!L(d=_(Qt(ss,i)));)try{await d()}catch(e){}Ht(ts,i,0)}})(),x),x={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return x},stopAutoLoad:v,isAutoLoading:()=>!L(u),save:k,startAutoSave:async()=>(await T().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),x),stopAutoSave:T,isAutoSaving:()=>!L(c),schedule:S,getStore:()=>e,destroy:()=>(Qt(ss,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return re(x)})(e,(async()=>{return e=s.getItem(t),ge(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),me(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(ge(l.newValue))}catch{e()}};return V.addEventListener(ls,l),l}),(e=>V.removeEventListener(ls,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==n?1:n,open:!!t}]),await e.startAutoSave()})),D(B,null,D("aside",{id:be},D(Je,{s:l}),D(qt,{s:l})),D("style",null,Fe))}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("../ui-react/index.js")):"function"==typeof define&&define.amd?define(["exports","react","../ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactInspector={},e.React,e.TinyBaseUiReact);
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,n="",a=l(n),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Has",h="Ids",m="Table",g=m+"s",p=m+h,b="Row",I=b+"Count",f=b+h,y="Cell",w=y+h,C="Value",v=C+"s",k=C+h,T="currentTarget",S="value",x=e=>n+e,V=globalThis.window,R=Math,q=R.min,M=R.floor,N=isFinite,L=e=>null==e,E=(e,t,s)=>L(e)?s?.():t(e),z=e=>e==a||e==r,O=e=>l(e)==i,$=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),F=e=>e.length,J=e=>{throw Error(e)},{PureComponent:P,Fragment:B,createElement:D,useCallback:Q,useLayoutEffect:j,useRef:H,useState:W}=t,U=(e,...t)=>L(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),X=(e,t)=>e.map(t),Y=e=>0==F(e),Z=(e,...t)=>e.push(...t),_=e=>e.shift(),ee=Object,te=e=>ee.getPrototypeOf(e),se=ee.entries,le=ee.isFrozen,ne=e=>!L(e)&&E(te(e),(e=>e==ee.prototype||L(te(e))),(()=>!0)),ae=ee.keys,re=ee.freeze,oe=(e=[])=>ee.fromEntries(e),ie=(e,t)=>t in e,de=(e,t)=>(delete e[t],e),ue=(e,t)=>X(se(e),(([e,s])=>t(s,e))),ce=e=>ne(e)&&0==(e=>F(ae(e)))(e),he=(e,t,s,l=0)=>L(e)||!ne(e)||!l&&ce(e)||le(e)?(s?.(),!1):(ue(e,((s,l)=>{t(s,l)||de(e,l)})),!!l||!ce(e)),me=JSON.stringify,ge=JSON.parse,pe=e=>me(e,((e,t)=>t instanceof Map?ee.fromEntries([...t]):t)),be="tinybaseInspector",Ie="TinyBase Inspector",fe=["left","top","bottom","right","full"],ye="state",we="sort",Ce="open",ve="position",ke=Ce,Te="editable",Se=(...e)=>pe(e),xe=(e,t)=>X(G(e),t),Ve=(e,t)=>[!!s.useCell(ye,e,Te,t),Q((s=>{t.setCell(ye,e,Te,(e=>!e)),s.preventDefault()}),[t,e])],Re="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",qe='content:url("',Me=qe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ne='</svg>")',Le=qe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Ee=X([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Me+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Ne)),ze=Me+"<path d='M20 20l60 60M20 80l60-60' />"+Ne,Oe=Me+`<path d='${Re}' />`+Ne,$e=Me+`<path d='${Re}M20 20l60 60' />`+Ne,Ae="*::-webkit-scrollbar",Fe=((e,t="")=>e.join(t))(ue({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Le,...oe(X(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...oe(X(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Le,"header>img:nth-of-type(6)":ze,...oe(X(Ee,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Oe,"details[open]>summary img.done":$e,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Je=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!0),[],e);return s.useValue(ke,e)?null:D("img",{onClick:l,title:Ie,"data-position":t})},Pe=({uniqueId:e,summary:t,editable:l,handleEditable:n,children:a,s:r})=>{const o=!!s.useCell(ye,e,Ce,r),i=s.useSetCellCallback(ye,e,Ce,(e=>e[T].open),[],r);return D("details",{open:o,onToggle:i},D("summary",null,t,n?D("img",{onClick:n,className:l?"done":"edit"}):null),a)},Be=e=>{const t=l(e);return z(t)||t==o&&N(e)?t:void 0},De=(e,t,s,l,n)=>L(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Qe=(e,t,s)=>L(s)?e.delValue(t):e.setValue(t,s),je=(e,t,s,l)=>e==a?t:e==o?s:l,{useCallback:He,useMemo:We,useState:Ue}=t,Ge="editable",Ke=(e,t)=>X(s.useTableCellIds(e,t),(t=>e+"."+t)),Xe=(e,t,s)=>{const l=He(e,t);return s?l:void 0},Ye=(...e)=>We((()=>e),e),Ze=(e,t)=>We((()=>({store:e,tableId:t})),[e,t]),_e=(e,t)=>We((()=>({queries:e,queryId:t})),[e,t]),et=(e,t=!1,s,l=0,n,a,r,o)=>{const[[i,d,u],c]=Ue([e,t,l]),h=He((e=>{c(e),o?.(e)}),[o]),m=Xe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=He((e=>h([i,d,e])),[h,i,d]),p=!0===r?mt:r;return[[i,d,u],m,We((()=>!1===r?null:D(p,{offset:u,limit:n,total:a,onChange:g})),[r,p,u,n,a,g])]},tt=(e,t,s)=>We((()=>{const n=t??e;return r=$(n)?oe(X(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:s,...(n=e,l(n)==a?{label:e}:e)};var n},oe(ue(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,s,e]),st=({className:e,headerRow:t,idColumn:s,params:[l,n,a,r,o,i]})=>D("table",{className:e},i?D("caption",null,i):null,!1===t?null:D("thead",null,D("tr",null,!1===s?null:D(lt,{sort:r??[],label:"Id",onClick:o}),ue(l,(({label:e},t)=>D(lt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),D("tbody",null,X(a,(e=>D("tr",{key:e},!1===s?null:D("th",null,e),ue(l,(({component:t,getComponentProps:s},l)=>D("td",{key:l},D(t,{...U(s,e,l),...n,rowId:e,cellId:l}))))))))),lt=({cellId:e,sort:[t,s],label:l=e??n,onClick:a})=>D("th",{onClick:Xe((()=>a?.(e)),[a,e],a),className:L(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},L(s)||t!=e?null:(s?"↓":"↑")+" ",l),nt=({localRowId:e,params:[l,n,a,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return D("tr",null,!1===l?null:D(t.Fragment,null,D("th",null,e),D("th",null,u)),ue(n,(({component:t,getComponentProps:s},l)=>{const[n,o]=l.split(".",2),i=n===a?e:n===r?u:null;return L(i)?null:D("td",{key:l},D(t,{...U(s,i,o),store:d,tableId:n,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:n=!0})=>{const[i,d]=Ue(),[u,c]=Ue(),[h,m]=Ue(),[g,p]=Ue(),[b,I]=Ue();u!==e&&(d(Be(e)),c(e),m(e+""),p(Number(e)||0),I(!!e));const f=He(((e,s)=>{s(e),c(e),t(e)}),[t]),y=He((()=>{if(!l?.()){const e=je(i,o,r,a),s=je(e,h,g,b);d(e),c(s),t(s)}}),[l,t,h,g,b,i]);return D("div",{className:s},n?D("button",{className:i,onClick:y},i):null,je(i,D("input",{key:i,value:h,onChange:He((e=>f(e[T][S]+"",m)),[f])}),D("input",{key:i,type:"number",value:g,onChange:He((e=>f(Number(e[T][S]||0),p)),[f])}),D("input",{key:i,type:"checkbox",checked:b,onChange:He((e=>f(!!e[T].checked,I)),[f])})))},rt=({tableId:e,cellId:t,descending:l,offset:n,limit:a,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,p]=et(t,l,i,n,a,s.useRowCount(e,r),d,u);return D(st,{...h,params:Ye(tt(s.useTableCellIds(e,r),c,o?ct:s.CellView),Ze(r,e),s.useSortedRowIds(e,...m,a,r),m,g,p)})},ot=({store:e,editable:t=!1,valueComponent:l=(t?ht:s.ValueView),getValueComponentProps:n,className:a,headerRow:r,idColumn:o})=>D("table",{className:a},!1===r?null:D("thead",null,D("tr",null,!1===o?null:D("th",null,"Id"),D("th",null,C))),D("tbody",null,X(s.useValueIds(e),(t=>D("tr",{key:t},!1===o?null:D("th",null,t),D("td",null,D(l,{...U(n,t),valueId:t,store:e}))))))),it=({indexId:e,sliceId:t,indexes:l,editable:n,customCells:a,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return D(st,{...r,params:Ye(tt(s.useTableCellIds(d,i),a,n?ct:s.CellView),Ze(i,d),s.useSliceRowIds(e,t,o))})},dt=({relationshipId:e,relationships:l,editable:n,customCells:a,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=tt([...Ke(c,u),...Ke(h,u)],a,n?ct:s.CellView),g=Ye(i,m,c,h,e,d,u);return D("table",{className:r},!1===o?null:D("thead",null,D("tr",null,!1===i?null:D(t.Fragment,null,D("th",null,c,".Id"),D("th",null,h,".Id")),ue(m,(({label:e},t)=>D("th",{key:t},e))))),D("tbody",null,X(s.useRowIds(c,u),(e=>D(nt,{key:e,localRowId:e,params:g})))))},ut=({queryId:e,cellId:t,descending:l,offset:n,limit:a,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=et(t,l,o,n,a,s.useResultRowCount(e,r),i,u);return D(st,{...c,params:Ye(tt(s.useResultTableCellIds(e,r),d,s.ResultCellView),_e(r,e),s.useResultSortedRowIds(e,...h,a,r),h,m,g)})},ct=({tableId:e,rowId:t,cellId:l,store:n,className:a,showType:r})=>D(at,{thing:s.useCell(e,t,l,n),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],n),className:a??Ge+y,showType:r,hasSchema:s.useStoreOrStoreById(n)?.hasTablesSchema}),ht=({valueId:e,store:t,className:l,showType:n})=>D(at,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Ge+C,showType:n,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),mt=({onChange:e,total:s,offset:l=0,limit:n=s,singular:a="row",plural:r=a+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Xe((()=>e(l-n)),[e,l,n],l>0),i=Xe((()=>e(l+n)),[e,l,n],l+n<s);return D(t.Fragment,null,s>n&&D(t.Fragment,null,D("button",{className:"previous",disabled:0==l,onClick:o},"←"),D("button",{className:"next",disabled:l+n>=s,onClick:i},"→"),l+1," to ",q(s,l+n)," of "),s," ",1!=s?r:a)},gt=({indexes:e,indexesId:t,indexId:l,s:n})=>D(Pe,{uniqueId:Se("i",t,l),summary:"Index: "+l,s:n},X(s.useSliceIds(l,e),(s=>D(pt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:n,key:s})))),pt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:n})=>{const a=Se("i",t,s,l),[r,o]=Ve(a,n);return D(Pe,{uniqueId:a,summary:"Slice: "+l,editable:r,handleEditable:o,s:n},D(it,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),n=s.useIndexIds(l);return L(l)?null:D(Pe,{uniqueId:Se("i",e),summary:"Indexes: "+(e??u),s:t},Y(n)?"No indexes defined":xe(n,(s=>D(gt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},It=({metrics:e,metricId:t})=>D("tr",null,D("th",null,t),D("td",null,e?.getTableId(t)),D("td",null,s.useMetric(t,e))),ft=({metricsId:e,s:t})=>{const l=s.useMetrics(e),n=s.useMetricIds(l);return L(l)?null:D(Pe,{uniqueId:Se("m",e),summary:"Metrics: "+(e??u),s:t},Y(n)?"No metrics defined":D("table",null,D("thead",null,D("th",null,"Metric Id"),D("th",null,"Table Id"),D("th",null,"Metric")),D("tbody",null,X(n,(e=>D(It,{metrics:l,metricId:e,key:e}))))))},yt=({queries:e,queriesId:t,queryId:l,s:n})=>{const a=Se("q",t,l),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n);return D(Pe,{uniqueId:a,summary:"Query: "+l,s:n},D(ut,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},wt=({queriesId:e,s:t})=>{const l=s.useQueries(e),n=s.useQueryIds(l);return L(l)?null:D(Pe,{uniqueId:Se("q",e),summary:"Queries: "+(e??u),s:t},Y(n)?"No queries defined":xe(n,(s=>D(yt,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},Ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const n=Se("r",t,s),[a,r]=Ve(n,l);return D(Pe,{uniqueId:n,summary:"Relationship: "+s,editable:a,handleEditable:r,s:l},D(dt,{relationshipId:s,relationships:e,editable:a}))},vt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),n=s.useRelationshipIds(l);return L(l)?null:D(Pe,{uniqueId:Se("r",e),summary:"Relationships: "+(e??u),s:t},Y(n)?"No relationships defined":xe(n,(s=>D(Ct,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},kt=({tableId:e,store:t,storeId:l,s:n})=>{const a=Se("t",l,e),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n),[u,c]=Ve(a,n);return D(Pe,{uniqueId:a,summary:m+": "+e,editable:u,handleEditable:c,s:n},D(rt,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},Tt=({store:e,storeId:t,s:l})=>{const n=Se("v",t),[a,r]=Ve(n,l);return Y(s.useValueIds(e))?null:D(Pe,{uniqueId:n,summary:v,editable:a,handleEditable:r,s:l},D(ot,{store:e,editable:a}))},St=({storeId:e,s:t})=>{const l=s.useStore(e),n=s.useTableIds(l);return L(l)?null:D(Pe,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??u),s:t},D(Tt,{storeId:e,store:l,s:t}),xe(n,(s=>D(kt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},xt=({s:e})=>{const t=H(null),l=H(0),[n,a]=W(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);j((()=>{const e=t.current;if(e&&!n){const t=new MutationObserver((()=>{e.scrollWidth>=M(r)+e.clientWidth&&e.scrollHeight>=M(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[n,r,o]);const i=Q((t=>{const{scrollLeft:s,scrollTop:n}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{a(!0),e.setPartialValues({scrollLeft:s,scrollTop:n})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),g=s.useIndexesIds(),p=s.useRelationships(),b=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return L(d)&&Y(u)&&L(c)&&Y(h)&&L(m)&&Y(g)&&L(p)&&Y(b)&&L(I)&&Y(f)?D("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):D("article",{ref:t,onScroll:i},D(St,{s:e}),X(u,(t=>D(St,{storeId:t,s:e,key:t}))),D(ft,{s:e}),X(h,(t=>D(ft,{metricsId:t,s:e,key:t}))),D(bt,{s:e}),X(g,(t=>D(bt,{indexesId:t,s:e,key:t}))),D(vt,{s:e}),X(b,(t=>D(vt,{relationshipsId:t,s:e,key:t}))),D(wt,{s:e}),X(f,(t=>D(wt,{queriesId:t,s:e,key:t}))))};class Vt extends P{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?D("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Rt=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!1),[],e),n=s.useSetValueCallback(ve,(e=>Number(e[T].dataset.id)),[],e);return D("header",null,D("img",{title:Ie}),D("span",null,Ie),X(fe,((e,s)=>s==t?null:D("img",{onClick:n,"data-id":s,title:"Dock to "+e,key:s}))),D("img",{onClick:l,title:"Close"}))},qt=({s:e})=>{const t=s.useValue(ve,e)??1;return s.useValue(ke,e)?D("main",{"data-position":t},D(Rt,{s:e}),D(Vt,null,D(xt,{s:e}))):null},Mt=e=>t=>{return s=(t,s)=>t+e(s),At(t).reduce(s,0);var s},Nt=e=>e?.size??0,Lt=Mt(Nt),Et=Mt(Lt),zt=Mt(Et),Ot=(e,t)=>e?.has(t)??!1,$t=e=>L(e)||0==Nt(e),At=e=>[...e?.values()??[]],Ft=e=>e.clear(),Jt=(e,t)=>e?.forEach(t),Pt=(e,t)=>e?.delete(t),Bt=e=>new Map(e),Dt=e=>[...e?.keys()??[]],Qt=(e,t)=>e?.get(t),jt=(e,t)=>Jt(e,((e,s)=>t(s,e))),Ht=(e,t,s)=>L(s)?(Pt(e,t),e):e?.set(t,s),Wt=(e,t,s,l)=>(Ot(e,t)?l?.(Qt(e,t)):Ht(e,t,s()),Qt(e,t)),Ut=(e,t,s,l=Ht)=>(ue(t,((t,l)=>s(e,l,t))),jt(e,(s=>ie(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const n={};return Jt(e,((e,a)=>{if(!s?.(e,a)){const s=t?t(e,a):e;l?.(s)||(n[a]=s)}})),n},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),$t,ce),Xt=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),$t,ce),Yt=(e,t)=>{const s=Bt();return Jt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Zt=e=>Yt(e,Yt),_t=e=>Yt(e,Zt),es=(e,t,s,l,n=0)=>E((s?Wt:Qt)(e,t[n],n>F(t)-2?s:Bt),(a=>{if(n>F(t)-2)return l?.(a)&&Ht(e,t[n]),a;const r=es(a,t,s,l,n+1);return $t(a)&&Ht(e,t[n]),r})),ts=Bt(),ss=Bt(),ls="storage",ns=e=>new Set($(e)||L(e)?e:[e]),as=(e,t)=>e?.add(t),rs=/^\d+$/,os=()=>{const e=[];let t=0;return[s=>(s?_(e):null)??n+t++,t=>{rs.test(t)&&F(e)<1e3&&Z(e,t)}]},is=e=>[e,e],ds=(e,t=Lt)=>t(e[0])+t(e[1]),us=()=>[Bt(),Bt()],cs=e=>[...e],hs=([e,t])=>e===t;Bt(X("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(n),((e,t)=>[e,t])));const ms=(e,t,s)=>Ht(e,t,Qt(e,t)==-s?void 0:s),gs=()=>{let e,t,s=!1,l=!1,a=0,r=[];const i=Bt(),h=Bt(),T=Bt(),S=Bt(),V=Bt(),R=Bt(),q=Bt(),M=Bt(),N=Bt(),J=Bt(),P=Bt(),B=Bt(),D=Bt(),Q=Bt(),j=ns(),H=Bt(),W=Bt(),U=Bt(),Y=Bt(),_=us(),ee=us(),te=us(),se=us(),le=us(),ne=us(),ae=us(),oe=us(),me=us(),be=us(),Ie=us(),fe=us(),ye=us(),we=us(),Ce=us(),ve=us(),ke=us(),Te=us(),Se=us(),xe=us(),Ve=us(),Re=us(),qe=Bt(),Me=us(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=os(),l=Bt();return[(s,a,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return Ht(l,d,[s,a,r,o,i]),as(es(a,r??[n],ns),d),d},(t,s,...a)=>K(((e,t=[n])=>{const s=[],l=(e,n)=>n==F(t)?Z(s,e):null===t[n]?Jt(e,(e=>l(e,n+1))):K([t[n],null],(t=>l(Qt(e,t),n+1)));return l(e,0),s})(t,s),(t=>Jt(t,(t=>Qt(l,t)[0](e,...s??[],...a))))),e=>E(Qt(l,e),(([,t,a])=>(es(t,a??[n],void 0,(t=>(Pt(t,e),$t(t)?1:0))),Ht(l,e),s(e),a))),t=>E(Qt(l,t),(([t,,s=[],l,n])=>{const a=(...r)=>{const o=F(r);o==F(s)?t(e,...r,...n(r)):L(s[o])?K(l[o]?.(...r)??[],(e=>a(...r,e))):a(...r,s[o])};a()}))]})(),Oe=e=>{if(!he(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!z(t)&&t!=o||(Be(e[u])!=t&&de(e,u),0))},$e=$,Ae=(t,s)=>(!e||Ot(P,s)||bt(s))&&he(t,((e,t)=>Fe(s,t,e)),(()=>bt(s))),Fe=(e,t,s,l)=>he(l?s:He(s,e,t),((l,n)=>E(Je(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>bt(e,t))),Je=(t,s,l,n)=>e?E(Qt(Qt(P,t),l),(e=>Be(n)!=e[d]?bt(t,s,l,n,e[u]):n),(()=>bt(t,s,l,n))):L(Be(n))?bt(t,s,l,n):n,Pe=(e,t)=>he(t?e:We(e),((t,s)=>E(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?E(Qt(D,e),(t=>Be(s)!=t[d]?It(e,s,t[u]):s),(()=>It(e,s))):L(Be(s))?It(e,s):s,He=(e,t,s)=>(E(Qt(B,t),(([l,n])=>{Jt(l,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(n,(l=>{ie(e,l)||bt(t,s,l)}))})),e),We=e=>(t&&(Jt(Q,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(j,(t=>{ie(e,t)||It(t)}))),e),Ue=e=>Ut(P,e,((e,t,s)=>{const l=Bt(),n=ns();Ut(Wt(P,t,Bt),s,((e,t,s)=>{Ht(e,t,s),E(s[u],(e=>Ht(l,t,e)),(()=>as(n,t)))})),Ht(B,t,[l,n])}),((e,t)=>{Ht(P,t),Ht(B,t)})),Ge=e=>Ut(D,e,((e,t,s)=>{Ht(D,t,s),E(s[u],(e=>Ht(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{Ht(D,t),Ht(Q,t),Pt(j,t)})),Ke=e=>ce(e)?Rs():ks(e),Xe=e=>Ut(U,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Ut(Wt(U,e,(()=>(ut(e,1),Ht(H,e,os()),Ht(W,e,Bt()),Bt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,n)=>Ut(Wt(t,s,(()=>(ct(e,s,1),Bt()))),l,((t,l,n)=>_e(e,s,t,l,n)),((l,a)=>it(e,t,s,l,a,n))),_e=(e,t,s,l,n)=>{Ot(s,l)||ht(e,t,l,1);const a=Qt(s,l);n!==a&&(mt(e,t,l,a,n),Ht(s,l,n))},et=(e,t,s,l,n)=>E(Qt(t,s),(t=>_e(e,s,t,l,n)),(()=>Ze(e,t,s,He({[l]:n},e,s)))),tt=e=>ce(e)?Ns():Ts(e),st=e=>Ut(Y,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{Ot(Y,e)||gt(e,1);const s=Qt(Y,e);t!==s&&(pt(e,s,t),Ht(Y,e,t))},nt=(e,t)=>{const[s]=Qt(H,e),l=s(t);return Ot(Qt(U,e),l)?nt(e,t):l},at=e=>Qt(U,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Qt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,n,a)=>{const r=Qt(Qt(B,e)?.[0],n);if(!L(r)&&!a)return _e(e,s,l,n,r);const o=t=>{mt(e,s,t,Qt(l,t)),ht(e,s,t,-1),Ht(l,t)};L(r)?o(n):jt(l,o),$t(l)&&(ct(e,s,-1),$t(Ht(t,s))&&(ut(e,-1),Ht(U,e),Ht(H,e),Ht(W,e)))},dt=e=>{const t=Qt(Q,e);if(!L(t))return lt(e,t);pt(e,Qt(Y,e)),gt(e,-1),Ht(Y,e)},ut=(e,t)=>ms(i,e,t),ct=(e,t,s)=>ms(Wt(S,e,Bt),t,s)&&Ht(T,e,Wt(T,e,(()=>0))+s),ht=(e,t,s,l)=>{const n=Qt(W,e),a=Qt(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&ms(Wt(h,e,Bt),s,l),Ht(n,s,a!=-l?a+l:null),ms(Wt(Wt(V,e,Bt),t,Bt),s,l)},mt=(e,t,s,l,n)=>{Wt(Wt(Wt(R,e,Bt),t,Bt),s,(()=>[l,0]))[1]=n,r[3]?.(e,t,s,n)},gt=(e,t)=>ms(q,e,t),pt=(e,t,s)=>{Wt(M,e,(()=>[t,0]))[1]=s,r[4]?.(e,s)},bt=(e,t,s,l,n)=>(Z(Wt(Wt(Wt(N,e,Bt),t,Bt),s,(()=>[])),l),n),It=(e,t,s)=>(Z(Wt(J,e,(()=>[])),t),s),ft=(e,t,s)=>E(Qt(Qt(Qt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ss(e,t,s))])),yt=e=>E(Qt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ps(e))])),wt=e=>$t(N)||$t(ve[e])?0:Jt(e?_t(N):N,((t,s)=>Jt(t,((t,l)=>Jt(t,((t,n)=>Le(ve[e],[s,l,n],t))))))),Ct=e=>$t(J)||$t(ke[e])?0:Jt(e?Yt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!$t(e))return Le(t,l,(()=>Gt(e))),jt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=bs();t!=s&&Le(_[e],void 0,t);const l=$t(be[e]),n=$t(ye[e])&&$t(we[e])&&$t(me[e])&&$t(Ie[e])&&$t(ne[e])&&$t(ae[e])&&$t(oe[e])&&l&&$t(te[e])&&$t(se[e]),a=$t(Ce[e])&&$t(fe[e])&&$t(le[e])&&$t(ee[e]);if(!n||!a){const t=e?[Yt(i),Zt(h),Yt(T),Zt(S),_t(V),_t(R)]:[i,h,T,S,V,R];if(!n){vt(t[0],te[e],se[e]),Jt(t[1],((t,s)=>vt(t,ne[e],ae[e],[s]))),Jt(t[2],((t,s)=>{0!=t&&Le(oe[e],[s],qt(s))}));const s=ns();Jt(t[3],((t,n)=>{vt(t,me[e],Ie[e],[n])&&!l&&(Le(be[e],[n,null]),as(s,n))})),l||Jt(t[5],((t,l)=>{if(!Ot(s,l)){const s=ns();Jt(t,(e=>Jt(e,(([t,l],n)=>l!==t?as(s,n):Pt(e,n))))),Jt(s,(t=>Le(be[e],[l,t])))}})),Jt(t[4],((t,s)=>Jt(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!a){let s;Jt(t[5],((t,l)=>{let n;Jt(t,((t,a)=>{let r;Jt(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,a,i],o,t,ft),s=n=r=1)})),r&&Le(fe[e],[l,a],ft)})),n&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},Tt=e=>{const t=Cs();t!=l&&Le(Te[e],void 0,t);const s=$t(xe[e])&&$t(Ve[e]),n=$t(Re[e])&&$t(Se[e]);if(!s||!n){const t=e?[Yt(q),Yt(M)]:[q,M];if(s||vt(t[0],xe[e],Ve[e]),!n){let s;Jt(t[1],(([t,l],n)=>{l!==t&&(Le(Re[e],[n],l,t,yt),s=1)})),s&&Le(Se[e],void 0,yt)}}},St=(e,...t)=>(zs((()=>e(...X(t,x)))),As),xt=()=>Xt(U),Vt=()=>Dt(U),Rt=e=>Dt(Qt(W,x(e))),qt=e=>Nt(Qt(U,x(e))),Mt=e=>Dt(Qt(U,x(e))),At=(e,t,s,l=0,n)=>{return X(A(G((a=Qt(U,x(e)),r=(e,s)=>[L(t)?s:Qt(e,x(t)),s],X([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,L(n)?n:l+n),(([,e])=>e));var a,r},ts=(e,t)=>Dt(Qt(Qt(U,x(e)),x(t))),ss=(e,t,s)=>Qt(Qt(Qt(U,x(e)),x(t)),x(s)),ls=()=>Gt(Y),rs=()=>Dt(Y),ps=e=>Qt(Y,x(e)),bs=()=>!$t(U),Is=e=>Ot(U,x(e)),fs=(e,t)=>Ot(Qt(W,x(e)),x(t)),ys=(e,t)=>Ot(Qt(U,x(e)),x(t)),ws=(e,t,s)=>Ot(Qt(Qt(U,x(e)),x(t)),x(s)),Cs=()=>!$t(Y),vs=e=>Ot(Y,x(e)),ks=e=>St((()=>(e=>he(e,Ae,bt))(e)?Xe(e):0)),Ts=e=>St((()=>Pe(e)?st(e):0)),Ss=e=>{try{Ke(ge(e))}catch{}return As},xs=t=>St((()=>{if((e=he(t,(e=>he(e,Oe))))&&(Ue(t),!$t(U))){const e=xt();Rs(),ks(e)}})),Vs=e=>St((()=>{if(t=(e=>he(e,Oe))(e)){const s=ls();Es(),Ns(),t=!0,Ge(e),Ts(s)}})),Rs=()=>St((()=>Xe({}))),qs=e=>St((e=>Ot(U,e)?rt(e):0),e),Ms=(e,t)=>St(((e,t)=>E(Qt(U,e),(s=>Ot(s,t)?ot(e,s,t):0))),e,t),Ns=()=>St((()=>st({}))),Ls=()=>St((()=>{Ue({}),e=!1})),Es=()=>St((()=>{Ge({}),t=!1})),zs=(e,t)=>{if(-1!=a){Os();const s=e();return $s(t),s}},Os=()=>(-1!=a&&a++,1==a&&(r[0]?.(),Le(qe)),As),$s=e=>(a>0&&(a--,0==a&&(a=1,wt(1),$t(R)||kt(1),Ct(1),$t(M)||Tt(1),e?.(As)&&(Jt(R,((e,t)=>Jt(e,((e,s)=>Jt(e,(([e],l)=>De(As,t,s,l,e))))))),Ft(R),Jt(M,(([e],t)=>Qe(As,t,e))),Ft(M)),Le(Me[0],void 0),a=-1,wt(0),$t(R)||kt(0),Ct(0),$t(M)||Tt(0),r[1]?.(),Le(Me[1],void 0),r[2]?.(),a=0,s=bs(),l=Cs(),K([i,h,T,S,V,R,N,q,M,J],Ft))),As),As={getContent:()=>[xt(),ls()],getTables:xt,getTableIds:Vt,getTable:e=>Kt(Qt(U,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:Mt,getSortedRowIds:At,getRow:(e,t)=>Gt(Qt(Qt(U,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ls,getValueIds:rs,getValue:ps,hasTables:bs,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>pe(U),getValuesJson:()=>pe(Y),getJson:()=>pe([U,Y]),getTablesSchemaJson:()=>pe(P),getValuesSchemaJson:()=>pe(D),getSchemaJson:()=>pe([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>St((()=>$e(e)?(([e,t])=>{(ce(e)?Rs:ks)(e),(ce(t)?Ns:Ts)(t)})(e):0)),setTables:ks,setTable:(e,t)=>St((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>St(((e,t)=>Fe(e,t,s)?Ze(e,at(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,at(e),l=nt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>St(((e,t)=>{if(Fe(e,t,s,1)){const l=at(e);ue(s,((s,n)=>et(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>St(((e,t,s)=>E(Je(e,t,s,O(l)?l(ss(e,t,s)):l),(l=>et(e,at(e),t,s,l)))),e,t,s),setValues:Ts,setPartialValues:e=>St((()=>Pe(e,1)?ue(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>St((e=>E(je(e,O(t)?t(ps(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>St((()=>{ue(e[0],((e,t)=>L(e)?qs(t):ue(e,((e,s)=>L(e)?Ms(t,s):ue(e,((e,l)=>De(As,t,s,l,e))))))),ue(e[1],((e,t)=>Qe(As,t,e)))})),setTablesJson:Ss,setValuesJson:e=>{try{tt(ge(e))}catch{}return As},setJson:e=>St((()=>{try{const[t,s]=ge(e);Ke(t),tt(s)}catch{Ss(e)}})),setTablesSchema:xs,setValuesSchema:Vs,setSchema:(e,t)=>St((()=>{xs(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>St(((e,t,s)=>E(Qt(U,e),(n=>E(Qt(n,t),(a=>Ot(a,s)?it(e,n,t,a,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>St((e=>Ot(Y,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>St((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Qt(i,t)?void 0:Gt(e,((e,s)=>-1===Qt(Qt(S,t),s)?void 0:Gt(e,(([,e])=>e),(e=>hs(e)))),$t,ce)),$t,ce),Gt(M,(([,e])=>e),(e=>hs(e))),1],getTransactionLog:()=>[!$t(R),!$t(M),Xt(R,cs,hs),Xt(N),Gt(M,cs,hs),Gt(J),Gt(i),Kt(S),Xt(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Jt(U,((t,s)=>e(s,(e=>Jt(t,((t,s)=>e(s,(e=>jt(t,e))))))))),forEachTableCell:(e,t)=>jt(Qt(W,x(e)),t),forEachRow:(e,t)=>Jt(Qt(U,x(e)),((e,s)=>t(s,(t=>jt(e,t))))),forEachCell:(e,t,s)=>jt(Qt(Qt(U,x(e)),x(t)),s),forEachValue:e=>jt(Y,e),addSortedRowIdsListener:(e,t,s,l,n,a,r)=>{let o=At(e,t,s,l,n);return Ne((()=>{const r=At(e,t,s,l,n);var i,d,u;d=o,F(i=r)===F(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,a(As,e,t,s,l,n,o))}),be[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:ds(_),tables:ds(ee),tableIds:ds(te),hasTable:ds(se),table:ds(le),tableCellIds:ds(ne),hasTableCell:ds(ae,Et),rowCount:ds(oe),rowIds:ds(me),sortedRowIds:ds(be),hasRow:ds(Ie,Et),row:ds(fe,Et),cellIds:ds(ye,Et),hasCell:ds(we,zt),cell:ds(Ce,zt),invalidCell:ds(ve,zt),hasValues:ds(Te),values:ds(Se),valueIds:ds(xe),hasValue:ds(Ve),value:ds(Re),invalidValue:ds(ke),transaction:Lt(qe)+ds(Me)}),isMergeable:()=>!1,createStore:gs,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,n)=>r=[e,t,s,l,n]};return ue({[c+g]:[0,_,[],()=>[bs()]],[g]:[0,ee],[p]:[0,te],[c+m]:[1,se,[Vt],e=>[Is(...e)]],[m]:[1,le,[Vt]],[m+w]:[1,ne,[Vt]],[c+m+y]:[2,ae,[Vt,Rt],e=>[fs(...e)]],[I]:[1,oe,[Vt]],[f]:[1,me,[Vt]],[c+b]:[2,Ie,[Vt,Mt],e=>[ys(...e)]],[b]:[2,fe,[Vt,Mt]],[w]:[2,ye,[Vt,Mt]],[c+y]:[3,we,[Vt,Mt,ts],e=>[ws(...e)]],[y]:[3,Ce,[Vt,Mt,ts],e=>is(ss(...e))],InvalidCell:[3,ve],[c+v]:[0,Te,[],()=>[Cs()]],[v]:[0,Se],[k]:[0,xe],[c+C]:[1,Ve,[rs],e=>[vs(...e)]],[C]:[1,Re,[rs],e=>is(ps(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],n)=>{As["add"+n+"Listener"]=(...n)=>Ne(n[e],t[n[e+1]?1:0],e>0?A(n,0,e):void 0,s,l)})),re(As)};e.Inspector=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(gs),n=fe.indexOf(e);return s.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,n,a,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Wt(ts,i,(()=>0)),Wt(ss,i,(()=>[]));const[p,b,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ce(e)||!ce(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ce(e)||!ce(t),t.setContent]:J("Store type not supported by this Persister"))(r,e),w=t=>{(p&&$(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await S((async()=>{try{const e=await t();$(e)?w(e):J("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),x),v=()=>(u&&(n(u),u=void 0),x),k=async e=>(1!=h&&(h=2,g++,await S((async()=>{try{await s(b,e)}catch(e){}h=0}))),x),T=()=>(E(c,e.delListener),c=void 0,x),S=async(...e)=>(Z(Qt(ss,i),...e),await(async()=>{if(!Qt(ts,i)){for(Ht(ts,i,1);!L(d=_(Qt(ss,i)));)try{await d()}catch(e){}Ht(ts,i,0)}})(),x),x={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return x},stopAutoLoad:v,isAutoLoading:()=>!L(u),save:k,startAutoSave:async()=>(await T().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),x),stopAutoSave:T,isAutoSaving:()=>!L(c),schedule:S,getStore:()=>e,destroy:()=>(Qt(ss,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return re(x)})(e,(async()=>{return e=s.getItem(t),ge(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),me(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(ge(l.newValue))}catch{e()}};return V.addEventListener(ls,l),l}),(e=>V.removeEventListener(ls,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==n?1:n,open:!!t}]),await e.startAutoSave()})),D(B,null,D("aside",{id:be},D(Je,{s:l}),D(qt,{s:l})),D("style",null,Fe))}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("../../ui-react/with-schemas/index.js")):"function"==typeof define&&define.amd?define(["exports","react","../ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactInspector={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,n="",a=l(n),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Has",h="Ids",m="Table",g=m+"s",p=m+h,b="Row",I=b+"Count",f=b+h,y="Cell",w=y+h,C="Value",v=C+"s",k=C+h,T="currentTarget",S="value",x=e=>n+e,V=globalThis.window,R=Math,q=R.min,M=R.floor,N=isFinite,L=e=>null==e,E=(e,t,s)=>L(e)?s?.():t(e),z=e=>e==a||e==r,O=e=>l(e)==i,$=e=>Array.isArray(e),A=(e,t,s)=>e.slice(t,s),F=e=>e.length,J=e=>{throw Error(e)},{PureComponent:P,Fragment:B,createElement:D,useCallback:Q,useLayoutEffect:j,useRef:H,useState:W}=t,U=(e,...t)=>L(e)?{}:e(...t),G=(e,t)=>e.sort(t),K=(e,t)=>e.forEach(t),X=(e,t)=>e.map(t),Y=e=>0==F(e),Z=(e,...t)=>e.push(...t),_=e=>e.shift(),ee=Object,te=e=>ee.getPrototypeOf(e),se=ee.entries,le=ee.isFrozen,ne=e=>!L(e)&&E(te(e),(e=>e==ee.prototype||L(te(e))),(()=>!0)),ae=ee.keys,re=ee.freeze,oe=(e=[])=>ee.fromEntries(e),ie=(e,t)=>t in e,de=(e,t)=>(delete e[t],e),ue=(e,t)=>X(se(e),(([e,s])=>t(s,e))),ce=e=>ne(e)&&0==(e=>F(ae(e)))(e),he=(e,t,s,l=0)=>L(e)||!ne(e)||!l&&ce(e)||le(e)?(s?.(),!1):(ue(e,((s,l)=>{t(s,l)||de(e,l)})),!!l||!ce(e)),me=JSON.stringify,ge=JSON.parse,pe=e=>me(e,((e,t)=>t instanceof Map?ee.fromEntries([...t]):t)),be="tinybaseInspector",Ie="TinyBase Inspector",fe=["left","top","bottom","right","full"],ye="state",we="sort",Ce="open",ve="position",ke=Ce,Te="editable",Se=(...e)=>pe(e),xe=(e,t)=>X(G([...e]),t),Ve=(e,t)=>[!!s.useCell(ye,e,Te,t),Q((s=>{t.setCell(ye,e,Te,(e=>!e)),s.preventDefault()}),[t,e])],Re="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",qe='content:url("',Me=qe+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ne='</svg>")',Le=qe+"data:image/svg+xml,%3csvg viewBox='0 0 680 680' xmlns='http://www.w3.org/2000/svg' style='width:680px%3bheight:680px'%3e %3cpath stroke='white' stroke-width='80' fill='none' d='M340 617a84 241 90 11.01 0zM131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124zm-12-127a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e %3cpath fill='%23d81b60' d='M131 475a94 254 70 10428-124 114 286 70 01-428 124zm0-140a94 254 70 10428-124 114 286 70 01-428 124z' /%3e %3cpath d='M249 619a94 240 90 00308-128 114 289 70 01-308 128zM119 208a94 254 70 00306 38 90 260 90 01-306-38zm221 3a74 241 90 11.01 0z' /%3e%3c/svg%3e\")",Ee=X([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Me+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+Ne)),ze=Me+"<path d='M20 20l60 60M20 80l60-60' />"+Ne,Oe=Me+`<path d='${Re}' />`+Ne,$e=Me+`<path d='${Re}M20 20l60 60' />`+Ne,Ae="*::-webkit-scrollbar",Fe=((e,t="")=>e.join(t))(ue({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Ae]:"width:0.5rem;height:0.5rem;",[Ae+"-track"]:"background:#111",[Ae+"-thumb"]:"background:#999;border:1px solid #111",[Ae+"-thumb:hover"]:"background:#fff",[Ae+"-corner"]:"background:#111",img:"width:1rem;height:1rem;background:#111;border:0;vertical-align:text-bottom",">img":"padding:0.25rem;bottom:0;right:0;position:fixed;"+Le,...oe(X(["bottom:0;left:0","top:0;right:0"],((e,t)=>[`>img[data-position='${t}']`,e]))),main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;",...oe(X(["bottom:0;left:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:30vh","bottom:0;left:0;width:100vw;height:30vh","top:0;right:0;width:35vw;height:100vh","top:0;right:0;width:100vw;height:100vh"],((e,t)=>[`main[data-position='${t}']`,e]))),header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":Le,"header>img:nth-of-type(6)":ze,...oe(X(Ee,((e,t)=>[`header>img[data-id='${t}']`,e]))),"header>span":"flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-left:0.25rem",article:"padding:0.25rem 0.25rem 0.25rem 0.5rem;overflow:auto;flex:1",details:"margin-left:0.75rem;width:fit-content;","details img":"display:none","details[open]>summary img":"display:unset;background:none;margin-left:0.25rem","details[open]>summary img.edit":Oe,"details[open]>summary img.done":$e,summary:"margin-left:-0.75rem;line-height:1.25rem;user-select:none;width:fit-content",table:"border-collapse:collapse;table-layout:fixed;margin-bottom:0.5rem","table input":"background:#111;color:unset;padding:0 0.25rem;border:0;font-size:unset;vertical-align:top;margin:0",'table input[type="number"]':"width:4rem","table tbody button":"font-size:0;background:#fff;border-radius:50%;margin:0 0.125rem 0 0;width:0.85rem;color:#111","table button:first-letter":"font-size:0.75rem",thead:"background:#222","th:nth-of-type(1)":"min-width:2rem;","th.sorted":"background:#000","table caption":"text-align:left;white-space:nowrap;line-height:1.25rem",button:"width:1.5rem;border:none;background:none;color:#fff;padding:0","button[disabled]":"color:#777","button.next":"margin-right:0.5rem",[`th,#${be} td`]:"overflow:hidden;text-overflow:ellipsis;padding:0.25rem 0.5rem;max-width:12rem;white-space:nowrap;border-width:1px 0;border-style:solid;border-color:#777;text-align:left","span.warn":"margin:0.25rem;color:#d81b60"},((e,t)=>e?`#${be} ${t}{${e}}`:""))),Je=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!0),[],e);return s.useValue(ke,e)?null:D("img",{onClick:l,title:Ie,"data-position":t})},Pe=({uniqueId:e,summary:t,editable:l,handleEditable:n,children:a,s:r})=>{const o=!!s.useCell(ye,e,Ce,r),i=s.useSetCellCallback(ye,e,Ce,(e=>e[T].open),[],r);return D("details",{open:o,onToggle:i},D("summary",null,t,n?D("img",{onClick:n,className:l?"done":"edit"}):null),a)},Be=e=>{const t=l(e);return z(t)||t==o&&N(e)?t:void 0},De=(e,t,s,l,n)=>L(n)?e.delCell(t,s,l,!0):e.setCell(t,s,l,n),Qe=(e,t,s)=>L(s)?e.delValue(t):e.setValue(t,s),je=(e,t,s,l)=>e==a?t:e==o?s:l,{useCallback:He,useMemo:We,useState:Ue}=t,Ge="editable",Ke=(e,t)=>X(s.useTableCellIds(e,t),(t=>e+"."+t)),Xe=(e,t,s)=>{const l=He(e,t);return s?l:void 0},Ye=(...e)=>We((()=>e),e),Ze=(e,t)=>We((()=>({store:e,tableId:t})),[e,t]),_e=(e,t)=>We((()=>({queries:e,queryId:t})),[e,t]),et=(e,t=!1,s,l=0,n,a,r,o)=>{const[[i,d,u],c]=Ue([e,t,l]),h=He((e=>{c(e),o?.(e)}),[o]),m=Xe((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),g=He((e=>h([i,d,e])),[h,i,d]),p=!0===r?mt:r;return[[i,d,u],m,We((()=>!1===r?null:D(p,{offset:u,limit:n,total:a,onChange:g})),[r,p,u,n,a,g])]},tt=(e,t,s)=>We((()=>{const n=t??e;return r=$(n)?oe(X(n,(e=>[e,e]))):n,o=(e,t)=>{return{label:t,component:s,...(n=e,l(n)==a?{label:e}:e)};var n},oe(ue(r,((e,t)=>[t,o(e,t)])));var r,o}),[t,s,e]),st=({className:e,headerRow:t,idColumn:s,params:[l,n,a,r,o,i]})=>D("table",{className:e},i?D("caption",null,i):null,!1===t?null:D("thead",null,D("tr",null,!1===s?null:D(lt,{sort:r??[],label:"Id",onClick:o}),ue(l,(({label:e},t)=>D(lt,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),D("tbody",null,X(a,(e=>D("tr",{key:e},!1===s?null:D("th",null,e),ue(l,(({component:t,getComponentProps:s},l)=>D("td",{key:l},D(t,{...U(s,e,l),...n,rowId:e,cellId:l}))))))))),lt=({cellId:e,sort:[t,s],label:l=e??n,onClick:a})=>D("th",{onClick:Xe((()=>a?.(e)),[a,e],a),className:L(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},L(s)||t!=e?null:(s?"↓":"↑")+" ",l),nt=({localRowId:e,params:[l,n,a,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return D("tr",null,!1===l?null:D(t.Fragment,null,D("th",null,e),D("th",null,u)),ue(n,(({component:t,getComponentProps:s},l)=>{const[n,o]=l.split(".",2),i=n===a?e:n===r?u:null;return L(i)?null:D("td",{key:l},D(t,{...U(s,i,o),store:d,tableId:n,rowId:i,cellId:o}))})))},at=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:n=!0})=>{const[i,d]=Ue(),[u,c]=Ue(),[h,m]=Ue(),[g,p]=Ue(),[b,I]=Ue();u!==e&&(d(Be(e)),c(e),m(e+""),p(Number(e)||0),I(!!e));const f=He(((e,s)=>{s(e),c(e),t(e)}),[t]),y=He((()=>{if(!l?.()){const e=je(i,o,r,a),s=je(e,h,g,b);d(e),c(s),t(s)}}),[l,t,h,g,b,i]);return D("div",{className:s},n?D("button",{className:i,onClick:y},i):null,je(i,D("input",{key:i,value:h,onChange:He((e=>f(e[T][S]+"",m)),[f])}),D("input",{key:i,type:"number",value:g,onChange:He((e=>f(Number(e[T][S]||0),p)),[f])}),D("input",{key:i,type:"checkbox",checked:b,onChange:He((e=>f(!!e[T].checked,I)),[f])})))},rt=({tableId:e,cellId:t,descending:l,offset:n,limit:a,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,g,p]=et(t,l,i,n,a,s.useRowCount(e,r),d,u);return D(st,{...h,params:Ye(tt(s.useTableCellIds(e,r),c,o?ct:s.CellView),Ze(r,e),s.useSortedRowIds(e,...m,a,r),m,g,p)})},ot=({store:e,editable:t=!1,valueComponent:l=(t?ht:s.ValueView),getValueComponentProps:n,className:a,headerRow:r,idColumn:o})=>D("table",{className:a},!1===r?null:D("thead",null,D("tr",null,!1===o?null:D("th",null,"Id"),D("th",null,C))),D("tbody",null,X(s.useValueIds(e),(t=>D("tr",{key:t},!1===o?null:D("th",null,t),D("td",null,D(l,{...U(n,t),valueId:t,store:e}))))))),it=({indexId:e,sliceId:t,indexes:l,editable:n,customCells:a,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return D(st,{...r,params:Ye(tt(s.useTableCellIds(d,i),a,n?ct:s.CellView),Ze(i,d),s.useSliceRowIds(e,t,o))})},dt=({relationshipId:e,relationships:l,editable:n,customCells:a,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=tt([...Ke(c,u),...Ke(h,u)],a,n?ct:s.CellView),g=Ye(i,m,c,h,e,d,u);return D("table",{className:r},!1===o?null:D("thead",null,D("tr",null,!1===i?null:D(t.Fragment,null,D("th",null,c,".Id"),D("th",null,h,".Id")),ue(m,(({label:e},t)=>D("th",{key:t},e))))),D("tbody",null,X(s.useRowIds(c,u),(e=>D(nt,{key:e,localRowId:e,params:g})))))},ut=({queryId:e,cellId:t,descending:l,offset:n,limit:a,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,g]=et(t,l,o,n,a,s.useResultRowCount(e,r),i,u);return D(st,{...c,params:Ye(tt(s.useResultTableCellIds(e,r),d,s.ResultCellView),_e(r,e),s.useResultSortedRowIds(e,...h,a,r),h,m,g)})},ct=({tableId:e,rowId:t,cellId:l,store:n,className:a,showType:r})=>D(at,{thing:s.useCell(e,t,l,n),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],n),className:a??Ge+y,showType:r,hasSchema:s.useStoreOrStoreById(n)?.hasTablesSchema}),ht=({valueId:e,store:t,className:l,showType:n})=>D(at,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Ge+C,showType:n,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),mt=({onChange:e,total:s,offset:l=0,limit:n=s,singular:a="row",plural:r=a+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Xe((()=>e(l-n)),[e,l,n],l>0),i=Xe((()=>e(l+n)),[e,l,n],l+n<s);return D(t.Fragment,null,s>n&&D(t.Fragment,null,D("button",{className:"previous",disabled:0==l,onClick:o},"←"),D("button",{className:"next",disabled:l+n>=s,onClick:i},"→"),l+1," to ",q(s,l+n)," of "),s," ",1!=s?r:a)},gt=({indexes:e,indexesId:t,indexId:l,s:n})=>D(Pe,{uniqueId:Se("i",t,l),summary:"Index: "+l,s:n},X(s.useSliceIds(l,e),(s=>D(pt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:n,key:s})))),pt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:n})=>{const a=Se("i",t,s,l),[r,o]=Ve(a,n);return D(Pe,{uniqueId:a,summary:"Slice: "+l,editable:r,handleEditable:o,s:n},D(it,{sliceId:l,indexId:s,indexes:e,editable:r}))},bt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),n=s.useIndexIds(l);return L(l)?null:D(Pe,{uniqueId:Se("i",e),summary:"Indexes: "+(e??u),s:t},Y(n)?"No indexes defined":xe(n,(s=>D(gt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},It=({metrics:e,metricId:t})=>D("tr",null,D("th",null,t),D("td",null,e?.getTableId(t)),D("td",null,s.useMetric(t,e))),ft=({metricsId:e,s:t})=>{const l=s.useMetrics(e),n=s.useMetricIds(l);return L(l)?null:D(Pe,{uniqueId:Se("m",e),summary:"Metrics: "+(e??u),s:t},Y(n)?"No metrics defined":D("table",null,D("thead",null,D("th",null,"Metric Id"),D("th",null,"Table Id"),D("th",null,"Metric")),D("tbody",null,X(n,(e=>D(It,{metrics:l,metricId:e,key:e}))))))},yt=({queries:e,queriesId:t,queryId:l,s:n})=>{const a=Se("q",t,l),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n);return D(Pe,{uniqueId:a,summary:"Query: "+l,s:n},D(ut,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},wt=({queriesId:e,s:t})=>{const l=s.useQueries(e),n=s.useQueryIds(l);return L(l)?null:D(Pe,{uniqueId:Se("q",e),summary:"Queries: "+(e??u),s:t},Y(n)?"No queries defined":xe(n,(s=>D(yt,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},Ct=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const n=Se("r",t,s),[a,r]=Ve(n,l);return D(Pe,{uniqueId:n,summary:"Relationship: "+s,editable:a,handleEditable:r,s:l},D(dt,{relationshipId:s,relationships:e,editable:a}))},vt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),n=s.useRelationshipIds(l);return L(l)?null:D(Pe,{uniqueId:Se("r",e),summary:"Relationships: "+(e??u),s:t},Y(n)?"No relationships defined":xe(n,(s=>D(Ct,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},kt=({tableId:e,store:t,storeId:l,s:n})=>{const a=Se("t",l,e),[r,o,i]=ge(s.useCell(ye,a,we,n)??"[]"),d=s.useSetCellCallback(ye,a,we,pe,[],n),[u,c]=Ve(a,n);return D(Pe,{uniqueId:a,summary:m+": "+e,editable:u,handleEditable:c,s:n},D(rt,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},Tt=({store:e,storeId:t,s:l})=>{const n=Se("v",t),[a,r]=Ve(n,l);return Y(s.useValueIds(e))?null:D(Pe,{uniqueId:n,summary:v,editable:a,handleEditable:r,s:l},D(ot,{store:e,editable:a}))},St=({storeId:e,s:t})=>{const l=s.useStore(e),n=s.useTableIds(l);return L(l)?null:D(Pe,{uniqueId:Se("s",e),summary:(l.isMergeable()?"Mergeable":"")+"Store: "+(e??u),s:t},D(Tt,{storeId:e,store:l,s:t}),xe(n,(s=>D(kt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},xt=({s:e})=>{const t=H(null),l=H(0),[n,a]=W(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);j((()=>{const e=t.current;if(e&&!n){const t=new MutationObserver((()=>{e.scrollWidth>=M(r)+e.clientWidth&&e.scrollHeight>=M(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[n,r,o]);const i=Q((t=>{const{scrollLeft:s,scrollTop:n}=t[T];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{a(!0),e.setPartialValues({scrollLeft:s,scrollTop:n})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),g=s.useIndexesIds(),p=s.useRelationships(),b=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return L(d)&&Y(u)&&L(c)&&Y(h)&&L(m)&&Y(g)&&L(p)&&Y(b)&&L(I)&&Y(f)?D("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the Inspector inside a Provider component."):D("article",{ref:t,onScroll:i},D(St,{s:e}),X(u,(t=>D(St,{storeId:t,s:e,key:t}))),D(ft,{s:e}),X(h,(t=>D(ft,{metricsId:t,s:e,key:t}))),D(bt,{s:e}),X(g,(t=>D(bt,{indexesId:t,s:e,key:t}))),D(vt,{s:e}),X(b,(t=>D(vt,{relationshipsId:t,s:e,key:t}))),D(wt,{s:e}),X(f,(t=>D(wt,{queriesId:t,s:e,key:t}))))};class Vt extends P{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError(){return{e:1}}componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?D("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const Rt=({s:e})=>{const t=s.useValue(ve,e)??1,l=s.useSetValueCallback(ke,(()=>!1),[],e),n=s.useSetValueCallback(ve,(e=>Number(e[T].dataset.id)),[],e);return D("header",null,D("img",{title:Ie}),D("span",null,Ie),X(fe,((e,s)=>s==t?null:D("img",{onClick:n,"data-id":s,title:"Dock to "+e,key:s}))),D("img",{onClick:l,title:"Close"}))},qt=({s:e})=>{const t=s.useValue(ve,e)??1;return s.useValue(ke,e)?D("main",{"data-position":t},D(Rt,{s:e}),D(Vt,null,D(xt,{s:e}))):null},Mt=e=>t=>{return s=(t,s)=>t+e(s),At(t).reduce(s,0);var s},Nt=e=>e?.size??0,Lt=Mt(Nt),Et=Mt(Lt),zt=Mt(Et),Ot=(e,t)=>e?.has(t)??!1,$t=e=>L(e)||0==Nt(e),At=e=>[...e?.values()??[]],Ft=e=>e.clear(),Jt=(e,t)=>e?.forEach(t),Pt=(e,t)=>e?.delete(t),Bt=e=>new Map(e),Dt=e=>[...e?.keys()??[]],Qt=(e,t)=>e?.get(t),jt=(e,t)=>Jt(e,((e,s)=>t(s,e))),Ht=(e,t,s)=>L(s)?(Pt(e,t),e):e?.set(t,s),Wt=(e,t,s,l)=>(Ot(e,t)?l?.(Qt(e,t)):Ht(e,t,s()),Qt(e,t)),Ut=(e,t,s,l=Ht)=>(ue(t,((t,l)=>s(e,l,t))),jt(e,(s=>ie(t,s)?0:l(e,s))),e),Gt=(e,t,s,l)=>{const n={};return Jt(e,((e,a)=>{if(!s?.(e,a)){const s=t?t(e,a):e;l?.(s)||(n[a]=s)}})),n},Kt=(e,t,s)=>Gt(e,(e=>Gt(e,t,s)),$t,ce),Xt=(e,t,s)=>Gt(e,(e=>Kt(e,t,s)),$t,ce),Yt=(e,t)=>{const s=Bt();return Jt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Zt=e=>Yt(e,Yt),_t=e=>Yt(e,Zt),es=(e,t,s,l,n=0)=>E((s?Wt:Qt)(e,t[n],n>F(t)-2?s:Bt),(a=>{if(n>F(t)-2)return l?.(a)&&Ht(e,t[n]),a;const r=es(a,t,s,l,n+1);return $t(a)&&Ht(e,t[n]),r})),ts=Bt(),ss=Bt(),ls="storage",ns=e=>new Set($(e)||L(e)?e:[e]),as=(e,t)=>e?.add(t),rs=/^\d+$/,os=()=>{const e=[];let t=0;return[s=>(s?_(e):null)??n+t++,t=>{rs.test(t)&&F(e)<1e3&&Z(e,t)}]},is=e=>[e,e],ds=(e,t=Lt)=>t(e[0])+t(e[1]),us=()=>[Bt(),Bt()],cs=e=>[...e],hs=([e,t])=>e===t;Bt(X("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".split(n),((e,t)=>[e,t])));const ms=(e,t,s)=>Ht(e,t,Qt(e,t)==-s?void 0:s),gs=()=>{let e,t,s=!1,l=!1,a=0,r=[];const i=Bt(),h=Bt(),T=Bt(),S=Bt(),V=Bt(),R=Bt(),q=Bt(),M=Bt(),N=Bt(),J=Bt(),P=Bt(),B=Bt(),D=Bt(),Q=Bt(),j=ns(),H=Bt(),W=Bt(),U=Bt(),Y=Bt(),_=us(),ee=us(),te=us(),se=us(),le=us(),ne=us(),ae=us(),oe=us(),me=us(),be=us(),Ie=us(),fe=us(),ye=us(),we=us(),Ce=us(),ve=us(),ke=us(),Te=us(),Se=us(),xe=us(),Ve=us(),Re=us(),qe=Bt(),Me=us(),[Ne,Le,Ee,ze]=(()=>{let e;const[t,s]=os(),l=Bt();return[(s,a,r,o=[],i=()=>[])=>{e??=As;const d=t(1);return Ht(l,d,[s,a,r,o,i]),as(es(a,r??[n],ns),d),d},(t,s,...a)=>K(((e,t=[n])=>{const s=[],l=(e,n)=>n==F(t)?Z(s,e):null===t[n]?Jt(e,(e=>l(e,n+1))):K([t[n],null],(t=>l(Qt(e,t),n+1)));return l(e,0),s})(t,s),(t=>Jt(t,(t=>Qt(l,t)[0](e,...s??[],...a))))),e=>E(Qt(l,e),(([,t,a])=>(es(t,a??[n],void 0,(t=>(Pt(t,e),$t(t)?1:0))),Ht(l,e),s(e),a))),t=>E(Qt(l,t),(([t,,s=[],l,n])=>{const a=(...r)=>{const o=F(r);o==F(s)?t(e,...r,...n(r)):L(s[o])?K(l[o]?.(...r)??[],(e=>a(...r,e))):a(...r,s[o])};a()}))]})(),Oe=e=>{if(!he(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!z(t)&&t!=o||(Be(e[u])!=t&&de(e,u),0))},$e=$,Ae=(t,s)=>(!e||Ot(P,s)||bt(s))&&he(t,((e,t)=>Fe(s,t,e)),(()=>bt(s))),Fe=(e,t,s,l)=>he(l?s:He(s,e,t),((l,n)=>E(Je(e,t,n,l),(e=>(s[n]=e,!0)),(()=>!1))),(()=>bt(e,t))),Je=(t,s,l,n)=>e?E(Qt(Qt(P,t),l),(e=>Be(n)!=e[d]?bt(t,s,l,n,e[u]):n),(()=>bt(t,s,l,n))):L(Be(n))?bt(t,s,l,n):n,Pe=(e,t)=>he(t?e:We(e),((t,s)=>E(je(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>It())),je=(e,s)=>t?E(Qt(D,e),(t=>Be(s)!=t[d]?It(e,s,t[u]):s),(()=>It(e,s))):L(Be(s))?It(e,s):s,He=(e,t,s)=>(E(Qt(B,t),(([l,n])=>{Jt(l,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(n,(l=>{ie(e,l)||bt(t,s,l)}))})),e),We=e=>(t&&(Jt(Q,((t,s)=>{ie(e,s)||(e[s]=t)})),Jt(j,(t=>{ie(e,t)||It(t)}))),e),Ue=e=>Ut(P,e,((e,t,s)=>{const l=Bt(),n=ns();Ut(Wt(P,t,Bt),s,((e,t,s)=>{Ht(e,t,s),E(s[u],(e=>Ht(l,t,e)),(()=>as(n,t)))})),Ht(B,t,[l,n])}),((e,t)=>{Ht(P,t),Ht(B,t)})),Ge=e=>Ut(D,e,((e,t,s)=>{Ht(D,t,s),E(s[u],(e=>Ht(Q,t,e)),(()=>as(j,t)))}),((e,t)=>{Ht(D,t),Ht(Q,t),Pt(j,t)})),Ke=e=>ce(e)?Rs():ks(e),Xe=e=>Ut(U,e,((e,t,s)=>Ye(t,s)),((e,t)=>rt(t))),Ye=(e,t)=>Ut(Wt(U,e,(()=>(ut(e,1),Ht(H,e,os()),Ht(W,e,Bt()),Bt()))),t,((t,s,l)=>Ze(e,t,s,l)),((t,s)=>ot(e,t,s))),Ze=(e,t,s,l,n)=>Ut(Wt(t,s,(()=>(ct(e,s,1),Bt()))),l,((t,l,n)=>_e(e,s,t,l,n)),((l,a)=>it(e,t,s,l,a,n))),_e=(e,t,s,l,n)=>{Ot(s,l)||ht(e,t,l,1);const a=Qt(s,l);n!==a&&(mt(e,t,l,a,n),Ht(s,l,n))},et=(e,t,s,l,n)=>E(Qt(t,s),(t=>_e(e,s,t,l,n)),(()=>Ze(e,t,s,He({[l]:n},e,s)))),tt=e=>ce(e)?Ns():Ts(e),st=e=>Ut(Y,e,((e,t,s)=>lt(t,s)),((e,t)=>dt(t))),lt=(e,t)=>{Ot(Y,e)||gt(e,1);const s=Qt(Y,e);t!==s&&(pt(e,s,t),Ht(Y,e,t))},nt=(e,t)=>{const[s]=Qt(H,e),l=s(t);return Ot(Qt(U,e),l)?nt(e,t):l},at=e=>Qt(U,e)??Ye(e,{}),rt=e=>Ye(e,{}),ot=(e,t,s)=>{const[,l]=Qt(H,e);l(s),Ze(e,t,s,{},!0)},it=(e,t,s,l,n,a)=>{const r=Qt(Qt(B,e)?.[0],n);if(!L(r)&&!a)return _e(e,s,l,n,r);const o=t=>{mt(e,s,t,Qt(l,t)),ht(e,s,t,-1),Ht(l,t)};L(r)?o(n):jt(l,o),$t(l)&&(ct(e,s,-1),$t(Ht(t,s))&&(ut(e,-1),Ht(U,e),Ht(H,e),Ht(W,e)))},dt=e=>{const t=Qt(Q,e);if(!L(t))return lt(e,t);pt(e,Qt(Y,e)),gt(e,-1),Ht(Y,e)},ut=(e,t)=>ms(i,e,t),ct=(e,t,s)=>ms(Wt(S,e,Bt),t,s)&&Ht(T,e,Wt(T,e,(()=>0))+s),ht=(e,t,s,l)=>{const n=Qt(W,e),a=Qt(n,s)??0;(0==a&&1==l||1==a&&-1==l)&&ms(Wt(h,e,Bt),s,l),Ht(n,s,a!=-l?a+l:null),ms(Wt(Wt(V,e,Bt),t,Bt),s,l)},mt=(e,t,s,l,n)=>{Wt(Wt(Wt(R,e,Bt),t,Bt),s,(()=>[l,0]))[1]=n,r[3]?.(e,t,s,n)},gt=(e,t)=>ms(q,e,t),pt=(e,t,s)=>{Wt(M,e,(()=>[t,0]))[1]=s,r[4]?.(e,s)},bt=(e,t,s,l,n)=>(Z(Wt(Wt(Wt(N,e,Bt),t,Bt),s,(()=>[])),l),n),It=(e,t,s)=>(Z(Wt(J,e,(()=>[])),t),s),ft=(e,t,s)=>E(Qt(Qt(Qt(R,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ss(e,t,s))])),yt=e=>E(Qt(M,e),(([e,t])=>[!0,e,t]),(()=>[!1,...is(ps(e))])),wt=e=>$t(N)||$t(ve[e])?0:Jt(e?_t(N):N,((t,s)=>Jt(t,((t,l)=>Jt(t,((t,n)=>Le(ve[e],[s,l,n],t))))))),Ct=e=>$t(J)||$t(ke[e])?0:Jt(e?Yt(J):J,((t,s)=>Le(ke[e],[s],t))),vt=(e,t,s,l)=>{if(!$t(e))return Le(t,l,(()=>Gt(e))),jt(e,((e,t)=>Le(s,[...l??[],e],1==t))),1},kt=e=>{const t=bs();t!=s&&Le(_[e],void 0,t);const l=$t(be[e]),n=$t(ye[e])&&$t(we[e])&&$t(me[e])&&$t(Ie[e])&&$t(ne[e])&&$t(ae[e])&&$t(oe[e])&&l&&$t(te[e])&&$t(se[e]),a=$t(Ce[e])&&$t(fe[e])&&$t(le[e])&&$t(ee[e]);if(!n||!a){const t=e?[Yt(i),Zt(h),Yt(T),Zt(S),_t(V),_t(R)]:[i,h,T,S,V,R];if(!n){vt(t[0],te[e],se[e]),Jt(t[1],((t,s)=>vt(t,ne[e],ae[e],[s]))),Jt(t[2],((t,s)=>{0!=t&&Le(oe[e],[s],qt(s))}));const s=ns();Jt(t[3],((t,n)=>{vt(t,me[e],Ie[e],[n])&&!l&&(Le(be[e],[n,null]),as(s,n))})),l||Jt(t[5],((t,l)=>{if(!Ot(s,l)){const s=ns();Jt(t,(e=>Jt(e,(([t,l],n)=>l!==t?as(s,n):Pt(e,n))))),Jt(s,(t=>Le(be[e],[l,t])))}})),Jt(t[4],((t,s)=>Jt(t,((t,l)=>vt(t,ye[e],we[e],[s,l])))))}if(!a){let s;Jt(t[5],((t,l)=>{let n;Jt(t,((t,a)=>{let r;Jt(t,(([t,o],i)=>{o!==t&&(Le(Ce[e],[l,a,i],o,t,ft),s=n=r=1)})),r&&Le(fe[e],[l,a],ft)})),n&&Le(le[e],[l],ft)})),s&&Le(ee[e],void 0,ft)}}},Tt=e=>{const t=Cs();t!=l&&Le(Te[e],void 0,t);const s=$t(xe[e])&&$t(Ve[e]),n=$t(Re[e])&&$t(Se[e]);if(!s||!n){const t=e?[Yt(q),Yt(M)]:[q,M];if(s||vt(t[0],xe[e],Ve[e]),!n){let s;Jt(t[1],(([t,l],n)=>{l!==t&&(Le(Re[e],[n],l,t,yt),s=1)})),s&&Le(Se[e],void 0,yt)}}},St=(e,...t)=>(zs((()=>e(...X(t,x)))),As),xt=()=>Xt(U),Vt=()=>Dt(U),Rt=e=>Dt(Qt(W,x(e))),qt=e=>Nt(Qt(U,x(e))),Mt=e=>Dt(Qt(U,x(e))),At=(e,t,s,l=0,n)=>{return X(A(G((a=Qt(U,x(e)),r=(e,s)=>[L(t)?s:Qt(e,x(t)),s],X([...a?.entries()??[]],(([e,t])=>r(t,e)))),(([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1))),l,L(n)?n:l+n),(([,e])=>e));var a,r},ts=(e,t)=>Dt(Qt(Qt(U,x(e)),x(t))),ss=(e,t,s)=>Qt(Qt(Qt(U,x(e)),x(t)),x(s)),ls=()=>Gt(Y),rs=()=>Dt(Y),ps=e=>Qt(Y,x(e)),bs=()=>!$t(U),Is=e=>Ot(U,x(e)),fs=(e,t)=>Ot(Qt(W,x(e)),x(t)),ys=(e,t)=>Ot(Qt(U,x(e)),x(t)),ws=(e,t,s)=>Ot(Qt(Qt(U,x(e)),x(t)),x(s)),Cs=()=>!$t(Y),vs=e=>Ot(Y,x(e)),ks=e=>St((()=>(e=>he(e,Ae,bt))(e)?Xe(e):0)),Ts=e=>St((()=>Pe(e)?st(e):0)),Ss=e=>{try{Ke(ge(e))}catch{}return As},xs=t=>St((()=>{if((e=he(t,(e=>he(e,Oe))))&&(Ue(t),!$t(U))){const e=xt();Rs(),ks(e)}})),Vs=e=>St((()=>{if(t=(e=>he(e,Oe))(e)){const s=ls();Es(),Ns(),t=!0,Ge(e),Ts(s)}})),Rs=()=>St((()=>Xe({}))),qs=e=>St((e=>Ot(U,e)?rt(e):0),e),Ms=(e,t)=>St(((e,t)=>E(Qt(U,e),(s=>Ot(s,t)?ot(e,s,t):0))),e,t),Ns=()=>St((()=>st({}))),Ls=()=>St((()=>{Ue({}),e=!1})),Es=()=>St((()=>{Ge({}),t=!1})),zs=(e,t)=>{if(-1!=a){Os();const s=e();return $s(t),s}},Os=()=>(-1!=a&&a++,1==a&&(r[0]?.(),Le(qe)),As),$s=e=>(a>0&&(a--,0==a&&(a=1,wt(1),$t(R)||kt(1),Ct(1),$t(M)||Tt(1),e?.(As)&&(Jt(R,((e,t)=>Jt(e,((e,s)=>Jt(e,(([e],l)=>De(As,t,s,l,e))))))),Ft(R),Jt(M,(([e],t)=>Qe(As,t,e))),Ft(M)),Le(Me[0],void 0),a=-1,wt(0),$t(R)||kt(0),Ct(0),$t(M)||Tt(0),r[1]?.(),Le(Me[1],void 0),r[2]?.(),a=0,s=bs(),l=Cs(),K([i,h,T,S,V,R,N,q,M,J],Ft))),As),As={getContent:()=>[xt(),ls()],getTables:xt,getTableIds:Vt,getTable:e=>Kt(Qt(U,x(e))),getTableCellIds:Rt,getRowCount:qt,getRowIds:Mt,getSortedRowIds:At,getRow:(e,t)=>Gt(Qt(Qt(U,x(e)),x(t))),getCellIds:ts,getCell:ss,getValues:ls,getValueIds:rs,getValue:ps,hasTables:bs,hasTable:Is,hasTableCell:fs,hasRow:ys,hasCell:ws,hasValues:Cs,hasValue:vs,getTablesJson:()=>pe(U),getValuesJson:()=>pe(Y),getJson:()=>pe([U,Y]),getTablesSchemaJson:()=>pe(P),getValuesSchemaJson:()=>pe(D),getSchemaJson:()=>pe([P,D]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:e=>St((()=>$e(e)?(([e,t])=>{(ce(e)?Rs:ks)(e),(ce(t)?Ns:Ts)(t)})(e):0)),setTables:ks,setTable:(e,t)=>St((e=>Ae(t,e)?Ye(e,t):0),e),setRow:(e,t,s)=>St(((e,t)=>Fe(e,t,s)?Ze(e,at(e),t,s):0),e,t),addRow:(e,t,s=!0)=>zs((()=>{let l;return Fe(e,l,t)&&(e=x(e),Ze(e,at(e),l=nt(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>St(((e,t)=>{if(Fe(e,t,s,1)){const l=at(e);ue(s,((s,n)=>et(e,l,t,n,s)))}}),e,t),setCell:(e,t,s,l)=>St(((e,t,s)=>E(Je(e,t,s,O(l)?l(ss(e,t,s)):l),(l=>et(e,at(e),t,s,l)))),e,t,s),setValues:Ts,setPartialValues:e=>St((()=>Pe(e,1)?ue(e,((e,t)=>lt(t,e))):0)),setValue:(e,t)=>St((e=>E(je(e,O(t)?t(ps(e)):t),(t=>lt(e,t)))),e),applyChanges:e=>St((()=>{ue(e[0],((e,t)=>L(e)?qs(t):ue(e,((e,s)=>L(e)?Ms(t,s):ue(e,((e,l)=>De(As,t,s,l,e))))))),ue(e[1],((e,t)=>Qe(As,t,e)))})),setTablesJson:Ss,setValuesJson:e=>{try{tt(ge(e))}catch{}return As},setJson:e=>St((()=>{try{const[t,s]=ge(e);Ke(t),tt(s)}catch{Ss(e)}})),setTablesSchema:xs,setValuesSchema:Vs,setSchema:(e,t)=>St((()=>{xs(e),Vs(t)})),delTables:Rs,delTable:qs,delRow:Ms,delCell:(e,t,s,l)=>St(((e,t,s)=>E(Qt(U,e),(n=>E(Qt(n,t),(a=>Ot(a,s)?it(e,n,t,a,s,l):0))))),e,t,s),delValues:Ns,delValue:e=>St((e=>Ot(Y,e)?dt(e):0),e),delTablesSchema:Ls,delValuesSchema:Es,delSchema:()=>St((()=>{Ls(),Es()})),transaction:zs,startTransaction:Os,getTransactionChanges:()=>[Gt(R,((e,t)=>-1===Qt(i,t)?void 0:Gt(e,((e,s)=>-1===Qt(Qt(S,t),s)?void 0:Gt(e,(([,e])=>e),(e=>hs(e)))),$t,ce)),$t,ce),Gt(M,(([,e])=>e),(e=>hs(e))),1],getTransactionLog:()=>[!$t(R),!$t(M),Xt(R,cs,hs),Xt(N),Gt(M,cs,hs),Gt(J),Gt(i),Kt(S),Xt(V),Gt(q)],finishTransaction:$s,forEachTable:e=>Jt(U,((t,s)=>e(s,(e=>Jt(t,((t,s)=>e(s,(e=>jt(t,e))))))))),forEachTableCell:(e,t)=>jt(Qt(W,x(e)),t),forEachRow:(e,t)=>Jt(Qt(U,x(e)),((e,s)=>t(s,(t=>jt(e,t))))),forEachCell:(e,t,s)=>jt(Qt(Qt(U,x(e)),x(t)),s),forEachValue:e=>jt(Y,e),addSortedRowIdsListener:(e,t,s,l,n,a,r)=>{let o=At(e,t,s,l,n);return Ne((()=>{const r=At(e,t,s,l,n);var i,d,u;d=o,F(i=r)===F(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,a(As,e,t,s,l,n,o))}),be[r?1:0],[e,t],[Vt])},addStartTransactionListener:e=>Ne(e,qe),addWillFinishTransactionListener:e=>Ne(e,Me[0]),addDidFinishTransactionListener:e=>Ne(e,Me[1]),callListener:e=>(ze(e),As),delListener:e=>(Ee(e),As),getListenerStats:()=>({hasTables:ds(_),tables:ds(ee),tableIds:ds(te),hasTable:ds(se),table:ds(le),tableCellIds:ds(ne),hasTableCell:ds(ae,Et),rowCount:ds(oe),rowIds:ds(me),sortedRowIds:ds(be),hasRow:ds(Ie,Et),row:ds(fe,Et),cellIds:ds(ye,Et),hasCell:ds(we,zt),cell:ds(Ce,zt),invalidCell:ds(ve,zt),hasValues:ds(Te),values:ds(Se),valueIds:ds(xe),hasValue:ds(Ve),value:ds(Re),invalidValue:ds(ke),transaction:Lt(qe)+ds(Me)}),isMergeable:()=>!1,createStore:gs,addListener:Ne,callListeners:Le,setInternalListeners:(e,t,s,l,n)=>r=[e,t,s,l,n]};return ue({[c+g]:[0,_,[],()=>[bs()]],[g]:[0,ee],[p]:[0,te],[c+m]:[1,se,[Vt],e=>[Is(...e)]],[m]:[1,le,[Vt]],[m+w]:[1,ne,[Vt]],[c+m+y]:[2,ae,[Vt,Rt],e=>[fs(...e)]],[I]:[1,oe,[Vt]],[f]:[1,me,[Vt]],[c+b]:[2,Ie,[Vt,Mt],e=>[ys(...e)]],[b]:[2,fe,[Vt,Mt]],[w]:[2,ye,[Vt,Mt]],[c+y]:[3,we,[Vt,Mt,ts],e=>[ws(...e)]],[y]:[3,Ce,[Vt,Mt,ts],e=>is(ss(...e))],InvalidCell:[3,ve],[c+v]:[0,Te,[],()=>[Cs()]],[v]:[0,Se],[k]:[0,xe],[c+C]:[1,Ve,[rs],e=>[vs(...e)]],[C]:[1,Re,[rs],e=>is(ps(e[0]))],InvalidValue:[1,ke]},(([e,t,s,l],n)=>{As["add"+n+"Listener"]=(...n)=>Ne(n[e],t[n[e+1]?1:0],e>0?A(n,0,e):void 0,s,l)})),re(As)};e.Inspector=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(gs),n=fe.indexOf(e);return s.useCreatePersister(l,(e=>{return t=be,s=sessionStorage,((e,t,s,l,n,a,r,o={},i=[])=>{let d,u,c,h=0,m=0,g=0;Wt(ts,i,(()=>0)),Wt(ss,i,(()=>[]));const[p,b,I,f,y]=((e=1,t)=>1!=e&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[e],[t]])=>!ce(e)||!ce(t),t.setDefaultContent]:2!=e?[0,t.getContent,t.getTransactionChanges,([e,t])=>!ce(e)||!ce(t),t.setContent]:J("Store type not supported by this Persister"))(r,e),w=t=>{(p&&$(t?.[0])?1===t?.[2]?e.applyMergeableChanges:e.setMergeableContent:1===t?.[2]?e.applyChanges:e.setContent)(t)},C=async e=>(2!=h&&(h=1,m++,await S((async()=>{try{const e=await t();$(e)?w(e):J("Content is not an array "+e)}catch(t){e&&y(e)}h=0}))),x),v=()=>(u&&(n(u),u=void 0),x),k=async e=>(1!=h&&(h=2,g++,await S((async()=>{try{await s(b,e)}catch(e){}h=0}))),x),T=()=>(E(c,e.delListener),c=void 0,x),S=async(...e)=>(Z(Qt(ss,i),...e),await(async()=>{if(!Qt(ts,i)){for(Ht(ts,i,1);!L(d=_(Qt(ss,i)));)try{await d()}catch(e){}Ht(ts,i,0)}})(),x),x={load:C,startAutoLoad:async e=>{await v().load(e);try{u=await l((async(e,t)=>{t||e?2!=h&&(h=1,m++,w(t??e),h=0):await C()}))}catch(e){}return x},stopAutoLoad:v,isAutoLoading:()=>!L(u),save:k,startAutoSave:async()=>(await T().save(),c=e.addDidFinishTransactionListener((()=>{const e=I();f(e)&&k(e)})),x),stopAutoSave:T,isAutoSaving:()=>!L(c),schedule:S,getStore:()=>e,destroy:()=>(Qt(ss,i).splice(0,void 0),v().stopAutoSave()),getStats:()=>({loads:m,saves:g}),...o};return re(x)})(e,(async()=>{return e=s.getItem(t),ge(e,((e,t)=>""===t?void 0:t));var e}),(async e=>{return s.setItem(t,(l=e(),me(l,((e,t)=>void 0===t?"":t))));var l}),(e=>{const l=l=>{if(l.storageArea===s&&l.key===t)try{e(ge(l.newValue))}catch{e()}};return V.addEventListener(ls,l),l}),(e=>V.removeEventListener(ls,e)),0,3,{getStorageName:()=>t});var t,s}),void 0,(async e=>{await e.load([{},{position:-1==n?1:n,open:!!t}]),await e.startAutoSave()})),D(B,null,D("aside",{id:be},D(Je,{s:l}),D(qt,{s:l})),D("style",null,Fe))}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("../../ui-react/with-schemas/index.js")):"function"==typeof define&&define.amd?define(["exports","react","../ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactInspector={},e.React,e.TinyBaseUiReact);
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value) ? otherwise?.() : then(value);
@@ -66,6 +68,7 @@
66
68
  );
67
69
  const objIds = object.keys;
68
70
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
71
+ const objHas = (obj, id) => id in obj;
69
72
  const objDel = (obj, id) => {
70
73
  delete obj[id];
71
74
  return obj;
@@ -84,13 +87,21 @@
84
87
  )
85
88
  );
86
89
  };
90
+ const objEnsure = (obj, id, getDefaultValue) => {
91
+ if (!objHas(obj, id)) {
92
+ obj[id] = getDefaultValue();
93
+ }
94
+ return obj[id];
95
+ };
87
96
 
88
97
  const {
89
98
  createContext,
90
99
  useContext: useContext$1,
91
100
  useEffect: useEffect$1,
92
101
  } = React;
93
- const Context = createContext([]);
102
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
103
+ createContext([]),
104
+ );
94
105
  const useThing = (id, offset) => {
95
106
  const contextValue = useContext$1(Context);
96
107
  return isUndefined(id)
@@ -10,6 +10,7 @@
10
10
  'use strict';
11
11
 
12
12
  const getTypeOf = (thing) => typeof thing;
13
+ const TINYBASE = 'tinybase';
13
14
  const EMPTY_STRING = '';
14
15
  const STRING = getTypeOf(EMPTY_STRING);
15
16
  const FUNCTION = getTypeOf(getTypeOf);
@@ -33,6 +34,7 @@
33
34
  const VALUES = VALUE + 's';
34
35
  const VALUE_IDS = VALUE + IDS;
35
36
 
37
+ const GLOBAL = globalThis;
36
38
  const isUndefined = (thing) => thing == void 0;
37
39
  const ifNotUndefined = (value, then, otherwise) =>
38
40
  isUndefined(value) ? otherwise?.() : then(value);
@@ -66,6 +68,7 @@
66
68
  );
67
69
  const objIds = object.keys;
68
70
  const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
71
+ const objHas = (obj, id) => id in obj;
69
72
  const objDel = (obj, id) => {
70
73
  delete obj[id];
71
74
  return obj;
@@ -84,13 +87,21 @@
84
87
  )
85
88
  );
86
89
  };
90
+ const objEnsure = (obj, id, getDefaultValue) => {
91
+ if (!objHas(obj, id)) {
92
+ obj[id] = getDefaultValue();
93
+ }
94
+ return obj[id];
95
+ };
87
96
 
88
97
  const {
89
98
  createContext,
90
99
  useContext: useContext$1,
91
100
  useEffect: useEffect$1,
92
101
  } = React;
93
- const Context = createContext([]);
102
+ const Context = objEnsure(GLOBAL, TINYBASE + '_uirc', () =>
103
+ createContext([]),
104
+ );
94
105
  const useThing = (id, offset) => {
95
106
  const contextValue = useContext$1(Context);
96
107
  return isUndefined(id)
@@ -168,7 +168,8 @@
168
168
  const OPEN_VALUE = OPEN_CELL;
169
169
  const EDITABLE_CELL = 'editable';
170
170
  const getUniqueId = (...args) => jsonStringWithMap(args);
171
- const sortedIdsMap = (ids, callback) => arrayMap(arraySort(ids), callback);
171
+ const sortedIdsMap = (ids, callback) =>
172
+ arrayMap(arraySort([...ids]), callback);
172
173
  const useEditable = (uniqueId, s) => [
173
174
  !!uiReact.useCell(STATE_TABLE, uniqueId, EDITABLE_CELL, s),
174
175
  useCallback$1(
@@ -168,7 +168,8 @@
168
168
  const OPEN_VALUE = OPEN_CELL;
169
169
  const EDITABLE_CELL = 'editable';
170
170
  const getUniqueId = (...args) => jsonStringWithMap(args);
171
- const sortedIdsMap = (ids, callback) => arrayMap(arraySort(ids), callback);
171
+ const sortedIdsMap = (ids, callback) =>
172
+ arrayMap(arraySort([...ids]), callback);
172
173
  const useEditable = (uniqueId, s) => [
173
174
  !!uiReact.useCell(STATE_TABLE, uniqueId, EDITABLE_CELL, s),
174
175
  useCallback$1(