"use strict";(self.webpackChunkjupyterlab_plugin_graph=self.webpackChunkjupyterlab_plugin_graph||[]).push([[651],{651:(e,t,a)=>{a.r(t),a.d(t,{default:()=>m});var n=a(185),i=a(968),s=a(168);class l{constructor(e){this._filter="",this._requires=!0,this._optional=!0,this._filterChanged=new s.Signal(this),this._plugins=e.plugins}get plugins(){return this._plugins}get filter(){return this._filter}set filter(e){this._filter=e,this._filterChanged.emit(void 0)}get requires(){return this._requires}set requires(e){this._requires=e,this._filterChanged.emit(void 0)}get optional(){return this._optional}set optional(e){this._optional=e,this._filterChanged.emit(void 0)}get filterChanged(){return this._filterChanged}}var r=a(706),o=a(961),c=a.n(o),d=a(271),h=a.n(d);class p extends r.Widget{constructor(e){super(),this._V=0,this._E=0,this._updated=new s.Signal(this),this._model=e,this._model.filterChanged.connect((()=>this.update()))}get V(){return this._V}get E(){return this._E}get updated(){return this._updated}update(){const{plugins:e,filter:t,requires:a,optional:n}=this._model,i=[],s=[];Object.keys(e).forEach((l=>{var r,o;let c=l;e[l].provides&&(c=e[l].provides.name);const d=e=>""===t||!!e.toLowerCase().match(t.toLowerCase()),h=e=>{i.push({data:{id:e,name:e}})};d(c)&&h(c),a&&(null!==(r=e[l].requires)&&void 0!==r?r:[]).forEach((e=>{(d(e.name)||d(c))&&(h(e.name),h(c),s.push({data:{source:c,target:e.name},style:{"line-style":"solid","line-color":"#F5A636"},classes:"top-center"}))})),n&&(null!==(o=e[l].optional)&&void 0!==o?o:[]).forEach((e=>{(d(e.name)||d(c))&&(h(e.name),h(c),s.push({data:{source:c,target:e.name},style:{"line-style":"dashed","line-color":"#0072B3"},classes:"top-center"}))}))})),this._cy=c()({layout:(()=>{const e=new Set;return i.forEach((t=>{e.add(t.data.name)})),e.size>=50?{name:"circle",nodeDimensionsIncludeLabels:!0,padding:5,spacingFactor:.1,avoidOverlap:!0}:{name:"concentric",nodeDimensionsIncludeLabels:!0,spacingFactor:.5,avoidOverlap:!0}})(),container:this.node,elements:{nodes:i,edges:s},style:[{selector:"node",style:{width:"label",shape:"rectangle",content:"data(name)","padding-bottom":"10px","text-valign":"center","background-color":"#81bc00","background-opacity":.4,"border-width":1,"border-color":"black"}},{selector:"edge",style:{"curve-style":"bezier","target-arrow-shape":"triangle"}}]}),this._V=this._cy.nodes().length,this._E=this._cy.edges().length,this._updated.emit(void 0)}onResize(){this._cy&&(this._cy.resize(),this._cy.fit())}}const u=e=>{const{model:t}=e,[a,n]=(0,d.useState)(t.filter);return h().createElement(i.InputGroup,{className:"filter",type:"text",placeholder:"Filter...",onChange:e=>{const a=e.target.value;n(a),t.filter=a},value:a})};class g extends n.MainAreaWidget{constructor(e){super({content:new p(e.model)});const t=e.model,a=n.ReactWidget.create(h().createElement(u,{model:t}));this.toolbar.addItem("filter",a);const i=n.ReactWidget.create(h().createElement("label",null,h().createElement("input",{style:{verticalAlign:"middle"},name:"requires",type:"checkbox",defaultChecked:!0,onChange:e=>{t.requires=e.target.checked}}),"Requires"));this.toolbar.addItem("requires",i);const s=n.ReactWidget.create(h().createElement("label",null,h().createElement("input",{style:{verticalAlign:"middle"},name:"optional",type:"checkbox",defaultChecked:!0,onChange:e=>{t.optional=e.target.checked}}),"Optional"));this.toolbar.addItem("optional",s),this.toolbar.addItem("spacer",n.Toolbar.createSpacerItem());const l=n.ReactWidget.create(h().createElement(n.UseSignal,{signal:this.content.updated},(()=>h().createElement("div",{style:{marginRight:"5px"}},this.content.V," plugins"))));this.toolbar.addItem("nodes",l);const r=n.ReactWidget.create(h().createElement(n.UseSignal,{signal:this.content.updated},(()=>h().createElement("div",{style:{marginRight:"5px"}},this.content.E," connections"))));this.toolbar.addItem("edges",r)}}const m={id:"jupyterlab-plugin-graph",autoStart:!0,optional:[n.ICommandPalette],activate:(e,t)=>{const{commands:a,shell:n}=e;e.restored.then((()=>{const s=e._pluginMap,r=new l({plugins:s}),o="jupyterlab-plugin-graph:open";a.addCommand(o,{label:"Plugin Dependency Graph",caption:"Open the plugin dependency graph",execute:()=>{const e=new g({model:r});e.title.label="Plugin Graph",e.title.icon=i.buildIcon,n.add(e,"main"),e.content.update()}}),t&&t.addItem({command:o,category:"Developer"})}))}}}}]);