LightRAG/lightrag/api/webui/assets/feature-graph-hW7OQbPC.js
2025-09-23 23:45:12 +08:00

730 lines
273 KiB
JavaScript
Generated

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/utils-vendor-BysuhMZA.js","assets/react-vendor-DEwriMA6.js"])))=>i.map(i=>d[i]);
var mi=Object.defineProperty;var vi=(t,e,r)=>e in t?mi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ne=(t,e,r)=>vi(t,typeof e!="symbol"?e+"":e,r);import{R as Y,r as p,c as yi,g as Be,d as bi,e as wi}from"./react-vendor-DEwriMA6.js";import{_ as ca,a as ua,f as rr,N as da,b as fa,c as ha,D as _n,d as Wt,F as xi,E as ga,e as Si,g as Xn,h as _i,n as Yn,v as We,i as pa,j as ma,r as Xe,k as va,y as ya,p as Ei,l as Ci,U as Jr,m as ki,o as Ti,S as Ri}from"./graph-vendor-B-X5JegA.js";import{j as g,c as En,P as _t,a as ba,D as Ai,C as Ii,S as ji,R as Ni,u as Ye,b as ft,d as wa,e as Li,A as zi,f as Ee,g as Ce,h as Pi,i as Di,O as Cn,k as xa,l as kn,m as Oi,T as Sa,n as _a,o as Ea,p as Gi,q as Mi,r as Ca,s as $i,t as Fi,v as Hi,w as Bi,x as Vi,y as ct,z as Ui,B as qi}from"./ui-vendor-CeCm8EER.js";import{t as Wi,c as ka,a as nr,b as Xi}from"./utils-vendor-BysuhMZA.js";function fe(...t){return Wi(ka(t))}function or(t){return t instanceof Error?t.message:`${t}`}function Jg(t,e){let r=0,n=null;return function(...a){const o=Date.now(),l=e-(o-r);l<=0?(n&&(clearTimeout(n),n=null),r=o,t.apply(this,a)):n||(n=setTimeout(()=>{r=Date.now(),n=null,t.apply(this,a)},l))}}const Tn=t=>{const e=t;e.use={};for(const r of Object.keys(e.getState()))e.use[r]=()=>e(n=>n[r]);return e},Zr="",Zg="/webui/",ze="ghost",en="#B2EBF2",Kn="#000",Yi="#000",Ki="#E2E2E2",tn="#EEEEEE",Qi="#F57F17",Ji="#969696",Zi="#F57F17",Qn="#B2EBF2",Nt=50,el=500,tl="1.0",rn=300,Ta=50,Lt=300,ut=4,nn=20,rl=15,Jn="*",ep={"text/plain":[".txt",".md",".rtf",".odt",".tex",".epub",".html",".htm",".csv",".json",".xml",".yaml",".yml",".log",".conf",".ini",".properties",".sql",".bat",".sh",".c",".cpp",".py",".java",".js",".ts",".swift",".go",".rb",".php",".css",".scss",".less"],"application/pdf":[".pdf"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":[".pptx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[".xlsx"]},tp={name:"LightRAG",github:"https://github.com/HKUDS/LightRAG"},nl="modulepreload",ol=function(t){return"/webui/"+t},Zn={},al=function(e,r,n){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),i=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=Promise.allSettled(r.map(s=>{if(s=ol(s),s in Zn)return;Zn[s]=!0;const c=s.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${s}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":nl,c||(d.as="script"),d.crossOrigin="",d.href=s,i&&d.setAttribute("nonce",i),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${s}`)))})}))}function o(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return a.then(l=>{for(const i of l||[])i.status==="rejected"&&o(i.reason);return e().catch(o)})};function Ra(t,e){let r;try{r=t()}catch{return}return{getItem:a=>{var o;const l=s=>s===null?null:JSON.parse(s,void 0),i=(o=r.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>r.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>r.removeItem(a)}}const on=t=>e=>{try{const r=t(e);return r instanceof Promise?r:{then(n){return on(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return on(n)(r)}}}},sl=(t,e)=>(r,n,a)=>{let o={storage:Ra(()=>localStorage),partialize:b=>b,version:0,merge:(b,R)=>({...R,...b}),...e},l=!1;const i=new Set,s=new Set;let c=o.storage;if(!c)return t((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...b)},n,a);const u=()=>{const b=o.partialize({...n()});return c.setItem(o.name,{state:b,version:o.version})},d=a.setState;a.setState=(b,R)=>{d(b,R),u()};const h=t((...b)=>{r(...b),u()},n,a);a.getInitialState=()=>h;let f;const y=()=>{var b,R;if(!c)return;l=!1,i.forEach(S=>{var k;return S((k=n())!=null?k:h)});const P=((R=o.onRehydrateStorage)==null?void 0:R.call(o,(b=n())!=null?b:h))||void 0;return on(c.getItem.bind(c))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const k=o.migrate(S.state,S.version);return k instanceof Promise?k.then(A=>[!0,A]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var k;const[A,j]=S;if(f=o.merge(j,(k=n())!=null?k:h),r(f,!0),A)return u()}).then(()=>{P==null||P(f,void 0),f=n(),l=!0,s.forEach(S=>S(f))}).catch(S=>{P==null||P(void 0,S)})};return a.persist={setOptions:b=>{o={...o,...b},b.storage&&(c=b.storage)},clearStorage:()=>{c==null||c.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>l,onHydrate:b=>(i.add(b),()=>{i.delete(b)}),onFinishHydration:b=>(s.add(b),()=>{s.delete(b)})},o.skipHydration||y(),f||h},il=sl,ll=nr()(il(t=>({theme:"system",language:"en",showPropertyPanel:!0,showNodeSearchBar:!0,showLegend:!1,showNodeLabel:!0,enableNodeDrag:!0,showEdgeLabel:!1,enableHideUnselectedEdges:!0,enableEdgeEvents:!1,minEdgeSize:1,maxEdgeSize:1,graphQueryMaxDepth:3,graphMaxNodes:1e3,backendMaxGraphNodes:null,graphLayoutMaxIterations:15,queryLabel:Jn,enableHealthCheck:!0,apiKey:null,currentTab:"documents",showFileName:!1,documentsPageSize:10,retrievalHistory:[],querySettings:{mode:"global",response_type:"Multiple Paragraphs",top_k:40,chunk_top_k:20,max_entity_tokens:6e3,max_relation_tokens:8e3,max_total_tokens:3e4,only_need_context:!1,only_need_prompt:!1,stream:!0,history_turns:0,user_prompt:"",enable_rerank:!0},setTheme:e=>t({theme:e}),setLanguage:e=>{t({language:e}),al(async()=>{const{default:r}=await import("./utils-vendor-BysuhMZA.js").then(n=>n.d);return{default:r}},__vite__mapDeps([0,1])).then(({default:r})=>{r.language!==e&&r.changeLanguage(e)})},setGraphLayoutMaxIterations:e=>t({graphLayoutMaxIterations:e}),setQueryLabel:e=>t({queryLabel:e}),setGraphQueryMaxDepth:e=>t({graphQueryMaxDepth:e}),setGraphMaxNodes:(e,r=!1)=>{const n=te.getState();if(n.graphMaxNodes!==e)if(r){const a=n.queryLabel;t({graphMaxNodes:e,queryLabel:""}),setTimeout(()=>{t({queryLabel:a})},300)}else t({graphMaxNodes:e})},setBackendMaxGraphNodes:e=>t({backendMaxGraphNodes:e}),setMinEdgeSize:e=>t({minEdgeSize:e}),setMaxEdgeSize:e=>t({maxEdgeSize:e}),setEnableHealthCheck:e=>t({enableHealthCheck:e}),setApiKey:e=>t({apiKey:e}),setCurrentTab:e=>t({currentTab:e}),setRetrievalHistory:e=>t({retrievalHistory:e}),updateQuerySettings:e=>{const r={...e};delete r.history_turns,t(n=>({querySettings:{...n.querySettings,...r,history_turns:0}}))},setShowFileName:e=>t({showFileName:e}),setShowLegend:e=>t({showLegend:e}),setDocumentsPageSize:e=>t({documentsPageSize:e})}),{name:"settings-storage",storage:Ra(()=>localStorage),version:17,migrate:(t,e)=>(e<2&&(t.showEdgeLabel=!1),e<3&&(t.queryLabel=Jn),e<4&&(t.showPropertyPanel=!0,t.showNodeSearchBar=!0,t.showNodeLabel=!0,t.enableHealthCheck=!0,t.apiKey=null),e<5&&(t.currentTab="documents"),e<6&&(t.querySettings={mode:"global",response_type:"Multiple Paragraphs",top_k:10,max_token_for_text_unit:4e3,max_token_for_global_context:4e3,max_token_for_local_context:4e3,only_need_context:!1,only_need_prompt:!1,stream:!0,history_turns:0,hl_keywords:[],ll_keywords:[]},t.retrievalHistory=[]),e<7&&(t.graphQueryMaxDepth=3,t.graphLayoutMaxIterations=15),e<8&&(t.graphMinDegree=0,t.language="en"),e<9&&(t.showFileName=!1),e<10&&(delete t.graphMinDegree,t.graphMaxNodes=1e3),e<11&&(t.minEdgeSize=1,t.maxEdgeSize=1),e<12&&(t.retrievalHistory=[]),e<13&&t.querySettings&&(t.querySettings.user_prompt=""),e<14&&(t.backendMaxGraphNodes=null),e<15&&(t.querySettings={...t.querySettings,mode:"mix",response_type:"Multiple Paragraphs",top_k:40,chunk_top_k:10,max_entity_tokens:1e4,max_relation_tokens:1e4,max_total_tokens:32e3,enable_rerank:!0,history_turns:0}),e<16&&(t.documentsPageSize=10),e<17&&t.querySettings&&(t.querySettings.history_turns=0),t)})),te=Tn(ll);class cl{constructor(){Ne(this,"nodes",[]);Ne(this,"edges",[]);Ne(this,"nodeIdMap",{});Ne(this,"edgeIdMap",{});Ne(this,"edgeDynamicIdMap",{});Ne(this,"getNode",e=>{const r=this.nodeIdMap[e];if(r!==void 0)return this.nodes[r]});Ne(this,"getEdge",(e,r=!0)=>{const n=r?this.edgeDynamicIdMap[e]:this.edgeIdMap[e];if(n!==void 0)return this.edges[n]});Ne(this,"buildDynamicMap",()=>{this.edgeDynamicIdMap={};for(let e=0;e<this.edges.length;e++){const r=this.edges[e];this.edgeDynamicIdMap[r.dynamicId]=e}})}}const ul=nr()((t,e)=>({selectedNode:null,focusedNode:null,selectedEdge:null,focusedEdge:null,moveToSelectedNode:!1,isFetching:!1,graphIsEmpty:!1,lastSuccessfulQueryLabel:"",graphDataFetchAttempted:!1,labelsFetchAttempted:!1,rawGraph:null,sigmaGraph:null,sigmaInstance:null,typeColorMap:new Map,searchEngine:null,setGraphIsEmpty:r=>t({graphIsEmpty:r}),setLastSuccessfulQueryLabel:r=>t({lastSuccessfulQueryLabel:r}),setIsFetching:r=>t({isFetching:r}),setSelectedNode:(r,n)=>t({selectedNode:r,moveToSelectedNode:n}),setFocusedNode:r=>t({focusedNode:r}),setSelectedEdge:r=>t({selectedEdge:r}),setFocusedEdge:r=>t({focusedEdge:r}),clearSelection:()=>t({selectedNode:null,focusedNode:null,selectedEdge:null,focusedEdge:null}),reset:()=>{t({selectedNode:null,focusedNode:null,selectedEdge:null,focusedEdge:null,rawGraph:null,sigmaGraph:null,searchEngine:null,moveToSelectedNode:!1,graphIsEmpty:!1})},setRawGraph:r=>t({rawGraph:r}),setSigmaGraph:r=>{t({sigmaGraph:r})},setMoveToSelectedNode:r=>t({moveToSelectedNode:r}),setSigmaInstance:r=>t({sigmaInstance:r}),setTypeColorMap:r=>t({typeColorMap:r}),setSearchEngine:r=>t({searchEngine:r}),resetSearchEngine:()=>t({searchEngine:null}),setGraphDataFetchAttempted:r=>t({graphDataFetchAttempted:r}),setLabelsFetchAttempted:r=>t({labelsFetchAttempted:r}),nodeToExpand:null,nodeToPrune:null,triggerNodeExpand:r=>t({nodeToExpand:r}),triggerNodePrune:r=>t({nodeToPrune:r}),graphDataVersion:0,incrementGraphDataVersion:()=>t(r=>({graphDataVersion:r.graphDataVersion+1})),updateNodeAndSelect:async(r,n,a,o)=>{const l=e(),{sigmaGraph:i,rawGraph:s}=l;if(!(!i||!s||!i.hasNode(r)))try{const c=i.getNodeAttributes(r);if(console.log("updateNodeAndSelect",r,n,a,o),r===n&&a==="entity_id"){i.addNode(o,{...c,label:o});const u=[];i.forEachEdge(r,(h,f,y,b)=>{const R=y===r?b:y,P=y===r,S=h,k=s.edgeDynamicIdMap[S],A=i.addEdge(P?o:R,P?R:o,f);k!==void 0&&u.push({originalDynamicId:S,newEdgeId:A,edgeIndex:k}),i.dropEdge(h)}),i.dropNode(r);const d=s.nodeIdMap[r];d!==void 0&&(s.nodes[d].id=o,s.nodes[d].labels=[o],s.nodes[d].properties.entity_id=o,delete s.nodeIdMap[r],s.nodeIdMap[o]=d),u.forEach(({originalDynamicId:h,newEdgeId:f,edgeIndex:y})=>{s.edges[y]&&(s.edges[y].source===r&&(s.edges[y].source=o),s.edges[y].target===r&&(s.edges[y].target=o),s.edges[y].dynamicId=f,delete s.edgeDynamicIdMap[h],s.edgeDynamicIdMap[f]=y)}),t({selectedNode:o,moveToSelectedNode:!0})}else{const u=s.nodeIdMap[String(r)];u!==void 0&&(s.nodes[u].properties[a]=o,a==="entity_id"&&(s.nodes[u].labels=[o],i.setNodeAttribute(String(r),"label",o))),t(d=>({graphDataVersion:d.graphDataVersion+1}))}}catch(c){throw console.error("Error updating node in graph:",c),new Error("Failed to update node in graph")}},updateEdgeAndSelect:async(r,n,a,o,l,i)=>{const s=e(),{sigmaGraph:c,rawGraph:u}=s;if(!(!c||!u))try{const d=u.edgeIdMap[String(r)];d!==void 0&&u.edges[d]&&(u.edges[d].properties[l]=i,n!==void 0&&l==="keywords"&&c.setEdgeAttribute(n,"label",i)),t(h=>({graphDataVersion:h.graphDataVersion+1})),t({selectedEdge:n})}catch(d){throw console.error(`Error updating edge ${a}->${o} in graph:`,d),new Error("Failed to update edge in graph")}}})),Z=Tn(ul);class dl{constructor(){Ne(this,"navigate",null)}setNavigate(e){this.navigate=e}resetAllApplicationState(e=!1){console.log("Resetting all application state...");const r=Z.getState(),n=r.sigmaInstance;r.reset(),r.setGraphDataFetchAttempted(!1),r.setLabelsFetchAttempted(!1),r.setSigmaInstance(null),r.setIsFetching(!1),Rn.getState().clear(),e||te.getState().setRetrievalHistory([]),sessionStorage.clear(),n&&(n.getGraph().clear(),n.kill(),Z.getState().setSigmaInstance(null))}navigateToLogin(){if(!this.navigate){console.error("Navigation function not set");return}const e=Xt.getState().username;e&&localStorage.setItem("LIGHTRAG-PREVIOUS-USER",e),this.resetAllApplicationState(!0),Xt.getState().logout(),this.navigate("/login")}navigateToHome(){if(!this.navigate){console.error("Navigation function not set");return}this.navigate("/")}}const Aa=new dl,rp="Invalid API Key",np="API Key required",we=Xi.create({baseURL:Zr,headers:{"Content-Type":"application/json"}});we.interceptors.request.use(t=>{const e=te.getState().apiKey,r=localStorage.getItem("LIGHTRAG-API-TOKEN");return r&&(t.headers.Authorization=`Bearer ${r}`),e&&(t.headers["X-API-Key"]=e),t});we.interceptors.response.use(t=>t,t=>{var e,r,n,a;if(t.response){if(((e=t.response)==null?void 0:e.status)===401){if((n=(r=t.config)==null?void 0:r.url)!=null&&n.includes("/login"))throw t;return Aa.navigateToLogin(),Promise.reject(new Error("Authentication required"))}throw new Error(`${t.response.status} ${t.response.statusText}
${JSON.stringify(t.response.data)}
${(a=t.config)==null?void 0:a.url}`)}throw t});const Ia=async(t,e,r)=>(await we.get(`/graphs?label=${encodeURIComponent(t)}&max_depth=${e}&max_nodes=${r}`)).data,eo=async(t=rn)=>(await we.get(`/graph/label/popular?limit=${t}`)).data,fl=async(t,e=Ta)=>(await we.get(`/graph/label/search?q=${encodeURIComponent(t)}&limit=${e}`)).data,hl=async()=>{try{return(await we.get("/health")).data}catch(t){return{status:"error",message:or(t)}}},op=async()=>(await we.post("/documents/scan")).data,ap=async t=>(await we.post("/query",t)).data,sp=async(t,e,r)=>{const n=te.getState().apiKey,a=localStorage.getItem("LIGHTRAG-API-TOKEN"),o={"Content-Type":"application/json",Accept:"application/x-ndjson"};a&&(o.Authorization=`Bearer ${a}`),n&&(o["X-API-Key"]=n);try{const l=await fetch(`${Zr}/query/stream`,{method:"POST",headers:o,body:JSON.stringify(t)});if(!l.ok){if(l.status===401)throw Aa.navigateToLogin(),new Error("Authentication required");let u="Unknown error";try{u=await l.text()}catch{}const d=`${Zr}/query/stream`;throw new Error(`${l.status} ${l.statusText}
${JSON.stringify({error:u})}
${d}`)}if(!l.body)throw new Error("Response body is null");const i=l.body.getReader(),s=new TextDecoder;let c="";for(;;){const{done:u,value:d}=await i.read();if(u)break;c+=s.decode(d,{stream:!0});const h=c.split(`
`);c=h.pop()||"";for(const f of h)if(f.trim())try{const y=JSON.parse(f);y.response?e(y.response):y.error&&r&&r(y.error)}catch(y){console.error("Error parsing stream chunk:",f,y),r&&r(`Error parsing server response: ${f}`)}}if(c.trim())try{const u=JSON.parse(c);u.response?e(u.response):u.error&&r&&r(u.error)}catch(u){console.error("Error parsing final chunk:",c,u),r&&r(`Error parsing final server response: ${c}`)}}catch(l){const i=or(l);if(i==="Authentication required"){console.error("Authentication required for stream request"),r&&r("Authentication required");return}const s=i.match(/^(\d{3})\s/);if(s){const c=parseInt(s[1],10);let u=i;switch(c){case 403:u="You do not have permission to access this resource (403 Forbidden)",console.error("Permission denied for stream request:",i);break;case 404:u="The requested resource does not exist (404 Not Found)",console.error("Resource not found for stream request:",i);break;case 429:u="Too many requests, please try again later (429 Too Many Requests)",console.error("Rate limited for stream request:",i);break;case 500:case 502:case 503:case 504:u=`Server error, please try again later (${c})`,console.error("Server error for stream request:",i);break;default:console.error("Stream request failed with status code:",c,i)}r&&r(u);return}if(i.includes("NetworkError")||i.includes("Failed to fetch")||i.includes("Network request failed")){console.error("Network error for stream request:",i),r&&r("Network connection error, please check your internet connection");return}if(i.includes("Error parsing")||i.includes("SyntaxError")){console.error("JSON parsing error in stream:",i),r&&r("Error processing response data");return}console.error("Unhandled stream error:",i),r?r(i):console.error("No error handler provided for stream error:",i)}},ip=async(t,e)=>{const r=new FormData;return r.append("file",t),(await we.post("/documents/upload",r,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e!==void 0?a=>{const o=Math.round(a.loaded*100/a.total);e(o)}:void 0})).data},lp=async()=>(await we.delete("/documents")).data,cp=async()=>(await we.post("/documents/clear_cache",{})).data,up=async(t,e=!1)=>(await we.delete("/documents/delete_document",{data:{doc_ids:t,delete_file:e}})).data,dp=async()=>{try{const t=await we.get("/auth-status",{timeout:5e3,headers:{Accept:"application/json"}});if((t.headers["content-type"]||"").includes("text/html"))return console.warn("Received HTML response instead of JSON for auth-status endpoint"),{auth_configured:!0,auth_mode:"enabled"};if(t.data&&typeof t.data=="object"&&"auth_configured"in t.data&&typeof t.data.auth_configured=="boolean"){if(t.data.auth_configured)return t.data;if(t.data.access_token&&typeof t.data.access_token=="string")return t.data;console.warn("Auth not configured but no valid access token provided")}return console.warn("Received invalid auth status response:",t.data),{auth_configured:!0,auth_mode:"enabled"}}catch(t){return console.error("Failed to get auth status:",or(t)),{auth_configured:!0,auth_mode:"enabled"}}},fp=async()=>(await we.get("/documents/pipeline_status")).data,hp=async(t,e)=>{const r=new FormData;return r.append("username",t),r.append("password",e),(await we.post("/login",r,{headers:{"Content-Type":"multipart/form-data"}})).data},gl=async(t,e,r=!1)=>(await we.post("/graph/entity/edit",{entity_name:t,updated_data:e,allow_rename:r})).data,pl=async(t,e,r)=>(await we.post("/graph/relation/edit",{source_id:t,target_id:e,updated_data:r})).data,ml=async t=>{try{return(await we.get(`/graph/entity/exists?name=${encodeURIComponent(t)}`)).data.exists}catch(e){return console.error("Error checking entity name:",e),!1}},gp=async t=>(await we.post("/documents/paginated",t)).data,vl=nr()((t,e)=>({health:!0,message:null,messageTitle:null,lastCheckTime:Date.now(),status:null,pipelineBusy:!1,healthCheckIntervalId:null,healthCheckFunction:null,healthCheckIntervalValue:rl*1e3,check:async()=>{var n;const r=await hl();if(r.status==="healthy"){if((r.core_version||r.api_version)&&Xt.getState().setVersion(r.core_version||null,r.api_version||null),("webui_title"in r||"webui_description"in r)&&Xt.getState().setCustomTitle("webui_title"in r?r.webui_title??null:null,"webui_description"in r?r.webui_description??null:null),(n=r.configuration)!=null&&n.max_graph_nodes){const a=parseInt(r.configuration.max_graph_nodes,10);!isNaN(a)&&a>0&&te.getState().backendMaxGraphNodes!==a&&(te.getState().setBackendMaxGraphNodes(a),te.getState().graphMaxNodes>a&&te.getState().setGraphMaxNodes(a,!0))}return t({health:!0,message:null,messageTitle:null,lastCheckTime:Date.now(),status:r,pipelineBusy:r.pipeline_busy}),!0}return t({health:!1,message:r.message,messageTitle:"Backend Health Check Error!",lastCheckTime:Date.now(),status:null}),!1},clear:()=>{t({health:!0,message:null,messageTitle:null})},setErrorMessage:(r,n)=>{t({health:!1,message:r,messageTitle:n})},setPipelineBusy:r=>{t({pipelineBusy:r})},setHealthCheckFunction:r=>{t({healthCheckFunction:r})},resetHealthCheckTimer:()=>{const{healthCheckIntervalId:r,healthCheckFunction:n,healthCheckIntervalValue:a}=e();if(r&&clearInterval(r),n){n();const o=setInterval(n,a);t({healthCheckIntervalId:o})}},resetHealthCheckTimerDelayed:r=>{setTimeout(()=>{e().resetHealthCheckTimer()},r)},clearHealthCheckTimer:()=>{const{healthCheckIntervalId:r}=e();r&&(clearInterval(r),t({healthCheckIntervalId:null}))}})),Rn=Tn(vl),ja=t=>{try{const e=t.split(".");return e.length!==3?{}:JSON.parse(atob(e[1]))}catch(e){return console.error("Error parsing token payload:",e),{}}},Na=t=>ja(t).sub||null,yl=t=>ja(t).role==="guest",bl=()=>{const t=localStorage.getItem("LIGHTRAG-API-TOKEN"),e=localStorage.getItem("LIGHTRAG-CORE-VERSION"),r=localStorage.getItem("LIGHTRAG-API-VERSION"),n=localStorage.getItem("LIGHTRAG-WEBUI-TITLE"),a=localStorage.getItem("LIGHTRAG-WEBUI-DESCRIPTION"),o=t?Na(t):null;return t?{isAuthenticated:!0,isGuestMode:yl(t),coreVersion:e,apiVersion:r,username:o,webuiTitle:n,webuiDescription:a}:{isAuthenticated:!1,isGuestMode:!1,coreVersion:e,apiVersion:r,username:null,webuiTitle:n,webuiDescription:a}},Xt=nr(t=>{const e=bl();return{isAuthenticated:e.isAuthenticated,isGuestMode:e.isGuestMode,coreVersion:e.coreVersion,apiVersion:e.apiVersion,username:e.username,webuiTitle:e.webuiTitle,webuiDescription:e.webuiDescription,login:(r,n=!1,a=null,o=null,l=null,i=null)=>{localStorage.setItem("LIGHTRAG-API-TOKEN",r),a&&localStorage.setItem("LIGHTRAG-CORE-VERSION",a),o&&localStorage.setItem("LIGHTRAG-API-VERSION",o),l?localStorage.setItem("LIGHTRAG-WEBUI-TITLE",l):localStorage.removeItem("LIGHTRAG-WEBUI-TITLE"),i?localStorage.setItem("LIGHTRAG-WEBUI-DESCRIPTION",i):localStorage.removeItem("LIGHTRAG-WEBUI-DESCRIPTION");const s=Na(r);t({isAuthenticated:!0,isGuestMode:n,username:s,coreVersion:a,apiVersion:o,webuiTitle:l,webuiDescription:i})},logout:()=>{localStorage.removeItem("LIGHTRAG-API-TOKEN");const r=localStorage.getItem("LIGHTRAG-CORE-VERSION"),n=localStorage.getItem("LIGHTRAG-API-VERSION"),a=localStorage.getItem("LIGHTRAG-WEBUI-TITLE"),o=localStorage.getItem("LIGHTRAG-WEBUI-DESCRIPTION");t({isAuthenticated:!1,isGuestMode:!1,username:null,coreVersion:r,apiVersion:n,webuiTitle:a,webuiDescription:o})},setVersion:(r,n)=>{r&&localStorage.setItem("LIGHTRAG-CORE-VERSION",r),n&&localStorage.setItem("LIGHTRAG-API-VERSION",n),t({coreVersion:r,apiVersion:n})},setCustomTitle:(r,n)=>{r?localStorage.setItem("LIGHTRAG-WEBUI-TITLE",r):localStorage.removeItem("LIGHTRAG-WEBUI-TITLE"),n?localStorage.setItem("LIGHTRAG-WEBUI-DESCRIPTION",n):localStorage.removeItem("LIGHTRAG-WEBUI-DESCRIPTION"),t({webuiTitle:r,webuiDescription:n})}}});var wl=t=>{switch(t){case"success":return _l;case"info":return Cl;case"warning":return El;case"error":return kl;default:return null}},xl=Array(12).fill(0),Sl=({visible:t,className:e})=>Y.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},Y.createElement("div",{className:"sonner-spinner"},xl.map((r,n)=>Y.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),_l=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),El=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Cl=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),kl=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Y.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Tl=Y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Y.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Y.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Rl=()=>{let[t,e]=Y.useState(document.hidden);return Y.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},an=1,Al=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,a=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:an++,o=this.toasts.find(i=>i.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(i=>i.id===a?(this.publish({...i,...t,id:a,title:r}),{...i,...t,id:a,dismissible:l,title:r}):i):this.addToast({title:r,...n,dismissible:l,id:a}),a},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),a=r!==void 0,o,l=n.then(async s=>{if(o=["resolve",s],Y.isValidElement(s))a=!1,this.create({id:r,type:"default",message:s});else if(jl(s)&&!s.ok){a=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${s.status}`):e.error,u=typeof e.description=="function"?await e.description(`HTTP error! status: ${s.status}`):e.description;this.create({id:r,type:"error",message:c,description:u})}else if(e.success!==void 0){a=!1;let c=typeof e.success=="function"?await e.success(s):e.success,u=typeof e.description=="function"?await e.description(s):e.description;this.create({id:r,type:"success",message:c,description:u})}}).catch(async s=>{if(o=["reject",s],e.error!==void 0){a=!1;let c=typeof e.error=="function"?await e.error(s):e.error,u=typeof e.description=="function"?await e.description(s):e.description;this.create({id:r,type:"error",message:c,description:u})}}).finally(()=>{var s;a&&(this.dismiss(r),r=void 0),(s=e.finally)==null||s.call(e)}),i=()=>new Promise((s,c)=>l.then(()=>o[0]==="reject"?c(o[1]):s(o[1])).catch(c));return typeof r!="string"&&typeof r!="number"?{unwrap:i}:Object.assign(r,{unwrap:i})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||an++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ae=new Al,Il=(t,e)=>{let r=(e==null?void 0:e.id)||an++;return Ae.addToast({title:t,...e,id:r}),r},jl=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Nl=Il,Ll=()=>Ae.toasts,zl=()=>Ae.getActiveToasts(),nt=Object.assign(Nl,{success:Ae.success,info:Ae.info,warning:Ae.warning,error:Ae.error,custom:Ae.custom,message:Ae.message,promise:Ae.promise,dismiss:Ae.dismiss,loading:Ae.loading},{getHistory:Ll,getToasts:zl});function Pl(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}Pl(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
`);function zt(t){return t.label!==void 0}var Dl=3,Ol="32px",Gl="16px",to=4e3,Ml=356,$l=14,Fl=20,Hl=200;function Fe(...t){return t.filter(Boolean).join(" ")}function Bl(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var Vl=t=>{var e,r,n,a,o,l,i,s,c,u,d;let{invert:h,toast:f,unstyled:y,interacting:b,setHeights:R,visibleToasts:P,heights:S,index:k,toasts:A,expanded:j,removeToast:D,defaultRichColors:v,closeButton:_,style:x,cancelButtonStyle:T,actionButtonStyle:I,className:z="",descriptionClassName:w="",duration:F,position:K,gap:O,loadingIcon:C,expandByDefault:E,classNames:W,icons:re,closeButtonAriaLabel:M="Close toast",pauseWhenPageIsHidden:m}=t,[L,U]=Y.useState(null),[q,Q]=Y.useState(null),[B,X]=Y.useState(!1),[le,ne]=Y.useState(!1),[se,oe]=Y.useState(!1),[$,V]=Y.useState(!1),[H,N]=Y.useState(!1),[ae,ue]=Y.useState(0),[ee,J]=Y.useState(0),G=Y.useRef(f.duration||F||to),he=Y.useRef(null),pe=Y.useRef(null),ye=k===0,xe=k+1<=P,de=f.type,me=f.dismissible!==!1,je=f.className||"",ke=f.descriptionClassName||"",Te=Y.useMemo(()=>S.findIndex(ce=>ce.toastId===f.id)||0,[S,f.id]),De=Y.useMemo(()=>{var ce;return(ce=f.closeButton)!=null?ce:_},[f.closeButton,_]),Ke=Y.useMemo(()=>f.duration||F||to,[f.duration,F]),Qe=Y.useRef(0),Re=Y.useRef(0),st=Y.useRef(0),Oe=Y.useRef(null),[fi,hi]=K.split("-"),qn=Y.useMemo(()=>S.reduce((ce,ge,ve)=>ve>=Te?ce:ce+ge.height,0),[S,Te]),Wn=Rl(),gi=f.invert||h,mr=de==="loading";Re.current=Y.useMemo(()=>Te*O+qn,[Te,qn]),Y.useEffect(()=>{G.current=Ke},[Ke]),Y.useEffect(()=>{X(!0)},[]),Y.useEffect(()=>{let ce=pe.current;if(ce){let ge=ce.getBoundingClientRect().height;return J(ge),R(ve=>[{toastId:f.id,height:ge,position:f.position},...ve]),()=>R(ve=>ve.filter(Ge=>Ge.toastId!==f.id))}},[R,f.id]),Y.useLayoutEffect(()=>{if(!B)return;let ce=pe.current,ge=ce.style.height;ce.style.height="auto";let ve=ce.getBoundingClientRect().height;ce.style.height=ge,J(ve),R(Ge=>Ge.find(Me=>Me.toastId===f.id)?Ge.map(Me=>Me.toastId===f.id?{...Me,height:ve}:Me):[{toastId:f.id,height:ve,position:f.position},...Ge])},[B,f.title,f.description,R,f.id]);let Je=Y.useCallback(()=>{ne(!0),ue(Re.current),R(ce=>ce.filter(ge=>ge.toastId!==f.id)),setTimeout(()=>{D(f)},Hl)},[f,D,R,Re]);Y.useEffect(()=>{if(f.promise&&de==="loading"||f.duration===1/0||f.type==="loading")return;let ce;return j||b||m&&Wn?(()=>{if(st.current<Qe.current){let ge=new Date().getTime()-Qe.current;G.current=G.current-ge}st.current=new Date().getTime()})():G.current!==1/0&&(Qe.current=new Date().getTime(),ce=setTimeout(()=>{var ge;(ge=f.onAutoClose)==null||ge.call(f,f),Je()},G.current)),()=>clearTimeout(ce)},[j,b,f,de,m,Wn,Je]),Y.useEffect(()=>{f.delete&&Je()},[Je,f.delete]);function pi(){var ce,ge,ve;return re!=null&&re.loading?Y.createElement("div",{className:Fe(W==null?void 0:W.loader,(ce=f==null?void 0:f.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":de==="loading"},re.loading):C?Y.createElement("div",{className:Fe(W==null?void 0:W.loader,(ge=f==null?void 0:f.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":de==="loading"},C):Y.createElement(Sl,{className:Fe(W==null?void 0:W.loader,(ve=f==null?void 0:f.classNames)==null?void 0:ve.loader),visible:de==="loading"})}return Y.createElement("li",{tabIndex:0,ref:pe,className:Fe(z,je,W==null?void 0:W.toast,(e=f==null?void 0:f.classNames)==null?void 0:e.toast,W==null?void 0:W.default,W==null?void 0:W[de],(r=f==null?void 0:f.classNames)==null?void 0:r[de]),"data-sonner-toast":"","data-rich-colors":(n=f.richColors)!=null?n:v,"data-styled":!(f.jsx||f.unstyled||y),"data-mounted":B,"data-promise":!!f.promise,"data-swiped":H,"data-removed":le,"data-visible":xe,"data-y-position":fi,"data-x-position":hi,"data-index":k,"data-front":ye,"data-swiping":se,"data-dismissible":me,"data-type":de,"data-invert":gi,"data-swipe-out":$,"data-swipe-direction":q,"data-expanded":!!(j||E&&B),style:{"--index":k,"--toasts-before":k,"--z-index":A.length-k,"--offset":`${le?ae:Re.current}px`,"--initial-height":E?"auto":`${ee}px`,...x,...f.style},onDragEnd:()=>{oe(!1),U(null),Oe.current=null},onPointerDown:ce=>{mr||!me||(he.current=new Date,ue(Re.current),ce.target.setPointerCapture(ce.pointerId),ce.target.tagName!=="BUTTON"&&(oe(!0),Oe.current={x:ce.clientX,y:ce.clientY}))},onPointerUp:()=>{var ce,ge,ve,Ge;if($||!me)return;Oe.current=null;let Me=Number(((ce=pe.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ze=Number(((ge=pe.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),it=new Date().getTime()-((ve=he.current)==null?void 0:ve.getTime()),$e=L==="x"?Me:Ze,et=Math.abs($e)/it;if(Math.abs($e)>=Fl||et>.11){ue(Re.current),(Ge=f.onDismiss)==null||Ge.call(f,f),Q(L==="x"?Me>0?"right":"left":Ze>0?"down":"up"),Je(),V(!0),N(!1);return}oe(!1),U(null)},onPointerMove:ce=>{var ge,ve,Ge,Me;if(!Oe.current||!me||((ge=window.getSelection())==null?void 0:ge.toString().length)>0)return;let Ze=ce.clientY-Oe.current.y,it=ce.clientX-Oe.current.x,$e=(ve=t.swipeDirections)!=null?ve:Bl(K);!L&&(Math.abs(it)>1||Math.abs(Ze)>1)&&U(Math.abs(it)>Math.abs(Ze)?"x":"y");let et={x:0,y:0};L==="y"?($e.includes("top")||$e.includes("bottom"))&&($e.includes("top")&&Ze<0||$e.includes("bottom")&&Ze>0)&&(et.y=Ze):L==="x"&&($e.includes("left")||$e.includes("right"))&&($e.includes("left")&&it<0||$e.includes("right")&&it>0)&&(et.x=it),(Math.abs(et.x)>0||Math.abs(et.y)>0)&&N(!0),(Ge=pe.current)==null||Ge.style.setProperty("--swipe-amount-x",`${et.x}px`),(Me=pe.current)==null||Me.style.setProperty("--swipe-amount-y",`${et.y}px`)}},De&&!f.jsx?Y.createElement("button",{"aria-label":M,"data-disabled":mr,"data-close-button":!0,onClick:mr||!me?()=>{}:()=>{var ce;Je(),(ce=f.onDismiss)==null||ce.call(f,f)},className:Fe(W==null?void 0:W.closeButton,(a=f==null?void 0:f.classNames)==null?void 0:a.closeButton)},(o=re==null?void 0:re.close)!=null?o:Tl):null,f.jsx||p.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:Y.createElement(Y.Fragment,null,de||f.icon||f.promise?Y.createElement("div",{"data-icon":"",className:Fe(W==null?void 0:W.icon,(l=f==null?void 0:f.classNames)==null?void 0:l.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||pi():null,f.type!=="loading"?f.icon||(re==null?void 0:re[de])||wl(de):null):null,Y.createElement("div",{"data-content":"",className:Fe(W==null?void 0:W.content,(i=f==null?void 0:f.classNames)==null?void 0:i.content)},Y.createElement("div",{"data-title":"",className:Fe(W==null?void 0:W.title,(s=f==null?void 0:f.classNames)==null?void 0:s.title)},typeof f.title=="function"?f.title():f.title),f.description?Y.createElement("div",{"data-description":"",className:Fe(w,ke,W==null?void 0:W.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),p.isValidElement(f.cancel)?f.cancel:f.cancel&&zt(f.cancel)?Y.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||T,onClick:ce=>{var ge,ve;zt(f.cancel)&&me&&((ve=(ge=f.cancel).onClick)==null||ve.call(ge,ce),Je())},className:Fe(W==null?void 0:W.cancelButton,(u=f==null?void 0:f.classNames)==null?void 0:u.cancelButton)},f.cancel.label):null,p.isValidElement(f.action)?f.action:f.action&&zt(f.action)?Y.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||I,onClick:ce=>{var ge,ve;zt(f.action)&&((ve=(ge=f.action).onClick)==null||ve.call(ge,ce),!ce.defaultPrevented&&Je())},className:Fe(W==null?void 0:W.actionButton,(d=f==null?void 0:f.classNames)==null?void 0:d.actionButton)},f.action.label):null))};function ro(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Ul(t,e){let r={};return[t,e].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Gl:Ol;function s(c){["top","right","bottom","left"].forEach(u=>{r[`${l}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?s(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${l}-${c}`]=i:r[`${l}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):s(i)}),r}var pp=p.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:s,mobileOffset:c,theme:u="light",richColors:d,duration:h,style:f,visibleToasts:y=Dl,toastOptions:b,dir:R=ro(),gap:P=$l,loadingIcon:S,icons:k,containerAriaLabel:A="Notifications",pauseWhenPageIsHidden:j}=t,[D,v]=Y.useState([]),_=Y.useMemo(()=>Array.from(new Set([n].concat(D.filter(m=>m.position).map(m=>m.position)))),[D,n]),[x,T]=Y.useState([]),[I,z]=Y.useState(!1),[w,F]=Y.useState(!1),[K,O]=Y.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),C=Y.useRef(null),E=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),W=Y.useRef(null),re=Y.useRef(!1),M=Y.useCallback(m=>{v(L=>{var U;return(U=L.find(q=>q.id===m.id))!=null&&U.delete||Ae.dismiss(m.id),L.filter(({id:q})=>q!==m.id)})},[]);return Y.useEffect(()=>Ae.subscribe(m=>{if(m.dismiss){v(L=>L.map(U=>U.id===m.id?{...U,delete:!0}:U));return}setTimeout(()=>{yi.flushSync(()=>{v(L=>{let U=L.findIndex(q=>q.id===m.id);return U!==-1?[...L.slice(0,U),{...L[U],...m},...L.slice(U+1)]:[m,...L]})})})}),[]),Y.useEffect(()=>{if(u!=="system"){O(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?O("dark"):O("light")),typeof window>"u")return;let m=window.matchMedia("(prefers-color-scheme: dark)");try{m.addEventListener("change",({matches:L})=>{O(L?"dark":"light")})}catch{m.addListener(({matches:U})=>{try{O(U?"dark":"light")}catch(q){console.error(q)}})}},[u]),Y.useEffect(()=>{D.length<=1&&z(!1)},[D]),Y.useEffect(()=>{let m=L=>{var U,q;a.every(Q=>L[Q]||L.code===Q)&&(z(!0),(U=C.current)==null||U.focus()),L.code==="Escape"&&(document.activeElement===C.current||(q=C.current)!=null&&q.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[a]),Y.useEffect(()=>{if(C.current)return()=>{W.current&&(W.current.focus({preventScroll:!0}),W.current=null,re.current=!1)}},[C.current]),Y.createElement("section",{ref:e,"aria-label":`${A} ${E}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((m,L)=>{var U;let[q,Q]=m.split("-");return D.length?Y.createElement("ol",{key:m,dir:R==="auto"?ro():R,tabIndex:-1,ref:C,className:i,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":q,"data-lifted":I&&D.length>1&&!o,"data-x-position":Q,style:{"--front-toast-height":`${((U=x[0])==null?void 0:U.height)||0}px`,"--width":`${Ml}px`,"--gap":`${P}px`,...f,...Ul(s,c)},onBlur:B=>{re.current&&!B.currentTarget.contains(B.relatedTarget)&&(re.current=!1,W.current&&(W.current.focus({preventScroll:!0}),W.current=null))},onFocus:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||re.current||(re.current=!0,W.current=B.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{w||z(!1)},onDragEnd:()=>z(!1),onPointerDown:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},D.filter(B=>!B.position&&L===0||B.position===m).map((B,X)=>{var le,ne;return Y.createElement(Vl,{key:B.id,icons:k,index:X,toast:B,defaultRichColors:d,duration:(le=b==null?void 0:b.duration)!=null?le:h,className:b==null?void 0:b.className,descriptionClassName:b==null?void 0:b.descriptionClassName,invert:r,visibleToasts:y,closeButton:(ne=b==null?void 0:b.closeButton)!=null?ne:l,interacting:w,position:m,style:b==null?void 0:b.style,unstyled:b==null?void 0:b.unstyled,classNames:b==null?void 0:b.classNames,cancelButtonStyle:b==null?void 0:b.cancelButtonStyle,actionButtonStyle:b==null?void 0:b.actionButtonStyle,removeToast:M,toasts:D.filter(se=>se.position==B.position),heights:x.filter(se=>se.position==B.position),setHeights:T,expandByDefault:o,gap:P,loadingIcon:S,expanded:I,pauseWhenPageIsHidden:j,swipeDirections:t.swipeDirections})})):null}))});const ql={theme:"system",setTheme:()=>null},La=p.createContext(ql);function mp({children:t,...e}){const r=te.use.theme(),n=te.use.setTheme();p.useEffect(()=>{const o=window.document.documentElement;if(o.classList.remove("light","dark"),r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),i=s=>{o.classList.remove("light","dark"),o.classList.add(s.matches?"dark":"light")};return o.classList.add(l.matches?"dark":"light"),l.addEventListener("change",i),()=>l.removeEventListener("change",i)}else o.classList.add(r)},[r]);const a={theme:r,setTheme:n};return g.jsx(La.Provider,{...e,value:a,children:t})}const Wl=(t,e,r,n)=>{var o,l,i,s;const a=[r,{code:e,...n||{}}];if((l=(o=t==null?void 0:t.services)==null?void 0:o.logger)!=null&&l.forward)return t.services.logger.forward(a,"warn","react-i18next::",!0);ht(a[0])&&(a[0]=`react-i18next:: ${a[0]}`),(s=(i=t==null?void 0:t.services)==null?void 0:i.logger)!=null&&s.warn?t.services.logger.warn(...a):console!=null&&console.warn&&console.warn(...a)},no={},sn=(t,e,r,n)=>{ht(r)&&no[r]||(ht(r)&&(no[r]=new Date),Wl(t,e,r,n))},za=(t,e)=>()=>{if(t.isInitialized)e();else{const r=()=>{setTimeout(()=>{t.off("initialized",r)},0),e()};t.on("initialized",r)}},ln=(t,e,r)=>{t.loadNamespaces(e,za(t,r))},oo=(t,e,r,n)=>{if(ht(r)&&(r=[r]),t.options.preload&&t.options.preload.indexOf(e)>-1)return ln(t,r,n);r.forEach(a=>{t.options.ns.indexOf(a)<0&&t.options.ns.push(a)}),t.loadLanguages(e,za(t,n))},Xl=(t,e,r={})=>!e.languages||!e.languages.length?(sn(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:r.lng,precheck:(n,a)=>{var o;if(((o=r.bindI18n)==null?void 0:o.indexOf("languageChanging"))>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!a(n.isLanguageChangingTo,t))return!1}}),ht=t=>typeof t=="string",Yl=t=>typeof t=="object"&&t!==null,Kl=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Ql={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Jl=t=>Ql[t],Zl=t=>t.replace(Kl,Jl);let cn={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Zl};const ec=(t={})=>{cn={...cn,...t}},tc=()=>cn;let Pa;const rc=t=>{Pa=t},nc=()=>Pa,vp={type:"3rdParty",init(t){ec(t.options.react),rc(t)}},oc=p.createContext();class ac{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const sc=(t,e)=>{const r=p.useRef();return p.useEffect(()=>{r.current=t},[t,e]),r.current},Da=(t,e,r,n)=>t.getFixedT(e,r,n),ic=(t,e,r,n)=>p.useCallback(Da(t,e,r,n),[t,e,r,n]),Se=(t,e={})=>{var A,j,D,v;const{i18n:r}=e,{i18n:n,defaultNS:a}=p.useContext(oc)||{},o=r||n||nc();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new ac),!o){sn(o,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const _=(T,I)=>ht(I)?I:Yl(I)&&ht(I.defaultValue)?I.defaultValue:Array.isArray(T)?T[T.length-1]:T,x=[_,{},!1];return x.t=_,x.i18n={},x.ready=!1,x}(A=o.options.react)!=null&&A.wait&&sn(o,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const l={...tc(),...o.options.react,...e},{useSuspense:i,keyPrefix:s}=l;let c=a||((j=o.options)==null?void 0:j.defaultNS);c=ht(c)?[c]:c||["translation"],(v=(D=o.reportNamespaces).addUsedNamespaces)==null||v.call(D,c);const u=(o.isInitialized||o.initializedStoreOnce)&&c.every(_=>Xl(_,o,l)),d=ic(o,e.lng||null,l.nsMode==="fallback"?c:c[0],s),h=()=>d,f=()=>Da(o,e.lng||null,l.nsMode==="fallback"?c:c[0],s),[y,b]=p.useState(h);let R=c.join();e.lng&&(R=`${e.lng}${R}`);const P=sc(R),S=p.useRef(!0);p.useEffect(()=>{const{bindI18n:_,bindI18nStore:x}=l;S.current=!0,!u&&!i&&(e.lng?oo(o,e.lng,c,()=>{S.current&&b(f)}):ln(o,c,()=>{S.current&&b(f)})),u&&P&&P!==R&&S.current&&b(f);const T=()=>{S.current&&b(f)};return _&&(o==null||o.on(_,T)),x&&(o==null||o.store.on(x,T)),()=>{S.current=!1,o&&(_==null||_.split(" ").forEach(I=>o.off(I,T))),x&&o&&x.split(" ").forEach(I=>o.store.off(I,T))}},[o,R]),p.useEffect(()=>{S.current&&u&&b(h)},[o,s,u]);const k=[y,o,u];if(k.t=y,k.i18n=o,k.ready=u,u||!u&&!i)return k;throw new Promise(_=>{e.lng?oo(o,e.lng,c,()=>_()):ln(o,c,()=>_())})},ao=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,so=ka,lc=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return so(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:o}=e,l=Object.keys(a).map(c=>{const u=r==null?void 0:r[c],d=o==null?void 0:o[c];if(u===null)return null;const h=ao(u)||ao(d);return a[c][h]}),i=r&&Object.entries(r).reduce((c,u)=>{let[d,h]=u;return h===void 0||(c[d]=h),c},{}),s=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:h,...f}=u;return Object.entries(f).every(y=>{let[b,R]=y;return Array.isArray(R)?R.includes({...o,...i}[b]):{...o,...i}[b]===R})?[...c,d,h]:c},[]);return so(t,l,s,r==null?void 0:r.class,r==null?void 0:r.className)};var[ar,yp]=En("Tooltip",[ba]),sr=ba(),Oa="TooltipProvider",cc=700,un="tooltip.open",[uc,An]=ar(Oa),Ga=t=>{const{__scopeTooltip:e,delayDuration:r=cc,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,[l,i]=p.useState(!0),s=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),g.jsx(uc,{scope:e,isOpenDelayed:l,delayDuration:r,onOpen:p.useCallback(()=>{window.clearTimeout(c.current),i(!1)},[]),onClose:p.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i(!0),n)},[n]),isPointerInTransitRef:s,onPointerInTransitChange:p.useCallback(u=>{s.current=u},[]),disableHoverableContent:a,children:o})};Ga.displayName=Oa;var ir="Tooltip",[dc,lr]=ar(ir),Ma=t=>{const{__scopeTooltip:e,children:r,open:n,defaultOpen:a=!1,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,s=An(ir,t.__scopeTooltip),c=sr(e),[u,d]=p.useState(null),h=ft(),f=p.useRef(0),y=l??s.disableHoverableContent,b=i??s.delayDuration,R=p.useRef(!1),[P=!1,S]=wa({prop:n,defaultProp:a,onChange:v=>{v?(s.onOpen(),document.dispatchEvent(new CustomEvent(un))):s.onClose(),o==null||o(v)}}),k=p.useMemo(()=>P?R.current?"delayed-open":"instant-open":"closed",[P]),A=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,R.current=!1,S(!0)},[S]),j=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,S(!1)},[S]),D=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{R.current=!0,S(!0),f.current=0},b)},[b,S]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),g.jsx(Li,{...c,children:g.jsx(dc,{scope:e,contentId:h,open:P,stateAttribute:k,trigger:u,onTriggerChange:d,onTriggerEnter:p.useCallback(()=>{s.isOpenDelayed?D():A()},[s.isOpenDelayed,D,A]),onTriggerLeave:p.useCallback(()=>{y?j():(window.clearTimeout(f.current),f.current=0)},[j,y]),onOpen:A,onClose:j,disableHoverableContent:y,children:r})})};Ma.displayName=ir;var dn="TooltipTrigger",$a=p.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,a=lr(dn,r),o=An(dn,r),l=sr(r),i=p.useRef(null),s=Ye(e,i,a.onTriggerChange),c=p.useRef(!1),u=p.useRef(!1),d=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(zi,{asChild:!0,...l,children:g.jsx(Ee.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:s,onPointerMove:Ce(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ce(t.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:Ce(t.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Ce(t.onFocus,()=>{c.current||a.onOpen()}),onBlur:Ce(t.onBlur,a.onClose),onClick:Ce(t.onClick,a.onClose)})})});$a.displayName=dn;var fc="TooltipPortal",[bp,hc]=ar(fc,{forceMount:void 0}),xt="TooltipContent",Fa=p.forwardRef((t,e)=>{const r=hc(xt,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=lr(xt,t.__scopeTooltip);return g.jsx(_t,{present:n||l.open,children:l.disableHoverableContent?g.jsx(Ha,{side:a,...o,ref:e}):g.jsx(gc,{side:a,...o,ref:e})})}),gc=p.forwardRef((t,e)=>{const r=lr(xt,t.__scopeTooltip),n=An(xt,t.__scopeTooltip),a=p.useRef(null),o=Ye(e,a),[l,i]=p.useState(null),{trigger:s,onClose:c}=r,u=a.current,{onPointerInTransitChange:d}=n,h=p.useCallback(()=>{i(null),d(!1)},[d]),f=p.useCallback((y,b)=>{const R=y.currentTarget,P={x:y.clientX,y:y.clientY},S=yc(P,R.getBoundingClientRect()),k=bc(P,S),A=wc(b.getBoundingClientRect()),j=Sc([...k,...A]);i(j),d(!0)},[d]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(s&&u){const y=R=>f(R,u),b=R=>f(R,s);return s.addEventListener("pointerleave",y),u.addEventListener("pointerleave",b),()=>{s.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",b)}}},[s,u,f,h]),p.useEffect(()=>{if(l){const y=b=>{const R=b.target,P={x:b.clientX,y:b.clientY},S=(s==null?void 0:s.contains(R))||(u==null?void 0:u.contains(R)),k=!xc(P,l);S?h():k&&(h(),c())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[s,u,l,c,h]),g.jsx(Ha,{...t,ref:o})}),[pc,mc]=ar(ir,{isInside:!1}),Ha=p.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,s=lr(xt,r),c=sr(r),{onClose:u}=s;return p.useEffect(()=>(document.addEventListener(un,u),()=>document.removeEventListener(un,u)),[u]),p.useEffect(()=>{if(s.trigger){const d=h=>{const f=h.target;f!=null&&f.contains(s.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[s.trigger,u]),g.jsx(Ai,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:g.jsxs(Ii,{"data-state":s.stateAttribute,...c,...i,ref:e,style:{...i.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[g.jsx(ji,{children:n}),g.jsx(pc,{scope:r,isInside:!0,children:g.jsx(Ni,{id:s.contentId,role:"tooltip",children:a||n})})]})})});Fa.displayName=xt;var Ba="TooltipArrow",vc=p.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,a=sr(r);return mc(Ba,r).isInside?null:g.jsx(Pi,{...a,...n,ref:e})});vc.displayName=Ba;function yc(t,e){const r=Math.abs(e.top-t.y),n=Math.abs(e.bottom-t.y),a=Math.abs(e.right-t.x),o=Math.abs(e.left-t.x);switch(Math.min(r,n,a,o)){case o:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function bc(t,e,r=5){const n=[];switch(e){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function wc(t){const{top:e,right:r,bottom:n,left:a}=t;return[{x:a,y:e},{x:r,y:e},{x:r,y:n},{x:a,y:n}]}function xc(t,e){const{x:r,y:n}=t;let a=!1;for(let o=0,l=e.length-1;o<e.length;l=o++){const i=e[o].x,s=e[o].y,c=e[l].x,u=e[l].y;s>n!=u>n&&r<(c-i)*(n-s)/(u-s)+i&&(a=!a)}return a}function Sc(t){const e=t.slice();return e.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),_c(e)}function _c(t){if(t.length<=1)return t.slice();const e=[];for(let n=0;n<t.length;n++){const a=t[n];for(;e.length>=2;){const o=e[e.length-1],l=e[e.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))e.pop();else break}e.push(a)}e.pop();const r=[];for(let n=t.length-1;n>=0;n--){const a=t[n];for(;r.length>=2;){const o=r[r.length-1],l=r[r.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))r.pop();else break}r.push(a)}return r.pop(),e.length===1&&r.length===1&&e[0].x===r[0].x&&e[0].y===r[0].y?e:e.concat(r)}var Ec=Ga,Cc=Ma,kc=$a,Va=Fa;const Ua=Ec,qa=Cc,Wa=kc,Tc=t=>typeof t!="string"?t:g.jsx("div",{className:"relative top-0 pt-1 whitespace-pre-wrap break-words",children:t}),In=p.forwardRef(({className:t,side:e="left",align:r="start",children:n,...a},o)=>{const l=p.useRef(null);return p.useEffect(()=>{l.current&&(l.current.scrollTop=0)},[n]),g.jsx(Va,{ref:o,side:e,align:r,className:fe("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-words rounded-md border px-3 py-2 text-sm shadow-md z-60",t),...a,children:typeof n=="string"?Tc(n):n})});In.displayName=Va.displayName;const io=lc("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"size-8"}},defaultVariants:{variant:"default",size:"default"}}),be=p.forwardRef(({className:t,variant:e,tooltip:r,size:n,side:a="right",asChild:o=!1,...l},i)=>{const s=o?Di:"button";return r?g.jsx(Ua,{children:g.jsxs(qa,{children:[g.jsx(Wa,{asChild:!0,children:g.jsx(s,{className:fe(io({variant:e,size:n,className:t}),"cursor-pointer"),ref:i,...l})}),g.jsx(In,{side:a,children:r})]})}):g.jsx(s,{className:fe(io({variant:e,size:n,className:t}),"cursor-pointer"),ref:i,...l})});be.displayName="Button";const Yt=p.forwardRef(({className:t,type:e,...r},n)=>g.jsx("input",{type:e,className:fe("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-9 rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm [&::-webkit-inner-spin-button]:opacity-50 [&::-webkit-outer-spin-button]:opacity-50",t),ref:n,...r}));Yt.displayName="Input";/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rc=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Xa=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var Ac={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ic=p.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},s)=>p.createElement("svg",{ref:s,...Ac,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:Xa("lucide",a),...i},[...l.map(([c,u])=>p.createElement(c,u)),...Array.isArray(o)?o:[o]]));/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ie=(t,e)=>{const r=p.forwardRef(({className:n,...a},o)=>p.createElement(Ic,{ref:o,iconNode:e,className:Xa(`lucide-${Rc(t)}`,n),...a}));return r.displayName=`${t}`,r};/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jc=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],wp=ie("Activity",jc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Nc=[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],xp=ie("AlignCenter",Nc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Lc=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Sp=ie("AlignLeft",Lc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zc=[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],_p=ie("AlignRight",zc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pc=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Ep=ie("ArrowDown",Pc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Dc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Cp=ie("ArrowUp",Dc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Oc=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Gc=ie("BookOpen",Oc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Mc=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ya=ie("Check",Mc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $c=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],kp=ie("ChevronDown",$c);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Tp=ie("ChevronLeft",Fc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Hc=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Rp=ie("ChevronRight",Hc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ap=ie("ChevronUp",Bc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vc=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Ip=ie("ChevronsLeft",Vc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Uc=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],jp=ie("ChevronsRight",Uc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qc=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Wc=ie("ChevronsUpDown",qc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xc=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Np=ie("Copy",Xc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yc=[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]],Lp=ie("Eraser",Yc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Kc=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],zp=ie("FileText",Kc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qc=[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]],Pp=ie("Files",Qc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Jc=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],Zc=ie("Fullscreen",Jc);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eu=[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]],tu=ie("GitBranchPlus",eu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ru=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],Dp=ie("Github",ru);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nu=[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]],ou=ie("Grip",nu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const au=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Op=ie("Info",au);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const su=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ka=ie("LoaderCircle",su);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iu=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Gp=ie("Loader",iu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lu=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Mp=ie("LogOut",lu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cu=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],uu=ie("Maximize",cu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const du=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],fu=ie("Minimize",du);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hu=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],$p=ie("Palette",hu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gu=[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]],pu=ie("Pause",gu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mu=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],vu=ie("Pencil",mu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yu=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],bu=ie("Play",yu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wu=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],xu=ie("RefreshCw",wu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Su=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],_u=ie("RotateCcw",Su);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Eu=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Cu=ie("RotateCw",Eu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ku=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Tu=ie("Scissors",ku);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ru=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Au=ie("Search",Ru);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Iu=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Fp=ie("Send",Iu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ju=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Nu=ie("Settings",ju);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Lu=[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hp=ie("SquareCheckBig",Lu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zu=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],Bp=ie("Trash",zu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pu=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Vp=ie("TriangleAlert",Pu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Du=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Qa=ie("Undo2",Du);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ou=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],Up=ie("Upload",Ou);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gu=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Mu=ie("X",Gu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $u=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],qp=ie("Zap",$u);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Hu=ie("ZoomIn",Fu);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Vu=ie("ZoomOut",Bu),Uu=Ea,Wp=Gi,qu=xa,Ja=p.forwardRef(({className:t,...e},r)=>g.jsx(Cn,{ref:r,className:fe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/30",t),...e}));Ja.displayName=Cn.displayName;const Za=p.forwardRef(({className:t,children:e,...r},n)=>g.jsxs(qu,{children:[g.jsx(Ja,{}),g.jsxs(kn,{ref:n,className:fe("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",t),...r,children:[e,g.jsxs(Oi,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",children:[g.jsx(Mu,{className:"h-4 w-4"}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Za.displayName=kn.displayName;const es=({className:t,...e})=>g.jsx("div",{className:fe("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});es.displayName="DialogHeader";const ts=({className:t,...e})=>g.jsx("div",{className:fe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});ts.displayName="DialogFooter";const rs=p.forwardRef(({className:t,...e},r)=>g.jsx(Sa,{ref:r,className:fe("text-lg leading-none font-semibold tracking-tight",t),...e}));rs.displayName=Sa.displayName;const ns=p.forwardRef(({className:t,...e},r)=>g.jsx(_a,{ref:r,className:fe("text-muted-foreground text-sm",t),...e}));ns.displayName=_a.displayName;const jn=$i,Nn=Fi,cr=p.forwardRef(({className:t,align:e="center",sideOffset:r=4,collisionPadding:n,sticky:a,avoidCollisions:o=!1,...l},i)=>g.jsx(Mi,{children:g.jsx(Ca,{ref:i,align:e,sideOffset:r,collisionPadding:n,sticky:a,avoidCollisions:o,className:fe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 rounded-md border p-4 shadow-md outline-none",t),...l})}));cr.displayName=Ca.displayName;var Wu=`
precision mediump float;
varying vec4 v_color;
varying float v_border;
const float radius = 0.5;
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main(void) {
vec2 m = gl_PointCoord - vec2(0.5, 0.5);
float dist = radius - length(m);
// No antialiasing for picking mode:
#ifdef PICKING_MODE
if (dist > v_border)
gl_FragColor = v_color;
else
gl_FragColor = transparent;
#else
float t = 0.0;
if (dist > v_border)
t = 1.0;
else if (dist > 0.0)
t = dist / v_border;
gl_FragColor = mix(transparent, v_color, t);
#endif
}
`,Xu=Wu,Yu=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute vec2 a_position;
attribute float a_size;
uniform float u_sizeRatio;
uniform float u_pixelRatio;
uniform mat3 u_matrix;
varying vec4 v_color;
varying float v_border;
const float bias = 255.0 / 254.0;
void main() {
gl_Position = vec4(
(u_matrix * vec3(a_position, 1)).xy,
0,
1
);
// Multiply the point size twice:
// - x SCALING_RATIO to correct the canvas scaling
// - x 2 to correct the formulae
gl_PointSize = a_size / u_sizeRatio * u_pixelRatio * 2.0;
v_border = (0.5 / a_size) * u_sizeRatio;
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,Ku=Yu,os=WebGLRenderingContext,lo=os.UNSIGNED_BYTE,co=os.FLOAT,Qu=["u_sizeRatio","u_pixelRatio","u_matrix"],Ju=function(t){function e(){return fa(this,e),ha(this,e,arguments)}return ca(e,t),ua(e,[{key:"getDefinition",value:function(){return{VERTICES:1,VERTEX_SHADER_SOURCE:Ku,FRAGMENT_SHADER_SOURCE:Xu,METHOD:WebGLRenderingContext.POINTS,UNIFORMS:Qu,ATTRIBUTES:[{name:"a_position",size:2,type:co},{name:"a_size",size:1,type:co},{name:"a_color",size:4,type:lo,normalized:!0},{name:"a_id",size:4,type:lo,normalized:!0}]}}},{key:"processVisibleItem",value:function(n,a,o){var l=this.array;l[a++]=o.x,l[a++]=o.y,l[a++]=o.size,l[a++]=rr(o.color),l[a++]=n}},{key:"setUniforms",value:function(n,a){var o=n.sizeRatio,l=n.pixelRatio,i=n.matrix,s=a.gl,c=a.uniformLocations,u=c.u_sizeRatio,d=c.u_pixelRatio,h=c.u_matrix;s.uniform1f(d,l),s.uniform1f(u,o),s.uniformMatrix3fv(h,!1,i)}}])}(da),Zu=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute vec2 a_normal;
attribute float a_normalCoef;
attribute vec2 a_positionStart;
attribute vec2 a_positionEnd;
attribute float a_positionCoef;
attribute float a_sourceRadius;
attribute float a_targetRadius;
attribute float a_sourceRadiusCoef;
attribute float a_targetRadiusCoef;
uniform mat3 u_matrix;
uniform float u_zoomRatio;
uniform float u_sizeRatio;
uniform float u_pixelRatio;
uniform float u_correctionRatio;
uniform float u_minEdgeThickness;
uniform float u_lengthToThicknessRatio;
uniform float u_feather;
varying vec4 v_color;
varying vec2 v_normal;
varying float v_thickness;
varying float v_feather;
const float bias = 255.0 / 254.0;
void main() {
float minThickness = u_minEdgeThickness;
vec2 normal = a_normal * a_normalCoef;
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
float normalLength = length(normal);
vec2 unitNormal = normal / normalLength;
// These first computations are taken from edge.vert.glsl. Please read it to
// get better comments on what's happening:
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
// Here, we move the point to leave space for the arrow heads:
// Source arrow head
float sourceRadius = a_sourceRadius * a_sourceRadiusCoef;
float sourceDirection = sign(sourceRadius);
float webGLSourceRadius = sourceDirection * sourceRadius * 2.0 * u_correctionRatio / u_sizeRatio;
float webGLSourceArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
vec2 sourceCompensationVector =
vec2(-sourceDirection * unitNormal.y, sourceDirection * unitNormal.x)
* (webGLSourceRadius + webGLSourceArrowHeadLength);
// Target arrow head
float targetRadius = a_targetRadius * a_targetRadiusCoef;
float targetDirection = sign(targetRadius);
float webGLTargetRadius = targetDirection * targetRadius * 2.0 * u_correctionRatio / u_sizeRatio;
float webGLTargetArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
vec2 targetCompensationVector =
vec2(-targetDirection * unitNormal.y, targetDirection * unitNormal.x)
* (webGLTargetRadius + webGLTargetArrowHeadLength);
// Here is the proper position of the vertex
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + sourceCompensationVector + targetCompensationVector, 1)).xy, 0, 1);
v_thickness = webGLThickness / u_zoomRatio;
v_normal = unitNormal;
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`,ed=Zu,as=WebGLRenderingContext,uo=as.UNSIGNED_BYTE,Ue=as.FLOAT,td=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],rd={lengthToThicknessRatio:_n.lengthToThicknessRatio};function ss(t){var e=Wt(Wt({},rd),{});return function(r){function n(){return fa(this,n),ha(this,n,arguments)}return ca(n,r),ua(n,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ed,FRAGMENT_SHADER_SOURCE:xi,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:td,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Ue},{name:"a_positionEnd",size:2,type:Ue},{name:"a_normal",size:2,type:Ue},{name:"a_color",size:4,type:uo,normalized:!0},{name:"a_id",size:4,type:uo,normalized:!0},{name:"a_sourceRadius",size:1,type:Ue},{name:"a_targetRadius",size:1,type:Ue}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Ue},{name:"a_normalCoef",size:1,type:Ue},{name:"a_sourceRadiusCoef",size:1,type:Ue},{name:"a_targetRadiusCoef",size:1,type:Ue}],CONSTANT_DATA:[[0,1,-1,0],[0,-1,1,0],[1,1,0,1],[1,1,0,1],[0,-1,1,0],[1,-1,0,-1]]}}},{key:"processVisibleItem",value:function(o,l,i,s,c){var u=c.size||1,d=i.x,h=i.y,f=s.x,y=s.y,b=rr(c.color),R=f-d,P=y-h,S=i.size||1,k=s.size||1,A=R*R+P*P,j=0,D=0;A&&(A=1/Math.sqrt(A),j=-P*A*u,D=R*A*u);var v=this.array;v[l++]=d,v[l++]=h,v[l++]=f,v[l++]=y,v[l++]=j,v[l++]=D,v[l++]=b,v[l++]=o,v[l++]=S,v[l++]=k}},{key:"setUniforms",value:function(o,l){var i=l.gl,s=l.uniformLocations,c=s.u_matrix,u=s.u_zoomRatio,d=s.u_feather,h=s.u_pixelRatio,f=s.u_correctionRatio,y=s.u_sizeRatio,b=s.u_minEdgeThickness,R=s.u_lengthToThicknessRatio;i.uniformMatrix3fv(c,!1,o.matrix),i.uniform1f(u,o.zoomRatio),i.uniform1f(y,o.sizeRatio),i.uniform1f(f,o.correctionRatio),i.uniform1f(h,o.pixelRatio),i.uniform1f(d,o.antiAliasingFeather),i.uniform1f(b,o.minEdgeThickness),i.uniform1f(R,e.lengthToThicknessRatio)}}])}(ga)}ss();function nd(t){return Si([ss(),Xn(t),Xn(Wt(Wt({},t),{},{extremity:"source"}))])}nd();function od(t){if(Array.isArray(t))return t}function ad(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,a,o,l,i=[],s=!0,c=!1;try{if(o=(r=r.call(t)).next,e!==0)for(;!(s=(n=o.call(r)).done)&&(i.push(n.value),i.length!==e);s=!0);}catch(u){c=!0,a=u}finally{try{if(!s&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(c)throw a}}return i}}function fn(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function is(t,e){if(t){if(typeof t=="string")return fn(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?fn(t,e):void 0}}function sd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function id(t,e){return od(t)||ad(t,e)||is(t,e)||sd()}function ld(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function cd(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ls(t){var e=cd(t,"string");return typeof e=="symbol"?e:e+""}function ud(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ls(n.key),n)}}function dd(t,e,r){return e&&ud(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Kt(t){return Kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Kt(t)}function cs(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cs=function(){return!!t})()}function hn(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function fd(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return hn(t)}function hd(t,e,r){return e=Kt(e),fd(t,cs()?Reflect.construct(e,r||[],Kt(t).constructor):e.apply(t,r))}function gn(t,e){return gn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},gn(t,e)}function gd(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&gn(t,e)}function yt(t,e,r){return(e=ls(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pd(t){if(Array.isArray(t))return fn(t)}function md(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function vd(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vr(t){return pd(t)||md(t)||is(t)||vd()}function fo(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ho(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?fo(Object(r),!0).forEach(function(n){yt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fo(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var yd="relative",bd={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},wd="#000000";function xd(t){var e=t.borders,r=Yn(e.filter(function(a){var o=a.size;return"fill"in o}).length),n=`
precision highp float;
varying vec2 v_diffVector;
varying float v_radius;
#ifdef PICKING_MODE
varying vec4 v_color;
#else
// For normal mode, we use the border colors defined in the program:
`.concat(e.flatMap(function(a,o){var l=a.size;return"attribute"in l?["varying float v_borderSize_".concat(o+1,";")]:[]}).join(`
`),`
`).concat(e.flatMap(function(a,o){var l=a.color;return"attribute"in l?["varying vec4 v_borderColor_".concat(o+1,";")]:"value"in l?["uniform vec4 u_borderColor_".concat(o+1,";")]:[]}).join(`
`),`
#endif
uniform float u_correctionRatio;
const float bias = 255.0 / 254.0;
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main(void) {
float dist = length(v_diffVector);
float aaBorder = 2.0 * u_correctionRatio;
float v_borderSize_0 = v_radius;
vec4 v_borderColor_0 = transparent;
// No antialiasing for picking mode:
#ifdef PICKING_MODE
if (dist > v_radius)
gl_FragColor = transparent;
else {
gl_FragColor = v_color;
gl_FragColor.a *= bias;
}
#else
// Sizes:
`).concat(e.flatMap(function(a,o){var l=a.size;if("fill"in l)return[];l=l;var i="attribute"in l?"v_borderSize_".concat(o+1):Yn(l.value),s=(l.mode||yd)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(s," * ").concat(i,";")]}).join(`
`),`
// Now, let's split the remaining space between "fill" borders:
float fillBorderSize = (v_radius - (`).concat(e.flatMap(function(a,o){var l=a.size;return"fill"in l?[]:["borderSize_".concat(o+1)]}).join(" + "),") ) / ").concat(r,`;
`).concat(e.flatMap(function(a,o){var l=a.size;return"fill"in l?[" float borderSize_".concat(o+1," = fillBorderSize;")]:[]}).join(`
`),`
// Finally, normalize all border sizes, to start from the full size and to end with the smallest:
float adjustedBorderSize_0 = v_radius;
`).concat(e.map(function(a,o){return" float adjustedBorderSize_".concat(o+1," = adjustedBorderSize_").concat(o," - borderSize_").concat(o+1,";")}).join(`
`),`
// Colors:
vec4 borderColor_0 = transparent;
`).concat(e.map(function(a,o){var l=a.color,i=[];return"attribute"in l?i.push(" vec4 borderColor_".concat(o+1," = v_borderColor_").concat(o+1,";")):"transparent"in l?i.push(" vec4 borderColor_".concat(o+1," = vec4(0.0, 0.0, 0.0, 0.0);")):i.push(" vec4 borderColor_".concat(o+1," = u_borderColor_").concat(o+1,";")),i.push(" borderColor_".concat(o+1,".a *= bias;")),i.push(" if (borderSize_".concat(o+1," <= 1.0 * u_correctionRatio) { borderColor_").concat(o+1," = borderColor_").concat(o,"; }")),i.join(`
`)}).join(`
`),`
if (dist > adjustedBorderSize_0) {
gl_FragColor = borderColor_0;
} else `).concat(e.map(function(a,o){return"if (dist > adjustedBorderSize_".concat(o,` - aaBorder) {
gl_FragColor = mix(borderColor_`).concat(o+1,", borderColor_").concat(o,", (dist - adjustedBorderSize_").concat(o,` + aaBorder) / aaBorder);
} else if (dist > adjustedBorderSize_`).concat(o+1,`) {
gl_FragColor = borderColor_`).concat(o+1,`;
} else `)}).join(""),` { /* Nothing to add here */ }
#endif
}
`);return n}function Sd(t){var e=t.borders,r=`
attribute vec2 a_position;
attribute float a_size;
attribute float a_angle;
uniform mat3 u_matrix;
uniform float u_sizeRatio;
uniform float u_correctionRatio;
varying vec2 v_diffVector;
varying float v_radius;
#ifdef PICKING_MODE
attribute vec4 a_id;
varying vec4 v_color;
#else
`.concat(e.flatMap(function(n,a){var o=n.size;return"attribute"in o?["attribute float a_borderSize_".concat(a+1,";"),"varying float v_borderSize_".concat(a+1,";")]:[]}).join(`
`),`
`).concat(e.flatMap(function(n,a){var o=n.color;return"attribute"in o?["attribute vec4 a_borderColor_".concat(a+1,";"),"varying vec4 v_borderColor_".concat(a+1,";")]:[]}).join(`
`),`
#endif
const float bias = 255.0 / 254.0;
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main() {
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
vec2 position = a_position + diffVector;
gl_Position = vec4(
(u_matrix * vec3(position, 1)).xy,
0,
1
);
v_radius = size / 2.0;
v_diffVector = diffVector;
#ifdef PICKING_MODE
v_color = a_id;
#else
`).concat(e.flatMap(function(n,a){var o=n.size;return"attribute"in o?[" v_borderSize_".concat(a+1," = a_borderSize_").concat(a+1,";")]:[]}).join(`
`),`
`).concat(e.flatMap(function(n,a){var o=n.color;return"attribute"in o?[" v_borderColor_".concat(a+1," = a_borderColor_").concat(a+1,";")]:[]}).join(`
`),`
#endif
}
`);return r}var us=WebGLRenderingContext,go=us.UNSIGNED_BYTE,Pt=us.FLOAT;function _d(t){var e,r=ho(ho({},bd),{}),n=r.borders,a=r.drawLabel,o=r.drawHover,l=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(vr(n.flatMap(function(i,s){var c=i.color;return"value"in c?["u_borderColor_".concat(s+1)]:[]})));return e=function(i){gd(s,i);function s(){var c;ld(this,s);for(var u=arguments.length,d=new Array(u),h=0;h<u;h++)d[h]=arguments[h];return c=hd(this,s,[].concat(d)),yt(hn(c),"drawLabel",a),yt(hn(c),"drawHover",o),c}return dd(s,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Sd(r),FRAGMENT_SHADER_SOURCE:xd(r),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:l,ATTRIBUTES:[{name:"a_position",size:2,type:Pt},{name:"a_id",size:4,type:go,normalized:!0},{name:"a_size",size:1,type:Pt}].concat(vr(n.flatMap(function(u,d){var h=u.color;return"attribute"in h?[{name:"a_borderColor_".concat(d+1),size:4,type:go,normalized:!0}]:[]})),vr(n.flatMap(function(u,d){var h=u.size;return"attribute"in h?[{name:"a_borderSize_".concat(d+1),size:1,type:Pt}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Pt}],CONSTANT_DATA:[[s.ANGLE_1],[s.ANGLE_2],[s.ANGLE_3]]}}},{key:"processVisibleItem",value:function(u,d,h){var f=this.array;f[d++]=h.x,f[d++]=h.y,f[d++]=u,f[d++]=h.size,n.forEach(function(y){var b=y.color;"attribute"in b&&(f[d++]=rr(h[b.attribute]||b.defaultValue||wd))}),n.forEach(function(y){var b=y.size;"attribute"in b&&(f[d++]=h[b.attribute]||b.defaultValue)})}},{key:"setUniforms",value:function(u,d){var h=d.gl,f=d.uniformLocations,y=f.u_sizeRatio,b=f.u_correctionRatio,R=f.u_matrix;h.uniform1f(b,u.correctionRatio),h.uniform1f(y,u.sizeRatio),h.uniformMatrix3fv(R,!1,u.matrix),n.forEach(function(P,S){var k=P.color;if("value"in k){var A=f["u_borderColor_".concat(S+1)],j=_i(k.value),D=id(j,4),v=D[0],_=D[1],x=D[2],T=D[3];h.uniform4f(A,v/255,_/255,x/255,T/255)}})}}]),s}(da),yt(e,"ANGLE_1",0),yt(e,"ANGLE_2",2*Math.PI/3),yt(e,"ANGLE_3",4*Math.PI/3),e}var Ed=_d();function Cd(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ds(t){var e=Cd(t,"string");return typeof e=="symbol"?e:e+""}function fs(t,e,r){return(e=ds(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function po(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Qt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?po(Object(r),!0).forEach(function(n){fs(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):po(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function kd(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Td(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ds(n.key),n)}}function Rd(t,e,r){return e&&Td(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Jt(t){return Jt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Jt(t)}function hs(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(hs=function(){return!!t})()}function gs(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ad(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gs(t)}function Id(t,e,r){return e=Jt(e),Ad(t,hs()?Reflect.construct(e,r||[],Jt(t).constructor):e.apply(t,r))}function pn(t,e){return pn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},pn(t,e)}function jd(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&pn(t,e)}function mn(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Nd(t){if(Array.isArray(t))return mn(t)}function Ld(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function zd(t,e){if(t){if(typeof t=="string")return mn(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?mn(t,e):void 0}}function Pd(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yr(t){return Nd(t)||Ld(t)||zd(t)||Pd()}function ps(t,e,r,n){var a=Math.pow(1-t,2)*e.x+2*(1-t)*t*r.x+Math.pow(t,2)*n.x,o=Math.pow(1-t,2)*e.y+2*(1-t)*t*r.y+Math.pow(t,2)*n.y;return{x:a,y:o}}function Dd(t,e,r){for(var n=20,a=0,o=t,l=0;l<n;l++){var i=ps((l+1)/n,t,e,r);a+=Math.sqrt(Math.pow(o.x-i.x,2)+Math.pow(o.y-i.y,2)),o=i}return a}function Od(t){var e=t.curvatureAttribute,r=t.defaultCurvature,n=t.keepLabelUpright,a=n===void 0?!0:n;return function(o,l,i,s,c){var u=c.edgeLabelSize,d=l[e]||r,h=c.edgeLabelFont,f=c.edgeLabelWeight,y=c.edgeLabelColor.attribute?l[c.edgeLabelColor.attribute]||c.edgeLabelColor.color||"#000":c.edgeLabelColor.color,b=l.label;if(b){o.fillStyle=y,o.font="".concat(f," ").concat(u,"px ").concat(h);var R=!a||i.x<s.x,P=R?i.x:s.x,S=R?i.y:s.y,k=R?s.x:i.x,A=R?s.y:i.y,j=(P+k)/2,D=(S+A)/2,v=k-P,_=A-S,x=Math.sqrt(Math.pow(v,2)+Math.pow(_,2)),T=R?1:-1,I=j+_*d*T,z=D-v*d*T,w=l.size*.7+5,F={x:z-S,y:-(I-P)},K=Math.sqrt(Math.pow(F.x,2)+Math.pow(F.y,2)),O={x:A-z,y:-(k-I)},C=Math.sqrt(Math.pow(O.x,2)+Math.pow(O.y,2));P+=w*F.x/K,S+=w*F.y/K,k+=w*O.x/C,A+=w*O.y/C,I+=w*_/x,z-=w*v/x;var E={x:I,y:z},W={x:P,y:S},re={x:k,y:A},M=Dd(W,E,re);if(!(M<i.size+s.size)){var m=o.measureText(b).width,L=M-i.size-s.size;if(m>L){var U="…";for(b=b+U,m=o.measureText(b).width;m>L&&b.length>1;)b=b.slice(0,-2)+U,m=o.measureText(b).width;if(b.length<4)return}for(var q={},Q=0,B=b.length;Q<B;Q++){var X=b[Q];q[X]||(q[X]=o.measureText(X).width*(1+d*.35))}for(var le=.5-m/M/2,ne=0,se=b.length;ne<se;ne++){var oe=b[ne],$=ps(le,W,E,re),V=2*(1-le)*(I-P)+2*le*(k-I),H=2*(1-le)*(z-S)+2*le*(A-z),N=Math.atan2(H,V);o.save(),o.translate($.x,$.y),o.rotate(N),o.fillText(oe,0,0),o.restore(),le+=q[oe]/M}}}}}function Gd(t){var e=t.arrowHead,r=(e==null?void 0:e.extremity)==="target"||(e==null?void 0:e.extremity)==="both",n=(e==null?void 0:e.extremity)==="source"||(e==null?void 0:e.extremity)==="both",a=`
precision highp float;
varying vec4 v_color;
varying float v_thickness;
varying float v_feather;
varying vec2 v_cpA;
varying vec2 v_cpB;
varying vec2 v_cpC;
`.concat(r?`
varying float v_targetSize;
varying vec2 v_targetPoint;`:"",`
`).concat(n?`
varying float v_sourceSize;
varying vec2 v_sourcePoint;`:"",`
`).concat(e?`
uniform float u_lengthToThicknessRatio;
uniform float u_widenessToThicknessRatio;`:"",`
float det(vec2 a, vec2 b) {
return a.x * b.y - b.x * a.y;
}
vec2 getDistanceVector(vec2 b0, vec2 b1, vec2 b2) {
float a = det(b0, b2), b = 2.0 * det(b1, b0), d = 2.0 * det(b2, b1);
float f = b * d - a * a;
vec2 d21 = b2 - b1, d10 = b1 - b0, d20 = b2 - b0;
vec2 gf = 2.0 * (b * d21 + d * d10 + a * d20);
gf = vec2(gf.y, -gf.x);
vec2 pp = -f * gf / dot(gf, gf);
vec2 d0p = b0 - pp;
float ap = det(d0p, d20), bp = 2.0 * det(d10, d0p);
float t = clamp((ap + bp) / (2.0 * a + b + d), 0.0, 1.0);
return mix(mix(b0, b1, t), mix(b1, b2, t), t);
}
float distToQuadraticBezierCurve(vec2 p, vec2 b0, vec2 b1, vec2 b2) {
return length(getDistanceVector(b0 - p, b1 - p, b2 - p));
}
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
void main(void) {
float dist = distToQuadraticBezierCurve(gl_FragCoord.xy, v_cpA, v_cpB, v_cpC);
float thickness = v_thickness;
`).concat(r?`
float distToTarget = length(gl_FragCoord.xy - v_targetPoint);
float targetArrowLength = v_targetSize + thickness * u_lengthToThicknessRatio;
if (distToTarget < targetArrowLength) {
thickness = (distToTarget - v_targetSize) / (targetArrowLength - v_targetSize) * u_widenessToThicknessRatio * thickness;
}`:"",`
`).concat(n?`
float distToSource = length(gl_FragCoord.xy - v_sourcePoint);
float sourceArrowLength = v_sourceSize + thickness * u_lengthToThicknessRatio;
if (distToSource < sourceArrowLength) {
thickness = (distToSource - v_sourceSize) / (sourceArrowLength - v_sourceSize) * u_widenessToThicknessRatio * thickness;
}`:"",`
float halfThickness = thickness / 2.0;
if (dist < halfThickness) {
#ifdef PICKING_MODE
gl_FragColor = v_color;
#else
float t = smoothstep(
halfThickness - v_feather,
halfThickness,
dist
);
gl_FragColor = mix(v_color, transparent, t);
#endif
} else {
gl_FragColor = transparent;
}
}
`);return a}function Md(t){var e=t.arrowHead,r=(e==null?void 0:e.extremity)==="target"||(e==null?void 0:e.extremity)==="both",n=(e==null?void 0:e.extremity)==="source"||(e==null?void 0:e.extremity)==="both",a=`
attribute vec4 a_id;
attribute vec4 a_color;
attribute float a_direction;
attribute float a_thickness;
attribute vec2 a_source;
attribute vec2 a_target;
attribute float a_current;
attribute float a_curvature;
`.concat(r?`attribute float a_targetSize;
`:"",`
`).concat(n?`attribute float a_sourceSize;
`:"",`
uniform mat3 u_matrix;
uniform float u_sizeRatio;
uniform float u_pixelRatio;
uniform vec2 u_dimensions;
uniform float u_minEdgeThickness;
uniform float u_feather;
varying vec4 v_color;
varying float v_thickness;
varying float v_feather;
varying vec2 v_cpA;
varying vec2 v_cpB;
varying vec2 v_cpC;
`).concat(r?`
varying float v_targetSize;
varying vec2 v_targetPoint;`:"",`
`).concat(n?`
varying float v_sourceSize;
varying vec2 v_sourcePoint;`:"",`
`).concat(e?`
uniform float u_widenessToThicknessRatio;`:"",`
const float bias = 255.0 / 254.0;
const float epsilon = 0.7;
vec2 clipspaceToViewport(vec2 pos, vec2 dimensions) {
return vec2(
(pos.x + 1.0) * dimensions.x / 2.0,
(pos.y + 1.0) * dimensions.y / 2.0
);
}
vec2 viewportToClipspace(vec2 pos, vec2 dimensions) {
return vec2(
pos.x / dimensions.x * 2.0 - 1.0,
pos.y / dimensions.y * 2.0 - 1.0
);
}
void main() {
float minThickness = u_minEdgeThickness;
// Selecting the correct position
// Branchless "position = a_source if a_current == 1.0 else a_target"
vec2 position = a_source * max(0.0, a_current) + a_target * max(0.0, 1.0 - a_current);
position = (u_matrix * vec3(position, 1)).xy;
vec2 source = (u_matrix * vec3(a_source, 1)).xy;
vec2 target = (u_matrix * vec3(a_target, 1)).xy;
vec2 viewportPosition = clipspaceToViewport(position, u_dimensions);
vec2 viewportSource = clipspaceToViewport(source, u_dimensions);
vec2 viewportTarget = clipspaceToViewport(target, u_dimensions);
vec2 delta = viewportTarget.xy - viewportSource.xy;
float len = length(delta);
vec2 normal = vec2(-delta.y, delta.x) * a_direction;
vec2 unitNormal = normal / len;
float boundingBoxThickness = len * a_curvature;
float curveThickness = max(minThickness, a_thickness / u_sizeRatio);
v_thickness = curveThickness * u_pixelRatio;
v_feather = u_feather;
v_cpA = viewportSource;
v_cpB = 0.5 * (viewportSource + viewportTarget) + unitNormal * a_direction * boundingBoxThickness;
v_cpC = viewportTarget;
vec2 viewportOffsetPosition = (
viewportPosition +
unitNormal * (boundingBoxThickness / 2.0 + sign(boundingBoxThickness) * (`).concat(e?"curveThickness * u_widenessToThicknessRatio":"curveThickness",` + epsilon)) *
max(0.0, a_direction) // NOTE: cutting the bounding box in half to avoid overdraw
);
position = viewportToClipspace(viewportOffsetPosition, u_dimensions);
gl_Position = vec4(position, 0, 1);
`).concat(r?`
v_targetSize = a_targetSize * u_pixelRatio / u_sizeRatio;
v_targetPoint = viewportTarget;
`:"",`
`).concat(n?`
v_sourceSize = a_sourceSize * u_pixelRatio / u_sizeRatio;
v_sourcePoint = viewportSource;
`:"",`
#ifdef PICKING_MODE
// For picking mode, we use the ID as the color:
v_color = a_id;
#else
// For normal mode, we use the color:
v_color = a_color;
#endif
v_color.a *= bias;
}
`);return a}var ms=.25,$d={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:ms},vs=WebGLRenderingContext,mo=vs.UNSIGNED_BYTE,tt=vs.FLOAT;function ur(t){var e=Qt(Qt({},$d),t||{}),r=e,n=r.arrowHead,a=r.curvatureAttribute,o=r.drawLabel,l=(n==null?void 0:n.extremity)==="target"||(n==null?void 0:n.extremity)==="both",i=(n==null?void 0:n.extremity)==="source"||(n==null?void 0:n.extremity)==="both",s=["u_matrix","u_sizeRatio","u_dimensions","u_pixelRatio","u_feather","u_minEdgeThickness"].concat(yr(n?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return function(c){jd(u,c);function u(){var d;kd(this,u);for(var h=arguments.length,f=new Array(h),y=0;y<h;y++)f[y]=arguments[y];return d=Id(this,u,[].concat(f)),fs(gs(d),"drawLabel",o||Od(e)),d}return Rd(u,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Md(e),FRAGMENT_SHADER_SOURCE:Gd(e),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_source",size:2,type:tt},{name:"a_target",size:2,type:tt}].concat(yr(l?[{name:"a_targetSize",size:1,type:tt}]:[]),yr(i?[{name:"a_sourceSize",size:1,type:tt}]:[]),[{name:"a_thickness",size:1,type:tt},{name:"a_curvature",size:1,type:tt},{name:"a_color",size:4,type:mo,normalized:!0},{name:"a_id",size:4,type:mo,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:tt},{name:"a_direction",size:1,type:tt}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(h,f,y,b,R){var P,S=R.size||1,k=y.x,A=y.y,j=b.x,D=b.y,v=rr(R.color),_=(P=R[a])!==null&&P!==void 0?P:ms,x=this.array;x[f++]=k,x[f++]=A,x[f++]=j,x[f++]=D,l&&(x[f++]=b.size),i&&(x[f++]=y.size),x[f++]=S,x[f++]=_,x[f++]=v,x[f++]=h}},{key:"setUniforms",value:function(h,f){var y=f.gl,b=f.uniformLocations,R=b.u_matrix,P=b.u_pixelRatio,S=b.u_feather,k=b.u_sizeRatio,A=b.u_dimensions,j=b.u_minEdgeThickness;if(y.uniformMatrix3fv(R,!1,h.matrix),y.uniform1f(P,h.pixelRatio),y.uniform1f(k,h.sizeRatio),y.uniform1f(S,h.antiAliasingFeather),y.uniform2f(A,h.width*h.pixelRatio,h.height*h.pixelRatio),y.uniform1f(j,h.minEdgeThickness),n){var D=b.u_lengthToThicknessRatio,v=b.u_widenessToThicknessRatio;y.uniform1f(D,n.lengthToThicknessRatio),y.uniform1f(v,n.widenessToThicknessRatio)}}}]),u}(ga)}ur();var Fd=ur({arrowHead:_n});ur({arrowHead:Qt(Qt({},_n),{},{extremity:"both"})});const Hd=({node:t,move:e})=>{const r=We(),{gotoNode:n}=pa();return p.useEffect(()=>{const a=r.getGraph();if(e){if(t&&a.hasNode(t))try{a.setNodeAttribute(t,"highlighted",!0),n(t)}catch(o){console.error("Error focusing on node:",o)}else r.setCustomBBox(null),r.getCamera().animate({x:.5,y:.5,ratio:1},{duration:0});Z.getState().setMoveToSelectedNode(!1)}else if(t&&a.hasNode(t))try{a.setNodeAttribute(t,"highlighted",!0)}catch(o){console.error("Error highlighting node:",o)}return()=>{if(t&&a.hasNode(t))try{a.setNodeAttribute(t,"highlighted",!1)}catch(o){console.error("Error cleaning up node highlight:",o)}}},[t,e,r,n]),null};function Et(t,e){const r=We(),n=p.useRef(e);return ma(n.current,e)||(n.current=e),{positions:p.useCallback(()=>n.current?t(r.getGraph(),n.current):{},[r,n,t]),assign:p.useCallback(()=>{n.current&&t.assign(r.getGraph(),n.current)},[r,n,t])}}function Ln(t,e){const r=We(),[n,a]=p.useState(!1),[o,l]=p.useState(null),i=p.useRef(e);return ma(i.current,e)||(i.current=e),p.useEffect(()=>{a(!1);let s=null;return i.current&&(s=new t(r.getGraph(),i.current)),l(s),()=>{s!==null&&s.kill()}},[r,i,l,a,t]),{stop:p.useCallback(()=>{o&&(o.stop(),a(!1))},[o,a]),start:p.useCallback(()=>{o&&(o.start(),a(!0))},[o,a]),kill:p.useCallback(()=>{o&&o.kill(),a(!1)},[o,a]),isRunning:n}}var br,vo;function It(){if(vo)return br;vo=1;function t(r){return!r||typeof r!="object"||typeof r=="function"||Array.isArray(r)||r instanceof Set||r instanceof Map||r instanceof RegExp||r instanceof Date}function e(r,n){r=r||{};var a={};for(var o in n){var l=r[o],i=n[o];if(!t(i)){a[o]=e(l,i);continue}l===void 0?a[o]=i:a[o]=l}return a}return br=e,br}var wr,yo;function Bd(){if(yo)return wr;yo=1;function t(r){return function(n,a){return n+Math.floor(r()*(a-n+1))}}var e=t(Math.random);return e.createRandom=t,wr=e,wr}var xr,bo;function Vd(){if(bo)return xr;bo=1;var t=Bd().createRandom;function e(n){var a=t(n);return function(o){for(var l=o.length,i=l-1,s=-1;++s<l;){var c=a(s,i),u=o[c];o[c]=o[s],o[s]=u}}}var r=e(Math.random);return r.createShuffleInPlace=e,xr=r,xr}var Sr,wo;function Ud(){if(wo)return Sr;wo=1;var t=It(),e=Xe(),r=Vd(),n={attributes:{x:"x",y:"y"},center:0,hierarchyAttributes:[],rng:Math.random,scale:1};function a(v,_,x,T,I){this.wrappedCircle=I||null,this.children={},this.countChildren=0,this.id=v||null,this.next=null,this.previous=null,this.x=_||null,this.y=x||null,I?this.r=1010101:this.r=T||999}a.prototype.hasChildren=function(){return this.countChildren>0},a.prototype.addChild=function(v,_){this.children[v]=_,++this.countChildren},a.prototype.getChild=function(v){if(!this.children.hasOwnProperty(v)){var _=new a;this.children[v]=_,++this.countChildren}return this.children[v]},a.prototype.applyPositionToChildren=function(){if(this.hasChildren()){var v=this;for(var _ in v.children){var x=v.children[_];x.x+=v.x,x.y+=v.y,x.applyPositionToChildren()}}};function o(v,_,x){for(var T in _.children){var I=_.children[T];I.hasChildren()?o(v,I,x):x[I.id]={x:I.x,y:I.y}}}function l(v,_){var x=v.r-_.r,T=_.x-v.x,I=_.y-v.y;return x<0||x*x<T*T+I*I}function i(v,_){var x=v.r-_.r+1e-6,T=_.x-v.x,I=_.y-v.y;return x>0&&x*x>T*T+I*I}function s(v,_){for(var x=0;x<_.length;++x)if(!i(v,_[x]))return!1;return!0}function c(v){return new a(null,v.x,v.y,v.r)}function u(v,_){var x=v.x,T=v.y,I=v.r,z=_.x,w=_.y,F=_.r,K=z-x,O=w-T,C=F-I,E=Math.sqrt(K*K+O*O);return new a(null,(x+z+K/E*C)/2,(T+w+O/E*C)/2,(E+I+F)/2)}function d(v,_,x){var T=v.x,I=v.y,z=v.r,w=_.x,F=_.y,K=_.r,O=x.x,C=x.y,E=x.r,W=T-w,re=T-O,M=I-F,m=I-C,L=K-z,U=E-z,q=T*T+I*I-z*z,Q=q-w*w-F*F+K*K,B=q-O*O-C*C+E*E,X=re*M-W*m,le=(M*B-m*Q)/(X*2)-T,ne=(m*L-M*U)/X,se=(re*Q-W*B)/(X*2)-I,oe=(W*U-re*L)/X,$=ne*ne+oe*oe-1,V=2*(z+le*ne+se*oe),H=le*le+se*se-z*z,N=-($?(V+Math.sqrt(V*V-4*$*H))/(2*$):H/V);return new a(null,T+le+ne*N,I+se+oe*N,N)}function h(v){switch(v.length){case 1:return c(v[0]);case 2:return u(v[0],v[1]);case 3:return d(v[0],v[1],v[2]);default:throw new Error("graphology-layout/circlepack: Invalid basis length "+v.length)}}function f(v,_){var x,T;if(s(_,v))return[_];for(x=0;x<v.length;++x)if(l(_,v[x])&&s(u(v[x],_),v))return[v[x],_];for(x=0;x<v.length-1;++x)for(T=x+1;T<v.length;++T)if(l(u(v[x],v[T]),_)&&l(u(v[x],_),v[T])&&l(u(v[T],_),v[x])&&s(d(v[x],v[T],_),v))return[v[x],v[T],_];throw new Error("graphology-layout/circlepack: extendBasis failure !")}function y(v){var _=v.wrappedCircle,x=v.next.wrappedCircle,T=_.r+x.r,I=(_.x*x.r+x.x*_.r)/T,z=(_.y*x.r+x.y*_.r)/T;return I*I+z*z}function b(v,_){var x=0,T=v.slice(),I=v.length,z=[],w,F;for(_(T);x<I;)w=T[x],F&&i(F,w)?++x:(z=f(z,w),F=h(z),x=0);return F}function R(v,_,x){var T=v.x-_.x,I,z,w=v.y-_.y,F,K,O=T*T+w*w;O?(z=_.r+x.r,z*=z,K=v.r+x.r,K*=K,z>K?(I=(O+K-z)/(2*O),F=Math.sqrt(Math.max(0,K/O-I*I)),x.x=v.x-I*T-F*w,x.y=v.y-I*w+F*T):(I=(O+z-K)/(2*O),F=Math.sqrt(Math.max(0,z/O-I*I)),x.x=_.x+I*T-F*w,x.y=_.y+I*w+F*T)):(x.x=_.x+x.r,x.y=_.y)}function P(v,_){var x=v.r+_.r-1e-6,T=_.x-v.x,I=_.y-v.y;return x>0&&x*x>T*T+I*I}function S(v,_){var x=v.length;if(x===0)return 0;var T,I,z,w,F,K,O,C,E,W;if(T=v[0],T.x=0,T.y=0,x<=1)return T.r;if(I=v[1],T.x=-I.r,I.x=T.r,I.y=0,x<=2)return T.r+I.r;z=v[2],R(I,T,z),T=new a(null,null,null,null,T),I=new a(null,null,null,null,I),z=new a(null,null,null,null,z),T.next=z.previous=I,I.next=T.previous=z,z.next=I.previous=T;e:for(K=3;K<x;++K){z=v[K],R(T.wrappedCircle,I.wrappedCircle,z),z=new a(null,null,null,null,z),O=I.next,C=T.previous,E=I.wrappedCircle.r,W=T.wrappedCircle.r;do if(E<=W){if(P(O.wrappedCircle,z.wrappedCircle)){I=O,T.next=I,I.previous=T,--K;continue e}E+=O.wrappedCircle.r,O=O.next}else{if(P(C.wrappedCircle,z.wrappedCircle)){T=C,T.next=I,I.previous=T,--K;continue e}W+=C.wrappedCircle.r,C=C.previous}while(O!==C.next);for(z.previous=T,z.next=I,T.next=I.previous=I=z,w=y(T);(z=z.next)!==I;)(F=y(z))<w&&(T=z,w=F);I=T.next}T=[I.wrappedCircle],z=I;for(var re=1e4;(z=z.next)!==I&&--re!==0;)T.push(z.wrappedCircle);for(z=b(T,_),K=0;K<x;++K)T=v[K],T.x-=z.x,T.y-=z.y;return z.r}function k(v,_){var x=0;if(v.hasChildren()){for(var T in v.children){var I=v.children[T];I.hasChildren()&&(I.r=k(I,_))}x=S(Object.values(v.children),_)}return x}function A(v,_){k(v,_);for(var x in v.children){var T=v.children[x];T.applyPositionToChildren()}}function j(v,_,x){if(!e(_))throw new Error("graphology-layout/circlepack: the given graph is not a valid graphology instance.");x=t(x,n);var T={},I={},z=_.nodes(),w=x.center,F=x.hierarchyAttributes,K=r.createShuffleInPlace(x.rng),O=x.scale,C=new a;_.forEachNode(function(L,U){var q=U.size?U.size:1,Q=new a(L,null,null,q),B=C;F.forEach(function(X){var le=U[X];B=B.getChild(le)}),B.addChild(L,Q)}),A(C,K),o(_,C,T);var E=z.length,W,re,M;for(M=0;M<E;M++){var m=z[M];W=w+O*T[m].x,re=w+O*T[m].y,I[m]={x:W,y:re},v&&(_.setNodeAttribute(m,x.attributes.x,W),_.setNodeAttribute(m,x.attributes.y,re))}return I}var D=j.bind(null,!1);return D.assign=j.bind(null,!0),Sr=D,Sr}var qd=Ud();const Wd=Be(qd);function Xd(t={}){return Et(Wd,t)}var _r,xo;function Yd(){if(xo)return _r;xo=1;var t=It(),e=Xe(),r={dimensions:["x","y"],center:.5,scale:1};function n(o,l,i){if(!e(l))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");i=t(i,r);var s=i.dimensions;if(!Array.isArray(s)||s.length!==2)throw new Error("graphology-layout/random: given dimensions are invalid.");var c=i.center,u=i.scale,d=Math.PI*2,h=(c-.5)*u,f=l.order,y=s[0],b=s[1];function R(k,A){return A[y]=u*Math.cos(k*d/f)+h,A[b]=u*Math.sin(k*d/f)+h,A}var P=0;if(!o){var S={};return l.forEachNode(function(k){S[k]=R(P++,{})}),S}l.updateEachNodeAttributes(function(k,A){return R(P++,A),A},{attributes:s})}var a=n.bind(null,!1);return a.assign=n.bind(null,!0),_r=a,_r}var Kd=Yd();const Qd=Be(Kd);function Jd(t={}){return Et(Qd,t)}var Tt={},So;function zn(){if(So)return Tt;So=1;function t(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,a){var o={},l=function(c){return typeof c>"u"?a:c};typeof a=="function"&&(l=a);var i=function(c){return l(c[n])},s=function(){return l(void 0)};return typeof n=="string"?(o.fromAttributes=i,o.fromGraph=function(c,u){return i(c.getNodeAttributes(u))},o.fromEntry=function(c,u){return i(u)}):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(c,u){return l(n(u,c.getNodeAttributes(u)))},o.fromEntry=function(c,u){return l(n(c,u))}):(o.fromAttributes=s,o.fromGraph=s,o.fromEntry=s),o}function r(n,a){var o={},l=function(c){return typeof c>"u"?a:c};typeof a=="function"&&(l=a);var i=function(c){return l(c[n])},s=function(){return l(void 0)};return typeof n=="string"?(o.fromAttributes=i,o.fromGraph=function(c,u){return i(c.getEdgeAttributes(u))},o.fromEntry=function(c,u){return i(u)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(c,u){var d=c.extremities(u);return l(n(u,c.getEdgeAttributes(u),d[0],d[1],c.getNodeAttributes(d[0]),c.getNodeAttributes(d[1]),c.isUndirected(u)))},o.fromEntry=function(c,u,d,h,f,y,b){return l(n(c,u,d,h,f,y,b))},o.fromPartialEntry=function(c,u,d,h){return l(n(c,u,d,h))},o.fromMinimalEntry=function(c,u){return l(n(c,u))}):(o.fromAttributes=s,o.fromGraph=s,o.fromEntry=s,o.fromMinimalEntry=s),o}return Tt.createNodeValueGetter=e,Tt.createEdgeValueGetter=r,Tt.createEdgeWeightGetter=function(n){return r(n,t)},Tt}var Er,_o;function ys(){if(_o)return Er;_o=1;const{createNodeValueGetter:t,createEdgeValueGetter:e}=zn();return Er=function(n,a,o){const{nodeXAttribute:l,nodeYAttribute:i}=o,{attraction:s,repulsion:c,gravity:u,inertia:d,maxMove:h}=o.settings;let{shouldSkipNode:f,shouldSkipEdge:y,isNodeFixed:b}=o;b=t(b),f=t(f,!1),y=e(y,!1);const R=n.filterNodes((k,A)=>!f.fromEntry(k,A)),P=R.length;for(let k=0;k<P;k++){const A=R[k],j=n.getNodeAttributes(A),D=a[A];D?a[A]={dx:D.dx*d,dy:D.dy*d,x:j[l]||0,y:j[i]||0}:a[A]={dx:0,dy:0,x:j[l]||0,y:j[i]||0}}if(c)for(let k=0;k<P;k++){const A=R[k],j=a[A];for(let D=k+1;D<P;D++){const v=R[D],_=a[v],x=_.x-j.x,T=_.y-j.y,I=Math.sqrt(x*x+T*T)||1,z=c/I*x,w=c/I*T;j.dx-=z,j.dy-=w,_.dx+=z,_.dy+=w}}if(s&&n.forEachEdge((k,A,j,D,v,_,x)=>{if(j===D||f.fromEntry(j,v)||f.fromEntry(D,_)||y.fromEntry(k,A,j,D,v,_,x))return;const T=a[j],I=a[D],z=I.x-T.x,w=I.y-T.y,F=Math.sqrt(z*z+w*w)||1,K=s*F*z,O=s*F*w;T.dx+=K,T.dy+=O,I.dx-=K,I.dy-=O}),u)for(let k=0;k<P;k++){const A=R[k],j=a[A],{x:D,y:v}=j,_=Math.sqrt(D*D+v*v)||1;a[A].dx-=D*u*_,a[A].dy-=v*u*_}const S=!1;for(let k=0;k<P;k++){const A=R[k],j=a[A],D=Math.sqrt(j.dx*j.dx+j.dy*j.dy);D>h&&(j.dx*=h/D,j.dy*=h/D),b.fromGraph(n,A)?j.fixed=!0:(j.x+=j.dx,j.y+=j.dy,j.fixed=!1)}return{converged:S}},Er}var Dt={},Eo;function bs(){return Eo||(Eo=1,Dt.assignLayoutChanges=function(t,e,r){const{nodeXAttribute:n,nodeYAttribute:a}=r;t.updateEachNodeAttributes((o,l)=>{const i=e[o];return!i||i.fixed||(l[n]=i.x,l[a]=i.y),l},{attributes:["x","y"]})},Dt.collectLayoutChanges=function(t){const e={};for(const r in t){const n=t[r];e[r]={x:n.x,y:n.y}}return e}),Dt}var Cr,Co;function ws(){return Co||(Co=1,Cr={nodeXAttribute:"x",nodeYAttribute:"y",isNodeFixed:"fixed",shouldSkipNode:null,shouldSkipEdge:null,settings:{attraction:5e-4,repulsion:.1,gravity:1e-4,inertia:.6,maxMove:200}}),Cr}var kr,ko;function Zd(){if(ko)return kr;ko=1;const t=Xe(),e=It(),r=ys(),n=bs(),a=ws();function o(i,s,c){if(!t(s))throw new Error("graphology-layout-force: the given graph is not a valid graphology instance.");typeof c=="number"?c={maxIterations:c}:c=c||{};const u=c.maxIterations;if(c=e(c,a),typeof u!="number"||u<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");const d={};let h=null,f;for(f=0;f<u&&(h=r(s,d,c),!h.converged);f++);if(i){n.assignLayoutChanges(s,d,c);return}return n.collectLayoutChanges(d)}const l=o.bind(null,!1);return l.assign=o.bind(null,!0),kr=l,kr}var ef=Zd();const tf=Be(ef);var Tr,To;function rf(){if(To)return Tr;To=1;const t=Xe(),e=It(),r=ys(),n=bs(),a=ws();function o(l,i){if(!t(l))throw new Error("graphology-layout-force/worker: the given graph is not a valid graphology instance.");i=e(i,a),this.callbacks={},i.onConverged&&(this.callbacks.onConverged=i.onConverged),this.graph=l,this.params=i,this.nodeStates={},this.frameID=null,this.running=!1,this.killed=!1}return o.prototype.isRunning=function(){return this.running},o.prototype.runFrame=function(){let{converged:l}=r(this.graph,this.nodeStates,this.params);n.assignLayoutChanges(this.graph,this.nodeStates,this.params),l=!1,l?(this.callbacks.onConverged&&this.callbacks.onConverged(),this.stop()):this.frameID=window.requestAnimationFrame(()=>this.runFrame())},o.prototype.stop=function(){return this.running=!1,this.frameID!==null&&(window.cancelAnimationFrame(this.frameID),this.frameID=null),this},o.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-force/worker.start: layout was killed.");this.running||(this.running=!0,this.runFrame())},o.prototype.kill=function(){this.stop(),delete this.nodeStates,this.killed=!0},Tr=o,Tr}var nf=rf();const of=Be(nf);function af(t={maxIterations:100}){return Et(tf,t)}function sf(t={}){return Ln(of,t)}var Rr,Ro;function lf(){if(Ro)return Rr;Ro=1;var t=0,e=1,r=2,n=3,a=4,o=5,l=6,i=7,s=8,c=9,u=0,d=1,h=2,f=0,y=1,b=2,R=3,P=4,S=5,k=6,A=7,j=8,D=3,v=10,_=3,x=9,T=10;return Rr=function(z,w,F){var K,O,C,E,W,re,M,m,L,U,q=w.length,Q=F.length,B=z.adjustSizes,X=z.barnesHutTheta*z.barnesHutTheta,le,ne,se,oe,$,V,H,N=[];for(C=0;C<q;C+=v)w[C+a]=w[C+r],w[C+o]=w[C+n],w[C+r]=0,w[C+n]=0;if(z.outboundAttractionDistribution){for(le=0,C=0;C<q;C+=v)le+=w[C+l];le/=q/v}if(z.barnesHutOptimize){var ae=1/0,ue=-1/0,ee=1/0,J=-1/0,G,he,pe;for(C=0;C<q;C+=v)ae=Math.min(ae,w[C+t]),ue=Math.max(ue,w[C+t]),ee=Math.min(ee,w[C+e]),J=Math.max(J,w[C+e]);var ye=ue-ae,xe=J-ee;for(ye>xe?(ee-=(ye-xe)/2,J=ee+ye):(ae-=(xe-ye)/2,ue=ae+xe),N[0+f]=-1,N[0+y]=(ae+ue)/2,N[0+b]=(ee+J)/2,N[0+R]=Math.max(ue-ae,J-ee),N[0+P]=-1,N[0+S]=-1,N[0+k]=0,N[0+A]=0,N[0+j]=0,K=1,C=0;C<q;C+=v)for(O=0,pe=D;;)if(N[O+S]>=0){w[C+t]<N[O+y]?w[C+e]<N[O+b]?G=N[O+S]:G=N[O+S]+x:w[C+e]<N[O+b]?G=N[O+S]+x*2:G=N[O+S]+x*3,N[O+A]=(N[O+A]*N[O+k]+w[C+t]*w[C+l])/(N[O+k]+w[C+l]),N[O+j]=(N[O+j]*N[O+k]+w[C+e]*w[C+l])/(N[O+k]+w[C+l]),N[O+k]+=w[C+l],O=G;continue}else if(N[O+f]<0){N[O+f]=C;break}else{if(N[O+S]=K*x,m=N[O+R]/2,L=N[O+S],N[L+f]=-1,N[L+y]=N[O+y]-m,N[L+b]=N[O+b]-m,N[L+R]=m,N[L+P]=L+x,N[L+S]=-1,N[L+k]=0,N[L+A]=0,N[L+j]=0,L+=x,N[L+f]=-1,N[L+y]=N[O+y]-m,N[L+b]=N[O+b]+m,N[L+R]=m,N[L+P]=L+x,N[L+S]=-1,N[L+k]=0,N[L+A]=0,N[L+j]=0,L+=x,N[L+f]=-1,N[L+y]=N[O+y]+m,N[L+b]=N[O+b]-m,N[L+R]=m,N[L+P]=L+x,N[L+S]=-1,N[L+k]=0,N[L+A]=0,N[L+j]=0,L+=x,N[L+f]=-1,N[L+y]=N[O+y]+m,N[L+b]=N[O+b]+m,N[L+R]=m,N[L+P]=N[O+P],N[L+S]=-1,N[L+k]=0,N[L+A]=0,N[L+j]=0,K+=4,w[N[O+f]+t]<N[O+y]?w[N[O+f]+e]<N[O+b]?G=N[O+S]:G=N[O+S]+x:w[N[O+f]+e]<N[O+b]?G=N[O+S]+x*2:G=N[O+S]+x*3,N[O+k]=w[N[O+f]+l],N[O+A]=w[N[O+f]+t],N[O+j]=w[N[O+f]+e],N[G+f]=N[O+f],N[O+f]=-1,w[C+t]<N[O+y]?w[C+e]<N[O+b]?he=N[O+S]:he=N[O+S]+x:w[C+e]<N[O+b]?he=N[O+S]+x*2:he=N[O+S]+x*3,G===he)if(pe--){O=G;continue}else{pe=D;break}N[he+f]=C;break}}if(z.barnesHutOptimize)for(ne=z.scalingRatio,C=0;C<q;C+=v)for(O=0;;)if(N[O+S]>=0)if(V=Math.pow(w[C+t]-N[O+A],2)+Math.pow(w[C+e]-N[O+j],2),U=N[O+R],4*U*U/V<X){if(se=w[C+t]-N[O+A],oe=w[C+e]-N[O+j],B===!0?V>0?(H=ne*w[C+l]*N[O+k]/V,w[C+r]+=se*H,w[C+n]+=oe*H):V<0&&(H=-ne*w[C+l]*N[O+k]/Math.sqrt(V),w[C+r]+=se*H,w[C+n]+=oe*H):V>0&&(H=ne*w[C+l]*N[O+k]/V,w[C+r]+=se*H,w[C+n]+=oe*H),O=N[O+P],O<0)break;continue}else{O=N[O+S];continue}else{if(re=N[O+f],re>=0&&re!==C&&(se=w[C+t]-w[re+t],oe=w[C+e]-w[re+e],V=se*se+oe*oe,B===!0?V>0?(H=ne*w[C+l]*w[re+l]/V,w[C+r]+=se*H,w[C+n]+=oe*H):V<0&&(H=-ne*w[C+l]*w[re+l]/Math.sqrt(V),w[C+r]+=se*H,w[C+n]+=oe*H):V>0&&(H=ne*w[C+l]*w[re+l]/V,w[C+r]+=se*H,w[C+n]+=oe*H)),O=N[O+P],O<0)break;continue}else for(ne=z.scalingRatio,E=0;E<q;E+=v)for(W=0;W<E;W+=v)se=w[E+t]-w[W+t],oe=w[E+e]-w[W+e],B===!0?(V=Math.sqrt(se*se+oe*oe)-w[E+s]-w[W+s],V>0?(H=ne*w[E+l]*w[W+l]/V/V,w[E+r]+=se*H,w[E+n]+=oe*H,w[W+r]-=se*H,w[W+n]-=oe*H):V<0&&(H=100*ne*w[E+l]*w[W+l],w[E+r]+=se*H,w[E+n]+=oe*H,w[W+r]-=se*H,w[W+n]-=oe*H)):(V=Math.sqrt(se*se+oe*oe),V>0&&(H=ne*w[E+l]*w[W+l]/V/V,w[E+r]+=se*H,w[E+n]+=oe*H,w[W+r]-=se*H,w[W+n]-=oe*H));for(L=z.gravity/z.scalingRatio,ne=z.scalingRatio,C=0;C<q;C+=v)H=0,se=w[C+t],oe=w[C+e],V=Math.sqrt(Math.pow(se,2)+Math.pow(oe,2)),z.strongGravityMode?V>0&&(H=ne*w[C+l]*L):V>0&&(H=ne*w[C+l]*L/V),w[C+r]-=se*H,w[C+n]-=oe*H;for(ne=1*(z.outboundAttractionDistribution?le:1),M=0;M<Q;M+=_)E=F[M+u],W=F[M+d],m=F[M+h],$=Math.pow(m,z.edgeWeightInfluence),se=w[E+t]-w[W+t],oe=w[E+e]-w[W+e],B===!0?(V=Math.sqrt(se*se+oe*oe)-w[E+s]-w[W+s],z.linLogMode?z.outboundAttractionDistribution?V>0&&(H=-ne*$*Math.log(1+V)/V/w[E+l]):V>0&&(H=-ne*$*Math.log(1+V)/V):z.outboundAttractionDistribution?V>0&&(H=-ne*$/w[E+l]):V>0&&(H=-ne*$)):(V=Math.sqrt(Math.pow(se,2)+Math.pow(oe,2)),z.linLogMode?z.outboundAttractionDistribution?V>0&&(H=-ne*$*Math.log(1+V)/V/w[E+l]):V>0&&(H=-ne*$*Math.log(1+V)/V):z.outboundAttractionDistribution?(V=1,H=-ne*$/w[E+l]):(V=1,H=-ne*$)),V>0&&(w[E+r]+=se*H,w[E+n]+=oe*H,w[W+r]-=se*H,w[W+n]-=oe*H);var de,me,je,ke,Te,De;if(B===!0)for(C=0;C<q;C+=v)w[C+c]!==1&&(de=Math.sqrt(Math.pow(w[C+r],2)+Math.pow(w[C+n],2)),de>T&&(w[C+r]=w[C+r]*T/de,w[C+n]=w[C+n]*T/de),me=w[C+l]*Math.sqrt((w[C+a]-w[C+r])*(w[C+a]-w[C+r])+(w[C+o]-w[C+n])*(w[C+o]-w[C+n])),je=Math.sqrt((w[C+a]+w[C+r])*(w[C+a]+w[C+r])+(w[C+o]+w[C+n])*(w[C+o]+w[C+n]))/2,ke=.1*Math.log(1+je)/(1+Math.sqrt(me)),Te=w[C+t]+w[C+r]*(ke/z.slowDown),w[C+t]=Te,De=w[C+e]+w[C+n]*(ke/z.slowDown),w[C+e]=De);else for(C=0;C<q;C+=v)w[C+c]!==1&&(me=w[C+l]*Math.sqrt((w[C+a]-w[C+r])*(w[C+a]-w[C+r])+(w[C+o]-w[C+n])*(w[C+o]-w[C+n])),je=Math.sqrt((w[C+a]+w[C+r])*(w[C+a]+w[C+r])+(w[C+o]+w[C+n])*(w[C+o]+w[C+n]))/2,ke=w[C+i]*Math.log(1+je)/(1+Math.sqrt(me)),w[C+i]=Math.min(1,Math.sqrt(ke*(Math.pow(w[C+r],2)+Math.pow(w[C+n],2))/(1+Math.sqrt(me)))),Te=w[C+t]+w[C+r]*(ke/z.slowDown),w[C+t]=Te,De=w[C+e]+w[C+n]*(ke/z.slowDown),w[C+e]=De);return{}},Rr}var qe={},Ao;function xs(){if(Ao)return qe;Ao=1;var t=10,e=3;return qe.assign=function(r){r=r||{};var n=Array.prototype.slice.call(arguments).slice(1),a,o,l;for(a=0,l=n.length;a<l;a++)if(n[a])for(o in n[a])r[o]=n[a][o];return r},qe.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},qe.graphToByteArrays=function(r,n){var a=r.order,o=r.size,l={},i,s=new Float32Array(a*t),c=new Float32Array(o*e);return i=0,r.forEachNode(function(u,d){l[u]=i,s[i]=d.x,s[i+1]=d.y,s[i+2]=0,s[i+3]=0,s[i+4]=0,s[i+5]=0,s[i+6]=1,s[i+7]=1,s[i+8]=d.size||1,s[i+9]=d.fixed?1:0,i+=t}),i=0,r.forEachEdge(function(u,d,h,f,y,b,R){var P=l[h],S=l[f],k=n(u,d,h,f,y,b,R);s[P+6]+=k,s[S+6]+=k,c[i]=P,c[i+1]=S,c[i+2]=k,i+=e}),{nodes:s,edges:c}},qe.assignLayoutChanges=function(r,n,a){var o=0;r.updateEachNodeAttributes(function(l,i){return i.x=n[o],i.y=n[o+1],o+=t,a?a(l,i):i})},qe.readGraphPositions=function(r,n){var a=0;r.forEachNode(function(o,l){n[a]=l.x,n[a+1]=l.y,a+=t})},qe.collectLayoutChanges=function(r,n,a){for(var o=r.nodes(),l={},i=0,s=0,c=n.length;i<c;i+=t){if(a){var u=Object.assign({},r.getNodeAttributes(o[s]));u.x=n[i],u.y=n[i+1],u=a(o[s],u),l[o[s]]={x:u.x,y:u.y}}else l[o[s]]={x:n[i],y:n[i+1]};s++}return l},qe.createWorker=function(n){var a=window.URL||window.webkitURL,o=n.toString(),l=a.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),i=new Worker(l);return a.revokeObjectURL(l),i},qe}var Ar,Io;function Ss(){return Io||(Io=1,Ar={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Ar}var Ir,jo;function cf(){if(jo)return Ir;jo=1;var t=Xe(),e=zn().createEdgeWeightGetter,r=lf(),n=xs(),a=Ss();function o(s,c,u){if(!t(c))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof u=="number"&&(u={iterations:u});var d=u.iterations;if(typeof d!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(d<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var h=e("getEdgeWeight"in u?u.getEdgeWeight:"weight").fromEntry,f=typeof u.outputReducer=="function"?u.outputReducer:null,y=n.assign({},a,u.settings),b=n.validateSettings(y);if(b)throw new Error("graphology-layout-forceatlas2: "+b.message);var R=n.graphToByteArrays(c,h),P;for(P=0;P<d;P++)r(y,R.nodes,R.edges);if(s){n.assignLayoutChanges(c,R.nodes,f);return}return n.collectLayoutChanges(c,R.nodes)}function l(s){var c=typeof s=="number"?s:s.order;return{barnesHutOptimize:c>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(c)}}var i=o.bind(null,!1);return i.assign=o.bind(null,!0),i.inferSettings=l,Ir=i,Ir}var uf=cf();const df=Be(uf);var jr,No;function ff(){return No||(No=1,jr=function(){var e,r,n={};(function(){var o=0,l=1,i=2,s=3,c=4,u=5,d=6,h=7,f=8,y=9,b=0,R=1,P=2,S=0,k=1,A=2,j=3,D=4,v=5,_=6,x=7,T=8,I=3,z=10,w=3,F=9,K=10;n.exports=function(C,E,W){var re,M,m,L,U,q,Q,B,X,le,ne=E.length,se=W.length,oe=C.adjustSizes,$=C.barnesHutTheta*C.barnesHutTheta,V,H,N,ae,ue,ee,J,G=[];for(m=0;m<ne;m+=z)E[m+c]=E[m+i],E[m+u]=E[m+s],E[m+i]=0,E[m+s]=0;if(C.outboundAttractionDistribution){for(V=0,m=0;m<ne;m+=z)V+=E[m+d];V/=ne/z}if(C.barnesHutOptimize){var he=1/0,pe=-1/0,ye=1/0,xe=-1/0,de,me,je;for(m=0;m<ne;m+=z)he=Math.min(he,E[m+o]),pe=Math.max(pe,E[m+o]),ye=Math.min(ye,E[m+l]),xe=Math.max(xe,E[m+l]);var ke=pe-he,Te=xe-ye;for(ke>Te?(ye-=(ke-Te)/2,xe=ye+ke):(he-=(Te-ke)/2,pe=he+Te),G[0+S]=-1,G[0+k]=(he+pe)/2,G[0+A]=(ye+xe)/2,G[0+j]=Math.max(pe-he,xe-ye),G[0+D]=-1,G[0+v]=-1,G[0+_]=0,G[0+x]=0,G[0+T]=0,re=1,m=0;m<ne;m+=z)for(M=0,je=I;;)if(G[M+v]>=0){E[m+o]<G[M+k]?E[m+l]<G[M+A]?de=G[M+v]:de=G[M+v]+F:E[m+l]<G[M+A]?de=G[M+v]+F*2:de=G[M+v]+F*3,G[M+x]=(G[M+x]*G[M+_]+E[m+o]*E[m+d])/(G[M+_]+E[m+d]),G[M+T]=(G[M+T]*G[M+_]+E[m+l]*E[m+d])/(G[M+_]+E[m+d]),G[M+_]+=E[m+d],M=de;continue}else if(G[M+S]<0){G[M+S]=m;break}else{if(G[M+v]=re*F,B=G[M+j]/2,X=G[M+v],G[X+S]=-1,G[X+k]=G[M+k]-B,G[X+A]=G[M+A]-B,G[X+j]=B,G[X+D]=X+F,G[X+v]=-1,G[X+_]=0,G[X+x]=0,G[X+T]=0,X+=F,G[X+S]=-1,G[X+k]=G[M+k]-B,G[X+A]=G[M+A]+B,G[X+j]=B,G[X+D]=X+F,G[X+v]=-1,G[X+_]=0,G[X+x]=0,G[X+T]=0,X+=F,G[X+S]=-1,G[X+k]=G[M+k]+B,G[X+A]=G[M+A]-B,G[X+j]=B,G[X+D]=X+F,G[X+v]=-1,G[X+_]=0,G[X+x]=0,G[X+T]=0,X+=F,G[X+S]=-1,G[X+k]=G[M+k]+B,G[X+A]=G[M+A]+B,G[X+j]=B,G[X+D]=G[M+D],G[X+v]=-1,G[X+_]=0,G[X+x]=0,G[X+T]=0,re+=4,E[G[M+S]+o]<G[M+k]?E[G[M+S]+l]<G[M+A]?de=G[M+v]:de=G[M+v]+F:E[G[M+S]+l]<G[M+A]?de=G[M+v]+F*2:de=G[M+v]+F*3,G[M+_]=E[G[M+S]+d],G[M+x]=E[G[M+S]+o],G[M+T]=E[G[M+S]+l],G[de+S]=G[M+S],G[M+S]=-1,E[m+o]<G[M+k]?E[m+l]<G[M+A]?me=G[M+v]:me=G[M+v]+F:E[m+l]<G[M+A]?me=G[M+v]+F*2:me=G[M+v]+F*3,de===me)if(je--){M=de;continue}else{je=I;break}G[me+S]=m;break}}if(C.barnesHutOptimize)for(H=C.scalingRatio,m=0;m<ne;m+=z)for(M=0;;)if(G[M+v]>=0)if(ee=Math.pow(E[m+o]-G[M+x],2)+Math.pow(E[m+l]-G[M+T],2),le=G[M+j],4*le*le/ee<$){if(N=E[m+o]-G[M+x],ae=E[m+l]-G[M+T],oe===!0?ee>0?(J=H*E[m+d]*G[M+_]/ee,E[m+i]+=N*J,E[m+s]+=ae*J):ee<0&&(J=-H*E[m+d]*G[M+_]/Math.sqrt(ee),E[m+i]+=N*J,E[m+s]+=ae*J):ee>0&&(J=H*E[m+d]*G[M+_]/ee,E[m+i]+=N*J,E[m+s]+=ae*J),M=G[M+D],M<0)break;continue}else{M=G[M+v];continue}else{if(q=G[M+S],q>=0&&q!==m&&(N=E[m+o]-E[q+o],ae=E[m+l]-E[q+l],ee=N*N+ae*ae,oe===!0?ee>0?(J=H*E[m+d]*E[q+d]/ee,E[m+i]+=N*J,E[m+s]+=ae*J):ee<0&&(J=-H*E[m+d]*E[q+d]/Math.sqrt(ee),E[m+i]+=N*J,E[m+s]+=ae*J):ee>0&&(J=H*E[m+d]*E[q+d]/ee,E[m+i]+=N*J,E[m+s]+=ae*J)),M=G[M+D],M<0)break;continue}else for(H=C.scalingRatio,L=0;L<ne;L+=z)for(U=0;U<L;U+=z)N=E[L+o]-E[U+o],ae=E[L+l]-E[U+l],oe===!0?(ee=Math.sqrt(N*N+ae*ae)-E[L+f]-E[U+f],ee>0?(J=H*E[L+d]*E[U+d]/ee/ee,E[L+i]+=N*J,E[L+s]+=ae*J,E[U+i]-=N*J,E[U+s]-=ae*J):ee<0&&(J=100*H*E[L+d]*E[U+d],E[L+i]+=N*J,E[L+s]+=ae*J,E[U+i]-=N*J,E[U+s]-=ae*J)):(ee=Math.sqrt(N*N+ae*ae),ee>0&&(J=H*E[L+d]*E[U+d]/ee/ee,E[L+i]+=N*J,E[L+s]+=ae*J,E[U+i]-=N*J,E[U+s]-=ae*J));for(X=C.gravity/C.scalingRatio,H=C.scalingRatio,m=0;m<ne;m+=z)J=0,N=E[m+o],ae=E[m+l],ee=Math.sqrt(Math.pow(N,2)+Math.pow(ae,2)),C.strongGravityMode?ee>0&&(J=H*E[m+d]*X):ee>0&&(J=H*E[m+d]*X/ee),E[m+i]-=N*J,E[m+s]-=ae*J;for(H=1*(C.outboundAttractionDistribution?V:1),Q=0;Q<se;Q+=w)L=W[Q+b],U=W[Q+R],B=W[Q+P],ue=Math.pow(B,C.edgeWeightInfluence),N=E[L+o]-E[U+o],ae=E[L+l]-E[U+l],oe===!0?(ee=Math.sqrt(N*N+ae*ae)-E[L+f]-E[U+f],C.linLogMode?C.outboundAttractionDistribution?ee>0&&(J=-H*ue*Math.log(1+ee)/ee/E[L+d]):ee>0&&(J=-H*ue*Math.log(1+ee)/ee):C.outboundAttractionDistribution?ee>0&&(J=-H*ue/E[L+d]):ee>0&&(J=-H*ue)):(ee=Math.sqrt(Math.pow(N,2)+Math.pow(ae,2)),C.linLogMode?C.outboundAttractionDistribution?ee>0&&(J=-H*ue*Math.log(1+ee)/ee/E[L+d]):ee>0&&(J=-H*ue*Math.log(1+ee)/ee):C.outboundAttractionDistribution?(ee=1,J=-H*ue/E[L+d]):(ee=1,J=-H*ue)),ee>0&&(E[L+i]+=N*J,E[L+s]+=ae*J,E[U+i]-=N*J,E[U+s]-=ae*J);var De,Ke,Qe,Re,st,Oe;if(oe===!0)for(m=0;m<ne;m+=z)E[m+y]!==1&&(De=Math.sqrt(Math.pow(E[m+i],2)+Math.pow(E[m+s],2)),De>K&&(E[m+i]=E[m+i]*K/De,E[m+s]=E[m+s]*K/De),Ke=E[m+d]*Math.sqrt((E[m+c]-E[m+i])*(E[m+c]-E[m+i])+(E[m+u]-E[m+s])*(E[m+u]-E[m+s])),Qe=Math.sqrt((E[m+c]+E[m+i])*(E[m+c]+E[m+i])+(E[m+u]+E[m+s])*(E[m+u]+E[m+s]))/2,Re=.1*Math.log(1+Qe)/(1+Math.sqrt(Ke)),st=E[m+o]+E[m+i]*(Re/C.slowDown),E[m+o]=st,Oe=E[m+l]+E[m+s]*(Re/C.slowDown),E[m+l]=Oe);else for(m=0;m<ne;m+=z)E[m+y]!==1&&(Ke=E[m+d]*Math.sqrt((E[m+c]-E[m+i])*(E[m+c]-E[m+i])+(E[m+u]-E[m+s])*(E[m+u]-E[m+s])),Qe=Math.sqrt((E[m+c]+E[m+i])*(E[m+c]+E[m+i])+(E[m+u]+E[m+s])*(E[m+u]+E[m+s]))/2,Re=E[m+h]*Math.log(1+Qe)/(1+Math.sqrt(Ke)),E[m+h]=Math.min(1,Math.sqrt(Re*(Math.pow(E[m+i],2)+Math.pow(E[m+s],2))/(1+Math.sqrt(Ke)))),st=E[m+o]+E[m+i]*(Re/C.slowDown),E[m+o]=st,Oe=E[m+l]+E[m+s]*(Re/C.slowDown),E[m+l]=Oe);return{}}})();var a=n.exports;self.addEventListener("message",function(o){var l=o.data;e=new Float32Array(l.nodes),l.edges&&(r=new Float32Array(l.edges)),a(l.settings,e,r),self.postMessage({nodes:e.buffer},[e.buffer])})}),jr}var Nr,Lo;function hf(){if(Lo)return Nr;Lo=1;var t=ff(),e=Xe(),r=zn().createEdgeWeightGetter,n=xs(),a=Ss();function o(l,i){if(i=i||{},!e(l))throw new Error("graphology-layout-forceatlas2/worker: the given graph is not a valid graphology instance.");var s=r("getEdgeWeight"in i?i.getEdgeWeight:"weight").fromEntry,c=n.assign({},a,i.settings),u=n.validateSettings(c);if(u)throw new Error("graphology-layout-forceatlas2/worker: "+u.message);this.worker=null,this.graph=l,this.settings=c,this.getEdgeWeight=s,this.matrices=null,this.running=!1,this.killed=!1,this.outputReducer=typeof i.outputReducer=="function"?i.outputReducer:null,this.handleMessage=this.handleMessage.bind(this);var d=void 0,h=this;this.handleGraphUpdate=function(){h.worker&&h.worker.terminate(),d&&clearTimeout(d),d=setTimeout(function(){d=void 0,h.spawnWorker()},0)},l.on("nodeAdded",this.handleGraphUpdate),l.on("edgeAdded",this.handleGraphUpdate),l.on("nodeDropped",this.handleGraphUpdate),l.on("edgeDropped",this.handleGraphUpdate),this.spawnWorker()}return o.prototype.isRunning=function(){return this.running},o.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=n.createWorker(t),this.worker.addEventListener("message",this.handleMessage),this.running&&(this.running=!1,this.start())},o.prototype.handleMessage=function(l){if(this.running){var i=new Float32Array(l.data.nodes);n.assignLayoutChanges(this.graph,i,this.outputReducer),this.outputReducer&&n.readGraphPositions(this.graph,i),this.matrices.nodes=i,this.askForIterations()}},o.prototype.askForIterations=function(l){var i=this.matrices,s={settings:this.settings,nodes:i.nodes.buffer},c=[i.nodes.buffer];return l&&(s.edges=i.edges.buffer,c.push(i.edges.buffer)),this.worker.postMessage(s,c),this},o.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-forceatlas2/worker.start: layout was killed.");return this.running?this:(this.matrices=n.graphToByteArrays(this.graph,this.getEdgeWeight),this.running=!0,this.askForIterations(!0),this)},o.prototype.stop=function(){return this.running=!1,this},o.prototype.kill=function(){if(this.killed)return this;this.running=!1,this.killed=!0,this.matrices=null,this.worker.terminate(),this.graph.removeListener("nodeAdded",this.handleGraphUpdate),this.graph.removeListener("edgeAdded",this.handleGraphUpdate),this.graph.removeListener("nodeDropped",this.handleGraphUpdate),this.graph.removeListener("edgeDropped",this.handleGraphUpdate)},Nr=o,Nr}var gf=hf();const pf=Be(gf);function _s(t={iterations:100}){return Et(df,t)}function mf(t={}){return Ln(pf,t)}var Lr,zo;function vf(){if(zo)return Lr;zo=1;var t=0,e=1,r=2,n=3;function a(l,i){return l+"§"+i}function o(){return .01*(.5-Math.random())}return Lr=function(i,s){var c=i.margin,u=i.ratio,d=i.expansion,h=i.gridSize,f=i.speed,y,b,R,P,S,k,A=!0,j=s.length,D=j/n|0,v=new Float32Array(D),_=new Float32Array(D),x=1/0,T=1/0,I=-1/0,z=-1/0;for(y=0;y<j;y+=n)R=s[y+t],P=s[y+e],k=s[y+r]*u+c,x=Math.min(x,R-k),I=Math.max(I,R+k),T=Math.min(T,P-k),z=Math.max(z,P+k);var w=I-x,F=z-T,K=(x+I)/2,O=(T+z)/2;x=K-d*w/2,I=K+d*w/2,T=O-d*F/2,z=O+d*F/2;var C=new Array(h*h),E=C.length,W;for(W=0;W<E;W++)C[W]=[];var re,M,m,L,U,q,Q,B,X,le;for(y=0;y<j;y+=n)for(R=s[y+t],P=s[y+e],k=s[y+r]*u+c,re=R-k,M=R+k,m=P-k,L=P+k,U=Math.floor(h*(re-x)/(I-x)),q=Math.floor(h*(M-x)/(I-x)),Q=Math.floor(h*(m-T)/(z-T)),B=Math.floor(h*(L-T)/(z-T)),X=U;X<=q;X++)for(le=Q;le<=B;le++)C[X*h+le].push(y);var ne,se=new Set,oe,$,V,H,N,ae,ue,ee,J,G,he,pe,ye;for(W=0;W<E;W++)for(ne=C[W],y=0,S=ne.length;y<S;y++)for(oe=ne[y],V=s[oe+t],N=s[oe+e],ue=s[oe+r],b=y+1;b<S;b++)$=ne[b],J=a(oe,$),!(E>1&&se.has(J))&&(E>1&&se.add(J),H=s[$+t],ae=s[$+e],ee=s[$+r],G=H-V,he=ae-N,pe=Math.sqrt(G*G+he*he),ye=pe<ue*u+c+(ee*u+c),ye&&(A=!1,$=$/n|0,pe>0?(v[$]+=G/pe*(1+ue),_[$]+=he/pe*(1+ue)):(v[$]+=w*o(),_[$]+=F*o())));for(y=0,b=0;y<j;y+=n,b++)s[y+t]+=v[b]*.1*f,s[y+e]+=_[b]*.1*f;return{converged:A}},Lr}var lt={},Po;function Es(){if(Po)return lt;Po=1;var t=3;return lt.validateSettings=function(e){return"gridSize"in e&&typeof e.gridSize!="number"||e.gridSize<=0?{message:"the `gridSize` setting should be a positive number."}:"margin"in e&&typeof e.margin!="number"||e.margin<0?{message:"the `margin` setting should be 0 or a positive number."}:"expansion"in e&&typeof e.expansion!="number"||e.expansion<=0?{message:"the `expansion` setting should be a positive number."}:"ratio"in e&&typeof e.ratio!="number"||e.ratio<=0?{message:"the `ratio` setting should be a positive number."}:"speed"in e&&typeof e.speed!="number"||e.speed<=0?{message:"the `speed` setting should be a positive number."}:null},lt.graphToByteArray=function(e,r){var n=e.order,a=new Float32Array(n*t),o=0;return e.forEachNode(function(l,i){typeof r=="function"&&(i=r(l,i)),a[o]=i.x,a[o+1]=i.y,a[o+2]=i.size||1,o+=t}),a},lt.assignLayoutChanges=function(e,r,n){var a=0;e.forEachNode(function(o){var l={x:r[a],y:r[a+1]};typeof n=="function"&&(l=n(o,l)),e.mergeNodeAttributes(o,l),a+=t})},lt.collectLayoutChanges=function(e,r,n){var a={},o=0;return e.forEachNode(function(l){var i={x:r[o],y:r[o+1]};typeof n=="function"&&(i=n(l,i)),a[l]=i,o+=t}),a},lt.createWorker=function(r){var n=window.URL||window.webkitURL,a=r.toString(),o=n.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),l=new Worker(o);return n.revokeObjectURL(o),l},lt}var zr,Do;function Cs(){return Do||(Do=1,zr={gridSize:20,margin:5,expansion:1.1,ratio:1,speed:3}),zr}var Pr,Oo;function yf(){if(Oo)return Pr;Oo=1;var t=Xe(),e=vf(),r=Es(),n=Cs(),a=500;function o(i,s,c){if(!t(s))throw new Error("graphology-layout-noverlap: the given graph is not a valid graphology instance.");typeof c=="number"?c={maxIterations:c}:c=c||{};var u=c.maxIterations||a;if(typeof u!="number"||u<=0)throw new Error("graphology-layout-force: you should provide a positive number of maximum iterations.");var d=Object.assign({},n,c.settings),h=r.validateSettings(d);if(h)throw new Error("graphology-layout-noverlap: "+h.message);var f=r.graphToByteArray(s,c.inputReducer),y=!1,b;for(b=0;b<u&&!y;b++)y=e(d,f).converged;if(i){r.assignLayoutChanges(s,f,c.outputReducer);return}return r.collectLayoutChanges(s,f,c.outputReducer)}var l=o.bind(null,!1);return l.assign=o.bind(null,!0),Pr=l,Pr}var bf=yf();const wf=Be(bf);var Dr,Go;function xf(){return Go||(Go=1,Dr=function(){var e,r={};(function(){var a=0,o=1,l=2,i=3;function s(u,d){return u+"§"+d}function c(){return .01*(.5-Math.random())}r.exports=function(d,h){var f=d.margin,y=d.ratio,b=d.expansion,R=d.gridSize,P=d.speed,S,k,A,j,D,v,_=!0,x=h.length,T=x/i|0,I=new Float32Array(T),z=new Float32Array(T),w=1/0,F=1/0,K=-1/0,O=-1/0;for(S=0;S<x;S+=i)A=h[S+a],j=h[S+o],v=h[S+l]*y+f,w=Math.min(w,A-v),K=Math.max(K,A+v),F=Math.min(F,j-v),O=Math.max(O,j+v);var C=K-w,E=O-F,W=(w+K)/2,re=(F+O)/2;w=W-b*C/2,K=W+b*C/2,F=re-b*E/2,O=re+b*E/2;var M=new Array(R*R),m=M.length,L;for(L=0;L<m;L++)M[L]=[];var U,q,Q,B,X,le,ne,se,oe,$;for(S=0;S<x;S+=i)for(A=h[S+a],j=h[S+o],v=h[S+l]*y+f,U=A-v,q=A+v,Q=j-v,B=j+v,X=Math.floor(R*(U-w)/(K-w)),le=Math.floor(R*(q-w)/(K-w)),ne=Math.floor(R*(Q-F)/(O-F)),se=Math.floor(R*(B-F)/(O-F)),oe=X;oe<=le;oe++)for($=ne;$<=se;$++)M[oe*R+$].push(S);var V,H=new Set,N,ae,ue,ee,J,G,he,pe,ye,xe,de,me,je;for(L=0;L<m;L++)for(V=M[L],S=0,D=V.length;S<D;S++)for(N=V[S],ue=h[N+a],J=h[N+o],he=h[N+l],k=S+1;k<D;k++)ae=V[k],ye=s(N,ae),!(m>1&&H.has(ye))&&(m>1&&H.add(ye),ee=h[ae+a],G=h[ae+o],pe=h[ae+l],xe=ee-ue,de=G-J,me=Math.sqrt(xe*xe+de*de),je=me<he*y+f+(pe*y+f),je&&(_=!1,ae=ae/i|0,me>0?(I[ae]+=xe/me*(1+he),z[ae]+=de/me*(1+he)):(I[ae]+=C*c(),z[ae]+=E*c())));for(S=0,k=0;S<x;S+=i,k++)h[S+a]+=I[k]*.1*P,h[S+o]+=z[k]*.1*P;return{converged:_}}})();var n=r.exports;self.addEventListener("message",function(a){var o=a.data;e=new Float32Array(o.nodes);var l=n(o.settings,e);self.postMessage({result:l,nodes:e.buffer},[e.buffer])})}),Dr}var Or,Mo;function Sf(){if(Mo)return Or;Mo=1;var t=xf(),e=Xe(),r=Es(),n=Cs();function a(o,l){if(l=l||{},!e(o))throw new Error("graphology-layout-noverlap/worker: the given graph is not a valid graphology instance.");var i=Object.assign({},n,l.settings),s=r.validateSettings(i);if(s)throw new Error("graphology-layout-noverlap/worker: "+s.message);this.worker=null,this.graph=o,this.settings=i,this.matrices=null,this.running=!1,this.killed=!1,this.inputReducer=l.inputReducer,this.outputReducer=l.outputReducer,this.callbacks={onConverged:typeof l.onConverged=="function"?l.onConverged:null},this.handleMessage=this.handleMessage.bind(this);var c=!1,u=this;this.handleAddition=function(){c||(c=!0,u.spawnWorker(),setTimeout(function(){c=!1},0))},o.on("nodeAdded",this.handleAddition),o.on("edgeAdded",this.handleAddition),this.spawnWorker()}return a.prototype.isRunning=function(){return this.running},a.prototype.spawnWorker=function(){this.worker&&this.worker.terminate(),this.worker=r.createWorker(t),this.worker.addEventListener("message",this.handleMessage),this.running&&(this.running=!1,this.start())},a.prototype.handleMessage=function(o){if(this.running){var l=new Float32Array(o.data.nodes);if(r.assignLayoutChanges(this.graph,l,this.outputReducer),this.matrices.nodes=l,o.data.result.converged){this.callbacks.onConverged&&this.callbacks.onConverged(),this.stop();return}this.askForIterations()}},a.prototype.askForIterations=function(){var o=this.matrices,l={settings:this.settings,nodes:o.nodes.buffer},i=[o.nodes.buffer];return this.worker.postMessage(l,i),this},a.prototype.start=function(){if(this.killed)throw new Error("graphology-layout-noverlap/worker.start: layout was killed.");return this.running?this:(this.matrices={nodes:r.graphToByteArray(this.graph,this.inputReducer)},this.running=!0,this.askForIterations(),this)},a.prototype.stop=function(){return this.running=!1,this},a.prototype.kill=function(){if(this.killed)return this;this.running=!1,this.killed=!0,this.matrices=null,this.worker.terminate(),this.graph.removeListener("nodeAdded",this.handleAddition),this.graph.removeListener("edgeAdded",this.handleAddition)},Or=a,Or}var _f=Sf();const Ef=Be(_f);function Cf(t={}){return Et(wf,t)}function kf(t={}){return Ln(Ef,t)}var Gr,$o;function Tf(){if($o)return Gr;$o=1;var t=It(),e=Xe(),r={dimensions:["x","y"],center:.5,rng:Math.random,scale:1};function n(o,l,i){if(!e(l))throw new Error("graphology-layout/random: the given graph is not a valid graphology instance.");i=t(i,r);var s=i.dimensions;if(!Array.isArray(s)||s.length<1)throw new Error("graphology-layout/random: given dimensions are invalid.");var c=s.length,u=i.center,d=i.rng,h=i.scale,f=(u-.5)*h;function y(R){for(var P=0;P<c;P++)R[s[P]]=d()*h+f;return R}if(!o){var b={};return l.forEachNode(function(R){b[R]=y({})}),b}l.updateEachNodeAttributes(function(R,P){return y(P),P},{attributes:s})}var a=n.bind(null,!1);return a.assign=n.bind(null,!0),Gr=a,Gr}var Rf=Tf();const Af=Be(Rf);function If(t={}){return Et(Af,t)}var Fo=1,jf=.9,Nf=.8,Lf=.17,Mr=.1,$r=.999,zf=.9999,Pf=.99,Df=/[\\\/_+.#"@\[\(\{&]/,Of=/[\\\/_+.#"@\[\(\{&]/g,Gf=/[\s-]/,ks=/[\s-]/g;function vn(t,e,r,n,a,o,l){if(o===e.length)return a===t.length?Fo:Pf;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var s=n.charAt(o),c=r.indexOf(s,a),u=0,d,h,f,y;c>=0;)d=vn(t,e,r,n,c+1,o+1,l),d>u&&(c===a?d*=Fo:Df.test(t.charAt(c-1))?(d*=Nf,f=t.slice(a,c-1).match(Of),f&&a>0&&(d*=Math.pow($r,f.length))):Gf.test(t.charAt(c-1))?(d*=jf,y=t.slice(a,c-1).match(ks),y&&a>0&&(d*=Math.pow($r,y.length))):(d*=Lf,a>0&&(d*=Math.pow($r,c-a))),t.charAt(c)!==e.charAt(o)&&(d*=zf)),(d<Mr&&r.charAt(c-1)===n.charAt(o+1)||n.charAt(o+1)===n.charAt(o)&&r.charAt(c-1)!==n.charAt(o))&&(h=vn(t,e,r,n,c+1,o+2,l),h*Mr>d&&(d=h*Mr)),d>u&&(u=d),c=r.indexOf(s,c+1);return l[i]=u,u}function Ho(t){return t.toLowerCase().replace(ks," ")}function Mf(t,e,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,vn(t,e,Ho(t),Ho(e),0,0,{})}var Fr={exports:{}},Hr={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Bo;function $f(){if(Bo)return Hr;Bo=1;var t=bi();function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var r=typeof Object.is=="function"?Object.is:e,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(d,h){var f=h(),y=n({inst:{value:f,getSnapshot:h}}),b=y[0].inst,R=y[1];return o(function(){b.value=f,b.getSnapshot=h,s(b)&&R({inst:b})},[d,f,h]),a(function(){return s(b)&&R({inst:b}),d(function(){s(b)&&R({inst:b})})},[d]),l(f),f}function s(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!r(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:i;return Hr.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Hr}var Vo;function Ff(){return Vo||(Vo=1,Fr.exports=$f()),Fr.exports}var Hf=Ff(),Rt='[cmdk-group=""]',Br='[cmdk-group-items=""]',Bf='[cmdk-group-heading=""]',Pn='[cmdk-item=""]',Uo=`${Pn}:not([aria-disabled="true"])`,yn="cmdk-item-select",dt="data-value",Vf=(t,e,r)=>Mf(t,e,r),Ts=p.createContext(void 0),jt=()=>p.useContext(Ts),Rs=p.createContext(void 0),Dn=()=>p.useContext(Rs),As=p.createContext(void 0),Is=p.forwardRef((t,e)=>{let r=bt(()=>{var m,L;return{search:"",value:(L=(m=t.value)!=null?m:t.defaultValue)!=null?L:"",filtered:{count:0,items:new Map,groups:new Set}}}),n=bt(()=>new Set),a=bt(()=>new Map),o=bt(()=>new Map),l=bt(()=>new Set),i=js(t),{label:s,children:c,value:u,onValueChange:d,filter:h,shouldFilter:f,loop:y,disablePointerSelection:b=!1,vimBindings:R=!0,...P}=t,S=ft(),k=ft(),A=ft(),j=p.useRef(null),D=th();pt(()=>{if(u!==void 0){let m=u.trim();r.current.value=m,v.emit()}},[u]),pt(()=>{D(6,w)},[]);let v=p.useMemo(()=>({subscribe:m=>(l.current.add(m),()=>l.current.delete(m)),snapshot:()=>r.current,setState:(m,L,U)=>{var q,Q,B;if(!Object.is(r.current[m],L)){if(r.current[m]=L,m==="search")z(),T(),D(1,I);else if(m==="value"&&(U||D(5,w),((q=i.current)==null?void 0:q.value)!==void 0)){let X=L??"";(B=(Q=i.current).onValueChange)==null||B.call(Q,X);return}v.emit()}},emit:()=>{l.current.forEach(m=>m())}}),[]),_=p.useMemo(()=>({value:(m,L,U)=>{var q;L!==((q=o.current.get(m))==null?void 0:q.value)&&(o.current.set(m,{value:L,keywords:U}),r.current.filtered.items.set(m,x(L,U)),D(2,()=>{T(),v.emit()}))},item:(m,L)=>(n.current.add(m),L&&(a.current.has(L)?a.current.get(L).add(m):a.current.set(L,new Set([m]))),D(3,()=>{z(),T(),r.current.value||I(),v.emit()}),()=>{o.current.delete(m),n.current.delete(m),r.current.filtered.items.delete(m);let U=F();D(4,()=>{z(),(U==null?void 0:U.getAttribute("id"))===m&&I(),v.emit()})}),group:m=>(a.current.has(m)||a.current.set(m,new Set),()=>{o.current.delete(m),a.current.delete(m)}),filter:()=>i.current.shouldFilter,label:s||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:A,labelId:k,listInnerRef:j}),[]);function x(m,L){var U,q;let Q=(q=(U=i.current)==null?void 0:U.filter)!=null?q:Vf;return m?Q(m,r.current.search,L):0}function T(){if(!r.current.search||i.current.shouldFilter===!1)return;let m=r.current.filtered.items,L=[];r.current.filtered.groups.forEach(q=>{let Q=a.current.get(q),B=0;Q.forEach(X=>{let le=m.get(X);B=Math.max(le,B)}),L.push([q,B])});let U=j.current;K().sort((q,Q)=>{var B,X;let le=q.getAttribute("id"),ne=Q.getAttribute("id");return((B=m.get(ne))!=null?B:0)-((X=m.get(le))!=null?X:0)}).forEach(q=>{let Q=q.closest(Br);Q?Q.appendChild(q.parentElement===Q?q:q.closest(`${Br} > *`)):U.appendChild(q.parentElement===U?q:q.closest(`${Br} > *`))}),L.sort((q,Q)=>Q[1]-q[1]).forEach(q=>{var Q;let B=(Q=j.current)==null?void 0:Q.querySelector(`${Rt}[${dt}="${encodeURIComponent(q[0])}"]`);B==null||B.parentElement.appendChild(B)})}function I(){let m=K().find(U=>U.getAttribute("aria-disabled")!=="true"),L=m==null?void 0:m.getAttribute(dt);v.setState("value",L||void 0)}function z(){var m,L,U,q;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Q=0;for(let B of n.current){let X=(L=(m=o.current.get(B))==null?void 0:m.value)!=null?L:"",le=(q=(U=o.current.get(B))==null?void 0:U.keywords)!=null?q:[],ne=x(X,le);r.current.filtered.items.set(B,ne),ne>0&&Q++}for(let[B,X]of a.current)for(let le of X)if(r.current.filtered.items.get(le)>0){r.current.filtered.groups.add(B);break}r.current.filtered.count=Q}function w(){var m,L,U;let q=F();q&&(((m=q.parentElement)==null?void 0:m.firstChild)===q&&((U=(L=q.closest(Rt))==null?void 0:L.querySelector(Bf))==null||U.scrollIntoView({block:"nearest"})),q.scrollIntoView({block:"nearest"}))}function F(){var m;return(m=j.current)==null?void 0:m.querySelector(`${Pn}[aria-selected="true"]`)}function K(){var m;return Array.from(((m=j.current)==null?void 0:m.querySelectorAll(Uo))||[])}function O(m){let L=K()[m];L&&v.setState("value",L.getAttribute(dt))}function C(m){var L;let U=F(),q=K(),Q=q.findIndex(X=>X===U),B=q[Q+m];(L=i.current)!=null&&L.loop&&(B=Q+m<0?q[q.length-1]:Q+m===q.length?q[0]:q[Q+m]),B&&v.setState("value",B.getAttribute(dt))}function E(m){let L=F(),U=L==null?void 0:L.closest(Rt),q;for(;U&&!q;)U=m>0?Zf(U,Rt):eh(U,Rt),q=U==null?void 0:U.querySelector(Uo);q?v.setState("value",q.getAttribute(dt)):C(m)}let W=()=>O(K().length-1),re=m=>{m.preventDefault(),m.metaKey?W():m.altKey?E(1):C(1)},M=m=>{m.preventDefault(),m.metaKey?O(0):m.altKey?E(-1):C(-1)};return p.createElement(Ee.div,{ref:e,tabIndex:-1,...P,"cmdk-root":"",onKeyDown:m=>{var L;if((L=P.onKeyDown)==null||L.call(P,m),!m.defaultPrevented)switch(m.key){case"n":case"j":{R&&m.ctrlKey&&re(m);break}case"ArrowDown":{re(m);break}case"p":case"k":{R&&m.ctrlKey&&M(m);break}case"ArrowUp":{M(m);break}case"Home":{m.preventDefault(),O(0);break}case"End":{m.preventDefault(),W();break}case"Enter":if(!m.nativeEvent.isComposing&&m.keyCode!==229){m.preventDefault();let U=F();if(U){let q=new Event(yn);U.dispatchEvent(q)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:_.inputId,id:_.labelId,style:nh},s),dr(t,m=>p.createElement(Rs.Provider,{value:v},p.createElement(Ts.Provider,{value:_},m))))}),Uf=p.forwardRef((t,e)=>{var r,n;let a=ft(),o=p.useRef(null),l=p.useContext(As),i=jt(),s=js(t),c=(n=(r=s.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;pt(()=>{if(!c)return i.item(a,l==null?void 0:l.id)},[c]);let u=Ns(a,o,[t.value,t.children,o],t.keywords),d=Dn(),h=mt(D=>D.value&&D.value===u.current),f=mt(D=>c||i.filter()===!1?!0:D.search?D.filtered.items.get(a)>0:!0);p.useEffect(()=>{let D=o.current;if(!(!D||t.disabled))return D.addEventListener(yn,y),()=>D.removeEventListener(yn,y)},[f,t.onSelect,t.disabled]);function y(){var D,v;b(),(v=(D=s.current).onSelect)==null||v.call(D,u.current)}function b(){d.setState("value",u.current,!0)}if(!f)return null;let{disabled:R,value:P,onSelect:S,forceMount:k,keywords:A,...j}=t;return p.createElement(Ee.div,{ref:At([o,e]),...j,id:a,"cmdk-item":"",role:"option","aria-disabled":!!R,"aria-selected":!!h,"data-disabled":!!R,"data-selected":!!h,onPointerMove:R||i.getDisablePointerSelection()?void 0:b,onClick:R?void 0:y},t.children)}),qf=p.forwardRef((t,e)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=ft(),i=p.useRef(null),s=p.useRef(null),c=ft(),u=jt(),d=mt(f=>a||u.filter()===!1?!0:f.search?f.filtered.groups.has(l):!0);pt(()=>u.group(l),[]),Ns(l,i,[t.value,t.heading,s]);let h=p.useMemo(()=>({id:l,forceMount:a}),[a]);return p.createElement(Ee.div,{ref:At([i,e]),...o,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},r&&p.createElement("div",{ref:s,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),dr(t,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},p.createElement(As.Provider,{value:h},f))))}),Wf=p.forwardRef((t,e)=>{let{alwaysRender:r,...n}=t,a=p.useRef(null),o=mt(l=>!l.search);return!r&&!o?null:p.createElement(Ee.div,{ref:At([a,e]),...n,"cmdk-separator":"",role:"separator"})}),Xf=p.forwardRef((t,e)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=Dn(),l=mt(u=>u.search),i=mt(u=>u.value),s=jt(),c=p.useMemo(()=>{var u;let d=(u=s.listInnerRef.current)==null?void 0:u.querySelector(`${Pn}[${dt}="${encodeURIComponent(i)}"]`);return d==null?void 0:d.getAttribute("id")},[]);return p.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),p.createElement(Ee.input,{ref:e,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":s.listId,"aria-labelledby":s.labelId,"aria-activedescendant":c,id:s.inputId,type:"text",value:a?t.value:l,onChange:u=>{a||o.setState("search",u.target.value),r==null||r(u.target.value)}})}),Yf=p.forwardRef((t,e)=>{let{children:r,label:n="Suggestions",...a}=t,o=p.useRef(null),l=p.useRef(null),i=jt();return p.useEffect(()=>{if(l.current&&o.current){let s=l.current,c=o.current,u,d=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let h=s.offsetHeight;c.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return d.observe(s),()=>{cancelAnimationFrame(u),d.unobserve(s)}}},[]),p.createElement(Ee.div,{ref:At([o,e]),...a,"cmdk-list":"",role:"listbox","aria-label":n,id:i.listId},dr(t,s=>p.createElement("div",{ref:At([l,i.listInnerRef]),"cmdk-list-sizer":""},s)))}),Kf=p.forwardRef((t,e)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return p.createElement(Ea,{open:r,onOpenChange:n},p.createElement(xa,{container:l},p.createElement(Cn,{"cmdk-overlay":"",className:a}),p.createElement(kn,{"aria-label":t.label,"cmdk-dialog":"",className:o},p.createElement(Is,{ref:e,...i}))))}),Qf=p.forwardRef((t,e)=>mt(r=>r.filtered.count===0)?p.createElement(Ee.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),Jf=p.forwardRef((t,e)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return p.createElement(Ee.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},dr(t,l=>p.createElement("div",{"aria-hidden":!0},l)))}),Ie=Object.assign(Is,{List:Yf,Item:Uf,Input:Xf,Group:qf,Separator:Wf,Dialog:Kf,Empty:Qf,Loading:Jf});function Zf(t,e){let r=t.nextElementSibling;for(;r;){if(r.matches(e))return r;r=r.nextElementSibling}}function eh(t,e){let r=t.previousElementSibling;for(;r;){if(r.matches(e))return r;r=r.previousElementSibling}}function js(t){let e=p.useRef(t);return pt(()=>{e.current=t}),e}var pt=typeof window>"u"?p.useEffect:p.useLayoutEffect;function bt(t){let e=p.useRef();return e.current===void 0&&(e.current=t()),e}function At(t){return e=>{t.forEach(r=>{typeof r=="function"?r(e):r!=null&&(r.current=e)})}}function mt(t){let e=Dn(),r=()=>t(e.snapshot());return Hf.useSyncExternalStore(e.subscribe,r,r)}function Ns(t,e,r,n=[]){let a=p.useRef(),o=jt();return pt(()=>{var l;let i=(()=>{var c;for(let u of r){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(c=u.current.textContent)==null?void 0:c.trim():a.current}})(),s=n.map(c=>c.trim());o.value(t,i,s),(l=e.current)==null||l.setAttribute(dt,i),a.current=i}),a}var th=()=>{let[t,e]=p.useState(),r=bt(()=>new Map);return pt(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),e({})}};function rh(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function dr({asChild:t,children:e},r){return t&&p.isValidElement(e)?p.cloneElement(rh(e),{ref:e.ref},r(e.props.children)):r(e)}var nh={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const fr=p.forwardRef(({className:t,...e},r)=>g.jsx(Ie,{ref:r,className:fe("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...e}));fr.displayName=Ie.displayName;const On=p.forwardRef(({className:t,...e},r)=>g.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[g.jsx(Au,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),g.jsx(Ie.Input,{ref:r,className:fe("placeholder:text-muted-foreground flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));On.displayName=Ie.Input.displayName;const hr=p.forwardRef(({className:t,...e},r)=>g.jsx(Ie.List,{ref:r,className:fe("max-h-[300px] overflow-x-hidden overflow-y-auto",t),...e}));hr.displayName=Ie.List.displayName;const Gn=p.forwardRef((t,e)=>g.jsx(Ie.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));Gn.displayName=Ie.Empty.displayName;const Ct=p.forwardRef(({className:t,...e},r)=>g.jsx(Ie.Group,{ref:r,className:fe("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...e}));Ct.displayName=Ie.Group.displayName;const oh=p.forwardRef(({className:t,...e},r)=>g.jsx(Ie.Separator,{ref:r,className:fe("bg-border -mx-1 h-px",t),...e}));oh.displayName=Ie.Separator.displayName;const kt=p.forwardRef(({className:t,...e},r)=>g.jsx(Ie.Item,{ref:r,className:fe("data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t),...e}));kt.displayName=Ie.Item.displayName;const ah=({layout:t,autoRunFor:e,mainLayout:r})=>{const n=We(),[a,o]=p.useState(!1),l=p.useRef(null),{t:i}=Se(),s=p.useCallback(()=>{if(n)try{const u=n.getGraph();if(!u||u.order===0)return;const d=r.positions();va(u,d,{duration:300})}catch(u){console.error("Error updating positions:",u),l.current&&(window.clearInterval(l.current),l.current=null,o(!1))}},[n,r]),c=p.useCallback(()=>{if(a){console.log("Stopping layout animation"),l.current&&(window.clearInterval(l.current),l.current=null);try{typeof t.kill=="function"?(t.kill(),console.log("Layout algorithm killed")):typeof t.stop=="function"&&(t.stop(),console.log("Layout algorithm stopped"))}catch(u){console.error("Error stopping layout algorithm:",u)}o(!1)}else console.log("Starting layout animation"),s(),l.current=window.setInterval(()=>{s()},200),o(!0),setTimeout(()=>{if(l.current){console.log("Auto-stopping layout animation after 3 seconds"),window.clearInterval(l.current),l.current=null,o(!1);try{typeof t.kill=="function"?t.kill():typeof t.stop=="function"&&t.stop()}catch(u){console.error("Error stopping layout algorithm:",u)}}},3e3)},[a,t,s]);return p.useEffect(()=>{if(!n){console.log("No sigma instance available");return}let u=null;return e!==void 0&&e>-1&&n.getGraph().order>0&&(console.log("Auto-starting layout animation"),s(),l.current=window.setInterval(()=>{s()},200),o(!0),e>0&&(u=window.setTimeout(()=>{console.log("Auto-stopping layout animation after timeout"),l.current&&(window.clearInterval(l.current),l.current=null),o(!1)},e))),()=>{l.current&&(window.clearInterval(l.current),l.current=null),u&&window.clearTimeout(u),o(!1)}},[e,n,s]),g.jsx(be,{size:"icon",onClick:c,tooltip:i(a?"graphPanel.sideBar.layoutsControl.stopAnimation":"graphPanel.sideBar.layoutsControl.startAnimation"),variant:ze,children:a?g.jsx(pu,{}):g.jsx(bu,{})})},sh=()=>{const t=We(),{t:e}=Se(),[r,n]=p.useState("Circular"),[a,o]=p.useState(!1),l=te.use.graphLayoutMaxIterations(),i=Jd(),s=Xd(),c=If(),u=Cf({maxIterations:l,settings:{margin:5,expansion:1.1,gridSize:1,ratio:1,speed:3}}),d=af({maxIterations:l,settings:{attraction:3e-4,repulsion:.02,gravity:.02,inertia:.4,maxMove:100}}),h=_s({iterations:l}),f=kf(),y=sf(),b=mf(),R=p.useMemo(()=>({Circular:{layout:i},Circlepack:{layout:s},Random:{layout:c},Noverlaps:{layout:u,worker:f},"Force Directed":{layout:d,worker:y},"Force Atlas":{layout:h,worker:b}}),[s,i,d,h,u,c,y,f,b]),P=p.useCallback(S=>{console.debug("Running layout:",S);const{positions:k}=R[S].layout;try{const A=t.getGraph();if(!A){console.error("No graph available");return}const j=k();console.log("Positions calculated, animating nodes"),va(A,j,{duration:400}),n(S)}catch(A){console.error("Error running layout:",A)}},[R,t]);return g.jsxs("div",{children:[g.jsx("div",{children:R[r]&&"worker"in R[r]&&g.jsx(ah,{layout:R[r].worker,mainLayout:R[r].layout})}),g.jsx("div",{children:g.jsxs(jn,{open:a,onOpenChange:o,children:[g.jsx(Nn,{asChild:!0,children:g.jsx(be,{size:"icon",variant:ze,onClick:()=>o(S=>!S),tooltip:e("graphPanel.sideBar.layoutsControl.layoutGraph"),children:g.jsx(ou,{})})}),g.jsx(cr,{side:"right",align:"start",sideOffset:8,collisionPadding:5,sticky:"always",className:"p-1 min-w-auto",children:g.jsx(fr,{children:g.jsx(hr,{children:g.jsx(Ct,{children:Object.keys(R).map(S=>g.jsx(kt,{onSelect:()=>{P(S)},className:"cursor-pointer text-xs",children:e(`graphPanel.sideBar.layoutsControl.layouts.${S}`)},S))})})})})]})})]})},ih=()=>{const t=p.useContext(La);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t},Ot=t=>!!(t.type.startsWith("mouse")&&t.buttons!==0),lh=({disableHoverEffect:t})=>{const e=We(),r=ya(),n=Ei(),a=te.use.graphLayoutMaxIterations(),{assign:o}=_s({iterations:a}),{theme:l}=ih(),i=te.use.enableHideUnselectedEdges(),s=te.use.enableEdgeEvents(),c=te.use.showEdgeLabel(),u=te.use.showNodeLabel(),d=te.use.minEdgeSize(),h=te.use.maxEdgeSize(),f=Z.use.selectedNode(),y=Z.use.focusedNode(),b=Z.use.selectedEdge(),R=Z.use.focusedEdge(),P=Z.use.sigmaGraph();return p.useEffect(()=>{if(P&&e){try{typeof e.setGraph=="function"?(e.setGraph(P),console.log("Binding graph to sigma instance")):(e.graph=P,console.warn("Simgma missing setGraph function, set graph property directly"))}catch(S){console.error("Error setting graph on sigma instance:",S)}o(),console.log("Initial layout applied to graph")}},[e,P,o,a]),p.useEffect(()=>{e&&(Z.getState().sigmaInstance||(console.log("Setting sigma instance from GraphControl"),Z.getState().setSigmaInstance(e)))},[e]),p.useEffect(()=>{const{setFocusedNode:S,setSelectedNode:k,setFocusedEdge:A,setSelectedEdge:j,clearSelection:D}=Z.getState(),v={enterNode:_=>{Ot(_.event.original)||e.getGraph().hasNode(_.node)&&S(_.node)},leaveNode:_=>{Ot(_.event.original)||S(null)},clickNode:_=>{e.getGraph().hasNode(_.node)&&(k(_.node),j(null))},clickStage:()=>D()};return s&&(v.clickEdge=_=>{j(_.edge),k(null)},v.enterEdge=_=>{Ot(_.event.original)||A(_.edge)},v.leaveEdge=_=>{Ot(_.event.original)||A(null)}),r(v),()=>{try{console.log("Cleaning up graph event listeners")}catch(_){console.warn("Error cleaning up graph event listeners:",_)}}},[r,s,e]),p.useEffect(()=>{if(e&&P){const S=e.getGraph();let k=Number.MAX_SAFE_INTEGER,A=0;S.forEachEdge(D=>{const v=S.getEdgeAttribute(D,"originalWeight")||1;typeof v=="number"&&(k=Math.min(k,v),A=Math.max(A,v))});const j=A-k;if(j>0){const D=h-d;S.forEachEdge(v=>{const _=S.getEdgeAttribute(v,"originalWeight")||1;if(typeof _=="number"){const x=d+D*Math.pow((_-k)/j,.5);S.setEdgeAttribute(v,"size",x)}})}else S.forEachEdge(D=>{S.setEdgeAttribute(D,"size",d)});e.refresh()}},[e,P,d,h]),p.useEffect(()=>{const S=l==="dark",k=S?en:void 0,A=S?Ji:void 0;n({enableEdgeEvents:s,renderEdgeLabels:c,renderLabels:u,nodeReducer:(j,D)=>{const v=e.getGraph();if(!v.hasNode(j))return console.warn(`Node ${j} not found in graph during theme switch, returning default data`),{...D,highlighted:!1,labelColor:k};const _={...D,highlighted:D.highlighted||!1,labelColor:k};if(!t){_.highlighted=!1;const x=y||f,T=R||b;if(x&&v.hasNode(x))try{(j===x||v.neighbors(x).includes(j))&&(_.highlighted=!0,j===f&&(_.borderColor=Qi))}catch(I){return console.error("Error in nodeReducer:",I),{...D,highlighted:!1,labelColor:k}}else if(T&&v.hasEdge(T))try{v.extremities(T).includes(j)&&(_.highlighted=!0,_.size=3)}catch(I){return console.error("Error accessing edge extremities in nodeReducer:",I),{...D,highlighted:!1,labelColor:k}}else return _;_.highlighted?S&&(_.labelColor=Yi):_.color=Ki}return _},edgeReducer:(j,D)=>{const v=e.getGraph();if(!v.hasEdge(j))return console.warn(`Edge ${j} not found in graph during theme switch, returning default data`),{...D,hidden:!1,labelColor:k,color:A};const _={...D,hidden:!1,labelColor:k,color:A};if(!t){const x=y||f;if(x&&v.hasNode(x))try{i?v.extremities(j).includes(x)||(_.hidden=!0):v.extremities(j).includes(x)&&(_.color=Qn)}catch(T){return console.error("Error in edgeReducer:",T),{...D,hidden:!1,labelColor:k,color:A}}else{const T=b&&v.hasEdge(b)?b:null,I=R&&v.hasEdge(R)?R:null;(T||I)&&(j===T?_.color=Zi:j===I?_.color=Qn:i&&(_.hidden=!0))}}return _}})},[f,y,b,R,n,e,t,l,i,s,c,u]),null},ch=()=>{const{zoomIn:t,zoomOut:e,reset:r}=pa({duration:200,factor:1.5}),n=We(),{t:a}=Se(),o=p.useCallback(()=>t(),[t]),l=p.useCallback(()=>e(),[e]),i=p.useCallback(()=>{if(n)try{n.setCustomBBox(null),n.refresh();const u=n.getGraph();if(!(u!=null&&u.order)||u.nodes().length===0){r();return}n.getCamera().animate({x:.5,y:.5,ratio:1.1},{duration:1e3})}catch(u){console.error("Error resetting zoom:",u),r()}},[n,r]),s=p.useCallback(()=>{if(!n)return;const u=n.getCamera(),h=u.angle+Math.PI/8;u.animate({angle:h},{duration:200})},[n]),c=p.useCallback(()=>{if(!n)return;const u=n.getCamera(),h=u.angle-Math.PI/8;u.animate({angle:h},{duration:200})},[n]);return g.jsxs(g.Fragment,{children:[g.jsx(be,{variant:ze,onClick:s,tooltip:a("graphPanel.sideBar.zoomControl.rotateCamera"),size:"icon",children:g.jsx(Cu,{})}),g.jsx(be,{variant:ze,onClick:c,tooltip:a("graphPanel.sideBar.zoomControl.rotateCameraCounterClockwise"),size:"icon",children:g.jsx(_u,{})}),g.jsx(be,{variant:ze,onClick:i,tooltip:a("graphPanel.sideBar.zoomControl.resetZoom"),size:"icon",children:g.jsx(Zc,{})}),g.jsx(be,{variant:ze,onClick:o,tooltip:a("graphPanel.sideBar.zoomControl.zoomIn"),size:"icon",children:g.jsx(Hu,{})}),g.jsx(be,{variant:ze,onClick:l,tooltip:a("graphPanel.sideBar.zoomControl.zoomOut"),size:"icon",children:g.jsx(Vu,{})})]})},uh=()=>{const{isFullScreen:t,toggle:e}=Ci(),{t:r}=Se();return g.jsx(g.Fragment,{children:t?g.jsx(be,{variant:ze,onClick:e,tooltip:r("graphPanel.sideBar.fullScreenControl.windowed"),size:"icon",children:g.jsx(fu,{})}):g.jsx(be,{variant:ze,onClick:e,tooltip:r("graphPanel.sideBar.fullScreenControl.fullScreen"),size:"icon",children:g.jsx(uu,{})})})};var Mn="Checkbox",[dh,Xp]=En(Mn),[fh,hh]=dh(Mn),Ls=p.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:s="on",onCheckedChange:c,form:u,...d}=t,[h,f]=p.useState(null),y=Ye(e,A=>f(A)),b=p.useRef(!1),R=h?u||!!h.closest("form"):!0,[P=!1,S]=wa({prop:a,defaultProp:o,onChange:c}),k=p.useRef(P);return p.useEffect(()=>{const A=h==null?void 0:h.form;if(A){const j=()=>S(k.current);return A.addEventListener("reset",j),()=>A.removeEventListener("reset",j)}},[h,S]),g.jsxs(fh,{scope:r,state:P,disabled:i,children:[g.jsx(Ee.button,{type:"button",role:"checkbox","aria-checked":at(P)?"mixed":P,"aria-required":l,"data-state":Ds(P),"data-disabled":i?"":void 0,disabled:i,value:s,...d,ref:y,onKeyDown:Ce(t.onKeyDown,A=>{A.key==="Enter"&&A.preventDefault()}),onClick:Ce(t.onClick,A=>{S(j=>at(j)?!0:!j),R&&(b.current=A.isPropagationStopped(),b.current||A.stopPropagation())})}),R&&g.jsx(gh,{control:h,bubbles:!b.current,name:n,value:s,checked:P,required:l,disabled:i,form:u,style:{transform:"translateX(-100%)"},defaultChecked:at(o)?!1:o})]})});Ls.displayName=Mn;var zs="CheckboxIndicator",Ps=p.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=hh(zs,r);return g.jsx(_t,{present:n||at(o.state)||o.state===!0,children:g.jsx(Ee.span,{"data-state":Ds(o.state),"data-disabled":o.disabled?"":void 0,...a,ref:e,style:{pointerEvents:"none",...t.style}})})});Ps.displayName=zs;var gh=t=>{const{control:e,checked:r,bubbles:n=!0,defaultChecked:a,...o}=t,l=p.useRef(null),i=Hi(r),s=Bi(e);p.useEffect(()=>{const u=l.current,d=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(d,"checked").set;if(i!==r&&f){const y=new Event("click",{bubbles:n});u.indeterminate=at(r),f.call(u,at(r)?!1:r),u.dispatchEvent(y)}},[i,r,n]);const c=p.useRef(at(r)?!1:r);return g.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a??c.current,...o,tabIndex:-1,ref:l,style:{...t.style,...s,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function at(t){return t==="indeterminate"}function Ds(t){return at(t)?"indeterminate":t?"checked":"unchecked"}var Os=Ls,ph=Ps;const Gs=p.forwardRef(({className:t,...e},r)=>g.jsx(Os,{ref:r,className:fe("peer border-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-muted data-[state=checked]:text-muted-foreground h-4 w-4 shrink-0 rounded-sm border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:g.jsx(ph,{className:fe("flex items-center justify-center text-current"),children:g.jsx(Ya,{className:"h-4 w-4"})})}));Gs.displayName=Os.displayName;var mh="Separator",qo="horizontal",vh=["horizontal","vertical"],Ms=p.forwardRef((t,e)=>{const{decorative:r,orientation:n=qo,...a}=t,o=yh(n)?n:qo,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return g.jsx(Ee.div,{"data-orientation":o,...i,...a,ref:e})});Ms.displayName=mh;function yh(t){return vh.includes(t)}var $s=Ms;const wt=p.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},a)=>g.jsx($s,{ref:a,decorative:r,orientation:e,className:fe("bg-border shrink-0",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));wt.displayName=$s.displayName;const rt=({checked:t,onCheckedChange:e,label:r})=>{const n=`checkbox-${r.toLowerCase().replace(/\s+/g,"-")}`;return g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Gs,{id:n,checked:t,onCheckedChange:e}),g.jsx("label",{htmlFor:n,className:"text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:r})]})},Vr=({value:t,onEditFinished:e,label:r,min:n,max:a,defaultValue:o})=>{const{t:l}=Se(),[i,s]=p.useState(t),c=`input-${r.toLowerCase().replace(/\s+/g,"-")}`;p.useEffect(()=>{s(t)},[t]);const u=p.useCallback(f=>{const y=f.target.value.trim();if(y.length===0){s(null);return}const b=Number.parseInt(y);if(!isNaN(b)&&b!==i){if(n!==void 0&&b<n||a!==void 0&&b>a)return;s(b)}},[i,n,a]),d=p.useCallback(()=>{i!==null&&t!==i&&e(i)},[t,i,e]),h=p.useCallback(()=>{o!==void 0&&t!==o&&(s(o),e(o))},[o,t,e]);return g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx("label",{htmlFor:c,className:"text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:r}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx(Yt,{id:c,type:"number",value:i===null?"":i,onChange:u,className:"h-6 w-full min-w-0 pr-1",min:n,max:a,onBlur:d,onKeyDown:f=>{f.key==="Enter"&&d()}}),o!==void 0&&g.jsx(be,{variant:"ghost",size:"icon",className:"h-6 w-6 flex-shrink-0 hover:bg-muted text-muted-foreground hover:text-foreground",onClick:h,type:"button",title:l("graphPanel.sideBar.settings.resetToDefault"),children:g.jsx(Qa,{className:"h-3.5 w-3.5"})})]})]})};function bh(){const[t,e]=p.useState(!1),r=te.use.showPropertyPanel(),n=te.use.showNodeSearchBar(),a=te.use.showNodeLabel(),o=te.use.enableEdgeEvents(),l=te.use.enableNodeDrag(),i=te.use.enableHideUnselectedEdges(),s=te.use.showEdgeLabel(),c=te.use.minEdgeSize(),u=te.use.maxEdgeSize(),d=te.use.graphQueryMaxDepth(),h=te.use.graphMaxNodes(),f=te.use.backendMaxGraphNodes(),y=te.use.graphLayoutMaxIterations(),b=te.use.enableHealthCheck(),R=p.useCallback(()=>te.setState(w=>({enableNodeDrag:!w.enableNodeDrag})),[]),P=p.useCallback(()=>te.setState(w=>({enableEdgeEvents:!w.enableEdgeEvents})),[]),S=p.useCallback(()=>te.setState(w=>({enableHideUnselectedEdges:!w.enableHideUnselectedEdges})),[]),k=p.useCallback(()=>te.setState(w=>({showEdgeLabel:!w.showEdgeLabel})),[]),A=p.useCallback(()=>te.setState(w=>({showPropertyPanel:!w.showPropertyPanel})),[]),j=p.useCallback(()=>te.setState(w=>({showNodeSearchBar:!w.showNodeSearchBar})),[]),D=p.useCallback(()=>te.setState(w=>({showNodeLabel:!w.showNodeLabel})),[]),v=p.useCallback(()=>te.setState(w=>({enableHealthCheck:!w.enableHealthCheck})),[]),_=p.useCallback(w=>{if(w<1)return;te.setState({graphQueryMaxDepth:w});const F=te.getState().queryLabel;te.getState().setQueryLabel(""),setTimeout(()=>{te.getState().setQueryLabel(F)},300)},[]),x=p.useCallback(w=>{const F=f||1e3;w<1||w>F||te.getState().setGraphMaxNodes(w,!0)},[f]),T=p.useCallback(w=>{w<1||te.setState({graphLayoutMaxIterations:w})},[]),{t:I}=Se(),z=()=>e(!1);return g.jsx(g.Fragment,{children:g.jsxs(jn,{open:t,onOpenChange:e,children:[g.jsx(Nn,{asChild:!0,children:g.jsx(be,{variant:ze,tooltip:I("graphPanel.sideBar.settings.settings"),size:"icon",children:g.jsx(Nu,{})})}),g.jsx(cr,{side:"right",align:"end",sideOffset:8,collisionPadding:5,className:"p-2 max-w-[200px]",onCloseAutoFocus:w=>w.preventDefault(),children:g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx(rt,{checked:b,onCheckedChange:v,label:I("graphPanel.sideBar.settings.healthCheck")}),g.jsx(wt,{}),g.jsx(rt,{checked:r,onCheckedChange:A,label:I("graphPanel.sideBar.settings.showPropertyPanel")}),g.jsx(rt,{checked:n,onCheckedChange:j,label:I("graphPanel.sideBar.settings.showSearchBar")}),g.jsx(wt,{}),g.jsx(rt,{checked:a,onCheckedChange:D,label:I("graphPanel.sideBar.settings.showNodeLabel")}),g.jsx(rt,{checked:l,onCheckedChange:R,label:I("graphPanel.sideBar.settings.nodeDraggable")}),g.jsx(wt,{}),g.jsx(rt,{checked:s,onCheckedChange:k,label:I("graphPanel.sideBar.settings.showEdgeLabel")}),g.jsx(rt,{checked:i,onCheckedChange:S,label:I("graphPanel.sideBar.settings.hideUnselectedEdges")}),g.jsx(rt,{checked:o,onCheckedChange:P,label:I("graphPanel.sideBar.settings.edgeEvents")}),g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx("label",{htmlFor:"edge-size-min",className:"text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:I("graphPanel.sideBar.settings.edgeSizeRange")}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Yt,{id:"edge-size-min",type:"number",value:c,onChange:w=>{const F=Number(w.target.value);!isNaN(F)&&F>=1&&F<=u&&te.setState({minEdgeSize:F})},className:"h-6 w-16 min-w-0 pr-1",min:1,max:Math.min(u,10)}),g.jsx("span",{children:"-"}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx(Yt,{id:"edge-size-max",type:"number",value:u,onChange:w=>{const F=Number(w.target.value);!isNaN(F)&&F>=c&&F>=1&&F<=10&&te.setState({maxEdgeSize:F})},className:"h-6 w-16 min-w-0 pr-1",min:c,max:10}),g.jsx(be,{variant:"ghost",size:"icon",className:"h-6 w-6 flex-shrink-0 hover:bg-muted text-muted-foreground hover:text-foreground",onClick:()=>te.setState({minEdgeSize:1,maxEdgeSize:5}),type:"button",title:I("graphPanel.sideBar.settings.resetToDefault"),children:g.jsx(Qa,{className:"h-3.5 w-3.5"})})]})]})]}),g.jsx(wt,{}),g.jsx(Vr,{label:I("graphPanel.sideBar.settings.maxQueryDepth"),min:1,value:d,defaultValue:3,onEditFinished:_}),g.jsx(Vr,{label:`${I("graphPanel.sideBar.settings.maxNodes")} (≤ ${f||1e3})`,min:1,max:f||1e3,value:h,defaultValue:f||1e3,onEditFinished:x}),g.jsx(Vr,{label:I("graphPanel.sideBar.settings.maxLayoutIterations"),min:1,max:30,value:y,defaultValue:15,onEditFinished:T}),g.jsx(wt,{}),g.jsx(be,{onClick:z,variant:"outline",size:"sm",className:"ml-auto px-4",children:I("graphPanel.sideBar.settings.save")})]})})]})})}const wh="ENTRIES",Fs="KEYS",Hs="VALUES",_e="";class Ur{constructor(e,r){const n=e._tree,a=Array.from(n.keys());this.set=e,this._type=r,this._path=a.length>0?[{node:n,keys:a}]:[]}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};const{node:e,keys:r}=vt(this._path);if(vt(r)===_e)return{done:!1,value:this.result()};const n=e.get(vt(r));return this._path.push({node:n,keys:Array.from(n.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=vt(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>vt(e)).filter(e=>e!==_e).join("")}value(){return vt(this._path).node.get(_e)}result(){switch(this._type){case Hs:return this.value();case Fs:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}}const vt=t=>t[t.length-1],xh=(t,e,r)=>{const n=new Map;if(e===void 0)return n;const a=e.length+1,o=a+r,l=new Uint8Array(o*a).fill(r+1);for(let i=0;i<a;++i)l[i]=i;for(let i=1;i<o;++i)l[i*a]=i;return Bs(t,e,r,n,l,1,a,""),n},Bs=(t,e,r,n,a,o,l,i)=>{const s=o*l;e:for(const c of t.keys())if(c===_e){const u=a[s-1];u<=r&&n.set(i,[t.get(c),u])}else{let u=o;for(let d=0;d<c.length;++d,++u){const h=c[d],f=l*u,y=f-l;let b=a[f];const R=Math.max(0,u-r-1),P=Math.min(l-1,u+r);for(let S=R;S<P;++S){const k=h!==e[S],A=a[y+S]+ +k,j=a[y+S+1]+1,D=a[f+S]+1,v=a[f+S+1]=Math.min(A,j,D);v<b&&(b=v)}if(b>r)continue e}Bs(t.get(c),e,r,n,a,u,l,i+c)}};class ot{constructor(e=new Map,r=""){this._size=void 0,this._tree=e,this._prefix=r}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[r,n]=Zt(this._tree,e.slice(this._prefix.length));if(r===void 0){const[a,o]=$n(n);for(const l of a.keys())if(l!==_e&&l.startsWith(o)){const i=new Map;return i.set(l.slice(o.length),a.get(l)),new ot(i,e)}}return new ot(r,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,Sh(this._tree,e)}entries(){return new Ur(this,wh)}forEach(e){for(const[r,n]of this)e(r,n,this)}fuzzyGet(e,r){return xh(this._tree,e,r)}get(e){const r=bn(this._tree,e);return r!==void 0?r.get(_e):void 0}has(e){const r=bn(this._tree,e);return r!==void 0&&r.has(_e)}keys(){return new Ur(this,Fs)}set(e,r){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,qr(this._tree,e).set(_e,r),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=qr(this._tree,e);return n.set(_e,r(n.get(_e))),this}fetch(e,r){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const n=qr(this._tree,e);let a=n.get(_e);return a===void 0&&n.set(_e,a=r()),a}values(){return new Ur(this,Hs)}[Symbol.iterator](){return this.entries()}static from(e){const r=new ot;for(const[n,a]of e)r.set(n,a);return r}static fromObject(e){return ot.from(Object.entries(e))}}const Zt=(t,e,r=[])=>{if(e.length===0||t==null)return[t,r];for(const n of t.keys())if(n!==_e&&e.startsWith(n))return r.push([t,n]),Zt(t.get(n),e.slice(n.length),r);return r.push([t,e]),Zt(void 0,"",r)},bn=(t,e)=>{if(e.length===0||t==null)return t;for(const r of t.keys())if(r!==_e&&e.startsWith(r))return bn(t.get(r),e.slice(r.length))},qr=(t,e)=>{const r=e.length;e:for(let n=0;t&&n<r;){for(const o of t.keys())if(o!==_e&&e[n]===o[0]){const l=Math.min(r-n,o.length);let i=1;for(;i<l&&e[n+i]===o[i];)++i;const s=t.get(o);if(i===o.length)t=s;else{const c=new Map;c.set(o.slice(i),s),t.set(e.slice(n,n+i),c),t.delete(o),t=c}n+=i;continue e}const a=new Map;return t.set(e.slice(n),a),a}return t},Sh=(t,e)=>{const[r,n]=Zt(t,e);if(r!==void 0){if(r.delete(_e),r.size===0)Vs(n);else if(r.size===1){const[a,o]=r.entries().next().value;Us(n,a,o)}}},Vs=t=>{if(t.length===0)return;const[e,r]=$n(t);if(e.delete(r),e.size===0)Vs(t.slice(0,-1));else if(e.size===1){const[n,a]=e.entries().next().value;n!==_e&&Us(t.slice(0,-1),n,a)}},Us=(t,e,r)=>{if(t.length===0)return;const[n,a]=$n(t);n.set(a+e,r),n.delete(a)},$n=t=>t[t.length-1],Fn="or",qs="and",_h="and_not";class gt{constructor(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');const r=e.autoVacuum==null||e.autoVacuum===!0?Yr:e.autoVacuum;this._options={...Xr,...e,autoVacuum:r,searchOptions:{...Wo,...e.searchOptions||{}},autoSuggestOptions:{...Rh,...e.autoSuggestOptions||{}}},this._index=new ot,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=xn,this.addFields(this._options.fields)}add(e){const{extractField:r,tokenize:n,processTerm:a,fields:o,idField:l}=this._options,i=r(e,l);if(i==null)throw new Error(`MiniSearch: document does not have ID field "${l}"`);if(this._idToShortId.has(i))throw new Error(`MiniSearch: duplicate ID ${i}`);const s=this.addDocumentId(i);this.saveStoredFields(s,e);for(const c of o){const u=r(e,c);if(u==null)continue;const d=n(u.toString(),c),h=this._fieldIds[c],f=new Set(d).size;this.addFieldLength(s,h,this._documentCount-1,f);for(const y of d){const b=a(y,c);if(Array.isArray(b))for(const R of b)this.addTerm(h,s,R);else b&&this.addTerm(h,s,b)}}}addAll(e){for(const r of e)this.add(r)}addAllAsync(e,r={}){const{chunkSize:n=10}=r,a={chunk:[],promise:Promise.resolve()},{chunk:o,promise:l}=e.reduce(({chunk:i,promise:s},c,u)=>(i.push(c),(u+1)%n===0?{chunk:[],promise:s.then(()=>new Promise(d=>setTimeout(d,0))).then(()=>this.addAll(i))}:{chunk:i,promise:s}),a);return l.then(()=>this.addAll(o))}remove(e){const{tokenize:r,processTerm:n,extractField:a,fields:o,idField:l}=this._options,i=a(e,l);if(i==null)throw new Error(`MiniSearch: document does not have ID field "${l}"`);const s=this._idToShortId.get(i);if(s==null)throw new Error(`MiniSearch: cannot remove document with ID ${i}: it is not in the index`);for(const c of o){const u=a(e,c);if(u==null)continue;const d=r(u.toString(),c),h=this._fieldIds[c],f=new Set(d).size;this.removeFieldLength(s,h,this._documentCount,f);for(const y of d){const b=n(y,c);if(Array.isArray(b))for(const R of b)this.removeTerm(h,s,R);else b&&this.removeTerm(h,s,b)}}this._storedFields.delete(s),this._documentIds.delete(s),this._idToShortId.delete(i),this._fieldLength.delete(s),this._documentCount-=1}removeAll(e){if(e)for(const r of e)this.remove(r);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new ot,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){const r=this._idToShortId.get(e);if(r==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(r),this._storedFields.delete(r),(this._fieldLength.get(r)||[]).forEach((n,a)=>{this.removeFieldLength(r,a,this._documentCount,n)}),this._fieldLength.delete(r),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;const{minDirtFactor:e,minDirtCount:r,batchSize:n,batchWait:a}=this._options.autoVacuum;this.conditionalVacuum({batchSize:n,batchWait:a},{minDirtCount:r,minDirtFactor:e})}discardAll(e){const r=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(const n of e)this.discard(n)}finally{this._options.autoVacuum=r}this.maybeAutoVacuum()}replace(e){const{idField:r,extractField:n}=this._options,a=n(e,r);this.discard(a),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,r){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&r,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{const n=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=xn,this.performVacuuming(e,n)}),this._enqueuedVacuum)):this.vacuumConditionsMet(r)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}async performVacuuming(e,r){const n=this._dirtCount;if(this.vacuumConditionsMet(r)){const a=e.batchSize||wn.batchSize,o=e.batchWait||wn.batchWait;let l=1;for(const[i,s]of this._index){for(const[c,u]of s)for(const[d]of u)this._documentIds.has(d)||(u.size<=1?s.delete(c):u.delete(d));this._index.get(i).size===0&&this._index.delete(i),l%a===0&&await new Promise(c=>setTimeout(c,o)),l+=1}this._dirtCount-=n}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:r,minDirtFactor:n}=e;return r=r||Yr.minDirtCount,n=n||Yr.minDirtFactor,this.dirtCount>=r&&this.dirtFactor>=n}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){const r=this._idToShortId.get(e);if(r!=null)return this._storedFields.get(r)}search(e,r={}){const{searchOptions:n}=this._options,a={...n,...r},o=this.executeQuery(e,r),l=[];for(const[i,{score:s,terms:c,match:u}]of o){const d=c.length||1,h={id:this._documentIds.get(i),score:s*d,terms:Object.keys(u),queryTerms:c,match:u};Object.assign(h,this._storedFields.get(i)),(a.filter==null||a.filter(h))&&l.push(h)}return e===gt.wildcard&&a.boostDocument==null||l.sort(Yo),l}autoSuggest(e,r={}){r={...this._options.autoSuggestOptions,...r};const n=new Map;for(const{score:o,terms:l}of this.search(e,r)){const i=l.join(" "),s=n.get(i);s!=null?(s.score+=o,s.count+=1):n.set(i,{score:o,terms:l,count:1})}const a=[];for(const[o,{score:l,terms:i,count:s}]of n)a.push({suggestion:o,terms:i,score:l/s});return a.sort(Yo),a}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,r){if(r==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),r)}static async loadJSONAsync(e,r){if(r==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),r)}static getDefault(e){if(Xr.hasOwnProperty(e))return Wr(Xr,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,r){const{index:n,documentIds:a,fieldLength:o,storedFields:l,serializationVersion:i}=e,s=this.instantiateMiniSearch(e,r);s._documentIds=Gt(a),s._fieldLength=Gt(o),s._storedFields=Gt(l);for(const[c,u]of s._documentIds)s._idToShortId.set(u,c);for(const[c,u]of n){const d=new Map;for(const h of Object.keys(u)){let f=u[h];i===1&&(f=f.ds),d.set(parseInt(h,10),Gt(f))}s._index.set(c,d)}return s}static async loadJSAsync(e,r){const{index:n,documentIds:a,fieldLength:o,storedFields:l,serializationVersion:i}=e,s=this.instantiateMiniSearch(e,r);s._documentIds=await Mt(a),s._fieldLength=await Mt(o),s._storedFields=await Mt(l);for(const[u,d]of s._documentIds)s._idToShortId.set(d,u);let c=0;for(const[u,d]of n){const h=new Map;for(const f of Object.keys(d)){let y=d[f];i===1&&(y=y.ds),h.set(parseInt(f,10),await Mt(y))}++c%1e3===0&&await Ws(0),s._index.set(u,h)}return s}static instantiateMiniSearch(e,r){const{documentCount:n,nextId:a,fieldIds:o,averageFieldLength:l,dirtCount:i,serializationVersion:s}=e;if(s!==1&&s!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");const c=new gt(r);return c._documentCount=n,c._nextId=a,c._idToShortId=new Map,c._fieldIds=o,c._avgFieldLength=l,c._dirtCount=i||0,c._index=new ot,c}executeQuery(e,r={}){if(e===gt.wildcard)return this.executeWildcardQuery(r);if(typeof e!="string"){const h={...r,...e,queries:void 0},f=e.queries.map(y=>this.executeQuery(y,h));return this.combineResults(f,h.combineWith)}const{tokenize:n,processTerm:a,searchOptions:o}=this._options,l={tokenize:n,processTerm:a,...o,...r},{tokenize:i,processTerm:s}=l,d=i(e).flatMap(h=>s(h)).filter(h=>!!h).map(Th(l)).map(h=>this.executeQuerySpec(h,l));return this.combineResults(d,l.combineWith)}executeQuerySpec(e,r){const n={...this._options.searchOptions,...r},a=(n.fields||this._options.fields).reduce((b,R)=>({...b,[R]:Wr(n.boost,R)||1}),{}),{boostDocument:o,weights:l,maxFuzzy:i,bm25:s}=n,{fuzzy:c,prefix:u}={...Wo.weights,...l},d=this._index.get(e.term),h=this.termResults(e.term,e.term,1,e.termBoost,d,a,o,s);let f,y;if(e.prefix&&(f=this._index.atPrefix(e.term)),e.fuzzy){const b=e.fuzzy===!0?.2:e.fuzzy,R=b<1?Math.min(i,Math.round(e.term.length*b)):b;R&&(y=this._index.fuzzyGet(e.term,R))}if(f)for(const[b,R]of f){const P=b.length-e.term.length;if(!P)continue;y==null||y.delete(b);const S=u*b.length/(b.length+.3*P);this.termResults(e.term,b,S,e.termBoost,R,a,o,s,h)}if(y)for(const b of y.keys()){const[R,P]=y.get(b);if(!P)continue;const S=c*b.length/(b.length+P);this.termResults(e.term,b,S,e.termBoost,R,a,o,s,h)}return h}executeWildcardQuery(e){const r=new Map,n={...this._options.searchOptions,...e};for(const[a,o]of this._documentIds){const l=n.boostDocument?n.boostDocument(o,"",this._storedFields.get(a)):1;r.set(a,{score:l,terms:[],match:{}})}return r}combineResults(e,r=Fn){if(e.length===0)return new Map;const n=r.toLowerCase(),a=Eh[n];if(!a)throw new Error(`Invalid combination operator: ${r}`);return e.reduce(a)||new Map}toJSON(){const e=[];for(const[r,n]of this._index){const a={};for(const[o,l]of n)a[o]=Object.fromEntries(l);e.push([r,a])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,serializationVersion:2}}termResults(e,r,n,a,o,l,i,s,c=new Map){if(o==null)return c;for(const u of Object.keys(l)){const d=l[u],h=this._fieldIds[u],f=o.get(h);if(f==null)continue;let y=f.size;const b=this._avgFieldLength[h];for(const R of f.keys()){if(!this._documentIds.has(R)){this.removeTerm(h,R,r),y-=1;continue}const P=i?i(this._documentIds.get(R),r,this._storedFields.get(R)):1;if(!P)continue;const S=f.get(R),k=this._fieldLength.get(R)[h],A=kh(S,y,this._documentCount,k,b,s),j=n*a*d*P*A,D=c.get(R);if(D){D.score+=j,Ah(D.terms,e);const v=Wr(D.match,r);v?v.push(u):D.match[r]=[u]}else c.set(R,{score:j,terms:[e],match:{[r]:[u]}})}}return c}addTerm(e,r,n){const a=this._index.fetch(n,Ko);let o=a.get(e);if(o==null)o=new Map,o.set(r,1),a.set(e,o);else{const l=o.get(r);o.set(r,(l||0)+1)}}removeTerm(e,r,n){if(!this._index.has(n)){this.warnDocumentChanged(r,e,n);return}const a=this._index.fetch(n,Ko),o=a.get(e);o==null||o.get(r)==null?this.warnDocumentChanged(r,e,n):o.get(r)<=1?o.size<=1?a.delete(e):o.delete(r):o.set(r,o.get(r)-1),this._index.get(n).size===0&&this._index.delete(n)}warnDocumentChanged(e,r,n){for(const a of Object.keys(this._fieldIds))if(this._fieldIds[a]===r){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${n}" was not present in field "${a}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){const r=this._nextId;return this._idToShortId.set(e,r),this._documentIds.set(r,e),this._documentCount+=1,this._nextId+=1,r}addFields(e){for(let r=0;r<e.length;r++)this._fieldIds[e[r]]=r}addFieldLength(e,r,n,a){let o=this._fieldLength.get(e);o==null&&this._fieldLength.set(e,o=[]),o[r]=a;const i=(this._avgFieldLength[r]||0)*n+a;this._avgFieldLength[r]=i/(n+1)}removeFieldLength(e,r,n,a){if(n===1){this._avgFieldLength[r]=0;return}const o=this._avgFieldLength[r]*n-a;this._avgFieldLength[r]=o/(n-1)}saveStoredFields(e,r){const{storeFields:n,extractField:a}=this._options;if(n==null||n.length===0)return;let o=this._storedFields.get(e);o==null&&this._storedFields.set(e,o={});for(const l of n){const i=a(r,l);i!==void 0&&(o[l]=i)}}}gt.wildcard=Symbol("*");const Wr=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0,Eh={[Fn]:(t,e)=>{for(const r of e.keys()){const n=t.get(r);if(n==null)t.set(r,e.get(r));else{const{score:a,terms:o,match:l}=e.get(r);n.score=n.score+a,n.match=Object.assign(n.match,l),Xo(n.terms,o)}}return t},[qs]:(t,e)=>{const r=new Map;for(const n of e.keys()){const a=t.get(n);if(a==null)continue;const{score:o,terms:l,match:i}=e.get(n);Xo(a.terms,l),r.set(n,{score:a.score+o,terms:a.terms,match:Object.assign(a.match,i)})}return r},[_h]:(t,e)=>{for(const r of e.keys())t.delete(r);return t}},Ch={k:1.2,b:.7,d:.5},kh=(t,e,r,n,a,o)=>{const{k:l,b:i,d:s}=o;return Math.log(1+(r-e+.5)/(e+.5))*(s+t*(l+1)/(t+l*(1-i+i*n/a)))},Th=t=>(e,r,n)=>{const a=typeof t.fuzzy=="function"?t.fuzzy(e,r,n):t.fuzzy||!1,o=typeof t.prefix=="function"?t.prefix(e,r,n):t.prefix===!0,l=typeof t.boostTerm=="function"?t.boostTerm(e,r,n):1;return{term:e,fuzzy:a,prefix:o,termBoost:l}},Xr={idField:"id",extractField:(t,e)=>t[e],tokenize:t=>t.split(Ih),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{typeof(console==null?void 0:console[t])=="function"&&console[t](e)},autoVacuum:!0},Wo={combineWith:Fn,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Ch},Rh={combineWith:qs,prefix:(t,e,r)=>e===r.length-1},wn={batchSize:1e3,batchWait:10},xn={minDirtFactor:.1,minDirtCount:20},Yr={...wn,...xn},Ah=(t,e)=>{t.includes(e)||t.push(e)},Xo=(t,e)=>{for(const r of e)t.includes(r)||t.push(r)},Yo=({score:t},{score:e})=>e-t,Ko=()=>new Map,Gt=t=>{const e=new Map;for(const r of Object.keys(t))e.set(parseInt(r,10),t[r]);return e},Mt=async t=>{const e=new Map;let r=0;for(const n of Object.keys(t))e.set(parseInt(n,10),t[n]),++r%1e3===0&&await Ws(0);return e},Ws=t=>new Promise(e=>setTimeout(e,t)),Ih=/[\n\r\p{Z}\p{P}]+/u,jh={index:new gt({fields:[]})};p.createContext(jh);const Qo=({label:t,color:e,hidden:r,labels:n={}})=>Y.createElement("div",{className:"node"},Y.createElement("span",{className:"render "+(r?"circle":"disc"),style:{backgroundColor:e||"#000"}}),Y.createElement("span",{className:`label ${r?"text-muted":""} ${t?"":"text-italic"}`},t||n.no_label||"No label")),Nh=({label:t,color:e,source:r,target:n,hidden:a,directed:o,labels:l={}})=>Y.createElement("div",{className:"edge"},Y.createElement(Qo,Object.assign({},r,{labels:l})),Y.createElement("div",{className:"body"},Y.createElement("div",{className:"render"},Y.createElement("span",{className:a?"dotted":"dash",style:{borderColor:e||"#000"}})," ",o&&Y.createElement("span",{className:"arrow",style:{borderTopColor:e||"#000"}})),Y.createElement("span",{className:`label ${a?"text-muted":""} ${t?"":"fst-italic"}`},t||l.no_label||"No label")),Y.createElement(Qo,Object.assign({},n,{labels:l}))),Lh=({id:t,labels:e})=>{const r=We(),n=p.useMemo(()=>{const a=r.getGraph().getEdgeAttributes(t),o=r.getSetting("nodeReducer"),l=r.getSetting("edgeReducer"),i=r.getGraph().getNodeAttributes(r.getGraph().source(t)),s=r.getGraph().getNodeAttributes(r.getGraph().target(t));return Object.assign(Object.assign(Object.assign({color:r.getSetting("defaultEdgeColor"),directed:r.getGraph().isDirected(t)},a),l?l(t,a):{}),{source:Object.assign(Object.assign({color:r.getSetting("defaultNodeColor")},i),o?o(t,i):{}),target:Object.assign(Object.assign({color:r.getSetting("defaultNodeColor")},s),o?o(t,s):{})})},[r,t]);return Y.createElement(Nh,Object.assign({},n,{labels:e}))};function Xs(t,e){const[r,n]=p.useState(t);return p.useEffect(()=>{const a=setTimeout(()=>{n(t)},e);return()=>{clearTimeout(a)}},[t,e]),r}function zh({fetcher:t,preload:e,filterFn:r,renderOption:n,getOptionValue:a,notFound:o,loadingSkeleton:l,label:i,placeholder:s="Select...",value:c,onChange:u,onFocus:d,disabled:h=!1,className:f,noResultsMessage:y}){const[b,R]=p.useState(!1),[P,S]=p.useState(!1),[k,A]=p.useState([]),[j,D]=p.useState(!1),[v,_]=p.useState(null),[x,T]=p.useState(""),I=Xs(x,e?0:150),z=p.useRef(null);p.useEffect(()=>{R(!0)},[]),p.useEffect(()=>{const C=E=>{z.current&&!z.current.contains(E.target)&&P&&S(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[P]);const w=p.useCallback(async C=>{try{D(!0),_(null);const E=await t(C);A(E)}catch(E){_(E instanceof Error?E.message:"Failed to fetch options")}finally{D(!1)}},[t]);p.useEffect(()=>{b&&(e?I&&A(C=>C.filter(E=>r?r(E,I):!0)):w(I))},[b,I,e,r,w]),p.useEffect(()=>{!b||!c||w(c)},[b,c,w]);const F=p.useCallback(C=>{u(C),requestAnimationFrame(()=>{const E=document.activeElement;E==null||E.blur(),S(!1)})},[u]),K=p.useCallback(()=>{S(!0),w(x)},[x,w]),O=p.useCallback(C=>{C.target.closest(".cmd-item")&&C.preventDefault()},[]);return g.jsx("div",{ref:z,className:fe(h&&"cursor-not-allowed opacity-50",f),onMouseDown:O,children:g.jsxs(fr,{shouldFilter:!1,className:"bg-transparent",children:[g.jsxs("div",{children:[g.jsx(On,{placeholder:s,value:x,className:"max-h-8",onFocus:K,onValueChange:C=>{T(C),P||S(!0)}}),j&&g.jsx("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 transform items-center",children:g.jsx(Ka,{className:"h-4 w-4 animate-spin"})})]}),g.jsxs(hr,{hidden:!P,children:[v&&g.jsx("div",{className:"text-destructive p-4 text-center",children:v}),j&&k.length===0&&(l||g.jsx(Ph,{})),!j&&!v&&k.length===0&&(o||g.jsx(Gn,{children:y??`No ${i.toLowerCase()} found.`})),g.jsx(Ct,{children:k.map((C,E)=>g.jsxs(Y.Fragment,{children:[g.jsx(kt,{value:a(C),onSelect:F,onMouseMove:()=>d(a(C)),className:"truncate cmd-item",children:n(C)},a(C)+`${E}`),E!==k.length-1&&g.jsx("div",{className:"bg-foreground/10 h-[1px]"},`divider-${E}`)]},a(C)+`-fragment-${E}`))})]})]})})}function Ph(){return g.jsx(Ct,{children:g.jsx(kt,{disabled:!0,children:g.jsxs("div",{className:"flex w-full items-center gap-2",children:[g.jsx("div",{className:"bg-muted h-6 w-6 animate-pulse rounded-full"}),g.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[g.jsx("div",{className:"bg-muted h-4 w-24 animate-pulse rounded"}),g.jsx("div",{className:"bg-muted h-3 w-16 animate-pulse rounded"})]})]})})})}const Kr="__message_item",Dh=({id:t})=>{const e=Z.use.sigmaGraph();if(!(e!=null&&e.hasNode(t)))return null;const r=e.getNodeAttribute(t,"label")||t,n=e.getNodeAttribute(t,"color")||"#666",a=e.getNodeAttribute(t,"size")||4;return g.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm",children:[g.jsx("div",{className:"rounded-full flex-shrink-0",style:{width:Math.max(8,Math.min(a*2,16)),height:Math.max(8,Math.min(a*2,16)),backgroundColor:n}}),g.jsx("span",{className:"truncate",children:r})]})};function Oh(t){return g.jsxs("div",{children:[t.type==="nodes"&&g.jsx(Dh,{id:t.id}),t.type==="edges"&&g.jsx(Lh,{id:t.id}),t.type==="message"&&g.jsx("div",{children:t.message})]})}const Gh=({onChange:t,onFocus:e,value:r})=>{const{t:n}=Se(),a=Z.use.sigmaGraph(),o=Z.use.searchEngine();p.useEffect(()=>{a&&Z.getState().resetSearchEngine()},[a]),p.useEffect(()=>{if(!a||a.nodes().length===0||o)return;const i=new gt({idField:"id",fields:["label"],searchOptions:{prefix:!0,fuzzy:.2,boost:{label:2}}}),s=a.nodes().filter(c=>a.hasNode(c)).map(c=>({id:c,label:a.getNodeAttribute(c,"label")}));s.length>0&&i.addAll(s),Z.getState().setSearchEngine(i)},[a,o]);const l=p.useCallback(async i=>{if(e&&e(null),!a||!o)return[];if(a.nodes().length===0)return[];if(!i)return a.nodes().filter(u=>a.hasNode(u)).slice(0,Nt).map(u=>({id:u,type:"nodes"}));let s=o.search(i).filter(c=>a.hasNode(c.id)).map(c=>({id:c.id,type:"nodes"}));if(s.length<5){const c=new Set(s.map(d=>d.id)),u=a.nodes().filter(d=>{if(c.has(d)||!a.hasNode(d))return!1;const h=a.getNodeAttribute(d,"label");return h&&typeof h=="string"&&!h.toLowerCase().startsWith(i.toLowerCase())&&h.toLowerCase().includes(i.toLowerCase())}).map(d=>({id:d,type:"nodes"}));s=[...s,...u]}return s.length<=Nt?s:[...s.slice(0,Nt),{type:"message",id:Kr,message:n("graphPanel.search.message",{count:s.length-Nt})}]},[a,o,e,n]);return g.jsx(zh,{className:"bg-background/60 w-24 rounded-xl border-1 opacity-60 backdrop-blur-lg transition-all hover:w-fit hover:opacity-100",fetcher:l,renderOption:Oh,getOptionValue:i=>i.id,value:r&&r.type!=="message"?r.id:null,onChange:i=>{i!==Kr&&t(i?{id:i,type:"nodes"}:null)},onFocus:i=>{i!==Kr&&e&&e(i?{id:i,type:"nodes"}:null)},label:"item",placeholder:n("graphPanel.search.placeholder")})},Mh=({...t})=>g.jsx(Gh,{...t});function $h({fetcher:t,preload:e,filterFn:r,renderOption:n,getOptionValue:a,getDisplayValue:o,notFound:l,loadingSkeleton:i,label:s,placeholder:c="Select...",value:u,onChange:d,disabled:h=!1,className:f,triggerClassName:y,searchInputClassName:b,noResultsMessage:R,triggerTooltip:P,clearable:S=!0,debounceTime:k=150}){const[A,j]=p.useState(!1),[D,v]=p.useState(!1),[_,x]=p.useState([]),[T,I]=p.useState(!1),[z,w]=p.useState(null),[F,K]=p.useState(u),[O,C]=p.useState(null),[E,W]=p.useState(""),re=Xs(E,e?0:k),[M,m]=p.useState([]),[L,U]=p.useState(null);p.useEffect(()=>{j(!0),K(u)},[u]),p.useEffect(()=>{u&&(!_.length||!O)?U(g.jsx("div",{children:u})):O&&U(null)},[u,_.length,O]),p.useEffect(()=>{if(u&&_.length>0){const Q=_.find(B=>a(B)===u);Q&&C(Q)}},[u,_,a]),p.useEffect(()=>{A||(async()=>{try{I(!0),w(null);const B=await t("");m(B),x(B)}catch(B){w(B instanceof Error?B.message:"Failed to fetch options")}finally{I(!1)}})()},[A,t]),p.useEffect(()=>{const Q=async()=>{try{I(!0),w(null);const B=await t(re);m(B),x(B)}catch(B){w(B instanceof Error?B.message:"Failed to fetch options")}finally{I(!1)}};A&&e?e&&x(re?M.filter(B=>r?r(B,re):!0):M):Q()},[t,re,A,e,r]);const q=p.useCallback(Q=>{const B=S&&Q===F?"":Q;K(B),C(_.find(X=>a(X)===B)||null),d(B),v(!1)},[F,d,S,_,a]);return g.jsxs(jn,{open:D,onOpenChange:v,children:[g.jsx(Nn,{asChild:!0,children:g.jsxs(be,{variant:"outline",role:"combobox","aria-expanded":D,className:fe("justify-between",h&&"cursor-not-allowed opacity-50",y),disabled:h,tooltip:P,side:"bottom",children:[u==="*"?g.jsx("div",{children:"*"}):O?o(O):L||c,g.jsx(Wc,{className:"opacity-50",size:10})]})}),g.jsx(cr,{className:fe("p-0",f),onCloseAutoFocus:Q=>Q.preventDefault(),align:"start",sideOffset:8,collisionPadding:5,children:g.jsxs(fr,{shouldFilter:!1,children:[g.jsxs("div",{className:"relative w-full border-b",children:[g.jsx(On,{placeholder:`Search ${s.toLowerCase()}...`,value:E,onValueChange:Q=>{W(Q)},className:b}),T&&_.length>0&&g.jsx("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 transform items-center",children:g.jsx(Ka,{className:"h-4 w-4 animate-spin"})})]}),g.jsxs(hr,{children:[z&&g.jsx("div",{className:"text-destructive p-4 text-center",children:z}),T&&_.length===0&&(i||g.jsx(Fh,{})),!T&&!z&&_.length===0&&(l||g.jsx(Gn,{children:R??`No ${s.toLowerCase()} found.`})),g.jsx(Ct,{children:_.map(Q=>{const B=a(Q),X=E.trim()===""?"":B;return g.jsxs(kt,{value:X,onSelect:()=>{q(B)},className:"truncate",children:[n(Q),g.jsx(Ya,{className:fe("ml-auto h-3 w-3",F===B?"opacity-100":"opacity-0")})]},B)})})]})]})})]})}function Fh(){return g.jsx(Ct,{children:g.jsx(kt,{disabled:!0,children:g.jsxs("div",{className:"flex w-full items-center gap-2",children:[g.jsx("div",{className:"bg-muted h-6 w-6 animate-pulse rounded-full"}),g.jsxs("div",{className:"flex flex-1 flex-col gap-1",children:[g.jsx("div",{className:"bg-muted h-4 w-24 animate-pulse rounded"}),g.jsx("div",{className:"bg-muted h-3 w-16 animate-pulse rounded"})]})]})})})}class Le{static getHistory(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return[];const r=JSON.parse(e);return r.version!==this.VERSION?(console.warn(`Search history version mismatch. Expected ${this.VERSION}, got ${r.version}. Clearing history.`),this.clearHistory(),[]):Array.isArray(r.items)?r.items.sort((n,a)=>a.lastAccessed!==n.lastAccessed?a.lastAccessed-n.lastAccessed:(a.accessCount||0)-(n.accessCount||0)):(console.warn("Invalid search history format. Clearing history."),this.clearHistory(),[])}catch(e){return console.error("Error reading search history:",e),this.clearHistory(),[]}}static addToHistory(e){if(!(!e||typeof e!="string"||e.trim()===""))try{const r=this.getHistory(),n=Date.now(),a=e.trim(),o=r.findIndex(i=>i.label===a);if(o>=0){const i=r[o];i.lastAccessed=n,i.accessCount=(i.accessCount||0)+1,r.splice(o,1),r.unshift(i)}else r.unshift({label:a,lastAccessed:n,accessCount:1});r.length>this.MAX_HISTORY&&r.splice(this.MAX_HISTORY);const l={items:r,version:this.VERSION};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(l))}catch(r){console.error("Error saving search history:",r)}}static clearHistory(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("Error clearing search history:",e)}}static async initializeWithDefaults(e){if(this.getHistory().length===0&&e.length>0)try{const n=Date.now(),o={items:e.map((l,i)=>({label:l.trim(),lastAccessed:n-i,accessCount:0})),version:this.VERSION};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(o))}catch(n){console.error("Error initializing search history with defaults:",n)}}static getRecentSearches(e=10){return this.getHistory().filter(n=>n.accessCount>0).slice(0,e)}static getPopularRecommendations(e){const n=this.getHistory().filter(a=>a.accessCount===0);return e?n.slice(0,e):n}static getHistoryLabels(e){const n=this.getHistory().map(a=>a.label);return e?n.slice(0,e):n}static hasLabel(e){return!e||typeof e!="string"?!1:this.getHistory().some(n=>n.label===e.trim())}static removeLabel(e){if(!(!e||typeof e!="string"))try{const r=this.getHistory(),n=e.trim(),a=r.filter(o=>o.label!==n);if(a.length!==r.length){const o={items:a,version:this.VERSION};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(o))}}catch(r){console.error("Error removing label from search history:",r)}}static getStats(){const e=this.getHistory(),r=e.filter(o=>o.accessCount>0).length,n=e.filter(o=>o.accessCount===0).length;let a=0;try{const o=localStorage.getItem(this.STORAGE_KEY);a=o?o.length:0}catch{}return{totalItems:e.length,recentSearches:r,popularRecommendations:n,storageSize:a}}}Ne(Le,"STORAGE_KEY","lightrag_search_history"),Ne(Le,"MAX_HISTORY",el),Ne(Le,"VERSION",tl);const Hh=()=>{const{t}=Se(),e=te.use.queryLabel(),[r,n]=p.useState(!1),[a,o]=p.useState(0),[l,i]=p.useState(0),s=p.useCallback(()=>r?t("graphPanel.graphLabels.refreshingTooltip"):!e||e==="*"?t("graphPanel.graphLabels.refreshGlobalTooltip"):t("graphPanel.graphLabels.refreshCurrentLabelTooltip",{label:e}),[e,t,r]);p.useEffect(()=>{(async()=>{if(Le.getHistory().length===0)try{const f=await eo(rn);await Le.initializeWithDefaults(f)}catch(f){console.error("Failed to initialize search history:",f)}})()},[]);const c=p.useCallback(async d=>{let h=[];if(!d||d.trim()===""||d.trim()==="*")h=Le.getHistoryLabels(Lt);else try{const y=await fl(d.trim(),Ta);h=y.length<=Lt?y:[...y.slice(0,Lt),"..."]}catch(y){console.error("Search API failed, falling back to local history search:",y);const b=Le.getHistory(),R=d.toLowerCase().trim();h=b.filter(P=>P.label.toLowerCase().includes(R)).map(P=>P.label).slice(0,Lt)}return["*",...h.filter(y=>y!=="*")]},[a]),u=p.useCallback(async()=>{n(!0),Z.getState().setTypeColorMap(new Map);try{let d=e;if((!d||d.trim()==="")&&(te.getState().setQueryLabel("*"),d="*"),d&&d!=="*")console.log(`Refreshing current label: ${d}`),Z.getState().setGraphDataFetchAttempted(!1),Z.getState().setLastSuccessfulQueryLabel(""),Z.getState().incrementGraphDataVersion();else{console.log("Refreshing global data and popular labels");try{const h=await eo(rn);if(Le.clearHistory(),h.length===0){const f=["entity","relationship","document","concept"];await Le.initializeWithDefaults(f)}else await Le.initializeWithDefaults(h)}catch(h){console.error("Failed to reload popular labels:",h);const f=["entity","relationship","document"];Le.clearHistory(),await Le.initializeWithDefaults(f)}Z.getState().setGraphDataFetchAttempted(!1),Z.getState().setLastSuccessfulQueryLabel(""),Z.getState().incrementGraphDataVersion(),await new Promise(h=>setTimeout(h,0)),o(h=>h+1),i(h=>h+1)}}catch(d){console.error("Error during refresh:",d)}finally{n(!1)}},[e]);return g.jsxs("div",{className:"flex items-center",children:[g.jsx(be,{size:"icon",variant:ze,onClick:u,tooltip:s(),className:"mr-2",disabled:r,children:g.jsx(xu,{className:`h-4 w-4 ${r?"animate-spin":""}`})}),g.jsx($h,{className:"min-w-[300px]",triggerClassName:"max-h-8",searchInputClassName:"max-h-8",triggerTooltip:t("graphPanel.graphLabels.selectTooltip"),fetcher:c,renderOption:d=>g.jsx("div",{style:{whiteSpace:"pre"},children:d}),getOptionValue:d=>d,getDisplayValue:d=>g.jsx("div",{style:{whiteSpace:"pre"},children:d}),notFound:g.jsx("div",{className:"py-6 text-center text-sm",children:"No labels found"}),label:t("graphPanel.graphLabels.label"),placeholder:t("graphPanel.graphLabels.placeholder"),value:e!==null?e:"*",onChange:d=>{const h=te.getState().queryLabel;d==="..."&&(d="*"),d===h&&d!=="*"&&(d="*"),d&&d!=="*"&&d!=="..."&&d.trim()!==""&&Le.addToHistory(d),Z.getState().setGraphDataFetchAttempted(!1),te.getState().setQueryLabel(d)},clearable:!1,debounceTime:500},l)]})},Ys=({text:t,className:e,tooltipClassName:r,tooltip:n,side:a,onClick:o})=>n?g.jsx(Ua,{delayDuration:200,children:g.jsxs(qa,{children:[g.jsx(Wa,{asChild:!0,children:g.jsx("label",{className:fe(e,o!==void 0?"cursor-pointer":void 0),onClick:o,children:t})}),g.jsx(In,{side:a,className:r,children:n})]})}):g.jsx("label",{className:fe(e,o!==void 0?"cursor-pointer":void 0),onClick:o,children:t});var $t={exports:{}},Bh=$t.exports,Jo;function Vh(){return Jo||(Jo=1,function(t){(function(e,r,n){function a(s){var c=this,u=i();c.next=function(){var d=2091639*c.s0+c.c*23283064365386963e-26;return c.s0=c.s1,c.s1=c.s2,c.s2=d-(c.c=d|0)},c.c=1,c.s0=u(" "),c.s1=u(" "),c.s2=u(" "),c.s0-=u(s),c.s0<0&&(c.s0+=1),c.s1-=u(s),c.s1<0&&(c.s1+=1),c.s2-=u(s),c.s2<0&&(c.s2+=1),u=null}function o(s,c){return c.c=s.c,c.s0=s.s0,c.s1=s.s1,c.s2=s.s2,c}function l(s,c){var u=new a(s),d=c&&c.state,h=u.next;return h.int32=function(){return u.next()*4294967296|0},h.double=function(){return h()+(h()*2097152|0)*11102230246251565e-32},h.quick=h,d&&(typeof d=="object"&&o(d,u),h.state=function(){return o(u,{})}),h}function i(){var s=4022871197,c=function(u){u=String(u);for(var d=0;d<u.length;d++){s+=u.charCodeAt(d);var h=.02519603282416938*s;s=h>>>0,h-=s,h*=s,s=h>>>0,h-=s,s+=h*4294967296}return(s>>>0)*23283064365386963e-26};return c}r&&r.exports?r.exports=l:this.alea=l})(Bh,t)}($t)),$t.exports}var Ft={exports:{}},Uh=Ft.exports,Zo;function qh(){return Zo||(Zo=1,function(t){(function(e,r,n){function a(i){var s=this,c="";s.x=0,s.y=0,s.z=0,s.w=0,s.next=function(){var d=s.x^s.x<<11;return s.x=s.y,s.y=s.z,s.z=s.w,s.w^=s.w>>>19^d^d>>>8},i===(i|0)?s.x=i:c+=i;for(var u=0;u<c.length+64;u++)s.x^=c.charCodeAt(u)|0,s.next()}function o(i,s){return s.x=i.x,s.y=i.y,s.z=i.z,s.w=i.w,s}function l(i,s){var c=new a(i),u=s&&s.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,y=(h+f)/(1<<21);while(y===0);return y},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&o(u,c),d.state=function(){return o(c,{})}),d}r&&r.exports?r.exports=l:this.xor128=l})(Uh,t)}(Ft)),Ft.exports}var Ht={exports:{}},Wh=Ht.exports,ea;function Xh(){return ea||(ea=1,function(t){(function(e,r,n){function a(i){var s=this,c="";s.next=function(){var d=s.x^s.x>>>2;return s.x=s.y,s.y=s.z,s.z=s.w,s.w=s.v,(s.d=s.d+362437|0)+(s.v=s.v^s.v<<4^(d^d<<1))|0},s.x=0,s.y=0,s.z=0,s.w=0,s.v=0,i===(i|0)?s.x=i:c+=i;for(var u=0;u<c.length+64;u++)s.x^=c.charCodeAt(u)|0,u==c.length&&(s.d=s.x<<10^s.x>>>4),s.next()}function o(i,s){return s.x=i.x,s.y=i.y,s.z=i.z,s.w=i.w,s.v=i.v,s.d=i.d,s}function l(i,s){var c=new a(i),u=s&&s.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,y=(h+f)/(1<<21);while(y===0);return y},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&o(u,c),d.state=function(){return o(c,{})}),d}r&&r.exports?r.exports=l:this.xorwow=l})(Wh,t)}(Ht)),Ht.exports}var Bt={exports:{}},Yh=Bt.exports,ta;function Kh(){return ta||(ta=1,function(t){(function(e,r,n){function a(i){var s=this;s.next=function(){var u=s.x,d=s.i,h,f;return h=u[d],h^=h>>>7,f=h^h<<24,h=u[d+1&7],f^=h^h>>>10,h=u[d+3&7],f^=h^h>>>3,h=u[d+4&7],f^=h^h<<7,h=u[d+7&7],h=h^h<<13,f^=h^h<<9,u[d]=f,s.i=d+1&7,f};function c(u,d){var h,f=[];if(d===(d|0))f[0]=d;else for(d=""+d,h=0;h<d.length;++h)f[h&7]=f[h&7]<<15^d.charCodeAt(h)+f[h+1&7]<<13;for(;f.length<8;)f.push(0);for(h=0;h<8&&f[h]===0;++h);for(h==8?f[7]=-1:f[h],u.x=f,u.i=0,h=256;h>0;--h)u.next()}c(s,i)}function o(i,s){return s.x=i.x.slice(),s.i=i.i,s}function l(i,s){i==null&&(i=+new Date);var c=new a(i),u=s&&s.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,y=(h+f)/(1<<21);while(y===0);return y},d.int32=c.next,d.quick=d,u&&(u.x&&o(u,c),d.state=function(){return o(c,{})}),d}r&&r.exports?r.exports=l:this.xorshift7=l})(Yh,t)}(Bt)),Bt.exports}var Vt={exports:{}},Qh=Vt.exports,ra;function Jh(){return ra||(ra=1,function(t){(function(e,r,n){function a(i){var s=this;s.next=function(){var u=s.w,d=s.X,h=s.i,f,y;return s.w=u=u+1640531527|0,y=d[h+34&127],f=d[h=h+1&127],y^=y<<13,f^=f<<17,y^=y>>>15,f^=f>>>12,y=d[h]=y^f,s.i=h,y+(u^u>>>16)|0};function c(u,d){var h,f,y,b,R,P=[],S=128;for(d===(d|0)?(f=d,d=null):(d=d+"\0",f=0,S=Math.max(S,d.length)),y=0,b=-32;b<S;++b)d&&(f^=d.charCodeAt((b+32)%d.length)),b===0&&(R=f),f^=f<<10,f^=f>>>15,f^=f<<4,f^=f>>>13,b>=0&&(R=R+1640531527|0,h=P[b&127]^=f+R,y=h==0?y+1:0);for(y>=128&&(P[(d&&d.length||0)&127]=-1),y=127,b=4*128;b>0;--b)f=P[y+34&127],h=P[y=y+1&127],f^=f<<13,h^=h<<17,f^=f>>>15,h^=h>>>12,P[y]=f^h;u.w=R,u.X=P,u.i=y}c(s,i)}function o(i,s){return s.i=i.i,s.w=i.w,s.X=i.X.slice(),s}function l(i,s){i==null&&(i=+new Date);var c=new a(i),u=s&&s.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,y=(h+f)/(1<<21);while(y===0);return y},d.int32=c.next,d.quick=d,u&&(u.X&&o(u,c),d.state=function(){return o(c,{})}),d}r&&r.exports?r.exports=l:this.xor4096=l})(Qh,t)}(Vt)),Vt.exports}var Ut={exports:{}},Zh=Ut.exports,na;function eg(){return na||(na=1,function(t){(function(e,r,n){function a(i){var s=this,c="";s.next=function(){var d=s.b,h=s.c,f=s.d,y=s.a;return d=d<<25^d>>>7^h,h=h-f|0,f=f<<24^f>>>8^y,y=y-d|0,s.b=d=d<<20^d>>>12^h,s.c=h=h-f|0,s.d=f<<16^h>>>16^y,s.a=y-d|0},s.a=0,s.b=0,s.c=-1640531527,s.d=1367130551,i===Math.floor(i)?(s.a=i/4294967296|0,s.b=i|0):c+=i;for(var u=0;u<c.length+20;u++)s.b^=c.charCodeAt(u)|0,s.next()}function o(i,s){return s.a=i.a,s.b=i.b,s.c=i.c,s.d=i.d,s}function l(i,s){var c=new a(i),u=s&&s.state,d=function(){return(c.next()>>>0)/4294967296};return d.double=function(){do var h=c.next()>>>11,f=(c.next()>>>0)/4294967296,y=(h+f)/(1<<21);while(y===0);return y},d.int32=c.next,d.quick=d,u&&(typeof u=="object"&&o(u,c),d.state=function(){return o(c,{})}),d}r&&r.exports?r.exports=l:this.tychei=l})(Zh,t)}(Ut)),Ut.exports}var qt={exports:{}};const tg={},rg=Object.freeze(Object.defineProperty({__proto__:null,default:tg},Symbol.toStringTag,{value:"Module"})),ng=wi(rg);var og=qt.exports,oa;function ag(){return oa||(oa=1,function(t){(function(e,r,n){var a=256,o=6,l=52,i="random",s=n.pow(a,o),c=n.pow(2,l),u=c*2,d=a-1,h;function f(A,j,D){var v=[];j=j==!0?{entropy:!0}:j||{};var _=P(R(j.entropy?[A,k(r)]:A??S(),3),v),x=new y(v),T=function(){for(var I=x.g(o),z=s,w=0;I<c;)I=(I+w)*a,z*=a,w=x.g(1);for(;I>=u;)I/=2,z/=2,w>>>=1;return(I+w)/z};return T.int32=function(){return x.g(4)|0},T.quick=function(){return x.g(4)/4294967296},T.double=T,P(k(x.S),r),(j.pass||D||function(I,z,w,F){return F&&(F.S&&b(F,x),I.state=function(){return b(x,{})}),w?(n[i]=I,z):I})(T,_,"global"in j?j.global:this==n,j.state)}function y(A){var j,D=A.length,v=this,_=0,x=v.i=v.j=0,T=v.S=[];for(D||(A=[D++]);_<a;)T[_]=_++;for(_=0;_<a;_++)T[_]=T[x=d&x+A[_%D]+(j=T[_])],T[x]=j;(v.g=function(I){for(var z,w=0,F=v.i,K=v.j,O=v.S;I--;)z=O[F=d&F+1],w=w*a+O[d&(O[F]=O[K=d&K+z])+(O[K]=z)];return v.i=F,v.j=K,w})(a)}function b(A,j){return j.i=A.i,j.j=A.j,j.S=A.S.slice(),j}function R(A,j){var D=[],v=typeof A,_;if(j&&v=="object")for(_ in A)try{D.push(R(A[_],j-1))}catch{}return D.length?D:v=="string"?A:A+"\0"}function P(A,j){for(var D=A+"",v,_=0;_<D.length;)j[d&_]=d&(v^=j[d&_]*19)+D.charCodeAt(_++);return k(j)}function S(){try{var A;return h&&(A=h.randomBytes)?A=A(a):(A=new Uint8Array(a),(e.crypto||e.msCrypto).getRandomValues(A)),k(A)}catch{var j=e.navigator,D=j&&j.plugins;return[+new Date,e,D,e.screen,k(r)]}}function k(A){return String.fromCharCode.apply(0,A)}if(P(n.random(),r),t.exports){t.exports=f;try{h=ng}catch{}}else n["seed"+i]=f})(typeof self<"u"?self:og,[],Math)}(qt)),qt.exports}var Qr,aa;function sg(){if(aa)return Qr;aa=1;var t=Vh(),e=qh(),r=Xh(),n=Kh(),a=Jh(),o=eg(),l=ag();return l.alea=t,l.xor128=e,l.xorwow=r,l.xorshift7=n,l.xor4096=a,l.tychei=o,Qr=l,Qr}var ig=sg();const Sn=Be(ig),lg={unknown:"unknown",未知:"unknown",other:"other",其它:"other",concept:"concept",object:"concept",type:"concept",category:"concept",model:"concept",project:"concept",condition:"concept",rule:"concept",regulation:"concept",article:"concept",law:"concept",legalclause:"concept",policy:"concept",disease:"concept",概念:"concept",对象:"concept",类别:"concept",分类:"concept",模型:"concept",项目:"concept",条件:"concept",规则:"concept",法律:"concept",法律条款:"concept",条文:"concept",政策:"policy",疾病:"concept",method:"method",process:"method",方法:"method",过程:"method",artifact:"artifact",technology:"artifact",tech:"artifact",product:"artifact",equipment:"artifact",device:"artifact",stuff:"artifact",component:"artifact",material:"artifact",chemical:"artifact",drug:"artifact",medicine:"artifact",food:"artifact",weapon:"artifact",arms:"artifact",人工制品:"artifact",人造物品:"artifact",技术:"technology",科技:"technology",产品:"artifact",设备:"artifact",装备:"artifact",物品:"artifact",材料:"artifact",化学:"artifact",药物:"artifact",食品:"artifact",武器:"artifact",军火:"artifact",naturalobject:"naturalobject",natural:"naturalobject",phenomena:"naturalobject",substance:"naturalobject",plant:"naturalobject",自然对象:"naturalobject",自然物体:"naturalobject",自然现象:"naturalobject",物质:"naturalobject",物体:"naturalobject",data:"data",figure:"data",value:"data",数据:"data",数字:"data",数值:"data",content:"content",book:"content",video:"content",内容:"content",作品:"content",书籍:"content",视频:"content",organization:"organization",org:"organization",company:"organization",组织:"organization",公司:"organization",机构:"organization",组织机构:"organization",event:"event",事件:"event",activity:"event",活动:"event",person:"person",people:"person",human:"person",role:"person",人物:"person",人类:"person",:"person",角色:"person",creature:"creature",animal:"creature",beings:"creature",being:"creature",alien:"creature",ghost:"creature",动物:"creature",生物:"creature",神仙:"creature",鬼怪:"creature",妖怪:"creature",location:"location",geography:"location",geo:"location",place:"location",address:"location",地点:"location",位置:"location",地址:"location",地理:"location",地域:"location"},sa={person:"#4169E1",creature:"#bd7ebe",organization:"#00cc00",location:"#cf6d17",event:"#00bfa0",concept:"#e3493b",method:"#b71c1c",content:"#0f558a",data:"#0000ff",artifact:"#4421af",naturalobject:"#b2e061",other:"#f4d371",unknown:"#b0b0b0"},cg=["#84a3e1","#5a2c6d","#2F4F4F","#003366","#9b3a31","#00CED1","#b300b3","#0f705d","#ff99cc","#6ef7b3","#cd071e"],ia=t=>{const e="#5D6D7E",r=t?t.toLowerCase():"unknown",n=Z.getState().typeColorMap,a=lg[r],o=a||r;if(n.has(o))return n.get(o)||e;if(a){const u=sa[a],d=new Map(n);return d.set(a,u),Z.setState({typeColorMap:d}),u}const l=new Set(Array.from(n.entries()).filter(([,u])=>!Object.values(sa).includes(u)).map(([,u])=>u)),s=cg.find(u=>!l.has(u))||e,c=new Map(n);return c.set(r,s),Z.setState({typeColorMap:c}),s},ug=t=>{if(!t)return console.log("Graph validation failed: graph is null"),!1;if(!Array.isArray(t.nodes)||!Array.isArray(t.edges))return console.log("Graph validation failed: nodes or edges is not an array"),!1;if(t.nodes.length===0)return console.log("Graph validation failed: nodes array is empty"),!1;for(const e of t.nodes)if(!e.id||!e.labels||!e.properties)return console.log("Graph validation failed: invalid node structure"),!1;for(const e of t.edges)if(!e.id||!e.source||!e.target)return console.log("Graph validation failed: invalid edge structure"),!1;for(const e of t.edges){const r=t.getNode(e.source),n=t.getNode(e.target);if(r==null||n==null)return console.log("Graph validation failed: edge references non-existent node"),!1}return console.log("Graph validation passed"),!0},dg=async(t,e,r)=>{let n=null;Z.getState().setLabelsFetchAttempted(!0);const a=t||"*";try{console.log(`Fetching graph label: ${a}, depth: ${e}, nodes: ${r}`),n=await Ia(a,e,r)}catch(l){return Rn.getState().setErrorMessage(or(l),"Query Graphs Error!"),null}let o=null;if(n){const l={},i={};for(let d=0;d<n.nodes.length;d++){const h=n.nodes[d];l[h.id]=d,h.x=Math.random(),h.y=Math.random(),h.degree=0,h.size=10}for(let d=0;d<n.edges.length;d++){const h=n.edges[d];i[h.id]=d;const f=l[h.source],y=l[h.target];if(f!==void 0&&f!==void 0){const b=n.nodes[f],R=n.nodes[y];if(!b){console.error(`Source node ${h.source} is undefined`);continue}if(!R){console.error(`Target node ${h.target} is undefined`);continue}b.degree+=1,R.degree+=1}}let s=Number.MAX_SAFE_INTEGER,c=0;for(const d of n.nodes)s=Math.min(s,d.degree),c=Math.max(c,d.degree);const u=c-s;if(u>0){const d=nn-ut;for(const h of n.nodes)h.size=Math.round(ut+d*Math.pow((h.degree-s)/u,.5))}o=new cl,o.nodes=n.nodes,o.edges=n.edges,o.nodeIdMap=l,o.edgeIdMap=i,ug(o)||(o=null,console.warn("Invalid graph data")),console.log("Graph data loaded")}return{rawGraph:o,is_truncated:n.is_truncated}},fg=t=>{var i,s;const e=te.getState().minEdgeSize,r=te.getState().maxEdgeSize;if(!t||!t.nodes.length)return console.log("No graph data available, skipping sigma graph creation"),null;const n=new Jr;for(const c of(t==null?void 0:t.nodes)??[]){Sn(c.id+Date.now().toString(),{global:!0});const u=Math.random(),d=Math.random();n.addNode(c.id,{label:c.labels.join(", "),color:c.color,x:u,y:d,size:c.size,borderColor:tn,borderSize:.2})}for(const c of(t==null?void 0:t.edges)??[]){const u=((i=c.properties)==null?void 0:i.weight)!==void 0?Number(c.properties.weight):1;c.dynamicId=n.addEdge(c.source,c.target,{label:((s=c.properties)==null?void 0:s.keywords)||void 0,size:u,originalWeight:u,type:"curvedNoArrow"})}let a=Number.MAX_SAFE_INTEGER,o=0;n.forEachEdge(c=>{const u=n.getEdgeAttribute(c,"originalWeight")||1;a=Math.min(a,u),o=Math.max(o,u)});const l=o-a;if(l>0){const c=r-e;n.forEachEdge(u=>{const d=n.getEdgeAttribute(u,"originalWeight")||1,h=e+c*Math.pow((d-a)/l,.5);n.setEdgeAttribute(u,"size",h)})}else n.forEachEdge(c=>{n.setEdgeAttribute(c,"size",e)});return n},hg=()=>{const{t}=Se(),e=te.use.queryLabel(),r=Z.use.rawGraph(),n=Z.use.sigmaGraph(),a=te.use.graphQueryMaxDepth(),o=te.use.graphMaxNodes(),l=Z.use.isFetching(),i=Z.use.nodeToExpand(),s=Z.use.nodeToPrune(),c=Z.use.graphDataVersion(),u=p.useRef(!1),d=p.useRef(!1),h=p.useRef(!1),f=p.useCallback(S=>(r==null?void 0:r.getNode(S))||null,[r]),y=p.useCallback((S,k=!0)=>(r==null?void 0:r.getEdge(S,k))||null,[r]),b=p.useRef(!1);p.useEffect(()=>{if(!e&&(r!==null||n!==null)){const S=Z.getState();S.reset(),S.setGraphDataFetchAttempted(!1),S.setLabelsFetchAttempted(!1),u.current=!1,d.current=!1}},[e,r,n]),p.useEffect(()=>{if(!b.current&&!(!e&&h.current)&&!l&&!Z.getState().graphDataFetchAttempted){b.current=!0,Z.getState().setGraphDataFetchAttempted(!0);const S=Z.getState();S.setIsFetching(!0),S.clearSelection(),S.sigmaGraph&&S.sigmaGraph.forEachNode(v=>{var _;(_=S.sigmaGraph)==null||_.setNodeAttribute(v,"highlighted",!1)}),console.log("Preparing graph data...");const k=e,A=a,j=o;let D;k?D=dg(k,A,j):(console.log("Query label is empty, show empty graph"),D=Promise.resolve({rawGraph:null,is_truncated:!1})),D.then(v=>{const _=Z.getState(),x=v==null?void 0:v.rawGraph;if(x&&x.nodes&&x.nodes.forEach(T=>{var z;const I=(z=T.properties)==null?void 0:z.entity_type;T.color=ia(I)}),v!=null&&v.is_truncated&&nt.info(t("graphPanel.dataIsTruncated","Graph data is truncated to Max Nodes")),_.reset(),!x||!x.nodes||x.nodes.length===0){const T=new Jr;T.addNode("empty-graph-node",{label:t("graphPanel.emptyGraph"),color:"#5D6D7E",x:.5,y:.5,size:15,borderColor:tn,borderSize:.2}),_.setSigmaGraph(T),_.setRawGraph(null),_.setGraphIsEmpty(!0);const I=Rn.getState().message,z=I&&I.includes("Authentication required");!z&&k&&te.getState().setQueryLabel(""),z?console.log("Keep queryLabel for post-login reload"):_.setLastSuccessfulQueryLabel(""),console.log(`Graph data is empty, created graph with empty graph node. Auth error: ${z}`)}else{const T=fg(x);x.buildDynamicMap(),_.setSigmaGraph(T),_.setRawGraph(x),_.setGraphIsEmpty(!1),_.setLastSuccessfulQueryLabel(k),_.setMoveToSelectedNode(!0)}u.current=!0,d.current=!0,b.current=!1,_.setIsFetching(!1),(!x||!x.nodes||x.nodes.length===0)&&!k&&(h.current=!0)}).catch(v=>{console.error("Error fetching graph data:",v);const _=Z.getState();_.setIsFetching(!1),u.current=!1,b.current=!1,_.setGraphDataFetchAttempted(!1),_.setLastSuccessfulQueryLabel("")})}},[e,a,o,l,t,c]),p.useEffect(()=>{i&&((async k=>{var A,j,D,v,_,x;if(!(!k||!n||!r))try{const T=r.getNode(k);if(!T){console.error("Node not found:",k);return}const I=T.labels[0];if(!I){console.error("Node has no label:",k);return}const z=await Ia(I,2,1e3);if(!z||!z.nodes||!z.edges){console.error("Failed to fetch extended graph");return}const w=[];for(const $ of z.nodes){Sn($.id,{global:!0});const V=(A=$.properties)==null?void 0:A.entity_type,H=ia(V);w.push({id:$.id,labels:$.labels,properties:$.properties,size:10,x:Math.random(),y:Math.random(),color:H,degree:0})}const F=[];for(const $ of z.edges)F.push({id:$.id,source:$.source,target:$.target,type:$.type,properties:$.properties,dynamicId:""});const K={};n.forEachNode($=>{K[$]={x:n.getNodeAttribute($,"x"),y:n.getNodeAttribute($,"y")}});const O=new Set(n.nodes()),C=new Set,E=new Set,W=1;let re=0,M=Number.MAX_SAFE_INTEGER,m=0;n.forEachNode($=>{const V=n.degree($);re=Math.max(re,V)}),n.forEachEdge($=>{const V=n.getEdgeAttribute($,"originalWeight")||1;M=Math.min(M,V),m=Math.max(m,V)});for(const $ of w){if(O.has($.id))continue;F.some(H=>H.source===k&&H.target===$.id||H.target===k&&H.source===$.id)&&C.add($.id)}const L=new Map,U=new Map,q=new Set;for(const $ of F){const V=O.has($.source)||C.has($.source),H=O.has($.target)||C.has($.target);V&&H?(E.add($.id),C.has($.source)?L.set($.source,(L.get($.source)||0)+1):O.has($.source)&&U.set($.source,(U.get($.source)||0)+1),C.has($.target)?L.set($.target,(L.get($.target)||0)+1):O.has($.target)&&U.set($.target,(U.get($.target)||0)+1)):(n.hasNode($.source)?q.add($.source):C.has($.source)&&(q.add($.source),L.set($.source,(L.get($.source)||0)+1)),n.hasNode($.target)?q.add($.target):C.has($.target)&&(q.add($.target),L.set($.target,(L.get($.target)||0)+1)))}const Q=($,V,H,N)=>{const ae=N-H||1,ue=nn-ut;for(const ee of V)if($.hasNode(ee)){let J=$.degree(ee);J+=1;const G=Math.min(J,N+1),he=Math.round(ut+ue*Math.pow((G-H)/ae,.5));$.setNodeAttribute(ee,"size",he)}},B=($,V,H)=>{const N=te.getState().minEdgeSize,ae=te.getState().maxEdgeSize,ue=H-V||1,ee=ae-N;$.forEachEdge(J=>{const G=$.getEdgeAttribute(J,"originalWeight")||1,he=N+ee*Math.pow((G-V)/ue,.5);$.setEdgeAttribute(J,"size",he)})};if(C.size===0){Q(n,q,W,re),nt.info(t("graphPanel.propertiesView.node.noNewNodes"));return}for(const[,$]of L.entries())re=Math.max(re,$);for(const[$,V]of U.entries()){const N=n.degree($)+V;re=Math.max(re,N)}const X=re-W||1,le=nn-ut,ne=((j=Z.getState().sigmaInstance)==null?void 0:j.getCamera().ratio)||1,se=Math.max(Math.sqrt(T.size)*4,Math.sqrt(C.size)*3)/ne;Sn(Date.now().toString(),{global:!0});const oe=Math.random()*2*Math.PI;console.log("nodeSize:",T.size,"nodesToAdd:",C.size),console.log("cameraRatio:",Math.round(ne*100)/100,"spreadFactor:",Math.round(se*100)/100);for(const $ of C){const V=w.find(G=>G.id===$),H=L.get($)||0,N=Math.min(H,re+1),ae=Math.round(ut+le*Math.pow((N-W)/X,.5)),ue=2*Math.PI*(Array.from(C).indexOf($)/C.size),ee=((D=K[$])==null?void 0:D.x)||K[T.id].x+Math.cos(oe+ue)*se,J=((v=K[$])==null?void 0:v.y)||K[T.id].y+Math.sin(oe+ue)*se;n.addNode($,{label:V.labels.join(", "),color:V.color,x:ee,y:J,size:ae,borderColor:tn,borderSize:.2}),r.getNode($)||(V.size=ae,V.x=ee,V.y=J,V.degree=H,r.nodes.push(V),r.nodeIdMap[$]=r.nodes.length-1)}for(const $ of E){const V=F.find(N=>N.id===$);if(n.hasEdge(V.source,V.target))continue;const H=((_=V.properties)==null?void 0:_.weight)!==void 0?Number(V.properties.weight):1;M=Math.min(M,H),m=Math.max(m,H),V.dynamicId=n.addEdge(V.source,V.target,{label:((x=V.properties)==null?void 0:x.keywords)||void 0,size:H,originalWeight:H,type:"curvedNoArrow"}),r.getEdge(V.id,!1)?console.error("Edge already exists in rawGraph:",V.id):(r.edges.push(V),r.edgeIdMap[V.id]=r.edges.length-1,r.edgeDynamicIdMap[V.dynamicId]=r.edges.length-1)}if(r.buildDynamicMap(),Z.getState().resetSearchEngine(),Q(n,q,W,re),B(n,M,m),n.hasNode(k)){const $=n.degree(k),V=Math.min($,re+1),H=Math.round(ut+le*Math.pow((V-W)/X,.5));n.setNodeAttribute(k,"size",H),T.size=H,T.degree=$}}catch(T){console.error("Error expanding node:",T)}})(i),window.setTimeout(()=>{Z.getState().triggerNodeExpand(null)},0))},[i,n,r,t]);const R=p.useCallback((S,k)=>{const A=new Set([S]);return k.forEachNode(j=>{if(j===S)return;const D=k.neighbors(j);D.length===1&&D[0]===S&&A.add(j)}),A},[]);return p.useEffect(()=>{s&&((k=>{if(!(!k||!n||!r))try{const A=Z.getState();if(!n.hasNode(k)){console.error("Node not found:",k);return}const j=R(k,n);if(j.size===n.nodes().length){nt.error(t("graphPanel.propertiesView.node.deleteAllNodesError"));return}A.clearSelection();for(const D of j){n.dropNode(D);const v=r.nodeIdMap[D];if(v!==void 0){const _=r.edges.filter(x=>x.source===D||x.target===D);for(const x of _){const T=r.edgeIdMap[x.id];if(T!==void 0){r.edges.splice(T,1);for(const[I,z]of Object.entries(r.edgeIdMap))z>T&&(r.edgeIdMap[I]=z-1);delete r.edgeIdMap[x.id],delete r.edgeDynamicIdMap[x.dynamicId]}}r.nodes.splice(v,1);for(const[x,T]of Object.entries(r.nodeIdMap))T>v&&(r.nodeIdMap[x]=T-1);delete r.nodeIdMap[D]}}r.buildDynamicMap(),Z.getState().resetSearchEngine(),j.size>1&&nt.info(t("graphPanel.propertiesView.node.nodesRemoved",{count:j.size}))}catch(A){console.error("Error pruning node:",A)}})(s),window.setTimeout(()=>{Z.getState().triggerNodePrune(null)},0))},[s,n,r,R,t]),{lightrageGraph:p.useCallback(()=>{if(n)return n;console.log("Creating new Sigma graph instance");const S=new Jr;return Z.getState().setSigmaGraph(S),S},[n]),getNode:f,getEdge:y}},gg=({name:t})=>{const{t:e}=Se(),r=n=>{const a=`graphPanel.propertiesView.node.propertyNames.${n}`,o=e(a);return o===a?n:o};return g.jsx("span",{className:"text-primary/60 tracking-wide whitespace-nowrap",children:r(t)})},pg=({onClick:t})=>g.jsx("div",{children:g.jsx(vu,{className:"h-3 w-3 text-gray-500 hover:text-gray-700 cursor-pointer",onClick:t})}),mg=({value:t,onClick:e,tooltip:r})=>g.jsx("div",{className:"flex items-center gap-1 overflow-hidden",children:g.jsx(Ys,{className:"hover:bg-primary/20 rounded p-1 overflow-hidden text-ellipsis whitespace-nowrap",tooltipClassName:"max-w-80 -translate-x-15",text:t,tooltip:r||(typeof t=="string"?t:JSON.stringify(t,null,2)),side:"left",onClick:e})}),vg=({isOpen:t,onClose:e,onSave:r,propertyName:n,initialValue:a,isSubmitting:o=!1})=>{const{t:l}=Se(),[i,s]=p.useState(""),[c,u]=p.useState(null);p.useEffect(()=>{t&&s(a)},[t,a]);const d=y=>{const b=`graphPanel.propertiesView.node.propertyNames.${y}`,R=l(b);return R===b?y:R},h=y=>{switch(y){case"description":return{className:"max-h-[50vh] min-h-[10em] resize-y",style:{height:"70vh",minHeight:"20em",resize:"vertical"}};case"entity_id":return{rows:2,className:"",style:{}};case"keywords":return{rows:4,className:"",style:{}};default:return{rows:5,className:"",style:{}}}},f=async()=>{if(i.trim()!==""){u(null);try{await r(i),e()}catch(y){console.error("Save error:",y),u(typeof y=="object"&&y!==null&&y.message||l("common.saveFailed"))}}};return g.jsx(Uu,{open:t,onOpenChange:y=>!y&&e(),children:g.jsxs(Za,{className:"sm:max-w-md",children:[g.jsxs(es,{children:[g.jsx(rs,{children:l("graphPanel.propertiesView.editProperty",{property:d(n)})}),g.jsx(ns,{children:l("graphPanel.propertiesView.editPropertyDescription")})]}),c&&g.jsx("div",{className:"bg-destructive/15 text-destructive px-4 py-2 rounded-md text-sm mt-2",children:c}),g.jsx("div",{className:"grid gap-4 py-4",children:(()=>{const y=h(n);return n==="description"?g.jsx("textarea",{value:i,onChange:b=>s(b.target.value),className:`border-input focus-visible:ring-ring flex w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${y.className}`,style:y.style,disabled:o}):g.jsx("textarea",{value:i,onChange:b=>s(b.target.value),rows:y.rows,className:`border-input focus-visible:ring-ring flex w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 ${y.className}`,disabled:o})})()}),g.jsxs(ts,{children:[g.jsx(be,{type:"button",variant:"outline",onClick:e,disabled:o,children:l("common.cancel")}),g.jsx(be,{type:"button",onClick:f,disabled:o,children:o?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"mr-2",children:g.jsxs("svg",{className:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[g.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),g.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),l("common.saving")]}):l("common.save")})]})]})})},yg=({name:t,value:e,onClick:r,nodeId:n,edgeId:a,entityId:o,dynamicId:l,entityType:i,sourceId:s,targetId:c,onValueChange:u,isEditable:d=!1,tooltip:h})=>{const{t:f}=Se(),[y,b]=p.useState(!1),[R,P]=p.useState(!1),[S,k]=p.useState(e);p.useEffect(()=>{k(e)},[e]);const A=()=>{d&&!y&&b(!0)},j=()=>{b(!1)},D=async v=>{if(R||v===String(S)){b(!1);return}P(!0);try{if(i==="node"&&o&&n){let _={[t]:v};if(t==="entity_id"){if(await ml(v)){nt.error(f("graphPanel.propertiesView.errors.duplicateName"));return}_={entity_name:v}}await gl(o,_,!0);try{await Z.getState().updateNodeAndSelect(n,o,t,v)}catch(x){throw console.error("Error updating node in graph:",x),new Error("Failed to update node in graph")}nt.success(f("graphPanel.propertiesView.success.entityUpdated"))}else if(i==="edge"&&s&&c&&a&&l){const _={[t]:v};await pl(s,c,_);try{await Z.getState().updateEdgeAndSelect(a,l,s,c,t,v)}catch(x){throw console.error(`Error updating edge ${s}->${c} in graph:`,x),new Error("Failed to update edge in graph")}nt.success(f("graphPanel.propertiesView.success.relationUpdated"))}b(!1),k(v),u==null||u(v)}catch(_){console.error("Error updating property:",_),nt.error(f("graphPanel.propertiesView.errors.updateFailed"))}finally{P(!1)}};return g.jsxs("div",{className:"flex items-center gap-1 overflow-hidden",children:[g.jsx(gg,{name:t}),g.jsx(pg,{onClick:A}),":",g.jsx(mg,{value:S,onClick:r,tooltip:h||(typeof S=="string"?S:JSON.stringify(S,null,2))}),g.jsx(vg,{isOpen:y,onClose:j,onSave:D,propertyName:t,initialValue:String(S),isSubmitting:R})]})},bg=()=>{const{getNode:t,getEdge:e}=hg(),r=Z.use.selectedNode(),n=Z.use.focusedNode(),a=Z.use.selectedEdge(),o=Z.use.focusedEdge(),l=Z.use.graphDataVersion(),[i,s]=p.useState(null),[c,u]=p.useState(null);return p.useEffect(()=>{let d=null,h=null;n?(d="node",h=t(n)):r?(d="node",h=t(r)):o?(d="edge",h=e(o,!0)):a&&(d="edge",h=e(a,!0)),h?(d=="node"?s(wg(h)):s(xg(h)),u(d)):(s(null),u(null))},[n,r,o,a,l,s,u,t,e]),i?g.jsx("div",{className:"bg-background/80 max-w-xs rounded-lg border-2 p-2 text-xs backdrop-blur-lg",children:c=="node"?g.jsx(Sg,{node:i}):g.jsx(_g,{edge:i})}):g.jsx(g.Fragment,{})},wg=t=>{const e=Z.getState(),r=[];if(e.sigmaGraph&&e.rawGraph)try{if(!e.sigmaGraph.hasNode(t.id))return console.warn("Node not found in sigmaGraph:",t.id),{...t,relationships:[]};const n=e.sigmaGraph.edges(t.id);for(const a of n){if(!e.sigmaGraph.hasEdge(a))continue;const o=e.rawGraph.getEdge(a,!0);if(o){const i=t.id===o.source?o.target:o.source;if(!e.sigmaGraph.hasNode(i))continue;const s=e.rawGraph.getNode(i);s&&r.push({type:"Neighbour",id:i,label:s.properties.entity_id?s.properties.entity_id:s.labels.join(", ")})}}}catch(n){console.error("Error refining node properties:",n)}return{...t,relationships:r}},xg=t=>{const e=Z.getState();let r,n;if(e.sigmaGraph&&e.rawGraph)try{if(!e.sigmaGraph.hasEdge(t.dynamicId))return console.warn("Edge not found in sigmaGraph:",t.id,"dynamicId:",t.dynamicId),{...t,sourceNode:void 0,targetNode:void 0};e.sigmaGraph.hasNode(t.source)&&(r=e.rawGraph.getNode(t.source)),e.sigmaGraph.hasNode(t.target)&&(n=e.rawGraph.getNode(t.target))}catch(a){console.error("Error refining edge properties:",a)}return{...t,sourceNode:r,targetNode:n}},He=({name:t,value:e,onClick:r,tooltip:n,nodeId:a,edgeId:o,dynamicId:l,entityId:i,entityType:s,sourceId:c,targetId:u,isEditable:d=!1})=>{const{t:h}=Se(),f=P=>{const S=`graphPanel.propertiesView.node.propertyNames.${P}`,k=h(S);return k===S?P:k},y=P=>typeof P=="string"?P.replace(/<SEP>/g,`;
`):typeof P=="string"?P:JSON.stringify(P,null,2),b=y(e),R=n||y(e);return d&&(t==="description"||t==="entity_id"||t==="keywords")?g.jsx(yg,{name:t,value:e,onClick:r,nodeId:a,entityId:i,edgeId:o,dynamicId:l,entityType:s,sourceId:c,targetId:u,isEditable:!0,tooltip:n||(typeof e=="string"?e:JSON.stringify(e,null,2))}):g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-primary/60 tracking-wide whitespace-nowrap",children:f(t)}),":",g.jsx(Ys,{className:"hover:bg-primary/20 rounded p-1 overflow-hidden text-ellipsis",tooltipClassName:"max-w-96 -translate-x-13",text:b,tooltip:R,side:"left",onClick:r})]})},Sg=({node:t})=>{const{t:e}=Se(),r=()=>{Z.getState().triggerNodeExpand(t.id)},n=()=>{Z.getState().triggerNodePrune(t.id)};return g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsx("h3",{className:"text-md pl-1 font-bold tracking-wide text-blue-700",children:e("graphPanel.propertiesView.node.title")}),g.jsxs("div",{className:"flex gap-3",children:[g.jsx(be,{size:"icon",variant:"ghost",className:"h-7 w-7 border border-gray-400 hover:bg-gray-200 dark:border-gray-600 dark:hover:bg-gray-700",onClick:r,tooltip:e("graphPanel.propertiesView.node.expandNode"),children:g.jsx(tu,{className:"h-4 w-4 text-gray-700 dark:text-gray-300"})}),g.jsx(be,{size:"icon",variant:"ghost",className:"h-7 w-7 border border-gray-400 hover:bg-gray-200 dark:border-gray-600 dark:hover:bg-gray-700",onClick:n,tooltip:e("graphPanel.propertiesView.node.pruneNode"),children:g.jsx(Tu,{className:"h-4 w-4 text-gray-900 dark:text-gray-300"})})]})]}),g.jsxs("div",{className:"bg-primary/5 max-h-96 overflow-auto rounded p-1",children:[g.jsx(He,{name:e("graphPanel.propertiesView.node.id"),value:String(t.id)}),g.jsx(He,{name:e("graphPanel.propertiesView.node.labels"),value:t.labels.join(", "),onClick:()=>{Z.getState().setSelectedNode(t.id,!0)}}),g.jsx(He,{name:e("graphPanel.propertiesView.node.degree"),value:t.degree})]}),g.jsx("h3",{className:"text-md pl-1 font-bold tracking-wide text-amber-700",children:e("graphPanel.propertiesView.node.properties")}),g.jsx("div",{className:"bg-primary/5 max-h-96 overflow-auto rounded p-1",children:Object.keys(t.properties).sort().map(a=>a==="created_at"?null:g.jsx(He,{name:a,value:t.properties[a],nodeId:String(t.id),entityId:t.properties.entity_id,entityType:"node",isEditable:a==="description"||a==="entity_id"},a))}),t.relationships.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("h3",{className:"text-md pl-1 font-bold tracking-wide text-emerald-700",children:e("graphPanel.propertiesView.node.relationships")}),g.jsx("div",{className:"bg-primary/5 max-h-96 overflow-auto rounded p-1",children:t.relationships.map(({type:a,id:o,label:l})=>g.jsx(He,{name:a,value:l,onClick:()=>{Z.getState().setSelectedNode(o,!0)}},o))})]})]})},_g=({edge:t})=>{const{t:e}=Se();return g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx("h3",{className:"text-md pl-1 font-bold tracking-wide text-violet-700",children:e("graphPanel.propertiesView.edge.title")}),g.jsxs("div",{className:"bg-primary/5 max-h-96 overflow-auto rounded p-1",children:[g.jsx(He,{name:e("graphPanel.propertiesView.edge.id"),value:t.id}),t.type&&g.jsx(He,{name:e("graphPanel.propertiesView.edge.type"),value:t.type}),g.jsx(He,{name:e("graphPanel.propertiesView.edge.source"),value:t.sourceNode?t.sourceNode.labels.join(", "):t.source,onClick:()=>{Z.getState().setSelectedNode(t.source,!0)}}),g.jsx(He,{name:e("graphPanel.propertiesView.edge.target"),value:t.targetNode?t.targetNode.labels.join(", "):t.target,onClick:()=>{Z.getState().setSelectedNode(t.target,!0)}})]}),g.jsx("h3",{className:"text-md pl-1 font-bold tracking-wide text-amber-700",children:e("graphPanel.propertiesView.edge.properties")}),g.jsx("div",{className:"bg-primary/5 max-h-96 overflow-auto rounded p-1",children:Object.keys(t.properties).sort().map(r=>{var n,a;return r==="created_at"?null:g.jsx(He,{name:r,value:t.properties[r],edgeId:String(t.id),dynamicId:String(t.dynamicId),entityType:"edge",sourceId:((n=t.sourceNode)==null?void 0:n.properties.entity_id)||t.source,targetId:((a=t.targetNode)==null?void 0:a.properties.entity_id)||t.target,isEditable:r==="description"||r==="keywords"},r)})})]})},Eg=()=>{const{t}=Se(),e=te.use.graphQueryMaxDepth(),r=te.use.graphMaxNodes();return g.jsxs("div",{className:"absolute bottom-4 left-[calc(1rem+2.5rem)] flex items-center gap-2 text-xs text-gray-400",children:[g.jsxs("div",{children:[t("graphPanel.sideBar.settings.depth"),": ",e]}),g.jsxs("div",{children:[t("graphPanel.sideBar.settings.max"),": ",r]})]})},Ks=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("bg-card text-card-foreground rounded-xl border shadow",t),...e}));Ks.displayName="Card";const Cg=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("flex flex-col space-y-1.5 p-6",t),...e}));Cg.displayName="CardHeader";const kg=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("leading-none font-semibold tracking-tight",t),...e}));kg.displayName="CardTitle";const Tg=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("text-muted-foreground text-sm",t),...e}));Tg.displayName="CardDescription";const Rg=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("p-6 pt-0",t),...e}));Rg.displayName="CardContent";const Ag=p.forwardRef(({className:t,...e},r)=>g.jsx("div",{ref:r,className:fe("flex items-center p-6 pt-0",t),...e}));Ag.displayName="CardFooter";function Ig(t,e){return p.useReducer((r,n)=>e[r][n]??r,t)}var Hn="ScrollArea",[Qs,Yp]=En(Hn),[jg,Pe]=Qs(Hn),Js=p.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,s]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState(null),[f,y]=p.useState(null),[b,R]=p.useState(null),[P,S]=p.useState(0),[k,A]=p.useState(0),[j,D]=p.useState(!1),[v,_]=p.useState(!1),x=Ye(e,I=>s(I)),T=Vi(a);return g.jsx(jg,{scope:r,type:n,dir:T,scrollHideDelay:o,scrollArea:i,viewport:c,onViewportChange:u,content:d,onContentChange:h,scrollbarX:f,onScrollbarXChange:y,scrollbarXEnabled:j,onScrollbarXEnabledChange:D,scrollbarY:b,onScrollbarYChange:R,scrollbarYEnabled:v,onScrollbarYEnabledChange:_,onCornerWidthChange:S,onCornerHeightChange:A,children:g.jsx(Ee.div,{dir:T,...l,ref:x,style:{position:"relative","--radix-scroll-area-corner-width":P+"px","--radix-scroll-area-corner-height":k+"px",...t.style}})})});Js.displayName=Hn;var Zs="ScrollAreaViewport",ei=p.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Pe(Zs,r),i=p.useRef(null),s=Ye(e,i,l.onViewportChange);return g.jsxs(g.Fragment,{children:[g.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),g.jsx(Ee.div,{"data-radix-scroll-area-viewport":"",...o,ref:s,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...t.style},children:g.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ei.displayName=Zs;var Ve="ScrollAreaScrollbar",Bn=p.forwardRef((t,e)=>{const{forceMount:r,...n}=t,a=Pe(Ve,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return p.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?g.jsx(Ng,{...n,ref:e,forceMount:r}):a.type==="scroll"?g.jsx(Lg,{...n,ref:e,forceMount:r}):a.type==="auto"?g.jsx(ti,{...n,ref:e,forceMount:r}):a.type==="always"?g.jsx(Vn,{...n,ref:e}):null});Bn.displayName=Ve;var Ng=p.forwardRef((t,e)=>{const{forceMount:r,...n}=t,a=Pe(Ve,t.__scopeScrollArea),[o,l]=p.useState(!1);return p.useEffect(()=>{const i=a.scrollArea;let s=0;if(i){const c=()=>{window.clearTimeout(s),l(!0)},u=()=>{s=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",c),i.addEventListener("pointerleave",u),()=>{window.clearTimeout(s),i.removeEventListener("pointerenter",c),i.removeEventListener("pointerleave",u)}}},[a.scrollArea,a.scrollHideDelay]),g.jsx(_t,{present:r||o,children:g.jsx(ti,{"data-state":o?"visible":"hidden",...n,ref:e})})}),Lg=p.forwardRef((t,e)=>{const{forceMount:r,...n}=t,a=Pe(Ve,t.__scopeScrollArea),o=t.orientation==="horizontal",l=pr(()=>s("SCROLL_END"),100),[i,s]=Ig("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(i==="idle"){const c=window.setTimeout(()=>s("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(c)}},[i,a.scrollHideDelay,s]),p.useEffect(()=>{const c=a.viewport,u=o?"scrollLeft":"scrollTop";if(c){let d=c[u];const h=()=>{const f=c[u];d!==f&&(s("SCROLL"),l()),d=f};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[a.viewport,o,s,l]),g.jsx(_t,{present:r||i!=="hidden",children:g.jsx(Vn,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Ce(t.onPointerEnter,()=>s("POINTER_ENTER")),onPointerLeave:Ce(t.onPointerLeave,()=>s("POINTER_LEAVE"))})})}),ti=p.forwardRef((t,e)=>{const r=Pe(Ve,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=p.useState(!1),i=t.orientation==="horizontal",s=pr(()=>{if(r.viewport){const c=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;l(i?c:u)}},10);return St(r.viewport,s),St(r.content,s),g.jsx(_t,{present:n||o,children:g.jsx(Vn,{"data-state":o?"visible":"hidden",...a,ref:e})})}),Vn=p.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,a=Pe(Ve,t.__scopeScrollArea),o=p.useRef(null),l=p.useRef(0),[i,s]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=si(i.viewport,i.content),u={...n,sizes:i,onSizesChange:s,hasThumb:c>0&&c<1,onThumbChange:h=>o.current=h,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:h=>l.current=h};function d(h,f){return Mg(h,l.current,i,f)}return r==="horizontal"?g.jsx(zg,{...u,ref:e,onThumbPositionChange:()=>{if(a.viewport&&o.current){const h=a.viewport.scrollLeft,f=la(h,i,a.dir);o.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:h=>{a.viewport&&(a.viewport.scrollLeft=h)},onDragScroll:h=>{a.viewport&&(a.viewport.scrollLeft=d(h,a.dir))}}):r==="vertical"?g.jsx(Pg,{...u,ref:e,onThumbPositionChange:()=>{if(a.viewport&&o.current){const h=a.viewport.scrollTop,f=la(h,i);o.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:h=>{a.viewport&&(a.viewport.scrollTop=h)},onDragScroll:h=>{a.viewport&&(a.viewport.scrollTop=d(h))}}):null}),zg=p.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Pe(Ve,t.__scopeScrollArea),[l,i]=p.useState(),s=p.useRef(null),c=Ye(e,s,o.onScrollbarXChange);return p.useEffect(()=>{s.current&&i(getComputedStyle(s.current))},[s]),g.jsx(ni,{"data-orientation":"horizontal",...a,ref:c,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":gr(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.x),onDragScroll:u=>t.onDragScroll(u.x),onWheelScroll:(u,d)=>{if(o.viewport){const h=o.viewport.scrollLeft+u.deltaX;t.onWheelScroll(h),li(h,d)&&u.preventDefault()}},onResize:()=>{s.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:s.current.clientWidth,paddingStart:tr(l.paddingLeft),paddingEnd:tr(l.paddingRight)}})}})}),Pg=p.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Pe(Ve,t.__scopeScrollArea),[l,i]=p.useState(),s=p.useRef(null),c=Ye(e,s,o.onScrollbarYChange);return p.useEffect(()=>{s.current&&i(getComputedStyle(s.current))},[s]),g.jsx(ni,{"data-orientation":"vertical",...a,ref:c,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":gr(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.y),onDragScroll:u=>t.onDragScroll(u.y),onWheelScroll:(u,d)=>{if(o.viewport){const h=o.viewport.scrollTop+u.deltaY;t.onWheelScroll(h),li(h,d)&&u.preventDefault()}},onResize:()=>{s.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:s.current.clientHeight,paddingStart:tr(l.paddingTop),paddingEnd:tr(l.paddingBottom)}})}})}),[Dg,ri]=Qs(Ve),ni=p.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:s,onDragScroll:c,onWheelScroll:u,onResize:d,...h}=t,f=Pe(Ve,r),[y,b]=p.useState(null),R=Ye(e,x=>b(x)),P=p.useRef(null),S=p.useRef(""),k=f.viewport,A=n.content-n.viewport,j=ct(u),D=ct(s),v=pr(d,10);function _(x){if(P.current){const T=x.clientX-P.current.left,I=x.clientY-P.current.top;c({x:T,y:I})}}return p.useEffect(()=>{const x=T=>{const I=T.target;(y==null?void 0:y.contains(I))&&j(T,A)};return document.addEventListener("wheel",x,{passive:!1}),()=>document.removeEventListener("wheel",x,{passive:!1})},[k,y,A,j]),p.useEffect(D,[n,D]),St(y,v),St(f.content,v),g.jsx(Dg,{scope:r,scrollbar:y,hasThumb:a,onThumbChange:ct(o),onThumbPointerUp:ct(l),onThumbPositionChange:D,onThumbPointerDown:ct(i),children:g.jsx(Ee.div,{...h,ref:R,style:{position:"absolute",...h.style},onPointerDown:Ce(t.onPointerDown,x=>{x.button===0&&(x.target.setPointerCapture(x.pointerId),P.current=y.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),_(x))}),onPointerMove:Ce(t.onPointerMove,_),onPointerUp:Ce(t.onPointerUp,x=>{const T=x.target;T.hasPointerCapture(x.pointerId)&&T.releasePointerCapture(x.pointerId),document.body.style.webkitUserSelect=S.current,f.viewport&&(f.viewport.style.scrollBehavior=""),P.current=null})})})}),er="ScrollAreaThumb",oi=p.forwardRef((t,e)=>{const{forceMount:r,...n}=t,a=ri(er,t.__scopeScrollArea);return g.jsx(_t,{present:r||a.hasThumb,children:g.jsx(Og,{ref:e,...n})})}),Og=p.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Pe(er,r),l=ri(er,r),{onThumbPositionChange:i}=l,s=Ye(e,d=>l.onThumbChange(d)),c=p.useRef(void 0),u=pr(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const d=o.viewport;if(d){const h=()=>{if(u(),!c.current){const f=$g(d,i);c.current=f,i()}};return i(),d.addEventListener("scroll",h),()=>d.removeEventListener("scroll",h)}},[o.viewport,u,i]),g.jsx(Ee.div,{"data-state":l.hasThumb?"visible":"hidden",...a,ref:s,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Ce(t.onPointerDownCapture,d=>{const f=d.target.getBoundingClientRect(),y=d.clientX-f.left,b=d.clientY-f.top;l.onThumbPointerDown({x:y,y:b})}),onPointerUp:Ce(t.onPointerUp,l.onThumbPointerUp)})});oi.displayName=er;var Un="ScrollAreaCorner",ai=p.forwardRef((t,e)=>{const r=Pe(Un,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?g.jsx(Gg,{...t,ref:e}):null});ai.displayName=Un;var Gg=p.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,a=Pe(Un,r),[o,l]=p.useState(0),[i,s]=p.useState(0),c=!!(o&&i);return St(a.scrollbarX,()=>{var d;const u=((d=a.scrollbarX)==null?void 0:d.offsetHeight)||0;a.onCornerHeightChange(u),s(u)}),St(a.scrollbarY,()=>{var d;const u=((d=a.scrollbarY)==null?void 0:d.offsetWidth)||0;a.onCornerWidthChange(u),l(u)}),c?g.jsx(Ee.div,{...n,ref:e,style:{width:o,height:i,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function tr(t){return t?parseInt(t,10):0}function si(t,e){const r=t/e;return isNaN(r)?0:r}function gr(t){const e=si(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function Mg(t,e,r,n="ltr"){const a=gr(r),o=a/2,l=e||o,i=a-l,s=r.scrollbar.paddingStart+l,c=r.scrollbar.size-r.scrollbar.paddingEnd-i,u=r.content-r.viewport,d=n==="ltr"?[0,u]:[u*-1,0];return ii([s,c],d)(t)}function la(t,e,r="ltr"){const n=gr(e),a=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-a,l=e.content-e.viewport,i=o-n,s=r==="ltr"?[0,l]:[l*-1,0],c=qi(t,s);return ii([0,l],[0,i])(c)}function ii(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function li(t,e){return t>0&&t<e}var $g=(t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function a(){const o={left:t.scrollLeft,top:t.scrollTop},l=r.left!==o.left,i=r.top!==o.top;(l||i)&&e(),r=o,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function pr(t,e){const r=ct(t),n=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(n.current),[]),p.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function St(t,e){const r=ct(e);Ui(()=>{let n=0;if(t){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(t),()=>{window.cancelAnimationFrame(n),a.unobserve(t)}}},[t,r])}var ci=Js,Fg=ei,Hg=ai;const ui=p.forwardRef(({className:t,children:e,...r},n)=>g.jsxs(ci,{ref:n,className:fe("relative overflow-hidden",t),...r,children:[g.jsx(Fg,{className:"h-full w-full rounded-[inherit]",children:e}),g.jsx(di,{}),g.jsx(Hg,{})]}));ui.displayName=ci.displayName;const di=p.forwardRef(({className:t,orientation:e="vertical",...r},n)=>g.jsx(Bn,{ref:n,orientation:e,className:fe("flex touch-none transition-colors select-none",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:g.jsx(oi,{className:"bg-border relative flex-1 rounded-full"})}));di.displayName=Bn.displayName;const Bg=({className:t})=>{const{t:e}=Se(),r=Z.use.typeColorMap();return!r||r.size===0?null:g.jsxs(Ks,{className:`p-2 max-w-xs ${t}`,children:[g.jsx("h3",{className:"text-sm font-medium mb-2",children:e("graphPanel.legend")}),g.jsx(ui,{className:"max-h-80",children:g.jsx("div",{className:"flex flex-col gap-1",children:Array.from(r.entries()).map(([n,a])=>g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"w-4 h-4 rounded-full",style:{backgroundColor:a}}),g.jsx("span",{className:"text-xs truncate",title:n,children:e(`graphPanel.nodeTypes.${n.toLowerCase().replace(/\s+/g,"")}`,n)})]},n))})})]})},Vg=()=>{const{t}=Se(),e=te.use.showLegend(),r=te.use.setShowLegend(),n=p.useCallback(()=>{r(!e)},[e,r]);return g.jsx(be,{variant:ze,onClick:n,tooltip:t("graphPanel.sideBar.legendControl.toggleLegend"),size:"icon",children:g.jsx(Gc,{})})},Ug=t=>({allowInvalidContainer:!0,defaultNodeType:"default",defaultEdgeType:"curvedNoArrow",renderEdgeLabels:!1,edgeProgramClasses:{arrow:Ti,curvedArrow:Fd,curvedNoArrow:ur()},nodeProgramClasses:{default:Ed,circel:ki,point:Ju},labelGridCellSize:60,labelRenderedSizeThreshold:12,enableEdgeEvents:!0,labelColor:{color:t?en:Kn,attribute:"labelColor"},edgeLabelColor:{color:t?en:Kn,attribute:"labelColor"},edgeLabelSize:8,labelSize:12}),qg=()=>{const t=ya(),e=We(),[r,n]=p.useState(null);return p.useEffect(()=>{t({downNode:a=>{n(a.node),e.getGraph().setNodeAttribute(a.node,"highlighted",!0)},mousemovebody:a=>{if(!r)return;const o=e.viewportToGraph(a);e.getGraph().setNodeAttribute(r,"x",o.x),e.getGraph().setNodeAttribute(r,"y",o.y),a.preventSigmaDefault(),a.original.preventDefault(),a.original.stopPropagation()},mouseup:()=>{r&&(n(null),e.getGraph().removeNodeAttribute(r,"highlighted"))},mousedown:a=>{a.original.buttons!==0&&!e.getCustomBBox()&&e.setCustomBBox(e.getBBox())}})},[t,e,r]),null},Kp=()=>{const[t,e]=p.useState(!1),r=p.useRef(null),n=p.useRef(""),a=Z.use.selectedNode(),o=Z.use.focusedNode(),l=Z.use.moveToSelectedNode(),i=Z.use.isFetching(),s=te.use.showPropertyPanel(),c=te.use.showNodeSearchBar(),u=te.use.enableNodeDrag(),d=te.use.showLegend(),h=te.use.theme(),f=p.useMemo(()=>Ug(h==="dark"),[h]);p.useEffect(()=>{if(n.current&&n.current!==h){e(!0),console.log("Theme switching detected:",n.current,"->",h);const k=setTimeout(()=>{e(!1),console.log("Theme switching completed")},150);return()=>clearTimeout(k)}n.current=h,console.log("Initialized sigma settings for theme:",h)},[h]),p.useEffect(()=>()=>{const S=Z.getState().sigmaInstance;if(S)try{S.kill(),Z.getState().setSigmaInstance(null),console.log("Cleared sigma instance on Graphviewer unmount")}catch(k){console.error("Error cleaning up sigma instance:",k)}},[]);const y=p.useCallback(S=>{S===null?Z.getState().setFocusedNode(null):S.type==="nodes"&&Z.getState().setFocusedNode(S.id)},[]),b=p.useCallback(S=>{S===null?Z.getState().setSelectedNode(null):S.type==="nodes"&&Z.getState().setSelectedNode(S.id,!0)},[]),R=p.useMemo(()=>o??a,[o,a]),P=p.useMemo(()=>a?{type:"nodes",id:a}:null,[a]);return g.jsxs("div",{className:"relative h-full w-full overflow-hidden",children:[g.jsxs(Ri,{settings:f,className:"!bg-background !size-full overflow-hidden",ref:r,children:[g.jsx(lh,{}),u&&g.jsx(qg,{}),g.jsx(Hd,{node:R,move:l}),g.jsxs("div",{className:"absolute top-2 left-2 flex items-start gap-2",children:[g.jsx(Hh,{}),c&&!t&&g.jsx(Mh,{value:P,onFocus:y,onChange:b})]}),g.jsxs("div",{className:"bg-background/60 absolute bottom-2 left-2 flex flex-col rounded-xl border-2 backdrop-blur-lg",children:[g.jsx(sh,{}),g.jsx(ch,{}),g.jsx(uh,{}),g.jsx(Vg,{}),g.jsx(bh,{})]}),s&&g.jsx("div",{className:"absolute top-2 right-2",children:g.jsx(bg,{})}),d&&g.jsx("div",{className:"absolute bottom-10 right-2",children:g.jsx(Bg,{className:"bg-background/60 backdrop-blur-lg"})}),g.jsx(Eg,{})]}),(i||t)&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:g.jsxs("div",{className:"text-center",children:[g.jsx("div",{className:"mb-2 h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),g.jsx("p",{children:t?"Switching Theme...":"Loading Graph Data..."})]})})]})};export{Ep as $,jp as A,be as B,kp as C,Uu as D,Lp as E,Pp as F,Sp as G,xp as H,Yt as I,_p as J,fp as K,Ka as L,Rn as M,te as N,Hp as O,gp as P,op as Q,Cg as R,ui as S,Vp as T,Up as U,Rg as V,xu as W,Mu as X,wp as Y,_u as Z,Cp as _,Ap as a,Op as a0,Ua as a1,qa as a2,Wa as a3,In as a4,ih as a5,Gp as a6,Np as a7,al as a8,sp as a9,ap as aa,Jg as ab,Xs as ac,Fp as ad,io as ae,rp as af,np as ag,jn as ah,Nn as ai,$p as aj,cr as ak,Xt as al,Zg as am,qp as an,tp as ao,Dp as ap,Mp as aq,Aa as ar,Zr as as,mp as at,Kp as au,dp as av,hp as aw,pp as ax,vp as ay,Ya as b,fe as c,Ks as d,kg as e,Tg as f,nt as g,zp as h,ip as i,or as j,Wp as k,Za as l,es as m,rs as n,ns as o,lp as p,cp as q,Gs as r,ep as s,ts as t,Se as u,up as v,Bp as w,Tp as x,Rp as y,Ip as z};