tinybase 4.1.1 → 4.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,T="currentTarget",k="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),{PureComponent:z,Fragment:$,createElement:O,useCallback:A,useLayoutEffect:F,useRef:J,useState:P}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),D=(e,t)=>e.map(t),Q=e=>e.length,j=e=>0==Q(e),W=(e,t,s)=>e.slice(t,s),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)=>D(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>Q(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)=>D(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),A((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>")',Te=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\")",ke=D([[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=((e,t="")=>e.join(t))(le({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"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;"+Te,...ee(D(["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(D(["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)":Te,"header>img:nth-of-type(6)":Se,...ee(D(ke,((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,#${oe} 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?`#${oe} ${t}{${e}}`:""))),Ne=({s:e})=>{const t=s.useValue(me,e)??1,l=s.useSetValueCallback(be,(()=>!0),[],e);return s.useValue(be,e)?null:O("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[T].open),[],r);return O("details",{open:o,onToggle:i},O("summary",null,t,a?O("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)=>D(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:O(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(D(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]})=>O("table",{className:e},i?O("caption",null,i):null,!1===t?null:O("thead",null,O("tr",null,!1===s?null:O(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>O(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),O("tbody",null,D(n,(e=>O("tr",{key:e},!1===s?null:O("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>O("td",{key:l},O(t,{...B(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>O("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 O("tr",null,!1===l?null:O(t.Fragment,null,O("th",null,e),O("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:O("td",{key:l},O(t,{...B(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 O("div",{className:s},O("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,O("input",{key:a,value:c,onChange:Oe((e=>p(e[T][k]+"",h)),[p])}),O("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[T][k]||0),b)),[p])}),O("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[T].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 O(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})=>O("table",{className:n},!1===r?null:O("thead",null,O("tr",null,!1===o?null:O("th",null,"Id"),O("th",null,y))),O("tbody",null,D(s.useValueIds(e),(t=>O("tr",{key:t},!1===o?null:O("th",null,t),O("td",null,O(l,{...B(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 O(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 O("table",{className:r},!1===o?null:O("thead",null,O("tr",null,!1===i?null:O(t.Fragment,null,O("th",null,c,".Id"),O("th",null,h,".Id")),le(m,(({label:e},t)=>O("th",{key:t},e))))),O("tbody",null,D(s.useRowIds(c,u),(e=>O(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 O(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})=>O(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})=>O(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 O(t.Fragment,null,s>a&&O(t.Fragment,null,O("button",{className:"previous",disabled:0==l,onClick:o},"←"),O("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})=>O(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},D(s.useSliceIds(l,e),(s=>O(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return O(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},O(_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:O(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},j(a)?"No indexes defined":pe(a,(s=>O(nt,{indexes:l,indexesId:e,indexId:s,s:t}))))},it=({metrics:e,metricId:t})=>O("tr",null,O("th",null,t),O("td",null,e?.getTableId(t)),O("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:O(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},j(a)?"No metrics defined":O("table",null,O("thead",null,O("th",null,"Metric Id"),O("th",null,"Table Id"),O("th",null,"Metric")),O("tbody",null,D(a,(e=>O(it,{metrics:l,metricId: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 O(Le,{uniqueId:n,summary:"Query: "+l,s:a},O(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:O(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},j(a)?"No queries defined":pe(a,(s=>O(ut,{queries:l,queriesId:e,queryId:s,s:t}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return O(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},O(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:O(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},j(a)?"No relationships defined":pe(a,(s=>O(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t}))))},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 O(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},O(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 j(s.useValueIds(e))?null:O(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},O(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:O(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},O(gt,{storeId:e,store:l,s:t}),pe(a,(s=>O(bt,{store:l,storeId:e,tableId:s,s:t}))))},pt=({s:e})=>{const t=J(null),l=J(0),[a,n]=P(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);F((()=>{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=A((t=>{const{scrollLeft:s,scrollTop:a}=t[T];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)&&j(u)&&q(c)&&j(h)&&q(m)&&j(b)&&q(g)&&j(I)&&q(p)&&j(f)?O("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):O("article",{ref:t,onScroll:i},O(It,{s:e}),D(u,(t=>O(It,{storeId:t,key:t,s:e}))),O(dt,{s:e}),D(h,(t=>O(dt,{metricsId:t,key:t,s:e}))),O(ot,{s:e}),D(b,(t=>O(ot,{indexesId:t,key:t,s:e}))),O(mt,{s:e}),D(I,(t=>O(mt,{relationshipsId:t,key:t,s:e}))),O(ct,{s:e}),D(f,(t=>O(ct,{queriesId:t,key:t,s:e}))))};class ft extends z{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?O("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[T].dataset.id)),[],e);return O("header",null,O("img",{title:ie}),O("span",null,ie),D(de,((e,s)=>s==t?null:O("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),O("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?O("main",{"data-position":t},O(wt,{s:e}),O(ft,null,O(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,Tt=Ct(vt),kt=Ct(Tt),St=Ct(kt),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>Q(t)-2?s:Mt),(n=>{if(a>Q(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)&&Q(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=Tt)=>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(),T=Mt(),k=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),z=Mt(),$=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Xt(),P=Mt(),B=Mt(),j=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)=>H(((e,t=[a])=>{const s=[],l=(e,a)=>a==Q(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):H([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=Q(r);o==Q(s)?e(t,...r,...a(r)):q(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Te=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))},ke=(t,s)=>(!e||xt($,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($,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(A,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(O,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(F,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(J,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft($,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At($,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(O,t,[l,a])}),((e,t)=>{Ot($,t),Ot(O,t)})),$e=e=>Ft(A,e,((e,t,s)=>{Ot(A,t,s),N(s[u],(e=>Ot(F,t,e)),(()=>Yt(J,t)))}),((e,t)=>{Ot(A,t),Ot(F,t),Lt(J,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(j,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(j,e,(()=>(Ye(e,1),Ot(P,e,_t()),Ot(B,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(P,e),l=s(t);return xt(zt(j,e),l)?je(e,t):l},We=e=>zt(j,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(P,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(O,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(j,e),Ot(P,e),Ot(B,e)))},Xe=e=>{const t=zt(F,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(T,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(B,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(k,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(z,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(z)||Vt(me[e])?0:Nt(e?Ht(z):z,((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(T),Qt(k),Qt(x)]:[r,i,c,T,k,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(...D(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(T,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(z),changedTableIds:Jt(r),changedRowIds:Pt(T),changedCellIds:Bt(k),changedValueIds:Jt(V)}),gt=()=>Bt(j),It=()=>Et(j),pt=e=>vt(zt(j,S(e))),ft=e=>Et(zt(j,S(e))),wt=(e,t,s,l=0,a)=>{return D(W((r=zt(j,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),D([...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(j,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(j,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,ke,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,Te))))&&(Le(t),!Vt(j))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,Te))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(j,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(j,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,H([r,i,c,T,k,x,E,V,R,z],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(j,S(e))),getTableCellIds:e=>Et(zt(B,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(j,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(j),hasTable:e=>xt(j,S(e)),hasTableCell:(e,t)=>xt(zt(B,S(e)),S(t)),hasRow:(e,t)=>xt(zt(j,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(j,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(j),getValuesJson:()=>ne(G),getJson:()=>ne([j,G]),getTablesSchemaJson:()=>ne($),getValuesSchemaJson:()=>ne(A),getSchemaJson:()=>ne([$,A]),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=>ke(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=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}return ws},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(j,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(j,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(B,S(e)),t),forEachRow:(e,t)=>Nt(zt(j,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(j,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,Q(i=r)===Q(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,kt),cellIds:ts(ue,kt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:Tt(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?W(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()})),O($,null,O("aside",{id:oe},O(Ne,{s:l}),O(yt,{s:l})),O("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>O(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=>O(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>O(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),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,T="currentTarget",k="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),{PureComponent:z,Fragment:$,createElement:O,useCallback:A,useLayoutEffect:F,useRef:J,useState:P}=t,B=(e,...t)=>q(e)?{}:e(...t),H=(e,t)=>e.forEach(t),D=(e,t)=>e.map(t),Q=e=>e.length,j=e=>0==Q(e),W=(e,t,s)=>e.slice(t,s),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)=>D(K.entries(e),(([e,s])=>t(s,e))),ae=e=>_(e)&&0==(e=>Q(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)=>D(e.sort(),t),fe=(e,t)=>[!!s.useCell(ue,e,ge,t),A((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>")',Te=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\")",ke=D([[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;"+Te,...ee(D(["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(D(["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)":Te,"header>img:nth-of-type(6)":Se,...ee(D(ke,((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:O("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[T].open),[],r);return O("details",{open:o,onToggle:i},O("summary",null,t,a?O("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)=>D(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:O(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(D(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]})=>O("table",{className:e},i?O("caption",null,i):null,!1===t?null:O("thead",null,O("tr",null,!1===s?null:O(Ge,{sort:r??[],label:"Id",onClick:o}),le(l,(({label:e},t)=>O(Ge,{key:t,cellId:t,label:e,sort:r??[],onClick:o}))))),O("tbody",null,D(n,(e=>O("tr",{key:e},!1===s?null:O("th",null,e),le(l,(({component:t,getComponentProps:s},l)=>O("td",{key:l},O(t,{...B(s,e,l),...a,rowId:e,cellId:l}))))))))),Ge=({cellId:e,sort:[t,s],label:l=e??a,onClick:n})=>O("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 O("tr",null,!1===l?null:O(t.Fragment,null,O("th",null,e),O("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:O("td",{key:l},O(t,{...B(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 O("div",{className:s},O("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,O("input",{key:a,value:c,onChange:Oe((e=>p(e[T][k]+"",h)),[p])}),O("input",{key:a,type:"number",value:m,onChange:Oe((e=>p(Number(e[T][k]||0),b)),[p])}),O("input",{key:a,type:"checkbox",checked:g,onChange:Oe((e=>p(!!e[T].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 O(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})=>O("table",{className:n},!1===r?null:O("thead",null,O("tr",null,!1===o?null:O("th",null,"Id"),O("th",null,y))),O("tbody",null,D(s.useValueIds(e),(t=>O("tr",{key:t},!1===o?null:O("th",null,t),O("td",null,O(l,{...B(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 O(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 O("table",{className:r},!1===o?null:O("thead",null,O("tr",null,!1===i?null:O(t.Fragment,null,O("th",null,c,".Id"),O("th",null,h,".Id")),le(m,(({label:e},t)=>O("th",{key:t},e))))),O("tbody",null,D(s.useRowIds(c,u),(e=>O(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 O(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})=>O(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})=>O(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 O(t.Fragment,null,s>a&&O(t.Fragment,null,O("button",{className:"previous",disabled:0==l,onClick:o},"←"),O("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})=>O(Le,{uniqueId:Ie("i",t,l),summary:"Index: "+l,s:a},D(s.useSliceIds(l,e),(s=>O(rt,{indexes:e,indexesId:t,indexId:l,sliceId:s,s:a})))),rt=({indexes:e,indexesId:t,indexId:s,sliceId:l,s:a})=>{const n=Ie("i",t,s,l),[r,o]=fe(n,a);return O(Le,{uniqueId:n,summary:"Slice: "+l,editable:r,handleEditable:o,s:a},O(_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:O(Le,{uniqueId:Ie("i",e),summary:"Indexes: "+(e??u),s:t},j(a)?"No indexes defined":pe(a,(s=>O(nt,{indexes:l,indexesId:e,indexId:s,s:t}))))},it=({metrics:e,metricId:t})=>O("tr",null,O("th",null,t),O("td",null,e?.getTableId(t)),O("td",null,s.useMetric(t,e))),dt=({metricsId:e,s:t})=>{const l=s.useMetrics(e),a=s.useMetricIds(l);return q(l)?null:O(Le,{uniqueId:Ie("m",e),summary:"Metrics: "+(e??u),s:t},j(a)?"No metrics defined":O("table",null,O("thead",null,O("th",null,"Metric Id"),O("th",null,"Table Id"),O("th",null,"Metric")),O("tbody",null,D(a,(e=>O(it,{metrics:l,metricId: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 O(Le,{uniqueId:n,summary:"Query: "+l,s:a},O(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:O(Le,{uniqueId:Ie("q",e),summary:"Queries: "+(e??u),s:t},j(a)?"No queries defined":pe(a,(s=>O(ut,{queries:l,queriesId:e,queryId:s,s:t}))))},ht=({relationships:e,relationshipsId:t,relationshipId:s,s:l})=>{const a=Ie("r",t,s),[n,r]=fe(a,l);return O(Le,{uniqueId:a,summary:"Relationship: "+s,editable:n,handleEditable:r,s:l},O(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:O(Le,{uniqueId:Ie("r",e),summary:"Relationships: "+(e??u),s:t},j(a)?"No relationships defined":pe(a,(s=>O(ht,{relationships:l,relationshipsId:e,relationshipId:s,s:t}))))},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 O(Le,{uniqueId:n,summary:h+": "+e,editable:u,handleEditable:c,s:a},O(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 j(s.useValueIds(e))?null:O(Le,{uniqueId:a,summary:C,editable:n,handleEditable:r,s:l},O(Ze,{store:e,editable:n}))},It=({storeId:e,s:t})=>{const l=s.useStore(e),a=s.useTableIds(l);return q(l)?null:O(Le,{uniqueId:Ie("s",e),summary:"Store: "+(e??u),s:t},O(gt,{storeId:e,store:l,s:t}),pe(a,(s=>O(bt,{store:l,storeId:e,tableId:s,s:t}))))},pt=({s:e})=>{const t=J(null),l=J(0),[a,n]=P(!1),{scrollLeft:r,scrollTop:o}=s.useValues(e);F((()=>{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=A((t=>{const{scrollLeft:s,scrollTop:a}=t[T];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)&&j(u)&&q(c)&&j(h)&&q(m)&&j(b)&&q(g)&&j(I)&&q(p)&&j(f)?O("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):O("article",{ref:t,onScroll:i},O(It,{s:e}),D(u,(t=>O(It,{storeId:t,key:t,s:e}))),O(dt,{s:e}),D(h,(t=>O(dt,{metricsId:t,key:t,s:e}))),O(ot,{s:e}),D(b,(t=>O(ot,{indexesId:t,key:t,s:e}))),O(mt,{s:e}),D(I,(t=>O(mt,{relationshipsId:t,key:t,s:e}))),O(ct,{s:e}),D(f,(t=>O(ct,{queriesId:t,key:t,s:e}))))};class ft extends z{constructor(e){super(e),this.state={e:0}}static getDerivedStateFromError=()=>({e:1});componentDidCatch=(e,t)=>console.error(e,t.componentStack);render(){return this.state.e?O("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[T].dataset.id)),[],e);return O("header",null,O("img",{title:ie}),O("span",null,ie),D(de,((e,s)=>s==t?null:O("img",{onClick:a,"data-id":s,title:"Dock to "+e,key:s}))),O("img",{onClick:l,title:"Close"}))},yt=({s:e})=>{const t=s.useValue(me,e)??1;return s.useValue(be,e)?O("main",{"data-position":t},O(wt,{s:e}),O(ft,null,O(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,Tt=Ct(vt),kt=Ct(Tt),St=Ct(kt),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>Q(t)-2?s:Mt),(n=>{if(a>Q(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)&&Q(e)<1e3&&U(e,t)}]},es=e=>[e,e],ts=(e,t=Tt)=>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(),T=Mt(),k=Mt(),x=Mt(),V=Mt(),R=Mt(),E=Mt(),z=Mt(),$=Mt(),O=Mt(),A=Mt(),F=Mt(),J=Xt(),P=Mt(),B=Mt(),j=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)=>H(((e,t=[a])=>{const s=[],l=(e,a)=>a==Q(t)?U(s,e):null===t[a]?Nt(e,(e=>l(e,a+1))):H([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=Q(r);o==Q(s)?e(t,...r,...a(r)):q(s[o])?H(l[o]?.(...r)??[],(e=>n(...r,e))):n(...r,s[o])};n()}))]})(),Te=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))},ke=(t,s)=>(!e||xt($,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($,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(A,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(O,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(F,((t,s)=>{te(e,s)||(e[s]=t)})),Nt(J,(t=>{te(e,t)||at(t)}))),e),Le=e=>Ft($,e,((e,t,s)=>{const l=Mt(),a=Xt();Ft(At($,t,Mt),s,((e,t,s)=>{Ot(e,t,s),N(s[u],(e=>Ot(l,t,e)),(()=>Yt(a,t)))})),Ot(O,t,[l,a])}),((e,t)=>{Ot($,t),Ot(O,t)})),$e=e=>Ft(A,e,((e,t,s)=>{Ot(A,t,s),N(s[u],(e=>Ot(F,t,e)),(()=>Yt(J,t)))}),((e,t)=>{Ot(A,t),Ot(F,t),Lt(J,t)})),Oe=e=>ae(e)?us():Gt(e),Ae=e=>Ft(j,e,((e,t,s)=>Fe(t,s)),((e,t)=>Ue(t))),Fe=(e,t)=>Ft(At(j,e,(()=>(Ye(e,1),Ot(P,e,_t()),Ot(B,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(P,e),l=s(t);return xt(zt(j,e),l)?je(e,t):l},We=e=>zt(j,e)??Fe(e,{}),Ue=e=>Fe(e,{}),Ge=(e,t,s)=>{const[,l]=zt(P,e);l(s),Je(e,t,s,{},!0)},Ke=(e,t,s,l,a,n)=>{const r=zt(zt(O,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(j,e),Ot(P,e),Ot(B,e)))},Xe=e=>{const t=zt(F,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(T,e,Mt),t,s)&&Ot(c,e,At(c,e,(()=>0))+s),_e=(e,t,s,l)=>{const a=zt(B,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(k,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(z,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(z)||Vt(me[e])?0:Nt(e?Ht(z):z,((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(T),Qt(k),Qt(x)]:[r,i,c,T,k,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(...D(t,S)))),ws),mt=()=>[Jt(x,((e,t)=>-1===zt(r,t)?null:Jt(e,((e,s)=>-1===zt(zt(T,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(z),changedTableIds:Jt(r),changedRowIds:Pt(T),changedCellIds:Bt(k),changedValueIds:Jt(V)}),gt=()=>Bt(j),It=()=>Et(j),pt=e=>vt(zt(j,S(e))),ft=e=>Et(zt(j,S(e))),wt=(e,t,s,l=0,a)=>{return D(W((r=zt(j,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),D([...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(j,S(e)),S(t))),Ct=(e,t,s)=>zt(zt(zt(j,S(e)),S(t)),S(s)),Rt=()=>Jt(G),Wt=()=>Et(G),Ut=e=>zt(G,S(e)),Gt=e=>ht((()=>(e=>ns(e,ke,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,Te))))&&(Le(t),!Vt(j))){const e=gt();us(),Gt(e)}})),ds=e=>ht((()=>{if(t=(e=>ns(e,Te))(e)){const s=Rt();gs(),ms(),t=!0,$e(e),Kt(s)}})),us=()=>ht((()=>Ae({}))),cs=e=>ht((e=>xt(j,e)?Ue(e):0),e),hs=(e,t)=>ht(((e,t)=>N(zt(j,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,H([r,i,c,T,k,x,E,V,R,z],qt))),ws),ws={getContent:()=>[gt(),Rt()],getTables:gt,getTableIds:It,getTable:e=>Pt(zt(j,S(e))),getTableCellIds:e=>Et(zt(B,S(e))),getRowCount:pt,getRowIds:ft,getSortedRowIds:wt,getRow:(e,t)=>Jt(zt(zt(j,S(e)),S(t))),getCellIds:yt,getCell:Ct,getValues:Rt,getValueIds:Wt,getValue:Ut,hasTables:()=>!Vt(j),hasTable:e=>xt(j,S(e)),hasTableCell:(e,t)=>xt(zt(B,S(e)),S(t)),hasRow:(e,t)=>xt(zt(j,S(e)),S(t)),hasCell:(e,t,s)=>xt(zt(zt(j,S(e)),S(t)),S(s)),hasValues:()=>!Vt(G),hasValue:e=>xt(G,S(e)),getTablesJson:()=>ne(j),getValuesJson:()=>ne(G),getJson:()=>ne([j,G]),getTablesSchemaJson:()=>ne($),getValuesSchemaJson:()=>ne(A),getSchemaJson:()=>ne([$,A]),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=>ke(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=>{try{const[t,s]=re(e);Oe(t),He(s)}catch{Zt(e)}return ws},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(j,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(j,((t,s)=>e(s,(e=>Nt(t,((t,s)=>e(s,(e=>$t(t,e))))))))),forEachTableCell:(e,t)=>$t(zt(B,S(e)),t),forEachRow:(e,t)=>Nt(zt(j,S(e)),((e,s)=>t(s,(t=>$t(e,t))))),forEachCell:(e,t,s)=>$t(zt(zt(j,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,Q(i=r)===Q(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,kt),cellIds:ts(ue,kt),cell:ts(ce,St),invalidCell:ts(he,St),values:ts(be),valueIds:ts(ge),value:ts(Ie),invalidValue:ts(me),transaction:Tt(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?W(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()})),O($,null,O("aside",{id:oe},O(Ne,{s:l}),O(yt,{s:l})),O("style",null,qe))};e.EditableCellView=st,e.EditableValueView=lt,e.RelationshipInHtmlTable=et,e.ResultSortedTableInHtmlTable=tt,e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:l,...a})=>O(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=>O(is,{...e}),e.TableInHtmlTable=({tableId:e,store:t,editable:l,customCells:a,...n})=>O(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:f,useState:w}=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="tinybaseStoreInspector",R="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",T='content:url("',S=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'>",N='</svg>")',V=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\")",z=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])=>S+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${a}' fill='white'/>`+N)),$=S+"<path d='M20 20l60 60M20 80l60-60' />"+N,M=S+`<path d='${R}' />`+N,q=S+`<path d='${R}M20 20l60 60' />`+N,B="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(v({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[B]:"width:0.5rem;height:0.5rem;",[B+"-track"]:"background:#111",[B+"-thumb"]:"background:#999;border:1px solid #111",[B+"-thumb:hover"]:"background:#fff",[B+"-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;"+V,...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)":V,"header>img:nth-of-type(6)":$,...k(C(z,((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":q,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,#${x} 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?`#${x} ${t}{${e}}`:"")));const H=(e,t,l,a)=>e==n?t:e==r?l:a,{useCallback:O,useMemo:F,useState:E}=t,P="editable",j=(e,t)=>C(l.useTableCellIds(e,t),(t=>e+"."+t)),A=(e,t,l)=>{const a=O(e,t);return l?a:void 0},L=(...e)=>F((()=>e),e),U=(e,t)=>F((()=>({store:e,tableId:t})),[e,t]),D=(e,t)=>F((()=>({queries:e,queryId:t})),[e,t]),G=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=E([e,t,a]),c=O((e=>{m(e),s?.(e)}),[s]),h=A((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=O((e=>c([i,d,e])),[c,i,d]),p=!0===r?_:r;return[[i,d,u],h,F((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},J=(e,t,l)=>F((()=>{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]),K=({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(Q,{sort:r??[],label:"Id",onClick:s}),v(a,(({label:e},t)=>b(Q,{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}))))))))),Q=({cellId:e,sort:[t,l],label:a=e??"",onClick:n})=>b("th",{onClick:A((()=>n?.(e)),[n,e],n),className:m(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},m(l)||t!=e?null:(l?"↓":"↑")+" ",a),W=({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}))})))},X=({thing:e,onThingChange:t,className:l,hasSchema:s})=>{const[m,c]=E(),[h,g]=E(),[p,f]=E(),[w,I]=E(),[C,y]=E();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),f(e+""),I(Number(e)||0),y(!!e));const k=O(((e,l)=>{l(e),g(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:m,onClick:O((()=>{if(!s?.()){const e=H(m,r,o,n),l=H(e,p,w,C);c(e),g(l),t(l)}}),[s,t,p,w,C,m])},m),H(m,b("input",{key:m,value:p,onChange:O((e=>k(e[i][d]+"",f)),[k])}),b("input",{key:m,type:"number",value:w,onChange:O((e=>k(Number(e[i][d]||0),I)),[k])}),b("input",{key:m,type:"checkbox",checked:C,onChange:O((e=>k(!!e[i].checked,y)),[k])})))},Y=({tableId:e,rowId:t,cellId:a,store:n,className:o})=>b(X,{thing:l.useCell(e,t,a,n),onThingChange:l.useSetCellCallback(e,t,a,(e=>e),[],n),className:o??P+"Cell",hasSchema:l.useStoreOrStoreById(n)?.hasTablesSchema}),Z=({valueId:e,store:t,className:a})=>b(X,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:a??P+s,hasSchema:l.useStoreOrStoreById(t)?.hasValuesSchema}),_=({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=A((()=>e(a-n)),[e,a,n],a>0),i=A((()=>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)},ee=e=>new Map(e);ee(),ee(),e.EditableCellView=Y,e.EditableValueView=Z,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=J([...j(m,u),...j(c,u)],o,n?Y:l.CellView),g=L(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(W,{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]=G(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(K,{...m,params:L(J(l.useResultTableCellIds(e,r),d,l.ResultCellView),D(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(K,{...n,params:L(J(l.useResultTableCellIds(e,t),a,l.ResultCellView),D(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(K,{...r,params:L(J(l.useTableCellIds(d,i),o,n?Y:l.CellView),U(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]=G(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(K,{...c,params:L(J(l.useTableCellIds(e,r),m,s?Y:l.CellView),U(r,e),l.useSortedRowIds(e,...h,o,r),h,g,p)})},e.SortedTablePaginator=_,e.StoreInspector=e=>null,e.TableInHtmlTable=({tableId:e,store:t,editable:a,customCells:n,...o})=>b(K,{...o,params:L(J(l.useTableCellIds(e,t),n,a?Y:l.CellView),U(t,e),l.useRowIds(e,t))}),e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:a=(t?Z: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,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:H,useMemo:O,useState:F}=t,E="editable",P=(e,t)=>C(l.useTableCellIds(e,t),(t=>e+"."+t)),j=(e,t,l)=>{const a=H(e,t);return l?a:void 0},A=(...e)=>O((()=>e),e),L=(e,t)=>O((()=>({store:e,tableId:t})),[e,t]),U=(e,t)=>O((()=>({queries:e,queryId:t})),[e,t]),D=(e,t=!1,l,a=0,n,o,r,s)=>{const[[i,d,u],m]=F([e,t,a]),c=H((e=>{m(e),s?.(e)}),[s]),h=j((e=>c([e,e==i&&!d,u])),[c,i,d,u],l),g=H((e=>c([i,d,e])),[c,i,d]),p=!0===r?Z:r;return[[i,d,u],h,O((()=>!1===r?null:b(p,{offset:u,limit:n,total:o,onChange:g})),[r,p,u,n,o,g])]},G=(e,t,l)=>O((()=>{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]=F(),[h,g]=F(),[p,w]=F(),[f,I]=F(),[C,y]=F();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=H(((e,l)=>{l(e),g(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:m,onClick:H((()=>{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:H((e=>k(e[i][d]+"",w)),[k])}),b("input",{key:m,type:"number",value:f,onChange:H((e=>k(Number(e[i][d]||0),I)),[k])}),b("input",{key:m,type:"checkbox",checked:C,onChange:H((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)},_=e=>new Map(e);_(),_(),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=A(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]=D(t,a,s,n,o,l.useResultRowCount(e,r),i,u);return b(J,{...m,params:A(G(l.useResultTableCellIds(e,r),d,l.ResultCellView),U(r,e),l.useResultSortedRowIds(e,...c,o,r),c,h,g)})},e.ResultTableInHtmlTable=({queryId:e,queries:t,customCells:a,...n})=>b(J,{...n,params:A(G(l.useResultTableCellIds(e,t),a,l.ResultCellView),U(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:A(G(l.useTableCellIds(d,i),o,n?X:l.CellView),L(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]=D(t,a,i,n,o,l.useRowCount(e,r),d,u);return b(J,{...c,params:A(G(l.useTableCellIds(e,r),m,s?X:l.CellView),L(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:A(G(l.useTableCellIds(e,t),n,a?X:l.CellView),L(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);
Binary file
@@ -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",v=p+"Count",g=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),{PureComponent:L,Fragment:M,createElement:j,useCallback:z,useLayoutEffect:$,useRef:A,useState:F}=l,J=(e,...l)=>O(e)?{}:e(...l),D=(e,l)=>e.forEach(l),B=(e,l)=>e.map(l),H=e=>e.length,Q=e=>0==H(e),W=(e,l,t)=>e.slice(l,t),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)=>B(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>H(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",ve=(...e)=>re(e),ge=(e,l)=>B(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),z((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=B([[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=((e,l="")=>e.join(l))(ne(je(Me(je(Me(je(Me({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"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(B(["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(B(["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(B(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,#${oe} 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?`#${oe} ${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:j("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 j("details",{open:o,onToggle:i},j("summary",null,l,s?j("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)=>B(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:j(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(B(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]})=>j("table",{className:e},i?j("caption",null,i):null,!1===l?null:j("thead",null,j("tr",null,!1===t?null:j(ml,{sort:null!=a?a:[],label:"Id",onClick:o}),ne(n,(({label:e},l)=>j(ml,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),j("tbody",null,B(r,(e=>j("tr",{key:e},!1===t?null:j("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>j("td",{key:n},j(l,_e(Ze(Ze({},J(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>j("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 j("tr",null,!1===n?null:j(l.Fragment,null,j("th",null,e),j("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:j("td",{key:n},j(l,_e(Ze({},J(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,v]=nl();u!==e&&(i(Je(e)),d(e),h(e+""),b(Number(e)||0),v(!!e));const g=ll(((e,t)=>{t(e),d(e),l(e)}),[l]);return j("div",{className:t},j("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,j("input",{key:s,value:c,onChange:ll((e=>g(e[k][x]+"",h)),[g])}),j("input",{key:s,type:"number",value:m,onChange:ll((e=>g(Number(e[k][x]||0),b)),[g])}),j("input",{key:s,type:"checkbox",checked:p,onChange:ll((e=>g(!!e[k].checked,v)),[g])})))},vl=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,v,g]=dl(s,r,d,a,o,t.useRowCount(n,i),c,h);return j(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,v,g)}))},gl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>j("table",{className:r},!1===a?null:j("thead",null,j("tr",null,!1===o?null:j("th",null,"Id"),j("th",null,y))),j("tbody",null,B(t.useValueIds(e),(l=>j("tr",{key:l},!1===o?null:j("th",null,l),j("td",null,j(n,_e(Ze({},J(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 j(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 j("table",{className:a},!1===o?null:j("thead",null,j("tr",null,!1===i?null:j(l.Fragment,null,j("th",null,c,".Id"),j("th",null,h,".Id")),ne(m,(({label:e},l)=>j("th",{key:l},e))))),j("tbody",null,B(t.useRowIds(c,d),(e=>j(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,v]=dl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return j(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,v)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r})=>{var a;return j(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 j(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 j(l.Fragment,null,t>s&&j(l.Fragment,null,j("button",{className:"previous",disabled:0==n,onClick:o},"←"),j("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})=>j(Fe,{uniqueId:ve("i",l,n),summary:"Index: "+n,s:s},B(t.useSliceIds(n,e),(t=>j(Sl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s})))),Sl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ve("i",l,t,n),[a,o]=fe(r,s);return j(Fe,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},j(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:j(Fe,{uniqueId:ve("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},Q(s)?"No indexes defined":ge(s,(t=>j(xl,{indexes:n,indexesId:e,indexId:t,s:l}))))},Vl=({metrics:e,metricId:l})=>j("tr",null,j("th",null,l),j("td",null,null==e?void 0:e.getTableId(l)),j("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:j(Fe,{uniqueId:ve("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},Q(s)?"No metrics defined":j("table",null,j("thead",null,j("th",null,"Metric Id"),j("th",null,"Table Id"),j("th",null,"Metric")),j("tbody",null,B(s,(e=>j(Vl,{metrics:n,metricId:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=ve("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 j(Fe,{uniqueId:a,summary:"Query: "+n,s:s},j(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:j(Fe,{uniqueId:ve("q",e),summary:"Queries: "+(null!=e?e:d),s:l},Q(s)?"No queries defined":ge(s,(t=>j(Ol,{queries:n,queriesId:e,queryId:t,s:l}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ve("r",l,t),[r,a]=fe(s,n);return j(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},j(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:j(Fe,{uniqueId:ve("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},Q(s)?"No relationships defined":ge(s,(t=>j(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=ve("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 j(Fe,{uniqueId:a,summary:h+": "+e,editable:c,handleEditable:m,s:s},j(vl,{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=ve("v",l),[r,a]=fe(s,n);return Q(t.useValueIds(e))?null:j(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:a,s:n},j(gl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:j(Fe,{uniqueId:ve("s",e),summary:"Store: "+(null!=e?e:d),s:l},j(Ll,{storeId:e,store:n,s:l}),ge(s,(t=>j(El,{store:n,storeId:e,tableId:t,s:l}))))},jl=({s:e})=>{const l=A(null),n=A(0),[s,r]=F(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);$((()=>{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=z((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(),v=t.useRelationshipsIds(),g=t.useQueries(),f=t.useQueriesIds();return O(u)&&Q(d)&&O(c)&&Q(h)&&O(m)&&Q(b)&&O(p)&&Q(v)&&O(g)&&Q(f)?j("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):j("article",{ref:l,onScroll:i},j(Ml,{s:e}),B(d,(l=>j(Ml,{storeId:l,key:l,s:e}))),j(Rl,{s:e}),B(h,(l=>j(Rl,{metricsId:l,key:l,s:e}))),j(Tl,{s:e}),B(b,(l=>j(Tl,{indexesId:l,key:l,s:e}))),j(Nl,{s:e}),B(v,(l=>j(Nl,{relationshipsId:l,key:l,s:e}))),j(ql,{s:e}),B(f,(l=>j(ql,{queriesId:l,key:l,s:e}))))};var zl=Object.defineProperty,$l=(e,l,t)=>(((e,l,t)=>{l in e?zl(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t})(e,"symbol"!=typeof l?l+"":l,t),t);class Al extends L{constructor(e){super(e),$l(this,"componentDidCatch",((e,l)=>console.error(e,l.componentStack))),this.state={e:0}}render(){return this.state.e?j("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}$l(Al,"getDerivedStateFromError",(()=>({e:1})));const Fl=({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 j("header",null,j("img",{title:ie}),j("span",null,ie),B(ue,((e,l)=>l==n?null:j("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),j("img",{onClick:s,title:"Close"}))},Jl=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?j("main",{"data-position":n},j(Fl,{s:e}),j(Al,null,j(jl,{s:e}))):null},Dl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Bl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Hl=Dl(Bl),Ql=Dl(Hl),Wl=Dl(Ql),Ul=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>O(e)||0==Bl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Xl=e=>e.clear(),Yl=(e,l)=>null==e?void 0:e.forEach(l),Zl=(e,l)=>null==e?void 0:e.delete(l),_l=e=>new Map(e),et=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},lt=(e,l)=>null==e?void 0:e.get(l),tt=(e,l)=>Yl(e,((e,t)=>l(t,e))),nt=(e,l,t)=>O(t)?(Zl(e,l),e):null==e?void 0:e.set(l,t),st=(e,l,t)=>(Ul(e,l)||nt(e,l,t()),lt(e,l)),rt=(e,l,t,n=nt)=>(ne(l,((l,n)=>t(e,n,l))),tt(e,(t=>le(l,t)?0:n(e,t))),e),at=(e,l,t)=>{const n={};return Yl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>at(e,(e=>at(e,l,t)),se),it=(e,l,t)=>at(e,(e=>ot(e,l,t)),se),ut=(e,l)=>{const t=_l();return Yl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},dt=e=>ut(e,ut),ct=e=>ut(e,dt),ht=(e,l,t,n,s=0)=>q((t?st:lt)(e,l[s],s>H(l)-2?t:_l),(r=>{if(s>H(l)-2)return(null==n?void 0:n(r))&&nt(e,l[s]),r;const a=ht(r,l,t,n,s+1);return Gl(r)&&nt(e,l[s]),a}));var mt=(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 bt=_l(),pt=_l();var vt=(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 gt="storage",ft=globalThis.window,It=e=>new Set(E(e)||O(e)?e:[e]),yt=(e,l)=>null==e?void 0:e.add(l),wt=/^\d+$/,Ct=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{wt.test(l)&&H(e)<1e3&&U(e,l)}]},kt=e=>[e,e],xt=(e,l=Hl)=>l(e[0])+l(e[1]),St=()=>[_l(),_l()],Tt=e=>[...e],Vt=([e,l])=>e===l,Rt=(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)),Ot=(e,l,t)=>nt(e,l,lt(e,l)==-t?void 0:t),qt=()=>{let e,l,t=!1,n=!1,r=0;const a=_l(),i=_l(),c=_l(),k=_l(),x=_l(),T=_l(),V=_l(),R=_l(),E=_l(),L=_l(),M=_l(),j=_l(),z=_l(),$=_l(),A=It(),F=_l(),J=_l(),Q=_l(),G=_l(),K=St(),X=St(),Y=St(),_=St(),ee=St(),oe=St(),ie=St(),ue=St(),de=St(),ce=St(),he=St(),me=St(),be=St(),pe=St(),ve=St(),ge=_l(),fe=St(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=Ct(),r=_l();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return nt(r,u,[e,n,a,o,i]),yt(ht(n,null!=a?a:[s],It),u),u},(e,t,...n)=>D(((e,l=[s])=>{const t=[],n=(e,s)=>s==H(l)?U(t,e):null===l[s]?Yl(e,(e=>n(e,s+1))):D([l[s],null],(l=>n(lt(e,l),s+1)));return n(e,0),t})(e,t),(e=>Yl(e,(e=>lt(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(lt(r,e),(([,l,t])=>(ht(l,null!=t?t:[s],void 0,(l=>(Zl(l,e),Gl(l)?1:0))),nt(r,e),n(e),t))),e=>q(lt(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=H(a);u==H(t)?e(l,...a,...s(a)):O(t[u])?D(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(!Rt(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||Ul(M,t)||nl(t))&&Rt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Rt(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(lt(lt(M,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)=>Rt(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(lt(z,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(lt(j,l),(([n,s])=>{Yl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Yl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Yl($,((l,t)=>{le(e,t)||(e[t]=l)})),Yl(A,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>rt(M,e,((e,l,t)=>{const n=_l(),s=It();rt(st(M,l,_l),t,((e,l,t)=>{nt(e,l,t),q(t[d],(e=>nt(n,l,e)),(()=>yt(s,l)))})),nt(j,l,[n,s])}),((e,l)=>{nt(M,l),nt(j,l)})),Ne=e=>rt(z,e,((e,l,t)=>{nt(z,l,t),q(t[d],(e=>nt($,l,e)),(()=>yt(A,l)))}),((e,l)=>{nt(z,l),nt($,l),Zl(A,l)})),Ee=e=>se(e)?ql():Sl(e),Le=e=>rt(Q,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>rt(st(Q,e,(()=>(Ye(e,1),nt(F,e,Ct()),nt(J,e,_l()),_l()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>rt(st(l,t,(()=>(Ze(e,t,1),_l()))),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)=>{Ul(t,n)||_e(e,l,n,1);const r=lt(t,n);s!==r&&(el(e,l,n,r,s),nt(t,n,s))},$e=(e,l,t,n,s)=>q(lt(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=>rt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ul(G,e)||ll(e,1);const t=lt(G,e);l!==t&&(tl(e,t,l),nt(G,e,l))},Qe=(e,l)=>{const[t]=lt(F,e),n=t(l);return Ul(lt(Q,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=lt(Q,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=lt(F,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var a;const o=lt(null==(a=lt(j,e))?void 0:a[0],s);if(!O(o)&&!r)return ze(e,t,n,s,o);const i=l=>{el(e,t,l,lt(n,l)),_e(e,t,l,-1),nt(n,l)};O(o)?i(s):tt(n,i),Gl(n)&&(Ze(e,t,-1),Gl(nt(l,t))&&(Ye(e,-1),nt(Q,e),nt(F,e),nt(J,e)))},Xe=e=>{const l=lt($,e);if(!O(l))return He(e,l);tl(e,lt(G,e)),ll(e,-1),nt(G,e)},Ye=(e,l)=>Ot(a,e,l),Ze=(e,l,t)=>Ot(st(k,e,_l),l,t)&&nt(c,e,st(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=lt(J,e),a=null!=(s=lt(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Ot(st(i,e,_l),t,n),nt(r,t,a!=-n?a+n:null),Ot(st(st(x,e,_l),l,_l),t,n)},el=(e,l,t,n,s)=>st(st(st(T,e,_l),l,_l),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Ot(V,e,l),tl=(e,l,t)=>st(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(st(st(st(E,e,_l),l,_l),t,(()=>[])),n),s),sl=(e,l,t)=>(U(st(L,e,(()=>[])),l),t),rl=(e,l,t)=>q(lt(lt(lt(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...kt(wl(e,l,t))])),al=e=>q(lt(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...kt(xl(e))])),ol=e=>Gl(E)||Gl(he[e])?0:Yl(e?ct(E):E,((l,t)=>Yl(l,((l,n)=>Yl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Gl(L)||Gl(me[e])?0:Yl(e?ut(L):L,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Gl(l))return ye(e,t,(()=>at(l))),1},dl=e=>{const l=Gl(ie[e]),t=Gl(de[e])&&Gl(_[e])&&Gl(ee[e])&&Gl(oe[e])&&l&&Gl(X[e]),n=Gl(ce[e])&&Gl(ue[e])&&Gl(Y[e])&&Gl(K[e]);if(!t||!n){const s=e?[ut(a),dt(i),ut(c),dt(k),ct(x),ct(T)]:[a,i,c,k,x,T];if(!t){ul(X[e],s[0]),Yl(s[1],((l,t)=>ul(_[e],l,[t]))),Yl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],gl(t))}));const t=It();Yl(s[3],((n,s)=>{ul(oe[e],n,[s])&&!l&&(ye(ie[e],[s,null]),yt(t,s))})),l||Yl(s[5],((l,n)=>{if(!Ul(t,n)){const t=It();Yl(l,(e=>Yl(e,(([l,n],s)=>n!==l?yt(t,s):Zl(e,s))))),Yl(t,(l=>ye(ie[e],[n,l])))}})),Yl(s[4],((l,t)=>Yl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Yl(s[5],((t,n)=>{let s;Yl(t,((t,r)=>{let a;Yl(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=Gl(pe[e]),t=Gl(ve[e])&&Gl(be[e]);if(!l||!t){const n=e?[ut(V),ut(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Yl(n[1],(([t,n],s)=>{n!==t&&(ye(ve[e],[s],n,t,al),l=1)})),l&&ye(be[e],void 0,al)}}},hl=(e,...l)=>(jl((()=>e(...B(l,S)))),Al),ml=()=>[at(T,((e,l)=>-1===lt(a,l)?null:at(e,((e,t)=>-1===lt(lt(k,l),t)?null:at(e,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))),se)),se),at(R,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:it(T,Tt,Vt),invalidCells:it(E),changedValues:at(R,Tt,Vt),invalidValues:at(L),changedTableIds:at(a),changedRowIds:ot(k),changedCellIds:it(x),changedValueIds:at(V)}),pl=()=>it(Q),vl=()=>et(Q),gl=e=>Bl(lt(Q,S(e))),fl=e=>et(lt(Q,S(e))),Il=(e,l,t,n=0,s)=>{return B(W((a=lt(Q,S(e)),o=(e,t)=>[O(l)?t:lt(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},B([...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)=>et(lt(lt(Q,S(e)),S(l))),wl=(e,l,t)=>lt(lt(lt(Q,S(e)),S(l)),S(t)),Cl=()=>at(G),kl=()=>et(G),xl=e=>lt(G,S(e)),Sl=e=>hl((()=>(e=>Rt(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=Rt(l,(e=>Rt(e,ke))))&&(Pe(l),!Gl(Q))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Rt(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ul(Q,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(lt(Q,e),(t=>Ul(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(ge,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Gl(T),n=!Gl(R),r=1,ol(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Yl(T,((e,l)=>Yl(e,((e,t)=>Yl(e,(([e],n)=>De(Al,l,t,n,e))))))),Yl(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,D([a,i,c,k,x,T,E,V,R,L],Xl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:vl,getTable:e=>ot(lt(Q,S(e))),getTableCellIds:e=>et(lt(J,S(e))),getRowCount:gl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>at(lt(lt(Q,S(e)),S(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:xl,hasTables:()=>!Gl(Q),hasTable:e=>Ul(Q,S(e)),hasTableCell:(e,l)=>Ul(lt(J,S(e)),S(l)),hasRow:(e,l)=>Ul(lt(Q,S(e)),S(l)),hasCell:(e,l,t)=>Ul(lt(lt(Q,S(e)),S(l)),S(t)),hasValues:()=>!Gl(G),hasValue:e=>Ul(G,S(e)),getTablesJson:()=>re(Q),getValuesJson:()=>re(G),getJson:()=>re([Q,G]),getTablesSchemaJson:()=>re(M),getValuesSchemaJson:()=>re(z),getSchemaJson:()=>re([M,z]),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=>{try{const[l,t]=ae(e);Ee(l),Ae(t)}catch(l){Vl(e)}return Al},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(lt(Q,e),(s=>q(lt(s,l),(r=>Ul(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ul(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Yl(Q,((l,t)=>e(t,(e=>Yl(l,((l,t)=>e(t,(e=>tt(l,e))))))))),forEachTableCell:(e,l)=>tt(lt(J,S(e)),l),forEachRow:(e,l)=>Yl(lt(Q,S(e)),((e,t)=>l(t,(l=>tt(e,l))))),forEachCell:(e,l,t)=>tt(lt(lt(Q,S(e)),S(l)),t),forEachValue:e=>tt(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,H(i=a)===H(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],[vl])},addStartTransactionListener:e=>Ie(e,ge),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:xt(K),tableIds:xt(X),tableCellIds:xt(_),table:xt(Y),rowCount:xt(ee),rowIds:xt(oe),sortedRowIds:xt(ie),row:xt(ue,Ql),cellIds:xt(de,Ql),cell:xt(ce,Wl),invalidCell:xt(he,Wl),values:xt(be),valueIds:xt(pe),value:xt(ve),invalidValue:xt(me),transaction:Hl(ge)+xt(fe)}),createStore:qt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[vl]],[h+I]:[1,_,[vl]],[v]:[1,ee,[vl]],[g]:[1,oe,[vl]],[p]:[2,ue,[vl,fl]],[I]:[2,de,[vl,fl]],[f]:[3,ce,[vl,fl,yl],e=>kt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ve,[kl],e=>kt(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?W(s,0,e):void 0,t,n)})),Z(Al)},Pt=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(qt),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;st(bt,a,(()=>0)),st(pt,a,(()=>[]));const b=e=>mt(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>mt(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>mt(void 0,null,(function*(){return yield b((()=>mt(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>mt(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>mt(void 0,null,(function*(){if(n){const l=n();yield b((()=>mt(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>mt(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=>mt(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>mt(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>mt(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)=>mt(void 0,null,(function*(){return U(lt(pt,a),...e),yield mt(void 0,null,(function*(){if(!lt(bt,a)){for(nt(bt,a,1);!O(i=G(lt(pt,a)));)try{yield i()}catch(e){null==r||r(e)}nt(bt,a,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>vt(void 0,null,(function*(){return ae(t.getItem(l))}))),(e=>vt(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 ft.addEventListener(gt,n),n}),(e=>ft.removeEventListener(gt,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})),j(M,null,j("aside",{id:oe},j(Ae,{s:n}),j(Jl,{s:n})),j("style",null,$e))};var Nt=Object.defineProperty,Et=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,jt=(e,l,t)=>l in e?Nt(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 j(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=vl,e.SortedTablePaginator=kl,e.StoreInspector=e=>j(Pt,((e,l)=>{for(var t in l||(l={}))Lt.call(l,t)&&jt(e,t,l[t]);if(Et)for(var t of Et(l))Mt.call(l,t)&&jt(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 j(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=gl},"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),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",v=p+"Count",g=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),{PureComponent:L,Fragment:M,createElement:j,useCallback:z,useLayoutEffect:$,useRef:A,useState:F}=l,J=(e,...l)=>O(e)?{}:e(...l),D=(e,l)=>e.forEach(l),B=(e,l)=>e.map(l),H=e=>e.length,Q=e=>0==H(e),W=(e,l,t)=>e.slice(l,t),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)=>B(K.entries(e),(([e,t])=>l(t,e))),se=e=>_(e)&&0==(e=>H(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",ve=(...e)=>re(e),ge=(e,l)=>B(e.sort(),l),fe=(e,l)=>[!!t.useCell(de,e,pe,l),z((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=B([[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(B(["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(B(["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(B(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:j("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 j("details",{open:o,onToggle:i},j("summary",null,l,s?j("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)=>B(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:j(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(B(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]})=>j("table",{className:e},i?j("caption",null,i):null,!1===l?null:j("thead",null,j("tr",null,!1===t?null:j(ml,{sort:null!=a?a:[],label:"Id",onClick:o}),ne(n,(({label:e},l)=>j(ml,{key:l,cellId:l,label:e,sort:null!=a?a:[],onClick:o}))))),j("tbody",null,B(r,(e=>j("tr",{key:e},!1===t?null:j("th",null,e),ne(n,(({component:l,getComponentProps:t},n)=>j("td",{key:n},j(l,_e(Ze(Ze({},J(t,e,n)),s),{rowId:e,cellId:n})))))))))),ml=({cellId:e,sort:[l,t],label:n=(null!=e?e:s),onClick:r})=>j("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 j("tr",null,!1===n?null:j(l.Fragment,null,j("th",null,e),j("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:j("td",{key:n},j(l,_e(Ze({},J(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,v]=nl();u!==e&&(i(Je(e)),d(e),h(e+""),b(Number(e)||0),v(!!e));const g=ll(((e,t)=>{t(e),d(e),l(e)}),[l]);return j("div",{className:t},j("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,j("input",{key:s,value:c,onChange:ll((e=>g(e[k][x]+"",h)),[g])}),j("input",{key:s,type:"number",value:m,onChange:ll((e=>g(Number(e[k][x]||0),b)),[g])}),j("input",{key:s,type:"checkbox",checked:p,onChange:ll((e=>g(!!e[k].checked,v)),[g])})))},vl=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,v,g]=dl(s,r,d,a,o,t.useRowCount(n,i),c,h);return j(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,v,g)}))},gl=({store:e,editable:l=!1,valueComponent:n=(l?Cl:t.ValueView),getValueComponentProps:s,className:r,headerRow:a,idColumn:o})=>j("table",{className:r},!1===a?null:j("thead",null,j("tr",null,!1===o?null:j("th",null,"Id"),j("th",null,y))),j("tbody",null,B(t.useValueIds(e),(l=>j("tr",{key:l},!1===o?null:j("th",null,l),j("td",null,j(n,_e(Ze({},J(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 j(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 j("table",{className:a},!1===o?null:j("thead",null,j("tr",null,!1===i?null:j(l.Fragment,null,j("th",null,c,".Id"),j("th",null,h,".Id")),ne(m,(({label:e},l)=>j("th",{key:l},e))))),j("tbody",null,B(t.useRowIds(c,d),(e=>j(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,v]=dl(s,r,u,a,o,t.useResultRowCount(n,i),d,h);return j(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,v)}))},wl=({tableId:e,rowId:l,cellId:n,store:s,className:r})=>{var a;return j(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 j(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 j(l.Fragment,null,t>s&&j(l.Fragment,null,j("button",{className:"previous",disabled:0==n,onClick:o},"←"),j("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})=>j(Fe,{uniqueId:ve("i",l,n),summary:"Index: "+n,s:s},B(t.useSliceIds(n,e),(t=>j(Sl,{indexes:e,indexesId:l,indexId:n,sliceId:t,s:s})))),Sl=({indexes:e,indexesId:l,indexId:t,sliceId:n,s:s})=>{const r=ve("i",l,t,n),[a,o]=fe(r,s);return j(Fe,{uniqueId:r,summary:"Slice: "+n,editable:a,handleEditable:o,s:s},j(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:j(Fe,{uniqueId:ve("i",e),summary:"Indexes: "+(null!=e?e:d),s:l},Q(s)?"No indexes defined":ge(s,(t=>j(xl,{indexes:n,indexesId:e,indexId:t,s:l}))))},Vl=({metrics:e,metricId:l})=>j("tr",null,j("th",null,l),j("td",null,null==e?void 0:e.getTableId(l)),j("td",null,t.useMetric(l,e))),Rl=({metricsId:e,s:l})=>{const n=t.useMetrics(e),s=t.useMetricIds(n);return O(n)?null:j(Fe,{uniqueId:ve("m",e),summary:"Metrics: "+(null!=e?e:d),s:l},Q(s)?"No metrics defined":j("table",null,j("thead",null,j("th",null,"Metric Id"),j("th",null,"Table Id"),j("th",null,"Metric")),j("tbody",null,B(s,(e=>j(Vl,{metrics:n,metricId:e}))))))},Ol=({queries:e,queriesId:l,queryId:n,s:s})=>{var r;const a=ve("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 j(Fe,{uniqueId:a,summary:"Query: "+n,s:s},j(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:j(Fe,{uniqueId:ve("q",e),summary:"Queries: "+(null!=e?e:d),s:l},Q(s)?"No queries defined":ge(s,(t=>j(Ol,{queries:n,queriesId:e,queryId:t,s:l}))))},Pl=({relationships:e,relationshipsId:l,relationshipId:t,s:n})=>{const s=ve("r",l,t),[r,a]=fe(s,n);return j(Fe,{uniqueId:s,summary:"Relationship: "+t,editable:r,handleEditable:a,s:n},j(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:j(Fe,{uniqueId:ve("r",e),summary:"Relationships: "+(null!=e?e:d),s:l},Q(s)?"No relationships defined":ge(s,(t=>j(Pl,{relationships:n,relationshipsId:e,relationshipId:t,s:l}))))},El=({tableId:e,store:l,storeId:n,s:s})=>{var r;const a=ve("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 j(Fe,{uniqueId:a,summary:h+": "+e,editable:c,handleEditable:m,s:s},j(vl,{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=ve("v",l),[r,a]=fe(s,n);return Q(t.useValueIds(e))?null:j(Fe,{uniqueId:s,summary:w,editable:r,handleEditable:a,s:n},j(gl,{store:e,editable:r}))},Ml=({storeId:e,s:l})=>{const n=t.useStore(e),s=t.useTableIds(n);return O(n)?null:j(Fe,{uniqueId:ve("s",e),summary:"Store: "+(null!=e?e:d),s:l},j(Ll,{storeId:e,store:n,s:l}),ge(s,(t=>j(El,{store:n,storeId:e,tableId:t,s:l}))))},jl=({s:e})=>{const l=A(null),n=A(0),[s,r]=F(!1),{scrollLeft:a,scrollTop:o}=t.useValues(e);$((()=>{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=z((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(),v=t.useRelationshipsIds(),g=t.useQueries(),f=t.useQueriesIds();return O(u)&&Q(d)&&O(c)&&Q(h)&&O(m)&&Q(b)&&O(p)&&Q(v)&&O(g)&&Q(f)?j("span",{className:"warn"},"There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component."):j("article",{ref:l,onScroll:i},j(Ml,{s:e}),B(d,(l=>j(Ml,{storeId:l,key:l,s:e}))),j(Rl,{s:e}),B(h,(l=>j(Rl,{metricsId:l,key:l,s:e}))),j(Tl,{s:e}),B(b,(l=>j(Tl,{indexesId:l,key:l,s:e}))),j(Nl,{s:e}),B(v,(l=>j(Nl,{relationshipsId:l,key:l,s:e}))),j(ql,{s:e}),B(f,(l=>j(ql,{queriesId:l,key:l,s:e}))))};var zl=Object.defineProperty,$l=(e,l,t)=>(((e,l,t)=>{l in e?zl(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t})(e,"symbol"!=typeof l?l+"":l,t),t);class Al extends L{constructor(e){super(e),$l(this,"componentDidCatch",((e,l)=>console.error(e,l.componentStack))),this.state={e:0}}render(){return this.state.e?j("span",{className:"warn"},"Inspector error: please see console for details."):this.props.children}}$l(Al,"getDerivedStateFromError",(()=>({e:1})));const Fl=({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 j("header",null,j("img",{title:ie}),j("span",null,ie),B(ue,((e,l)=>l==n?null:j("img",{onClick:r,"data-id":l,title:"Dock to "+e,key:l}))),j("img",{onClick:s,title:"Close"}))},Jl=({s:e})=>{var l;const n=null!=(l=t.useValue(me,e))?l:1;return t.useValue(be,e)?j("main",{"data-position":n},j(Fl,{s:e}),j(Al,null,j(jl,{s:e}))):null},Dl=e=>l=>{return t=(l,t)=>l+e(t),Kl(l).reduce(t,0);var t},Bl=e=>{var l;return null!=(l=null==e?void 0:e.size)?l:0},Hl=Dl(Bl),Ql=Dl(Hl),Wl=Dl(Ql),Ul=(e,l)=>{var t;return null!=(t=null==e?void 0:e.has(l))&&t},Gl=e=>O(e)||0==Bl(e),Kl=e=>{var l;return[...null!=(l=null==e?void 0:e.values())?l:[]]},Xl=e=>e.clear(),Yl=(e,l)=>null==e?void 0:e.forEach(l),Zl=(e,l)=>null==e?void 0:e.delete(l),_l=e=>new Map(e),et=e=>{var l;return[...null!=(l=null==e?void 0:e.keys())?l:[]]},lt=(e,l)=>null==e?void 0:e.get(l),tt=(e,l)=>Yl(e,((e,t)=>l(t,e))),nt=(e,l,t)=>O(t)?(Zl(e,l),e):null==e?void 0:e.set(l,t),st=(e,l,t)=>(Ul(e,l)||nt(e,l,t()),lt(e,l)),rt=(e,l,t,n=nt)=>(ne(l,((l,n)=>t(e,n,l))),tt(e,(t=>le(l,t)?0:n(e,t))),e),at=(e,l,t)=>{const n={};return Yl(e,((e,s)=>{const r=l?l(e,s):e;!(null==t?void 0:t(r,e))&&(n[s]=r)})),n},ot=(e,l,t)=>at(e,(e=>at(e,l,t)),se),it=(e,l,t)=>at(e,(e=>ot(e,l,t)),se),ut=(e,l)=>{const t=_l();return Yl(e,((e,n)=>{var s;return t.set(n,null!=(s=null==l?void 0:l(e))?s:e)})),t},dt=e=>ut(e,ut),ct=e=>ut(e,dt),ht=(e,l,t,n,s=0)=>q((t?st:lt)(e,l[s],s>H(l)-2?t:_l),(r=>{if(s>H(l)-2)return(null==n?void 0:n(r))&&nt(e,l[s]),r;const a=ht(r,l,t,n,s+1);return Gl(r)&&nt(e,l[s]),a}));var mt=(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 bt=_l(),pt=_l();var vt=(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 gt="storage",ft=globalThis.window,It=e=>new Set(E(e)||O(e)?e:[e]),yt=(e,l)=>null==e?void 0:e.add(l),wt=/^\d+$/,Ct=()=>{const e=[];let l=0;return[t=>{var n;return null!=(n=t?G(e):null)?n:s+l++},l=>{wt.test(l)&&H(e)<1e3&&U(e,l)}]},kt=e=>[e,e],xt=(e,l=Hl)=>l(e[0])+l(e[1]),St=()=>[_l(),_l()],Tt=e=>[...e],Vt=([e,l])=>e===l,Rt=(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)),Ot=(e,l,t)=>nt(e,l,lt(e,l)==-t?void 0:t),qt=()=>{let e,l,t=!1,n=!1,r=0;const a=_l(),i=_l(),c=_l(),k=_l(),x=_l(),T=_l(),V=_l(),R=_l(),E=_l(),L=_l(),M=_l(),j=_l(),z=_l(),$=_l(),A=It(),F=_l(),J=_l(),Q=_l(),G=_l(),K=St(),X=St(),Y=St(),_=St(),ee=St(),oe=St(),ie=St(),ue=St(),de=St(),ce=St(),he=St(),me=St(),be=St(),pe=St(),ve=St(),ge=_l(),fe=St(),[Ie,ye,we,Ce]=(e=>{let l;const[t,n]=Ct(),r=_l();return[(e,n,a,o=[],i=(()=>[]))=>{null!=l||(l=Al);const u=t(1);return nt(r,u,[e,n,a,o,i]),yt(ht(n,null!=a?a:[s],It),u),u},(e,t,...n)=>D(((e,l=[s])=>{const t=[],n=(e,s)=>s==H(l)?U(t,e):null===l[s]?Yl(e,(e=>n(e,s+1))):D([l[s],null],(l=>n(lt(e,l),s+1)));return n(e,0),t})(e,t),(e=>Yl(e,(e=>lt(r,e)[0](l,...null!=t?t:[],...n))))),e=>q(lt(r,e),(([,l,t])=>(ht(l,null!=t?t:[s],void 0,(l=>(Zl(l,e),Gl(l)?1:0))),nt(r,e),n(e),t))),e=>q(lt(r,e),(([e,,t=[],n,s])=>{const r=(...a)=>{var o,i;const u=H(a);u==H(t)?e(l,...a,...s(a)):O(t[u])?D(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(!Rt(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||Ul(M,t)||nl(t))&&Rt(l,((e,l)=>Se(t,l,e)),(()=>nl(t))),Se=(e,l,t,n)=>Rt(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(lt(lt(M,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)=>Rt(l?e:qe(e),((l,t)=>q(Re(t,l),(l=>(e[t]=l,!0)),(()=>!1))),(()=>sl())),Re=(e,t)=>l?q(lt(z,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(lt(j,l),(([n,s])=>{Yl(n,((l,t)=>{le(e,t)||(e[t]=l)})),Yl(s,(n=>{le(e,n)||nl(l,t,n)}))})),e),qe=e=>(l&&(Yl($,((l,t)=>{le(e,t)||(e[t]=l)})),Yl(A,(l=>{le(e,l)||sl(l)}))),e),Pe=e=>rt(M,e,((e,l,t)=>{const n=_l(),s=It();rt(st(M,l,_l),t,((e,l,t)=>{nt(e,l,t),q(t[d],(e=>nt(n,l,e)),(()=>yt(s,l)))})),nt(j,l,[n,s])}),((e,l)=>{nt(M,l),nt(j,l)})),Ne=e=>rt(z,e,((e,l,t)=>{nt(z,l,t),q(t[d],(e=>nt($,l,e)),(()=>yt(A,l)))}),((e,l)=>{nt(z,l),nt($,l),Zl(A,l)})),Ee=e=>se(e)?ql():Sl(e),Le=e=>rt(Q,e,((e,l,t)=>Me(l,t)),((e,l)=>Ue(l))),Me=(e,l)=>rt(st(Q,e,(()=>(Ye(e,1),nt(F,e,Ct()),nt(J,e,_l()),_l()))),l,((l,t,n)=>je(e,l,t,n)),((l,t)=>Ge(e,l,t))),je=(e,l,t,n,s)=>rt(st(l,t,(()=>(Ze(e,t,1),_l()))),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)=>{Ul(t,n)||_e(e,l,n,1);const r=lt(t,n);s!==r&&(el(e,l,n,r,s),nt(t,n,s))},$e=(e,l,t,n,s)=>q(lt(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=>rt(G,e,((e,l,t)=>He(l,t)),((e,l)=>Xe(l))),He=(e,l)=>{Ul(G,e)||ll(e,1);const t=lt(G,e);l!==t&&(tl(e,t,l),nt(G,e,l))},Qe=(e,l)=>{const[t]=lt(F,e),n=t(l);return Ul(lt(Q,e),n)?Qe(e,l):n},We=e=>{var l;return null!=(l=lt(Q,e))?l:Me(e,{})},Ue=e=>Me(e,{}),Ge=(e,l,t)=>{const[,n]=lt(F,e);n(t),je(e,l,t,{},!0)},Ke=(e,l,t,n,s,r)=>{var a;const o=lt(null==(a=lt(j,e))?void 0:a[0],s);if(!O(o)&&!r)return ze(e,t,n,s,o);const i=l=>{el(e,t,l,lt(n,l)),_e(e,t,l,-1),nt(n,l)};O(o)?i(s):tt(n,i),Gl(n)&&(Ze(e,t,-1),Gl(nt(l,t))&&(Ye(e,-1),nt(Q,e),nt(F,e),nt(J,e)))},Xe=e=>{const l=lt($,e);if(!O(l))return He(e,l);tl(e,lt(G,e)),ll(e,-1),nt(G,e)},Ye=(e,l)=>Ot(a,e,l),Ze=(e,l,t)=>Ot(st(k,e,_l),l,t)&&nt(c,e,st(c,e,(()=>0))+t),_e=(e,l,t,n)=>{var s;const r=lt(J,e),a=null!=(s=lt(r,t))?s:0;(0==a&&1==n||1==a&&-1==n)&&Ot(st(i,e,_l),t,n),nt(r,t,a!=-n?a+n:null),Ot(st(st(x,e,_l),l,_l),t,n)},el=(e,l,t,n,s)=>st(st(st(T,e,_l),l,_l),t,(()=>[n,0]))[1]=s,ll=(e,l)=>Ot(V,e,l),tl=(e,l,t)=>st(R,e,(()=>[l,0]))[1]=t,nl=(e,l,t,n,s)=>(U(st(st(st(E,e,_l),l,_l),t,(()=>[])),n),s),sl=(e,l,t)=>(U(st(L,e,(()=>[])),l),t),rl=(e,l,t)=>q(lt(lt(lt(T,e),l),t),(([e,l])=>[!0,e,l]),(()=>[!1,...kt(wl(e,l,t))])),al=e=>q(lt(R,e),(([e,l])=>[!0,e,l]),(()=>[!1,...kt(xl(e))])),ol=e=>Gl(E)||Gl(he[e])?0:Yl(e?ct(E):E,((l,t)=>Yl(l,((l,n)=>Yl(l,((l,s)=>ye(he[e],[t,n,s],l))))))),il=e=>Gl(L)||Gl(me[e])?0:Yl(e?ut(L):L,((l,t)=>ye(me[e],[t],l))),ul=(e,l,t)=>{if(!Gl(l))return ye(e,t,(()=>at(l))),1},dl=e=>{const l=Gl(ie[e]),t=Gl(de[e])&&Gl(_[e])&&Gl(ee[e])&&Gl(oe[e])&&l&&Gl(X[e]),n=Gl(ce[e])&&Gl(ue[e])&&Gl(Y[e])&&Gl(K[e]);if(!t||!n){const s=e?[ut(a),dt(i),ut(c),dt(k),ct(x),ct(T)]:[a,i,c,k,x,T];if(!t){ul(X[e],s[0]),Yl(s[1],((l,t)=>ul(_[e],l,[t]))),Yl(s[2],((l,t)=>{0!=l&&ye(ee[e],[t],gl(t))}));const t=It();Yl(s[3],((n,s)=>{ul(oe[e],n,[s])&&!l&&(ye(ie[e],[s,null]),yt(t,s))})),l||Yl(s[5],((l,n)=>{if(!Ul(t,n)){const t=It();Yl(l,(e=>Yl(e,(([l,n],s)=>n!==l?yt(t,s):Zl(e,s))))),Yl(t,(l=>ye(ie[e],[n,l])))}})),Yl(s[4],((l,t)=>Yl(l,((l,n)=>ul(de[e],l,[t,n])))))}if(!n){let l;Yl(s[5],((t,n)=>{let s;Yl(t,((t,r)=>{let a;Yl(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=Gl(pe[e]),t=Gl(ve[e])&&Gl(be[e]);if(!l||!t){const n=e?[ut(V),ut(R)]:[V,R];if(l||ul(pe[e],n[0]),!t){let l;Yl(n[1],(([t,n],s)=>{n!==t&&(ye(ve[e],[s],n,t,al),l=1)})),l&&ye(be[e],void 0,al)}}},hl=(e,...l)=>(jl((()=>e(...B(l,S)))),Al),ml=()=>[at(T,((e,l)=>-1===lt(a,l)?null:at(e,((e,t)=>-1===lt(lt(k,l),t)?null:at(e,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))),se)),se),at(R,(([,e])=>null!=e?e:null),((e,l)=>Vt(l)))],bl=()=>({cellsTouched:t,valuesTouched:n,changedCells:it(T,Tt,Vt),invalidCells:it(E),changedValues:at(R,Tt,Vt),invalidValues:at(L),changedTableIds:at(a),changedRowIds:ot(k),changedCellIds:it(x),changedValueIds:at(V)}),pl=()=>it(Q),vl=()=>et(Q),gl=e=>Bl(lt(Q,S(e))),fl=e=>et(lt(Q,S(e))),Il=(e,l,t,n=0,s)=>{return B(W((a=lt(Q,S(e)),o=(e,t)=>[O(l)?t:lt(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},B([...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)=>et(lt(lt(Q,S(e)),S(l))),wl=(e,l,t)=>lt(lt(lt(Q,S(e)),S(l)),S(t)),Cl=()=>at(G),kl=()=>et(G),xl=e=>lt(G,S(e)),Sl=e=>hl((()=>(e=>Rt(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=Rt(l,(e=>Rt(e,ke))))&&(Pe(l),!Gl(Q))){const e=pl();ql(),Sl(e)}})),Ol=e=>hl((()=>{if(l=(e=>Rt(e,ke))(e)){const t=Cl();Ml(),El(),l=!0,Ne(e),Tl(t)}})),ql=()=>hl((()=>Le({}))),Pl=e=>hl((e=>Ul(Q,e)?Ue(e):0),e),Nl=(e,l)=>hl(((e,l)=>q(lt(Q,e),(t=>Ul(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(ge,void 0,ml,bl),Al),$l=e=>(r>0&&(r--,0==r&&(t=!Gl(T),n=!Gl(R),r=1,ol(1),t&&dl(1),il(1),n&&cl(1),(null==e?void 0:e(ml,bl))&&(Yl(T,((e,l)=>Yl(e,((e,t)=>Yl(e,(([e],n)=>De(Al,l,t,n,e))))))),Yl(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,D([a,i,c,k,x,T,E,V,R,L],Xl))),Al),Al={getContent:()=>[pl(),Cl()],getTables:pl,getTableIds:vl,getTable:e=>ot(lt(Q,S(e))),getTableCellIds:e=>et(lt(J,S(e))),getRowCount:gl,getRowIds:fl,getSortedRowIds:Il,getRow:(e,l)=>at(lt(lt(Q,S(e)),S(l))),getCellIds:yl,getCell:wl,getValues:Cl,getValueIds:kl,getValue:xl,hasTables:()=>!Gl(Q),hasTable:e=>Ul(Q,S(e)),hasTableCell:(e,l)=>Ul(lt(J,S(e)),S(l)),hasRow:(e,l)=>Ul(lt(Q,S(e)),S(l)),hasCell:(e,l,t)=>Ul(lt(lt(Q,S(e)),S(l)),S(t)),hasValues:()=>!Gl(G),hasValue:e=>Ul(G,S(e)),getTablesJson:()=>re(Q),getValuesJson:()=>re(G),getJson:()=>re([Q,G]),getTablesSchemaJson:()=>re(M),getValuesSchemaJson:()=>re(z),getSchemaJson:()=>re([M,z]),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=>{try{const[l,t]=ae(e);Ee(l),Ae(t)}catch(l){Vl(e)}return Al},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(lt(Q,e),(s=>q(lt(s,l),(r=>Ul(r,t)?Ke(e,s,l,r,t,n):0))))),e,l,t),delValues:El,delValue:e=>hl((e=>Ul(G,e)?Xe(e):0),e),delTablesSchema:Ll,delValuesSchema:Ml,delSchema:()=>hl((()=>{Ll(),Ml()})),transaction:jl,startTransaction:zl,finishTransaction:$l,forEachTable:e=>Yl(Q,((l,t)=>e(t,(e=>Yl(l,((l,t)=>e(t,(e=>tt(l,e))))))))),forEachTableCell:(e,l)=>tt(lt(J,S(e)),l),forEachRow:(e,l)=>Yl(lt(Q,S(e)),((e,t)=>l(t,(l=>tt(e,l))))),forEachCell:(e,l,t)=>tt(lt(lt(Q,S(e)),S(l)),t),forEachValue:e=>tt(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,H(i=a)===H(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],[vl])},addStartTransactionListener:e=>Ie(e,ge),addWillFinishTransactionListener:e=>Ie(e,fe[0]),addDidFinishTransactionListener:e=>Ie(e,fe[1]),callListener:e=>(Ce(e),Al),delListener:e=>(we(e),Al),getListenerStats:()=>({tables:xt(K),tableIds:xt(X),tableCellIds:xt(_),table:xt(Y),rowCount:xt(ee),rowIds:xt(oe),sortedRowIds:xt(ie),row:xt(ue,Ql),cellIds:xt(de,Ql),cell:xt(ce,Wl),invalidCell:xt(he,Wl),values:xt(be),valueIds:xt(pe),value:xt(ve),invalidValue:xt(me),transaction:Hl(ge)+xt(fe)}),createStore:qt,addListener:Ie,callListeners:ye};return ne({[m]:[0,K],[b]:[0,X],[h]:[1,Y,[vl]],[h+I]:[1,_,[vl]],[v]:[1,ee,[vl]],[g]:[1,oe,[vl]],[p]:[2,ue,[vl,fl]],[I]:[2,de,[vl,fl]],[f]:[3,ce,[vl,fl,yl],e=>kt(wl(...e))],InvalidCell:[3,he],[w]:[0,be],[C]:[0,pe],[y]:[1,ve,[kl],e=>kt(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?W(s,0,e):void 0,t,n)})),Z(Al)},Pt=({position:e="right",open:l=!1})=>{const n=t.useCreateStore(qt),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;st(bt,a,(()=>0)),st(pt,a,(()=>[]));const b=e=>mt(void 0,null,(function*(){return 2!=d&&(d=1,c++,yield p.schedule((()=>mt(void 0,null,(function*(){yield e(),d=0}))))),p})),p={load:(t,n)=>mt(void 0,null,(function*(){return yield b((()=>mt(void 0,null,(function*(){try{e.setContent(yield l())}catch(l){e.setContent([t,n])}}))))})),startAutoLoad:(...t)=>mt(void 0,[...t],(function*(t={},s={}){return p.stopAutoLoad(),yield p.load(t,s),m=1,u=n(((t,n)=>mt(void 0,null,(function*(){if(n){const l=n();yield b((()=>mt(void 0,null,(function*(){return e.setTransactionChanges(l)}))))}else yield b((()=>mt(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=>mt(void 0,null,(function*(){return 1!=d&&(d=2,h++,yield p.schedule((()=>mt(void 0,null,(function*(){try{yield t(e.getContent,l)}catch(e){null==r||r(e)}d=0}))))),p})),startAutoSave:()=>mt(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)=>mt(void 0,null,(function*(){return U(lt(pt,a),...e),yield mt(void 0,null,(function*(){if(!lt(bt,a)){for(nt(bt,a,1);!O(i=G(lt(pt,a)));)try{yield i()}catch(e){null==r||r(e)}nt(bt,a,0)}})),p})),getStore:()=>e,destroy:()=>p.stopAutoLoad().stopAutoSave(),getStats:()=>({loads:c,saves:h})};return Z(p)})(e,(()=>vt(void 0,null,(function*(){return ae(t.getItem(l))}))),(e=>vt(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 ft.addEventListener(gt,n),n}),(e=>ft.removeEventListener(gt,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})),j(M,null,j("aside",{id:oe},j(Ae,{s:n}),j(Jl,{s:n})),j("style",null,$e))};var Nt=Object.defineProperty,Et=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,jt=(e,l,t)=>l in e?Nt(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 j(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=vl,e.SortedTablePaginator=kl,e.StoreInspector=e=>j(Pt,((e,l)=>{for(var t in l||(l={}))Lt.call(l,t)&&jt(e,t,l[t]);if(Et)for(var t of Et(l))Mt.call(l,t)&&jt(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 j(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=gl},"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,n=r(""),a=r(!0),o=r(0),i="Value",s="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),y=(e,t)=>e.map(t),I=Object,C=(e=[])=>I.fromEntries(e),k=(e,t)=>y(I.entries(e),(([e,l])=>t(l,e))),x="tinybaseStoreInspector",R="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",O='content:url("',T=O+"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=O+"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,r])=>T+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+S)),j=T+"<path d='M20 20l60 60M20 80l60-60' />"+S,P=T+`<path d='${R}' />`+S,z=T+`<path d='${R}M20 20l60 60' />`+S;var $=Object.defineProperty,q=Object.defineProperties,M=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,E=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,H=(e,t,l)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,D=(e,t)=>{for(var l in t||(t={}))E.call(t,l)&&H(e,l,t[l]);if(B)for(var l of B(t))F.call(t,l)&&H(e,l,t[l]);return e},A=(e,t)=>q(e,M(t));const L="*::-webkit-scrollbar";((e,t="")=>{e.join(t)})(k(A(D(A(D(A(D({"":"all:initial;font-family:sans-serif;font-size:0.75rem;position:fixed;z-index:999999","*":"all:revert","*::before":"all:revert","*::after":"all:revert",[L]:"width:0.5rem;height:0.5rem;",[L+"-track"]:"background:#111",[L+"-thumb"]:"background:#999;border:1px solid #111",[L+"-thumb:hover"]:"background:#fff",[L+"-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},C(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;"}),C(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)":j}),C(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":P,"details[open]>summary img.done":z,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,#${x} 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?`#${x} ${t}{${e}}`:"")));const U=(e,t,l,r)=>e==n?t:e==o?l:r;var G=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,Y=(e,t,l)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,Z=(e,t)=>{for(var l in t||(t={}))W.call(t,l)&&Y(e,l,t[l]);if(Q)for(var l of Q(t))X.call(t,l)&&Y(e,l,t[l]);return e},_=(e,t)=>J(e,K(t)),ee=(e,t)=>{var l={};for(var r in e)W.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(null!=e&&Q)for(var r of Q(e))t.indexOf(r)<0&&X.call(e,r)&&(l[r]=e[r]);return l};const{useCallback:te,useMemo:le,useState:re}=t,ne="editable",ae=(e,t)=>y(l.useTableCellIds(e,t),(t=>e+"."+t)),oe=(e,t,l)=>{const r=te(e,t);return l?r:void 0},ie=(...e)=>le((()=>e),e),se=(e,t)=>le((()=>({store:e,tableId:t})),[e,t]),de=(e,t)=>le((()=>({queries:e,queryId:t})),[e,t]),ue=(e,t=!1,l,r=0,n,a,o,i)=>{const[[s,d,u],c]=re([e,t,r]),m=te((e=>{c(e),null==i||i(e)}),[i]),h=oe((e=>m([e,e==s&&!d,u])),[m,s,d,u],l),p=te((e=>m([s,d,e])),[m,s,d]),g=!0===o?we:o;return[[s,d,u],h,le((()=>!1===o?null:b(g,{offset:u,limit:n,total:a,onChange:p})),[o,g,u,n,a,p])]},ce=(e,t,l)=>le((()=>{const a=null!=t?t:e;return C(k(Array.isArray(a)?C(y(a,(e=>[e,e]))):a,((e,t)=>{return[t,Z(Z({},{label:t,component:l}),(a=e,r(a)==n?{label:e}:e))];var a})))}),[t,l,e]),me=({className:e,headerRow:t,idColumn:l,params:[r,n,a,o,i,s]})=>b("table",{className:e},s?b("caption",null,s):null,!1===t?null:b("thead",null,b("tr",null,!1===l?null:b(he,{sort:null!=o?o:[],label:"Id",onClick:i}),k(r,(({label:e},t)=>b(he,{key:t,cellId:t,label:e,sort:null!=o?o:[],onClick:i}))))),b("tbody",null,y(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(Z({},v(l,e,r)),n),{rowId:e,cellId:r})))))))))),he=({cellId:e,sort:[t,l],label:r=(null!=e?e:""),onClick:n})=>b("th",{onClick:oe((()=>null==n?void 0:n(e)),[n,e],n),className:c(l)||t!=e?void 0:`sorted ${l?"de":"a"}scending`},c(l)||t!=e?null:(l?"↓":"↑")+" ",r),be=({localRowId:e,params:[r,n,a,o,i,s,d]})=>{const u=l.useRemoteRowId(i,e,s);return b("tr",null,!1===r?null:b(t.Fragment,null,b("th",null,e),b("th",null,u)),k(n,(({component:t,getComponentProps:l},r)=>{const[n,i]=r.split(".",2),s=n===a?e:n===o?u:null;return c(s)?null:b("td",{key:r},b(t,_(Z({},v(l,s,i)),{store:d,tableId:n,rowId:s,cellId:i})))})))},pe=({thing:e,onThingChange:t,className:l,hasSchema:i})=>{const[c,m]=re(),[h,p]=re(),[g,f]=re(),[w,v]=re(),[y,I]=re();h!==e&&(m((e=>{const t=r(e);return(e=>e==n||e==a)(t)||t==o&&u(e)?t:void 0})(e)),p(e),f(e+""),v(Number(e)||0),I(!!e));const C=te(((e,l)=>{l(e),p(e),t(e)}),[t]);return b("div",{className:l},b("button",{className:c,onClick:te((()=>{if(!(null==i?void 0:i())){const e=U(c,o,a,n),l=U(e,g,w,y);m(e),p(l),t(l)}}),[i,t,g,w,y,c])},c),U(c,b("input",{key:c,value:g,onChange:te((e=>C(e[s][d]+"",f)),[C])}),b("input",{key:c,type:"number",value:w,onChange:te((e=>C(Number(e[s][d]||0),v)),[C])}),b("input",{key:c,type:"checkbox",checked:y,onChange:te((e=>C(!!e[s].checked,I)),[C])})))},ge=({tableId:e,rowId:t,cellId:r,store:n,className:a})=>{var o;return b(pe,{thing:l.useCell(e,t,r,n),onThingChange:l.useSetCellCallback(e,t,r,(e=>e),[],n),className:null!=a?a:ne+"Cell",hasSchema:null==(o=l.useStoreOrStoreById(n))?void 0:o.hasTablesSchema})},fe=({valueId:e,store:t,className:r})=>{var n;return b(pe,{thing:l.useValue(e,t),onThingChange:l.useSetValueCallback(e,(e=>e),[],t),className:null!=r?r:ne+i,hasSchema:null==(n=l.useStoreOrStoreById(t))?void 0:n.hasValuesSchema})},we=({onChange:e,total:l,offset:r=0,limit:n=l,singular:a="row",plural:o=a+"s"})=>{(r>l||r<0)&&(r=0,e(0));const i=oe((()=>e(r-n)),[e,r,n],r>0),s=oe((()=>e(r+n)),[e,r,n],r+n<l);return b(t.Fragment,null,l>n&&b(t.Fragment,null,b("button",{className:"previous",disabled:0==r,onClick:i},"←"),b("button",{className:"next",disabled:r+n>=l,onClick:s},"→"),r+1," to ",Math.min(l,r+n)," of "),l," ",1!=l?o:a)};var ve=Object.defineProperty,ye=(e,t,l)=>(((e,t,l)=>{t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l})(e,"symbol"!=typeof t?t+"":t,l),l);ye(class extends m{constructor(e){super(e),ye(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 Ie=e=>new Map(e);Ie(),Ie(),e.EditableCellView=ge,e.EditableValueView=fe,e.RelationshipInHtmlTable=({relationshipId:e,relationships:r,editable:n,customCells:a,className:o,headerRow:i,idColumn:s=!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=ce([...ae(c,u),...ae(m,u)],a,n?ge:l.CellView),p=ie(s,h,c,m,e,d,u);return b("table",{className:o},!1===i?null:b("thead",null,b("tr",null,!1===s?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,y(l.useRowIds(c,u),(e=>b(be,{key:e,localRowId:e,params:p})))))},e.ResultSortedTableInHtmlTable=e=>{var t=e,{queryId:r,cellId:n,descending:a,offset:o,limit:i,queries:s,sortOnClick:d,paginator:u=!1,customCells:c,onChange:m}=t,h=ee(t,["queryId","cellId","descending","offset","limit","queries","sortOnClick","paginator","customCells","onChange"]);const[p,g,f]=ue(n,a,d,o,i,l.useResultRowCount(r,s),u,m);return b(me,_(Z({},h),{params:ie(ce(l.useResultTableCellIds(r,s),c,l.ResultCellView),de(s,r),l.useResultSortedRowIds(r,...p,i,s),p,g,f)}))},e.ResultTableInHtmlTable=e=>{var t=e,{queryId:r,queries:n,customCells:a}=t,o=ee(t,["queryId","queries","customCells"]);return b(me,_(Z({},o),{params:ie(ce(l.useResultTableCellIds(r,n),a,l.ResultCellView),de(n,r),l.useResultRowIds(r,n))}))},e.SliceInHtmlTable=e=>{var t=e,{indexId:r,sliceId:n,indexes:a,editable:o,customCells:i}=t,s=ee(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(me,_(Z({},s),{params:ie(ce(l.useTableCellIds(c,u),i,o?ge:l.CellView),se(u,c),l.useSliceRowIds(r,n,d))}))},e.SortedTableInHtmlTable=e=>{var t=e,{tableId:r,cellId:n,descending:a,offset:o,limit:i,store:s,editable:d,sortOnClick:u,paginator:c=!1,onChange:m,customCells:h}=t,p=ee(t,["tableId","cellId","descending","offset","limit","store","editable","sortOnClick","paginator","onChange","customCells"]);const[g,f,w]=ue(n,a,u,o,i,l.useRowCount(r,s),c,m);return b(me,_(Z({},p),{params:ie(ce(l.useTableCellIds(r,s),h,d?ge:l.CellView),se(s,r),l.useSortedRowIds(r,...g,i,s),g,f,w)}))},e.SortedTablePaginator=we,e.StoreInspector=e=>null,e.TableInHtmlTable=e=>{var t=e,{tableId:r,store:n,editable:a,customCells:o}=t,i=ee(t,["tableId","store","editable","customCells"]);return b(me,_(Z({},i),{params:ie(ce(l.useTableCellIds(r,n),o,a?ge:l.CellView),se(n,r),l.useRowIds(r,n))}))},e.ValuesInHtmlTable=({store:e,editable:t=!1,valueComponent:r=(t?fe:l.ValueView),getValueComponentProps:n,className:a,headerRow:o,idColumn:s})=>b("table",{className:a},!1===o?null:b("thead",null,b("tr",null,!1===s?null:b("th",null,"Id"),b("th",null,i))),b("tbody",null,y(l.useValueIds(e),(t=>b("tr",{key:t},!1===s?null:b("th",null,t),b("td",null,b(r,_(Z({},v(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 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),y=(e,t)=>e.map(t),I=Object,C=(e=[])=>I.fromEntries(e),k=(e,t)=>y(I.entries(e),(([e,l])=>t(l,e))),x="M20 80l5-15l40-40l10 10l-40 40l-15 5m5-15l10 10",R='content:url("',O=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'>",T='</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=y([[20,20,20,60],[20,20,60,20],[20,60,60,20],[60,20,20,60],[30,30,40,40]],(([e,t,l,r])=>O+`<rect x='20' y='20' width='60' height='60' fill='grey'/><rect x='${e}' y='${t}' width='${l}' height='${r}' fill='white'/>`+T)),V=O+"<path d='M20 20l60 60M20 80l60-60' />"+T,j=O+`<path d='${x}' />`+T,P=O+`<path d='${x}M20 20l60 60' />`+T;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(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;"}),C(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)":S,"header>img:nth-of-type(6)":V}),C(y(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)=>y(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(y(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,y(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(),[y,I]=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),I(!!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,y);m(e),p(l),t(l)}}),[s,t,g,w,y,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:y,onChange:ee((e=>C(!!e[i].checked,I)),[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)};var we=Object.defineProperty,ve=(e,t,l)=>(((e,t,l)=>{t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l})(e,"symbol"!=typeof t?t+"":t,l),l);ve(class extends m{constructor(e){super(e),ve(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 ye=e=>new Map(e);ye(),ye(),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,y(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,y(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);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -213,43 +213,43 @@
213
213
  "devDependencies": {
214
214
  "@automerge/automerge": "^2.1.0-alpha.6",
215
215
  "@babel/cli": "^7.22.10",
216
- "@babel/core": "^7.22.10",
217
- "@babel/preset-env": "^7.22.10",
216
+ "@babel/core": "^7.22.11",
217
+ "@babel/preset-env": "^7.22.14",
218
218
  "@babel/preset-react": "^7.22.5",
219
- "@babel/preset-typescript": "^7.22.5",
219
+ "@babel/preset-typescript": "^7.22.11",
220
220
  "@rollup/plugin-image": "^3.0.2",
221
221
  "@rollup/plugin-replace": "^5.0.2",
222
222
  "@rollup/plugin-terser": "^0.4.3",
223
- "@sqlite.org/sqlite-wasm": "^3.42.0-build7",
223
+ "@sqlite.org/sqlite-wasm": "^3.43.0-build3",
224
224
  "@types/asciichart": "^1.5.6",
225
225
  "@types/expect-puppeteer": "^5.0.3",
226
226
  "@types/http-server": "^0.12.1",
227
227
  "@types/jest": "^29.5.4",
228
228
  "@types/jest-environment-puppeteer": "^5.0.3",
229
- "@types/less": "^3.0.3",
230
- "@types/node": "^20.5.3",
229
+ "@types/less": "^3.0.4",
230
+ "@types/node": "^20.5.7",
231
231
  "@types/puppeteer": "^5.4.7",
232
232
  "@types/react": "^18.2.21",
233
233
  "@types/react-dom": "^18.2.7",
234
234
  "@types/react-test-renderer": "^18.0.0",
235
235
  "@types/tmp": "^0.2.3",
236
- "@typescript-eslint/eslint-plugin": "^6.4.1",
237
- "@typescript-eslint/parser": "^6.4.1",
236
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
237
+ "@typescript-eslint/parser": "^6.5.0",
238
238
  "@vlcn.io/crsqlite-wasm": "^0.14.0",
239
239
  "asciichart": "^1.5.25",
240
240
  "automerge-repo": "^0.1.0",
241
241
  "babel-eslint": "^10.1.0",
242
- "babel-jest": "^29.6.3",
242
+ "babel-jest": "^29.6.4",
243
243
  "babel-plugin-transform-import-meta": "^2.2.1",
244
244
  "babel-preset-minify": "^0.5.2",
245
245
  "buffer-replace": "^1.0.0",
246
246
  "country-flag-emoji-json": "^2.0.0",
247
- "cspell": "^7.0.1",
247
+ "cspell": "^7.2.0",
248
248
  "esbuild": "^0.19.2",
249
- "eslint": "^8.47.0",
249
+ "eslint": "^8.48.0",
250
250
  "eslint-config-prettier": "^9.0.0",
251
251
  "eslint-plugin-jest": "^27.2.3",
252
- "eslint-plugin-jsdoc": "^46.5.0",
252
+ "eslint-plugin-jsdoc": "^46.5.1",
253
253
  "eslint-plugin-react": "7.33.2",
254
254
  "eslint-plugin-react-hooks": "^4.6.0",
255
255
  "expo-sqlite": "^11.5.0",
@@ -257,13 +257,13 @@
257
257
  "gulp": "^4.0.2",
258
258
  "gulp-gzip": "^1.4.2",
259
259
  "http-server": "^14.1.1",
260
- "jest": "^29.6.3",
261
- "jest-environment-jsdom": "^29.6.3",
260
+ "jest": "^29.6.4",
261
+ "jest-environment-jsdom": "^29.6.4",
262
262
  "jest-fetch-mock": "^3.0.3",
263
263
  "jest-puppeteer": "^9.0.0",
264
264
  "less": "^4.2.0",
265
265
  "prettier": "^2.8.8",
266
- "puppeteer": "^21.1.0",
266
+ "puppeteer": "^21.1.1",
267
267
  "react": "^18.2.0",
268
268
  "react-dom": "^18.2.0",
269
269
  "react-test-renderer": "^18.2.0",
@@ -277,7 +277,7 @@
277
277
  "tinydocs": "^0.1.32",
278
278
  "tmp": "^0.2.1",
279
279
  "ts-unused-exports": "^10.0.0",
280
- "typescript": "5.1.6",
280
+ "typescript": "5.2.2",
281
281
  "yjs": "^13.6.7"
282
282
  },
283
283
  "peerDependencies": {