tinybase 4.3.10 → 4.3.12

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 (63) hide show
  1. package/lib/cjs/persisters/persister-partykit-client.cjs +1 -1
  2. package/lib/cjs/persisters/persister-partykit-client.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-partykit-server.cjs +1 -1
  4. package/lib/cjs/persisters/persister-partykit-server.cjs.gz +0 -0
  5. package/lib/cjs/ui-react-dom-debug.cjs +1 -1
  6. package/lib/cjs/ui-react-dom-debug.cjs.gz +0 -0
  7. package/lib/cjs/ui-react-dom.cjs +1 -1
  8. package/lib/cjs/ui-react-dom.cjs.gz +0 -0
  9. package/lib/cjs-es6/persisters/persister-partykit-client.cjs +1 -1
  10. package/lib/cjs-es6/persisters/persister-partykit-client.cjs.gz +0 -0
  11. package/lib/cjs-es6/persisters/persister-partykit-server.cjs +1 -1
  12. package/lib/cjs-es6/persisters/persister-partykit-server.cjs.gz +0 -0
  13. package/lib/cjs-es6/ui-react-dom-debug.cjs +1 -1
  14. package/lib/cjs-es6/ui-react-dom-debug.cjs.gz +0 -0
  15. package/lib/cjs-es6/ui-react-dom.cjs +1 -1
  16. package/lib/cjs-es6/ui-react-dom.cjs.gz +0 -0
  17. package/lib/debug/persisters/persister-partykit-client.js +29 -19
  18. package/lib/debug/persisters/persister-partykit-server.js +155 -64
  19. package/lib/debug/ui-react-dom.js +45 -30
  20. package/lib/es6/persisters/persister-partykit-client.js +1 -1
  21. package/lib/es6/persisters/persister-partykit-client.js.gz +0 -0
  22. package/lib/es6/persisters/persister-partykit-server.js +1 -1
  23. package/lib/es6/persisters/persister-partykit-server.js.gz +0 -0
  24. package/lib/es6/ui-react-dom-debug.js +1 -1
  25. package/lib/es6/ui-react-dom-debug.js.gz +0 -0
  26. package/lib/es6/ui-react-dom.js +1 -1
  27. package/lib/es6/ui-react-dom.js.gz +0 -0
  28. package/lib/persisters/persister-partykit-client.js +1 -1
  29. package/lib/persisters/persister-partykit-client.js.gz +0 -0
  30. package/lib/persisters/persister-partykit-server.js +1 -1
  31. package/lib/persisters/persister-partykit-server.js.gz +0 -0
  32. package/lib/types/persisters/persister-indexed-db.d.ts +4 -5
  33. package/lib/types/persisters/persister-partykit-client.d.ts +18 -7
  34. package/lib/types/persisters/persister-partykit-server.d.ts +335 -7
  35. package/lib/types/tools.d.ts +4 -6
  36. package/lib/types/ui-react-dom.d.ts +13 -2
  37. package/lib/types/ui-react.d.ts +4 -4
  38. package/lib/types/with-schemas/persisters/persister-indexed-db.d.ts +4 -5
  39. package/lib/types/with-schemas/persisters/persister-partykit-client.d.ts +18 -7
  40. package/lib/types/with-schemas/persisters/persister-partykit-server.d.ts +359 -7
  41. package/lib/types/with-schemas/tools.d.ts +4 -6
  42. package/lib/types/with-schemas/ui-react-dom.d.ts +21 -4
  43. package/lib/types/with-schemas/ui-react.d.ts +4 -4
  44. package/lib/ui-react-dom.js +1 -1
  45. package/lib/ui-react-dom.js.gz +0 -0
  46. package/lib/umd/persisters/persister-partykit-client.js +1 -1
  47. package/lib/umd/persisters/persister-partykit-client.js.gz +0 -0
  48. package/lib/umd/persisters/persister-partykit-server.js +1 -1
  49. package/lib/umd/persisters/persister-partykit-server.js.gz +0 -0
  50. package/lib/umd/ui-react-dom-debug.js +1 -1
  51. package/lib/umd/ui-react-dom-debug.js.gz +0 -0
  52. package/lib/umd/ui-react-dom.js +1 -1
  53. package/lib/umd/ui-react-dom.js.gz +0 -0
  54. package/lib/umd-es6/persisters/persister-partykit-client.js +1 -1
  55. package/lib/umd-es6/persisters/persister-partykit-client.js.gz +0 -0
  56. package/lib/umd-es6/persisters/persister-partykit-server.js +1 -1
  57. package/lib/umd-es6/persisters/persister-partykit-server.js.gz +0 -0
  58. package/lib/umd-es6/ui-react-dom-debug.js +1 -1
  59. package/lib/umd-es6/ui-react-dom-debug.js.gz +0 -0
  60. package/lib/umd-es6/ui-react-dom.js +1 -1
  61. package/lib/umd-es6/ui-react-dom.js.gz +0 -0
  62. package/package.json +10 -10
  63. package/readme.md +2 -2
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),r=l(!0),o=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",I=g+"Count",p=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,k="currentTarget",T="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==r,M=e=>l(e)==i,E=e=>Array.isArray(e),z=(e,t,s)=>e.slice(t,s),$=e=>e.length,{PureComponent:O,Fragment:A,createElement:F,useCallback:J,useLayoutEffect:P,useRef:B,useState:H}=t,D=(e,...t)=>q(e)?{}:e(...t),Q=(e,t)=>e.forEach(t),j=(e,t)=>e.map(t),W=e=>0==$(e),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>j(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>$(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),re=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",Ie=(...e)=>ne(e),pe=(e,t)=>j(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),J((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',ke=ye+"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\")",Te=j([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-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;"+ke,...ee(j(["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;",...ee(j(["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)":ke,"header>img:nth-of-type(6)":Se,...ee(j(Te,((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":xe,"details[open]>summary img.done":Ve,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,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?`& ${t}{${e}}`:"")))}`,Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:F("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:r})=>{const o=!!s.useCell(ue,e,he,r),i=s.useSetCellCallback(ue,e,he,(e=>e[k].open),[],r);return F("details",{open:o,onToggle:i},F("summary",null,t,a?F("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==o&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==o?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>j(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,r,o)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),o?.(e)}),[o]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===r?at:r;return[[i,d,u],m,Ae((()=>!1===r?null:F(g,{offset:u,limit:a,total:n,onChange:b})),[r,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(j(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,r,o,i]})=>F("table",{className:e},i?F("caption",null,i):null,!1===t?null:F("thead",null,F("tr",null,!1===s?null:F(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>F(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),F("tbody",null,j(n,(e=>F("tr",{key:e},!1===s?null:F("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>F("td",{key:l},F(t,{...D(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>F("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,r,o,i,d]})=>{const u=s.useRemoteRowId(o,e,i);return F("tr",null,!1===l?null:F(t.Fragment,null,F("th",null,e),F("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,o]=l.split(".",2),i=a===n?e:a===r?u:null;return q(i)?null:F("td",{key:l},F(t,{...D(s,i,o),store:d,tableId:a,rowId:i,cellId:o}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l})=>{const[a,i]=Fe(),[d,u]=Fe(),[c,h]=Fe(),[m,b]=Fe(),[g,I]=Fe();d!==e&&(i(Me(e)),u(e),h(e+""),b(Number(e)||0),I(!!e));const p=Oe(((e,s)=>{s(e),u(e),t(e)}),[t]);return F("div",{className:s},F("button",{className:a,onClick:Oe((()=>{if(!l?.()){const e=$e(a,o,r,n),s=$e(e,c,m,g);i(e),u(s),t(s)}}),[l,t,c,m,g,a])},a),$e(a,F("input",{key:a,value:c,onChange:Oe((e=>p(e[k][T]+"",h)),[p])}),F("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[k][T]||0),b)),[p])}),F("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[k].checked,I)),[p])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:r,editable:o,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,r),d,u);return F(Ue,{...h,params:He(We(s.useTableCellIds(e,r),c,o?st:s.CellView),De(r,e),s.useSortedRowIds(e,...m,n,r),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:r,idColumn:o})=>F("table",{className:n},!1===r?null:F("thead",null,F("tr",null,!1===o?null:F("th",null,"Id"),F("th",null,y))),F("tbody",null,j(s.useValueIds(e),(t=>F("tr",{key:t},!1===o?null:F("th",null,t),F("td",null,F(l,{...D(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...r})=>{const[o,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return F(Ue,{...r,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,o))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:r,headerRow:o,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return F("table",{className:r},!1===o?null:F("thead",null,F("tr",null,!1===i?null:F(t.Fragment,null,F("th",null,c,".Id"),F("th",null,h,".Id")),le(m,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,j(s.useRowIds(c,u),(e=>F(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:r,sortOnClick:o,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,o,a,n,s.useResultRowCount(e,r),i,u);return F(Ue,{...c,params:He(We(s.useResultTableCellIds(e,r),d,s.ResultCellView),Qe(r,e),s.useResultSortedRowIds(e,...h,n,r),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n})=>F(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l})=>F(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:r=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const o=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return F(t.Fragment,null,s>a&&F(t.Fragment,null,F("button",{className:"previous",disabled:0==l,onClick:o},"←"),F("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?r:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>F(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},j(s.useSliceIds(l,e),(s=>F(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a,key:s})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return F(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},F(_e,{sliceId:l,indexId:s,indexes:e,editable:r}))},ot=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:F(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},W(a)?"No indexes defined":pe(a,(s=>F(nt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},it=({metrics:e,metricId:t})=>F("tr",null,F("th",null,t),F("td",null,e?.getTableId(t)),F("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:F(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},W(a)?"No metrics defined":F("table",null,F("thead",null,F("th",null,"Metric Id"),F("th",null,"Table Id"),F("th",null,"Metric")),F("tbody",null,j(a,(e=>F(it,{metrics:l,metricId:e,key:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=Ie("q",t,l),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return F(Le,{uniqueId:n,summary:"Query: "+l,s:a},F(tt,{queryId:l,queries:e,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:F(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},W(a)?"No queries defined":pe(a,(s=>F(ut,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return F(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},F(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:F(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},W(a)?"No relationships defined":pe(a,(s=>F(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=Ie("t",l,e),[r,o,i]=re(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return F(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},F(Ye,{tableId:e,store:t,cellId:r,descending:o,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=Ie("v",t),[n,r]=fe(a,l);return W(s.useValueIds(e))?null:F(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},F(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:F(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},F(gt,{storeId:e,store:l,s:t}),pe(a,(s=>F(bt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},pt=({s:e})=>{const t=B(null),l=B(0),[a,n]=H(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);P((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(r)+e.clientWidth&&e.scrollHeight>=x(o)+e.clientHeight&&e.scrollTo(r,o)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,r,o]);const i=J((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),I=s.useRelationshipsIds(),p=s.useQueries(),f=s.useQueriesIds();return q(d)&&W(u)&&q(c)&&W(h)&&q(m)&&W(b)&&q(g)&&W(I)&&q(p)&&W(f)?F("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):F("article",{ref:t,onScroll:i},F(It,{s:e}),j(u,(t=>F(It,{storeId:t,s:e,key:t}))),F(dt,{s:e}),j(h,(t=>F(dt,{metricsId:t,s:e,key:t}))),F(ot,{s:e}),j(b,(t=>F(ot,{indexesId:t,s:e,key:t}))),F(mt,{s:e}),j(I,(t=>F(mt,{relationshipsId:t,s:e,key:t}))),F(ct,{s:e}),j(f,(t=>F(ct,{queriesId:t,s:e,key:t}))))};class ft extends O{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?F("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return F("header",null,F("img",{title:ie}),F("span",null,ie),j(de,((e,s)=>s==t?null:F("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),F("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?F("main",{"data-position":t},F(wt,{s:e}),F(ft,null,F(pt,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,kt=Ct(vt),Tt=Ct(kt),St=Ct(Tt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>$(t)-2?s:Mt),(n=>{if(a>$(t)-2)return l?.(n)&&Ot(e,t[a]),n;const r=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),r})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&$(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=kt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),rs=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),os=()=>{let e,t,s=!1,l=!1,n=0;const r=Mt(),i=Mt(),c=Mt(),k=Mt(),T=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Mt(),P=Mt(),B=Xt(),H=Mt(),D=Mt(),W=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),oe=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),Ie=ss(),pe=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,r,o=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,r,o,i]),Yt(jt(l,r??[a],Xt),d),d},(e,s,...l)=>Q(((e,t=[a])=>{const s=[],l=(e,a)=>a==$(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):Q([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...r)=>{const o=$(r);o==$(s)?e(t,...r,...a(r)):q(s[o])?Q(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),ke=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=o||(Me(e[u])!=t&&se(e,u),0))},Te=(t,s)=>(!e||xt(A,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt(A,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(J,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(F,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(P,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(B,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft(A,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At(A,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(F,t,[l,a])}),((e,t)=>{Ot(A,t),Ot(F,t)})),$e=e=>Ft(J,e,((e,t,s)=>{Ot(J,t,s),N(s[u],(e=>Ot(P,t,e)),(()=>Yt(B,t)))}),((e,t)=>{Ot(J,t),Ot(P,t),Lt(B,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(W,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(W,e,(()=>(Ye(e,1),Ot(H,e,_t()),Ot(D,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(H,e),l=s(t);return xt(zt(W,e),l)?je(e,t):l},We=e=>zt(W,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(H,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(F,e)?.[0],a);if(!q(r)&&!n)return Pe(e,s,l,a,r);const o=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(r)?o(a):$t(l,o),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(W,e),Ot(H,e),Ot(D,e)))},Xe=e=>{const t=zt(P,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>rs(r,e,t),Ze=(e,t,s)=>rs(At(k,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(D,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&rs(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),rs(At(At(T,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>rs(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(O,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),rt=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),ot=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(O)||Vt(me[e])?0:Nt(e?Ht(O):O,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(oe[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(r),Dt(i),Ht(c),Dt(k),Qt(T),Qt(x)]:[r,i,c,k,T,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],pt(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(oe[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let r;Nt(s,(([s,o],i)=>{o!==s&&(ye(ce[e],[l,n,i],o,s,nt),t=a=r=1)})),r&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(Ie[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(Ie[e],[a],l,s,rt),t=1)})),t&&ye(be[e],void 0,rt)}}},ht=(e,...t)=>(Is((()=>e(...j(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(k,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(O),changedTableIds:Jt(r),changedRowIds:Pt(k),changedCellIds:Bt(T),changedValueIds:Jt(V)}),gt=()=>Bt(W),It=()=>Et(W),pt=e=>vt(zt(W,S(e))),ft=e=>Et(zt(W,S(e))),wt=(e,t,s,l=0,a)=>{return j(z((r=zt(W,S(e)),o=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),j([...r?.entries()??[]],(([e,t])=>o(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,r,o},yt=(e,t)=>Et(zt(zt(W,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(W,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,Te,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(re(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,ke))))&&(Le(t),!Vt(W))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,ke))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(W,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(W,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),Is=(e,t)=>{if(-1!=n){ps();const s=e();return fs(t),s}},ps=()=>(-1!=n&&n++,1==n&&ye(pe,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,ot(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,ot(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,Q([r,i,c,k,T,x,E,V,R,O],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(W,S(e))),getTableCellIds:e=>Et(zt(D,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(W,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(W),hasTable:e=>xt(W,S(e)),hasTableCell:(e,t)=>xt(zt(D,S(e)),S(t)),hasRow:(e,t)=>xt(zt(W,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(W,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(W),getValuesJson:()=>ne(G),getJson:()=>ne([W,G]),getTablesSchemaJson:()=>ne(A),getValuesSchemaJson:()=>ne(J),getSchemaJson:()=>ne([A,J]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>Te(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>Is((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(re(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(W,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:Is,startTransaction:ps,finishTransaction:fs,forEachTable:e=>Nt(W,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(D,S(e)),t),forEachRow:(e,t)=>Nt(zt(W,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(W,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,r)=>{let o=wt(e,t,s,l,a);return we((()=>{const r=wt(e,t,s,l,a);var i,d,u;d=o,$(i=r)===$(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(o=r,n(ws,e,t,s,l,a,o))}),ie[r?1:0],[e,t],[It])},addStartTransactionListener:e=>we(e,pe),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(oe),sortedRowIds:ts(ie),row:ts(de,Tt),cellIds:ts(ue,Tt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:kt(pe)+ts(fe)}),createStore:os,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[It]],[h+w]:[1,_,[It]],[I]:[1,ee,[It]],[p]:[1,oe,[It]],[g]:[2,de,[It,ft]],[w]:[2,ue,[It,ft]],[f]:[3,ce,[It,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,Ie,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?z(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(os),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,r=[])=>{let o,i,d,u=0,c=0,h=0,m=0;At(Wt,r,(()=>0)),At(Ut,r,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(N(o,e.delListener),g),schedule:async(...e)=>(U(zt(Ut,r),...e),await(async()=>{if(!zt(Wt,r)){for(Ot(Wt,r,1);!q(i=G(zt(Ut,r)));)try{await i()}catch(e){n?.(e)}Ot(Wt,r,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(g)})(e,(async()=>re(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>re(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,oe,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),F(A,null,F("aside",{id:oe},F(Ne,{s:l}),F(yt,{s:l})),F("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>F(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>F(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>F(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,s){"use strict";const l=e=>typeof e,a="",n=l(a),o=l(!0),r=l(0),i=l(l),d="type",u="default",c="Ids",h="Table",m=h+"s",b=h+c,g="Row",p=g+"Count",I=g+c,f="Cell",w=f+c,y="Value",C=y+"s",v=y+c,k="currentTarget",T="value",S=e=>a+e,x=Math.floor,V=isFinite,R=(e,t)=>e instanceof t,q=e=>null==e,N=(e,t,s)=>q(e)?s?.():t(e),L=e=>e==n||e==o,M=e=>l(e)==i,E=e=>Array.isArray(e),z=(e,t,s)=>e.slice(t,s),$=e=>e.length,{PureComponent:O,Fragment:A,createElement:F,useCallback:J,useLayoutEffect:P,useRef:B,useState:H}=t,D=(e,...t)=>q(e)?{}:e(...t),Q=(e,t)=>e.forEach(t),j=(e,t)=>e.map(t),W=e=>0==$(e),U=(e,...t)=>e.push(...t),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),te=(e,t)=>!q(((e,t)=>N(e,(e=>e[t])))(e,t)),se=(e,t)=>(delete e[t],e),le=(e,t)=>j(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>$(X(e)))(e),ne=e=>JSON.stringify(e,((e,t)=>R(t,Map)?K.fromEntries([...t]):t)),oe=JSON.parse,re="tinybaseStoreInspector",ie="TinyBase Store Inspector",de=["left","top","bottom","right","full"],ue="state",ce="sort",he="open",me="position",be=he,ge="editable",pe=(...e)=>ne(e),Ie=(e,t)=>j(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),J((s=>{t.setCell(ue,e,ge,(e=>!e)),s.preventDefault()}),[t,e])],we="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',Ce=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",ve='</svg>")',ke=ye+"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\")",Te=j([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,s,l])=>Ce+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${s}' height='${l}' fill='white'/>`+ve)),Se=Ce+"<path d='M20 20l60 60M20 80l60-60' />"+ve,xe=Ce+`<path d='${we}' />`+ve,Ve=Ce+`<path d='${we}M20 20l60 60' />`+ve,Re="*::-webkit-scrollbar",qe=`#${re}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,t="")=>e.join(t))(le({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[Re]:"width:0.5rem;height:0.5rem;",[Re+"-track"]:"background:#111",[Re+"-thumb"]:"background:#999;border:1px solid #111",[Re+"-thumb:hover"]:"background:#fff",[Re+"-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;"+ke,...ee(j(["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;",...ee(j(["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)":ke,"header>img:nth-of-type(6)":Se,...ee(j(Te,((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":xe,"details[open]>summary img.done":Ve,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,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?`& ${t}{${e}}`:"")))}`,Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:F("img",{onClick:l,title:ie,"data-position":t})},Le=({uniqueId:e,summary:t,editable:l,handleEditable:a,children:n,s:o})=>{const r=!!s.useCell(ue,e,he,o),i=s.useSetCellCallback(ue,e,he,(e=>e[k].open),[],o);return F("details",{open:r,onToggle:i},F("summary",null,t,a?F("img",{onClick:a,className:l?"done":"edit"}):null),n)},Me=e=>{const t=l(e);return L(t)||t==r&&V(e)?t:void 0},Ee=(e,t,s,l,a)=>q(a)?e.delCell(t,s,l,!0):e.setCell(t,s,l,a),ze=(e,t,s)=>q(s)?e.delValue(t):e.setValue(t,s),$e=(e,t,s,l)=>e==n?t:e==r?s:l,{useCallback:Oe,useMemo:Ae,useState:Fe}=t,Je="editable",Pe=(e,t)=>j(s.useTableCellIds(e,t),(t=>e+"."+t)),Be=(e,t,s)=>{const l=Oe(e,t);return s?l:void 0},He=(...e)=>Ae((()=>e),e),De=(e,t)=>Ae((()=>({store:e,tableId:t})),[e,t]),Qe=(e,t)=>Ae((()=>({queries:e,queryId:t})),[e,t]),je=(e,t=!1,s,l=0,a,n,o,r)=>{const[[i,d,u],c]=Fe([e,t,l]),h=Oe((e=>{c(e),r?.(e)}),[r]),m=Be((e=>h([e,e==i&&!d,u])),[h,i,d,u],s),b=Oe((e=>h([i,d,e])),[h,i,d]),g=!0===o?at:o;return[[i,d,u],m,Ae((()=>!1===o?null:F(g,{offset:u,limit:a,total:n,onChange:b})),[o,g,u,a,n,b])]},We=(e,t,s)=>Ae((()=>{const a=t??e;return ee(le(E(a)?ee(j(a,(e=>[e,e]))):a,((e,t)=>{return[t,{label:t,component:s,...(a=e,l(a)==n?{label:e}:e)}];var a})))}),[t,s,e]),Ue=({className:e,headerRow:t,idColumn:s,params:[l,a,n,o,r,i]})=>F("table",{className:e},i?F("caption",null,i):null,!1===t?null:F("thead",null,F("tr",null,!1===s?null:F(Ge,{sort:o??[],label:"Id",onClick:r}),le(l,(({label:e},t)=>F(Ge,{key:t,cellId:t,label:e,sort:o??[],onClick:r}))))),F("tbody",null,j(n,(e=>F("tr",{key:e},!1===s?null:F("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>F("td",{key:l},F(t,{...D(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>F("th",{onClick:Be((()=>n?.(e)),[n,e],n),className:q(s)||t!=e?void 0:`sorted ${s?"de":"a"}scending`},q(s)||t!=e?null:(s?"↓":"↑")+" ",l),Ke=({localRowId:e,params:[l,a,n,o,r,i,d]})=>{const u=s.useRemoteRowId(r,e,i);return F("tr",null,!1===l?null:F(t.Fragment,null,F("th",null,e),F("th",null,u)),le(a,(({component:t,getComponentProps:s},l)=>{const[a,r]=l.split(".",2),i=a===n?e:a===o?u:null;return q(i)?null:F("td",{key:l},F(t,{...D(s,i,r),store:d,tableId:a,rowId:i,cellId:r}))})))},Xe=({thing:e,onThingChange:t,className:s,hasSchema:l,showType:a=!0})=>{const[i,d]=Fe(),[u,c]=Fe(),[h,m]=Fe(),[b,g]=Fe(),[p,I]=Fe();u!==e&&(d(Me(e)),c(e),m(e+""),g(Number(e)||0),I(!!e));const f=Oe(((e,s)=>{s(e),c(e),t(e)}),[t]),w=Oe((()=>{if(!l?.()){const e=$e(i,r,o,n),s=$e(e,h,b,p);d(e),c(s),t(s)}}),[l,t,h,b,p,i]);return F("div",{className:s},a?F("button",{className:i,onClick:w},i):null,$e(i,F("input",{key:i,value:h,onChange:Oe((e=>f(e[k][T]+"",m)),[f])}),F("input",{key:i,type:"number",value:b,onChange:Oe((e=>f(Number(e[k][T]||0),g)),[f])}),F("input",{key:i,type:"checkbox",checked:p,onChange:Oe((e=>f(!!e[k].checked,I)),[f])})))},Ye=({tableId:e,cellId:t,descending:l,offset:a,limit:n,store:o,editable:r,sortOnClick:i,paginator:d=!1,onChange:u,customCells:c,...h})=>{const[m,b,g]=je(t,l,i,a,n,s.useRowCount(e,o),d,u);return F(Ue,{...h,params:He(We(s.useTableCellIds(e,o),c,r?st:s.CellView),De(o,e),s.useSortedRowIds(e,...m,n,o),m,b,g)})},Ze=({store:e,editable:t=!1,valueComponent:l=(t?lt:s.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:r})=>F("table",{className:n},!1===o?null:F("thead",null,F("tr",null,!1===r?null:F("th",null,"Id"),F("th",null,y))),F("tbody",null,j(s.useValueIds(e),(t=>F("tr",{key:t},!1===r?null:F("th",null,t),F("td",null,F(l,{...D(a,t),valueId:t,store:e}))))))),_e=({indexId:e,sliceId:t,indexes:l,editable:a,customCells:n,...o})=>{const[r,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(s.useIndexesOrIndexesById(l),e);return F(Ue,{...o,params:He(We(s.useTableCellIds(d,i),n,a?st:s.CellView),De(i,d),s.useSliceRowIds(e,t,r))})},et=({relationshipId:e,relationships:l,editable:a,customCells:n,className:o,headerRow:r,idColumn:i=!0})=>{const[d,u,c,h]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(s.useRelationshipsOrRelationshipsById(l),e),m=We([...Pe(c,u),...Pe(h,u)],n,a?st:s.CellView),b=He(i,m,c,h,e,d,u);return F("table",{className:o},!1===r?null:F("thead",null,F("tr",null,!1===i?null:F(t.Fragment,null,F("th",null,c,".Id"),F("th",null,h,".Id")),le(m,(({label:e},t)=>F("th",{key:t},e))))),F("tbody",null,j(s.useRowIds(c,u),(e=>F(Ke,{key:e,localRowId:e,params:b})))))},tt=({queryId:e,cellId:t,descending:l,offset:a,limit:n,queries:o,sortOnClick:r,paginator:i=!1,customCells:d,onChange:u,...c})=>{const[h,m,b]=je(t,l,r,a,n,s.useResultRowCount(e,o),i,u);return F(Ue,{...c,params:He(We(s.useResultTableCellIds(e,o),d,s.ResultCellView),Qe(o,e),s.useResultSortedRowIds(e,...h,n,o),h,m,b)})},st=({tableId:e,rowId:t,cellId:l,store:a,className:n,showType:o})=>F(Xe,{thing:s.useCell(e,t,l,a),onThingChange:s.useSetCellCallback(e,t,l,(e=>e),[],a),className:n??Je+f,showType:o,hasSchema:s.useStoreOrStoreById(a)?.hasTablesSchema}),lt=({valueId:e,store:t,className:l,showType:a})=>F(Xe,{thing:s.useValue(e,t),onThingChange:s.useSetValueCallback(e,(e=>e),[],t),className:l??Je+y,showType:a,hasSchema:s.useStoreOrStoreById(t)?.hasValuesSchema}),at=({onChange:e,total:s,offset:l=0,limit:a=s,singular:n="row",plural:o=n+"s"})=>{(l>s||l<0)&&(l=0,e(0));const r=Be((()=>e(l-a)),[e,l,a],l>0),i=Be((()=>e(l+a)),[e,l,a],l+a<s);return F(t.Fragment,null,s>a&&F(t.Fragment,null,F("button",{className:"previous",disabled:0==l,onClick:r},"←"),F("button",{className:"next",disabled:l+a>=s,onClick:i},"→"),l+1," to ",Math.min(s,l+a)," of "),s," ",1!=s?o:n)},nt=({indexes:e,indexesId:t,indexId:l,s:a})=>F(Le,{uniqueId:pe("i",t,l),summary:"Index: "+l,s:a},j(s.useSliceIds(l,e),(s=>F(ot,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a,key:s})))),ot=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=pe("i",t,s,l),[o,r]=fe(n,a);return F(Le,{uniqueId:n,summary:"Slice: "+l,editable:o,handleEditable:r,s:a},F(_e,{sliceId:l,indexId:s,indexes:e,editable:o}))},rt=({indexesId:e,s:t})=>{const l=s.useIndexes(e),a=s.useIndexIds(l);return q(l)?null:F(Le,{uniqueId:pe("i",e),summary:"Indexes: "+(e??u),s:t},W(a)?"No indexes defined":Ie(a,(s=>F(nt,{indexes:l,indexesId:e,indexId:s,s:t,key:s}))))},it=({metrics:e,metricId:t})=>F("tr",null,F("th",null,t),F("td",null,e?.getTableId(t)),F("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:F(Le,{uniqueId:pe("m",e),summary:"Metrics: "+(e??u),s:t},W(a)?"No metrics defined":F("table",null,F("thead",null,F("th",null,"Metric Id"),F("th",null,"Table Id"),F("th",null,"Metric")),F("tbody",null,j(a,(e=>F(it,{metrics:l,metricId:e,key:e}))))))},ut=({queries:e,queriesId:t,queryId:l,s:a})=>{const n=pe("q",t,l),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a);return F(Le,{uniqueId:n,summary:"Query: "+l,s:a},F(tt,{queryId:l,queries:e,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ct=({queriesId:e,s:t})=>{const l=s.useQueries(e),a=s.useQueryIds(l);return q(l)?null:F(Le,{uniqueId:pe("q",e),summary:"Queries: "+(e??u),s:t},W(a)?"No queries defined":Ie(a,(s=>F(ut,{queries:l,queriesId:e,queryId:s,s:t,key:s}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=pe("r",t,s),[n,o]=fe(a,l);return F(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:o,s:l},F(et,{relationshipId:s,relationships:e,editable:n}))},mt=({relationshipsId:e,s:t})=>{const l=s.useRelationships(e),a=s.useRelationshipIds(l);return q(l)?null:F(Le,{uniqueId:pe("r",e),summary:"Relationships: "+(e??u),s:t},W(a)?"No relationships defined":Ie(a,(s=>F(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t,key:s}))))},bt=({tableId:e,store:t,storeId:l,s:a})=>{const n=pe("t",l,e),[o,r,i]=oe(s.useCell(ue,n,ce,a)??"[]"),d=s.useSetCellCallback(ue,n,ce,ne,[],a),[u,c]=fe(n,a);return F(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},F(Ye,{tableId:e,store:t,cellId:o,descending:r,offset:i,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:u}))},gt=({store:e,storeId:t,s:l})=>{const a=pe("v",t),[n,o]=fe(a,l);return W(s.useValueIds(e))?null:F(Le,{uniqueId:a,summary:C,editable:n,handleEditable:o,s:l},F(Ze,{store:e,editable:n}))},pt=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:F(Le,{uniqueId:pe("s",e),summary:"Store: "+(e??u),s:t},F(gt,{storeId:e,store:l,s:t}),Ie(a,(s=>F(bt,{store:l,storeId:e,tableId:s,s:t,key:s}))))},It=({s:e})=>{const t=B(null),l=B(0),[a,n]=H(!1),{scrollLeft:o,scrollTop:r}=s.useValues(e);P((()=>{const e=t.current;if(e&&!a){const t=new MutationObserver((()=>{e.scrollWidth>=x(o)+e.clientWidth&&e.scrollHeight>=x(r)+e.clientHeight&&e.scrollTo(o,r)}));return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()}}),[a,o,r]);const i=J((t=>{const{scrollLeft:s,scrollTop:a}=t[k];cancelIdleCallback(l.current),l.current=requestIdleCallback((()=>{n(!0),e.setPartialValues({scrollLeft:s,scrollTop:a})}))}),[e]),d=s.useStore(),u=s.useStoreIds(),c=s.useMetrics(),h=s.useMetricsIds(),m=s.useIndexes(),b=s.useIndexesIds(),g=s.useRelationships(),p=s.useRelationshipsIds(),I=s.useQueries(),f=s.useQueriesIds();return q(d)&&W(u)&&q(c)&&W(h)&&q(m)&&W(b)&&q(g)&&W(p)&&q(I)&&W(f)?F("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):F("article",{ref:t,onScroll:i},F(pt,{s:e}),j(u,(t=>F(pt,{storeId:t,s:e,key:t}))),F(dt,{s:e}),j(h,(t=>F(dt,{metricsId:t,s:e,key:t}))),F(rt,{s:e}),j(b,(t=>F(rt,{indexesId:t,s:e,key:t}))),F(mt,{s:e}),j(p,(t=>F(mt,{relationshipsId:t,s:e,key:t}))),F(ct,{s:e}),j(f,(t=>F(ct,{queriesId:t,s:e,key:t}))))};class ft extends O{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?F("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const wt=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!1),[],e),a=s.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return F("header",null,F("img",{title:ie}),F("span",null,ie),j(de,((e,s)=>s==t?null:F("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),F("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?F("main",{"data-position":t},F(wt,{s:e}),F(ft,null,F(It,{s:e}))):null},Ct=e=>t=>{return s=(t,s)=>t+e(s),Rt(t).reduce(s,0);var s},vt=e=>e?.size??0,kt=Ct(vt),Tt=Ct(kt),St=Ct(Tt),xt=(e,t)=>e?.has(t)??!1,Vt=e=>q(e)||0==vt(e),Rt=e=>[...e?.values()??[]],qt=e=>e.clear(),Nt=(e,t)=>e?.forEach(t),Lt=(e,t)=>e?.delete(t),Mt=e=>new Map(e),Et=e=>[...e?.keys()??[]],zt=(e,t)=>e?.get(t),$t=(e,t)=>Nt(e,((e,s)=>t(s,e))),Ot=(e,t,s)=>q(s)?(Lt(e,t),e):e?.set(t,s),At=(e,t,s)=>(xt(e,t)||Ot(e,t,s()),zt(e,t)),Ft=(e,t,s,l=Ot)=>(le(t,((t,l)=>s(e,l,t))),$t(e,(s=>te(t,s)?0:l(e,s))),e),Jt=(e,t,s)=>{const l={};return Nt(e,((e,a)=>{const n=t?t(e,a):e;!s?.(n,e)&&(l[a]=n)})),l},Pt=(e,t,s)=>Jt(e,(e=>Jt(e,t,s)),ae),Bt=(e,t,s)=>Jt(e,(e=>Pt(e,t,s)),ae),Ht=(e,t)=>{const s=Mt();return Nt(e,((e,l)=>s.set(l,t?.(e)??e))),s},Dt=e=>Ht(e,Ht),Qt=e=>Ht(e,Dt),jt=(e,t,s,l,a=0)=>N((s?At:zt)(e,t[a],a>$(t)-2?s:Mt),(n=>{if(a>$(t)-2)return l?.(n)&&Ot(e,t[a]),n;const o=jt(n,t,s,l,a+1);return Vt(n)&&Ot(e,t[a]),o})),Wt=Mt(),Ut=Mt(),Gt="storage",Kt=globalThis.window,Xt=e=>new Set(E(e)||q(e)?e:[e]),Yt=(e,t)=>e?.add(t),Zt=/^\d+$/,_t=()=>{const e=[];let t=0;return[s=>(s?G(e):null)??a+t++,t=>{Zt.test(t)&&$(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=kt)=>t(e[0])+t(e[1]),ss=()=>[Mt(),Mt()],ls=e=>[...e],as=([e,t])=>e===t,ns=(e,t,s)=>q(e)||!_(e)||ae(e)||Y(e)?(s?.(),!1):(le(e,((s,l)=>{t(s,l)||se(e,l)})),!ae(e)),os=(e,t,s)=>Ot(e,t,zt(e,t)==-s?void 0:s),rs=()=>{let e,t,s=!1,l=!1,n=0;const o=Mt(),i=Mt(),c=Mt(),k=Mt(),T=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Mt(),P=Mt(),B=Xt(),H=Mt(),D=Mt(),W=Mt(),G=Mt(),K=ss(),X=ss(),Y=ss(),_=ss(),ee=ss(),re=ss(),ie=ss(),de=ss(),ue=ss(),ce=ss(),he=ss(),me=ss(),be=ss(),ge=ss(),pe=ss(),Ie=Mt(),fe=ss(),[we,ye,Ce,ve]=(e=>{let t;const[s,l]=_t(),n=Mt();return[(e,l,o,r=[],i=(()=>[]))=>{t??=ws;const d=s(1);return Ot(n,d,[e,l,o,r,i]),Yt(jt(l,o??[a],Xt),d),d},(e,s,...l)=>Q(((e,t=[a])=>{const s=[],l=(e,a)=>a==$(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):Q([t[a],null],(t=>l(zt(e,t),a+1)));return l(e,0),s})(e,s),(e=>Nt(e,(e=>zt(n,e)[0](t,...s??[],...l))))),e=>N(zt(n,e),(([,t,s])=>(jt(t,s??[a],void 0,(t=>(Lt(t,e),Vt(t)?1:0))),Ot(n,e),l(e),s))),e=>N(zt(n,e),(([e,,s=[],l,a])=>{const n=(...o)=>{const r=$(o);r==$(s)?e(t,...o,...a(o)):q(s[r])?Q(l[r]?.(...o)??[],(e=>n(...o,e))):n(...o,s[r])};n()}))]})(),ke=e=>{if(!ns(e,((e,t)=>[d,u].includes(t))))return!1;const t=e[d];return!(!L(t)&&t!=r||(Me(e[u])!=t&&se(e,u),0))},Te=(t,s)=>(!e||xt(A,s)||lt(s))&&ns(t,((e,t)=>Se(s,t,e)),(()=>lt(s))),Se=(e,t,s,l)=>ns(l?s:qe(s,e,t),((l,a)=>N(xe(e,t,a,l),(e=>(s[a]=e,!0)),(()=>!1))),(()=>lt(e,t))),xe=(t,s,l,a)=>e?N(zt(zt(A,t),l),(e=>Me(a)!=e[d]?lt(t,s,l,a,e[u]):a),(()=>lt(t,s,l,a))):q(Me(a))?lt(t,s,l,a):a,Ve=(e,t)=>ns(t?e:Ne(e),((t,s)=>N(Re(s,t),(t=>(e[s]=t,!0)),(()=>!1))),(()=>at())),Re=(e,s)=>t?N(zt(J,e),(t=>Me(s)!=t[d]?at(e,s,t[u]):s),(()=>at(e,s))):q(Me(s))?at(e,s):s,qe=(e,t,s)=>(N(zt(F,t),(([l,a])=>{Nt(l,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(a,(l=>{te(e,l)||lt(t,s,l)}))})),e),Ne=e=>(t&&(Nt(P,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(B,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft(A,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At(A,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(F,t,[l,a])}),((e,t)=>{Ot(A,t),Ot(F,t)})),$e=e=>Ft(J,e,((e,t,s)=>{Ot(J,t,s),N(s[u],(e=>Ot(P,t,e)),(()=>Yt(B,t)))}),((e,t)=>{Ot(J,t),Ot(P,t),Lt(B,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(W,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(W,e,(()=>(Ye(e,1),Ot(H,e,_t()),Ot(D,e,Mt()),Mt()))),t,((t,s,l)=>Je(e,t,s,l)),((t,s)=>Ge(e,t,s))),Je=(e,t,s,l,a)=>Ft(At(t,s,(()=>(Ze(e,s,1),Mt()))),l,((t,l,a)=>Pe(e,s,t,l,a)),((l,n)=>Ke(e,t,s,l,n,a))),Pe=(e,t,s,l,a)=>{xt(s,l)||_e(e,t,l,1);const n=zt(s,l);a!==n&&(et(e,t,l,n,a),Ot(s,l,a))},Be=(e,t,s,l,a)=>N(zt(t,s),(t=>Pe(e,s,t,l,a)),(()=>Je(e,t,s,qe({[l]:a},e,s)))),He=e=>ae(e)?ms():Kt(e),De=e=>Ft(G,e,((e,t,s)=>Qe(t,s)),((e,t)=>Xe(t))),Qe=(e,t)=>{xt(G,e)||tt(e,1);const s=zt(G,e);t!==s&&(st(e,s,t),Ot(G,e,t))},je=(e,t)=>{const[s]=zt(H,e),l=s(t);return xt(zt(W,e),l)?je(e,t):l},We=e=>zt(W,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(H,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const o=zt(zt(F,e)?.[0],a);if(!q(o)&&!n)return Pe(e,s,l,a,o);const r=t=>{et(e,s,t,zt(l,t)),_e(e,s,t,-1),Ot(l,t)};q(o)?r(a):$t(l,r),Vt(l)&&(Ze(e,s,-1),Vt(Ot(t,s))&&(Ye(e,-1),Ot(W,e),Ot(H,e),Ot(D,e)))},Xe=e=>{const t=zt(P,e);if(!q(t))return Qe(e,t);st(e,zt(G,e)),tt(e,-1),Ot(G,e)},Ye=(e,t)=>os(o,e,t),Ze=(e,t,s)=>os(At(k,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(D,e),n=zt(a,s)??0;(0==n&&1==l||1==n&&-1==l)&&os(At(i,e,Mt),s,l),Ot(a,s,n!=-l?n+l:null),os(At(At(T,e,Mt),t,Mt),s,l)},et=(e,t,s,l,a)=>At(At(At(x,e,Mt),t,Mt),s,(()=>[l,0]))[1]=a,tt=(e,t)=>os(V,e,t),st=(e,t,s)=>At(R,e,(()=>[t,0]))[1]=s,lt=(e,t,s,l,a)=>(U(At(At(At(E,e,Mt),t,Mt),s,(()=>[])),l),a),at=(e,t,s)=>(U(At(O,e,(()=>[])),t),s),nt=(e,t,s)=>N(zt(zt(zt(x,e),t),s),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ct(e,t,s))])),ot=e=>N(zt(R,e),(([e,t])=>[!0,e,t]),(()=>[!1,...es(Ut(e))])),rt=e=>Vt(E)||Vt(he[e])?0:Nt(e?Qt(E):E,((t,s)=>Nt(t,((t,l)=>Nt(t,((t,a)=>ye(he[e],[s,l,a],t))))))),it=e=>Vt(O)||Vt(me[e])?0:Nt(e?Ht(O):O,((t,s)=>ye(me[e],[s],t))),dt=(e,t,s)=>{if(!Vt(t))return ye(e,s,(()=>Jt(t))),1},ut=e=>{const t=Vt(ie[e]),s=Vt(ue[e])&&Vt(_[e])&&Vt(ee[e])&&Vt(re[e])&&t&&Vt(X[e]),l=Vt(ce[e])&&Vt(de[e])&&Vt(Y[e])&&Vt(K[e]);if(!s||!l){const a=e?[Ht(o),Dt(i),Ht(c),Dt(k),Qt(T),Qt(x)]:[o,i,c,k,T,x];if(!s){dt(X[e],a[0]),Nt(a[1],((t,s)=>dt(_[e],t,[s]))),Nt(a[2],((t,s)=>{0!=t&&ye(ee[e],[s],It(s))}));const s=Xt();Nt(a[3],((l,a)=>{dt(re[e],l,[a])&&!t&&(ye(ie[e],[a,null]),Yt(s,a))})),t||Nt(a[5],((t,l)=>{if(!xt(s,l)){const s=Xt();Nt(t,(e=>Nt(e,(([t,l],a)=>l!==t?Yt(s,a):Lt(e,a))))),Nt(s,(t=>ye(ie[e],[l,t])))}})),Nt(a[4],((t,s)=>Nt(t,((t,l)=>dt(ue[e],t,[s,l])))))}if(!l){let t;Nt(a[5],((s,l)=>{let a;Nt(s,((s,n)=>{let o;Nt(s,(([s,r],i)=>{r!==s&&(ye(ce[e],[l,n,i],r,s,nt),t=a=o=1)})),o&&ye(de[e],[l,n],nt)})),a&&ye(Y[e],[l],nt)})),t&&ye(K[e],void 0,nt)}}},ct=e=>{const t=Vt(ge[e]),s=Vt(pe[e])&&Vt(be[e]);if(!t||!s){const l=e?[Ht(V),Ht(R)]:[V,R];if(t||dt(ge[e],l[0]),!s){let t;Nt(l[1],(([s,l],a)=>{l!==s&&(ye(pe[e],[a],l,s,ot),t=1)})),t&&ye(be[e],void 0,ot)}}},ht=(e,...t)=>(ps((()=>e(...j(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(o,t)?null:Jt(e,((e,s)=>-1===zt(zt(k,t),s)?null:Jt(e,(([,e])=>e??null),((e,t)=>as(t)))),ae)),ae),Jt(R,(([,e])=>e??null),((e,t)=>as(t)))],bt=()=>({cellsTouched:s,valuesTouched:l,changedCells:Bt(x,ls,as),invalidCells:Bt(E),changedValues:Jt(R,ls,as),invalidValues:Jt(O),changedTableIds:Jt(o),changedRowIds:Pt(k),changedCellIds:Bt(T),changedValueIds:Jt(V)}),gt=()=>Bt(W),pt=()=>Et(W),It=e=>vt(zt(W,S(e))),ft=e=>Et(zt(W,S(e))),wt=(e,t,s,l=0,a)=>{return j(z((o=zt(W,S(e)),r=(e,s)=>[q(t)?s:zt(e,S(t)),s],n=([e],[t])=>((e??0)<(t??0)?-1:1)*(s?-1:1),j([...o?.entries()??[]],(([e,t])=>r(t,e))).sort(n)),l,q(a)?a:l+a),(([,e])=>e));var n,o,r},yt=(e,t)=>Et(zt(zt(W,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(W,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,Te,lt))(e)?Ae(e):0)),Kt=e=>ht((()=>Ve(e)?De(e):0)),Zt=e=>{try{Oe(oe(e))}catch{}return ws},is=t=>ht((()=>{if((e=ns(t,(e=>ns(e,ke))))&&(Le(t),!Vt(W))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,ke))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(W,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(W,e),(s=>xt(s,t)?Ge(e,s,t):0))),e,t),ms=()=>ht((()=>De({}))),bs=()=>ht((()=>{Le({}),e=!1})),gs=()=>ht((()=>{$e({}),t=!1})),ps=(e,t)=>{if(-1!=n){Is();const s=e();return fs(t),s}},Is=()=>(-1!=n&&n++,1==n&&ye(Ie,void 0,mt,bt),ws),fs=e=>(n>0&&(n--,0==n&&(s=!Vt(x),l=!Vt(R),n=1,rt(1),s&&ut(1),it(1),l&&ct(1),e?.(mt,bt)&&(Nt(x,((e,t)=>Nt(e,((e,s)=>Nt(e,(([e],l)=>Ee(ws,t,s,l,e))))))),Nt(R,(([e],t)=>ze(ws,t,e))),s=l=!1),ye(fe[0],void 0,mt,bt),n=-1,rt(0),s&&ut(0),it(0),l&&ct(0),ye(fe[1],void 0,mt,bt),n=0,s=l=!1,Q([o,i,c,k,T,x,E,V,R,O],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:pt,getTable:e=>Pt(zt(W,S(e))),getTableCellIds:e=>Et(zt(D,S(e))),getRowCount:It,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(W,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(W),hasTable:e=>xt(W,S(e)),hasTableCell:(e,t)=>xt(zt(D,S(e)),S(t)),hasRow:(e,t)=>xt(zt(W,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(W,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(W),getValuesJson:()=>ne(G),getJson:()=>ne([W,G]),getTablesSchemaJson:()=>ne(A),getValuesSchemaJson:()=>ne(J),getSchemaJson:()=>ne([A,J]),hasTablesSchema:()=>e,hasValuesSchema:()=>t,setContent:([e,t])=>ht((()=>{(ae(e)?us:Gt)(e),(ae(t)?ms:Kt)(t)})),setTables:Gt,setTable:(e,t)=>ht((e=>Te(t,e)?Fe(e,t):0),e),setRow:(e,t,s)=>ht(((e,t)=>Se(e,t,s)?Je(e,We(e),t,s):0),e,t),addRow:(e,t,s=!0)=>ps((()=>{let l;return Se(e,l,t)&&(e=S(e),Je(e,We(e),l=je(e,s?1:0),t)),l})),setPartialRow:(e,t,s)=>ht(((e,t)=>{if(Se(e,t,s,1)){const l=We(e);le(s,((s,a)=>Be(e,l,t,a,s)))}}),e,t),setCell:(e,t,s,l)=>ht(((e,t,s)=>N(xe(e,t,s,M(l)?l(Ct(e,t,s)):l),(l=>Be(e,We(e),t,s,l)))),e,t,s),setValues:Kt,setPartialValues:e=>ht((()=>Ve(e,1)?le(e,((e,t)=>Qe(t,e))):0)),setValue:(e,t)=>ht((e=>N(Re(e,M(t)?t(Ut(e)):t),(t=>Qe(e,t)))),e),setTransactionChanges:e=>ht((()=>{le(e[0],((e,t)=>q(e)?cs(t):le(e,((e,s)=>q(e)?hs(t,s):le(e,((e,l)=>Ee(ws,t,s,l,e))))))),le(e[1],((e,t)=>ze(ws,t,e)))})),setTablesJson:Zt,setValuesJson:e=>{try{He(oe(e))}catch{}return ws},setJson:e=>ht((()=>{try{const[t,s]=oe(e);Oe(t),He(s)}catch{Zt(e)}})),setTablesSchema:is,setValuesSchema:ds,setSchema:(e,t)=>ht((()=>{is(e),ds(t)})),delTables:us,delTable:cs,delRow:hs,delCell:(e,t,s,l)=>ht(((e,t,s)=>N(zt(W,e),(a=>N(zt(a,t),(n=>xt(n,s)?Ke(e,a,t,n,s,l):0))))),e,t,s),delValues:ms,delValue:e=>ht((e=>xt(G,e)?Xe(e):0),e),delTablesSchema:bs,delValuesSchema:gs,delSchema:()=>ht((()=>{bs(),gs()})),transaction:ps,startTransaction:Is,finishTransaction:fs,forEachTable:e=>Nt(W,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(D,S(e)),t),forEachRow:(e,t)=>Nt(zt(W,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(W,S(e)),S(t)),s),forEachValue:e=>$t(G,e),addSortedRowIdsListener:(e,t,s,l,a,n,o)=>{let r=wt(e,t,s,l,a);return we((()=>{const o=wt(e,t,s,l,a);var i,d,u;d=r,$(i=o)===$(d)&&(u=(e,t)=>d[t]===e,i.every(u))||(r=o,n(ws,e,t,s,l,a,r))}),ie[o?1:0],[e,t],[pt])},addStartTransactionListener:e=>we(e,Ie),addWillFinishTransactionListener:e=>we(e,fe[0]),addDidFinishTransactionListener:e=>we(e,fe[1]),callListener:e=>(ve(e),ws),delListener:e=>(Ce(e),ws),getListenerStats:()=>({tables:ts(K),tableIds:ts(X),tableCellIds:ts(_),table:ts(Y),rowCount:ts(ee),rowIds:ts(re),sortedRowIds:ts(ie),row:ts(de,Tt),cellIds:ts(ue,Tt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(pe),invalidValue:ts(me),transaction:kt(Ie)+ts(fe)}),createStore:rs,addListener:we,callListeners:ye};return le({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[pt]],[h+w]:[1,_,[pt]],[p]:[1,ee,[pt]],[I]:[1,re,[pt]],[g]:[2,de,[pt,ft]],[w]:[2,ue,[pt,ft]],[f]:[3,ce,[pt,ft,yt],e=>es(Ct(...e))],InvalidCell:[3,he],[C]:[0,be],[v]:[0,ge],[y]:[1,pe,[Wt],e=>es(Ut(e[0]))],InvalidValue:[1,me]},(([e,t,s,l],a)=>{ws["add"+a+"Listener"]=(...a)=>we(a[e],t[a[e+1]?1:0],e>0?z(a,0,e):void 0,s,l)})),Z(ws)},is=({position:e="right",open:t=!1})=>{const l=s.useCreateStore(rs),a=de.indexOf(e);return s.useCreatePersister(l,(e=>{return((e,t,s,l)=>((e,t,s,l,a,n,o=[])=>{let r,i,d,u=0,c=0,h=0,m=0;At(Wt,o,(()=>0)),At(Ut,o,(()=>[]));const b=async e=>(2!=u&&(u=1,c++,await g.schedule((async()=>{await e(),u=0}))),g),g={load:async(s,l)=>await b((async()=>{try{e.setContent(await t())}catch{e.setContent([s,l])}})),startAutoLoad:async(s={},a={})=>(g.stopAutoLoad(),await g.load(s,a),m=1,d=l((async(s,l)=>{if(l){const t=l();await b((async()=>e.setTransactionChanges(t)))}else await b((async()=>{try{e.setContent(s?.()??await t())}catch(e){n?.(e)}}))})),g),stopAutoLoad:()=>(m&&(a(d),d=void 0,m=0),g),save:async t=>(1!=u&&(u=2,h++,await g.schedule((async()=>{try{await s(e.getContent,t)}catch(e){n?.(e)}u=0}))),g),startAutoSave:async()=>(await g.stopAutoSave().save(),r=e.addDidFinishTransactionListener(((e,t)=>{const[s,l]=t();ae(s)&&ae(l)||g.save((()=>[s,l]))})),g),stopAutoSave:()=>(N(r,e.delListener),g),schedule:async(...e)=>(U(zt(Ut,o),...e),await(async()=>{if(!zt(Wt,o)){for(Ot(Wt,o,1);!q(i=G(zt(Ut,o)));)try{await i()}catch(e){n?.(e)}Ot(Wt,o,0)}})(),g),getStore:()=>e,destroy:()=>g.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(g)})(e,(async()=>oe(s.getItem(t))),(async e=>s.setItem(t,ne(e()))),(e=>{const l=l=>{l.storageArea===s&&l.key===t&&e((()=>oe(l.newValue)))};return Kt.addEventListener(Gt,l),l}),(e=>Kt.removeEventListener(Gt,e)),l))(e,re,sessionStorage,t);var t}),void 0,(async e=>{await e.load(void 0,{position:-1==a?1:a,open:!!t}),await e.startAutoSave()})),F(A,null,F("aside",{id:re},F(Ne,{s:l}),F(yt,{s:l})),F("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>F(Ue,{...a,params:He(We(s.useResultTableCellIds(e,t),l,s.ResultCellView),Qe(t,e),s.useResultRowIds(e,t))}),e.SliceInHtmlTable=_e,e.SortedTableInHtmlTable=Ye,e.SortedTablePaginator=at,e.StoreInspector=e=>F(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>F(Ue,{...n,params:He(We(s.useTableCellIds(e,t),a,l?st:s.CellView),De(t,e),s.useRowIds(e,t))}),e.ValuesInHtmlTable=Ze},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,n=a(""),o=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:w,useState:f}=t,I=(e,...t)=>m(e)?{}:e(...t),C=(e,t)=>e.map(t),y=Object,k=(e=[])=>y.fromEntries(e),v=(e,t)=>C(y.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',T=R+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',N=R+"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\")",V=C([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=T+"<path d='M20 20l60 60M20 80l60-60' />"+S,M=T+`<path d='${x}' />`+S,$=T+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[q]:"width:0.5rem;height:0.5rem;",[q+"-track"]:"background:#111",[q+"-thumb"]:"background:#999;border:1px solid #111",[q+"-thumb:hover"]:"background:#fff",[q+"-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;"+N,...k(C(["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;",...k(C(["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)":N,"header>img:nth-of-type(6)":z,...k(C(V,((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":M,"details[open]>summary img.done":$,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,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?`& ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:F,useMemo:H,useState:O}=t,E="editable",P=(e,t)=>C(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=F(e,t);return l?a:void 0},D=(...e)=>H((()=>e),e),A=(e,t)=>H((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>H((()=>({queries:e,queryId:t})),[e,t]),U=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=O([e,t,a]),c=F((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=F((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,H((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},G=(e,t,l)=>H((()=>{const o=t??e;return k(v(Array.isArray(o)?k(C(o,(e=>[e,e]))):o,((e,t)=>{return[t,{label:t,component:l,...(o=e,a(o)==n?{label:e}:e)}];var o})))}),[t,l,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,n,o,r,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(K,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,C(o,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),v(a,(({component:t,getComponentProps:l},a)=>b("td",{key:a},b(t,{...I(l,e,a),...n,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>b("th",{onClick:j((()=>n?.(e)),[n,e],n),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:e,params:[a,n,o,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===a?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),v(n,(({component:t,getComponentProps:l},a)=>{const[n,s]=a.split(".",2),i=n===o?e:n===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:n,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[m,c]=O(),[h,g]=O(),[p,w]=O(),[f,I]=O(),[C,y]=O();h!==e&&(c((e=>{const t=a(e);return(e=>e==n||e==o)(t)||t==r&&u(e)?t:void 0})(e)),g(e),w(e+""),I(Number(e)||0),y(!!e));const k=F(((e,l)=>{l(e),g(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:m,onClick:F((()=>{if(!s?.()){const e=B(m,r,o,n),l=B(e,p,f,C);c(e),g(l),t(l)}}),[s,t,p,f,C,m])},m),B(m,b("input",{key:m,value:p,onChange:F((e=>k(e[i][d]+"",w)),[k])}),b("input",{key:m,type:"number",value:f,onChange:F((e=>k(Number(e[i][d]||0),I)),[k])}),b("input",{key:m,type:"checkbox",checked:C,onChange:F((e=>k(!!e[i].checked,y)),[k])})))},X=({tableId:e,rowId:t,cellId:a,store:n,className:o})=>b(W,{thing:l.useCell(e,t,a,n),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],n),className:o??E+"Cell",hasSchema:l.useStoreOrStoreById(n)?.hasTablesSchema}),Y=({valueId:e,store:t,className:a})=>b(W,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??E+s,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),Z=({onChange:e,total:l,offset:a=0,limit:n=l,singular:o="row",plural:r=o+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=j((()=>e(a-n)),[e,a,n],a>0),i=j((()=>e(a+n)),[e,a,n],a+n<l);return b(t.Fragment,null,l>n&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+n>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+n)," of "),l," ",1!=l?r:o)};class _ extends c{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ee=e=>new Map(e);ee(),ee(),e.EditableCellView=X,e.EditableValueView=Y,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:n,customCells:o,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=G([...P(m,u),...P(c,u)],o,n?X:l.CellView),g=D(i,h,m,c,e,d,u);return b("table",{className:r},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,m,".Id"),b("th",null,c,".Id")),v(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,C(l.useRowIds(m,u),(e=>b(Q,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:n,limit:o,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=U(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:D(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),L(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(J,{...n,params:D(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),L(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:n,customCells:o,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(J,{...r,params:D(G(l.useTableCellIds(d,i),o,n?X:l.CellView),A(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:n,limit:o,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=U(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(J,{...c,params:D(G(l.useTableCellIds(e,r),m,s?X:l.CellView),A(r,e),l.useSortedRowIds(e,...h,o,r),h,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>b(J,{...o,params:D(G(l.useTableCellIds(e,t),n,a?X:l.CellView),A(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Y:l.ValueView),getValueComponentProps:n,className:o,headerRow:r,idColumn:i})=>b("table",{className:o},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,C(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(n,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,l){"use strict";const a=e=>typeof e,o=a(""),n=a(!0),r=a(0),s="Value",i="currentTarget",d="value",u=isFinite,m=e=>null==e,{PureComponent:c,Fragment:h,createElement:b,useCallback:g,useLayoutEffect:p,useRef:w,useState:f}=t,I=(e,...t)=>m(e)?{}:e(...t),y=(e,t)=>e.map(t),C=Object,k=(e=[])=>C.fromEntries(e),v=(e,t)=>y(C.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',R=T+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",S='</svg>")',N=T+"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\")",V=y([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,a])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+S)),z=R+"<path d='M20 20l60 60M20 80l60-60' />"+S,M=R+`<path d='${x}' />`+S,$=R+`<path d='${x}M20 20l60 60' />`+S,q="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[q]:"width:0.5rem;height:0.5rem;",[q+"-track"]:"background:#111",[q+"-thumb"]:"background:#999;border:1px solid #111",[q+"-thumb:hover"]:"background:#fff",[q+"-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;"+N,...k(y(["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;",...k(y(["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)":N,"header>img:nth-of-type(6)":z,...k(y(V,((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":M,"details[open]>summary img.done":$,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,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?`& ${t}{${e}}`:"")));const B=(e,t,l,a)=>e==o?t:e==r?l:a,{useCallback:F,useMemo:H,useState:O}=t,E="editable",P=(e,t)=>y(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=F(e,t);return l?a:void 0},D=(...e)=>H((()=>e),e),A=(e,t)=>H((()=>({store:e,tableId:t})),[e,t]),L=(e,t)=>H((()=>({queries:e,queryId:t})),[e,t]),U=(e,t=!1,l,a=0,o,n,r,s)=>{const[[i,d,u],m]=O([e,t,a]),c=F((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=F((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,H((()=>!1===r?null:b(p,{offset:u,limit:o,total:n,onChange:g})),[r,p,u,o,n,g])]},G=(e,t,l)=>H((()=>{const n=t??e;return k(v(Array.isArray(n)?k(y(n,(e=>[e,e]))):n,((e,t)=>{return[t,{label:t,component:l,...(n=e,a(n)==o?{label:e}:e)}];var n})))}),[t,l,e]),J=({className:e,headerRow:t,idColumn:l,params:[a,o,n,r,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(K,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(K,{key:t,cellId:t,label:e,sort:r??[],onClick:s}))))),b("tbody",null,y(n,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),v(a,(({component:t,getComponentProps:l},a)=>b("td",{key:a},b(t,{...I(l,e,a),...o,rowId:e,cellId:a}))))))))),K=({cellId:e,sort:[t,l],label:a=e??"",onClick:o})=>b("th",{onClick:j((()=>o?.(e)),[o,e],o),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),Q=({localRowId:e,params:[a,o,n,r,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===a?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),v(o,(({component:t,getComponentProps:l},a)=>{const[o,s]=a.split(".",2),i=o===n?e:o===r?u:null;return m(i)?null:b("td",{key:a},b(t,{...I(l,i,s),store:d,tableId:o,rowId:i,cellId:s}))})))},W=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:m=!0})=>{const[c,h]=O(),[g,p]=O(),[w,f]=O(),[I,y]=O(),[C,k]=O();g!==e&&(h((e=>{const t=a(e);return(e=>e==o||e==n)(t)||t==r&&u(e)?t:void 0})(e)),p(e),f(e+""),y(Number(e)||0),k(!!e));const v=F(((e,l)=>{l(e),p(e),t(e)}),[t]),x=F((()=>{if(!s?.()){const e=B(c,r,n,o),l=B(e,w,I,C);h(e),p(l),t(l)}}),[s,t,w,I,C,c]);return b("div",{className:l},m?b("button",{className:c,onClick:x},c):null,B(c,b("input",{key:c,value:w,onChange:F((e=>v(e[i][d]+"",f)),[v])}),b("input",{key:c,type:"number",value:I,onChange:F((e=>v(Number(e[i][d]||0),y)),[v])}),b("input",{key:c,type:"checkbox",checked:C,onChange:F((e=>v(!!e[i].checked,k)),[v])})))},X=({tableId:e,rowId:t,cellId:a,store:o,className:n,showType:r})=>b(W,{thing:l.useCell(e,t,a,o),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],o),className:n??E+"Cell",showType:r,hasSchema:l.useStoreOrStoreById(o)?.hasTablesSchema}),Y=({valueId:e,store:t,className:a,showType:o})=>b(W,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??E+s,showType:o,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),Z=({onChange:e,total:l,offset:a=0,limit:o=l,singular:n="row",plural:r=n+"s"})=>{(a>l||a<0)&&(a=0,e(0));const s=j((()=>e(a-o)),[e,a,o],a>0),i=j((()=>e(a+o)),[e,a,o],a+o<l);return b(t.Fragment,null,l>o&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==a,onClick:s},"←"),b("button",{className:"next",disabled:a+o>=l,onClick:i},"→"),a+1," to ",Math.min(l,a+o)," of "),l," ",1!=l?r:n)};class _ extends c{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}static{this.getDerivedStateFromError=()=>({e:1})}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}const ee=e=>new Map(e);ee(),ee(),e.EditableCellView=X,e.EditableValueView=Y,e.RelationshipInHtmlTable=({relationshipId:e,relationships:a,editable:o,customCells:n,className:r,headerRow:s,idColumn:i=!0})=>{const[d,u,m,c]=((e,t)=>[e,e?.getStore(),e?.getLocalTableId(t),e?.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(a),e),h=G([...P(m,u),...P(c,u)],n,o?X:l.CellView),g=D(i,h,m,c,e,d,u);return b("table",{className:r},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,m,".Id"),b("th",null,c,".Id")),v(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,y(l.useRowIds(m,u),(e=>b(Q,{key:e,localRowId:e,params:g})))))},e.ResultSortedTableInHtmlTable=({queryId:e,cellId:t,descending:a,offset:o,limit:n,queries:r,sortOnClick:s,paginator:i=!1,customCells:d,onChange:u,...m})=>{const[c,h,g]=U(t,a,s,o,n,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:D(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),L(r,e),l.useResultSortedRowIds(e,...c,n,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...o})=>b(J,{...o,params:D(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),L(t,e),l.useResultRowIds(e,t))}),e.SliceInHtmlTable=({indexId:e,sliceId:t,indexes:a,editable:o,customCells:n,...r})=>{const[s,i,d]=((e,t)=>[e,e?.getStore(),e?.getTableId(t)])(l.useIndexesOrIndexesById(a),e);return b(J,{...r,params:D(G(l.useTableCellIds(d,i),n,o?X:l.CellView),A(i,d),l.useSliceRowIds(e,t,s))})},e.SortedTableInHtmlTable=({tableId:e,cellId:t,descending:a,offset:o,limit:n,store:r,editable:s,sortOnClick:i,paginator:d=!1,onChange:u,customCells:m,...c})=>{const[h,g,p]=U(t,a,i,o,n,l.useRowCount(e,r),d,u);return b(J,{...c,params:D(G(l.useTableCellIds(e,r),m,s?X:l.CellView),A(r,e),l.useSortedRowIds(e,...h,n,r),h,g,p)})},e.SortedTablePaginator=Z,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:o,...n})=>b(J,{...n,params:D(G(l.useTableCellIds(e,t),o,a?X:l.CellView),A(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Y:l.ValueView),getValueComponentProps:o,className:n,headerRow:r,idColumn:i})=>b("table",{className:n},!1===r?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,y(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(a,{...I(o,t),valueId:t,store:e})))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
Binary file
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n=t(""),o=(e,t)=>e instanceof t,r=e=>null==e,l=e=>t(e)==n,i=Object,s=i.keys,u=i.freeze,a=e=>(e=>o(e,i)&&e.constructor==i)(e)&&0==(e=>s(e).length)(e),c=e=>JSON.stringify(e,((e,t)=>o(t,Map)?i.fromEntries([...t]):t)),d=JSON.parse,v=e=>new Map(e),y=(e,t)=>null==e?void 0:e.get(t),f=(e,t,n)=>{return r(n)?(l=t,null==(o=e)||o.delete(l),e):null==e?void 0:e.set(t,n);var o,l},p=(e,t,n)=>{var o,r,l;return r=t,null!=(l=null==(o=e)?void 0:o.has(r))&&l||f(e,t,n()),y(e,t)};var h=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const P=v(),m=v();var b=Object.defineProperty,g=Object.defineProperties,O=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,A=(e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))j.call(t,n)&&A(e,n,t[n]);if(S)for(var n of S(t))w.call(t,n)&&A(e,n,t[n]);return e},x=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const C="message",T={storeProtocol:"https",storePath:"/store"};e.createPartyKitPersister=(e,t,n,o)=>{var i;const{host:s,room:v}=t.partySocketOptions,{storeProtocol:b,storePath:S}=L(L({},T),l(n)?{storeProtocol:n}:n),j=b+"://"+s+"/parties/"+(null!=(i=t.name)?i:"main")+"/"+v+S,w=e=>x(void 0,null,(function*(){return yield(yield fetch(j,(t=L({},e?{method:"PUT",body:c(e)}:{}),n={mode:"cors",cache:"no-store"},g(t,O(n))))).json();var t,n}));return((e,t,n,o,l,i,s=[])=>{let c,d,v,b=0,g=0;p(P,s,(()=>0)),p(m,s,(()=>[]));const O=e=>h(void 0,null,(function*(){return 2!=b&&(b=1,yield S.schedule((()=>h(void 0,null,(function*(){yield e(),b=0}))))),S})),S={load:(n,o)=>h(void 0,null,(function*(){return yield O((()=>h(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>h(void 0,[...n],(function*(n={},r={}){return S.stopAutoLoad(),yield S.load(n,r),g=1,v=o(((n,o)=>h(void 0,null,(function*(){if(o){const t=o();yield O((()=>h(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield O((()=>h(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==i||i(e)}}))))})))),S})),stopAutoLoad:()=>(g&&(l(v),v=void 0,g=0),S),save:t=>h(void 0,null,(function*(){return 1!=b&&(b=2,yield S.schedule((()=>h(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==i||i(e)}b=0}))))),S})),startAutoSave:()=>h(void 0,null,(function*(){return yield S.stopAutoSave().save(),c=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();a(n)&&a(o)||S.save((()=>[n,o]))})),S})),stopAutoSave:()=>{var t,n;return t=c,n=e.delListener,!!r(t)||n(t),S},schedule:(...e)=>h(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(y(m,s),...e),yield h(void 0,null,(function*(){if(!y(P,s)){for(f(P,s,1);!r((e=y(m,s),d=e.shift()));)try{yield d()}catch(e){null==i||i(e)}f(P,s,0)}var e})),S})),getStore:()=>e,destroy:()=>S.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return u(S)})(e,(()=>x(void 0,null,(function*(){return yield w()}))),((e,n)=>x(void 0,null,(function*(){var o;n?t.send((o=n(),"s"+(l(o)?o:c(o)))):yield w(e())}))),(e=>{const n=t=>{const[n,o]=[(s=t.data)[0],d((r=s,l=1,r.slice(l,i)))];var r,l,i,s;"s"==n&&e(void 0,(()=>o))};return t.addEventListener(C,n),n}),(e=>{t.removeEventListener(C,e)}),o)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitClient={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",o=t(n),r=(e,t)=>e instanceof t,l=e=>null==e,i=(e,t,n)=>l(e)?null==n?void 0:n():t(e),s=e=>t(e)==o,u=e=>e.length,a=Object,d=a.keys,c=a.freeze,v=e=>(e=>r(e,a)&&e.constructor==a)(e)&&0==(e=>u(d(e)))(e),y=e=>JSON.stringify(e,((e,t)=>r(t,Map)?a.fromEntries([...t]):t)),f=JSON.parse,p="/store",h=e=>new Map(e),m=(e,t)=>null==e?void 0:e.get(t),P=(e,t,n)=>{return l(n)?(r=t,null==(o=e)||o.delete(r),e):null==e?void 0:e.set(t,n);var o,r},b=(e,t,n)=>{var o,r,l;return r=t,null!=(l=null==(o=e)?void 0:o.has(r))&&l||P(e,t,n()),m(e,t)};var g=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const O=h(),S=h();var j=Object.defineProperty,w=Object.defineProperties,x=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,T=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))L.call(t,n)&&T(e,n,t[n]);if(A)for(var n of A(t))C.call(t,n)&&T(e,n,t[n]);return e},k=(e,t,n)=>new Promise(((o,r)=>{var l=e=>{try{s(n.next(e))}catch(e){r(e)}},i=e=>{try{s(n.throw(e))}catch(e){r(e)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(l,i);s((n=n.apply(e,t)).next())}));const D="message";e.createPartyKitPersister=(e,t,o,r)=>{var a;const{host:d,room:h}=t.partySocketOptions,{storeProtocol:j="https",storePath:A=p,messagePrefix:L=n}=E({},s(o)?{storeProtocol:o}:o),C=j+"://"+d+"/parties/"+(null!=(a=t.name)?a:"main")+"/"+h+A,T=e=>k(void 0,null,(function*(){return yield(yield fetch(C,(t=E({},e?{method:"PUT",body:y(e)}:{}),n={mode:"cors",cache:"no-store"},w(t,x(n))))).json();var t,n}));return((e,t,n,o,r,s,u=[])=>{let a,d,y,f=0,p=0;b(O,u,(()=>0)),b(S,u,(()=>[]));const h=e=>g(void 0,null,(function*(){return 2!=f&&(f=1,yield j.schedule((()=>g(void 0,null,(function*(){yield e(),f=0}))))),j})),j={load:(n,o)=>g(void 0,null,(function*(){return yield h((()=>g(void 0,null,(function*(){try{e.setContent(yield t())}catch(t){e.setContent([n,o])}}))))})),startAutoLoad:(...n)=>g(void 0,[...n],(function*(n={},r={}){return j.stopAutoLoad(),yield j.load(n,r),p=1,y=o(((n,o)=>g(void 0,null,(function*(){if(o){const t=o();yield h((()=>g(void 0,null,(function*(){return e.setTransactionChanges(t)}))))}else yield h((()=>g(void 0,null,(function*(){var o;try{e.setContent(null!=(o=null==n?void 0:n())?o:yield t())}catch(e){null==s||s(e)}}))))})))),j})),stopAutoLoad:()=>(p&&(r(y),y=void 0,p=0),j),save:t=>g(void 0,null,(function*(){return 1!=f&&(f=2,yield j.schedule((()=>g(void 0,null,(function*(){try{yield n(e.getContent,t)}catch(e){null==s||s(e)}f=0}))))),j})),startAutoSave:()=>g(void 0,null,(function*(){return yield j.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,t)=>{const[n,o]=t();v(n)&&v(o)||j.save((()=>[n,o]))})),j})),stopAutoSave:()=>(i(a,e.delListener),j),schedule:(...e)=>g(void 0,null,(function*(){return((e,...t)=>{e.push(...t)})(m(S,u),...e),yield g(void 0,null,(function*(){if(!m(O,u)){for(P(O,u,1);!l((e=m(S,u),d=e.shift()));)try{yield d()}catch(e){null==s||s(e)}P(O,u,0)}var e})),j})),getStore:()=>e,destroy:()=>j.stopAutoLoad().stopAutoSave(),getStats:()=>({})};return c(j)})(e,(()=>k(void 0,null,(function*(){return yield T()}))),((e,n)=>k(void 0,null,(function*(){var o,r;n?t.send((o=L,r=n(),o+"s"+(s(r)?r:y(r)))):yield T(e())}))),(e=>{const n=t=>i(((e,t,n)=>{const o=u(e);return((e,t)=>e.startsWith(t))(t,e)?[t[o],f((r=t,l=o+1,r.slice(l,void 0)))]:void 0;var r,l})(L,t.data),(([t,n])=>{"s"==t&&e(void 0,(()=>n))}));return t.addEventListener(D,n),n}),(e=>{t.removeEventListener(D,e)}),r)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitClient={});
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,s=t(""),n="t",r=Promise,i=e=>null==e,o=(e,t,s)=>e.slice(t,s),l=e=>e.length,a=(e,t)=>e.map(t),c=(e,...t)=>e.push(...t),u=Object,h=(e=[])=>u.fromEntries(e),d=(e,t)=>a(u.entries(e),(([e,s])=>t(s,e))),f=(e,t,s)=>(((e,t)=>!i(((e,t)=>{return n=e=>e[t],i(s=e)?void 0:n(s);var s,n})(e,t)))(e,t)||(e[t]=s()),e[t]),y=e=>JSON.stringify(e,((e,t)=>t instanceof Map?u.fromEntries([...t]):t)),p=JSON.parse,v=(e,t)=>[e[0],t?p(o(e,1)):o(e,1)],g=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,s)=>t(s,e)));var m=(e,t,s)=>new Promise(((n,r)=>{var i=e=>{try{l(s.next(e))}catch(e){r(e)}},o=e=>{try{l(s.throw(e))}catch(e){r(e)}},l=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);l((s=s.apply(e,t)).next())}));const P="hasStore",x=h(a(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),R=(e,t)=>m(void 0,null,(function*(){return yield e.get(t+P)})),w=(e,t,s)=>m(void 0,null,(function*(){const o=[e.put(t+P,1)],a=[];d(s[0],((s,r)=>i(s)?((e,...t)=>e.unshift(...t))(a,t+b(n,r)):d(s,((s,l)=>i(s)?c(a,t+b(n,r,l)):d(s,((s,i)=>S(o,e,t+b(n,r,l,i),s))))))),d(s[1],((s,n)=>S(o,e,t+"v"+n,s))),0!=l(a)&&g(yield e.list(),(t=>a.every((s=>!t.startsWith(s)||S(o,e,t)&&!1)))),yield(e=>{return t=function*(){return r.all(e)},new Promise(((e,s)=>{var n=e=>{try{i(t.next(e))}catch(e){s(e)}},r=e=>{try{i(t.throw(e))}catch(e){s(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,r);i((t=t.apply(void 0,null)).next())}));var t})(o)})),b=(e,...t)=>e+o(y(t),1,-1),S=(e,t,s,n)=>c(e,i(n)?t.delete(s):t.put(s,n));e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={},this.createResponse=(e,t=null)=>{var s;return new Response(t,{status:e,headers:null!=(s=this.config.responseHeaders)?s:x})}}onRequest(e){return m(this,null,(function*(){var t,s;const r=this.party.storage,i=null!=(t=this.config.storagePrefix)?t:"",a=null!=(s=this.config.storePath)?s:"/store";if(new URL(e.url).pathname.endsWith(a)){const t=yield R(r,i),s=yield e.text();return"PUT"==e.method?t?this.createResponse(205):(yield w(r,i,p(s)),this.createResponse(201)):this.createResponse(200,t?y(yield((e,t)=>m(void 0,null,(function*(){const s={},r={};return g(yield e.list(),((e,i)=>{if(e.startsWith(t)){e=o(e,l(t));const[a,c]=v(e);if(a==n){const[e,t,n]=p("["+c+"]");f(f(s,e,h),t,h)[n]=i}else"v"==a&&(r[c]=i)}})),[s,r]})))(r,i)):"")}return this.createResponse(404)}))}onMessage(e,n){return m(this,null,(function*(){var r;const i=this.party.storage,o=null!=(r=this.config.storagePrefix)?r:"",[l,a]=v(e,1);"s"==l&&(yield R(i,o))&&(yield w(i,o,a),this.party.broadcast(((e,n)=>"s"+(t(n)==s?n:y(n)))(0,a),[n.id]))}))}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
1
+ var e,t;e=this,t=function(e){"use strict";const t=e=>typeof e,n="",r=t(n),l="t",i=(e,t)=>e.startsWith(t),s=Promise,o=e=>null==e,a=(e,t,n)=>o(e)?null==n?void 0:n():t(e),u=(e,t,n)=>e.slice(t,n),c=e=>e.length,d=(e,t)=>e.map(t),f=(e,...t)=>e.push(...t),h=Object,y=(e=[])=>h.fromEntries(e),v=(e,t)=>d(h.entries(e),(([e,n])=>t(n,e))),p=(e,t,n)=>(((e,t)=>!o(((e,t)=>a(e,(e=>e[t])))(e,t)))(e,t)||(e[t]=n()),e[t]),g=e=>JSON.stringify(e,((e,t)=>t instanceof Map?h.fromEntries([...t]):t)),P=JSON.parse,S=(e,n,l)=>e+n+(t(l)==r?l:g(l)),m=(e,t,n)=>{const r=c(e);return i(t,e)?[t[r],(n?P:String)(u(t,r+1))]:void 0},x=(e,t)=>((e,t)=>null==e?void 0:e.forEach(t))(e,((e,n)=>t(n,e)));var w=(e,t,n)=>new Promise(((r,l)=>{var i=e=>{try{o(n.next(e))}catch(e){l(e)}},s=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=e=>e.done?r(e.value):Promise.resolve(e.value).then(i,s);o((n=n.apply(e,t)).next())}));const b="hasStore",T=y(d(["Origin","Methods","Headers"],(e=>["Access-Control-Allow-"+e,"*"]))),D=e=>w(void 0,null,(function*(){var t;return yield e.party.storage.get((null!=(t=e.config.storagePrefix)?t:n)+b)})),R=(e,t,r,a)=>w(void 0,null,(function*(){var u;const d=e.party.storage,h=null!=(u=e.config.storagePrefix)?u:n,y=[d.put(h+b,1)],p=[];v(t[0],((t,n)=>o(t)?!r&&e.canDelTable(n,a)&&((e,...t)=>e.unshift(...t))(p,C(h,l,n)):e.canSetTable(n,r,a)&&v(t,((t,i)=>o(t)?!r&&e.canDelRow(n,i,a)&&f(p,C(h,l,n,i)):e.canSetRow(n,i,r,a)&&v(t,((t,s)=>o(t)?!r&&e.canDelCell(n,i,s,a)&&f(y,d.delete(C(h,l,n,i,s))):e.canSetCell(n,i,s,t,r,a)&&f(y,d.put(C(h,l,n,i,s),t)))))))),v(t[1],((t,n)=>o(t)?!r&&e.canDelValue(n,a)&&f(y,d.delete(h+"v"+n)):e.canSetValue(n,t,r,a)&&f(y,d.put(h+"v"+n,t)))),0!=c(p)&&x(yield d.list(),(e=>p.every((t=>!i(e,t)||f(y,d.delete(e))&&0)))),yield(e=>{return t=function*(){return s.all(e)},new Promise(((e,n)=>{var r=e=>{try{i(t.next(e))}catch(e){n(e)}},l=e=>{try{i(t.throw(e))}catch(e){n(e)}},i=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,l);i((t=t.apply(void 0,null)).next())}));var t})(y)})),C=(e,t,...n)=>S(e,t,u(g(n),1,-1)),O=(e,t,n=null)=>w(void 0,null,(function*(){var r;return new Response(n,{status:t,headers:null!=(r=e.config.responseHeaders)?r:T})}));e.TinyBasePartyKitServer=class{constructor(e){this.party=e,this.config={}}onRequest(e){return w(this,null,(function*(){var t;const r=null!=(t=this.config.storePath)?t:"/store";if(new URL(e.url).pathname.endsWith(r)){const t=yield D(this),r=yield e.text();return"PUT"==e.method?t?O(this,205):(yield R(this,P(r),!0,e),O(this,201)):O(this,200,t?g(yield(i=this,w(void 0,null,(function*(){var e;const t={},r={},s=null!=(e=i.config.storagePrefix)?e:n;return x(yield i.party.storage.list(),((e,n)=>a(m(s,e),(([e,i])=>{if(e==l){const[e,r,l]=P("["+i+"]");p(p(t,e,y),r,y)[l]=n}else"v"==e&&(r[i]=n)})))),[t,r]})))):n)}var i;return O(this,404)}))}onMessage(e,t){return w(this,null,(function*(){var r;const l=null!=(r=this.config.messagePrefix)?r:n;yield a(m(l,e,1),(e=>w(this,[e],(function*([e,n]){"s"==e&&(yield D(this))&&(yield R(this,n,!1,t),this.party.broadcast(S(l,"s",n)))}))))}))}canSetTable(e,t,n){return!0}canDelTable(e,t){return!0}canSetRow(e,t,n,r){return!0}canDelRow(e,t,n){return!0}canSetCell(e,t,n,r,l,i){return!0}canDelCell(e,t,n,r){return!0}canSetValue(e,t,n,r){return!0}canDelValue(e,t){return!0}}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterPartyKitServer={});
@@ -1 +1 @@
1
- var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),a=n(!0),o=n(0),i=n(n),u="type",d="default",c="Ids",h="Table",m=h+"s",b=h+c,p="Row",g=p+"Count",v=p+c,f="Cell",I=f+c,y="Value",w=y+"s",C=y+c,k="currentTarget",x="value",S=e=>s+e,T=Math.floor,V=isFinite,R=(e,l)=>e instanceof l,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==a,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,B=(e,...l)=>O(e)?{}:e(...l),H=(e,l)=>e.forEach(l),Q=(e,l)=>e.map(l),W=e=>0==M(e),U=(e,...l)=>e.push(...l),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),le=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),te=(e,l)=>(delete e[l],e),ne=(e,l)=>Q(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>M(X(e)))(e),re=e=>JSON.stringify(e,((e,l)=>R(l,Map)?K.fromEntries([...l]):l)),ae=JSON.parse,oe="tinybaseStoreInspector",ie="TinyBase Store Inspector",ue=["left","top","bottom","right","full"],de="state",ce="sort",he="open",me="position",be=he,pe="editable",ge=(...e)=>re(e),ve=(e,l)=>Q(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),A((t=>{l.setCell(de,e,pe,(e=>!e)),t.preventDefault()}),[l,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',we=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ce='</svg>")',ke=ye+"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\")",xe=Q([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>we+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+Ce)),Se=we+"<path d='M20 20l60 60M20 80l60-60' />"+Ce,Te=we+`<path d='${Ie}' />`+Ce,Ve=we+`<path d='${Ie}M20 20l60 60' />`+Ce;var Re=Object.defineProperty,Oe=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Le=(e,l,t)=>l in e?Re(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Me=(e,l)=>{for(var t in l||(l={}))Ne.call(l,t)&&Le(e,t,l[t]);if(Pe)for(var t of Pe(l))Ee.call(l,t)&&Le(e,t,l[t]);return e},je=(e,l)=>Oe(e,qe(l));const ze="*::-webkit-scrollbar",$e=`#${oe}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,l="")=>e.join(l))(ne(je(Me(je(Me(je(Me({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[ze]:"width:0.5rem;height:0.5rem;",[ze+"-track"]:"background:#111",[ze+"-thumb"]:"background:#999;border:1px solid #111",[ze+"-thumb:hover"]:"background:#fff",[ze+"-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;"+ke},ee(Q(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),ee(Q(["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,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":Se}),ee(Q(xe,((e,l)=>[`header>img[data-id='${l}']`,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":Te,"details[open]>summary img.done":Ve,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,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,l)=>e?`& ${l}{${e}}`:"")))}`,Ae=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!0),[],e);return t.useValue(be,e)?null:$("img",{onClick:s,title:ie,"data-position":n})},Fe=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:a})=>{const o=!!t.useCell(de,e,he,a),i=t.useSetCellCallback(de,e,he,(e=>e[k].open),[],a);return $("details",{open:o,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},Je=e=>{const l=n(e);return P(l)||l==o&&V(e)?l:void 0},De=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Be=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),He=(e,l,t,n)=>e==r?l:e==o?t:n;var Qe=Object.defineProperty,We=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ye=(e,l,t)=>l in e?Qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ze=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Ye(e,t,l[t]);if(Ge)for(var t of Ge(l))Xe.call(l,t)&&Ye(e,t,l[t]);return e},_e=(e,l)=>We(e,Ue(l)),el=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Xe.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:ll,useMemo:tl,useState:nl}=l,sl="editable",rl=(e,l)=>Q(t.useTableCellIds(e,l),(l=>e+"."+l)),al=(e,l,t)=>{const n=ll(e,l);return t?n:void 0},ol=(...e)=>tl((()=>e),e),il=(e,l)=>tl((()=>({store:e,tableId:l})),[e,l]),ul=(e,l)=>tl((()=>({queries:e,queryId:l})),[e,l]),dl=(e,l=!1,t,n=0,s,r,a,o)=>{const[[i,u,d],c]=nl([e,l,n]),h=ll((e=>{c(e),null==o||o(e)}),[o]),m=al((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=ll((e=>h([i,u,e])),[h,i,u]),p=!0===a?kl:a;return[[i,u,d],m,tl((()=>!1===a?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[a,p,d,s,r,b])]},cl=(e,l,t)=>tl((()=>{const s=null!=l?l:e;return ee(ne(E(s)?ee(Q(s,(e=>[e,e]))):s,((e,l)=>{return[l,Ze(Ze({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),hl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,a,o,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(ml,{sort:null!=a?a:[],label:"Id",onClick:o}),ne(n,(({label:e},l)=>$(ml,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),$("tbody",null,Q(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,_e(Ze(Ze({},B(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:al((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),bl=({localRowId:e,params:[n,s,r,a,o,i,u]})=>{const d=t.useRemoteRowId(o,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),ne(s,(({component:l,getComponentProps:t},n)=>{const[s,o]=n.split(".",2),i=s===r?e:s===a?d:null;return O(i)?null:$("td",{key:n},$(l,_e(Ze({},B(t,i,o)),{store:u,tableId:s,rowId:i,cellId:o})))})))},pl=({thing:e,onThingChange:l,className:t,hasSchema:n})=>{const[s,i]=nl(),[u,d]=nl(),[c,h]=nl(),[m,b]=nl(),[p,g]=nl();u!==e&&(i(Je(e)),d(e),h(e+""),b(Number(e)||0),g(!!e));const v=ll(((e,t)=>{t(e),d(e),l(e)}),[l]);return $("div",{className:t},$("button",{className:s,onClick:ll((()=>{if(!(null==n?void 0:n())){const e=He(s,o,a,r),t=He(e,c,m,p);i(e),d(t),l(t)}}),[n,l,c,m,p,s])},s),He(s,$("input",{key:s,value:c,onChange:ll((e=>v(e[k][x]+"",h)),[v])}),$("input",{key:s,type:"number",value:m,onChange:ll((e=>v(Number(e[k][x]||0),b)),[v])}),$("input",{key:s,type:"checkbox",checked:p,onChange:ll((e=>v(!!e[k].checked,g)),[v])})))},gl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:a,limit:o,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=el(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=dl(s,r,d,a,o,t.useRowCount(n,i),c,h);return $(hl,_e(Ze({},b),{params:ol(cl(t.useTableCellIds(n,i),m,u?wl:t.CellView),il(i,n),t.useSortedRowIds(n,...p,o,i),p,g,v)}))},vl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>$("table",{className:r},!1===a?null:$("thead",null,$("tr",null,!1===o?null:$("th",null,"Id"),$("th",null,y))),$("tbody",null,Q(t.useValueIds(e),(l=>$("tr",{key:l},!1===o?null:$("th",null,l),$("td",null,$(n,_e(Ze({},B(s,l)),{valueId:l,store:e})))))))),fl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:a,customCells:o}=l,i=el(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(hl,_e(Ze({},i),{params:ol(cl(t.useTableCellIds(c,d),o,a?wl:t.CellView),il(d,c),t.useSliceRowIds(n,s,u))}))},Il=({relationshipId:e,relationships:n,editable:s,customCells:r,className:a,headerRow:o,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=cl([...rl(c,d),...rl(h,d)],r,s?wl:t.CellView),b=ol(i,m,c,h,e,u,d);return $("table",{className:a},!1===o?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),ne(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,Q(t.useRowIds(c,d),(e=>$(bl,{key:e,localRowId:e,params:b})))))},yl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:a,limit:o,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=el(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=dl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return $(hl,_e(Ze({},m),{params:ol(cl(t.useResultTableCellIds(n,i),c,t.ResultCellView),ul(i,n),t.useResultSortedRowIds(n,...b,o,i),b,p,g)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r})=>{var a;return $(pl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:sl+f,hasSchema:null==(a=t.useStoreOrStoreById(s))?void 0:a.hasTablesSchema})},Cl=({valueId:e,store:l,className:n})=>{var s;return $(pl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:sl+y,hasSchema:null==(s=t.useStoreOrStoreById(l))?void 0:s.hasValuesSchema})},kl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:a=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const o=al((()=>e(n-s)),[e,n,s],n>0),i=al((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:o},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?a:r)},xl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(Fe,{uniqueId:ge("i",l,n),summary:"Index: "+n,s:s},Q(t.useSliceIds(n,e),(t=>$(Sl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),Sl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ge("i",l,t,n),[a,o]=fe(r,s);return $(Fe,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},$(fl,{sliceId:n,indexId:t,indexes:e,editable:a}))},Tl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(Fe,{uniqueId:ge("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},W(s)?"No indexes defined":ve(s,(t=>$(xl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Vl=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(Fe,{uniqueId:ge("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},W(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,Q(s,(e=>$(Vl,{metrics:n,metricId:e,key:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=ge("q",l,n),[o,i,u]=ae(null!=(r=t.useCell(de,a,ce,s))?r:"[]"),d=t.useSetCellCallback(de,a,ce,re,[],s);return $(Fe,{uniqueId:a,summary:"Query: "+n,s:s},$(yl,{queryId:n,queries:e,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ql=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(Fe,{uniqueId:ge("q",e),summary:"Queries: "+(null!=e?e:d),s:l},W(s)?"No queries defined":ve(s,(t=>$(Ol,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ge("r",l,t),[r,a]=fe(s,n);return $(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},$(Il,{relationshipId:t,relationships:e,editable:r}))},Nl=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(Fe,{uniqueId:ge("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},W(s)?"No relationships defined":ve(s,(t=>$(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=ge("t",n,e),[o,i,u]=ae(null!=(r=t.useCell(de,a,ce,s))?r:"[]"),d=t.useSetCellCallback(de,a,ce,re,[],s),[c,m]=fe(a,s);return $(Fe,{uniqueId:a,summary:h+": "+e,editable:c,handleEditable:m,s:s},$(gl,{tableId:e,store:l,cellId:o,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},Ll=({store:e,storeId:l,s:n})=>{const s=ge("v",l),[r,a]=fe(s,n);return W(t.useValueIds(e))?null:$(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:a,s:n},$(vl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(Fe,{uniqueId:ge("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(Ll,{storeId:e,store:n,s:l}),ve(s,(t=>$(El,{store:n,storeId:e,tableId:t,s:l,key:t}))))},jl=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=T(a)+e.clientWidth&&e.scrollHeight>=T(o)+e.clientHeight&&e.scrollTo(a,o)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,a,o]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&W(d)&&O(c)&&W(h)&&O(m)&&W(b)&&O(p)&&W(g)&&O(v)&&W(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(Ml,{s:e}),Q(d,(l=>$(Ml,{storeId:l,s:e,key:l}))),$(Rl,{s:e}),Q(h,(l=>$(Rl,{metricsId:l,s:e,key:l}))),$(Tl,{s:e}),Q(b,(l=>$(Tl,{indexesId:l,s:e,key:l}))),$(Nl,{s:e}),Q(g,(l=>$(Nl,{relationshipsId:l,s:e,key:l}))),$(ql,{s:e}),Q(f,(l=>$(ql,{queriesId:l,s:e,key:l}))))};class zl extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl.getDerivedStateFromError=()=>({e:1});const $l=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!1),[],e),r=t.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:ie}),$("span",null,ie),Q(ue,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Al=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?$("main",{"data-position":n},$($l,{s:e}),$(zl,null,$(jl,{s:e}))):null},Fl=e=>l=>{return t=(l,t)=>l+e(t),Ul(l).reduce(t,0);var t},Jl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Fl(Jl),Bl=Fl(Dl),Hl=Fl(Bl),Ql=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Wl=e=>O(e)||0==Jl(e),Ul=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Gl=e=>e.clear(),Kl=(e,l)=>null==e?void 0:e.forEach(l),Xl=(e,l)=>null==e?void 0:e.delete(l),Yl=e=>new Map(e),Zl=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},_l=(e,l)=>null==e?void 0:e.get(l),et=(e,l)=>Kl(e,((e,t)=>l(t,e))),lt=(e,l,t)=>O(t)?(Xl(e,l),e):null==e?void 0:e.set(l,t),tt=(e,l,t)=>(Ql(e,l)||lt(e,l,t()),_l(e,l)),nt=(e,l,t,n=lt)=>(ne(l,((l,n)=>t(e,n,l))),et(e,(t=>le(l,t)?0:n(e,t))),e),st=(e,l,t)=>{const n={};return Kl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},rt=(e,l,t)=>st(e,(e=>st(e,l,t)),se),at=(e,l,t)=>st(e,(e=>rt(e,l,t)),se),ot=(e,l)=>{const t=Yl();return Kl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},it=e=>ot(e,ot),ut=e=>ot(e,it),dt=(e,l,t,n,s=0)=>q((t?tt:_l)(e,l[s],s>M(l)-2?t:Yl),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&lt(e,l[s]),r;const a=dt(r,l,t,n,s+1);return Wl(r)&&lt(e,l[s]),a}));var ct=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const ht=Yl(),mt=Yl();var bt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{o(t.next(e))}catch(e){s(e)}},a=e=>{try{o(t.throw(e))}catch(e){s(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);o((t=t.apply(e,l)).next())}));const pt="storage",gt=globalThis.window,vt=e=>new Set(E(e)||O(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),It=/^\d+$/,yt=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{It.test(l)&&M(e)<1e3&&U(e,l)}]},wt=e=>[e,e],Ct=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Yl(),Yl()],xt=e=>[...e],St=([e,l])=>e===l,Tt=(e,l,t)=>O(e)||!_(e)||se(e)||Y(e)?(null==t||t(),!1):(ne(e,((t,n)=>{l(t,n)||te(e,n)})),!se(e)),Vt=(e,l,t)=>lt(e,l,_l(e,l)==-t?void 0:t),Rt=()=>{let e,l,t=!1,n=!1,r=0;const a=Yl(),i=Yl(),c=Yl(),k=Yl(),x=Yl(),T=Yl(),V=Yl(),R=Yl(),E=Yl(),j=Yl(),z=Yl(),$=Yl(),A=Yl(),F=Yl(),J=vt(),D=Yl(),B=Yl(),W=Yl(),G=Yl(),K=kt(),X=kt(),Y=kt(),_=kt(),ee=kt(),oe=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ge=kt(),ve=Yl(),fe=kt(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=yt(),r=Yl();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return lt(r,u,[e,n,a,o,i]),ft(dt(n,null!=a?a:[s],vt),u),u},(e,t,...n)=>H(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?U(t,e):null===l[s]?Kl(e,(e=>n(e,s+1))):H([l[s],null],(l=>n(_l(e,l),s+1)));return n(e,0),t})(e,t),(e=>Kl(e,(e=>_l(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(_l(r,e),(([,l,t])=>(dt(l,null!=t?t:[s],void 0,(l=>(Xl(l,e),Wl(l)?1:0))),lt(r,e),n(e),t))),e=>q(_l(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=M(a);u==M(t)?e(l,...a,...s(a)):O(t[u])?H(null!=(i=null==(o=n[u])?void 0:o.call(n,...a))?i:[],(e=>r(...a,e))):r(...a,t[u])};r()}))]})(),ke=e=>{if(!Tt(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=o||(Je(e[d])!=l&&te(e,d),0))},xe=(l,t)=>(!e||Ql(z,t)||nl(t))&&Tt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Tt(n?t:Oe(t,e,l),((n,s)=>q(Te(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Te=(l,t,n,s)=>e?q(_l(_l(z,l),n),(e=>Je(s)!=e[u]?nl(l,t,n,s,e[d]):s),(()=>nl(l,t,n,s))):O(Je(s))?nl(l,t,n,s):s,Ve=(e,l)=>Tt(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(_l(A,e),(l=>Je(t)!=l[u]?sl(e,t,l[d]):t),(()=>sl(e,t))):O(Je(t))?sl(e,t):t,Oe=(e,l,t)=>(q(_l($,l),(([n,s])=>{Kl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Kl(F,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(J,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>nt(z,e,((e,l,t)=>{const n=Yl(),s=vt();nt(tt(z,l,Yl),t,((e,l,t)=>{lt(e,l,t),q(t[d],(e=>lt(n,l,e)),(()=>ft(s,l)))})),lt($,l,[n,s])}),((e,l)=>{lt(z,l),lt($,l)})),Ne=e=>nt(A,e,((e,l,t)=>{lt(A,l,t),q(t[d],(e=>lt(F,l,e)),(()=>ft(J,l)))}),((e,l)=>{lt(A,l),lt(F,l),Xl(J,l)})),Ee=e=>se(e)?ql():Sl(e),Le=e=>nt(W,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>nt(tt(W,e,(()=>(Ye(e,1),lt(D,e,yt()),lt(B,e,Yl()),Yl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>nt(tt(l,t,(()=>(Ze(e,t,1),Yl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ke(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Ql(t,n)||_e(e,l,n,1);const r=_l(t,n);s!==r&&(el(e,l,n,r,s),lt(t,n,s))},$e=(e,l,t,n,s)=>q(_l(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>se(e)?El():Tl(e),Fe=e=>nt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ql(G,e)||ll(e,1);const t=_l(G,e);l!==t&&(tl(e,t,l),lt(G,e,l))},Qe=(e,l)=>{const[t]=_l(D,e),n=t(l);return Ql(_l(W,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=_l(W,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=_l(D,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var a;const o=_l(null==(a=_l($,e))?void 0:a[0],s);if(!O(o)&&!r)return ze(e,t,n,s,o);const i=l=>{el(e,t,l,_l(n,l)),_e(e,t,l,-1),lt(n,l)};O(o)?i(s):et(n,i),Wl(n)&&(Ze(e,t,-1),Wl(lt(l,t))&&(Ye(e,-1),lt(W,e),lt(D,e),lt(B,e)))},Xe=e=>{const l=_l(F,e);if(!O(l))return He(e,l);tl(e,_l(G,e)),ll(e,-1),lt(G,e)},Ye=(e,l)=>Vt(a,e,l),Ze=(e,l,t)=>Vt(tt(k,e,Yl),l,t)&&lt(c,e,tt(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=_l(B,e),a=null!=(s=_l(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Vt(tt(i,e,Yl),t,n),lt(r,t,a!=-n?a+n:null),Vt(tt(tt(x,e,Yl),l,Yl),t,n)},el=(e,l,t,n,s)=>tt(tt(tt(T,e,Yl),l,Yl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Vt(V,e,l),tl=(e,l,t)=>tt(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(tt(tt(tt(E,e,Yl),l,Yl),t,(()=>[])),n),s),sl=(e,l,t)=>(U(tt(j,e,(()=>[])),l),t),rl=(e,l,t)=>q(_l(_l(_l(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(wl(e,l,t))])),al=e=>q(_l(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(xl(e))])),ol=e=>Wl(E)||Wl(he[e])?0:Kl(e?ut(E):E,((l,t)=>Kl(l,((l,n)=>Kl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Wl(j)||Wl(me[e])?0:Kl(e?ot(j):j,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Wl(l))return ye(e,t,(()=>st(l))),1},dl=e=>{const l=Wl(ie[e]),t=Wl(de[e])&&Wl(_[e])&&Wl(ee[e])&&Wl(oe[e])&&l&&Wl(X[e]),n=Wl(ce[e])&&Wl(ue[e])&&Wl(Y[e])&&Wl(K[e]);if(!t||!n){const s=e?[ot(a),it(i),ot(c),it(k),ut(x),ut(T)]:[a,i,c,k,x,T];if(!t){ul(X[e],s[0]),Kl(s[1],((l,t)=>ul(_[e],l,[t]))),Kl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],vl(t))}));const t=vt();Kl(s[3],((n,s)=>{ul(oe[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Kl(s[5],((l,n)=>{if(!Ql(t,n)){const t=vt();Kl(l,(e=>Kl(e,(([l,n],s)=>n!==l?ft(t,s):Xl(e,s))))),Kl(t,(l=>ye(ie[e],[n,l])))}})),Kl(s[4],((l,t)=>Kl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Kl(s[5],((t,n)=>{let s;Kl(t,((t,r)=>{let a;Kl(t,(([t,o],i)=>{o!==t&&(ye(ce[e],[n,r,i],o,t,rl),l=s=a=1)})),a&&ye(ue[e],[n,r],rl)})),s&&ye(Y[e],[n],rl)})),l&&ye(K[e],void 0,rl)}}},cl=e=>{const l=Wl(pe[e]),t=Wl(ge[e])&&Wl(be[e]);if(!l||!t){const n=e?[ot(V),ot(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Kl(n[1],(([t,n],s)=>{n!==t&&(ye(ge[e],[s],n,t,al),l=1)})),l&&ye(be[e],void 0,al)}}},hl=(e,...l)=>(jl((()=>e(...Q(l,S)))),Al),ml=()=>[st(T,((e,l)=>-1===_l(a,l)?null:st(e,((e,t)=>-1===_l(_l(k,l),t)?null:st(e,(([,e])=>null!=e?e:null),((e,l)=>St(l)))),se)),se),st(R,(([,e])=>null!=e?e:null),((e,l)=>St(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:at(T,xt,St),invalidCells:at(E),changedValues:st(R,xt,St),invalidValues:st(j),changedTableIds:st(a),changedRowIds:rt(k),changedCellIds:at(x),changedValueIds:st(V)}),pl=()=>at(W),gl=()=>Zl(W),vl=e=>Jl(_l(W,S(e))),fl=e=>Zl(_l(W,S(e))),Il=(e,l,t,n=0,s)=>{return Q(L((a=_l(W,S(e)),o=(e,t)=>[O(l)?t:_l(e,S(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},Q([...null!=(i=null==a?void 0:a.entries())?i:[]],(([e,l])=>o(l,e))).sort(r)),n,O(s)?s:n+s),(([,e])=>e));var r,a,o,i},yl=(e,l)=>Zl(_l(_l(W,S(e)),S(l))),wl=(e,l,t)=>_l(_l(_l(W,S(e)),S(l)),S(t)),Cl=()=>st(G),kl=()=>Zl(G),xl=e=>_l(G,S(e)),Sl=e=>hl((()=>(e=>Tt(e,xe,nl))(e)?Le(e):0)),Tl=e=>hl((()=>Ve(e)?Fe(e):0)),Vl=e=>{try{Ee(ae(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=Tt(l,(e=>Tt(e,ke))))&&(Pe(l),!Wl(W))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Tt(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ql(W,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(_l(W,e),(t=>Ql(t,l)?Ge(e,t,l):0))),e,l),El=()=>hl((()=>Fe({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ve,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Wl(T),n=!Wl(R),r=1,ol(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Kl(T,((e,l)=>Kl(e,((e,t)=>Kl(e,(([e],n)=>De(Al,l,t,n,e))))))),Kl(R,(([e],l)=>Be(Al,l,e))),t=n=!1),ye(fe[0],void 0,ml,bl),r=-1,ol(0),t&&dl(0),il(0),n&&cl(0),ye(fe[1],void 0,ml,bl),r=0,t=n=!1,H([a,i,c,k,x,T,E,V,R,j],Gl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:gl,getTable:e=>rt(_l(W,S(e))),getTableCellIds:e=>Zl(_l(B,S(e))),getRowCount:vl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>st(_l(_l(W,S(e)),S(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:xl,hasTables:()=>!Wl(W),hasTable:e=>Ql(W,S(e)),hasTableCell:(e,l)=>Ql(_l(B,S(e)),S(l)),hasRow:(e,l)=>Ql(_l(W,S(e)),S(l)),hasCell:(e,l,t)=>Ql(_l(_l(W,S(e)),S(l)),S(t)),hasValues:()=>!Wl(G),hasValue:e=>Ql(G,S(e)),getTablesJson:()=>re(W),getValuesJson:()=>re(G),getJson:()=>re([W,G]),getTablesSchemaJson:()=>re(z),getValuesSchemaJson:()=>re(A),getSchemaJson:()=>re([z,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(se(e)?ql:Sl)(e),(se(l)?El:Tl)(l)})),setTables:Sl,setTable:(e,l)=>hl((e=>xe(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>Se(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return Se(e,n,l)&&(e=S(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(Se(e,l,t,1)){const n=We(e);ne(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>q(Te(e,l,t,N(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Tl,setPartialValues:e=>hl((()=>Ve(e,1)?ne(e,((e,l)=>He(l,e))):0)),setValue:(e,l)=>hl((e=>q(Re(e,N(l)?l(xl(e)):l),(l=>He(e,l)))),e),setTransactionChanges:e=>hl((()=>{ne(e[0],((e,l)=>O(e)?Pl(l):ne(e,((e,t)=>O(e)?Nl(l,t):ne(e,((e,n)=>De(Al,l,t,n,e))))))),ne(e[1],((e,l)=>Be(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(ae(e))}catch(e){}return Al},setJson:e=>hl((()=>{try{const[l,t]=ae(e);Ee(l),Ae(t)}catch(l){Vl(e)}})),setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>q(_l(W,e),(s=>q(_l(s,l),(r=>Ql(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ql(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Kl(W,((l,t)=>e(t,(e=>Kl(l,((l,t)=>e(t,(e=>et(l,e))))))))),forEachTableCell:(e,l)=>et(_l(B,S(e)),l),forEachRow:(e,l)=>Kl(_l(W,S(e)),((e,t)=>l(t,(l=>et(e,l))))),forEachCell:(e,l,t)=>et(_l(_l(W,S(e)),S(l)),t),forEachValue:e=>et(G,e),addSortedRowIdsListener:(e,l,t,n,s,r,a)=>{let o=Il(e,l,t,n,s);return Ie((()=>{const a=Il(e,l,t,n,s);var i,u,d;u=o,M(i=a)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(o=a,r(Al,e,l,t,n,s,o))}),ie[a?1:0],[e,l],[gl])},addStartTransactionListener:e=>Ie(e,ve),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:Ct(K),tableIds:Ct(X),tableCellIds:Ct(_),table:Ct(Y),rowCount:Ct(ee),rowIds:Ct(oe),sortedRowIds:Ct(ie),row:Ct(ue,Bl),cellIds:Ct(de,Bl),cell:Ct(ce,Hl),invalidCell:Ct(he,Hl),values:Ct(be),valueIds:Ct(pe),value:Ct(ge),invalidValue:Ct(me),transaction:Dl(ve)+Ct(fe)}),createStore:Rt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[gl]],[h+I]:[1,_,[gl]],[g]:[1,ee,[gl]],[v]:[1,oe,[gl]],[p]:[2,ue,[gl,fl]],[I]:[2,de,[gl,fl]],[f]:[3,ce,[gl,fl,yl],e=>wt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ge,[kl],e=>wt(xl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>Ie(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),Z(Al)},Ot=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(Rt),s=ue.indexOf(e);return t.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,a=[])=>{let o,i,u,d=0,c=0,h=0,m=0;tt(ht,a,(()=>0)),tt(mt,a,(()=>[]));const b=e=>ct(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ct(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ct(void 0,null,(function*(){return yield b((()=>ct(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ct(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ct(void 0,null,(function*(){if(n){const l=n();yield b((()=>ct(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ct(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ct(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ct(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ct(void 0,null,(function*(){return yield p.stopAutoSave().save(),o=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();se(t)&&se(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(q(o,e.delListener),p),schedule:(...e)=>ct(void 0,null,(function*(){return U(_l(mt,a),...e),yield ct(void 0,null,(function*(){if(!_l(ht,a)){for(lt(ht,a,1);!O(i=G(_l(mt,a)));)try{yield i()}catch(e){null==r||r(e)}lt(ht,a,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>bt(void 0,null,(function*(){return ae(t.getItem(l))}))),(e=>bt(void 0,null,(function*(){return t.setItem(l,re(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>ae(n.newValue)))};return gt.addEventListener(pt,n),n}),(e=>gt.removeEventListener(pt,e)),n))(e,oe,sessionStorage,l);var l}),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:oe},$(Ae,{s:n}),$(Al,{s:n})),$("style",null,$e))};var qt=Object.defineProperty,Pt=Object.getOwnPropertySymbols,Nt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Lt=(e,l,t)=>l in e?qt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=wl,e.EditableValueView=Cl,e.RelationshipInHtmlTable=Il,e.ResultSortedTableInHtmlTable=yl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,a=el(l,["queryId","queries","customCells"]);return $(hl,_e(Ze({},a),{params:ol(cl(t.useResultTableCellIds(n,s),r,t.ResultCellView),ul(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=fl,e.SortedTableInHtmlTable=gl,e.SortedTablePaginator=kl,e.StoreInspector=e=>$(Ot,((e,l)=>{for(var t in l||(l={}))Nt.call(l,t)&&Lt(e,t,l[t]);if(Pt)for(var t of Pt(l))Et.call(l,t)&&Lt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:a}=l,o=el(l,["tableId","store","editable","customCells"]);return $(hl,_e(Ze({},o),{params:ol(cl(t.useTableCellIds(n,s),a,r?wl:t.CellView),il(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=vl},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
1
+ var e,l;e=this,l=function(e,l,t){"use strict";const n=e=>typeof e,s="",r=n(s),o=n(!0),a=n(0),i=n(n),u="type",d="default",c="Ids",h="Table",m=h+"s",b=h+c,p="Row",g=p+"Count",v=p+c,f="Cell",I=f+c,y="Value",w=y+"s",C=y+c,k="currentTarget",T="value",x=e=>s+e,S=Math.floor,V=isFinite,R=(e,l)=>e instanceof l,O=e=>null==e,q=(e,l,t)=>O(e)?null==t?void 0:t():l(e),P=e=>e==r||e==o,N=e=>n(e)==i,E=e=>Array.isArray(e),L=(e,l,t)=>e.slice(l,t),M=e=>e.length,{PureComponent:j,Fragment:z,createElement:$,useCallback:A,useLayoutEffect:F,useRef:J,useState:D}=l,B=(e,...l)=>O(e)?{}:e(...l),H=(e,l)=>e.forEach(l),Q=(e,l)=>e.map(l),W=e=>0==M(e),U=(e,...l)=>e.push(...l),G=e=>e.shift(),K=Object,X=K.keys,Y=K.isFrozen,Z=K.freeze,_=e=>R(e,K)&&e.constructor==K,ee=(e=[])=>K.fromEntries(e),le=(e,l)=>!O(((e,l)=>q(e,(e=>e[l])))(e,l)),te=(e,l)=>(delete e[l],e),ne=(e,l)=>Q(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>M(X(e)))(e),re=e=>JSON.stringify(e,((e,l)=>R(l,Map)?K.fromEntries([...l]):l)),oe=JSON.parse,ae="tinybaseStoreInspector",ie="TinyBase Store Inspector",ue=["left","top","bottom","right","full"],de="state",ce="sort",he="open",me="position",be=he,pe="editable",ge=(...e)=>re(e),ve=(e,l)=>Q(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),A((t=>{l.setCell(de,e,pe,(e=>!e)),t.preventDefault()}),[l,e])],Ie="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",ye='content:url("',we=ye+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",Ce='</svg>")',ke=ye+"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\")",Te=Q([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,l,t,n])=>we+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${l}' width='${t}' height='${n}' fill='white'/>`+Ce)),xe=we+"<path d='M20 20l60 60M20 80l60-60' />"+Ce,Se=we+`<path d='${Ie}' />`+Ce,Ve=we+`<path d='${Ie}M20 20l60 60' />`+Ce;var Re=Object.defineProperty,Oe=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Le=(e,l,t)=>l in e?Re(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Me=(e,l)=>{for(var t in l||(l={}))Ne.call(l,t)&&Le(e,t,l[t]);if(Pe)for(var t of Pe(l))Ee.call(l,t)&&Le(e,t,l[t]);return e},je=(e,l)=>Oe(e,qe(l));const ze="*::-webkit-scrollbar",$e=`#${ae}{\n all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999;\n ${((e,l="")=>e.join(l))(ne(je(Me(je(Me(je(Me({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[ze]:"width:0.5rem;height:0.5rem;",[ze+"-track"]:"background:#111",[ze+"-thumb"]:"background:#999;border:1px solid #111",[ze+"-thumb:hover"]:"background:#fff",[ze+"-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;"+ke},ee(Q(["bottom:0;left:0","top:0;right:0"],((e,l)=>[`>img[data-position='${l}']`,e])))),{main:"display:flex;flex-direction:column;background:#111d;color:#fff;position:fixed;"}),ee(Q(["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,l)=>[`main[data-position='${l}']`,e])))),{header:"display:flex;padding:0.25rem;background:#000;align-items:center","header>img:nth-of-type(1)":ke,"header>img:nth-of-type(6)":xe}),ee(Q(Te,((e,l)=>[`header>img[data-id='${l}']`,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":Se,"details[open]>summary img.done":Ve,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,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,l)=>e?`& ${l}{${e}}`:"")))}`,Ae=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!0),[],e);return t.useValue(be,e)?null:$("img",{onClick:s,title:ie,"data-position":n})},Fe=({uniqueId:e,summary:l,editable:n,handleEditable:s,children:r,s:o})=>{const a=!!t.useCell(de,e,he,o),i=t.useSetCellCallback(de,e,he,(e=>e[k].open),[],o);return $("details",{open:a,onToggle:i},$("summary",null,l,s?$("img",{onClick:s,className:n?"done":"edit"}):null),r)},Je=e=>{const l=n(e);return P(l)||l==a&&V(e)?l:void 0},De=(e,l,t,n,s)=>O(s)?e.delCell(l,t,n,!0):e.setCell(l,t,n,s),Be=(e,l,t)=>O(t)?e.delValue(l):e.setValue(l,t),He=(e,l,t,n)=>e==r?l:e==a?t:n;var Qe=Object.defineProperty,We=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable,Ye=(e,l,t)=>l in e?Qe(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t,Ze=(e,l)=>{for(var t in l||(l={}))Ke.call(l,t)&&Ye(e,t,l[t]);if(Ge)for(var t of Ge(l))Xe.call(l,t)&&Ye(e,t,l[t]);return e},_e=(e,l)=>We(e,Ue(l)),el=(e,l)=>{var t={};for(var n in e)Ke.call(e,n)&&l.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&Ge)for(var n of Ge(e))l.indexOf(n)<0&&Xe.call(e,n)&&(t[n]=e[n]);return t};const{useCallback:ll,useMemo:tl,useState:nl}=l,sl="editable",rl=(e,l)=>Q(t.useTableCellIds(e,l),(l=>e+"."+l)),ol=(e,l,t)=>{const n=ll(e,l);return t?n:void 0},al=(...e)=>tl((()=>e),e),il=(e,l)=>tl((()=>({store:e,tableId:l})),[e,l]),ul=(e,l)=>tl((()=>({queries:e,queryId:l})),[e,l]),dl=(e,l=!1,t,n=0,s,r,o,a)=>{const[[i,u,d],c]=nl([e,l,n]),h=ll((e=>{c(e),null==a||a(e)}),[a]),m=ol((e=>h([e,e==i&&!u,d])),[h,i,u,d],t),b=ll((e=>h([i,u,e])),[h,i,u]),p=!0===o?kl:o;return[[i,u,d],m,tl((()=>!1===o?null:$(p,{offset:d,limit:s,total:r,onChange:b})),[o,p,d,s,r,b])]},cl=(e,l,t)=>tl((()=>{const s=null!=l?l:e;return ee(ne(E(s)?ee(Q(s,(e=>[e,e]))):s,((e,l)=>{return[l,Ze(Ze({},{label:l,component:t}),(s=e,n(s)==r?{label:e}:e))];var s})))}),[l,t,e]),hl=({className:e,headerRow:l,idColumn:t,params:[n,s,r,o,a,i]})=>$("table",{className:e},i?$("caption",null,i):null,!1===l?null:$("thead",null,$("tr",null,!1===t?null:$(ml,{sort:null!=o?o:[],label:"Id",onClick:a}),ne(n,(({label:e},l)=>$(ml,{key:l,cellId:l,label:e,sort:null!=o?o:[],onClick:a}))))),$("tbody",null,Q(r,(e=>$("tr",{key:e},!1===t?null:$("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>$("td",{key:n},$(l,_e(Ze(Ze({},B(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>$("th",{onClick:ol((()=>null==r?void 0:r(e)),[r,e],r),className:O(t)||l!=e?void 0:`sorted ${t?"de":"a"}scending`},O(t)||l!=e?null:(t?"↓":"↑")+" ",n),bl=({localRowId:e,params:[n,s,r,o,a,i,u]})=>{const d=t.useRemoteRowId(a,e,i);return $("tr",null,!1===n?null:$(l.Fragment,null,$("th",null,e),$("th",null,d)),ne(s,(({component:l,getComponentProps:t},n)=>{const[s,a]=n.split(".",2),i=s===r?e:s===o?d:null;return O(i)?null:$("td",{key:n},$(l,_e(Ze({},B(t,i,a)),{store:u,tableId:s,rowId:i,cellId:a})))})))},pl=({thing:e,onThingChange:l,className:t,hasSchema:n,showType:s=!0})=>{const[i,u]=nl(),[d,c]=nl(),[h,m]=nl(),[b,p]=nl(),[g,v]=nl();d!==e&&(u(Je(e)),c(e),m(e+""),p(Number(e)||0),v(!!e));const f=ll(((e,t)=>{t(e),c(e),l(e)}),[l]),I=ll((()=>{if(!(null==n?void 0:n())){const e=He(i,a,o,r),t=He(e,h,b,g);u(e),c(t),l(t)}}),[n,l,h,b,g,i]);return $("div",{className:t},s?$("button",{className:i,onClick:I},i):null,He(i,$("input",{key:i,value:h,onChange:ll((e=>f(e[k][T]+"",m)),[f])}),$("input",{key:i,type:"number",value:b,onChange:ll((e=>f(Number(e[k][T]||0),p)),[f])}),$("input",{key:i,type:"checkbox",checked:g,onChange:ll((e=>f(!!e[k].checked,v)),[f])})))},gl=e=>{var l=e,{tableId:n,cellId:s,descending:r,offset:o,limit:a,store:i,editable:u,sortOnClick:d,paginator:c=!1,onChange:h,customCells:m}=l,b=el(l,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[p,g,v]=dl(s,r,d,o,a,t.useRowCount(n,i),c,h);return $(hl,_e(Ze({},b),{params:al(cl(t.useTableCellIds(n,i),m,u?wl:t.CellView),il(i,n),t.useSortedRowIds(n,...p,a,i),p,g,v)}))},vl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:o,idColumn:a})=>$("table",{className:r},!1===o?null:$("thead",null,$("tr",null,!1===a?null:$("th",null,"Id"),$("th",null,y))),$("tbody",null,Q(t.useValueIds(e),(l=>$("tr",{key:l},!1===a?null:$("th",null,l),$("td",null,$(n,_e(Ze({},B(s,l)),{valueId:l,store:e})))))))),fl=e=>{var l=e,{indexId:n,sliceId:s,indexes:r,editable:o,customCells:a}=l,i=el(l,["indexId","sliceId","indexes","editable","customCells"]);const[u,d,c]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(l)])(t.useIndexesOrIndexesById(r),n);return $(hl,_e(Ze({},i),{params:al(cl(t.useTableCellIds(c,d),a,o?wl:t.CellView),il(d,c),t.useSliceRowIds(n,s,u))}))},Il=({relationshipId:e,relationships:n,editable:s,customCells:r,className:o,headerRow:a,idColumn:i=!0})=>{const[u,d,c,h]=((e,l)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(l),null==e?void 0:e.getRemoteTableId(l)])(t.useRelationshipsOrRelationshipsById(n),e),m=cl([...rl(c,d),...rl(h,d)],r,s?wl:t.CellView),b=al(i,m,c,h,e,u,d);return $("table",{className:o},!1===a?null:$("thead",null,$("tr",null,!1===i?null:$(l.Fragment,null,$("th",null,c,".Id"),$("th",null,h,".Id")),ne(m,(({label:e},l)=>$("th",{key:l},e))))),$("tbody",null,Q(t.useRowIds(c,d),(e=>$(bl,{key:e,localRowId:e,params:b})))))},yl=e=>{var l=e,{queryId:n,cellId:s,descending:r,offset:o,limit:a,queries:i,sortOnClick:u,paginator:d=!1,customCells:c,onChange:h}=l,m=el(l,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[b,p,g]=dl(s,r,u,o,a,t.useResultRowCount(n,i),d,h);return $(hl,_e(Ze({},m),{params:al(cl(t.useResultTableCellIds(n,i),c,t.ResultCellView),ul(i,n),t.useResultSortedRowIds(n,...b,a,i),b,p,g)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r,showType:o})=>{var a;return $(pl,{thing:t.useCell(e,l,n,s),onThingChange:t.useSetCellCallback(e,l,n,(e=>e),[],s),className:null!=r?r:sl+f,showType:o,hasSchema:null==(a=t.useStoreOrStoreById(s))?void 0:a.hasTablesSchema})},Cl=({valueId:e,store:l,className:n,showType:s})=>{var r;return $(pl,{thing:t.useValue(e,l),onThingChange:t.useSetValueCallback(e,(e=>e),[],l),className:null!=n?n:sl+y,showType:s,hasSchema:null==(r=t.useStoreOrStoreById(l))?void 0:r.hasValuesSchema})},kl=({onChange:e,total:t,offset:n=0,limit:s=t,singular:r="row",plural:o=r+"s"})=>{(n>t||n<0)&&(n=0,e(0));const a=ol((()=>e(n-s)),[e,n,s],n>0),i=ol((()=>e(n+s)),[e,n,s],n+s<t);return $(l.Fragment,null,t>s&&$(l.Fragment,null,$("button",{className:"previous",disabled:0==n,onClick:a},"←"),$("button",{className:"next",disabled:n+s>=t,onClick:i},"→"),n+1," to ",Math.min(t,n+s)," of "),t," ",1!=t?o:r)},Tl=({indexes:e,indexesId:l,indexId:n,s:s})=>$(Fe,{uniqueId:ge("i",l,n),summary:"Index: "+n,s:s},Q(t.useSliceIds(n,e),(t=>$(xl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s,key:t})))),xl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ge("i",l,t,n),[o,a]=fe(r,s);return $(Fe,{uniqueId:r,summary:"Slice: "+n,editable:o,handleEditable:a,s:s},$(fl,{sliceId:n,indexId:t,indexes:e,editable:o}))},Sl=({indexesId:e,s:l})=>{const n=t.useIndexes(e),s=t.useIndexIds(n);return O(n)?null:$(Fe,{uniqueId:ge("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},W(s)?"No indexes defined":ve(s,(t=>$(Tl,{indexes:n,indexesId:e,indexId:t,s:l,key:t}))))},Vl=({metrics:e,metricId:l})=>$("tr",null,$("th",null,l),$("td",null,null==e?void 0:e.getTableId(l)),$("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:$(Fe,{uniqueId:ge("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},W(s)?"No metrics defined":$("table",null,$("thead",null,$("th",null,"Metric Id"),$("th",null,"Table Id"),$("th",null,"Metric")),$("tbody",null,Q(s,(e=>$(Vl,{metrics:n,metricId:e,key:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const o=ge("q",l,n),[a,i,u]=oe(null!=(r=t.useCell(de,o,ce,s))?r:"[]"),d=t.useSetCellCallback(de,o,ce,re,[],s);return $(Fe,{uniqueId:o,summary:"Query: "+n,s:s},$(yl,{queryId:n,queries:e,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d}))},ql=({queriesId:e,s:l})=>{const n=t.useQueries(e),s=t.useQueryIds(n);return O(n)?null:$(Fe,{uniqueId:ge("q",e),summary:"Queries: "+(null!=e?e:d),s:l},W(s)?"No queries defined":ve(s,(t=>$(Ol,{queries:n,queriesId:e,queryId:t,s:l,key:t}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ge("r",l,t),[r,o]=fe(s,n);return $(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:o,s:n},$(Il,{relationshipId:t,relationships:e,editable:r}))},Nl=({relationshipsId:e,s:l})=>{const n=t.useRelationships(e),s=t.useRelationshipIds(n);return O(n)?null:$(Fe,{uniqueId:ge("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},W(s)?"No relationships defined":ve(s,(t=>$(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l,key:t}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const o=ge("t",n,e),[a,i,u]=oe(null!=(r=t.useCell(de,o,ce,s))?r:"[]"),d=t.useSetCellCallback(de,o,ce,re,[],s),[c,m]=fe(o,s);return $(Fe,{uniqueId:o,summary:h+": "+e,editable:c,handleEditable:m,s:s},$(gl,{tableId:e,store:l,cellId:a,descending:i,offset:u,limit:10,paginator:!0,sortOnClick:!0,onChange:d,editable:c}))},Ll=({store:e,storeId:l,s:n})=>{const s=ge("v",l),[r,o]=fe(s,n);return W(t.useValueIds(e))?null:$(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:o,s:n},$(vl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:$(Fe,{uniqueId:ge("s",e),summary:"Store: "+(null!=e?e:d),s:l},$(Ll,{storeId:e,store:n,s:l}),ve(s,(t=>$(El,{store:n,storeId:e,tableId:t,s:l,key:t}))))},jl=({s:e})=>{const l=J(null),n=J(0),[s,r]=D(!1),{scrollLeft:o,scrollTop:a}=t.useValues(e);F((()=>{const e=l.current;if(e&&!s){const l=new MutationObserver((()=>{e.scrollWidth>=S(o)+e.clientWidth&&e.scrollHeight>=S(a)+e.clientHeight&&e.scrollTo(o,a)}));return l.observe(e,{childList:!0,subtree:!0}),()=>l.disconnect()}}),[s,o,a]);const i=A((l=>{const{scrollLeft:t,scrollTop:s}=l[k];cancelIdleCallback(n.current),n.current=requestIdleCallback((()=>{r(!0),e.setPartialValues({scrollLeft:t,scrollTop:s})}))}),[e]),u=t.useStore(),d=t.useStoreIds(),c=t.useMetrics(),h=t.useMetricsIds(),m=t.useIndexes(),b=t.useIndexesIds(),p=t.useRelationships(),g=t.useRelationshipsIds(),v=t.useQueries(),f=t.useQueriesIds();return O(u)&&W(d)&&O(c)&&W(h)&&O(m)&&W(b)&&O(p)&&W(g)&&O(v)&&W(f)?$("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):$("article",{ref:l,onScroll:i},$(Ml,{s:e}),Q(d,(l=>$(Ml,{storeId:l,s:e,key:l}))),$(Rl,{s:e}),Q(h,(l=>$(Rl,{metricsId:l,s:e,key:l}))),$(Sl,{s:e}),Q(b,(l=>$(Sl,{indexesId:l,s:e,key:l}))),$(Nl,{s:e}),Q(g,(l=>$(Nl,{relationshipsId:l,s:e,key:l}))),$(ql,{s:e}),Q(f,(l=>$(ql,{queriesId:l,s:e,key:l}))))};class zl extends j{constructor(e){super(e),this.componentDidCatch=(e,l)=>console.error(e,l.componentStack),this.state={e:0}}render(){return this.state.e?$("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}zl.getDerivedStateFromError=()=>({e:1});const $l=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1,s=t.useSetValueCallback(be,(()=>!1),[],e),r=t.useSetValueCallback(me,(e=>Number(e[k].dataset.id)),[],e);return $("header",null,$("img",{title:ie}),$("span",null,ie),Q(ue,((e,l)=>l==n?null:$("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),$("img",{onClick:s,title:"Close"}))},Al=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?$("main",{"data-position":n},$($l,{s:e}),$(zl,null,$(jl,{s:e}))):null},Fl=e=>l=>{return t=(l,t)=>l+e(t),Ul(l).reduce(t,0);var t},Jl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Dl=Fl(Jl),Bl=Fl(Dl),Hl=Fl(Bl),Ql=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Wl=e=>O(e)||0==Jl(e),Ul=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Gl=e=>e.clear(),Kl=(e,l)=>null==e?void 0:e.forEach(l),Xl=(e,l)=>null==e?void 0:e.delete(l),Yl=e=>new Map(e),Zl=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},_l=(e,l)=>null==e?void 0:e.get(l),et=(e,l)=>Kl(e,((e,t)=>l(t,e))),lt=(e,l,t)=>O(t)?(Xl(e,l),e):null==e?void 0:e.set(l,t),tt=(e,l,t)=>(Ql(e,l)||lt(e,l,t()),_l(e,l)),nt=(e,l,t,n=lt)=>(ne(l,((l,n)=>t(e,n,l))),et(e,(t=>le(l,t)?0:n(e,t))),e),st=(e,l,t)=>{const n={};return Kl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},rt=(e,l,t)=>st(e,(e=>st(e,l,t)),se),ot=(e,l,t)=>st(e,(e=>rt(e,l,t)),se),at=(e,l)=>{const t=Yl();return Kl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},it=e=>at(e,at),ut=e=>at(e,it),dt=(e,l,t,n,s=0)=>q((t?tt:_l)(e,l[s],s>M(l)-2?t:Yl),(r=>{if(s>M(l)-2)return(null==n?void 0:n(r))&&lt(e,l[s]),r;const o=dt(r,l,t,n,s+1);return Wl(r)&&lt(e,l[s]),o}));var ct=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const ht=Yl(),mt=Yl();var bt=(e,l,t)=>new Promise(((n,s)=>{var r=e=>{try{a(t.next(e))}catch(e){s(e)}},o=e=>{try{a(t.throw(e))}catch(e){s(e)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,o);a((t=t.apply(e,l)).next())}));const pt="storage",gt=globalThis.window,vt=e=>new Set(E(e)||O(e)?e:[e]),ft=(e,l)=>null==e?void 0:e.add(l),It=/^\d+$/,yt=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{It.test(l)&&M(e)<1e3&&U(e,l)}]},wt=e=>[e,e],Ct=(e,l=Dl)=>l(e[0])+l(e[1]),kt=()=>[Yl(),Yl()],Tt=e=>[...e],xt=([e,l])=>e===l,St=(e,l,t)=>O(e)||!_(e)||se(e)||Y(e)?(null==t||t(),!1):(ne(e,((t,n)=>{l(t,n)||te(e,n)})),!se(e)),Vt=(e,l,t)=>lt(e,l,_l(e,l)==-t?void 0:t),Rt=()=>{let e,l,t=!1,n=!1,r=0;const o=Yl(),i=Yl(),c=Yl(),k=Yl(),T=Yl(),S=Yl(),V=Yl(),R=Yl(),E=Yl(),j=Yl(),z=Yl(),$=Yl(),A=Yl(),F=Yl(),J=vt(),D=Yl(),B=Yl(),W=Yl(),G=Yl(),K=kt(),X=kt(),Y=kt(),_=kt(),ee=kt(),ae=kt(),ie=kt(),ue=kt(),de=kt(),ce=kt(),he=kt(),me=kt(),be=kt(),pe=kt(),ge=kt(),ve=Yl(),fe=kt(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=yt(),r=Yl();return[(e,n,o,a=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return lt(r,u,[e,n,o,a,i]),ft(dt(n,null!=o?o:[s],vt),u),u},(e,t,...n)=>H(((e,l=[s])=>{const t=[],n=(e,s)=>s==M(l)?U(t,e):null===l[s]?Kl(e,(e=>n(e,s+1))):H([l[s],null],(l=>n(_l(e,l),s+1)));return n(e,0),t})(e,t),(e=>Kl(e,(e=>_l(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(_l(r,e),(([,l,t])=>(dt(l,null!=t?t:[s],void 0,(l=>(Xl(l,e),Wl(l)?1:0))),lt(r,e),n(e),t))),e=>q(_l(r,e),(([e,,t=[],n,s])=>{const r=(...o)=>{var a,i;const u=M(o);u==M(t)?e(l,...o,...s(o)):O(t[u])?H(null!=(i=null==(a=n[u])?void 0:a.call(n,...o))?i:[],(e=>r(...o,e))):r(...o,t[u])};r()}))]})(),ke=e=>{if(!St(e,((e,l)=>[u,d].includes(l))))return!1;const l=e[u];return!(!P(l)&&l!=a||(Je(e[d])!=l&&te(e,d),0))},Te=(l,t)=>(!e||Ql(z,t)||nl(t))&&St(l,((e,l)=>xe(t,l,e)),(()=>nl(t))),xe=(e,l,t,n)=>St(n?t:Oe(t,e,l),((n,s)=>q(Se(e,l,s,n),(e=>(t[s]=e,!0)),(()=>!1))),(()=>nl(e,l))),Se=(l,t,n,s)=>e?q(_l(_l(z,l),n),(e=>Je(s)!=e[u]?nl(l,t,n,s,e[d]):s),(()=>nl(l,t,n,s))):O(Je(s))?nl(l,t,n,s):s,Ve=(e,l)=>St(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(_l(A,e),(l=>Je(t)!=l[u]?sl(e,t,l[d]):t),(()=>sl(e,t))):O(Je(t))?sl(e,t):t,Oe=(e,l,t)=>(q(_l($,l),(([n,s])=>{Kl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Kl(F,((l,t)=>{le(e,t)||(e[t]=l)})),Kl(J,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>nt(z,e,((e,l,t)=>{const n=Yl(),s=vt();nt(tt(z,l,Yl),t,((e,l,t)=>{lt(e,l,t),q(t[d],(e=>lt(n,l,e)),(()=>ft(s,l)))})),lt($,l,[n,s])}),((e,l)=>{lt(z,l),lt($,l)})),Ne=e=>nt(A,e,((e,l,t)=>{lt(A,l,t),q(t[d],(e=>lt(F,l,e)),(()=>ft(J,l)))}),((e,l)=>{lt(A,l),lt(F,l),Xl(J,l)})),Ee=e=>se(e)?ql():xl(e),Le=e=>nt(W,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>nt(tt(W,e,(()=>(Ye(e,1),lt(D,e,yt()),lt(B,e,Yl()),Yl()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>nt(tt(l,t,(()=>(Ze(e,t,1),Yl()))),n,((l,n,s)=>ze(e,t,l,n,s)),((n,r)=>Ke(e,l,t,n,r,s))),ze=(e,l,t,n,s)=>{Ql(t,n)||_e(e,l,n,1);const r=_l(t,n);s!==r&&(el(e,l,n,r,s),lt(t,n,s))},$e=(e,l,t,n,s)=>q(_l(l,t),(l=>ze(e,t,l,n,s)),(()=>je(e,l,t,Oe({[n]:s},e,t)))),Ae=e=>se(e)?El():Sl(e),Fe=e=>nt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ql(G,e)||ll(e,1);const t=_l(G,e);l!==t&&(tl(e,t,l),lt(G,e,l))},Qe=(e,l)=>{const[t]=_l(D,e),n=t(l);return Ql(_l(W,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=_l(W,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=_l(D,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var o;const a=_l(null==(o=_l($,e))?void 0:o[0],s);if(!O(a)&&!r)return ze(e,t,n,s,a);const i=l=>{el(e,t,l,_l(n,l)),_e(e,t,l,-1),lt(n,l)};O(a)?i(s):et(n,i),Wl(n)&&(Ze(e,t,-1),Wl(lt(l,t))&&(Ye(e,-1),lt(W,e),lt(D,e),lt(B,e)))},Xe=e=>{const l=_l(F,e);if(!O(l))return He(e,l);tl(e,_l(G,e)),ll(e,-1),lt(G,e)},Ye=(e,l)=>Vt(o,e,l),Ze=(e,l,t)=>Vt(tt(k,e,Yl),l,t)&&lt(c,e,tt(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=_l(B,e),o=null!=(s=_l(r,t))?s:0;(0==o&&1==n||1==o&&-1==n)&&Vt(tt(i,e,Yl),t,n),lt(r,t,o!=-n?o+n:null),Vt(tt(tt(T,e,Yl),l,Yl),t,n)},el=(e,l,t,n,s)=>tt(tt(tt(S,e,Yl),l,Yl),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Vt(V,e,l),tl=(e,l,t)=>tt(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(tt(tt(tt(E,e,Yl),l,Yl),t,(()=>[])),n),s),sl=(e,l,t)=>(U(tt(j,e,(()=>[])),l),t),rl=(e,l,t)=>q(_l(_l(_l(S,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(wl(e,l,t))])),ol=e=>q(_l(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...wt(Tl(e))])),al=e=>Wl(E)||Wl(he[e])?0:Kl(e?ut(E):E,((l,t)=>Kl(l,((l,n)=>Kl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Wl(j)||Wl(me[e])?0:Kl(e?at(j):j,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Wl(l))return ye(e,t,(()=>st(l))),1},dl=e=>{const l=Wl(ie[e]),t=Wl(de[e])&&Wl(_[e])&&Wl(ee[e])&&Wl(ae[e])&&l&&Wl(X[e]),n=Wl(ce[e])&&Wl(ue[e])&&Wl(Y[e])&&Wl(K[e]);if(!t||!n){const s=e?[at(o),it(i),at(c),it(k),ut(T),ut(S)]:[o,i,c,k,T,S];if(!t){ul(X[e],s[0]),Kl(s[1],((l,t)=>ul(_[e],l,[t]))),Kl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],vl(t))}));const t=vt();Kl(s[3],((n,s)=>{ul(ae[e],n,[s])&&!l&&(ye(ie[e],[s,null]),ft(t,s))})),l||Kl(s[5],((l,n)=>{if(!Ql(t,n)){const t=vt();Kl(l,(e=>Kl(e,(([l,n],s)=>n!==l?ft(t,s):Xl(e,s))))),Kl(t,(l=>ye(ie[e],[n,l])))}})),Kl(s[4],((l,t)=>Kl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Kl(s[5],((t,n)=>{let s;Kl(t,((t,r)=>{let o;Kl(t,(([t,a],i)=>{a!==t&&(ye(ce[e],[n,r,i],a,t,rl),l=s=o=1)})),o&&ye(ue[e],[n,r],rl)})),s&&ye(Y[e],[n],rl)})),l&&ye(K[e],void 0,rl)}}},cl=e=>{const l=Wl(pe[e]),t=Wl(ge[e])&&Wl(be[e]);if(!l||!t){const n=e?[at(V),at(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Kl(n[1],(([t,n],s)=>{n!==t&&(ye(ge[e],[s],n,t,ol),l=1)})),l&&ye(be[e],void 0,ol)}}},hl=(e,...l)=>(jl((()=>e(...Q(l,x)))),Al),ml=()=>[st(S,((e,l)=>-1===_l(o,l)?null:st(e,((e,t)=>-1===_l(_l(k,l),t)?null:st(e,(([,e])=>null!=e?e:null),((e,l)=>xt(l)))),se)),se),st(R,(([,e])=>null!=e?e:null),((e,l)=>xt(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:ot(S,Tt,xt),invalidCells:ot(E),changedValues:st(R,Tt,xt),invalidValues:st(j),changedTableIds:st(o),changedRowIds:rt(k),changedCellIds:ot(T),changedValueIds:st(V)}),pl=()=>ot(W),gl=()=>Zl(W),vl=e=>Jl(_l(W,x(e))),fl=e=>Zl(_l(W,x(e))),Il=(e,l,t,n=0,s)=>{return Q(L((o=_l(W,x(e)),a=(e,t)=>[O(l)?t:_l(e,x(l)),t],r=([e],[l])=>{return((null!=(n=e)?n:0)<(null!=(s=l)?s:0)?-1:1)*(t?-1:1);var n,s},Q([...null!=(i=null==o?void 0:o.entries())?i:[]],(([e,l])=>a(l,e))).sort(r)),n,O(s)?s:n+s),(([,e])=>e));var r,o,a,i},yl=(e,l)=>Zl(_l(_l(W,x(e)),x(l))),wl=(e,l,t)=>_l(_l(_l(W,x(e)),x(l)),x(t)),Cl=()=>st(G),kl=()=>Zl(G),Tl=e=>_l(G,x(e)),xl=e=>hl((()=>(e=>St(e,Te,nl))(e)?Le(e):0)),Sl=e=>hl((()=>Ve(e)?Fe(e):0)),Vl=e=>{try{Ee(oe(e))}catch(e){}return Al},Rl=l=>hl((()=>{if((e=St(l,(e=>St(e,ke))))&&(Pe(l),!Wl(W))){const e=pl();ql(),xl(e)}})),Ol=e=>hl((()=>{if(l=(e=>St(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Sl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ql(W,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(_l(W,e),(t=>Ql(t,l)?Ge(e,t,l):0))),e,l),El=()=>hl((()=>Fe({}))),Ll=()=>hl((()=>{Pe({}),e=!1})),Ml=()=>hl((()=>{Ne({}),l=!1})),jl=(e,l)=>{if(-1!=r){zl();const t=e();return $l(l),t}},zl=()=>(-1!=r&&r++,1==r&&ye(ve,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Wl(S),n=!Wl(R),r=1,al(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Kl(S,((e,l)=>Kl(e,((e,t)=>Kl(e,(([e],n)=>De(Al,l,t,n,e))))))),Kl(R,(([e],l)=>Be(Al,l,e))),t=n=!1),ye(fe[0],void 0,ml,bl),r=-1,al(0),t&&dl(0),il(0),n&&cl(0),ye(fe[1],void 0,ml,bl),r=0,t=n=!1,H([o,i,c,k,T,S,E,V,R,j],Gl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:gl,getTable:e=>rt(_l(W,x(e))),getTableCellIds:e=>Zl(_l(B,x(e))),getRowCount:vl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>st(_l(_l(W,x(e)),x(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:Tl,hasTables:()=>!Wl(W),hasTable:e=>Ql(W,x(e)),hasTableCell:(e,l)=>Ql(_l(B,x(e)),x(l)),hasRow:(e,l)=>Ql(_l(W,x(e)),x(l)),hasCell:(e,l,t)=>Ql(_l(_l(W,x(e)),x(l)),x(t)),hasValues:()=>!Wl(G),hasValue:e=>Ql(G,x(e)),getTablesJson:()=>re(W),getValuesJson:()=>re(G),getJson:()=>re([W,G]),getTablesSchemaJson:()=>re(z),getValuesSchemaJson:()=>re(A),getSchemaJson:()=>re([z,A]),hasTablesSchema:()=>e,hasValuesSchema:()=>l,setContent:([e,l])=>hl((()=>{(se(e)?ql:xl)(e),(se(l)?El:Sl)(l)})),setTables:xl,setTable:(e,l)=>hl((e=>Te(l,e)?Me(e,l):0),e),setRow:(e,l,t)=>hl(((e,l)=>xe(e,l,t)?je(e,We(e),l,t):0),e,l),addRow:(e,l,t=!0)=>jl((()=>{let n;return xe(e,n,l)&&(e=x(e),je(e,We(e),n=Qe(e,t?1:0),l)),n})),setPartialRow:(e,l,t)=>hl(((e,l)=>{if(xe(e,l,t,1)){const n=We(e);ne(t,((t,s)=>$e(e,n,l,s,t)))}}),e,l),setCell:(e,l,t,n)=>hl(((e,l,t)=>q(Se(e,l,t,N(n)?n(wl(e,l,t)):n),(n=>$e(e,We(e),l,t,n)))),e,l,t),setValues:Sl,setPartialValues:e=>hl((()=>Ve(e,1)?ne(e,((e,l)=>He(l,e))):0)),setValue:(e,l)=>hl((e=>q(Re(e,N(l)?l(Tl(e)):l),(l=>He(e,l)))),e),setTransactionChanges:e=>hl((()=>{ne(e[0],((e,l)=>O(e)?Pl(l):ne(e,((e,t)=>O(e)?Nl(l,t):ne(e,((e,n)=>De(Al,l,t,n,e))))))),ne(e[1],((e,l)=>Be(Al,l,e)))})),setTablesJson:Vl,setValuesJson:e=>{try{Ae(oe(e))}catch(e){}return Al},setJson:e=>hl((()=>{try{const[l,t]=oe(e);Ee(l),Ae(t)}catch(l){Vl(e)}})),setTablesSchema:Rl,setValuesSchema:Ol,setSchema:(e,l)=>hl((()=>{Rl(e),Ol(l)})),delTables:ql,delTable:Pl,delRow:Nl,delCell:(e,l,t,n)=>hl(((e,l,t)=>q(_l(W,e),(s=>q(_l(s,l),(r=>Ql(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ql(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Kl(W,((l,t)=>e(t,(e=>Kl(l,((l,t)=>e(t,(e=>et(l,e))))))))),forEachTableCell:(e,l)=>et(_l(B,x(e)),l),forEachRow:(e,l)=>Kl(_l(W,x(e)),((e,t)=>l(t,(l=>et(e,l))))),forEachCell:(e,l,t)=>et(_l(_l(W,x(e)),x(l)),t),forEachValue:e=>et(G,e),addSortedRowIdsListener:(e,l,t,n,s,r,o)=>{let a=Il(e,l,t,n,s);return Ie((()=>{const o=Il(e,l,t,n,s);var i,u,d;u=a,M(i=o)===M(u)&&(d=(e,l)=>u[l]===e,i.every(d))||(a=o,r(Al,e,l,t,n,s,a))}),ie[o?1:0],[e,l],[gl])},addStartTransactionListener:e=>Ie(e,ve),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:Ct(K),tableIds:Ct(X),tableCellIds:Ct(_),table:Ct(Y),rowCount:Ct(ee),rowIds:Ct(ae),sortedRowIds:Ct(ie),row:Ct(ue,Bl),cellIds:Ct(de,Bl),cell:Ct(ce,Hl),invalidCell:Ct(he,Hl),values:Ct(be),valueIds:Ct(pe),value:Ct(ge),invalidValue:Ct(me),transaction:Dl(ve)+Ct(fe)}),createStore:Rt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[gl]],[h+I]:[1,_,[gl]],[g]:[1,ee,[gl]],[v]:[1,ae,[gl]],[p]:[2,ue,[gl,fl]],[I]:[2,de,[gl,fl]],[f]:[3,ce,[gl,fl,yl],e=>wt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ge,[kl],e=>wt(Tl(e[0]))],InvalidValue:[1,me]},(([e,l,t,n],s)=>{Al["add"+s+"Listener"]=(...s)=>Ie(s[e],l[s[e+1]?1:0],e>0?L(s,0,e):void 0,t,n)})),Z(Al)},Ot=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(Rt),s=ue.indexOf(e);return t.useCreatePersister(n,(e=>{return((e,l,t,n)=>((e,l,t,n,s,r,o=[])=>{let a,i,u,d=0,c=0,h=0,m=0;tt(ht,o,(()=>0)),tt(mt,o,(()=>[]));const b=e=>ct(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>ct(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>ct(void 0,null,(function*(){return yield b((()=>ct(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>ct(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>ct(void 0,null,(function*(){if(n){const l=n();yield b((()=>ct(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>ct(void 0,null,(function*(){var n;try{e.setContent(null!=(n=null==t?void 0:t())?n:yield l())}catch(e){null==r||r(e)}}))))})))),p})),stopAutoLoad:()=>(m&&(s(u),u=void 0,m=0),p),save:l=>ct(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>ct(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>ct(void 0,null,(function*(){return yield p.stopAutoSave().save(),a=e.addDidFinishTransactionListener(((e,l)=>{const[t,n]=l();se(t)&&se(n)||p.save((()=>[t,n]))})),p})),stopAutoSave:()=>(q(a,e.delListener),p),schedule:(...e)=>ct(void 0,null,(function*(){return U(_l(mt,o),...e),yield ct(void 0,null,(function*(){if(!_l(ht,o)){for(lt(ht,o,1);!O(i=G(_l(mt,o)));)try{yield i()}catch(e){null==r||r(e)}lt(ht,o,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>bt(void 0,null,(function*(){return oe(t.getItem(l))}))),(e=>bt(void 0,null,(function*(){return t.setItem(l,re(e()))}))),(e=>{const n=n=>{n.storageArea===t&&n.key===l&&e((()=>oe(n.newValue)))};return gt.addEventListener(pt,n),n}),(e=>gt.removeEventListener(pt,e)),n))(e,ae,sessionStorage,l);var l}),void 0,(e=>{return t=function*(){yield e.load(void 0,{position:-1==s?1:s,open:!!l}),yield e.startAutoSave()},new Promise(((e,l)=>{var n=e=>{try{r(t.next(e))}catch(e){l(e)}},s=e=>{try{r(t.throw(e))}catch(e){l(e)}},r=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,s);r((t=t.apply(void 0,null)).next())}));var t})),$(z,null,$("aside",{id:ae},$(Ae,{s:n}),$(Al,{s:n})),$("style",null,$e))};var qt=Object.defineProperty,Pt=Object.getOwnPropertySymbols,Nt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable,Lt=(e,l,t)=>l in e?qt(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;e.EditableCellView=wl,e.EditableValueView=Cl,e.RelationshipInHtmlTable=Il,e.ResultSortedTableInHtmlTable=yl,e.ResultTableInHtmlTable=e=>{var l=e,{queryId:n,queries:s,customCells:r}=l,o=el(l,["queryId","queries","customCells"]);return $(hl,_e(Ze({},o),{params:al(cl(t.useResultTableCellIds(n,s),r,t.ResultCellView),ul(s,n),t.useResultRowIds(n,s))}))},e.SliceInHtmlTable=fl,e.SortedTableInHtmlTable=gl,e.SortedTablePaginator=kl,e.StoreInspector=e=>$(Ot,((e,l)=>{for(var t in l||(l={}))Nt.call(l,t)&&Lt(e,t,l[t]);if(Pt)for(var t of Pt(l))Et.call(l,t)&&Lt(e,t,l[t]);return e})({},e)),e.TableInHtmlTable=e=>{var l=e,{tableId:n,store:s,editable:r,customCells:o}=l,a=el(l,["tableId","store","editable","customCells"]);return $(hl,_e(Ze({},a),{params:al(cl(t.useTableCellIds(n,s),o,r?wl:t.CellView),il(s,n),t.useRowIds(n,s))}))},e.ValuesInHtmlTable=vl},"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDomDebug={},e.React,e.TinyBaseUiReact);
@@ -1 +1 @@
1
- var e,t;e=this,t=function(e,t,l){"use strict";const r=e=>typeof e,a=r(""),n=r(!0),o=r(0),s="Value",i="currentTarget",d="value",u=isFinite,c=e=>null==e,{PureComponent:m,Fragment:h,createElement:b,useCallback:p,useLayoutEffect:g,useRef:f,useState:w}=t,v=(e,...t)=>c(e)?{}:e(...t),I=(e,t)=>e.map(t),y=Object,C=(e=[])=>y.fromEntries(e),k=(e,t)=>I(y.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',T=R+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",O='</svg>")',S=R+"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\")",N=I([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+O)),V=T+"<path d='M20 20l60 60M20 80l60-60' />"+O,j=T+`<path d='${x}' />`+O,P=T+`<path d='${x}M20 20l60 60' />`+O;var z=Object.defineProperty,q=Object.defineProperties,M=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,l)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,H=(e,t)=>{for(var l in t||(t={}))B.call(t,l)&&F(e,l,t[l]);if($)for(var l of $(t))E.call(t,l)&&F(e,l,t[l]);return e},D=(e,t)=>q(e,M(t));const A="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k(D(H(D(H(D(H({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[A]:"width:0.5rem;height:0.5rem;",[A+"-track"]:"background:#111",[A+"-thumb"]:"background:#999;border:1px solid #111",[A+"-thumb:hover"]:"background:#fff",[A+"-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;"+S},C(I(["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;"}),C(I(["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)":S,"header>img:nth-of-type(6)":V}),C(I(N,((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":j,"details[open]>summary img.done":P,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,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?`& ${t}{${e}}`:"")));const L=(e,t,l,r)=>e==a?t:e==o?l:r;var U=Object.defineProperty,G=Object.defineProperties,J=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,X=(e,t,l)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Y=(e,t)=>{for(var l in t||(t={}))Q.call(t,l)&&X(e,l,t[l]);if(K)for(var l of K(t))W.call(t,l)&&X(e,l,t[l]);return e},Z=(e,t)=>G(e,J(t)),_=(e,t)=>{var l={};for(var r in e)Q.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&K)for(var r of K(e))t.indexOf(r)<0&&W.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:ee,useMemo:te,useState:le}=t,re="editable",ae=(e,t)=>I(l.useTableCellIds(e,t),(t=>e+"."+t)),ne=(e,t,l)=>{const r=ee(e,t);return l?r:void 0},oe=(...e)=>te((()=>e),e),se=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),ie=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,r=0,a,n,o,s)=>{const[[i,d,u],c]=le([e,t,r]),m=ee((e=>{c(e),null==s||s(e)}),[s]),h=ne((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=ee((e=>m([i,d,e])),[m,i,d]),g=!0===o?fe:o;return[[i,d,u],h,te((()=>!1===o?null:b(g,{offset:u,limit:a,total:n,onChange:p})),[o,g,u,a,n,p])]},ue=(e,t,l)=>te((()=>{const n=null!=t?t:e;return C(k(Array.isArray(n)?C(I(n,(e=>[e,e]))):n,((e,t)=>{return[t,Y(Y({},{label:t,component:l}),(n=e,r(n)==a?{label:e}:e))];var n})))}),[t,l,e]),ce=({className:e,headerRow:t,idColumn:l,params:[r,a,n,o,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(me,{sort:null!=o?o:[],label:"Id",onClick:s}),k(r,(({label:e},t)=>b(me,{key:t,cellId:t,label:e,sort:null!=o?o:[],onClick:s}))))),b("tbody",null,I(n,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),k(r,(({component:t,getComponentProps:l},r)=>b("td",{key:r},b(t,Z(Y(Y({},v(l,e,r)),a),{rowId:e,cellId:r})))))))))),me=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:a})=>b("th",{onClick:ne((()=>null==a?void 0:a(e)),[a,e],a),className:c(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},c(l)||t!=e?null:(l?"↓":"↑")+" ",r),he=({localRowId:e,params:[r,a,n,o,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===r?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),k(a,(({component:t,getComponentProps:l},r)=>{const[a,s]=r.split(".",2),i=a===n?e:a===o?u:null;return c(i)?null:b("td",{key:r},b(t,Z(Y({},v(l,i,s)),{store:d,tableId:a,rowId:i,cellId:s})))})))},be=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[c,m]=le(),[h,p]=le(),[g,f]=le(),[w,v]=le(),[I,y]=le();h!==e&&(m((e=>{const t=r(e);return(e=>e==a||e==n)(t)||t==o&&u(e)?t:void 0})(e)),p(e),f(e+""),v(Number(e)||0),y(!!e));const C=ee(((e,l)=>{l(e),p(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:c,onClick:ee((()=>{if(!(null==s?void 0:s())){const e=L(c,o,n,a),l=L(e,g,w,I);m(e),p(l),t(l)}}),[s,t,g,w,I,c])},c),L(c,b("input",{key:c,value:g,onChange:ee((e=>C(e[i][d]+"",f)),[C])}),b("input",{key:c,type:"number",value:w,onChange:ee((e=>C(Number(e[i][d]||0),v)),[C])}),b("input",{key:c,type:"checkbox",checked:I,onChange:ee((e=>C(!!e[i].checked,y)),[C])})))},pe=({tableId:e,rowId:t,cellId:r,store:a,className:n})=>{var o;return b(be,{thing:l.useCell(e,t,r,a),onThingChange:l.useSetCellCallback(e,t,r,(e=>e),[],a),className:null!=n?n:re+"Cell",hasSchema:null==(o=l.useStoreOrStoreById(a))?void 0:o.hasTablesSchema})},ge=({valueId:e,store:t,className:r})=>{var a;return b(be,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=r?r:re+s,hasSchema:null==(a=l.useStoreOrStoreById(t))?void 0:a.hasValuesSchema})},fe=({onChange:e,total:l,offset:r=0,limit:a=l,singular:n="row",plural:o=n+"s"})=>{(r>l||r<0)&&(r=0,e(0));const s=ne((()=>e(r-a)),[e,r,a],r>0),i=ne((()=>e(r+a)),[e,r,a],r+a<l);return b(t.Fragment,null,l>a&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==r,onClick:s},"←"),b("button",{className:"next",disabled:r+a>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+a)," of "),l," ",1!=l?o:n)};(class extends m{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}).getDerivedStateFromError=()=>({e:1});const we=e=>new Map(e);we(),we(),e.EditableCellView=pe,e.EditableValueView=ge,e.RelationshipInHtmlTable=({relationshipId:e,relationships:r,editable:a,customCells:n,className:o,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(r),e),h=ue([...ae(c,u),...ae(m,u)],n,a?pe:l.CellView),p=oe(i,h,c,m,e,d,u);return b("table",{className:o},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,c,".Id"),b("th",null,m,".Id")),k(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,I(l.useRowIds(c,u),(e=>b(he,{key:e,localRowId:e,params:p})))))},e.ResultSortedTableInHtmlTable=e=>{var t=e,{queryId:r,cellId:a,descending:n,offset:o,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=t,h=_(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=de(a,n,d,o,s,l.useResultRowCount(r,i),u,m);return b(ce,Z(Y({},h),{params:oe(ue(l.useResultTableCellIds(r,i),c,l.ResultCellView),ie(i,r),l.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},e.ResultTableInHtmlTable=e=>{var t=e,{queryId:r,queries:a,customCells:n}=t,o=_(t,["queryId","queries","customCells"]);return b(ce,Z(Y({},o),{params:oe(ue(l.useResultTableCellIds(r,a),n,l.ResultCellView),ie(a,r),l.useResultRowIds(r,a))}))},e.SliceInHtmlTable=e=>{var t=e,{indexId:r,sliceId:a,indexes:n,editable:o,customCells:s}=t,i=_(t,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(l.useIndexesOrIndexesById(n),r);return b(ce,Z(Y({},i),{params:oe(ue(l.useTableCellIds(c,u),s,o?pe:l.CellView),se(u,c),l.useSliceRowIds(r,a,d))}))},e.SortedTableInHtmlTable=e=>{var t=e,{tableId:r,cellId:a,descending:n,offset:o,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:h}=t,p=_(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=de(a,n,u,o,s,l.useRowCount(r,i),c,m);return b(ce,Z(Y({},p),{params:oe(ue(l.useTableCellIds(r,i),h,d?pe:l.CellView),se(i,r),l.useSortedRowIds(r,...g,s,i),g,f,w)}))},e.SortedTablePaginator=fe,e.StoreInspector=e=>null,e.TableInHtmlTable=e=>{var t=e,{tableId:r,store:a,editable:n,customCells:o}=t,s=_(t,["tableId","store","editable","customCells"]);return b(ce,Z(Y({},s),{params:oe(ue(l.useTableCellIds(r,a),o,n?pe:l.CellView),se(a,r),l.useRowIds(r,a))}))},e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:r=(t?ge:l.ValueView),getValueComponentProps:a,className:n,headerRow:o,idColumn:i})=>b("table",{className:n},!1===o?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,I(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(r,Z(Y({},v(a,t)),{valueId:t,store:e}))))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
1
+ var e,t;e=this,t=function(e,t,l){"use strict";const r=e=>typeof e,o=r(""),a=r(!0),n=r(0),s="Value",i="currentTarget",d="value",u=isFinite,c=e=>null==e,{PureComponent:m,Fragment:h,createElement:b,useCallback:p,useLayoutEffect:g,useRef:f,useState:w}=t,y=(e,...t)=>c(e)?{}:e(...t),v=(e,t)=>e.map(t),I=Object,C=(e=[])=>I.fromEntries(e),k=(e,t)=>v(I.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',R=T+"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' stroke-width='4' stroke='white' fill='none'>",O='</svg>")',S=T+"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\")",N=v([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>R+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+O)),V=R+"<path d='M20 20l60 60M20 80l60-60' />"+O,j=R+`<path d='${x}' />`+O,P=R+`<path d='${x}M20 20l60 60' />`+O;var z=Object.defineProperty,q=Object.defineProperties,M=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,F=(e,t,l)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,H=(e,t)=>{for(var l in t||(t={}))B.call(t,l)&&F(e,l,t[l]);if($)for(var l of $(t))E.call(t,l)&&F(e,l,t[l]);return e},D=(e,t)=>q(e,M(t));const A="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k(D(H(D(H(D(H({"*":"all:revert","*::before":"all:revert","*::after":"all:revert",[A]:"width:0.5rem;height:0.5rem;",[A+"-track"]:"background:#111",[A+"-thumb"]:"background:#999;border:1px solid #111",[A+"-thumb:hover"]:"background:#fff",[A+"-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;"+S},C(v(["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;"}),C(v(["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)":S,"header>img:nth-of-type(6)":V}),C(v(N,((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":j,"details[open]>summary img.done":P,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,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?`& ${t}{${e}}`:"")));const L=(e,t,l,r)=>e==o?t:e==n?l:r;var U=Object.defineProperty,G=Object.defineProperties,J=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,X=(e,t,l)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Y=(e,t)=>{for(var l in t||(t={}))Q.call(t,l)&&X(e,l,t[l]);if(K)for(var l of K(t))W.call(t,l)&&X(e,l,t[l]);return e},Z=(e,t)=>G(e,J(t)),_=(e,t)=>{var l={};for(var r in e)Q.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&K)for(var r of K(e))t.indexOf(r)<0&&W.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:ee,useMemo:te,useState:le}=t,re="editable",oe=(e,t)=>v(l.useTableCellIds(e,t),(t=>e+"."+t)),ae=(e,t,l)=>{const r=ee(e,t);return l?r:void 0},ne=(...e)=>te((()=>e),e),se=(e,t)=>te((()=>({store:e,tableId:t})),[e,t]),ie=(e,t)=>te((()=>({queries:e,queryId:t})),[e,t]),de=(e,t=!1,l,r=0,o,a,n,s)=>{const[[i,d,u],c]=le([e,t,r]),m=ee((e=>{c(e),null==s||s(e)}),[s]),h=ae((e=>m([e,e==i&&!d,u])),[m,i,d,u],l),p=ee((e=>m([i,d,e])),[m,i,d]),g=!0===n?fe:n;return[[i,d,u],h,te((()=>!1===n?null:b(g,{offset:u,limit:o,total:a,onChange:p})),[n,g,u,o,a,p])]},ue=(e,t,l)=>te((()=>{const a=null!=t?t:e;return C(k(Array.isArray(a)?C(v(a,(e=>[e,e]))):a,((e,t)=>{return[t,Y(Y({},{label:t,component:l}),(a=e,r(a)==o?{label:e}:e))];var a})))}),[t,l,e]),ce=({className:e,headerRow:t,idColumn:l,params:[r,o,a,n,s,i]})=>b("table",{className:e},i?b("caption",null,i):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(me,{sort:null!=n?n:[],label:"Id",onClick:s}),k(r,(({label:e},t)=>b(me,{key:t,cellId:t,label:e,sort:null!=n?n:[],onClick:s}))))),b("tbody",null,v(a,(e=>b("tr",{key:e},!1===l?null:b("th",null,e),k(r,(({component:t,getComponentProps:l},r)=>b("td",{key:r},b(t,Z(Y(Y({},y(l,e,r)),o),{rowId:e,cellId:r})))))))))),me=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:o})=>b("th",{onClick:ae((()=>null==o?void 0:o(e)),[o,e],o),className:c(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},c(l)||t!=e?null:(l?"↓":"↑")+" ",r),he=({localRowId:e,params:[r,o,a,n,s,i,d]})=>{const u=l.useRemoteRowId(s,e,i);return b("tr",null,!1===r?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),k(o,(({component:t,getComponentProps:l},r)=>{const[o,s]=r.split(".",2),i=o===a?e:o===n?u:null;return c(i)?null:b("td",{key:r},b(t,Z(Y({},y(l,i,s)),{store:d,tableId:o,rowId:i,cellId:s})))})))},be=({thing:e,onThingChange:t,className:l,hasSchema:s,showType:c=!0})=>{const[m,h]=le(),[p,g]=le(),[f,w]=le(),[y,v]=le(),[I,C]=le();p!==e&&(h((e=>{const t=r(e);return(e=>e==o||e==a)(t)||t==n&&u(e)?t:void 0})(e)),g(e),w(e+""),v(Number(e)||0),C(!!e));const k=ee(((e,l)=>{l(e),g(e),t(e)}),[t]),x=ee((()=>{if(!(null==s?void 0:s())){const e=L(m,n,a,o),l=L(e,f,y,I);h(e),g(l),t(l)}}),[s,t,f,y,I,m]);return b("div",{className:l},c?b("button",{className:m,onClick:x},m):null,L(m,b("input",{key:m,value:f,onChange:ee((e=>k(e[i][d]+"",w)),[k])}),b("input",{key:m,type:"number",value:y,onChange:ee((e=>k(Number(e[i][d]||0),v)),[k])}),b("input",{key:m,type:"checkbox",checked:I,onChange:ee((e=>k(!!e[i].checked,C)),[k])})))},pe=({tableId:e,rowId:t,cellId:r,store:o,className:a,showType:n})=>{var s;return b(be,{thing:l.useCell(e,t,r,o),onThingChange:l.useSetCellCallback(e,t,r,(e=>e),[],o),className:null!=a?a:re+"Cell",showType:n,hasSchema:null==(s=l.useStoreOrStoreById(o))?void 0:s.hasTablesSchema})},ge=({valueId:e,store:t,className:r,showType:o})=>{var a;return b(be,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=r?r:re+s,showType:o,hasSchema:null==(a=l.useStoreOrStoreById(t))?void 0:a.hasValuesSchema})},fe=({onChange:e,total:l,offset:r=0,limit:o=l,singular:a="row",plural:n=a+"s"})=>{(r>l||r<0)&&(r=0,e(0));const s=ae((()=>e(r-o)),[e,r,o],r>0),i=ae((()=>e(r+o)),[e,r,o],r+o<l);return b(t.Fragment,null,l>o&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==r,onClick:s},"←"),b("button",{className:"next",disabled:r+o>=l,onClick:i},"→"),r+1," to ",Math.min(l,r+o)," of "),l," ",1!=l?n:a)};(class extends m{constructor(e){super(e),this.componentDidCatch=(e,t)=>console.error(e,t.componentStack),this.state={e:0}}render(){return this.state.e?b("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}).getDerivedStateFromError=()=>({e:1});const we=e=>new Map(e);we(),we(),e.EditableCellView=pe,e.EditableValueView=ge,e.RelationshipInHtmlTable=({relationshipId:e,relationships:r,editable:o,customCells:a,className:n,headerRow:s,idColumn:i=!0})=>{const[d,u,c,m]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getLocalTableId(t),null==e?void 0:e.getRemoteTableId(t)])(l.useRelationshipsOrRelationshipsById(r),e),h=ue([...oe(c,u),...oe(m,u)],a,o?pe:l.CellView),p=ne(i,h,c,m,e,d,u);return b("table",{className:n},!1===s?null:b("thead",null,b("tr",null,!1===i?null:b(t.Fragment,null,b("th",null,c,".Id"),b("th",null,m,".Id")),k(h,(({label:e},t)=>b("th",{key:t},e))))),b("tbody",null,v(l.useRowIds(c,u),(e=>b(he,{key:e,localRowId:e,params:p})))))},e.ResultSortedTableInHtmlTable=e=>{var t=e,{queryId:r,cellId:o,descending:a,offset:n,limit:s,queries:i,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=t,h=_(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=de(o,a,d,n,s,l.useResultRowCount(r,i),u,m);return b(ce,Z(Y({},h),{params:ne(ue(l.useResultTableCellIds(r,i),c,l.ResultCellView),ie(i,r),l.useResultSortedRowIds(r,...p,s,i),p,g,f)}))},e.ResultTableInHtmlTable=e=>{var t=e,{queryId:r,queries:o,customCells:a}=t,n=_(t,["queryId","queries","customCells"]);return b(ce,Z(Y({},n),{params:ne(ue(l.useResultTableCellIds(r,o),a,l.ResultCellView),ie(o,r),l.useResultRowIds(r,o))}))},e.SliceInHtmlTable=e=>{var t=e,{indexId:r,sliceId:o,indexes:a,editable:n,customCells:s}=t,i=_(t,["indexId","sliceId","indexes","editable","customCells"]);const[d,u,c]=((e,t)=>[e,null==e?void 0:e.getStore(),null==e?void 0:e.getTableId(t)])(l.useIndexesOrIndexesById(a),r);return b(ce,Z(Y({},i),{params:ne(ue(l.useTableCellIds(c,u),s,n?pe:l.CellView),se(u,c),l.useSliceRowIds(r,o,d))}))},e.SortedTableInHtmlTable=e=>{var t=e,{tableId:r,cellId:o,descending:a,offset:n,limit:s,store:i,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:h}=t,p=_(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=de(o,a,u,n,s,l.useRowCount(r,i),c,m);return b(ce,Z(Y({},p),{params:ne(ue(l.useTableCellIds(r,i),h,d?pe:l.CellView),se(i,r),l.useSortedRowIds(r,...g,s,i),g,f,w)}))},e.SortedTablePaginator=fe,e.StoreInspector=e=>null,e.TableInHtmlTable=e=>{var t=e,{tableId:r,store:o,editable:a,customCells:n}=t,s=_(t,["tableId","store","editable","customCells"]);return b(ce,Z(Y({},s),{params:ne(ue(l.useTableCellIds(r,o),n,a?pe:l.CellView),se(o,r),l.useRowIds(r,o))}))},e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:r=(t?ge:l.ValueView),getValueComponentProps:o,className:a,headerRow:n,idColumn:i})=>b("table",{className:a},!1===n?null:b("thead",null,b("tr",null,!1===i?null:b("th",null,"Id"),b("th",null,s))),b("tbody",null,v(l.useValueIds(e),(t=>b("tr",{key:t},!1===i?null:b("th",null,t),b("td",null,b(r,Z(Y({},y(o,t)),{valueId:t,store:e}))))))))},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("./ui-react")):"function"==typeof define&&define.amd?define(["exports","react","./ui-react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseUiReactDom={},e.React,e.TinyBaseUiReact);
Binary file