dbnexus 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +1815 -379
- package/dist/cli.js +1 -1
- package/dist/web/assets/{index-DoAn-9yR.js → index-Dc1NWltv.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -34279,7 +34279,7 @@ var ServerRepository = class {
|
|
|
34279
34279
|
};
|
|
34280
34280
|
|
|
34281
34281
|
// apps/cli/dist/version.js
|
|
34282
|
-
var VERSION = true ? "0.4.
|
|
34282
|
+
var VERSION = true ? "0.4.1" : "0.1.10";
|
|
34283
34283
|
|
|
34284
34284
|
// apps/cli/dist/commands/init.js
|
|
34285
34285
|
function loadEnvFile(cwd) {
|
|
@@ -497,7 +497,7 @@ ORDER BY date;`,tags:["window","aggregate","cumulative"]}];function dce(){return
|
|
|
497
497
|
`)})]}),u.sqlStatements.length>0&&r.jsxs(N,{children:[r.jsxs(G,{variant:"subtitle2",sx:{fontWeight:600,mb:1},children:["Executed SQL (",u.sqlStatements.length," statements)"]}),r.jsx(N,{sx:{fontFamily:"monospace",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:300,overflow:"auto",bgcolor:"background.default",p:2,borderRadius:1},children:u.sqlStatements.join(`
|
|
498
498
|
|
|
499
499
|
`)})]})]})}),r.jsx(Yt,{sx:{p:2},children:r.jsx(xe,{onClick:()=>d(null),children:"Close"})})]})]})}function jM(e){return e.toLocaleString()}function kM(e){return e===void 0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function EM(e,t){switch(e){case"query":return r.jsx(El,{sx:{fontSize:18}});case"migration":return r.jsx(Rc,{sx:{fontSize:18}});case"sync":return r.jsx(_o,{sx:{fontSize:18}});case"connection":return t.includes("create")?r.jsx(Hn,{sx:{fontSize:18}}):t.includes("delete")?r.jsx(Bn,{sx:{fontSize:18}}):t.includes("update")?r.jsx(Ir,{sx:{fontSize:18}}):r.jsx(Sn,{sx:{fontSize:18}});default:return r.jsx(No,{sx:{fontSize:18}})}}function qd(e,t){if(t==="error")return"#ef4444";switch(e){case"query":return"#8b5cf6";case"migration":return"#f59e0b";case"sync":return"#22c55e";case"connection":return"#0ea5e9";default:return"#6b7280"}}function oue(){var R,$,z,I,O,A,D;const[e,t]=g.useState(""),[n,o]=g.useState("all"),[s,i]=g.useState("all"),[a,l]=g.useState(null),[u,d]=g.useState(!1),[p,h]=g.useState({items:[]}),{data:m=[],isLoading:y}=mt({queryKey:["queryHistory"],queryFn:()=>Jo.getHistory(void 0,500)}),{data:x=[],isLoading:v}=mt({queryKey:["migrationHistory"],queryFn:()=>kn.getMigrationHistory({limit:500})}),{data:b=[],isLoading:w}=mt({queryKey:["syncRuns"],queryFn:()=>Ws.getSyncRuns(500)}),{data:k=[]}=mt({queryKey:["connections"],queryFn:gr.getAll}),C=y||v||w,j=[...m.map(M=>{var L;return{id:`query-${M.id}`,type:"query",action:"execute",description:M.sql,timestamp:new Date(M.executedAt),status:M.success?"success":"error",details:{connectionId:M.connectionId,connectionName:(L=k.find(F=>F.id===M.connectionId))==null?void 0:L.name,executionTimeMs:M.executionTimeMs,rowCount:M.rowCount,error:M.error}}}),...x.map(M=>({id:`migration-${M.id}`,type:"migration",action:"apply",description:M.description||`Migration from ${M.sourceConnectionName} to ${M.targetConnectionName}`,timestamp:new Date(M.appliedAt),status:M.success?"success":"error",details:{sourceConnection:M.sourceConnectionName,targetConnection:M.targetConnectionName,sourceSchema:M.sourceSchema,targetSchema:M.targetSchema,statementCount:M.sqlStatements.length,error:M.error}})),...b.map(M=>({id:`sync-${M.id}`,type:"sync",action:M.tableName?"table-sync":"schema-sync",description:M.tableName?`Sync ${M.schemaName}.${M.tableName}`:`Sync schema ${M.schemaName||"unknown"}`,timestamp:new Date(M.startedAt),status:M.status==="failed"?"error":M.status==="completed"?"success":"info",details:{sourceConnection:M.sourceConnectionName,targetConnection:M.targetConnectionName,sourceSchema:M.schemaName,targetSchema:M.schemaName,rowCount:M.inserts+M.updates+M.deletes,error:M.errors.length>0?M.errors.join(`
|
|
500
|
-
`):void 0,inserts:M.inserts,updates:M.updates,deletes:M.deletes}}))];j.sort((M,L)=>L.timestamp.getTime()-M.timestamp.getTime());const E=j.filter(M=>{var L,F,_,V,W,q,H,K,ne,X,te;if(n!=="all"&&M.type!==n||s!=="all"&&!(((L=M.details)==null?void 0:L.connectionId)===s||((F=M.details)==null?void 0:F.sourceConnection)===((_=k.find(J=>J.id===s))==null?void 0:_.name)||((V=M.details)==null?void 0:V.targetConnection)===((W=k.find(J=>J.id===s))==null?void 0:W.name)))return!1;if(e){const Z=e.toLowerCase();return M.description.toLowerCase().includes(Z)||M.action.toLowerCase().includes(Z)||M.type.toLowerCase().includes(Z)||((H=(q=M.details)==null?void 0:q.connectionName)==null?void 0:H.toLowerCase().includes(Z))||((ne=(K=M.details)==null?void 0:K.sourceConnection)==null?void 0:ne.toLowerCase().includes(Z))||((te=(X=M.details)==null?void 0:X.targetConnection)==null?void 0:te.toLowerCase().includes(Z))}return!0}),T=[{field:"timestamp",headerName:"Time",width:170,renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:jM(M.value)})},{field:"type",headerName:"Type",width:120,renderCell:M=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(qC,{sx:{width:24,height:24,bgcolor:`${qd(M.row.type,M.row.status)}20`,color:qd(M.row.type,M.row.status)},children:EM(M.row.type,M.row.action)}),r.jsx(ze,{label:M.value,size:"small",sx:{fontSize:10,height:20,textTransform:"capitalize",bgcolor:`${qd(M.row.type,M.row.status)}15`,color:qd(M.row.type,M.row.status)}})]})},{field:"description",headerName:"Description",flex:1,minWidth:300,renderCell:M=>r.jsx(Ge,{title:M.value,placement:"top-start",children:r.jsx(G,{variant:"body2",sx:{fontFamily:M.row.type==="query"?"monospace":"inherit",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.value})})},{field:"connection",headerName:"Connection",width:150,valueGetter:(M,L)=>{var F,_,V;return(F=L.details)!=null&&F.connectionName?L.details.connectionName:(_=L.details)!=null&&_.sourceConnection&&((V=L.details)!=null&&V.targetConnection)?`${L.details.sourceConnection} → ${L.details.targetConnection}`:"-"},renderCell:M=>r.jsx(Ge,{title:M.value,children:r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.value})})},{field:"duration",headerName:"Duration",width:90,valueGetter:(M,L)=>{var F;return(F=L.details)==null?void 0:F.executionTimeMs},renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:M.value&&M.value>1e3?"warning.main":"text.secondary"},children:kM(M.value)})},{field:"rows",headerName:"Rows",width:80,valueGetter:(M,L)=>{var F;return(F=L.details)==null?void 0:F.rowCount},renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:M.value!==void 0?M.value.toLocaleString():"-"})},{field:"status",headerName:"Status",width:90,renderCell:M=>r.jsx(ze,{label:M.value==="error"?"Error":"Success",size:"small",sx:{fontSize:10,height:20,bgcolor:M.value==="error"?"rgba(239, 68, 68, 0.1)":"rgba(34, 197, 94, 0.1)",color:M.value==="error"?"#ef4444":"#22c55e"}})},{field:"actions",headerName:"",width:60,sortable:!1,renderCell:M=>r.jsx(Ge,{title:"View Details",children:r.jsx(_e,{size:"small",onClick:()=>l(M.row),children:r.jsx(Ba,{sx:{fontSize:16}})})})}];return r.jsxs(N,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[r.jsxs(N,{sx:{display:"flex",gap:2,mt:1,mb:2,flexWrap:"wrap",alignItems:"center"},children:[r.jsxs(pn,{size:"small",sx:{minWidth:150},children:[r.jsx(mn,{children:"Type"}),r.jsxs(nn,{value:n,onChange:M=>o(M.target.value),label:"Type",children:[r.jsx(De,{value:"all",children:"All Activity"}),r.jsx(De,{value:"query",children:"Queries"}),r.jsx(De,{value:"migration",children:"Migrations"}),r.jsx(De,{value:"sync",children:"Sync Operations"}),r.jsx(De,{value:"connection",children:"Connections"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,onChange:M=>i(M.target.value),label:"Connection",children:[r.jsx(De,{value:"all",children:"All Connections"}),k.map(M=>r.jsx(De,{value:M.id,children:M.name},M.id))]})]}),r.jsx(wt,{size:"small",placeholder:"Search activity...",value:e,onChange:M=>t(M.target.value),sx:{minWidth:300},InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{sx:{fontSize:16}})})})}}),r.jsx(N,{sx:{flex:1}}),r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsx(ze,{label:`${E.length} activities`,size:"small",color:"primary"})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:T,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:400,width:"100%"},children:r.jsx(Ps,{rows:E,columns:T,loading:C,filterModel:p,onFilterModelChange:h,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}},sorting:{sortModel:[{field:"timestamp",sort:"desc"}]}},disableRowSelectionOnClick:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}}}})}),r.jsxs(qt,{open:!!a,onClose:()=>l(null),maxWidth:"md",fullWidth:!0,children:[r.jsx(Jt,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[a&&r.jsx(qC,{sx:{width:32,height:32,bgcolor:`${qd(a.type,a.status)}20`,color:qd(a.type,a.status)},children:EM(a.type,a.action)}),r.jsxs(G,{variant:"h6",sx:{textTransform:"capitalize"},children:[a==null?void 0:a.type," Details"]})]})}),r.jsx(Xt,{children:a&&r.jsxs(N,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[r.jsxs(N,{sx:{display:"flex",gap:3,flexWrap:"wrap"},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Time"}),r.jsx(G,{variant:"body2",children:jM(a.timestamp)})]}),((R=a.details)==null?void 0:R.connectionName)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Connection"}),r.jsx(G,{variant:"body2",children:a.details.connectionName})]}),(($=a.details)==null?void 0:$.sourceConnection)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Source"}),r.jsxs(G,{variant:"body2",children:[a.details.sourceConnection,a.details.sourceSchema&&`.${a.details.sourceSchema}`]})]}),((z=a.details)==null?void 0:z.targetConnection)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Target"}),r.jsxs(G,{variant:"body2",children:[a.details.targetConnection,a.details.targetSchema&&`.${a.details.targetSchema}`]})]}),((I=a.details)==null?void 0:I.executionTimeMs)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Duration"}),r.jsx(G,{variant:"body2",children:kM(a.details.executionTimeMs)})]}),((O=a.details)==null?void 0:O.rowCount)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Rows"}),r.jsx(G,{variant:"body2",children:a.details.rowCount.toLocaleString()})]}),((A=a.details)==null?void 0:A.statementCount)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Statements"}),r.jsx(G,{variant:"body2",children:a.details.statementCount})]}),r.jsx(ze,{label:a.status==="error"?"Error":"Success",size:"small",sx:{alignSelf:"center",bgcolor:a.status==="error"?"rgba(239, 68, 68, 0.1)":"rgba(34, 197, 94, 0.1)",color:a.status==="error"?"#ef4444":"#22c55e"}})]}),a.status==="error"&&((D=a.details)==null?void 0:D.error)&&r.jsxs(Dt,{severity:"error",sx:{"& .MuiAlert-message":{width:"100%"}},children:[r.jsx(G,{variant:"subtitle2",sx:{fontWeight:600,mb:1},children:"Error Details"}),r.jsx(N,{sx:{fontFamily:"monospace",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:200,overflow:"auto",bgcolor:"rgba(0,0,0,0.1)",p:1.5,borderRadius:1},children:a.details.error})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:a.type==="query"?"SQL Query":"Description"}),r.jsx(N,{sx:{p:2,bgcolor:"background.default",borderRadius:1,fontFamily:a.type==="query"?"monospace":"inherit",fontSize:13,whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:300,overflow:"auto"},children:a.description})]})]})}),r.jsx(Yt,{sx:{p:2},children:r.jsx(xe,{onClick:()=>l(null),children:"Close"})})]})]})}function IM(e){return new Date(e).toLocaleString()}function sue(e){return e.includes("created")?r.jsx(Hn,{sx:{fontSize:18}}):e.includes("updated")?r.jsx(Ir,{sx:{fontSize:18}}):e.includes("deleted")?r.jsx(Bn,{sx:{fontSize:18}}):r.jsx(No,{sx:{fontSize:18}})}function PM(e){return e.includes("created")?"#22c55e":e.includes("updated")?"#f59e0b":e.includes("deleted")?"#ef4444":"#6b7280"}function iue(e){switch(e){case"connection":return r.jsx(Sn,{sx:{fontSize:18}});case"project":return r.jsx(im,{sx:{fontSize:18}});case"database_group":return r.jsx(Mie,{sx:{fontSize:18}});case"table":return r.jsx(ro,{sx:{fontSize:18}});case"column":return r.jsx(Bie,{sx:{fontSize:18}});default:return r.jsx(No,{sx:{fontSize:18}})}}function aue(){const[e,t]=g.useState(""),[n,o]=g.useState("all"),[s,i]=g.useState("all"),[a,l]=g.useState(null),[u,d]=g.useState(!1),[p,h]=g.useState({items:[]}),{data:m=[],isLoading:y}=mt({queryKey:["auditLogs"],queryFn:()=>BQ.getLogs({limit:500})}),{data:x=[]}=mt({queryKey:["connections"],queryFn:gr.getAll}),v=m.filter(w=>{var k;if(n!=="all"&&w.entityType!==n||s!=="all"&&w.connectionId!==s)return!1;if(e){const C=e.toLowerCase();return w.action.toLowerCase().includes(C)||w.entityType.toLowerCase().includes(C)||((k=w.connectionName)==null?void 0:k.toLowerCase().includes(C))||JSON.stringify(w.details).toLowerCase().includes(C)}return!0}),b=[{field:"createdAt",headerName:"Time",width:170,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:IM(w.value)})},{field:"action",headerName:"Action",width:200,renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(N,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"50%",bgcolor:`${PM(w.value)}20`,color:PM(w.value)},children:sue(w.value)}),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value.replace(/_/g," ").replace(/\b\w/g,k=>k.toUpperCase())})]})},{field:"entityType",headerName:"Entity Type",width:150,renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[iue(w.value),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value.replace(/_/g," ").replace(/\b\w/g,k=>k.toUpperCase())})]})},{field:"details",headerName:"Details",flex:1,renderCell:w=>{const k=w.value,C=(k==null?void 0:k.name)||(k==null?void 0:k.tableName)||(k==null?void 0:k.columnName)||"N/A";return r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(C)})}},{field:"connectionName",headerName:"Connection",width:150,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value||"-"})},{field:"actions",headerName:"Actions",width:80,sortable:!1,renderCell:w=>r.jsx(Ge,{title:"View Details",children:r.jsx(_e,{size:"small",onClick:()=>l(w.row),children:r.jsx(fs,{fontSize:"small"})})})}];return r.jsxs(N,{sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:0},children:[r.jsxs(N,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1,mb:2},children:[r.jsx(wt,{size:"small",placeholder:"Search audit logs...",value:e,onChange:w=>t(w.target.value),sx:{minWidth:300},InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{fontSize:"small"})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{fontSize:"small"})})})}}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Entity Type"}),r.jsxs(nn,{value:n,label:"Entity Type",onChange:w=>o(w.target.value),children:[r.jsx(De,{value:"all",children:"All Types"}),r.jsx(De,{value:"connection",children:"Connection"}),r.jsx(De,{value:"project",children:"Project"}),r.jsx(De,{value:"database_group",children:"Database Group"}),r.jsx(De,{value:"table",children:"Table"}),r.jsx(De,{value:"column",children:"Column"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:200},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,label:"Connection",onChange:w=>i(w.target.value),children:[r.jsx(De,{value:"all",children:"All Connections"}),x.map(w=>r.jsx(De,{value:w.id,children:w.name},w.id))]})]}),r.jsxs(N,{sx:{ml:"auto",display:"flex",gap:1,alignItems:"center"},children:[r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsx(ze,{label:`${v.length} events`,size:"small",color:"primary"})]})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:b,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:0,display:"flex",justifyContent:"center",alignItems:"center"},children:r.jsx(N,{sx:{width:"100%",height:"100%"},children:r.jsx(Ps,{rows:v,columns:b,loading:y,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}}},filterModel:p,onFilterModelChange:h,disableRowSelectionOnClick:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}},"& .MuiDataGrid-columnHeader":{display:"flex",alignItems:"center"},"& .MuiDataGrid-columnHeaderTitle":{textAlign:"center",width:"100%"}}})})}),r.jsxs(qt,{open:!!a,onClose:()=>l(null),maxWidth:"md",fullWidth:!0,children:[r.jsx(Jt,{children:"Audit Log Details"}),r.jsx(Xt,{children:a&&r.jsxs(N,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Time"}),r.jsx(G,{variant:"body2",children:IM(a.createdAt)})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Action"}),r.jsx(G,{variant:"body2",children:a.action.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase())})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Entity Type"}),r.jsx(G,{variant:"body2",children:a.entityType.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase())})]}),a.connectionName&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Connection"}),r.jsx(G,{variant:"body2",children:a.connectionName})]}),a.details&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Details"}),r.jsx(Dt,{severity:"info",sx:{mt:1},children:r.jsx("pre",{style:{margin:0,fontSize:"12px",whiteSpace:"pre-wrap"},children:JSON.stringify(a.details,null,2)})})]})]})}),r.jsx(Yt,{children:r.jsx(xe,{onClick:()=>l(null),children:"Close"})})]})]})}function lue(e){return e.toLocaleString()}function cue(e){return e===void 0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function uue(e){return e===void 0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function due(e){switch(e){case"backup_created":return r.jsx(zw,{sx:{fontSize:16}});case"backup_restored":return r.jsx(cO,{sx:{fontSize:16}});case"backup_deleted":return r.jsx(Bn,{sx:{fontSize:16}});case"backup_uploaded":return r.jsx(dO,{sx:{fontSize:16}});default:return r.jsx(Sn,{sx:{fontSize:16}})}}function fue(e){switch(e){case"backup_created":return"Created";case"backup_restored":return"Restored";case"backup_deleted":return"Deleted";case"backup_uploaded":return"Uploaded";default:return e}}function pue(e){switch(e){case"backup_created":return"#22c55e";case"backup_restored":return"#3b82f6";case"backup_deleted":return"#ef4444";case"backup_uploaded":return"#8b5cf6";default:return"#6b7280"}}function hue(){const[e,t]=g.useState(""),[n,o]=g.useState("all"),[s,i]=g.useState("all"),[a,l]=g.useState("all"),[u,d]=g.useState(!1),[p,h]=g.useState({items:[]}),{data:m=[],isLoading:y}=mt({queryKey:["backupLogs"],queryFn:()=>xi.getLogs({limit:500})}),{data:x=[]}=mt({queryKey:["connections"],queryFn:gr.getAll}),v=m.filter(w=>{var k,C,j,E;if(n!=="all"&&w.operation!==n||s!=="all"&&w.connectionId!==s||a!=="all"&&w.status!==a)return!1;if(e){const T=e.toLowerCase();return((k=w.databaseName)==null?void 0:k.toLowerCase().includes(T))||((C=w.connectionName)==null?void 0:C.toLowerCase().includes(T))||((j=w.backupFilename)==null?void 0:j.toLowerCase().includes(T))||((E=w.databaseEngine)==null?void 0:E.toLowerCase().includes(T))}return!0}),b=[{field:"createdAt",headerName:"Time",width:170,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:lue(new Date(w.row.createdAt))})},{field:"operation",headerName:"Operation",width:130,valueGetter:(w,k)=>fue(k.operation),renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(N,{sx:{color:pue(w.row.operation)},children:due(w.row.operation)}),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value})]})},{field:"connectionName",headerName:"Connection",width:180,valueGetter:(w,k)=>k.connectionName||k.databaseName,renderCell:w=>r.jsx(Ge,{title:w.value,children:r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value})})},{field:"backupFilename",headerName:"Backup File",flex:1,minWidth:250,renderCell:w=>r.jsx(Ge,{title:w.value||"-",children:r.jsx(G,{variant:"body2",sx:{fontSize:12,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value||"-"})})},{field:"databaseEngine",headerName:"Engine",width:100,renderCell:w=>r.jsx(ze,{label:w.value,size:"small",sx:{fontSize:10,height:20,textTransform:"uppercase",bgcolor:"rgba(99, 102, 241, 0.1)",color:"#6366f1"}})},{field:"fileSize",headerName:"Size",width:100,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:"text.secondary"},children:uue(w.value)})},{field:"duration",headerName:"Duration",width:100,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:"text.secondary"},children:cue(w.value)})},{field:"status",headerName:"Status",width:100,renderCell:w=>r.jsx(ze,{label:w.value,size:"small",sx:{fontSize:10,height:20,textTransform:"capitalize",bgcolor:w.value==="success"?"rgba(34, 197, 94, 0.1)":"rgba(239, 68, 68, 0.1)",color:w.value==="success"?"#22c55e":"#ef4444"}})}];return r.jsxs(N,{sx:{height:"100%",width:"100%",display:"flex",flexDirection:"column"},children:[r.jsxs(N,{sx:{display:"flex",gap:2,mt:1,mb:2,flexWrap:"wrap",alignItems:"center"},children:[r.jsxs(pn,{size:"small",sx:{minWidth:140},children:[r.jsx(mn,{children:"Operation"}),r.jsxs(nn,{value:n,onChange:w=>o(w.target.value),label:"Operation",children:[r.jsx(De,{value:"all",children:"All Operations"}),r.jsx(De,{value:"backup_created",children:"Created"}),r.jsx(De,{value:"backup_restored",children:"Restored"}),r.jsx(De,{value:"backup_deleted",children:"Deleted"}),r.jsx(De,{value:"backup_uploaded",children:"Uploaded"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,onChange:w=>i(w.target.value),label:"Connection",children:[r.jsx(De,{value:"all",children:"All Connections"}),x.map(w=>r.jsx(De,{value:w.id,children:w.name},w.id))]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:120},children:[r.jsx(mn,{children:"Status"}),r.jsxs(nn,{value:a,onChange:w=>l(w.target.value),label:"Status",children:[r.jsx(De,{value:"all",children:"All"}),r.jsx(De,{value:"success",children:"Success"}),r.jsx(De,{value:"failed",children:"Failed"})]})]}),r.jsx(wt,{size:"small",placeholder:"Search by database, connection, or file...",value:e,onChange:w=>t(w.target.value),sx:{minWidth:300},slotProps:{input:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{sx:{fontSize:16}})})})}}}),r.jsx(N,{sx:{flex:1}}),r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsxs(G,{variant:"body2",color:"text.secondary",children:[v.length," backup operations"]})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:b,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:400},children:r.jsx(Ps,{rows:v,columns:b,filterModel:p,onFilterModelChange:h,loading:y,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}},sorting:{sortModel:[{field:"createdAt",sort:"desc"}]}},disableRowSelectionOnClick:!0,disableColumnMenu:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderBottom:"1px solid",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}},"& .MuiDataGrid-columnHeaders":{borderBottom:"1px solid",borderColor:"divider"}}})})]})}function Kd({children:e,value:t,index:n}){return r.jsx(N,{role:"tabpanel",hidden:t!==n,sx:{flex:1,display:t===n?"flex":"none",flexDirection:"column",overflow:"hidden"},children:t===n&&e})}const BO=["query-history","migrations","data-sync","activity","audit-logs","backups"];function TM(e){const t=BO.indexOf(e);return t>=0?t:0}function mue(){const[e,t]=Oc(),n=e.get("tab"),[o,s]=g.useState(n?TM(n):0),{data:i=[],isLoading:a}=mt({queryKey:["connections"],queryFn:gr.getAll});return g.useEffect(()=>{const l=BO[o];l&&t({tab:l},{replace:!0})},[o,t]),g.useEffect(()=>{if(n){const l=TM(n);l!==o&&s(l)}},[n]),!a&&i.length===0?r.jsx(Tc,{to:"/dashboard",replace:!0}):r.jsxs(N,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsxs(N,{sx:{mb:3},children:[r.jsx(G,{variant:"h5",fontWeight:600,gutterBottom:!0,children:"Logs & History"}),r.jsx(G,{variant:"body2",color:"text.secondary",children:"Review query history, migrations, and system activity"})]}),r.jsxs(An,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsxs(ei,{value:o,onChange:(l,u)=>s(u),sx:{borderBottom:1,borderColor:"divider",minHeight:48,"& .MuiTab-root":{minHeight:48,textTransform:"none"}},children:[r.jsx(Cn,{icon:r.jsx(Wu,{sx:{fontSize:18}}),iconPosition:"start",label:"Query History","data-tour":"query-history"}),r.jsx(Cn,{icon:r.jsx(Rc,{sx:{fontSize:18}}),iconPosition:"start",label:"Migrations"}),r.jsx(Cn,{icon:r.jsx(_o,{sx:{fontSize:18}}),iconPosition:"start",label:"Data Sync"}),r.jsx(Cn,{icon:r.jsx(_ie,{sx:{fontSize:18}}),iconPosition:"start",label:"Activity"}),r.jsx(Cn,{icon:r.jsx(lj,{sx:{fontSize:18}}),iconPosition:"start",label:"Audit Logs"}),r.jsx(Cn,{icon:r.jsx(zw,{sx:{fontSize:18}}),iconPosition:"start",label:"Backup & Restore"})]}),r.jsxs(N,{sx:{flex:1,p:2,pt:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[r.jsx(Kd,{value:o,index:0,children:r.jsx(tue,{})}),r.jsx(Kd,{value:o,index:1,children:r.jsx(nue,{})}),r.jsx(Kd,{value:o,index:2,children:r.jsx(rue,{})}),r.jsx(Kd,{value:o,index:3,children:r.jsx(oue,{})}),r.jsx(Kd,{value:o,index:4,children:r.jsx(aue,{})}),r.jsx(Kd,{value:o,index:5,children:r.jsx(hue,{})})]})]})]})}function HO({label:e,value:t,onChange:n,colors:o}){return r.jsxs(N,{children:[r.jsx(G,{variant:"caption",sx:{color:"text.secondary",mb:1,display:"block"},children:e}),r.jsx(up,{value:t,exclusive:!0,onChange:(s,i)=>i&&n(i),size:"small",sx:{gap:.5,flexWrap:"wrap"},children:Object.entries(o).map(([s,i])=>r.jsx(Es,{value:i,title:s,sx:{width:24,height:24,borderRadius:.5,bgcolor:`rgba(${i}, 0.4)`,border:`1px solid rgba(${i}, 0.6)`,"&.Mui-selected":{bgcolor:`rgba(${i}, 0.6)`,border:`2px solid rgba(${i}, 1)`},"&:hover":{bgcolor:`rgba(${i}, 0.5)`}}},s))})]})}const gue={teal:"Teal",indigo:"Indigo",violet:"Violet",blue:"Blue",emerald:"Emerald",rose:"Rose",lightblue:"Light Blue",orange:"Orange",githubGreen:"Green"};function xue(){const{getMode:e,toggleMode:t}=zb(),n=e(),{colorScheme:o,setColorScheme:s}=dw();return r.jsxs(r.Fragment,{children:[r.jsx(_t,{sx:{mb:3},children:r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Theme"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:"Choose between light and dark mode"})]}),r.jsxs(up,{value:n,exclusive:!0,onChange:(i,a)=>a&&t(),size:"small",children:[r.jsxs(Es,{value:"light",sx:{px:2,"&.Mui-selected":{bgcolor:"primary.main",color:"primary.contrastText","&:hover":{bgcolor:"primary.dark"}}},children:[r.jsx($ie,{sx:{mr:1,fontSize:18}}),"Light"]}),r.jsxs(Es,{value:"dark",sx:{px:2,"&.Mui-selected":{bgcolor:"primary.main",color:"primary.contrastText","&:hover":{bgcolor:"primary.dark"}}},children:[r.jsx(Eie,{sx:{mr:1,fontSize:18}}),"Dark"]})]})]})}),r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Accent Color"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:"Choose your preferred color scheme"})]}),r.jsx(N,{sx:{display:"flex",gap:1.5,flexWrap:"wrap",mb:3},children:Object.keys(tm).map(i=>{const a=tm[i],l=o===i;return r.jsxs(N,{onClick:()=>s(i),sx:{width:72,height:72,borderRadius:1,bgcolor:l?`${a.primary}20`:"action.hover",border:2,borderColor:l?a.primary:"transparent",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:.5,transition:"all 0.15s","&:hover":{borderColor:a.primary,bgcolor:`${a.primary}15`}},children:[r.jsx(N,{sx:{width:24,height:24,borderRadius:"50%",background:`linear-gradient(135deg, ${a.primaryLight} 0%, ${a.primary} 100%)`}}),r.jsx(G,{variant:"caption",sx:{color:l?a.primary:"text.secondary",fontWeight:l?600:400,fontSize:11,textAlign:"center"},children:gue[i]})]},i)})})]})]})}function yue({tag:e,onUpdate:t,onDelete:n}){const[o,s]=g.useState(!1),[i,a]=g.useState(e.name),[l,u]=g.useState(e.color),d=()=>{i.trim()&&(t({name:i.trim(),color:l}),s(!1))},p=()=>{a(e.name),u(e.color),s(!1)};return o?r.jsxs(N,{sx:{display:"flex",alignItems:"flex-start",gap:2,py:2,borderBottom:1,borderColor:"divider"},children:[r.jsxs(N,{sx:{flex:1},children:[r.jsx(wt,{size:"small",value:i,onChange:h=>a(h.target.value),placeholder:"Tag name",autoFocus:!0,sx:{mb:1.5},fullWidth:!0}),r.jsx(HO,{label:"Color",value:l,onChange:u,colors:Th})]}),r.jsxs(N,{sx:{display:"flex",gap:.5,pt:.5},children:[r.jsx(_e,{size:"small",onClick:d,sx:{color:"success.main","&:hover":{bgcolor:"action.hover"}},children:r.jsx(la,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:p,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:r.jsx(Ga,{fontSize:"small"})})]})]}):r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,borderBottom:1,borderColor:"divider"},children:[r.jsx(ze,{label:e.name,size:"small",sx:{bgcolor:`rgba(${e.color}, 0.15)`,color:`rgb(${e.color})`,border:`1px solid rgba(${e.color}, 0.3)`,borderRadius:"16px",fontWeight:500}}),r.jsx(N,{sx:{flex:1}}),r.jsx(_e,{size:"small",onClick:()=>s(!0),sx:{color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"}},children:r.jsx(Ir,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:n,sx:{color:"text.secondary","&:hover":{color:"error.main",bgcolor:"action.hover"}},children:r.jsx(Bn,{fontSize:"small"})})]})}function bue(){const{tags:e,addTag:t,updateTag:n,deleteTag:o}=dp(),[s,i]=g.useState(!1),[a,l]=g.useState(""),[u,d]=g.useState(Th.blue),p=()=>{a.trim()&&(t({name:a.trim(),color:u}),l(""),d(Th.blue),i(!1))},h=()=>{l(""),d(Th.blue),i(!1)};return r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[r.jsx(Rie,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Tags"})]}),r.jsx(N,{sx:{display:"flex",gap:1},children:!s&&r.jsx(xe,{size:"small",startIcon:r.jsx(Hn,{}),onClick:()=>i(!0),sx:{color:"primary.main",textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Add tag"})})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Tags help you organize and categorize your database connections."}),s&&r.jsxs(N,{sx:{display:"flex",alignItems:"flex-start",gap:2,py:2,mb:2,borderBottom:1,borderColor:"divider",bgcolor:m=>m.palette.mode==="dark"?"rgba(34, 197, 94, 0.05)":"rgba(34, 197, 94, 0.08)",mx:-2.5,px:2.5},children:[r.jsxs(N,{sx:{flex:1},children:[r.jsx(wt,{size:"small",value:a,onChange:m=>l(m.target.value),placeholder:"New tag name",autoFocus:!0,onKeyDown:m=>{m.key==="Enter"&&p(),m.key==="Escape"&&h()},sx:{mb:1.5},fullWidth:!0}),r.jsx(HO,{label:"Color",value:u,onChange:d,colors:Th})]}),r.jsxs(N,{sx:{display:"flex",gap:.5,pt:.5},children:[r.jsx(_e,{size:"small",onClick:p,disabled:!a.trim(),sx:{color:"success.main","&:hover":{bgcolor:"action.hover"}},children:r.jsx(la,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:h,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:r.jsx(Ga,{fontSize:"small"})})]})]}),e.length===0?r.jsx(N,{sx:{py:4,textAlign:"center"},children:r.jsx(G,{variant:"body2",sx:{color:"text.secondary"},children:"No tags yet. Add your first tag to get started."})}):r.jsx(N,{children:e.map(m=>r.jsx(yue,{tag:m,onUpdate:y=>n(m.id,y),onDelete:()=>o(m.id)},m.id))}),r.jsxs(N,{sx:{mt:4,pt:3,borderTop:"1px solid rgba(255,255,255,0.1)"},children:[r.jsx(G,{variant:"subtitle2",sx:{color:"rgba(255,255,255,0.5)",mb:2},children:"Preview"}),r.jsx(N,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:e.map(m=>r.jsx(ze,{label:m.name,size:"small",sx:{bgcolor:`rgba(${m.color}, 0.15)`,color:`rgb(${m.color})`,border:`1px solid rgba(${m.color}, 0.3)`,borderRadius:"16px",fontWeight:500}},m.id))})]})]})}function vue(){return r.jsxs(r.Fragment,{children:[r.jsx(xue,{}),r.jsx(bue,{})]})}function Cue(){const e="0.4.0",[t,n]=g.useState(!1),[o,s]=g.useState(!1),i=En(p=>p.success),a=En(p=>p.error),l="bc1qhrg37apup3dkdmxmmy2kt0xcrufxjekxnd7x9jm3k0lv5lyzyrjqecryqh",u=`https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=bitcoin:${l}`,d=async()=>{try{await navigator.clipboard.writeText(l),s(!0),i("Bitcoin address copied to clipboard"),setTimeout(()=>s(!1),2e3)}catch{a("Failed to copy address")}};return r.jsxs(r.Fragment,{children:[r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(Qm,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"About DB Nexus"})]}),r.jsxs(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:["A ",r.jsx("strong",{children:"local-first"})," database management tool designed for speed, safety, and clarity. DB Nexus brings together query editing, schema visualization, data synchronization, and production safety guardrails in one modern experience."]}),r.jsxs(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:["Works seamlessly with ",r.jsx("strong",{children:"PostgreSQL, MySQL, and SQLite"})," — everything runs locally, giving you full control over your data and infrastructure."]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Open source and designed for database administrators and developers who value both power and usability."}),r.jsxs(G,{variant:"caption",sx:{color:"text.disabled"},children:["Version ",e]})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Contact & Support"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"For questions, feedback, or support:"}),r.jsx(xe,{variant:"outlined",startIcon:r.jsx(tb,{}),href:"mailto:admin@dbnexus.dev",sx:{textTransform:"none",borderColor:"divider",color:"text.primary","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"admin@dbnexus.dev"})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Support Development"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"If DB Nexus helps you, consider supporting its development."}),r.jsx(xe,{variant:"outlined",startIcon:r.jsx(N,{component:"img",src:"/Bitcoin.svg.webp",alt:"Bitcoin",sx:{width:20,height:20}}),onClick:()=>n(!0),sx:{textTransform:"none","&:hover":{bgcolor:"action.hover",borderColor:"primary.main",color:"primary.main"}},children:"Donate Bitcoin"})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Resources"}),r.jsxs(N,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[r.jsx(xe,{variant:"outlined",href:"https://github.com/akademskig/dbnexus",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"⭐ Star on GitHub"}),r.jsx(xe,{variant:"outlined",href:"https://docs.dbnexus.dev",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Documentation"}),r.jsx(xe,{variant:"outlined",href:"https://github.com/akademskig/dbnexus/issues",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Report Issue"})]})]}),r.jsxs(_t,{children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"License & Credits"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"DB Nexus is open source software."}),r.jsxs(G,{variant:"caption",sx:{color:"text.disabled"},children:["© ",new Date().getFullYear()," DB Nexus. All rights reserved."]})]}),r.jsxs(qt,{open:t,onClose:()=>n(!1),maxWidth:"xs",fullWidth:!0,children:[r.jsx(Jt,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[r.jsx(N,{component:"img",src:"/Bitcoin.svg.webp",alt:"Bitcoin",sx:{width:28,height:28}}),r.jsx(G,{variant:"h6",children:"Donate Bitcoin"})]})}),r.jsx(Xt,{children:r.jsxs(N,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[r.jsx(G,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Support DB Nexus development"}),r.jsx(N,{component:"img",src:u,alt:"Bitcoin QR Code",sx:{width:200,height:200,border:1,borderColor:"divider",borderRadius:1,p:1,bgcolor:"white"}}),r.jsxs(N,{sx:{width:"100%"},children:[r.jsx(G,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Bitcoin Address:"}),r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1,p:1.2,borderRadius:1,border:1.5,borderColor:"divider","&:hover":{borderColor:"primary.main"}},children:[r.jsx(G,{variant:"body2",sx:{flex:1,wordBreak:"break-all",fontFamily:"monospace",fontSize:11},children:l}),r.jsx(_e,{size:"small",onClick:d,sx:{color:o?"success.main":"primary.main"},children:o?r.jsx(la,{}):r.jsx(go,{})})]})]})]})}),r.jsx(Yt,{sx:{px:2,pb:2},children:r.jsx(xe,{onClick:()=>n(!1),children:"Close"})})]})]})}function Sue(){const e=S1.filter(s=>s.category==="query"),t=S1.filter(s=>s.category==="navigation"),n=S1.filter(s=>s.category==="general"),o=({title:s,shortcuts:i})=>r.jsxs(N,{sx:{mb:4},children:[r.jsx(G,{variant:"subtitle2",sx:{color:"text.secondary",mb:1.5,textTransform:"uppercase",fontSize:11,letterSpacing:"0.05em"},children:s}),r.jsx(Ks,{children:r.jsxs(Us,{size:"small",children:[r.jsx(Qs,{children:r.jsxs(ir,{children:[r.jsx(Ve,{sx:{fontWeight:600,width:150},children:"Shortcut"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Action"})]})}),r.jsx(qs,{children:i.map((a,l)=>r.jsxs(ir,{sx:{"&:last-child td":{borderBottom:0}},children:[r.jsx(Ve,{children:r.jsx(N,{sx:{display:"inline-flex",gap:.5,fontFamily:"monospace",fontSize:12},children:HQ(a).split("+").map((u,d)=>r.jsx(N,{component:"kbd",sx:{px:1,py:.25,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:.5,fontSize:11,fontWeight:600,minWidth:24,textAlign:"center"},children:u},d))})}),r.jsx(Ve,{children:r.jsx(G,{variant:"body2",children:a.description})})]},l))})]})})]});return r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(aO,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Keyboard Shortcuts"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:4},children:"Use these keyboard shortcuts to navigate and work faster. On Mac, use ⌘ (Command) instead of Ctrl."}),r.jsx(o,{title:"Query Editor",shortcuts:e}),r.jsx(o,{title:"Navigation",shortcuts:t}),r.jsx(o,{title:"General",shortcuts:n})]})}function wue(){const e=En(),t=lr(),[n,o]=g.useState(!1),{data:s,isLoading:i}=mt({queryKey:["backup-tools-status"],queryFn:()=>xi.checkTools()}),a=fn({mutationFn:()=>xi.installTools(),onSuccess:d=>{d.success?(e.success(d.message),t.invalidateQueries({queryKey:["backup-tools-status"]})):e.error(d.message)},onError:d=>{e.error(`Installation failed: ${d.message}`)}}),l=()=>{if(!(s!=null&&s.instructions))return;const d=s.instructions.instructions.filter(p=>p.trim()&&!p.includes(":")).join(`
|
|
500
|
+
`):void 0,inserts:M.inserts,updates:M.updates,deletes:M.deletes}}))];j.sort((M,L)=>L.timestamp.getTime()-M.timestamp.getTime());const E=j.filter(M=>{var L,F,_,V,W,q,H,K,ne,X,te;if(n!=="all"&&M.type!==n||s!=="all"&&!(((L=M.details)==null?void 0:L.connectionId)===s||((F=M.details)==null?void 0:F.sourceConnection)===((_=k.find(J=>J.id===s))==null?void 0:_.name)||((V=M.details)==null?void 0:V.targetConnection)===((W=k.find(J=>J.id===s))==null?void 0:W.name)))return!1;if(e){const Z=e.toLowerCase();return M.description.toLowerCase().includes(Z)||M.action.toLowerCase().includes(Z)||M.type.toLowerCase().includes(Z)||((H=(q=M.details)==null?void 0:q.connectionName)==null?void 0:H.toLowerCase().includes(Z))||((ne=(K=M.details)==null?void 0:K.sourceConnection)==null?void 0:ne.toLowerCase().includes(Z))||((te=(X=M.details)==null?void 0:X.targetConnection)==null?void 0:te.toLowerCase().includes(Z))}return!0}),T=[{field:"timestamp",headerName:"Time",width:170,renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:jM(M.value)})},{field:"type",headerName:"Type",width:120,renderCell:M=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(qC,{sx:{width:24,height:24,bgcolor:`${qd(M.row.type,M.row.status)}20`,color:qd(M.row.type,M.row.status)},children:EM(M.row.type,M.row.action)}),r.jsx(ze,{label:M.value,size:"small",sx:{fontSize:10,height:20,textTransform:"capitalize",bgcolor:`${qd(M.row.type,M.row.status)}15`,color:qd(M.row.type,M.row.status)}})]})},{field:"description",headerName:"Description",flex:1,minWidth:300,renderCell:M=>r.jsx(Ge,{title:M.value,placement:"top-start",children:r.jsx(G,{variant:"body2",sx:{fontFamily:M.row.type==="query"?"monospace":"inherit",fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.value})})},{field:"connection",headerName:"Connection",width:150,valueGetter:(M,L)=>{var F,_,V;return(F=L.details)!=null&&F.connectionName?L.details.connectionName:(_=L.details)!=null&&_.sourceConnection&&((V=L.details)!=null&&V.targetConnection)?`${L.details.sourceConnection} → ${L.details.targetConnection}`:"-"},renderCell:M=>r.jsx(Ge,{title:M.value,children:r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.value})})},{field:"duration",headerName:"Duration",width:90,valueGetter:(M,L)=>{var F;return(F=L.details)==null?void 0:F.executionTimeMs},renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:M.value&&M.value>1e3?"warning.main":"text.secondary"},children:kM(M.value)})},{field:"rows",headerName:"Rows",width:80,valueGetter:(M,L)=>{var F;return(F=L.details)==null?void 0:F.rowCount},renderCell:M=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:M.value!==void 0?M.value.toLocaleString():"-"})},{field:"status",headerName:"Status",width:90,renderCell:M=>r.jsx(ze,{label:M.value==="error"?"Error":"Success",size:"small",sx:{fontSize:10,height:20,bgcolor:M.value==="error"?"rgba(239, 68, 68, 0.1)":"rgba(34, 197, 94, 0.1)",color:M.value==="error"?"#ef4444":"#22c55e"}})},{field:"actions",headerName:"",width:60,sortable:!1,renderCell:M=>r.jsx(Ge,{title:"View Details",children:r.jsx(_e,{size:"small",onClick:()=>l(M.row),children:r.jsx(Ba,{sx:{fontSize:16}})})})}];return r.jsxs(N,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[r.jsxs(N,{sx:{display:"flex",gap:2,mt:1,mb:2,flexWrap:"wrap",alignItems:"center"},children:[r.jsxs(pn,{size:"small",sx:{minWidth:150},children:[r.jsx(mn,{children:"Type"}),r.jsxs(nn,{value:n,onChange:M=>o(M.target.value),label:"Type",children:[r.jsx(De,{value:"all",children:"All Activity"}),r.jsx(De,{value:"query",children:"Queries"}),r.jsx(De,{value:"migration",children:"Migrations"}),r.jsx(De,{value:"sync",children:"Sync Operations"}),r.jsx(De,{value:"connection",children:"Connections"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,onChange:M=>i(M.target.value),label:"Connection",children:[r.jsx(De,{value:"all",children:"All Connections"}),k.map(M=>r.jsx(De,{value:M.id,children:M.name},M.id))]})]}),r.jsx(wt,{size:"small",placeholder:"Search activity...",value:e,onChange:M=>t(M.target.value),sx:{minWidth:300},InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{sx:{fontSize:16}})})})}}),r.jsx(N,{sx:{flex:1}}),r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsx(ze,{label:`${E.length} activities`,size:"small",color:"primary"})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:T,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:400,width:"100%"},children:r.jsx(Ps,{rows:E,columns:T,loading:C,filterModel:p,onFilterModelChange:h,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}},sorting:{sortModel:[{field:"timestamp",sort:"desc"}]}},disableRowSelectionOnClick:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}}}})}),r.jsxs(qt,{open:!!a,onClose:()=>l(null),maxWidth:"md",fullWidth:!0,children:[r.jsx(Jt,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[a&&r.jsx(qC,{sx:{width:32,height:32,bgcolor:`${qd(a.type,a.status)}20`,color:qd(a.type,a.status)},children:EM(a.type,a.action)}),r.jsxs(G,{variant:"h6",sx:{textTransform:"capitalize"},children:[a==null?void 0:a.type," Details"]})]})}),r.jsx(Xt,{children:a&&r.jsxs(N,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[r.jsxs(N,{sx:{display:"flex",gap:3,flexWrap:"wrap"},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Time"}),r.jsx(G,{variant:"body2",children:jM(a.timestamp)})]}),((R=a.details)==null?void 0:R.connectionName)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Connection"}),r.jsx(G,{variant:"body2",children:a.details.connectionName})]}),(($=a.details)==null?void 0:$.sourceConnection)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Source"}),r.jsxs(G,{variant:"body2",children:[a.details.sourceConnection,a.details.sourceSchema&&`.${a.details.sourceSchema}`]})]}),((z=a.details)==null?void 0:z.targetConnection)&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Target"}),r.jsxs(G,{variant:"body2",children:[a.details.targetConnection,a.details.targetSchema&&`.${a.details.targetSchema}`]})]}),((I=a.details)==null?void 0:I.executionTimeMs)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Duration"}),r.jsx(G,{variant:"body2",children:kM(a.details.executionTimeMs)})]}),((O=a.details)==null?void 0:O.rowCount)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Rows"}),r.jsx(G,{variant:"body2",children:a.details.rowCount.toLocaleString()})]}),((A=a.details)==null?void 0:A.statementCount)!==void 0&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Statements"}),r.jsx(G,{variant:"body2",children:a.details.statementCount})]}),r.jsx(ze,{label:a.status==="error"?"Error":"Success",size:"small",sx:{alignSelf:"center",bgcolor:a.status==="error"?"rgba(239, 68, 68, 0.1)":"rgba(34, 197, 94, 0.1)",color:a.status==="error"?"#ef4444":"#22c55e"}})]}),a.status==="error"&&((D=a.details)==null?void 0:D.error)&&r.jsxs(Dt,{severity:"error",sx:{"& .MuiAlert-message":{width:"100%"}},children:[r.jsx(G,{variant:"subtitle2",sx:{fontWeight:600,mb:1},children:"Error Details"}),r.jsx(N,{sx:{fontFamily:"monospace",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:200,overflow:"auto",bgcolor:"rgba(0,0,0,0.1)",p:1.5,borderRadius:1},children:a.details.error})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:a.type==="query"?"SQL Query":"Description"}),r.jsx(N,{sx:{p:2,bgcolor:"background.default",borderRadius:1,fontFamily:a.type==="query"?"monospace":"inherit",fontSize:13,whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:300,overflow:"auto"},children:a.description})]})]})}),r.jsx(Yt,{sx:{p:2},children:r.jsx(xe,{onClick:()=>l(null),children:"Close"})})]})]})}function IM(e){return new Date(e).toLocaleString()}function sue(e){return e.includes("created")?r.jsx(Hn,{sx:{fontSize:18}}):e.includes("updated")?r.jsx(Ir,{sx:{fontSize:18}}):e.includes("deleted")?r.jsx(Bn,{sx:{fontSize:18}}):r.jsx(No,{sx:{fontSize:18}})}function PM(e){return e.includes("created")?"#22c55e":e.includes("updated")?"#f59e0b":e.includes("deleted")?"#ef4444":"#6b7280"}function iue(e){switch(e){case"connection":return r.jsx(Sn,{sx:{fontSize:18}});case"project":return r.jsx(im,{sx:{fontSize:18}});case"database_group":return r.jsx(Mie,{sx:{fontSize:18}});case"table":return r.jsx(ro,{sx:{fontSize:18}});case"column":return r.jsx(Bie,{sx:{fontSize:18}});default:return r.jsx(No,{sx:{fontSize:18}})}}function aue(){const[e,t]=g.useState(""),[n,o]=g.useState("all"),[s,i]=g.useState("all"),[a,l]=g.useState(null),[u,d]=g.useState(!1),[p,h]=g.useState({items:[]}),{data:m=[],isLoading:y}=mt({queryKey:["auditLogs"],queryFn:()=>BQ.getLogs({limit:500})}),{data:x=[]}=mt({queryKey:["connections"],queryFn:gr.getAll}),v=m.filter(w=>{var k;if(n!=="all"&&w.entityType!==n||s!=="all"&&w.connectionId!==s)return!1;if(e){const C=e.toLowerCase();return w.action.toLowerCase().includes(C)||w.entityType.toLowerCase().includes(C)||((k=w.connectionName)==null?void 0:k.toLowerCase().includes(C))||JSON.stringify(w.details).toLowerCase().includes(C)}return!0}),b=[{field:"createdAt",headerName:"Time",width:170,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:IM(w.value)})},{field:"action",headerName:"Action",width:200,renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(N,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"50%",bgcolor:`${PM(w.value)}20`,color:PM(w.value)},children:sue(w.value)}),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value.replace(/_/g," ").replace(/\b\w/g,k=>k.toUpperCase())})]})},{field:"entityType",headerName:"Entity Type",width:150,renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[iue(w.value),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value.replace(/_/g," ").replace(/\b\w/g,k=>k.toUpperCase())})]})},{field:"details",headerName:"Details",flex:1,renderCell:w=>{const k=w.value,C=(k==null?void 0:k.name)||(k==null?void 0:k.tableName)||(k==null?void 0:k.columnName)||"N/A";return r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(C)})}},{field:"connectionName",headerName:"Connection",width:150,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value||"-"})},{field:"actions",headerName:"Actions",width:80,sortable:!1,renderCell:w=>r.jsx(Ge,{title:"View Details",children:r.jsx(_e,{size:"small",onClick:()=>l(w.row),children:r.jsx(fs,{fontSize:"small"})})})}];return r.jsxs(N,{sx:{width:"100%",height:"100%",display:"flex",flexDirection:"column",gap:0},children:[r.jsxs(N,{sx:{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",mt:1,mb:2},children:[r.jsx(wt,{size:"small",placeholder:"Search audit logs...",value:e,onChange:w=>t(w.target.value),sx:{minWidth:300},InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{fontSize:"small"})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{fontSize:"small"})})})}}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Entity Type"}),r.jsxs(nn,{value:n,label:"Entity Type",onChange:w=>o(w.target.value),children:[r.jsx(De,{value:"all",children:"All Types"}),r.jsx(De,{value:"connection",children:"Connection"}),r.jsx(De,{value:"project",children:"Project"}),r.jsx(De,{value:"database_group",children:"Database Group"}),r.jsx(De,{value:"table",children:"Table"}),r.jsx(De,{value:"column",children:"Column"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:200},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,label:"Connection",onChange:w=>i(w.target.value),children:[r.jsx(De,{value:"all",children:"All Connections"}),x.map(w=>r.jsx(De,{value:w.id,children:w.name},w.id))]})]}),r.jsxs(N,{sx:{ml:"auto",display:"flex",gap:1,alignItems:"center"},children:[r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsx(ze,{label:`${v.length} events`,size:"small",color:"primary"})]})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:b,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:0,display:"flex",justifyContent:"center",alignItems:"center"},children:r.jsx(N,{sx:{width:"100%",height:"100%"},children:r.jsx(Ps,{rows:v,columns:b,loading:y,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}}},filterModel:p,onFilterModelChange:h,disableRowSelectionOnClick:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}},"& .MuiDataGrid-columnHeader":{display:"flex",alignItems:"center"},"& .MuiDataGrid-columnHeaderTitle":{textAlign:"center",width:"100%"}}})})}),r.jsxs(qt,{open:!!a,onClose:()=>l(null),maxWidth:"md",fullWidth:!0,children:[r.jsx(Jt,{children:"Audit Log Details"}),r.jsx(Xt,{children:a&&r.jsxs(N,{sx:{display:"flex",flexDirection:"column",gap:2,mt:1},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Time"}),r.jsx(G,{variant:"body2",children:IM(a.createdAt)})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Action"}),r.jsx(G,{variant:"body2",children:a.action.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase())})]}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Entity Type"}),r.jsx(G,{variant:"body2",children:a.entityType.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase())})]}),a.connectionName&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Connection"}),r.jsx(G,{variant:"body2",children:a.connectionName})]}),a.details&&r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Details"}),r.jsx(Dt,{severity:"info",sx:{mt:1},children:r.jsx("pre",{style:{margin:0,fontSize:"12px",whiteSpace:"pre-wrap"},children:JSON.stringify(a.details,null,2)})})]})]})}),r.jsx(Yt,{children:r.jsx(xe,{onClick:()=>l(null),children:"Close"})})]})]})}function lue(e){return e.toLocaleString()}function cue(e){return e===void 0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`}function uue(e){return e===void 0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function due(e){switch(e){case"backup_created":return r.jsx(zw,{sx:{fontSize:16}});case"backup_restored":return r.jsx(cO,{sx:{fontSize:16}});case"backup_deleted":return r.jsx(Bn,{sx:{fontSize:16}});case"backup_uploaded":return r.jsx(dO,{sx:{fontSize:16}});default:return r.jsx(Sn,{sx:{fontSize:16}})}}function fue(e){switch(e){case"backup_created":return"Created";case"backup_restored":return"Restored";case"backup_deleted":return"Deleted";case"backup_uploaded":return"Uploaded";default:return e}}function pue(e){switch(e){case"backup_created":return"#22c55e";case"backup_restored":return"#3b82f6";case"backup_deleted":return"#ef4444";case"backup_uploaded":return"#8b5cf6";default:return"#6b7280"}}function hue(){const[e,t]=g.useState(""),[n,o]=g.useState("all"),[s,i]=g.useState("all"),[a,l]=g.useState("all"),[u,d]=g.useState(!1),[p,h]=g.useState({items:[]}),{data:m=[],isLoading:y}=mt({queryKey:["backupLogs"],queryFn:()=>xi.getLogs({limit:500})}),{data:x=[]}=mt({queryKey:["connections"],queryFn:gr.getAll}),v=m.filter(w=>{var k,C,j,E;if(n!=="all"&&w.operation!==n||s!=="all"&&w.connectionId!==s||a!=="all"&&w.status!==a)return!1;if(e){const T=e.toLowerCase();return((k=w.databaseName)==null?void 0:k.toLowerCase().includes(T))||((C=w.connectionName)==null?void 0:C.toLowerCase().includes(T))||((j=w.backupFilename)==null?void 0:j.toLowerCase().includes(T))||((E=w.databaseEngine)==null?void 0:E.toLowerCase().includes(T))}return!0}),b=[{field:"createdAt",headerName:"Time",width:170,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12},children:lue(new Date(w.row.createdAt))})},{field:"operation",headerName:"Operation",width:130,valueGetter:(w,k)=>fue(k.operation),renderCell:w=>r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(N,{sx:{color:pue(w.row.operation)},children:due(w.row.operation)}),r.jsx(G,{variant:"body2",sx:{fontSize:12},children:w.value})]})},{field:"connectionName",headerName:"Connection",width:180,valueGetter:(w,k)=>k.connectionName||k.databaseName,renderCell:w=>r.jsx(Ge,{title:w.value,children:r.jsx(G,{variant:"body2",sx:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value})})},{field:"backupFilename",headerName:"Backup File",flex:1,minWidth:250,renderCell:w=>r.jsx(Ge,{title:w.value||"-",children:r.jsx(G,{variant:"body2",sx:{fontSize:12,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.value||"-"})})},{field:"databaseEngine",headerName:"Engine",width:100,renderCell:w=>r.jsx(ze,{label:w.value,size:"small",sx:{fontSize:10,height:20,textTransform:"uppercase",bgcolor:"rgba(99, 102, 241, 0.1)",color:"#6366f1"}})},{field:"fileSize",headerName:"Size",width:100,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:"text.secondary"},children:uue(w.value)})},{field:"duration",headerName:"Duration",width:100,renderCell:w=>r.jsx(G,{variant:"body2",sx:{fontSize:12,color:"text.secondary"},children:cue(w.value)})},{field:"status",headerName:"Status",width:100,renderCell:w=>r.jsx(ze,{label:w.value,size:"small",sx:{fontSize:10,height:20,textTransform:"capitalize",bgcolor:w.value==="success"?"rgba(34, 197, 94, 0.1)":"rgba(239, 68, 68, 0.1)",color:w.value==="success"?"#22c55e":"#ef4444"}})}];return r.jsxs(N,{sx:{height:"100%",width:"100%",display:"flex",flexDirection:"column"},children:[r.jsxs(N,{sx:{display:"flex",gap:2,mt:1,mb:2,flexWrap:"wrap",alignItems:"center"},children:[r.jsxs(pn,{size:"small",sx:{minWidth:140},children:[r.jsx(mn,{children:"Operation"}),r.jsxs(nn,{value:n,onChange:w=>o(w.target.value),label:"Operation",children:[r.jsx(De,{value:"all",children:"All Operations"}),r.jsx(De,{value:"backup_created",children:"Created"}),r.jsx(De,{value:"backup_restored",children:"Restored"}),r.jsx(De,{value:"backup_deleted",children:"Deleted"}),r.jsx(De,{value:"backup_uploaded",children:"Uploaded"})]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:180},children:[r.jsx(mn,{children:"Connection"}),r.jsxs(nn,{value:s,onChange:w=>i(w.target.value),label:"Connection",children:[r.jsx(De,{value:"all",children:"All Connections"}),x.map(w=>r.jsx(De,{value:w.id,children:w.name},w.id))]})]}),r.jsxs(pn,{size:"small",sx:{minWidth:120},children:[r.jsx(mn,{children:"Status"}),r.jsxs(nn,{value:a,onChange:w=>l(w.target.value),label:"Status",children:[r.jsx(De,{value:"all",children:"All"}),r.jsx(De,{value:"success",children:"Success"}),r.jsx(De,{value:"failed",children:"Failed"})]})]}),r.jsx(wt,{size:"small",placeholder:"Search by database, connection, or file...",value:e,onChange:w=>t(w.target.value),sx:{minWidth:300},slotProps:{input:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(fs,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e&&r.jsx(er,{position:"end",children:r.jsx(_e,{size:"small",onClick:()=>t(""),children:r.jsx(Cp,{sx:{fontSize:16}})})})}}}),r.jsx(N,{sx:{flex:1}}),r.jsx(Ge,{title:u?"Hide filters":"Show filters",children:r.jsx(_e,{size:"small",onClick:()=>d(!u),sx:{color:u||p.items.length>0?"primary.main":"text.secondary"},children:r.jsx(Hs,{badgeContent:p.items.length,color:"primary",invisible:p.items.length===0,children:r.jsx(od,{fontSize:"small"})})})}),r.jsxs(G,{variant:"body2",color:"text.secondary",children:[v.length," backup operations"]})]}),r.jsx(ad,{filterModel:p,onFilterModelChange:h,show:!u,sx:{px:1,pt:0}}),r.jsx(id,{open:u,filterModel:p,columns:b,onFilterModelChange:h,sx:{px:1,pt:0}}),r.jsx(N,{sx:{flex:1,minHeight:400},children:r.jsx(Ps,{rows:v,columns:b,filterModel:p,onFilterModelChange:h,loading:y,pageSizeOptions:[25,50,100],initialState:{pagination:{paginationModel:{pageSize:25}},sorting:{sortModel:[{field:"createdAt",sort:"desc"}]}},disableRowSelectionOnClick:!0,disableColumnMenu:!0,sx:{border:"none","& .MuiDataGrid-cell":{fontSize:12,display:"flex",alignItems:"center",borderBottom:"1px solid",borderColor:"divider"},"& .MuiDataGrid-row":{"&:hover":{bgcolor:"action.hover"}},"& .MuiDataGrid-columnHeaders":{borderBottom:"1px solid",borderColor:"divider"}}})})]})}function Kd({children:e,value:t,index:n}){return r.jsx(N,{role:"tabpanel",hidden:t!==n,sx:{flex:1,display:t===n?"flex":"none",flexDirection:"column",overflow:"hidden"},children:t===n&&e})}const BO=["query-history","migrations","data-sync","activity","audit-logs","backups"];function TM(e){const t=BO.indexOf(e);return t>=0?t:0}function mue(){const[e,t]=Oc(),n=e.get("tab"),[o,s]=g.useState(n?TM(n):0),{data:i=[],isLoading:a}=mt({queryKey:["connections"],queryFn:gr.getAll});return g.useEffect(()=>{const l=BO[o];l&&t({tab:l},{replace:!0})},[o,t]),g.useEffect(()=>{if(n){const l=TM(n);l!==o&&s(l)}},[n]),!a&&i.length===0?r.jsx(Tc,{to:"/dashboard",replace:!0}):r.jsxs(N,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsxs(N,{sx:{mb:3},children:[r.jsx(G,{variant:"h5",fontWeight:600,gutterBottom:!0,children:"Logs & History"}),r.jsx(G,{variant:"body2",color:"text.secondary",children:"Review query history, migrations, and system activity"})]}),r.jsxs(An,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsxs(ei,{value:o,onChange:(l,u)=>s(u),sx:{borderBottom:1,borderColor:"divider",minHeight:48,"& .MuiTab-root":{minHeight:48,textTransform:"none"}},children:[r.jsx(Cn,{icon:r.jsx(Wu,{sx:{fontSize:18}}),iconPosition:"start",label:"Query History","data-tour":"query-history"}),r.jsx(Cn,{icon:r.jsx(Rc,{sx:{fontSize:18}}),iconPosition:"start",label:"Migrations"}),r.jsx(Cn,{icon:r.jsx(_o,{sx:{fontSize:18}}),iconPosition:"start",label:"Data Sync"}),r.jsx(Cn,{icon:r.jsx(_ie,{sx:{fontSize:18}}),iconPosition:"start",label:"Activity"}),r.jsx(Cn,{icon:r.jsx(lj,{sx:{fontSize:18}}),iconPosition:"start",label:"Audit Logs"}),r.jsx(Cn,{icon:r.jsx(zw,{sx:{fontSize:18}}),iconPosition:"start",label:"Backup & Restore"})]}),r.jsxs(N,{sx:{flex:1,p:2,pt:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[r.jsx(Kd,{value:o,index:0,children:r.jsx(tue,{})}),r.jsx(Kd,{value:o,index:1,children:r.jsx(nue,{})}),r.jsx(Kd,{value:o,index:2,children:r.jsx(rue,{})}),r.jsx(Kd,{value:o,index:3,children:r.jsx(oue,{})}),r.jsx(Kd,{value:o,index:4,children:r.jsx(aue,{})}),r.jsx(Kd,{value:o,index:5,children:r.jsx(hue,{})})]})]})]})}function HO({label:e,value:t,onChange:n,colors:o}){return r.jsxs(N,{children:[r.jsx(G,{variant:"caption",sx:{color:"text.secondary",mb:1,display:"block"},children:e}),r.jsx(up,{value:t,exclusive:!0,onChange:(s,i)=>i&&n(i),size:"small",sx:{gap:.5,flexWrap:"wrap"},children:Object.entries(o).map(([s,i])=>r.jsx(Es,{value:i,title:s,sx:{width:24,height:24,borderRadius:.5,bgcolor:`rgba(${i}, 0.4)`,border:`1px solid rgba(${i}, 0.6)`,"&.Mui-selected":{bgcolor:`rgba(${i}, 0.6)`,border:`2px solid rgba(${i}, 1)`},"&:hover":{bgcolor:`rgba(${i}, 0.5)`}}},s))})]})}const gue={teal:"Teal",indigo:"Indigo",violet:"Violet",blue:"Blue",emerald:"Emerald",rose:"Rose",lightblue:"Light Blue",orange:"Orange",githubGreen:"Green"};function xue(){const{getMode:e,toggleMode:t}=zb(),n=e(),{colorScheme:o,setColorScheme:s}=dw();return r.jsxs(r.Fragment,{children:[r.jsx(_t,{sx:{mb:3},children:r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsxs(N,{children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Theme"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:"Choose between light and dark mode"})]}),r.jsxs(up,{value:n,exclusive:!0,onChange:(i,a)=>a&&t(),size:"small",children:[r.jsxs(Es,{value:"light",sx:{px:2,"&.Mui-selected":{bgcolor:"primary.main",color:"primary.contrastText","&:hover":{bgcolor:"primary.dark"}}},children:[r.jsx($ie,{sx:{mr:1,fontSize:18}}),"Light"]}),r.jsxs(Es,{value:"dark",sx:{px:2,"&.Mui-selected":{bgcolor:"primary.main",color:"primary.contrastText","&:hover":{bgcolor:"primary.dark"}}},children:[r.jsx(Eie,{sx:{mr:1,fontSize:18}}),"Dark"]})]})]})}),r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Accent Color"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mt:.5},children:"Choose your preferred color scheme"})]}),r.jsx(N,{sx:{display:"flex",gap:1.5,flexWrap:"wrap",mb:3},children:Object.keys(tm).map(i=>{const a=tm[i],l=o===i;return r.jsxs(N,{onClick:()=>s(i),sx:{width:72,height:72,borderRadius:1,bgcolor:l?`${a.primary}20`:"action.hover",border:2,borderColor:l?a.primary:"transparent",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:.5,transition:"all 0.15s","&:hover":{borderColor:a.primary,bgcolor:`${a.primary}15`}},children:[r.jsx(N,{sx:{width:24,height:24,borderRadius:"50%",background:`linear-gradient(135deg, ${a.primaryLight} 0%, ${a.primary} 100%)`}}),r.jsx(G,{variant:"caption",sx:{color:l?a.primary:"text.secondary",fontWeight:l?600:400,fontSize:11,textAlign:"center"},children:gue[i]})]},i)})})]})]})}function yue({tag:e,onUpdate:t,onDelete:n}){const[o,s]=g.useState(!1),[i,a]=g.useState(e.name),[l,u]=g.useState(e.color),d=()=>{i.trim()&&(t({name:i.trim(),color:l}),s(!1))},p=()=>{a(e.name),u(e.color),s(!1)};return o?r.jsxs(N,{sx:{display:"flex",alignItems:"flex-start",gap:2,py:2,borderBottom:1,borderColor:"divider"},children:[r.jsxs(N,{sx:{flex:1},children:[r.jsx(wt,{size:"small",value:i,onChange:h=>a(h.target.value),placeholder:"Tag name",autoFocus:!0,sx:{mb:1.5},fullWidth:!0}),r.jsx(HO,{label:"Color",value:l,onChange:u,colors:Th})]}),r.jsxs(N,{sx:{display:"flex",gap:.5,pt:.5},children:[r.jsx(_e,{size:"small",onClick:d,sx:{color:"success.main","&:hover":{bgcolor:"action.hover"}},children:r.jsx(la,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:p,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:r.jsx(Ga,{fontSize:"small"})})]})]}):r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:2,py:1.5,borderBottom:1,borderColor:"divider"},children:[r.jsx(ze,{label:e.name,size:"small",sx:{bgcolor:`rgba(${e.color}, 0.15)`,color:`rgb(${e.color})`,border:`1px solid rgba(${e.color}, 0.3)`,borderRadius:"16px",fontWeight:500}}),r.jsx(N,{sx:{flex:1}}),r.jsx(_e,{size:"small",onClick:()=>s(!0),sx:{color:"text.secondary","&:hover":{color:"text.primary",bgcolor:"action.hover"}},children:r.jsx(Ir,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:n,sx:{color:"text.secondary","&:hover":{color:"error.main",bgcolor:"action.hover"}},children:r.jsx(Bn,{fontSize:"small"})})]})}function bue(){const{tags:e,addTag:t,updateTag:n,deleteTag:o}=dp(),[s,i]=g.useState(!1),[a,l]=g.useState(""),[u,d]=g.useState(Th.blue),p=()=>{a.trim()&&(t({name:a.trim(),color:u}),l(""),d(Th.blue),i(!1))},h=()=>{l(""),d(Th.blue),i(!1)};return r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[r.jsx(Rie,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Tags"})]}),r.jsx(N,{sx:{display:"flex",gap:1},children:!s&&r.jsx(xe,{size:"small",startIcon:r.jsx(Hn,{}),onClick:()=>i(!0),sx:{color:"primary.main",textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Add tag"})})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Tags help you organize and categorize your database connections."}),s&&r.jsxs(N,{sx:{display:"flex",alignItems:"flex-start",gap:2,py:2,mb:2,borderBottom:1,borderColor:"divider",bgcolor:m=>m.palette.mode==="dark"?"rgba(34, 197, 94, 0.05)":"rgba(34, 197, 94, 0.08)",mx:-2.5,px:2.5},children:[r.jsxs(N,{sx:{flex:1},children:[r.jsx(wt,{size:"small",value:a,onChange:m=>l(m.target.value),placeholder:"New tag name",autoFocus:!0,onKeyDown:m=>{m.key==="Enter"&&p(),m.key==="Escape"&&h()},sx:{mb:1.5},fullWidth:!0}),r.jsx(HO,{label:"Color",value:u,onChange:d,colors:Th})]}),r.jsxs(N,{sx:{display:"flex",gap:.5,pt:.5},children:[r.jsx(_e,{size:"small",onClick:p,disabled:!a.trim(),sx:{color:"success.main","&:hover":{bgcolor:"action.hover"}},children:r.jsx(la,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:h,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:r.jsx(Ga,{fontSize:"small"})})]})]}),e.length===0?r.jsx(N,{sx:{py:4,textAlign:"center"},children:r.jsx(G,{variant:"body2",sx:{color:"text.secondary"},children:"No tags yet. Add your first tag to get started."})}):r.jsx(N,{children:e.map(m=>r.jsx(yue,{tag:m,onUpdate:y=>n(m.id,y),onDelete:()=>o(m.id)},m.id))}),r.jsxs(N,{sx:{mt:4,pt:3,borderTop:"1px solid rgba(255,255,255,0.1)"},children:[r.jsx(G,{variant:"subtitle2",sx:{color:"rgba(255,255,255,0.5)",mb:2},children:"Preview"}),r.jsx(N,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:e.map(m=>r.jsx(ze,{label:m.name,size:"small",sx:{bgcolor:`rgba(${m.color}, 0.15)`,color:`rgb(${m.color})`,border:`1px solid rgba(${m.color}, 0.3)`,borderRadius:"16px",fontWeight:500}},m.id))})]})]})}function vue(){return r.jsxs(r.Fragment,{children:[r.jsx(xue,{}),r.jsx(bue,{})]})}function Cue(){const e="0.4.1",[t,n]=g.useState(!1),[o,s]=g.useState(!1),i=En(p=>p.success),a=En(p=>p.error),l="bc1qhrg37apup3dkdmxmmy2kt0xcrufxjekxnd7x9jm3k0lv5lyzyrjqecryqh",u=`https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=bitcoin:${l}`,d=async()=>{try{await navigator.clipboard.writeText(l),s(!0),i("Bitcoin address copied to clipboard"),setTimeout(()=>s(!1),2e3)}catch{a("Failed to copy address")}};return r.jsxs(r.Fragment,{children:[r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(Qm,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"About DB Nexus"})]}),r.jsxs(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:["A ",r.jsx("strong",{children:"local-first"})," database management tool designed for speed, safety, and clarity. DB Nexus brings together query editing, schema visualization, data synchronization, and production safety guardrails in one modern experience."]}),r.jsxs(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:["Works seamlessly with ",r.jsx("strong",{children:"PostgreSQL, MySQL, and SQLite"})," — everything runs locally, giving you full control over your data and infrastructure."]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Open source and designed for database administrators and developers who value both power and usability."}),r.jsxs(G,{variant:"caption",sx:{color:"text.disabled"},children:["Version ",e]})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Contact & Support"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"For questions, feedback, or support:"}),r.jsx(xe,{variant:"outlined",startIcon:r.jsx(tb,{}),href:"mailto:admin@dbnexus.dev",sx:{textTransform:"none",borderColor:"divider",color:"text.primary","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"admin@dbnexus.dev"})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Support Development"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"If DB Nexus helps you, consider supporting its development."}),r.jsx(xe,{variant:"outlined",startIcon:r.jsx(N,{component:"img",src:"/Bitcoin.svg.webp",alt:"Bitcoin",sx:{width:20,height:20}}),onClick:()=>n(!0),sx:{textTransform:"none","&:hover":{bgcolor:"action.hover",borderColor:"primary.main",color:"primary.main"}},children:"Donate Bitcoin"})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"Resources"}),r.jsxs(N,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[r.jsx(xe,{variant:"outlined",href:"https://github.com/akademskig/dbnexus",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"⭐ Star on GitHub"}),r.jsx(xe,{variant:"outlined",href:"https://docs.dbnexus.dev",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Documentation"}),r.jsx(xe,{variant:"outlined",href:"https://github.com/akademskig/dbnexus/issues",target:"_blank",rel:"noopener noreferrer",sx:{textTransform:"none","&:hover":{bgcolor:"action.hover"}},children:"Report Issue"})]})]}),r.jsxs(_t,{children:[r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600,mb:2},children:"License & Credits"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:2},children:"DB Nexus is open source software."}),r.jsxs(G,{variant:"caption",sx:{color:"text.disabled"},children:["© ",new Date().getFullYear()," DB Nexus. All rights reserved."]})]}),r.jsxs(qt,{open:t,onClose:()=>n(!1),maxWidth:"xs",fullWidth:!0,children:[r.jsx(Jt,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[r.jsx(N,{component:"img",src:"/Bitcoin.svg.webp",alt:"Bitcoin",sx:{width:28,height:28}}),r.jsx(G,{variant:"h6",children:"Donate Bitcoin"})]})}),r.jsx(Xt,{children:r.jsxs(N,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[r.jsx(G,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Support DB Nexus development"}),r.jsx(N,{component:"img",src:u,alt:"Bitcoin QR Code",sx:{width:200,height:200,border:1,borderColor:"divider",borderRadius:1,p:1,bgcolor:"white"}}),r.jsxs(N,{sx:{width:"100%"},children:[r.jsx(G,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Bitcoin Address:"}),r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1,p:1.2,borderRadius:1,border:1.5,borderColor:"divider","&:hover":{borderColor:"primary.main"}},children:[r.jsx(G,{variant:"body2",sx:{flex:1,wordBreak:"break-all",fontFamily:"monospace",fontSize:11},children:l}),r.jsx(_e,{size:"small",onClick:d,sx:{color:o?"success.main":"primary.main"},children:o?r.jsx(la,{}):r.jsx(go,{})})]})]})]})}),r.jsx(Yt,{sx:{px:2,pb:2},children:r.jsx(xe,{onClick:()=>n(!1),children:"Close"})})]})]})}function Sue(){const e=S1.filter(s=>s.category==="query"),t=S1.filter(s=>s.category==="navigation"),n=S1.filter(s=>s.category==="general"),o=({title:s,shortcuts:i})=>r.jsxs(N,{sx:{mb:4},children:[r.jsx(G,{variant:"subtitle2",sx:{color:"text.secondary",mb:1.5,textTransform:"uppercase",fontSize:11,letterSpacing:"0.05em"},children:s}),r.jsx(Ks,{children:r.jsxs(Us,{size:"small",children:[r.jsx(Qs,{children:r.jsxs(ir,{children:[r.jsx(Ve,{sx:{fontWeight:600,width:150},children:"Shortcut"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Action"})]})}),r.jsx(qs,{children:i.map((a,l)=>r.jsxs(ir,{sx:{"&:last-child td":{borderBottom:0}},children:[r.jsx(Ve,{children:r.jsx(N,{sx:{display:"inline-flex",gap:.5,fontFamily:"monospace",fontSize:12},children:HQ(a).split("+").map((u,d)=>r.jsx(N,{component:"kbd",sx:{px:1,py:.25,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:.5,fontSize:11,fontWeight:600,minWidth:24,textAlign:"center"},children:u},d))})}),r.jsx(Ve,{children:r.jsx(G,{variant:"body2",children:a.description})})]},l))})]})})]});return r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(aO,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Keyboard Shortcuts"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:4},children:"Use these keyboard shortcuts to navigate and work faster. On Mac, use ⌘ (Command) instead of Ctrl."}),r.jsx(o,{title:"Query Editor",shortcuts:e}),r.jsx(o,{title:"Navigation",shortcuts:t}),r.jsx(o,{title:"General",shortcuts:n})]})}function wue(){const e=En(),t=lr(),[n,o]=g.useState(!1),{data:s,isLoading:i}=mt({queryKey:["backup-tools-status"],queryFn:()=>xi.checkTools()}),a=fn({mutationFn:()=>xi.installTools(),onSuccess:d=>{d.success?(e.success(d.message),t.invalidateQueries({queryKey:["backup-tools-status"]})):e.error(d.message)},onError:d=>{e.error(`Installation failed: ${d.message}`)}}),l=()=>{if(!(s!=null&&s.instructions))return;const d=s.instructions.instructions.filter(p=>p.trim()&&!p.includes(":")).join(`
|
|
501
501
|
`);navigator.clipboard.writeText(d),e.success("Installation commands copied to clipboard")},u=()=>{o(!1),a.mutate()};return i?r.jsx(_t,{children:r.jsx(N,{sx:{py:4,textAlign:"center"},children:r.jsx(G,{variant:"body2",color:"text.secondary",children:"Checking system tools..."})})}):r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(cm,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Database Tools"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Database backup tools are required for native backup/restore functionality."}),r.jsx(Ks,{sx:{mb:3},children:r.jsxs(Us,{size:"small",children:[r.jsx(Qs,{children:r.jsxs(ir,{children:[r.jsx(Ve,{sx:{fontWeight:600},children:"Tool"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Status"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Version"})]})}),r.jsx(qs,{children:s==null?void 0:s.tools.map(d=>r.jsxs(ir,{children:[r.jsx(Ve,{children:r.jsx(G,{variant:"body2",fontFamily:"monospace",children:d.name})}),r.jsx(Ve,{children:r.jsx(ze,{label:d.installed?"Installed":"Not Installed",size:"small",color:d.installed?"success":"default",sx:{minWidth:100}})}),r.jsx(Ve,{children:r.jsx(G,{variant:"body2",color:"text.secondary",fontFamily:"monospace",fontSize:12,children:d.version||"-"})})]},d.name))})]})}),s&&!s.allInstalled&&s.instructions&&r.jsxs(N,{children:[r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[r.jsxs(G,{variant:"subtitle2",fontWeight:600,children:["Installation Commands (",s.instructions.platform,")"]}),r.jsxs(N,{sx:{display:"flex",gap:1},children:[r.jsx(xe,{size:"small",startIcon:r.jsx(go,{}),onClick:l,sx:{textTransform:"none"},children:"Copy"}),s.instructions.canAutoInstall&&r.jsx(xe,{size:"small",variant:"contained",startIcon:a.isPending?r.jsx(Rt,{size:16}):r.jsx(cm,{}),onClick:()=>o(!0),disabled:a.isPending,sx:{textTransform:"none"},children:a.isPending?"Installing...":"Auto Install"})]})]}),r.jsx(N,{sx:{p:2,borderRadius:1,border:1,borderColor:"primary.main",fontFamily:"monospace",fontSize:13,overflowX:"auto"},children:s.instructions.instructions.map((d,p)=>r.jsx(G,{variant:"body2",sx:{fontFamily:"monospace",fontSize:12,color:d.includes(":")?"text.secondary":"text.primary",fontWeight:d.includes(":")?600:400},children:d},p))}),r.jsx(Dt,{severity:"info",sx:{mt:2},children:s.instructions.canAutoInstall?r.jsxs(r.Fragment,{children:["Click ",r.jsx("strong",{children:"Auto Install"})," to automatically install the tools, or copy the commands and run them manually in your terminal. Administrator privileges are required."]}):r.jsx(r.Fragment,{children:"Copy and paste these commands into your terminal to install the required tools. You may need administrator privileges."})})]}),(s==null?void 0:s.allInstalled)&&r.jsx(Dt,{severity:"success",children:"All database tools are installed and ready to use!"}),r.jsxs(qt,{open:n,onClose:()=>o(!1),maxWidth:"sm",fullWidth:!0,children:[r.jsx(Jt,{children:"Install Database Tools"}),r.jsxs(Xt,{children:[r.jsx(Dt,{severity:"warning",sx:{mb:2},children:"This will prompt for your sudo/administrator password to install system packages."}),r.jsx(G,{variant:"body2",color:"text.secondary",paragraph:!0,children:"The following tools will be installed:"}),r.jsx(N,{component:"ul",sx:{pl:2,mb:2,color:"text.secondary",fontSize:14},children:s==null?void 0:s.tools.filter(d=>!d.installed).map(d=>r.jsx("li",{children:d.name},d.name))}),r.jsx(G,{variant:"body2",color:"text.secondary",children:"Commands to be executed:"}),r.jsx(N,{sx:{mt:1,p:1.5,borderRadius:1,border:1,borderColor:"primary.main",fontFamily:"monospace",fontSize:12},children:s==null?void 0:s.instructions.instructions.map((d,p)=>r.jsx(G,{variant:"body2",sx:{fontFamily:"monospace",fontSize:11},children:d},p))})]}),r.jsxs(Yt,{sx:{px:2,pb:2},children:[r.jsx(xe,{onClick:()=>o(!1),children:"Cancel"}),r.jsx(xe,{variant:"contained",onClick:u,autoFocus:!0,children:"Install"})]})]})]})}function jue(){const e=En(),t=()=>{localStorage.removeItem(Mh),localStorage.removeItem("dbnexus:onboarding:step"),localStorage.removeItem("dbnexus:onboarding:minimized"),e.success("Tutorial reset! Redirecting to start..."),globalThis.location.href="/projects"};return r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(Ny,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Tutorial"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"New to DB Nexus? The interactive tutorial will guide you through the main features and help you get started."}),r.jsx(xe,{variant:"contained",startIcon:r.jsx(Ny,{}),onClick:t,sx:{textTransform:"none"},children:"Start Tutorial"})]})}function kue(){const[e,t]=Oc(),[n,o]=g.useState(0);g.useEffect(()=>{const i=e.get("tab");i==="preferences"||i==="appearance"||i==="tags"?o(0):i==="shortcuts"?o(1):i==="tools"?o(2):i==="help"?o(3):i==="about"&&o(4)},[e]);const s=(i,a)=>{o(a);const u=["preferences","shortcuts","tools","help","about"][a];u&&t({tab:u})};return r.jsx(N,{sx:{p:4,maxWidth:1400,mx:"auto"},children:r.jsxs(N,{sx:{maxWidth:850,mx:"auto"},children:[r.jsxs(N,{sx:{mb:4},children:[r.jsx(G,{variant:"h4",sx:{fontWeight:600,color:"text.primary",letterSpacing:"-0.02em",mb:1},children:"Settings"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary"},children:"Customize your preferences and application settings"})]}),r.jsx(_t,{sx:{mb:3,p:0},children:r.jsx(N,{sx:{display:"flex",alignItems:"center"},children:r.jsxs(ei,{value:n,onChange:s,sx:{flex:1,px:2,"& .MuiTabs-indicator":{bgcolor:"primary.main"},"& .MuiTab-root":{color:"text.secondary",textTransform:"none",fontWeight:500,gap:1,minHeight:56,"&.Mui-selected":{color:"primary.main"}}},children:[r.jsx(Cn,{icon:r.jsx(Oie,{fontSize:"small"}),iconPosition:"start",label:"UI"}),r.jsx(Cn,{icon:r.jsx(aO,{fontSize:"small"}),iconPosition:"start",label:"Keyboard Shortcuts"}),r.jsx(Cn,{icon:r.jsx(cm,{fontSize:"small"}),iconPosition:"start",label:"System Tools"}),r.jsx(Cn,{icon:r.jsx(Ny,{fontSize:"small"}),iconPosition:"start",label:"Help"}),r.jsx(Cn,{icon:r.jsx(Qm,{fontSize:"small"}),iconPosition:"start",label:"About"})]})})}),n===0&&r.jsx(vue,{}),n===1&&r.jsx(Sue,{}),n===2&&r.jsx(wue,{}),n===3&&r.jsx(jue,{}),n===4&&r.jsx(Cue,{})]})})}const Eue={admin:"Administrator",editor:"Editor",viewer:"Viewer"};function Iue(){const e=En(),t=lr(),{user:n,accessToken:o,logout:s}=Ra(),[i,a]=g.useState(!1),[l,u]=g.useState(""),[d,p]=g.useState(""),[h,m]=g.useState(""),[y,x]=g.useState(!1),[v,b]=g.useState(!1),[w,k]=g.useState(null),[C,j]=g.useState(!1),[E,T]=g.useState(!1),[R,$]=g.useState(null),[z,I]=g.useState(""),[O,A]=g.useState(""),[D,M]=g.useState(null),[L,F]=g.useState(!1),{data:_,isLoading:V}=mt({queryKey:["api-keys"],queryFn:()=>C1.getAll()}),W=fn({mutationFn:()=>C1.create(z,O||void 0),onSuccess:Z=>{t.invalidateQueries({queryKey:["api-keys"]}),Z.key&&M(Z.key),I(""),A("")},onError:Z=>{e.error(Z.message)}}),q=fn({mutationFn:Z=>C1.delete(Z),onSuccess:()=>{e.success("API key deleted"),t.invalidateQueries({queryKey:["api-keys"]}),T(!1),$(null)},onError:Z=>{e.error(Z.message)}}),H=async()=>{if(k(null),!l||!d){k("Please fill in all fields");return}if(d.length<8){k("New password must be at least 8 characters");return}if(d!==h){k("Passwords do not match");return}if(!o){k("Not authenticated");return}b(!0);try{await sc.changePassword(l,d,o),e.success("Password changed successfully. Please log in again."),a(!1),s()}catch(Z){k(Z.message)}finally{b(!1)}},K=()=>{a(!1),u(""),p(""),m(""),x(!1),k(null)},ne=()=>{if(!z.trim()){e.error("Please enter a key name");return}W.mutate()},X=async()=>{D&&(await navigator.clipboard.writeText(D),F(!0),e.success("API key copied to clipboard"),setTimeout(()=>F(!1),2e3))},te=()=>{j(!1),M(null),I(""),A("")};return n?r.jsxs(r.Fragment,{children:[r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx($c,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Account Information"})]}),r.jsxs(N,{sx:{display:"flex",flexDirection:"column",gap:2},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:2},children:[r.jsx(tb,{sx:{color:"text.secondary"}}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Email"}),r.jsx(G,{variant:"body1",children:n.email})]})]}),r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:2},children:[r.jsx($c,{sx:{color:"text.secondary"}}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Name"}),r.jsx(G,{variant:"body1",children:n.name||"Not set"})]})]}),r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:2},children:[r.jsx(tO,{sx:{color:"text.secondary"}}),r.jsxs(N,{children:[r.jsx(G,{variant:"caption",color:"text.secondary",children:"Role"}),r.jsx(N,{sx:{mt:.5},children:r.jsx(ze,{label:Eue[n.role]||n.role,size:"small",color:n.role==="admin"?"error":n.role==="editor"?"warning":"default"})})]})]})]})]}),r.jsxs(_t,{sx:{mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(yf,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Security"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Update your password or sign out of your account."}),r.jsxs(N,{sx:{display:"flex",gap:2},children:[r.jsx(xe,{variant:"outlined",startIcon:r.jsx(yf,{}),onClick:()=>a(!0),sx:{textTransform:"none"},children:"Change Password"}),r.jsx(xe,{variant:"outlined",color:"error",startIcon:r.jsx(uD,{}),onClick:()=>s(),sx:{textTransform:"none"},children:"Sign Out"})]})]}),r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:3},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[r.jsx(Vs,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"API Keys"})]}),r.jsx(xe,{variant:"contained",startIcon:r.jsx(Hn,{}),onClick:()=>j(!0),size:"small",sx:{textTransform:"none"},children:"Create API Key"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"API keys allow programmatic access to DB Nexus from the CLI or scripts. Keys are shown only once when created."}),V?r.jsxs(N,{sx:{py:4,textAlign:"center"},children:[r.jsx(Rt,{size:24}),r.jsx(G,{variant:"body2",color:"text.secondary",sx:{mt:2},children:"Loading API keys..."})]}):_&&_.length>0?r.jsx(Ks,{children:r.jsxs(Us,{size:"small",children:[r.jsx(Qs,{children:r.jsxs(ir,{children:[r.jsx(Ve,{sx:{fontWeight:600},children:"Name"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Created"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Last Used"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Expires"}),r.jsx(Ve,{sx:{fontWeight:600,width:80},children:"Actions"})]})}),r.jsx(qs,{children:_.map(Z=>{const J=Z.expiresAt&&new Date(Z.expiresAt)<new Date;return r.jsxs(ir,{children:[r.jsx(Ve,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[Z.name,J&&r.jsx(ze,{label:"Expired",size:"small",color:"error"})]})}),r.jsx(Ve,{children:new Date(Z.createdAt).toLocaleDateString()}),r.jsx(Ve,{children:Z.lastUsedAt?new Date(Z.lastUsedAt).toLocaleDateString():"Never"}),r.jsx(Ve,{children:Z.expiresAt?new Date(Z.expiresAt).toLocaleDateString():"Never"}),r.jsx(Ve,{children:r.jsx(_e,{size:"small",onClick:()=>{$(Z),T(!0)},title:"Delete key",sx:{"&:hover":{color:"error.main"}},children:r.jsx(Bn,{fontSize:"small"})})})]},Z.id)})})]})}):r.jsx(N,{sx:{py:4,textAlign:"center"},children:r.jsx(G,{variant:"body2",color:"text.secondary",children:"No API keys yet. Create one to get started."})})]}),r.jsxs(qt,{open:i,onClose:K,maxWidth:"sm",fullWidth:!0,children:[r.jsx(Jt,{children:"Change Password"}),r.jsxs(Xt,{children:[w&&r.jsx(Sc,{severity:"error",sx:{mb:2},children:w}),r.jsx(wt,{label:"Current Password",type:y?"text":"password",value:l,onChange:Z=>u(Z.target.value),fullWidth:!0,margin:"normal",autoComplete:"current-password",InputProps:{endAdornment:r.jsx(er,{position:"end",children:r.jsx(_e,{onClick:()=>x(!y),edge:"end",size:"small",children:y?r.jsx(rb,{}):r.jsx(Ba,{})})})}}),r.jsx(wt,{label:"New Password",type:y?"text":"password",value:d,onChange:Z=>p(Z.target.value),fullWidth:!0,margin:"normal",autoComplete:"new-password",helperText:"Minimum 8 characters"}),r.jsx(wt,{label:"Confirm New Password",type:y?"text":"password",value:h,onChange:Z=>m(Z.target.value),fullWidth:!0,margin:"normal",autoComplete:"new-password"}),r.jsx(Sc,{severity:"info",sx:{mt:2},children:"You will be logged out after changing your password."})]}),r.jsxs(Yt,{sx:{px:2,pb:2},children:[r.jsx(xe,{onClick:K,children:"Cancel"}),r.jsx(xe,{variant:"contained",onClick:H,disabled:v,children:v?"Changing...":"Change Password"})]})]}),r.jsxs(qt,{open:C,onClose:te,maxWidth:"sm",fullWidth:!0,children:[r.jsx(Jt,{children:D?"API Key Created":"Create API Key"}),r.jsx(Xt,{children:D?r.jsxs(r.Fragment,{children:[r.jsx(Sc,{severity:"warning",sx:{mb:2},children:"Copy this key now. You will not be able to see it again!"}),r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1,p:2,borderRadius:1,bgcolor:"action.hover",border:1,borderColor:"divider"},children:[r.jsx(G,{variant:"body2",sx:{flex:1,wordBreak:"break-all",fontFamily:"monospace",fontSize:12},children:D}),r.jsx(_e,{onClick:X,color:L?"success":"primary",children:L?r.jsx(la,{}):r.jsx(go,{})})]}),r.jsxs(G,{variant:"body2",color:"text.secondary",sx:{mt:2},children:["Use this key in the Authorization header:"," ",r.jsxs("code",{children:["Bearer ","{your-key}"]})]})]}):r.jsxs(r.Fragment,{children:[r.jsx(wt,{label:"Key Name",value:z,onChange:Z=>I(Z.target.value),fullWidth:!0,margin:"normal",placeholder:"e.g., CLI Access, CI/CD Pipeline",helperText:"A descriptive name for this API key"}),r.jsx(wt,{label:"Expiration Date (optional)",type:"date",value:O,onChange:Z=>A(Z.target.value),fullWidth:!0,margin:"normal",InputLabelProps:{shrink:!0},helperText:"Leave empty for no expiration"})]})}),r.jsxs(Yt,{sx:{px:2,pb:2},children:[r.jsx(xe,{onClick:te,children:D?"Close":"Cancel"}),!D&&r.jsx(xe,{variant:"contained",onClick:ne,disabled:W.isPending||!z.trim(),children:W.isPending?"Creating...":"Create"})]})]}),r.jsxs(qt,{open:E,onClose:()=>T(!1),maxWidth:"xs",fullWidth:!0,children:[r.jsx(Jt,{children:"Delete API Key"}),r.jsxs(Xt,{children:[r.jsx(Sc,{severity:"warning",sx:{mb:2},children:"This action cannot be undone."}),r.jsxs(G,{variant:"body2",children:["Are you sure you want to delete the API key"," ",r.jsx("strong",{children:R==null?void 0:R.name}),"? Any applications using this key will lose access."]})]}),r.jsxs(Yt,{sx:{px:2,pb:2},children:[r.jsx(xe,{onClick:()=>T(!1),children:"Cancel"}),r.jsx(xe,{variant:"contained",color:"error",onClick:()=>R&&q.mutate(R.id),disabled:q.isPending,children:q.isPending?"Deleting...":"Delete"})]})]})]}):r.jsx(_t,{children:r.jsx(G,{variant:"body2",color:"text.secondary",children:"Please log in to view account settings."})})}const Pue={admin:"error",editor:"warning",viewer:"default"},Tue={admin:"Admin",editor:"Editor",viewer:"Viewer"};function Mue(){const e=En(),t=lr(),n=Ra(b=>b.user),[o,s]=g.useState(!1),[i,a]=g.useState(null),[l,u]=g.useState(null),{data:d,isLoading:p,error:h}=mt({queryKey:["users"],queryFn:()=>v1.getAll()}),m=fn({mutationFn:({id:b,role:w})=>v1.updateRole(b,w),onSuccess:()=>{e.success("User role updated"),t.invalidateQueries({queryKey:["users"]}),u(null)},onError:b=>{e.error(b.message)}}),y=fn({mutationFn:b=>v1.delete(b),onSuccess:()=>{e.success("User deleted"),t.invalidateQueries({queryKey:["users"]}),s(!1),a(null)},onError:b=>{e.error(b.message)}}),x=b=>{a(b),s(!0)},v=(b,w)=>{m.mutate({id:b,role:w})};return(n==null?void 0:n.role)!=="admin"?r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(lj,{sx:{color:"warning.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"Access Denied"})]}),r.jsx(G,{variant:"body2",color:"text.secondary",children:"Only administrators can manage users."})]}):p?r.jsx(_t,{children:r.jsxs(N,{sx:{py:4,textAlign:"center"},children:[r.jsx(Rt,{size:24}),r.jsx(G,{variant:"body2",color:"text.secondary",sx:{mt:2},children:"Loading users..."})]})}):h?r.jsx(_t,{children:r.jsxs(Sc,{severity:"error",children:["Failed to load users: ",h.message]})}):r.jsxs(r.Fragment,{children:[r.jsxs(_t,{children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:3},children:[r.jsx(ij,{sx:{color:"primary.main"}}),r.jsx(G,{variant:"h6",sx:{color:"text.primary",fontWeight:600},children:"User Management"})]}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary",mb:3},children:"Manage user accounts and their roles. Admins have full access, editors can read/write data, and viewers have read-only access."}),r.jsx(Ks,{children:r.jsxs(Us,{size:"small",children:[r.jsx(Qs,{children:r.jsxs(ir,{children:[r.jsx(Ve,{sx:{fontWeight:600},children:"Email"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Name"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Role"}),r.jsx(Ve,{sx:{fontWeight:600},children:"Created"}),r.jsx(Ve,{sx:{fontWeight:600,width:100},children:"Actions"})]})}),r.jsx(qs,{children:d==null?void 0:d.map(b=>r.jsxs(ir,{children:[r.jsx(Ve,{children:r.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[b.email,b.id===(n==null?void 0:n.id)&&r.jsx(ze,{label:"You",size:"small",variant:"outlined"})]})}),r.jsx(Ve,{children:b.name||"-"}),r.jsx(Ve,{children:l===b.id?r.jsxs(nn,{value:b.role,size:"small",onChange:w=>v(b.id,w.target.value),onClose:()=>u(null),autoFocus:!0,sx:{minWidth:100},children:[r.jsx(De,{value:"admin",children:"Admin"}),r.jsx(De,{value:"editor",children:"Editor"}),r.jsx(De,{value:"viewer",children:"Viewer"})]}):r.jsx(ze,{label:Tue[b.role],size:"small",color:Pue[b.role],icon:b.role==="admin"?r.jsx(tO,{}):void 0})}),r.jsx(Ve,{children:new Date(b.createdAt).toLocaleDateString()}),r.jsx(Ve,{children:r.jsxs(N,{sx:{display:"flex",gap:.5},children:[r.jsx(_e,{size:"small",onClick:()=>u(b.id),disabled:b.id===(n==null?void 0:n.id),title:"Edit role",children:r.jsx(Ir,{fontSize:"small"})}),r.jsx(_e,{size:"small",onClick:()=>x(b),disabled:b.id===(n==null?void 0:n.id),title:"Delete user",sx:{"&:hover":{color:"error.main"}},children:r.jsx(Bn,{fontSize:"small"})})]})})]},b.id))})]})})]}),r.jsxs(qt,{open:o,onClose:()=>s(!1),maxWidth:"xs",fullWidth:!0,children:[r.jsx(Jt,{children:"Delete User"}),r.jsxs(Xt,{children:[r.jsx(Sc,{severity:"warning",sx:{mb:2},children:"This action cannot be undone."}),r.jsxs(G,{variant:"body2",children:["Are you sure you want to delete the user"," ",r.jsx("strong",{children:i==null?void 0:i.email}),"?"]})]}),r.jsxs(Yt,{sx:{px:2,pb:2},children:[r.jsx(xe,{onClick:()=>s(!1),children:"Cancel"}),r.jsx(xe,{variant:"contained",color:"error",onClick:()=>i&&y.mutate(i.id),disabled:y.isPending,children:y.isPending?"Deleting...":"Delete"})]})]})]})}function Rue(){const[e,t]=Oc(),[n,o]=g.useState(0),s=Ra(a=>a.user);g.useEffect(()=>{const a=e.get("tab");o(a==="users"||a==="admin"?1:0)},[e]);const i=(a,l)=>{o(l);const d=["account","users"][l];d&&t({tab:d})};return r.jsx(N,{sx:{p:4,maxWidth:1400,mx:"auto"},children:r.jsxs(N,{sx:{maxWidth:850,mx:"auto"},children:[r.jsxs(N,{sx:{mb:4},children:[r.jsx(G,{variant:"h4",sx:{fontWeight:600,color:"text.primary",letterSpacing:"-0.02em",mb:1},children:"Account"}),r.jsx(G,{variant:"body2",sx:{color:"text.secondary"},children:"Manage your account settings and security"})]}),r.jsx(_t,{sx:{mb:3,p:0},children:r.jsx(N,{sx:{display:"flex",alignItems:"center"},children:r.jsxs(ei,{value:n,onChange:i,sx:{flex:1,px:2,"& .MuiTabs-indicator":{bgcolor:"primary.main"},"& .MuiTab-root":{color:"text.secondary",textTransform:"none",fontWeight:500,gap:1,minHeight:56,"&.Mui-selected":{color:"primary.main"}}},children:[r.jsx(Cn,{icon:r.jsx($c,{fontSize:"small"}),iconPosition:"start",label:"Profile & Security"}),(s==null?void 0:s.role)==="admin"&&r.jsx(Cn,{icon:r.jsx(ij,{fontSize:"small"}),iconPosition:"start",label:"Users"})]})})}),n===0&&r.jsx(Iue,{}),n===1&&(s==null?void 0:s.role)==="admin"&&r.jsx(Mue,{})]})})}function $ue({icon:e,title:t,description:n}){const o=Rr();return r.jsxs(An,{elevation:0,sx:{p:3,height:"100%",bgcolor:Re(o.palette.primary.main,.05),border:"1px solid",borderColor:Re(o.palette.primary.main,.1),borderRadius:2,transition:"all 0.2s ease","&:hover":{transform:"translateY(-4px)",borderColor:Re(o.palette.primary.main,.3),boxShadow:`0 8px 24px ${Re(o.palette.primary.main,.15)}`}},children:[r.jsx(N,{sx:{width:48,height:48,borderRadius:2,bgcolor:Re(o.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2,color:"primary.main"},children:e}),r.jsx(G,{variant:"h6",fontWeight:600,gutterBottom:!0,children:t}),r.jsx(G,{variant:"body2",color:"text.secondary",children:n})]})}const zue=[{icon:r.jsx(Sn,{}),title:"Multi-Database Support",description:"Connect to PostgreSQL, MySQL, and SQLite databases. Manage all your databases from a single interface."},{icon:r.jsx(Rc,{}),title:"Schema Comparison",description:"Compare schemas between databases and generate migration scripts automatically. Keep environments in sync."},{icon:r.jsx(_o,{}),title:"Data Synchronization",description:"Sync data between database instances with conflict resolution. Perfect for dev/staging/prod workflows."},{icon:r.jsx(El,{}),title:"Powerful Query Editor",description:"Write and execute SQL with syntax highlighting, autocomplete, and query history. Export results to CSV or JSON."},{icon:r.jsx(eb,{}),title:"Fast & Local",description:"Runs entirely on your machine. No cloud required, no data leaves your computer. Lightning fast performance."},{icon:r.jsx(lj,{}),title:"Secure by Design",description:"Your credentials stay local. Connections are encrypted. No telemetry, no tracking, no accounts required."}],Due=[{name:"PostgreSQL",color:"#336791"},{name:"MySQL",color:"#4479A1"},{name:"SQLite",color:"#003B57"}];function Oue(){const e=Rr(),t=Lr();return r.jsxs(N,{sx:{minHeight:"100vh",bgcolor:"background.default"},children:[r.jsx(N,{sx:{position:"relative",overflow:"hidden",pt:{xs:8,md:12},pb:{xs:10,md:16},"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,background:`radial-gradient(ellipse at 50% 0%, ${Re(e.palette.primary.main,.15)} 0%, transparent 70%)`,pointerEvents:"none"}},children:r.jsx(ih,{maxWidth:"lg",children:r.jsxs(N,{sx:{textAlign:"center",position:"relative",zIndex:1},children:[r.jsxs(N,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:2,mb:4},children:[r.jsx(N,{component:"img",src:e.palette.mode==="dark"?"/logo-dark.svg":"/logo-light.svg",alt:"DB Nexus",sx:{width:72,height:72}}),r.jsxs(G,{variant:"h3",sx:{fontFamily:'"JetBrains Mono", monospace',fontWeight:700,letterSpacing:"-0.02em"},children:[r.jsx(N,{component:"span",sx:{bgcolor:"primary.main",color:"primary.contrastText",px:1,py:.5,borderRadius:1,mr:.5},children:"DB"}),"Nexus"]})]}),r.jsxs(G,{variant:"h4",sx:{fontWeight:600,mb:2,maxWidth:700,mx:"auto",lineHeight:1.3},children:["The Modern Database Manager",r.jsx("br",{}),r.jsx(N,{component:"span",sx:{color:"primary.main"},children:"for Developers"})]}),r.jsx(G,{variant:"h6",color:"text.secondary",sx:{mb:4,maxWidth:600,mx:"auto",fontWeight:400},children:"Connect, query, compare, and sync your databases. All from a beautiful, local-first interface. No cloud required."}),r.jsxs(N,{sx:{display:"flex",gap:2,justifyContent:"center",mb:6},children:[r.jsx(xe,{variant:"contained",size:"large",startIcon:r.jsx(xf,{}),sx:{px:4,py:1.5,fontSize:16,fontWeight:600,textTransform:"none",borderRadius:2},onClick:()=>t("/dashboard"),children:"Get Started"}),r.jsx(xe,{variant:"outlined",size:"large",startIcon:r.jsx(Tie,{}),sx:{px:4,py:1.5,fontSize:16,fontWeight:600,textTransform:"none",borderRadius:2},href:"https://github.com/akademskig/dbnexus",target:"_blank",children:"View on GitHub"})]}),r.jsx(N,{sx:{display:"flex",gap:1.5,justifyContent:"center",flexWrap:"wrap"},children:Due.map(n=>r.jsx(N,{sx:{px:2,py:.75,borderRadius:1,bgcolor:Re(n.color,.1),border:"1px solid",borderColor:Re(n.color,.2)},children:r.jsx(G,{variant:"body2",sx:{fontWeight:500,color:n.color},children:n.name})},n.name))})]})})}),r.jsxs(ih,{maxWidth:"lg",sx:{py:{xs:8,md:12}},children:[r.jsxs(N,{sx:{textAlign:"center",mb:6},children:[r.jsx(G,{variant:"h4",fontWeight:600,gutterBottom:!0,children:"Everything you need to manage databases"}),r.jsx(G,{variant:"body1",color:"text.secondary",sx:{maxWidth:600,mx:"auto"},children:"A complete toolkit for database development, from schema design to data synchronization."})]}),r.jsx(Wh,{container:!0,spacing:3,children:zue.map(n=>r.jsx(Wh,{item:!0,xs:12,sm:6,md:4,children:r.jsx($ue,{...n})},n.title))})]}),r.jsx(N,{sx:{bgcolor:Re(e.palette.primary.main,.03),py:{xs:8,md:12}},children:r.jsxs(ih,{maxWidth:"lg",children:[r.jsxs(N,{sx:{textAlign:"center",mb:6},children:[r.jsx(G,{variant:"h4",fontWeight:600,gutterBottom:!0,children:"Beautiful, intuitive interface"}),r.jsx(G,{variant:"body1",color:"text.secondary",children:"Designed for productivity with dark and light themes."})]}),r.jsx(An,{elevation:0,sx:{p:1,borderRadius:3,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",overflow:"hidden"},children:r.jsx(N,{sx:{height:400,borderRadius:2,bgcolor:"background.default",display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(G,{color:"text.secondary",children:"[Screenshot placeholder - Add actual app screenshot here]"})})})]})}),r.jsx(ih,{maxWidth:"md",sx:{py:{xs:8,md:12}},children:r.jsxs(An,{elevation:0,sx:{p:{xs:4,md:6},textAlign:"center",borderRadius:3,background:`linear-gradient(135deg, ${Re(e.palette.primary.main,.1)} 0%, ${Re(e.palette.primary.dark,.1)} 100%)`,border:"1px solid",borderColor:Re(e.palette.primary.main,.2)},children:[r.jsx(G,{variant:"h4",fontWeight:600,gutterBottom:!0,children:"Ready to get started?"}),r.jsx(G,{variant:"body1",color:"text.secondary",sx:{mb:4},children:"Download DB Nexus for free and take control of your databases."}),r.jsx(xe,{variant:"contained",size:"large",startIcon:r.jsx(xf,{}),sx:{px:4,py:1.5,fontSize:16,fontWeight:600,textTransform:"none",borderRadius:2},onClick:()=>t("/dashboard"),children:"Launch DB Nexus"})]})}),r.jsx(N,{sx:{borderTop:"1px solid",borderColor:"divider",py:4},children:r.jsx(ih,{maxWidth:"lg",children:r.jsxs(N,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:2},children:[r.jsx(G,{variant:"body2",color:"text.secondary",children:"© 2026 DB Nexus. Open source under AGPL-3.0 license."}),r.jsxs(N,{sx:{display:"flex",gap:3},children:[r.jsx(G,{variant:"body2",component:"a",href:"https://github.com/akademskig/dbnexus",target:"_blank",sx:{color:"text.secondary",textDecoration:"none","&:hover":{color:"primary.main"}},children:"GitHub"}),r.jsx(G,{variant:"body2",component:"a",href:"#",sx:{color:"text.secondary",textDecoration:"none","&:hover":{color:"primary.main"}},children:"Documentation"}),r.jsx(G,{variant:"body2",component:"a",href:"#",sx:{color:"text.secondary",textDecoration:"none","&:hover":{color:"primary.main"}},children:"Releases"})]})]})})})]})}function MM({children:e,value:t,index:n}){return r.jsx("div",{role:"tabpanel",hidden:t!==n,children:t===n&&r.jsx(N,{sx:{pt:3},children:e})})}function Aue(){const e=Rr(),t=Lr(),{login:n,register:o,isLoading:s,error:i,clearError:a,authEnabled:l,checkAuthStatus:u,isAuthenticated:d}=Ra(),[p,h]=g.useState(0),[m,y]=g.useState(""),[x,v]=g.useState(""),[b,w]=g.useState(""),[k,C]=g.useState(""),[j,E]=g.useState(!1),[T,R]=g.useState(null);g.useEffect(()=>{u()},[u]),g.useEffect(()=>{l===!0&&d&&t("/")},[d,l,t]),g.useEffect(()=>{l===!1&&h(1)},[l]);const $=async O=>{if(O.preventDefault(),R(null),a(),!m||!x){R("Please fill in all fields");return}try{await n(m,x),t("/")}catch{}},z=async O=>{if(O.preventDefault(),R(null),a(),!m||!x){R("Please fill in all fields");return}if(x.length<8){R("Password must be at least 8 characters");return}if(x!==k){R("Passwords do not match");return}try{await o(m,x,b||void 0),t("/")}catch{}},I=T||i;return r.jsx(N,{sx:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"background.default",p:2},children:r.jsx(JV,{sx:{maxWidth:440,width:"100%",borderRadius:3,boxShadow:e.shadows[8]},children:r.jsxs(nG,{sx:{p:4},children:[r.jsxs(N,{sx:{textAlign:"center",mb:3},children:[r.jsx(N,{sx:{display:"flex",justifyContent:"center",mb:2},children:r.jsx(dD,{size:72})}),r.jsx(G,{variant:"h4",fontWeight:600,children:"DB Nexus"}),r.jsx(G,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:l===!1?"Create your admin account to get started":"Sign in to manage your databases"})]}),l!==!1&&r.jsxs(ei,{value:p,onChange:(O,A)=>{h(A),a(),R(null)},variant:"fullWidth",sx:{mb:1},children:[r.jsx(Cn,{label:"Sign In"}),r.jsx(Cn,{label:"Register"})]}),I&&r.jsx(Sc,{severity:"error",sx:{mb:2},onClose:()=>{a(),R(null)},children:I}),r.jsx(MM,{value:p,index:0,children:r.jsxs("form",{onSubmit:$,children:[r.jsx(wt,{fullWidth:!0,label:"Email",type:"email",value:m,onChange:O=>y(O.target.value),margin:"normal",autoComplete:"email",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(tb,{color:"action"})})}}),r.jsx(wt,{fullWidth:!0,label:"Password",type:j?"text":"password",value:x,onChange:O=>v(O.target.value),margin:"normal",autoComplete:"current-password",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(yf,{color:"action"})}),endAdornment:r.jsx(er,{position:"end",children:r.jsx(_e,{onClick:()=>E(!j),edge:"end",size:"small",children:j?r.jsx(rb,{}):r.jsx(Ba,{})})})}}),r.jsx(xe,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:s,sx:{mt:3,py:1.5},children:s?r.jsx(Rt,{size:24}):"Sign In"})]})}),r.jsx(MM,{value:p,index:1,children:r.jsxs("form",{onSubmit:z,children:[l===!1&&r.jsx(Sc,{severity:"info",sx:{mb:2},children:"This will be the admin account for your DB Nexus instance."}),r.jsx(wt,{fullWidth:!0,label:"Name (optional)",type:"text",value:b,onChange:O=>w(O.target.value),margin:"normal",autoComplete:"name",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx($c,{color:"action"})})}}),r.jsx(wt,{fullWidth:!0,label:"Email",type:"email",value:m,onChange:O=>y(O.target.value),margin:"normal",autoComplete:"email",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(tb,{color:"action"})})}}),r.jsx(wt,{fullWidth:!0,label:"Password",type:j?"text":"password",value:x,onChange:O=>v(O.target.value),margin:"normal",autoComplete:"new-password",helperText:"Minimum 8 characters",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(yf,{color:"action"})}),endAdornment:r.jsx(er,{position:"end",children:r.jsx(_e,{onClick:()=>E(!j),edge:"end",size:"small",children:j?r.jsx(rb,{}):r.jsx(Ba,{})})})}}),r.jsx(wt,{fullWidth:!0,label:"Confirm Password",type:j?"text":"password",value:k,onChange:O=>C(O.target.value),margin:"normal",autoComplete:"new-password",InputProps:{startAdornment:r.jsx(er,{position:"start",children:r.jsx(yf,{color:"action"})})}}),r.jsx(xe,{type:"submit",fullWidth:!0,variant:"contained",size:"large",disabled:s,sx:{mt:3,py:1.5},children:s?r.jsx(Rt,{size:24}):l===!1?"Create Admin Account":"Create Account"})]})}),r.jsx(mr,{sx:{my:3}}),r.jsx(G,{variant:"caption",color:"text.secondary",display:"block",textAlign:"center",children:"Local-first database management"})]})})})}function so(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=so(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Lue={value:()=>{}};function sv(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new yy(n)}function yy(e){this._=e}function Fue(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",s=n.indexOf(".");if(s>=0&&(o=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}yy.prototype=sv.prototype={constructor:yy,on:function(e,t){var n=this._,o=Fue(e+"",n),s,i=-1,a=o.length;if(arguments.length<2){for(;++i<a;)if((s=(e=o[i]).type)&&(s=Nue(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(s=(e=o[i]).type)n[s]=RM(n[s],e.name,t);else if(t==null)for(s in n)n[s]=RM(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new yy(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),o=0,s,i;o<s;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,s=i.length;o<s;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],s=0,i=o.length;s<i;++s)o[s].value.apply(t,n)}};function Nue(e,t){for(var n=0,o=e.length,s;n<o;++n)if((s=e[n]).name===t)return s.value}function RM(e,t,n){for(var o=0,s=e.length;o<s;++o)if(e[o].name===t){e[o]=Lue,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var mS="http://www.w3.org/1999/xhtml";const $M={svg:"http://www.w3.org/2000/svg",xhtml:mS,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function iv(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),$M.hasOwnProperty(t)?{space:$M[t],local:e}:e}function _ue(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===mS&&t.documentElement.namespaceURI===mS?t.createElement(e):t.createElementNS(n,e)}}function Bue(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function WO(e){var t=iv(e);return(t.local?Bue:_ue)(t)}function Hue(){}function bj(e){return e==null?Hue:function(){return this.querySelector(e)}}function Wue(e){typeof e!="function"&&(e=bj(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=o[s]=new Array(a),u,d,p=0;p<a;++p)(u=i[p])&&(d=e.call(u,u.__data__,p,i))&&("__data__"in u&&(d.__data__=u.__data__),l[p]=d);return new ni(o,this._parents)}function Vue(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Gue(){return[]}function VO(e){return e==null?Gue:function(){return this.querySelectorAll(e)}}function Uue(e){return function(){return Vue(e.apply(this,arguments))}}function que(e){typeof e=="function"?e=Uue(e):e=VO(e);for(var t=this._groups,n=t.length,o=[],s=[],i=0;i<n;++i)for(var a=t[i],l=a.length,u,d=0;d<l;++d)(u=a[d])&&(o.push(e.call(u,u.__data__,d,a)),s.push(u));return new ni(o,s)}function GO(e){return function(){return this.matches(e)}}function UO(e){return function(t){return t.matches(e)}}var Kue=Array.prototype.find;function Que(e){return function(){return Kue.call(this.children,e)}}function Yue(){return this.firstElementChild}function Xue(e){return this.select(e==null?Yue:Que(typeof e=="function"?e:UO(e)))}var Jue=Array.prototype.filter;function Zue(){return Array.from(this.children)}function ede(e){return function(){return Jue.call(this.children,e)}}function tde(e){return this.selectAll(e==null?Zue:ede(typeof e=="function"?e:UO(e)))}function nde(e){typeof e!="function"&&(e=GO(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=o[s]=[],u,d=0;d<a;++d)(u=i[d])&&e.call(u,u.__data__,d,i)&&l.push(u);return new ni(o,this._parents)}function qO(e){return new Array(e.length)}function rde(){return new ni(this._enter||this._groups.map(qO),this._parents)}function ab(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ab.prototype={constructor:ab,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function ode(e){return function(){return e}}function sde(e,t,n,o,s,i){for(var a=0,l,u=t.length,d=i.length;a<d;++a)(l=t[a])?(l.__data__=i[a],o[a]=l):n[a]=new ab(e,i[a]);for(;a<u;++a)(l=t[a])&&(s[a]=l)}function ide(e,t,n,o,s,i,a){var l,u,d=new Map,p=t.length,h=i.length,m=new Array(p),y;for(l=0;l<p;++l)(u=t[l])&&(m[l]=y=a.call(u,u.__data__,l,t)+"",d.has(y)?s[l]=u:d.set(y,u));for(l=0;l<h;++l)y=a.call(e,i[l],l,i)+"",(u=d.get(y))?(o[l]=u,u.__data__=i[l],d.delete(y)):n[l]=new ab(e,i[l]);for(l=0;l<p;++l)(u=t[l])&&d.get(m[l])===u&&(s[l]=u)}function ade(e){return e.__data__}function lde(e,t){if(!arguments.length)return Array.from(this,ade);var n=t?ide:sde,o=this._parents,s=this._groups;typeof e!="function"&&(e=ode(e));for(var i=s.length,a=new Array(i),l=new Array(i),u=new Array(i),d=0;d<i;++d){var p=o[d],h=s[d],m=h.length,y=cde(e.call(p,p&&p.__data__,d,o)),x=y.length,v=l[d]=new Array(x),b=a[d]=new Array(x),w=u[d]=new Array(m);n(p,h,v,b,w,y,t);for(var k=0,C=0,j,E;k<x;++k)if(j=v[k]){for(k>=C&&(C=k+1);!(E=b[C])&&++C<x;);j._next=E||null}}return a=new ni(a,o),a._enter=l,a._exit=u,a}function cde(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ude(){return new ni(this._exit||this._groups.map(qO),this._parents)}function dde(e,t,n){var o=this.enter(),s=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),o&&s?o.merge(s).order():s}function fde(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,s=n.length,i=o.length,a=Math.min(s,i),l=new Array(s),u=0;u<a;++u)for(var d=n[u],p=o[u],h=d.length,m=l[u]=new Array(h),y,x=0;x<h;++x)(y=d[x]||p[x])&&(m[x]=y);for(;u<s;++u)l[u]=n[u];return new ni(l,this._parents)}function pde(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],s=o.length-1,i=o[s],a;--s>=0;)(a=o[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function hde(e){e||(e=mde);function t(h,m){return h&&m?e(h.__data__,m.__data__):!h-!m}for(var n=this._groups,o=n.length,s=new Array(o),i=0;i<o;++i){for(var a=n[i],l=a.length,u=s[i]=new Array(l),d,p=0;p<l;++p)(d=a[p])&&(u[p]=d);u.sort(t)}return new ni(s,this._parents).order()}function mde(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gde(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xde(){return Array.from(this)}function yde(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,i=o.length;s<i;++s){var a=o[s];if(a)return a}return null}function bde(){let e=0;for(const t of this)++e;return e}function vde(){return!this.node()}function Cde(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var s=t[n],i=0,a=s.length,l;i<a;++i)(l=s[i])&&e.call(l,l.__data__,i,s);return this}function Sde(e){return function(){this.removeAttribute(e)}}function wde(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jde(e,t){return function(){this.setAttribute(e,t)}}function kde(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Ede(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Ide(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function Pde(e,t){var n=iv(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?wde:Sde:typeof t=="function"?n.local?Ide:Ede:n.local?kde:jde)(n,t))}function KO(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Tde(e){return function(){this.style.removeProperty(e)}}function Mde(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Rde(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function $de(e,t,n){return arguments.length>1?this.each((t==null?Tde:typeof t=="function"?Rde:Mde)(e,t,n??"")):qf(this.node(),e)}function qf(e,t){return e.style.getPropertyValue(t)||KO(e).getComputedStyle(e,null).getPropertyValue(t)}function zde(e){return function(){delete this[e]}}function Dde(e,t){return function(){this[e]=t}}function Ode(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ade(e,t){return arguments.length>1?this.each((t==null?zde:typeof t=="function"?Ode:Dde)(e,t)):this.node()[e]}function QO(e){return e.trim().split(/^|\s+/)}function vj(e){return e.classList||new YO(e)}function YO(e){this._node=e,this._names=QO(e.getAttribute("class")||"")}YO.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function XO(e,t){for(var n=vj(e),o=-1,s=t.length;++o<s;)n.add(t[o])}function JO(e,t){for(var n=vj(e),o=-1,s=t.length;++o<s;)n.remove(t[o])}function Lde(e){return function(){XO(this,e)}}function Fde(e){return function(){JO(this,e)}}function Nde(e,t){return function(){(t.apply(this,arguments)?XO:JO)(this,e)}}function _de(e,t){var n=QO(e+"");if(arguments.length<2){for(var o=vj(this.node()),s=-1,i=n.length;++s<i;)if(!o.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Nde:t?Lde:Fde)(n,t))}function Bde(){this.textContent=""}function Hde(e){return function(){this.textContent=e}}function Wde(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Vde(e){return arguments.length?this.each(e==null?Bde:(typeof e=="function"?Wde:Hde)(e)):this.node().textContent}function Gde(){this.innerHTML=""}function Ude(e){return function(){this.innerHTML=e}}function qde(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Kde(e){return arguments.length?this.each(e==null?Gde:(typeof e=="function"?qde:Ude)(e)):this.node().innerHTML}function Qde(){this.nextSibling&&this.parentNode.appendChild(this)}function Yde(){return this.each(Qde)}function Xde(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Jde(){return this.each(Xde)}function Zde(e){var t=typeof e=="function"?e:WO(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function efe(){return null}function tfe(e,t){var n=typeof e=="function"?e:WO(e),o=t==null?efe:typeof t=="function"?t:bj(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function nfe(){var e=this.parentNode;e&&e.removeChild(this)}function rfe(){return this.each(nfe)}function ofe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sfe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ife(e){return this.select(e?sfe:ofe)}function afe(e){return arguments.length?this.property("__data__",e):this.node().__data__}function lfe(e){return function(t){e.call(this,t,this.__data__)}}function cfe(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function ufe(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function dfe(e,t,n){return function(){var o=this.__on,s,i=lfe(t);if(o){for(var a=0,l=o.length;a<l;++a)if((s=o[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(s):this.__on=[s]}}function ffe(e,t,n){var o=cfe(e+""),s,i=o.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,d=l.length,p;u<d;++u)for(s=0,p=l[u];s<i;++s)if((a=o[s]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?dfe:ufe,s=0;s<i;++s)this.each(l(o[s],t,n));return this}function ZO(e,t,n){var o=KO(e),s=o.CustomEvent;typeof s=="function"?s=new s(t,n):(s=o.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function pfe(e,t){return function(){return ZO(this,e,t)}}function hfe(e,t){return function(){return ZO(this,e,t.apply(this,arguments))}}function mfe(e,t){return this.each((typeof t=="function"?hfe:pfe)(e,t))}function*gfe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],s=0,i=o.length,a;s<i;++s)(a=o[s])&&(yield a)}var eA=[null];function ni(e,t){this._groups=e,this._parents=t}function cg(){return new ni([[document.documentElement]],eA)}function xfe(){return this}ni.prototype=cg.prototype={constructor:ni,select:Wue,selectAll:que,selectChild:Xue,selectChildren:tde,filter:nde,data:lde,enter:rde,exit:ude,join:dde,merge:fde,selection:xfe,order:pde,sort:hde,call:gde,nodes:xde,node:yde,size:bde,empty:vde,each:Cde,attr:Pde,style:$de,property:Ade,classed:_de,text:Vde,html:Kde,raise:Yde,lower:Jde,append:Zde,insert:tfe,remove:rfe,clone:ife,datum:afe,on:ffe,dispatch:mfe,[Symbol.iterator]:gfe};function Bs(e){return typeof e=="string"?new ni([[document.querySelector(e)]],[document.documentElement]):new ni([[e]],eA)}function yfe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Qi(e,t){if(e=yfe(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const bfe={passive:!1},vm={capture:!0,passive:!1};function Y1(e){e.stopImmediatePropagation()}function bf(e){e.preventDefault(),e.stopImmediatePropagation()}function tA(e){var t=e.document.documentElement,n=Bs(e).on("dragstart.drag",bf,vm);"onselectstart"in t?n.on("selectstart.drag",bf,vm):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nA(e,t){var n=e.document.documentElement,o=Bs(e).on("dragstart.drag",null);t&&(o.on("click.drag",bf,vm),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ux=e=>()=>e;function gS(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:i,x:a,y:l,dx:u,dy:d,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}gS.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function vfe(e){return!e.ctrlKey&&!e.button}function Cfe(){return this.parentNode}function Sfe(e,t){return t??{x:e.x,y:e.y}}function wfe(){return navigator.maxTouchPoints||"ontouchstart"in this}function rA(){var e=vfe,t=Cfe,n=Sfe,o=wfe,s={},i=sv("start","drag","end"),a=0,l,u,d,p,h=0;function m(j){j.on("mousedown.drag",y).filter(o).on("touchstart.drag",b).on("touchmove.drag",w,bfe).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(j,E){if(!(p||!e.call(this,j,E))){var T=C(this,t.call(this,j,E),j,E,"mouse");T&&(Bs(j.view).on("mousemove.drag",x,vm).on("mouseup.drag",v,vm),tA(j.view),Y1(j),d=!1,l=j.clientX,u=j.clientY,T("start",j))}}function x(j){if(bf(j),!d){var E=j.clientX-l,T=j.clientY-u;d=E*E+T*T>h}s.mouse("drag",j)}function v(j){Bs(j.view).on("mousemove.drag mouseup.drag",null),nA(j.view,d),bf(j),s.mouse("end",j)}function b(j,E){if(e.call(this,j,E)){var T=j.changedTouches,R=t.call(this,j,E),$=T.length,z,I;for(z=0;z<$;++z)(I=C(this,R,j,E,T[z].identifier,T[z]))&&(Y1(j),I("start",j,T[z]))}}function w(j){var E=j.changedTouches,T=E.length,R,$;for(R=0;R<T;++R)($=s[E[R].identifier])&&(bf(j),$("drag",j,E[R]))}function k(j){var E=j.changedTouches,T=E.length,R,$;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),R=0;R<T;++R)($=s[E[R].identifier])&&(Y1(j),$("end",j,E[R]))}function C(j,E,T,R,$,z){var I=i.copy(),O=Qi(z||T,E),A,D,M;if((M=n.call(j,new gS("beforestart",{sourceEvent:T,target:m,identifier:$,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:I}),R))!=null)return A=M.x-O[0]||0,D=M.y-O[1]||0,function L(F,_,V){var W=O,q;switch(F){case"start":s[$]=L,q=a++;break;case"end":delete s[$],--a;case"drag":O=Qi(V||_,E),q=a;break}I.call(F,j,new gS(F,{sourceEvent:_,subject:M,target:m,identifier:$,active:q,x:O[0]+A,y:O[1]+D,dx:O[0]-W[0],dy:O[1]-W[1],dispatch:I}),R)}}return m.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Ux(!!j),m):e},m.container=function(j){return arguments.length?(t=typeof j=="function"?j:Ux(j),m):t},m.subject=function(j){return arguments.length?(n=typeof j=="function"?j:Ux(j),m):n},m.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Ux(!!j),m):o},m.on=function(){var j=i.on.apply(i,arguments);return j===i?m:j},m.clickDistance=function(j){return arguments.length?(h=(j=+j)*j,m):Math.sqrt(h)},m}function Cj(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function oA(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function ug(){}var Cm=.7,lb=1/Cm,vf="\\s*([+-]?\\d+)\\s*",Sm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Da="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",jfe=/^#([0-9a-f]{3,8})$/,kfe=new RegExp(`^rgb\\(${vf},${vf},${vf}\\)$`),Efe=new RegExp(`^rgb\\(${Da},${Da},${Da}\\)$`),Ife=new RegExp(`^rgba\\(${vf},${vf},${vf},${Sm}\\)$`),Pfe=new RegExp(`^rgba\\(${Da},${Da},${Da},${Sm}\\)$`),Tfe=new RegExp(`^hsl\\(${Sm},${Da},${Da}\\)$`),Mfe=new RegExp(`^hsla\\(${Sm},${Da},${Da},${Sm}\\)$`),zM={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Cj(ug,Qu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:DM,formatHex:DM,formatHex8:Rfe,formatHsl:$fe,formatRgb:OM,toString:OM});function DM(){return this.rgb().formatHex()}function Rfe(){return this.rgb().formatHex8()}function $fe(){return sA(this).formatHsl()}function OM(){return this.rgb().formatRgb()}function Qu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=jfe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?AM(t):n===3?new ws(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?qx(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?qx(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=kfe.exec(e))?new ws(t[1],t[2],t[3],1):(t=Efe.exec(e))?new ws(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ife.exec(e))?qx(t[1],t[2],t[3],t[4]):(t=Pfe.exec(e))?qx(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Tfe.exec(e))?NM(t[1],t[2]/100,t[3]/100,1):(t=Mfe.exec(e))?NM(t[1],t[2]/100,t[3]/100,t[4]):zM.hasOwnProperty(e)?AM(zM[e]):e==="transparent"?new ws(NaN,NaN,NaN,0):null}function AM(e){return new ws(e>>16&255,e>>8&255,e&255,1)}function qx(e,t,n,o){return o<=0&&(e=t=n=NaN),new ws(e,t,n,o)}function zfe(e){return e instanceof ug||(e=Qu(e)),e?(e=e.rgb(),new ws(e.r,e.g,e.b,e.opacity)):new ws}function xS(e,t,n,o){return arguments.length===1?zfe(e):new ws(e,t,n,o??1)}function ws(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Cj(ws,xS,oA(ug,{brighter(e){return e=e==null?lb:Math.pow(lb,e),new ws(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Cm:Math.pow(Cm,e),new ws(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ws(Ou(this.r),Ou(this.g),Ou(this.b),cb(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:LM,formatHex:LM,formatHex8:Dfe,formatRgb:FM,toString:FM}));function LM(){return`#${Cu(this.r)}${Cu(this.g)}${Cu(this.b)}`}function Dfe(){return`#${Cu(this.r)}${Cu(this.g)}${Cu(this.b)}${Cu((isNaN(this.opacity)?1:this.opacity)*255)}`}function FM(){const e=cb(this.opacity);return`${e===1?"rgb(":"rgba("}${Ou(this.r)}, ${Ou(this.g)}, ${Ou(this.b)}${e===1?")":`, ${e})`}`}function cb(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ou(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Cu(e){return e=Ou(e),(e<16?"0":"")+e.toString(16)}function NM(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ji(e,t,n,o)}function sA(e){if(e instanceof Ji)return new Ji(e.h,e.s,e.l,e.opacity);if(e instanceof ug||(e=Qu(e)),!e)return new Ji;if(e instanceof Ji)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,s=Math.min(t,n,o),i=Math.max(t,n,o),a=NaN,l=i-s,u=(i+s)/2;return l?(t===i?a=(n-o)/l+(n<o)*6:n===i?a=(o-t)/l+2:a=(t-n)/l+4,l/=u<.5?i+s:2-i-s,a*=60):l=u>0&&u<1?0:a,new Ji(a,l,u,e.opacity)}function Ofe(e,t,n,o){return arguments.length===1?sA(e):new Ji(e,t,n,o??1)}function Ji(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Cj(Ji,Ofe,oA(ug,{brighter(e){return e=e==null?lb:Math.pow(lb,e),new Ji(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Cm:Math.pow(Cm,e),new Ji(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,s=2*n-o;return new ws(X1(e>=240?e-240:e+120,s,o),X1(e,s,o),X1(e<120?e+240:e-120,s,o),this.opacity)},clamp(){return new Ji(_M(this.h),Kx(this.s),Kx(this.l),cb(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=cb(this.opacity);return`${e===1?"hsl(":"hsla("}${_M(this.h)}, ${Kx(this.s)*100}%, ${Kx(this.l)*100}%${e===1?")":`, ${e})`}`}}));function _M(e){return e=(e||0)%360,e<0?e+360:e}function Kx(e){return Math.max(0,Math.min(1,e||0))}function X1(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Sj=e=>()=>e;function Afe(e,t){return function(n){return e+n*t}}function Lfe(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function Ffe(e){return(e=+e)==1?iA:function(t,n){return n-t?Lfe(t,n,e):Sj(isNaN(t)?n:t)}}function iA(e,t){var n=t-e;return n?Afe(e,n):Sj(isNaN(e)?t:e)}const ub=(function e(t){var n=Ffe(t);function o(s,i){var a=n((s=xS(s)).r,(i=xS(i)).r),l=n(s.g,i.g),u=n(s.b,i.b),d=iA(s.opacity,i.opacity);return function(p){return s.r=a(p),s.g=l(p),s.b=u(p),s.opacity=d(p),s+""}}return o.gamma=e,o})(1);function Nfe(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),s;return function(i){for(s=0;s<n;++s)o[s]=e[s]*(1-i)+t[s]*i;return o}}function _fe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bfe(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,s=new Array(o),i=new Array(n),a;for(a=0;a<o;++a)s[a]=qh(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<o;++a)i[a]=s[a](l);return i}}function Hfe(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Ia(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Wfe(e,t){var n={},o={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=qh(e[s],t[s]):o[s]=t[s];return function(i){for(s in n)o[s]=n[s](i);return o}}var yS=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,J1=new RegExp(yS.source,"g");function Vfe(e){return function(){return e}}function Gfe(e){return function(t){return e(t)+""}}function aA(e,t){var n=yS.lastIndex=J1.lastIndex=0,o,s,i,a=-1,l=[],u=[];for(e=e+"",t=t+"";(o=yS.exec(e))&&(s=J1.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(o=o[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,u.push({i:a,x:Ia(o,s)})),n=J1.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?u[0]?Gfe(u[0].x):Vfe(t):(t=u.length,function(d){for(var p=0,h;p<t;++p)l[(h=u[p]).i]=h.x(d);return l.join("")})}function qh(e,t){var n=typeof t,o;return t==null||n==="boolean"?Sj(t):(n==="number"?Ia:n==="string"?(o=Qu(t))?(t=o,ub):aA:t instanceof Qu?ub:t instanceof Date?Hfe:_fe(t)?Nfe:Array.isArray(t)?Bfe:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Wfe:Ia)(e,t)}var BM=180/Math.PI,bS={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lA(e,t,n,o,s,i){var a,l,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*o)&&(n-=e*u,o-=t*u),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,u/=l),e*o<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*BM,skewX:Math.atan(u)*BM,scaleX:a,scaleY:l}}var Qx;function Ufe(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?bS:lA(t.a,t.b,t.c,t.d,t.e,t.f)}function qfe(e){return e==null||(Qx||(Qx=document.createElementNS("http://www.w3.org/2000/svg","g")),Qx.setAttribute("transform",e),!(e=Qx.transform.baseVal.consolidate()))?bS:(e=e.matrix,lA(e.a,e.b,e.c,e.d,e.e,e.f))}function cA(e,t,n,o){function s(d){return d.length?d.pop()+" ":""}function i(d,p,h,m,y,x){if(d!==h||p!==m){var v=y.push("translate(",null,t,null,n);x.push({i:v-4,x:Ia(d,h)},{i:v-2,x:Ia(p,m)})}else(h||m)&&y.push("translate("+h+t+m+n)}function a(d,p,h,m){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),m.push({i:h.push(s(h)+"rotate(",null,o)-2,x:Ia(d,p)})):p&&h.push(s(h)+"rotate("+p+o)}function l(d,p,h,m){d!==p?m.push({i:h.push(s(h)+"skewX(",null,o)-2,x:Ia(d,p)}):p&&h.push(s(h)+"skewX("+p+o)}function u(d,p,h,m,y,x){if(d!==h||p!==m){var v=y.push(s(y)+"scale(",null,",",null,")");x.push({i:v-4,x:Ia(d,h)},{i:v-2,x:Ia(p,m)})}else(h!==1||m!==1)&&y.push(s(y)+"scale("+h+","+m+")")}return function(d,p){var h=[],m=[];return d=e(d),p=e(p),i(d.translateX,d.translateY,p.translateX,p.translateY,h,m),a(d.rotate,p.rotate,h,m),l(d.skewX,p.skewX,h,m),u(d.scaleX,d.scaleY,p.scaleX,p.scaleY,h,m),d=p=null,function(y){for(var x=-1,v=m.length,b;++x<v;)h[(b=m[x]).i]=b.x(y);return h.join("")}}}var Kfe=cA(Ufe,"px, ","px)","deg)"),Qfe=cA(qfe,", ",")",")"),Yfe=1e-12;function HM(e){return((e=Math.exp(e))+1/e)/2}function Xfe(e){return((e=Math.exp(e))-1/e)/2}function Jfe(e){return((e=Math.exp(2*e))-1)/(e+1)}const by=(function e(t,n,o){function s(i,a){var l=i[0],u=i[1],d=i[2],p=a[0],h=a[1],m=a[2],y=p-l,x=h-u,v=y*y+x*x,b,w;if(v<Yfe)w=Math.log(m/d)/t,b=function(R){return[l+R*y,u+R*x,d*Math.exp(t*R*w)]};else{var k=Math.sqrt(v),C=(m*m-d*d+o*v)/(2*d*n*k),j=(m*m-d*d-o*v)/(2*m*n*k),E=Math.log(Math.sqrt(C*C+1)-C),T=Math.log(Math.sqrt(j*j+1)-j);w=(T-E)/t,b=function(R){var $=R*w,z=HM(E),I=d/(n*k)*(z*Jfe(t*$+E)-Xfe(E));return[l+I*y,u+I*x,d*z/HM(t*$+E)]}}return b.duration=w*1e3*t/Math.SQRT2,b}return s.rho=function(i){var a=Math.max(.001,+i),l=a*a,u=l*l;return e(a,l,u)},s})(Math.SQRT2,2,4);var Kf=0,Oh=0,Ch=0,uA=1e3,db,Ah,fb=0,Yu=0,av=0,wm=typeof performance=="object"&&performance.now?performance:Date,dA=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wj(){return Yu||(dA(Zfe),Yu=wm.now()+av)}function Zfe(){Yu=0}function pb(){this._call=this._time=this._next=null}pb.prototype=fA.prototype={constructor:pb,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?wj():+n)+(t==null?0:+t),!this._next&&Ah!==this&&(Ah?Ah._next=this:db=this,Ah=this),this._call=e,this._time=n,vS()},stop:function(){this._call&&(this._call=null,this._time=1/0,vS())}};function fA(e,t,n){var o=new pb;return o.restart(e,t,n),o}function epe(){wj(),++Kf;for(var e=db,t;e;)(t=Yu-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Kf}function WM(){Yu=(fb=wm.now())+av,Kf=Oh=0;try{epe()}finally{Kf=0,npe(),Yu=0}}function tpe(){var e=wm.now(),t=e-fb;t>uA&&(av-=t,fb=e)}function npe(){for(var e,t=db,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:db=n);Ah=e,vS(o)}function vS(e){if(!Kf){Oh&&(Oh=clearTimeout(Oh));var t=e-Yu;t>24?(e<1/0&&(Oh=setTimeout(WM,e-wm.now()-av)),Ch&&(Ch=clearInterval(Ch))):(Ch||(fb=wm.now(),Ch=setInterval(tpe,uA)),Kf=1,dA(WM))}}function VM(e,t,n){var o=new pb;return t=t==null?0:+t,o.restart(s=>{o.stop(),e(s+t)},t,n),o}var rpe=sv("start","end","cancel","interrupt"),ope=[],pA=0,GM=1,CS=2,vy=3,UM=4,SS=5,Cy=6;function lv(e,t,n,o,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;spe(e,n,{name:t,index:o,group:s,on:rpe,tween:ope,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pA})}function jj(e,t){var n=pa(e,t);if(n.state>pA)throw new Error("too late; already scheduled");return n}function qa(e,t){var n=pa(e,t);if(n.state>vy)throw new Error("too late; already running");return n}function pa(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function spe(e,t,n){var o=e.__transition,s;o[t]=n,n.timer=fA(i,0,n.time);function i(d){n.state=GM,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var p,h,m,y;if(n.state!==GM)return u();for(p in o)if(y=o[p],y.name===n.name){if(y.state===vy)return VM(a);y.state===UM?(y.state=Cy,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete o[p]):+p<t&&(y.state=Cy,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete o[p])}if(VM(function(){n.state===vy&&(n.state=UM,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=CS,n.on.call("start",e,e.__data__,n.index,n.group),n.state===CS){for(n.state=vy,s=new Array(m=n.tween.length),p=0,h=-1;p<m;++p)(y=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++h]=y);s.length=h+1}}function l(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(u),n.state=SS,1),h=-1,m=s.length;++h<m;)s[h].call(e,p);n.state===SS&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Cy,n.timer.stop(),delete o[t];for(var d in o)return;delete e.__transition}}function Sy(e,t){var n=e.__transition,o,s,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((o=n[a]).name!==t){i=!1;continue}s=o.state>CS&&o.state<SS,o.state=Cy,o.timer.stop(),o.on.call(s?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[a]}i&&delete e.__transition}}function ipe(e){return this.each(function(){Sy(this,e)})}function ape(e,t){var n,o;return function(){var s=qa(this,e),i=s.tween;if(i!==n){o=n=i;for(var a=0,l=o.length;a<l;++a)if(o[a].name===t){o=o.slice(),o.splice(a,1);break}}s.tween=o}}function lpe(e,t,n){var o,s;if(typeof n!="function")throw new Error;return function(){var i=qa(this,e),a=i.tween;if(a!==o){s=(o=a).slice();for(var l={name:t,value:n},u=0,d=s.length;u<d;++u)if(s[u].name===t){s[u]=l;break}u===d&&s.push(l)}i.tween=s}}function cpe(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=pa(this.node(),n).tween,s=0,i=o.length,a;s<i;++s)if((a=o[s]).name===e)return a.value;return null}return this.each((t==null?ape:lpe)(n,e,t))}function kj(e,t,n){var o=e._id;return e.each(function(){var s=qa(this,o);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return pa(s,o).value[t]}}function hA(e,t){var n;return(typeof t=="number"?Ia:t instanceof Qu?ub:(n=Qu(t))?(t=n,ub):aA)(e,t)}function upe(e){return function(){this.removeAttribute(e)}}function dpe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fpe(e,t,n){var o,s=n+"",i;return function(){var a=this.getAttribute(e);return a===s?null:a===o?i:i=t(o=a,n)}}function ppe(e,t,n){var o,s=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===o?i:i=t(o=a,n)}}function hpe(e,t,n){var o,s,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=l+"",a===u?null:a===o&&u===s?i:(s=u,i=t(o=a,l)))}}function mpe(e,t,n){var o,s,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=l+"",a===u?null:a===o&&u===s?i:(s=u,i=t(o=a,l)))}}function gpe(e,t){var n=iv(e),o=n==="transform"?Qfe:hA;return this.attrTween(e,typeof t=="function"?(n.local?mpe:hpe)(n,o,kj(this,"attr."+e,t)):t==null?(n.local?dpe:upe)(n):(n.local?ppe:fpe)(n,o,t))}function xpe(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ype(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function bpe(e,t){var n,o;function s(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ype(e,i)),n}return s._value=t,s}function vpe(e,t){var n,o;function s(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&xpe(e,i)),n}return s._value=t,s}function Cpe(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=iv(e);return this.tween(n,(o.local?bpe:vpe)(o,t))}function Spe(e,t){return function(){jj(this,e).delay=+t.apply(this,arguments)}}function wpe(e,t){return t=+t,function(){jj(this,e).delay=t}}function jpe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Spe:wpe)(t,e)):pa(this.node(),t).delay}function kpe(e,t){return function(){qa(this,e).duration=+t.apply(this,arguments)}}function Epe(e,t){return t=+t,function(){qa(this,e).duration=t}}function Ipe(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kpe:Epe)(t,e)):pa(this.node(),t).duration}function Ppe(e,t){if(typeof t!="function")throw new Error;return function(){qa(this,e).ease=t}}function Tpe(e){var t=this._id;return arguments.length?this.each(Ppe(t,e)):pa(this.node(),t).ease}function Mpe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;qa(this,e).ease=n}}function Rpe(e){if(typeof e!="function")throw new Error;return this.each(Mpe(this._id,e))}function $pe(e){typeof e!="function"&&(e=GO(e));for(var t=this._groups,n=t.length,o=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=o[s]=[],u,d=0;d<a;++d)(u=i[d])&&e.call(u,u.__data__,d,i)&&l.push(u);return new Il(o,this._parents,this._name,this._id)}function zpe(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,s=n.length,i=Math.min(o,s),a=new Array(o),l=0;l<i;++l)for(var u=t[l],d=n[l],p=u.length,h=a[l]=new Array(p),m,y=0;y<p;++y)(m=u[y]||d[y])&&(h[y]=m);for(;l<o;++l)a[l]=t[l];return new Il(a,this._parents,this._name,this._id)}function Dpe(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Ope(e,t,n){var o,s,i=Dpe(t)?jj:qa;return function(){var a=i(this,e),l=a.on;l!==o&&(s=(o=l).copy()).on(t,n),a.on=s}}function Ape(e,t){var n=this._id;return arguments.length<2?pa(this.node(),n).on.on(e):this.each(Ope(n,e,t))}function Lpe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Fpe(){return this.on("end.remove",Lpe(this._id))}function Npe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=bj(e));for(var o=this._groups,s=o.length,i=new Array(s),a=0;a<s;++a)for(var l=o[a],u=l.length,d=i[a]=new Array(u),p,h,m=0;m<u;++m)(p=l[m])&&(h=e.call(p,p.__data__,m,l))&&("__data__"in p&&(h.__data__=p.__data__),d[m]=h,lv(d[m],t,n,m,d,pa(p,n)));return new Il(i,this._parents,t,n)}function _pe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=VO(e));for(var o=this._groups,s=o.length,i=[],a=[],l=0;l<s;++l)for(var u=o[l],d=u.length,p,h=0;h<d;++h)if(p=u[h]){for(var m=e.call(p,p.__data__,h,u),y,x=pa(p,n),v=0,b=m.length;v<b;++v)(y=m[v])&&lv(y,t,n,v,m,x);i.push(m),a.push(p)}return new Il(i,a,t,n)}var Bpe=cg.prototype.constructor;function Hpe(){return new Bpe(this._groups,this._parents)}function Wpe(e,t){var n,o,s;return function(){var i=qf(this,e),a=(this.style.removeProperty(e),qf(this,e));return i===a?null:i===n&&a===o?s:s=t(n=i,o=a)}}function mA(e){return function(){this.style.removeProperty(e)}}function Vpe(e,t,n){var o,s=n+"",i;return function(){var a=qf(this,e);return a===s?null:a===o?i:i=t(o=a,n)}}function Gpe(e,t,n){var o,s,i;return function(){var a=qf(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),qf(this,e))),a===u?null:a===o&&u===s?i:(s=u,i=t(o=a,l))}}function Upe(e,t){var n,o,s,i="style."+t,a="end."+i,l;return function(){var u=qa(this,e),d=u.on,p=u.value[i]==null?l||(l=mA(t)):void 0;(d!==n||s!==p)&&(o=(n=d).copy()).on(a,s=p),u.on=o}}function qpe(e,t,n){var o=(e+="")=="transform"?Kfe:hA;return t==null?this.styleTween(e,Wpe(e,o)).on("end.style."+e,mA(e)):typeof t=="function"?this.styleTween(e,Gpe(e,o,kj(this,"style."+e,t))).each(Upe(this._id,e)):this.styleTween(e,Vpe(e,o,t),n).on("end.style."+e,null)}function Kpe(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Qpe(e,t,n){var o,s;function i(){var a=t.apply(this,arguments);return a!==s&&(o=(s=a)&&Kpe(e,a,n)),o}return i._value=t,i}function Ype(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Qpe(e,t,n??""))}function Xpe(e){return function(){this.textContent=e}}function Jpe(e){return function(){var t=e(this);this.textContent=t??""}}function Zpe(e){return this.tween("text",typeof e=="function"?Jpe(kj(this,"text",e)):Xpe(e==null?"":e+""))}function ehe(e){return function(t){this.textContent=e.call(this,t)}}function the(e){var t,n;function o(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&ehe(s)),t}return o._value=e,o}function nhe(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,the(e))}function rhe(){for(var e=this._name,t=this._id,n=gA(),o=this._groups,s=o.length,i=0;i<s;++i)for(var a=o[i],l=a.length,u,d=0;d<l;++d)if(u=a[d]){var p=pa(u,t);lv(u,e,n,d,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new Il(o,this._parents,e,n)}function ohe(){var e,t,n=this,o=n._id,s=n.size();return new Promise(function(i,a){var l={value:a},u={value:function(){--s===0&&i()}};n.each(function(){var d=qa(this,o),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),d.on=t}),s===0&&i()})}var she=0;function Il(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function gA(){return++she}var ll=cg.prototype;Il.prototype={constructor:Il,select:Npe,selectAll:_pe,selectChild:ll.selectChild,selectChildren:ll.selectChildren,filter:$pe,merge:zpe,selection:Hpe,transition:rhe,call:ll.call,nodes:ll.nodes,node:ll.node,size:ll.size,empty:ll.empty,each:ll.each,on:Ape,attr:gpe,attrTween:Cpe,style:qpe,styleTween:Ype,text:Zpe,textTween:nhe,remove:Fpe,tween:cpe,delay:jpe,duration:Ipe,ease:Tpe,easeVarying:Rpe,end:ohe,[Symbol.iterator]:ll[Symbol.iterator]};function ihe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ahe={time:null,delay:0,duration:250,ease:ihe};function lhe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function che(e){var t,n;e instanceof Il?(t=e._id,e=e._name):(t=gA(),(n=ahe).time=wj(),e=e==null?null:e+"");for(var o=this._groups,s=o.length,i=0;i<s;++i)for(var a=o[i],l=a.length,u,d=0;d<l;++d)(u=a[d])&&lv(u,e,t,d,a,n||lhe(u,t));return new Il(o,this._parents,e,t)}cg.prototype.interrupt=ipe;cg.prototype.transition=che;const Yx=e=>()=>e;function uhe(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:s}})}function ml(e,t,n){this.k=e,this.x=t,this.y=n}ml.prototype={constructor:ml,scale:function(e){return e===1?this:new ml(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ml(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var cv=new ml(1,0,0);xA.prototype=ml.prototype;function xA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return cv;return e.__zoom}function Z1(e){e.stopImmediatePropagation()}function Sh(e){e.preventDefault(),e.stopImmediatePropagation()}function dhe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function fhe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function qM(){return this.__zoom||cv}function phe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function hhe(){return navigator.maxTouchPoints||"ontouchstart"in this}function mhe(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function yA(){var e=dhe,t=fhe,n=mhe,o=phe,s=hhe,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,u=by,d=sv("start","zoom","end"),p,h,m,y=500,x=150,v=0,b=10;function w(M){M.property("__zoom",qM).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",I).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(M,L,F,_){var V=M.selection?M.selection():M;V.property("__zoom",qM),M!==V?E(M,L,F,_):V.interrupt().each(function(){T(this,arguments).event(_).start().zoom(null,typeof L=="function"?L.apply(this,arguments):L).end()})},w.scaleBy=function(M,L,F,_){w.scaleTo(M,function(){var V=this.__zoom.k,W=typeof L=="function"?L.apply(this,arguments):L;return V*W},F,_)},w.scaleTo=function(M,L,F,_){w.transform(M,function(){var V=t.apply(this,arguments),W=this.__zoom,q=F==null?j(V):typeof F=="function"?F.apply(this,arguments):F,H=W.invert(q),K=typeof L=="function"?L.apply(this,arguments):L;return n(C(k(W,K),q,H),V,a)},F,_)},w.translateBy=function(M,L,F,_){w.transform(M,function(){return n(this.__zoom.translate(typeof L=="function"?L.apply(this,arguments):L,typeof F=="function"?F.apply(this,arguments):F),t.apply(this,arguments),a)},null,_)},w.translateTo=function(M,L,F,_,V){w.transform(M,function(){var W=t.apply(this,arguments),q=this.__zoom,H=_==null?j(W):typeof _=="function"?_.apply(this,arguments):_;return n(cv.translate(H[0],H[1]).scale(q.k).translate(typeof L=="function"?-L.apply(this,arguments):-L,typeof F=="function"?-F.apply(this,arguments):-F),W,a)},_,V)};function k(M,L){return L=Math.max(i[0],Math.min(i[1],L)),L===M.k?M:new ml(L,M.x,M.y)}function C(M,L,F){var _=L[0]-F[0]*M.k,V=L[1]-F[1]*M.k;return _===M.x&&V===M.y?M:new ml(M.k,_,V)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function E(M,L,F,_){M.on("start.zoom",function(){T(this,arguments).event(_).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(_).end()}).tween("zoom",function(){var V=this,W=arguments,q=T(V,W).event(_),H=t.apply(V,W),K=F==null?j(H):typeof F=="function"?F.apply(V,W):F,ne=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),X=V.__zoom,te=typeof L=="function"?L.apply(V,W):L,Z=u(X.invert(K).concat(ne/X.k),te.invert(K).concat(ne/te.k));return function(J){if(J===1)J=te;else{var Y=Z(J),oe=ne/Y[2];J=new ml(oe,K[0]-Y[0]*oe,K[1]-Y[1]*oe)}q.zoom(null,J)}})}function T(M,L,F){return!F&&M.__zooming||new R(M,L)}function R(M,L){this.that=M,this.args=L,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,L),this.taps=0}R.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,L){return this.mouse&&M!=="mouse"&&(this.mouse[1]=L.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=L.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=L.invert(this.touch1[0])),this.that.__zoom=L,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var L=Bs(this.that).datum();d.call(M,this.that,new uhe(M,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:d}),L)}};function $(M,...L){if(!e.apply(this,arguments))return;var F=T(this,L).event(M),_=this.__zoom,V=Math.max(i[0],Math.min(i[1],_.k*Math.pow(2,o.apply(this,arguments)))),W=Qi(M);if(F.wheel)(F.mouse[0][0]!==W[0]||F.mouse[0][1]!==W[1])&&(F.mouse[1]=_.invert(F.mouse[0]=W)),clearTimeout(F.wheel);else{if(_.k===V)return;F.mouse=[W,_.invert(W)],Sy(this),F.start()}Sh(M),F.wheel=setTimeout(q,x),F.zoom("mouse",n(C(k(_,V),F.mouse[0],F.mouse[1]),F.extent,a));function q(){F.wheel=null,F.end()}}function z(M,...L){if(m||!e.apply(this,arguments))return;var F=M.currentTarget,_=T(this,L,!0).event(M),V=Bs(M.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",ne,!0),W=Qi(M,F),q=M.clientX,H=M.clientY;tA(M.view),Z1(M),_.mouse=[W,this.__zoom.invert(W)],Sy(this),_.start();function K(X){if(Sh(X),!_.moved){var te=X.clientX-q,Z=X.clientY-H;_.moved=te*te+Z*Z>v}_.event(X).zoom("mouse",n(C(_.that.__zoom,_.mouse[0]=Qi(X,F),_.mouse[1]),_.extent,a))}function ne(X){V.on("mousemove.zoom mouseup.zoom",null),nA(X.view,_.moved),Sh(X),_.event(X).end()}}function I(M,...L){if(e.apply(this,arguments)){var F=this.__zoom,_=Qi(M.changedTouches?M.changedTouches[0]:M,this),V=F.invert(_),W=F.k*(M.shiftKey?.5:2),q=n(C(k(F,W),_,V),t.apply(this,L),a);Sh(M),l>0?Bs(this).transition().duration(l).call(E,q,_,M):Bs(this).call(w.transform,q,_,M)}}function O(M,...L){if(e.apply(this,arguments)){var F=M.touches,_=F.length,V=T(this,L,M.changedTouches.length===_).event(M),W,q,H,K;for(Z1(M),q=0;q<_;++q)H=F[q],K=Qi(H,this),K=[K,this.__zoom.invert(K),H.identifier],V.touch0?!V.touch1&&V.touch0[2]!==K[2]&&(V.touch1=K,V.taps=0):(V.touch0=K,W=!0,V.taps=1+!!p);p&&(p=clearTimeout(p)),W&&(V.taps<2&&(h=K[0],p=setTimeout(function(){p=null},y)),Sy(this),V.start())}}function A(M,...L){if(this.__zooming){var F=T(this,L).event(M),_=M.changedTouches,V=_.length,W,q,H,K;for(Sh(M),W=0;W<V;++W)q=_[W],H=Qi(q,this),F.touch0&&F.touch0[2]===q.identifier?F.touch0[0]=H:F.touch1&&F.touch1[2]===q.identifier&&(F.touch1[0]=H);if(q=F.that.__zoom,F.touch1){var ne=F.touch0[0],X=F.touch0[1],te=F.touch1[0],Z=F.touch1[1],J=(J=te[0]-ne[0])*J+(J=te[1]-ne[1])*J,Y=(Y=Z[0]-X[0])*Y+(Y=Z[1]-X[1])*Y;q=k(q,Math.sqrt(J/Y)),H=[(ne[0]+te[0])/2,(ne[1]+te[1])/2],K=[(X[0]+Z[0])/2,(X[1]+Z[1])/2]}else if(F.touch0)H=F.touch0[0],K=F.touch0[1];else return;F.zoom("touch",n(C(q,H,K),F.extent,a))}}function D(M,...L){if(this.__zooming){var F=T(this,L).event(M),_=M.changedTouches,V=_.length,W,q;for(Z1(M),m&&clearTimeout(m),m=setTimeout(function(){m=null},y),W=0;W<V;++W)q=_[W],F.touch0&&F.touch0[2]===q.identifier?delete F.touch0:F.touch1&&F.touch1[2]===q.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(q=Qi(q,this),Math.hypot(h[0]-q[0],h[1]-q[1])<b)){var H=Bs(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return w.wheelDelta=function(M){return arguments.length?(o=typeof M=="function"?M:Yx(+M),w):o},w.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Yx(!!M),w):e},w.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Yx(!!M),w):s},w.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Yx([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),w):t},w.scaleExtent=function(M){return arguments.length?(i[0]=+M[0],i[1]=+M[1],w):[i[0],i[1]]},w.translateExtent=function(M){return arguments.length?(a[0][0]=+M[0][0],a[1][0]=+M[1][0],a[0][1]=+M[0][1],a[1][1]=+M[1][1],w):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},w.constrain=function(M){return arguments.length?(n=M,w):n},w.duration=function(M){return arguments.length?(l=+M,w):l},w.interpolate=function(M){return arguments.length?(u=M,w):u},w.on=function(){var M=d.on.apply(d,arguments);return M===d?w:M},w.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,w):Math.sqrt(v)},w.tapDistance=function(M){return arguments.length?(b=+M,w):b},w}const Ha={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},jm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],bA=["Enter"," ","Escape"],vA={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Qf;(function(e){e.Strict="strict",e.Loose="loose"})(Qf||(Qf={}));var Au;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Au||(Au={}));var km;(function(e){e.Partial="partial",e.Full="full"})(km||(km={}));const CA={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var uc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(uc||(uc={}));var Em;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Em||(Em={}));var Gt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Gt||(Gt={}));const KM={[Gt.Left]:Gt.Right,[Gt.Right]:Gt.Left,[Gt.Top]:Gt.Bottom,[Gt.Bottom]:Gt.Top};function SA(e){return e===null?null:e?"valid":"invalid"}const wA=e=>"id"in e&&"source"in e&&"target"in e,ghe=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ej=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),dg=(e,t=[0,0])=>{const{width:n,height:o}=$l(e),s=e.origin??t,i=n*s[0],a=o*s[1];return{x:e.position.x-i,y:e.position.y-a}},xhe=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Ej(s)?s:t.nodeLookup.get(s.id));const l=a?hb(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return uv(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return dv(n)},fg=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=uv(n,hb(s)),o=!0)}),o?dv(n):{x:0,y:0,width:0,height:0}},Ij=(e,t,[n,o,s]=[0,0,1],i=!1,a=!1)=>{const l={...hg(t,[n,o,s]),width:t.width/s,height:t.height/s},u=[];for(const d of e.values()){const{measured:p,selectable:h=!0,hidden:m=!1}=d;if(a&&!h||m)continue;const y=p.width??d.width??d.initialWidth??null,x=p.height??d.height??d.initialHeight??null,v=Im(l,Xf(d)),b=(y??0)*(x??0),w=i&&v>0;(!d.internals.handleBounds||w||v>=b||d.dragging)&&u.push(d)}return u},yhe=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function bhe(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function vhe({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=bhe(e,a),u=fg(l),d=Pj(u,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await o.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function jA({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:u,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??o;let h=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Ha.error005());else{const y=l.measured.width,x=l.measured.height;y&&x&&(h=[[u,d],[u+y,d+x]])}else l&&Jf(a.extent)&&(h=[[a.extent[0][0]+u,a.extent[0][1]+d],[a.extent[1][0]+u,a.extent[1][1]+d]]);const m=Jf(h)?Xu(t,h,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Ha.error015())),{position:{x:m.x-u+(a.measured.width??0)*p[0],y:m.y-d+(a.measured.height??0)*p[1]},positionAbsolute:m}}async function Che({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const i=new Set(e.map(m=>m.id)),a=[];for(const m of n){if(m.deletable===!1)continue;const y=i.has(m.id),x=!y&&m.parentId&&a.find(v=>v.id===m.parentId);(y||x)&&a.push(m)}const l=new Set(t.map(m=>m.id)),u=o.filter(m=>m.deletable!==!1),p=yhe(a,u);for(const m of u)l.has(m.id)&&!p.find(x=>x.id===m.id)&&p.push(m);if(!s)return{edges:p,nodes:a};const h=await s({nodes:a,edges:p});return typeof h=="boolean"?h?{edges:p,nodes:a}:{edges:[],nodes:[]}:h}const Yf=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xu=(e={x:0,y:0},t,n)=>({x:Yf(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Yf(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function kA(e,t,n){const{width:o,height:s}=$l(n),{x:i,y:a}=n.internals.positionAbsolute;return Xu(e,[[i,a],[i+o,a+s]],t)}const QM=(e,t,n)=>e<t?Yf(Math.abs(e-t),1,t)/t:e>n?-Yf(Math.abs(e-n),1,t)/t:0,EA=(e,t,n=15,o=40)=>{const s=QM(e.x,o,t.width-o)*n,i=QM(e.y,o,t.height-o)*n;return[s,i]},uv=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wS=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),dv=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Xf=(e,t=[0,0])=>{var s,i;const{x:n,y:o}=Ej(e)?e.internals.positionAbsolute:dg(e,t);return{x:n,y:o,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},hb=(e,t=[0,0])=>{var s,i;const{x:n,y:o}=Ej(e)?e.internals.positionAbsolute:dg(e,t);return{x:n,y:o,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:o+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},IA=(e,t)=>dv(uv(wS(e),wS(t))),Im=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},YM=e=>ra(e.width)&&ra(e.height)&&ra(e.x)&&ra(e.y),ra=e=>!isNaN(e)&&isFinite(e),She=(e,t)=>{},pg=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),hg=({x:e,y:t},[n,o,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-o)/s};return i?pg(l,a):l},mb=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function Qd(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function whe(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Qd(e,n),s=Qd(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=Qd(e.top??e.y??0,n),s=Qd(e.bottom??e.y??0,n),i=Qd(e.left??e.x??0,t),a=Qd(e.right??e.x??0,t);return{top:o,right:a,bottom:s,left:i,x:i+a,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function jhe(e,t,n,o,s,i){const{x:a,y:l}=mb(e,[t,n,o]),{x:u,y:d}=mb({x:e.x+e.width,y:e.y+e.height},[t,n,o]),p=s-u,h=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(h)}}const Pj=(e,t,n,o,s,i)=>{const a=whe(i,t,n),l=(t-a.x)/e.width,u=(n-a.y)/e.height,d=Math.min(l,u),p=Yf(d,o,s),h=e.x+e.width/2,m=e.y+e.height/2,y=t/2-h*p,x=n/2-m*p,v=jhe(e,y,x,p,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:y-b.left+b.right,y:x-b.top+b.bottom,zoom:p}},Pm=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Jf(e){return e!=null&&e!=="parent"}function $l(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function PA(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function TA(e,t={width:0,height:0},n,o,s){const i={...e},a=o.get(n);if(a){const l=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function XM(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function khe(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function Ehe(e){return{...vA,...e||{}}}function Kh(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:i,y:a}=oa(e),l=hg({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},o),{x:u,y:d}=n?pg(l,t):l;return{xSnapped:u,ySnapped:d,...l}}const Tj=e=>({width:e.offsetWidth,height:e.offsetHeight}),MA=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Ihe=["INPUT","SELECT","TEXTAREA"];function RA(e){var o,s;const t=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Ihe.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const $A=e=>"clientX"in e,oa=(e,t)=>{var i,a;const n=$A(e),o=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},JM=(e,t,n,o,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...Tj(a)}})};function zA({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:l}){const u=e*.125+s*.375+a*.375+n*.125,d=t*.125+i*.375+l*.375+o*.125,p=Math.abs(u-e),h=Math.abs(d-t);return[u,d,p,h]}function Xx(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ZM({pos:e,x1:t,y1:n,x2:o,y2:s,c:i}){switch(e){case Gt.Left:return[t-Xx(t-o,i),n];case Gt.Right:return[t+Xx(o-t,i),n];case Gt.Top:return[t,n-Xx(n-s,i)];case Gt.Bottom:return[t,n+Xx(s-n,i)]}}function DA({sourceX:e,sourceY:t,sourcePosition:n=Gt.Bottom,targetX:o,targetY:s,targetPosition:i=Gt.Top,curvature:a=.25}){const[l,u]=ZM({pos:n,x1:e,y1:t,x2:o,y2:s,c:a}),[d,p]=ZM({pos:i,x1:o,y1:s,x2:e,y2:t,c:a}),[h,m,y,x]=zA({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:p});return[`M${e},${t} C${l},${u} ${d},${p} ${o},${s}`,h,m,y,x]}function OA({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,a=Math.abs(o-t)/2,l=o<t?o+a:o-a;return[i,l,s,a]}function Phe({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const a=s&&n?o+1e3:o,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function The({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const i=uv(hb(e),hb(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return Im(a,dv(i))>0}const Mhe=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Rhe=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),$he=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Mhe;let s;return wA(e)?s={...e}:s={...e,id:o(e)},Rhe(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function AA({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,i,a,l]=OA({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,i,a,l]}const eR={[Gt.Left]:{x:-1,y:0},[Gt.Right]:{x:1,y:0},[Gt.Top]:{x:0,y:-1},[Gt.Bottom]:{x:0,y:1}},zhe=({source:e,sourcePosition:t=Gt.Bottom,target:n})=>t===Gt.Left||t===Gt.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},tR=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Dhe({source:e,sourcePosition:t=Gt.Bottom,target:n,targetPosition:o=Gt.Top,center:s,offset:i,stepPosition:a}){const l=eR[t],u=eR[o],d={x:e.x+l.x*i,y:e.y+l.y*i},p={x:n.x+u.x*i,y:n.y+u.y*i},h=zhe({source:d,sourcePosition:t,target:p}),m=h.x!==0?"x":"y",y=h[m];let x=[],v,b;const w={x:0,y:0},k={x:0,y:0},[,,C,j]=OA({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[m]*u[m]===-1){m==="x"?(v=s.x??d.x+(p.x-d.x)*a,b=s.y??(d.y+p.y)/2):(v=s.x??(d.x+p.x)/2,b=s.y??d.y+(p.y-d.y)*a);const T=[{x:v,y:d.y},{x:v,y:p.y}],R=[{x:d.x,y:b},{x:p.x,y:b}];l[m]===y?x=m==="x"?T:R:x=m==="x"?R:T}else{const T=[{x:d.x,y:p.y}],R=[{x:p.x,y:d.y}];if(m==="x"?x=l.x===y?R:T:x=l.y===y?T:R,t===o){const A=Math.abs(e[m]-n[m]);if(A<=i){const D=Math.min(i-1,i-A);l[m]===y?w[m]=(d[m]>e[m]?-1:1)*D:k[m]=(p[m]>n[m]?-1:1)*D}}if(t!==o){const A=m==="x"?"y":"x",D=l[m]===u[A],M=d[A]>p[A],L=d[A]<p[A];(l[m]===1&&(!D&&M||D&&L)||l[m]!==1&&(!D&&L||D&&M))&&(x=m==="x"?T:R)}const $={x:d.x+w.x,y:d.y+w.y},z={x:p.x+k.x,y:p.y+k.y},I=Math.max(Math.abs($.x-x[0].x),Math.abs(z.x-x[0].x)),O=Math.max(Math.abs($.y-x[0].y),Math.abs(z.y-x[0].y));I>=O?(v=($.x+z.x)/2,b=x[0].y):(v=x[0].x,b=($.y+z.y)/2)}return[[e,{x:d.x+w.x,y:d.y+w.y},...x,{x:p.x+k.x,y:p.y+k.y},n],v,b,C,j]}function Ohe(e,t,n,o){const s=Math.min(tR(e,t)/2,tR(t,n)/2,o),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*p}`}const l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${i},${a+s*u}Q ${i},${a} ${i+s*l},${a}`}function jS({sourceX:e,sourceY:t,sourcePosition:n=Gt.Bottom,targetX:o,targetY:s,targetPosition:i=Gt.Top,borderRadius:a=5,centerX:l,centerY:u,offset:d=20,stepPosition:p=.5}){const[h,m,y,x,v]=Dhe({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:i,center:{x:l,y:u},offset:d,stepPosition:p});return[h.reduce((w,k,C)=>{let j="";return C>0&&C<h.length-1?j=Ohe(h[C-1],k,h[C+1],a):j=`${C===0?"M":"L"}${k.x} ${k.y}`,w+=j,w},""),m,y,x,v]}function nR(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ahe(e){var h;const{sourceNode:t,targetNode:n}=e;if(!nR(t)||!nR(n))return null;const o=t.internals.handleBounds||rR(t.handles),s=n.internals.handleBounds||rR(n.handles),i=oR((o==null?void 0:o.source)??[],e.sourceHandle),a=oR(e.connectionMode===Qf.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!a)return(h=e.onError)==null||h.call(e,"008",Ha.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Gt.Bottom,u=(a==null?void 0:a.position)||Gt.Top,d=Ju(t,i,l),p=Ju(n,a,u);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:u}}function rR(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Ju(e,t,n=Gt.Left,o=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??$l(e);if(o)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Gt.Top:return{x:s+a/2,y:i};case Gt.Right:return{x:s+a,y:i+l/2};case Gt.Bottom:return{x:s+a/2,y:i+l};case Gt.Left:return{x:s,y:i+l/2}}}function oR(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function kS(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Lhe(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||o,l.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const d=kS(u,t);i.has(d)||(a.push({id:d,color:u.color||n,...u}),i.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const LA=1e3,Fhe=10,Mj={nodeOrigin:[0,0],nodeExtent:jm,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Nhe={...Mj,checkEquality:!0};function Rj(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function _he(e,t,n){const o=Rj(Mj,n);for(const s of e.values())if(s.parentId)zj(s,e,t,o);else{const i=dg(s,o.nodeOrigin),a=Jf(s.extent)?s.extent:o.nodeExtent,l=Xu(i,a,$l(s));s.internals.positionAbsolute=l}}function Bhe(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&o.push(i)}return{source:n,target:o}}function $j(e){return e==="manual"}function ES(e,t,n,o={}){var d,p;const s=Rj(Nhe,o),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!$j(s.zIndexMode)?LA:0;let u=e.length>0;t.clear(),n.clear();for(const h of e){let m=a.get(h.id);if(s.checkEquality&&h===(m==null?void 0:m.internals.userNode))t.set(h.id,m);else{const y=dg(h,s.nodeOrigin),x=Jf(h.extent)?h.extent:s.nodeExtent,v=Xu(y,x,$l(h));m={...s.defaults,...h,measured:{width:(d=h.measured)==null?void 0:d.width,height:(p=h.measured)==null?void 0:p.height},internals:{positionAbsolute:v,handleBounds:Bhe(h,m),z:FA(h,l,s.zIndexMode),userNode:h}},t.set(h.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(u=!1),h.parentId&&zj(m,t,n,o,i)}return u}function Hhe(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function zj(e,t,n,o,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:u}=Rj(Mj,o),d=e.parentId,p=t.get(d);if(!p){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Hhe(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&u==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*Fhe),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const h=i&&!$j(u)?LA:0,{x:m,y,z:x}=Whe(e,p,a,l,h,u),{positionAbsolute:v}=e.internals,b=m!==v.x||y!==v.y;(b||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:m,y}:v,z:x}})}function FA(e,t,n){const o=ra(e.zIndex)?e.zIndex:0;return $j(n)?o:o+(e.selected?t:0)}function Whe(e,t,n,o,s,i){const{x:a,y:l}=t.internals.positionAbsolute,u=$l(e),d=dg(e,n),p=Jf(e.extent)?Xu(d,e.extent,u):d;let h=Xu({x:a+p.x,y:l+p.y},o,u);e.extent==="parent"&&(h=kA(h,u,t));const m=FA(e,s,i),y=t.internals.z??0;return{x:h.x,y:h.y,z:y>=m?y+1:m}}function Dj(e,t,n,o=[0,0]){var a;const s=[],i=new Map;for(const l of e){const u=t.get(l.parentId);if(!u)continue;const d=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??Xf(u),p=IA(d,l.rect);i.set(l.parentId,{expandedRect:p,parent:u})}return i.size>0&&i.forEach(({expandedRect:l,parent:u},d)=>{var C;const p=u.internals.positionAbsolute,h=$l(u),m=u.origin??o,y=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,x=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,v=Math.max(h.width,Math.round(l.width)),b=Math.max(h.height,Math.round(l.height)),w=(v-h.width)*m[0],k=(b-h.height)*m[1];(y>0||x>0||w||k)&&(s.push({id:d,type:"position",position:{x:u.position.x-y+w,y:u.position.y-x+k}}),(C=n.get(d))==null||C.forEach(j=>{e.some(E=>E.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+y,y:j.position.y+x}})})),(h.width<l.width||h.height<l.height||y||x)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:v+(y?m[0]*y-w:0),height:b+(x?m[1]*x-k:0)}})}),s}function Vhe(e,t,n,o,s,i,a){const l=o==null?void 0:o.querySelector(".xyflow__viewport");let u=!1;if(!l)return{changes:[],updatedInternals:u};const d=[],p=window.getComputedStyle(l),{m22:h}=new window.DOMMatrixReadOnly(p.transform),m=[];for(const y of e.values()){const x=t.get(y.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),u=!0;continue}const v=Tj(y.nodeElement),b=x.measured.width!==v.width||x.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!x.internals.handleBounds||y.force))){const k=y.nodeElement.getBoundingClientRect(),C=Jf(x.extent)?x.extent:i;let{positionAbsolute:j}=x.internals;x.parentId&&x.extent==="parent"?j=kA(j,v,t.get(x.parentId)):C&&(j=Xu(j,C,v));const E={...x,measured:v,internals:{...x.internals,positionAbsolute:j,handleBounds:{source:JM("source",y.nodeElement,k,h,x.id),target:JM("target",y.nodeElement,k,h,x.id)}}};t.set(x.id,E),x.parentId&&zj(E,t,n,{nodeOrigin:s,zIndexMode:a}),u=!0,b&&(d.push({id:x.id,type:"dimensions",dimensions:v}),x.expandParent&&x.parentId&&m.push({id:x.id,parentId:x.parentId,rect:Xf(E,s)}))}}if(m.length>0){const y=Dj(m,t,n,s);d.push(...y)}return{changes:d,updatedInternals:u}}async function Ghe({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],o),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function sR(e,t,n,o,s,i){let a=s;const l=o.get(a)||new Map;o.set(a,l.set(n,t)),a=`${s}-${e}`;const u=o.get(a)||new Map;if(o.set(a,u.set(n,t)),i){a=`${s}-${e}-${i}`;const d=o.get(a)||new Map;o.set(a,d.set(n,t))}}function NA(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:l=null}=o,u={edgeId:o.id,source:s,target:i,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${i}-${l}`,p=`${i}-${l}--${s}-${a}`;sR("source",u,p,e,s,a),sR("target",u,d,e,i,l),t.set(o.id,o)}}function _A(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_A(n,t):!1}function iR(e,t,n){var s;let o=e;do{if((s=o==null?void 0:o.matches)!=null&&s.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function Uhe(e,t,n,o){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!_A(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&s.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function eC({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var a,l,u;const s=[];for(const[d,p]of t){const h=(a=n.get(d))==null?void 0:a.internals.userNode;h&&s.push({...h,position:p.position,dragging:o})}if(!e)return[s[0],s];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((u=t.get(e))==null?void 0:u.position)||i.position,dragging:o}:s[0],s]}function qhe({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:o-s.distance.y},a=pg(i,t);return{x:a.x-i.x,y:a.y-i.y}}function Khe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,u=!1,d={x:0,y:0},p=null,h=!1,m=null,y=!1,x=!1,v=null;function b({noDragClassName:k,handleSelector:C,domNode:j,isSelectable:E,nodeId:T,nodeClickDistance:R=0}){m=Bs(j);function $({x:A,y:D}){const{nodeLookup:M,nodeExtent:L,snapGrid:F,snapToGrid:_,nodeOrigin:V,onNodeDrag:W,onSelectionDrag:q,onError:H,updateNodePositions:K}=t();i={x:A,y:D};let ne=!1;const X=l.size>1,te=X&&L?wS(fg(l)):null,Z=X&&_?qhe({dragItems:l,snapGrid:F,x:A,y:D}):null;for(const[J,Y]of l){if(!M.has(J))continue;let oe={x:A-Y.distance.x,y:D-Y.distance.y};_&&(oe=Z?{x:Math.round(oe.x+Z.x),y:Math.round(oe.y+Z.y)}:pg(oe,F));let ie=null;if(X&&L&&!Y.extent&&te){const{positionAbsolute:se}=Y.internals,ue=se.x-te.x+L[0][0],ge=se.x+Y.measured.width-te.x2+L[1][0],de=se.y-te.y+L[0][1],ae=se.y+Y.measured.height-te.y2+L[1][1];ie=[[ue,de],[ge,ae]]}const{position:le,positionAbsolute:pe}=jA({nodeId:J,nextPosition:oe,nodeLookup:M,nodeExtent:ie||L,nodeOrigin:V,onError:H});ne=ne||Y.position.x!==le.x||Y.position.y!==le.y,Y.position=le,Y.internals.positionAbsolute=pe}if(x=x||ne,!!ne&&(K(l,!0),v&&(o||W||!T&&q))){const[J,Y]=eC({nodeId:T,dragItems:l,nodeLookup:M});o==null||o(v,l,J,Y),W==null||W(v,J,Y),T||q==null||q(v,Y)}}async function z(){if(!p)return;const{transform:A,panBy:D,autoPanSpeed:M,autoPanOnNodeDrag:L}=t();if(!L){u=!1,cancelAnimationFrame(a);return}const[F,_]=EA(d,p,M);(F!==0||_!==0)&&(i.x=(i.x??0)-F/A[2],i.y=(i.y??0)-_/A[2],await D({x:F,y:_})&&$(i)),a=requestAnimationFrame(z)}function I(A){var X;const{nodeLookup:D,multiSelectionActive:M,nodesDraggable:L,transform:F,snapGrid:_,snapToGrid:V,selectNodesOnDrag:W,onNodeDragStart:q,onSelectionDragStart:H,unselectNodesAndEdges:K}=t();h=!0,(!W||!E)&&!M&&T&&((X=D.get(T))!=null&&X.selected||K()),E&&W&&T&&(e==null||e(T));const ne=Kh(A.sourceEvent,{transform:F,snapGrid:_,snapToGrid:V,containerBounds:p});if(i=ne,l=Uhe(D,L,ne,T),l.size>0&&(n||q||!T&&H)){const[te,Z]=eC({nodeId:T,dragItems:l,nodeLookup:D});n==null||n(A.sourceEvent,l,te,Z),q==null||q(A.sourceEvent,te,Z),T||H==null||H(A.sourceEvent,Z)}}const O=rA().clickDistance(R).on("start",A=>{const{domNode:D,nodeDragThreshold:M,transform:L,snapGrid:F,snapToGrid:_}=t();p=(D==null?void 0:D.getBoundingClientRect())||null,y=!1,x=!1,v=A.sourceEvent,M===0&&I(A),i=Kh(A.sourceEvent,{transform:L,snapGrid:F,snapToGrid:_,containerBounds:p}),d=oa(A.sourceEvent,p)}).on("drag",A=>{const{autoPanOnNodeDrag:D,transform:M,snapGrid:L,snapToGrid:F,nodeDragThreshold:_,nodeLookup:V}=t(),W=Kh(A.sourceEvent,{transform:M,snapGrid:L,snapToGrid:F,containerBounds:p});if(v=A.sourceEvent,(A.sourceEvent.type==="touchmove"&&A.sourceEvent.touches.length>1||T&&!V.has(T))&&(y=!0),!y){if(!u&&D&&h&&(u=!0,z()),!h){const q=oa(A.sourceEvent,p),H=q.x-d.x,K=q.y-d.y;Math.sqrt(H*H+K*K)>_&&I(A)}(i.x!==W.xSnapped||i.y!==W.ySnapped)&&l&&h&&(d=oa(A.sourceEvent,p),$(W))}}).on("end",A=>{if(!(!h||y)&&(u=!1,h=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:D,updateNodePositions:M,onNodeDragStop:L,onSelectionDragStop:F}=t();if(x&&(M(l,!1),x=!1),s||L||!T&&F){const[_,V]=eC({nodeId:T,dragItems:l,nodeLookup:D,dragging:!1});s==null||s(A.sourceEvent,l,_,V),L==null||L(A.sourceEvent,_,V),T||F==null||F(A.sourceEvent,V)}}}).filter(A=>{const D=A.target;return!A.button&&(!k||!iR(D,`.${k}`,j))&&(!C||iR(D,C,j))});m.call(O)}function w(){m==null||m.on(".drag",null)}return{update:b,destroy:w}}function Qhe(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Im(s,Xf(i))>0&&o.push(i);return o}const Yhe=250;function Xhe(e,t,n,o){var l,u;let s=[],i=1/0;const a=Qhe(e,n,t+Yhe);for(const d of a){const p=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((u=d.internals.handleBounds)==null?void 0:u.target)??[]];for(const h of p){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:m,y}=Ju(d,h,h.position,!0),x=Math.sqrt(Math.pow(m-e.x,2)+Math.pow(y-e.y,2));x>t||(x<i?(s=[{...h,x:m,y}],i=x):x===i&&s.push({...h,x:m,y}))}}if(!s.length)return null;if(s.length>1){const d=o.type==="source"?"target":"source";return s.find(p=>p.type===d)??s[0]}return s[0]}function BA(e,t,n,o,s,i=!1){var d,p,h;const a=o.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((h=a.internals.handleBounds)==null?void 0:h.target)??[]],u=(n?l==null?void 0:l.find(m=>m.id===n):l==null?void 0:l[0])??null;return u&&i?{...u,...Ju(a,u,u.position,!0)}:u}function HA(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Jhe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const WA=()=>!0;function Zhe(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:u,lib:d,autoPanOnConnect:p,flowId:h,panBy:m,cancelConnection:y,onConnectStart:x,onConnect:v,onConnectEnd:b,isValidConnection:w=WA,onReconnectEnd:k,updateConnection:C,getTransform:j,getFromHandle:E,autoPanSpeed:T,dragThreshold:R=1,handleDomNode:$}){const z=MA(e.target);let I=0,O;const{x:A,y:D}=oa(e),M=HA(i,$),L=l==null?void 0:l.getBoundingClientRect();let F=!1;if(!L||!M)return;const _=BA(s,M,o,u,t);if(!_)return;let V=oa(e,L),W=!1,q=null,H=!1,K=null;function ne(){if(!p||!L)return;const[le,pe]=EA(V,L,T);m({x:le,y:pe}),I=requestAnimationFrame(ne)}const X={..._,nodeId:s,type:M,position:_.position},te=u.get(s);let J={inProgress:!0,isValid:null,from:Ju(te,X,Gt.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:te,to:V,toHandle:null,toPosition:KM[X.position],toNode:null,pointer:V};function Y(){F=!0,C(J),x==null||x(e,{nodeId:s,handleId:o,handleType:M})}R===0&&Y();function oe(le){if(!F){const{x:ae,y:Ie}=oa(le),Ae=ae-A,it=Ie-D;if(!(Ae*Ae+it*it>R*R))return;Y()}if(!E()||!X){ie(le);return}const pe=j();V=oa(le,L),O=Xhe(hg(V,pe,!1,[1,1]),n,u,X),W||(ne(),W=!0);const se=VA(le,{handle:O,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:a?"target":"source",isValidConnection:w,doc:z,lib:d,flowId:h,nodeLookup:u});K=se.handleDomNode,q=se.connection,H=Jhe(!!O,se.isValid);const ue=u.get(s),ge=ue?Ju(ue,X,Gt.Left,!0):J.from,de={...J,from:ge,isValid:H,to:se.toHandle&&H?mb({x:se.toHandle.x,y:se.toHandle.y},pe):V,toHandle:se.toHandle,toPosition:H&&se.toHandle?se.toHandle.position:KM[X.position],toNode:se.toHandle?u.get(se.toHandle.nodeId):null,pointer:V};C(de),J=de}function ie(le){if(!("touches"in le&&le.touches.length>0)){if(F){(O||K)&&q&&H&&(v==null||v(q));const{inProgress:pe,...se}=J,ue={...se,toPosition:J.toHandle?J.toPosition:null};b==null||b(le,ue),i&&(k==null||k(le,ue))}y(),cancelAnimationFrame(I),W=!1,H=!1,q=null,K=null,z.removeEventListener("mousemove",oe),z.removeEventListener("mouseup",ie),z.removeEventListener("touchmove",oe),z.removeEventListener("touchend",ie)}}z.addEventListener("mousemove",oe),z.addEventListener("mouseup",ie),z.addEventListener("touchmove",oe),z.addEventListener("touchend",ie)}function VA(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:u,isValidConnection:d=WA,nodeLookup:p}){const h=i==="target",m=t?a.querySelector(`.${l}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:y,y:x}=oa(e),v=a.elementFromPoint(y,x),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:m,w={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=HA(void 0,b),C=b.getAttribute("data-nodeid"),j=b.getAttribute("data-handleid"),E=b.classList.contains("connectable"),T=b.classList.contains("connectableend");if(!C||!k)return w;const R={source:h?C:o,sourceHandle:h?j:s,target:h?o:C,targetHandle:h?s:j};w.connection=R;const z=E&&T&&(n===Qf.Strict?h&&k==="source"||!h&&k==="target":C!==o||j!==s);w.isValid=z&&d(R),w.toHandle=BA(C,k,j,p,n,!0)}return w}const IS={onPointerDown:Zhe,isValid:VA};function eme({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=Bs(e);function i({translateExtent:l,width:u,height:d,zoomStep:p=1,pannable:h=!0,zoomable:m=!0,inversePan:y=!1}){const x=C=>{if(C.sourceEvent.type!=="wheel"||!t)return;const j=n(),E=C.sourceEvent.ctrlKey&&Pm()?10:1,T=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?1:.002)*p,R=j[2]*Math.pow(2,T*E);t.scaleTo(R)};let v=[0,0];const b=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(v=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},w=C=>{const j=n();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!t)return;const E=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],T=[E[0]-v[0],E[1]-v[1]];v=E;const R=o()*Math.max(j[2],Math.log(j[2]))*(y?-1:1),$={x:j[0]-T[0]*R,y:j[1]-T[1]*R},z=[[0,0],[u,d]];t.setViewportConstrained({x:$.x,y:$.y,zoom:j[2]},z,l)},k=yA().on("start",b).on("zoom",h?w:null).on("zoom.wheel",m?x:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:Qi}}const fv=e=>({x:e.x,y:e.y,zoom:e.k}),tC=({x:e,y:t,zoom:n})=>cv.translate(e,t).scale(n),df=(e,t)=>e.target.closest(`.${t}`),GA=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tme=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,nC=(e,t=0,n=tme,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},UA=e=>{const t=e.ctrlKey&&Pm()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nme({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:u,onPanZoomEnd:d}){return p=>{if(df(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(p.ctrlKey&&a){const b=Qi(p),w=UA(p),k=h*Math.pow(2,w);o.scaleTo(n,k,b,p);return}const m=p.deltaMode===1?20:1;let y=s===Au.Vertical?0:p.deltaX*m,x=s===Au.Horizontal?0:p.deltaY*m;!Pm()&&p.shiftKey&&s!==Au.Vertical&&(y=p.deltaY*m,x=0),o.translateBy(n,-(y/h)*i,-(x/h)*i,{internal:!0});const v=fv(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(p,v),e.panScrollTimeout=setTimeout(()=>{d==null||d(p,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,v))}}function rme({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const i=o.type==="wheel",a=!t&&i&&!o.ctrlKey,l=df(o,e);if(o.ctrlKey&&i&&l&&o.preventDefault(),a||l)return null;o.preventDefault(),n.call(this,o,s)}}function ome({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var i,a,l;if((i=o.sourceEvent)!=null&&i.internal)return;const s=fv(o.transform);e.mouseButton=((a=o.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((l=o.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,s))}}function sme({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&GA(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||o([i.transform.x,i.transform.y,i.transform.k]),s&&!((l=i.sourceEvent)!=null&&l.internal)&&(s==null||s(i.sourceEvent,fv(i.transform)))}}function ime({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&GA(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const u=fv(a.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,u)},n?150:0)}}}function ame({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:u,lib:d,connectionInProgress:p}){return h=>{var b;const m=e||t,y=n&&h.ctrlKey,x=h.type==="wheel";if(h.button===1&&h.type==="mousedown"&&(df(h,`${d}-flow__node`)||df(h,`${d}-flow__edge`)))return!0;if(!o&&!m&&!s&&!i&&!n||a||p&&!x||df(h,l)&&x||df(h,u)&&(!x||s&&x&&!e)||!n&&h.ctrlKey&&x)return!1;if(!n&&h.type==="touchstart"&&((b=h.touches)==null?void 0:b.length)>1)return h.preventDefault(),!1;if(!m&&!s&&!y&&x||!o&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(o)&&!o.includes(h.button)&&h.type==="mousedown")return!1;const v=Array.isArray(o)&&o.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||x)&&v}}function lme({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),h=yA().scaleExtent([t,n]).translateExtent(o),m=Bs(e).call(h);k({x:s.x,y:s.y,zoom:Yf(s.zoom,t,n)},[[0,0],[p.width,p.height]],o);const y=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(UA);function v(O,A){return m?new Promise(D=>{h==null||h.interpolate((A==null?void 0:A.interpolate)==="linear"?qh:by).transform(nC(m,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>D(!0)),O)}):Promise.resolve(!1)}function b({noWheelClassName:O,noPanClassName:A,onPaneContextMenu:D,userSelectionActive:M,panOnScroll:L,panOnDrag:F,panOnScrollMode:_,panOnScrollSpeed:V,preventScrolling:W,zoomOnPinch:q,zoomOnScroll:H,zoomOnDoubleClick:K,zoomActivationKeyPressed:ne,lib:X,onTransformChange:te,connectionInProgress:Z,paneClickDistance:J,selectionOnDrag:Y}){M&&!d.isZoomingOrPanning&&w();const oe=L&&!ne&&!M;h.clickDistance(Y?1/0:!ra(J)||J<0?0:J);const ie=oe?nme({zoomPanValues:d,noWheelClassName:O,d3Selection:m,d3Zoom:h,panOnScrollMode:_,panOnScrollSpeed:V,zoomOnPinch:q,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):rme({noWheelClassName:O,preventScrolling:W,d3ZoomHandler:y});if(m.on("wheel.zoom",ie,{passive:!1}),!M){const pe=ome({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});h.on("start",pe);const se=sme({zoomPanValues:d,panOnDrag:F,onPaneContextMenu:!!D,onPanZoom:i,onTransformChange:te});h.on("zoom",se);const ue=ime({zoomPanValues:d,panOnDrag:F,panOnScroll:L,onPaneContextMenu:D,onPanZoomEnd:l,onDraggingChange:u});h.on("end",ue)}const le=ame({zoomActivationKeyPressed:ne,panOnDrag:F,zoomOnScroll:H,panOnScroll:L,zoomOnDoubleClick:K,zoomOnPinch:q,userSelectionActive:M,noPanClassName:A,noWheelClassName:O,lib:X,connectionInProgress:Z});h.filter(le),K?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function w(){h.on("zoom",null)}async function k(O,A,D){const M=tC(O),L=h==null?void 0:h.constrain()(M,A,D);return L&&await v(L),new Promise(F=>F(L))}async function C(O,A){const D=tC(O);return await v(D,A),new Promise(M=>M(D))}function j(O){if(m){const A=tC(O),D=m.property("__zoom");(D.k!==O.zoom||D.x!==O.x||D.y!==O.y)&&(h==null||h.transform(m,A,null,{sync:!0}))}}function E(){const O=m?xA(m.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function T(O,A){return m?new Promise(D=>{h==null||h.interpolate((A==null?void 0:A.interpolate)==="linear"?qh:by).scaleTo(nC(m,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>D(!0)),O)}):Promise.resolve(!1)}function R(O,A){return m?new Promise(D=>{h==null||h.interpolate((A==null?void 0:A.interpolate)==="linear"?qh:by).scaleBy(nC(m,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>D(!0)),O)}):Promise.resolve(!1)}function $(O){h==null||h.scaleExtent(O)}function z(O){h==null||h.translateExtent(O)}function I(O){const A=!ra(O)||O<0?0:O;h==null||h.clickDistance(A)}return{update:b,destroy:w,setViewport:C,setViewportConstrained:k,getViewport:E,scaleTo:T,scaleBy:R,setScaleExtent:$,setTranslateExtent:z,syncViewport:j,setClickDistance:I}}var Zf;(function(e){e.Line="line",e.Handle="handle"})(Zf||(Zf={}));function cme({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:i}){const a=e-t,l=n-o,u=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(u[0]=u[0]*-1),l&&i&&(u[1]=u[1]*-1),u}function aR(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function ec(e,t){return Math.max(0,t-e)}function tc(e,t){return Math.max(0,e-t)}function Jx(e,t,n){return Math.max(0,t-e,e-n)}function lR(e,t){return e?!t:t}function ume(e,t,n,o,s,i,a,l){let{affectsX:u,affectsY:d}=t;const{isHorizontal:p,isVertical:h}=t,m=p&&h,{xSnapped:y,ySnapped:x}=n,{minWidth:v,maxWidth:b,minHeight:w,maxHeight:k}=o,{x:C,y:j,width:E,height:T,aspectRatio:R}=e;let $=Math.floor(p?y-e.pointerX:0),z=Math.floor(h?x-e.pointerY:0);const I=E+(u?-$:$),O=T+(d?-z:z),A=-i[0]*E,D=-i[1]*T;let M=Jx(I,v,b),L=Jx(O,w,k);if(a){let V=0,W=0;u&&$<0?V=ec(C+$+A,a[0][0]):!u&&$>0&&(V=tc(C+I+A,a[1][0])),d&&z<0?W=ec(j+z+D,a[0][1]):!d&&z>0&&(W=tc(j+O+D,a[1][1])),M=Math.max(M,V),L=Math.max(L,W)}if(l){let V=0,W=0;u&&$>0?V=tc(C+$,l[0][0]):!u&&$<0&&(V=ec(C+I,l[1][0])),d&&z>0?W=tc(j+z,l[0][1]):!d&&z<0&&(W=ec(j+O,l[1][1])),M=Math.max(M,V),L=Math.max(L,W)}if(s){if(p){const V=Jx(I/R,w,k)*R;if(M=Math.max(M,V),a){let W=0;!u&&!d||u&&!d&&m?W=tc(j+D+I/R,a[1][1])*R:W=ec(j+D+(u?$:-$)/R,a[0][1])*R,M=Math.max(M,W)}if(l){let W=0;!u&&!d||u&&!d&&m?W=ec(j+I/R,l[1][1])*R:W=tc(j+(u?$:-$)/R,l[0][1])*R,M=Math.max(M,W)}}if(h){const V=Jx(O*R,v,b)/R;if(L=Math.max(L,V),a){let W=0;!u&&!d||d&&!u&&m?W=tc(C+O*R+A,a[1][0])/R:W=ec(C+(d?z:-z)*R+A,a[0][0])/R,L=Math.max(L,W)}if(l){let W=0;!u&&!d||d&&!u&&m?W=ec(C+O*R,l[1][0])/R:W=tc(C+(d?z:-z)*R,l[0][0])/R,L=Math.max(L,W)}}}z=z+(z<0?L:-L),$=$+($<0?M:-M),s&&(m?I>O*R?z=(lR(u,d)?-$:$)/R:$=(lR(u,d)?-z:z)*R:p?(z=$/R,d=u):($=z*R,u=d));const F=u?C+$:C,_=d?j+z:j;return{width:E+(u?-$:$),height:T+(d?-z:z),x:i[0]*$*(u?-1:1)+F,y:i[1]*z*(d?-1:1)+_}}const qA={width:0,height:0,x:0,y:0},dme={...qA,pointerX:0,pointerY:0,aspectRatio:1};function fme(e){return[[0,0],[e.measured.width,e.measured.height]]}function pme(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,u=n[1]*a;return[[o-l,s-u],[o+i-l,s+a-u]]}function hme({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const i=Bs(e);let a={controlDirection:aR("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:p,keepAspectRatio:h,resizeDirection:m,onResizeStart:y,onResize:x,onResizeEnd:v,shouldResize:b}){let w={...qA},k={...dme};a={boundaries:p,resizeDirection:m,keepAspectRatio:h,controlDirection:aR(d)};let C,j=null,E=[],T,R,$,z=!1;const I=rA().on("start",O=>{const{nodeLookup:A,transform:D,snapGrid:M,snapToGrid:L,nodeOrigin:F,paneDomNode:_}=n();if(C=A.get(t),!C)return;j=(_==null?void 0:_.getBoundingClientRect())??null;const{xSnapped:V,ySnapped:W}=Kh(O.sourceEvent,{transform:D,snapGrid:M,snapToGrid:L,containerBounds:j});w={width:C.measured.width??0,height:C.measured.height??0,x:C.position.x??0,y:C.position.y??0},k={...w,pointerX:V,pointerY:W,aspectRatio:w.width/w.height},T=void 0,C.parentId&&(C.extent==="parent"||C.expandParent)&&(T=A.get(C.parentId),R=T&&C.extent==="parent"?fme(T):void 0),E=[],$=void 0;for(const[q,H]of A)if(H.parentId===t&&(E.push({id:q,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const K=pme(H,C,H.origin??F);$?$=[[Math.min(K[0][0],$[0][0]),Math.min(K[0][1],$[0][1])],[Math.max(K[1][0],$[1][0]),Math.max(K[1][1],$[1][1])]]:$=K}y==null||y(O,{...w})}).on("drag",O=>{const{transform:A,snapGrid:D,snapToGrid:M,nodeOrigin:L}=n(),F=Kh(O.sourceEvent,{transform:A,snapGrid:D,snapToGrid:M,containerBounds:j}),_=[];if(!C)return;const{x:V,y:W,width:q,height:H}=w,K={},ne=C.origin??L,{width:X,height:te,x:Z,y:J}=ume(k,a.controlDirection,F,a.boundaries,a.keepAspectRatio,ne,R,$),Y=X!==q,oe=te!==H,ie=Z!==V&&Y,le=J!==W&&oe;if(!ie&&!le&&!Y&&!oe)return;if((ie||le||ne[0]===1||ne[1]===1)&&(K.x=ie?Z:w.x,K.y=le?J:w.y,w.x=K.x,w.y=K.y,E.length>0)){const ge=Z-V,de=J-W;for(const ae of E)ae.position={x:ae.position.x-ge+ne[0]*(X-q),y:ae.position.y-de+ne[1]*(te-H)},_.push(ae)}if((Y||oe)&&(K.width=Y&&(!a.resizeDirection||a.resizeDirection==="horizontal")?X:w.width,K.height=oe&&(!a.resizeDirection||a.resizeDirection==="vertical")?te:w.height,w.width=K.width,w.height=K.height),T&&C.expandParent){const ge=ne[0]*(K.width??0);K.x&&K.x<ge&&(w.x=ge,k.x=k.x-(K.x-ge));const de=ne[1]*(K.height??0);K.y&&K.y<de&&(w.y=de,k.y=k.y-(K.y-de))}const pe=cme({width:w.width,prevWidth:q,height:w.height,prevHeight:H,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),se={...w,direction:pe};(b==null?void 0:b(O,se))!==!1&&(z=!0,x==null||x(O,se),o(K,_))}).on("end",O=>{z&&(v==null||v(O,{...w}),s==null||s({...w}),z=!1)});i.call(I)}function u(){i.on(".drag",null)}return{update:l,destroy:u}}var rC={exports:{}},oC={};/**
|
|
502
502
|
* @license React
|
|
503
503
|
* use-sync-external-store-shim/with-selector.production.js
|
package/dist/web/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@700&display=swap"
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
/>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-Dc1NWltv.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-BrgwqzVU.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|