{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH-stable/components/bp2019-pane.js"],"names":["Windows","deepCopy","State","SelectAction","FilterAction","Bp2019Pane","initialize","childPanes","state","paneCloseButton","get","container","data","individualsSelection","parent","addEventListener","event","stopPropagation","setGeoData","detail","geoData","setData","selectAction","dataProcessor","colorStore","filterAction","setIncludeStop","setDataProcessor","updateState","applyState","fromState","propagateState","dispatchEvent","Event","applyActionFromTop","action","startingPane","getParent","applyAction","setParent","newParent","addVisualization","visualization","componentName","visualizationType","appendChild","_bindListeners","colorAction","inspectAction","localActions","forEach","setColorStore","child","setGlobalControlWidget","globalControlWidget","getData","getVisualizationType","getState","setState","getIndividualsSelection","setIndividualsSelection","addChild","push","removeChild","index","indexOf","splice","deleteFreehandSelectionChildren","freehandSelection","i","length","color","selectionColor","onCloseButtonClicked","setTitleBarColor","style","background","setFocus","classList","remove","add","setLocalControls","removeFocus","unsetLocalControls","evt","pane","windowBarExtent","lively","getExtent","windowBarHeight","y","clearTimeout","resizeTimer","setTimeout","visualizationExtent","subPt","pt","setExtent","controlWidgetExtent","updateLocalActions"],"mappings":";;;;;;AAAOA,a;;AACCC,c,gDAAAA,Q;;AACAC,W,sDAAAA,K;;AAECC,kB,kDAAAA,Y;AAAcC,kB,kDAAAA,Y;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAER,YAAMC,UAAN,SAAyBL,OAAzB,CAAiC;AAC9CM,qBAAa;AACX,gBAAMA,UAAN;AACA,eAAKC,UAAL,GAAkB,EAAlB;AACA,eAAKC,KAAL,GAAa,IAAIN,KAAJ,EAAb;AACA,eAAKO,eAAL,GAAuB,KAAKC,GAAL,CAAS,oBAAT,CAAvB;AACA,eAAKC,SAAL,GAAiB,KAAKD,GAAL,CAAS,SAAT,CAAjB;AACA,eAAKE,IAAL,GAAY,EAAZ;AACA,eAAKC,oBAAL,GAA4B,EAA5B;AACA,eAAKC,MAAL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AP,CAAU,CAAV,EAAaP,eAAb,CAAtD,CAAqF;AAArF,eAA1B,CACA,KAAK/C,aAAL,CAAmBuD,SAAnB,CAA6BH,mBAA7B;AACA,kBAAI,KAAKxC,mBAAT,EAA8B;AAC5B,oBAAI4C,sBAAsBX,OAAOC,SAAP,CAAiB,IAAjB,CAA1B;AACA,qBAAKlC,mBAAL,CAAyB2C,SAAzB,CAAmCV,OAAOS,EAAP,CAAU,GAAV,EAAeE,oBAAoBR,CAAnC,CAAnC;AACD;AACF,aAPkB,EAOhB,GAPgB,CAAnB;AAQD,WAZD;;AAcA,eAAK3E,gBAAL,CAAsB,uBAAtB,EAAgDC,KAAD,IAAW;AACxDA,kBAAMC,eAAN;AACA,iBAAKT,KAAL,CAAW2F,kBAAX,CAA8BnF,MAAMG,MAAN,CAAa8B,YAA3C;AACD,WAHD;AAID;;AAjN6C;;yBAA3B5C,U","file":"bp2019-pane.js","sourcesContent":["import Windows from 'src/components/widgets/lively-window.js';\nimport {deepCopy} from \"../src/internal/individuals-as-points/common/utils.js\"\nimport {State} from \"../src/internal/individuals-as-points/common/actionState.js\"\n\nimport { SelectAction, FilterAction } from \"../src/internal/individuals-as-points/common/actions.js\"\n\nexport default class Bp2019Pane extends Windows {\n  initialize() {\n    super.initialize()\n    this.childPanes = []\n    this.state = new State()\n    this.paneCloseButton = this.get(\"#pane-close-button\")\n    this.container = this.get(\".window\")\n    this.data = []\n    this.individualsSelection = {}\n    this.parent = \"parent\"\n    \n    this.addEventListener(\"data-loaded\", (event) => {\n      event.stopPropagation()\n      \n      this.setGeoData(event.detail.geoData)\n      this.setData(event.detail.data)\n      let selectAction = new SelectAction(new FilterAction(), event.detail.dataProcessor, event.detail.colorStore, true)\n      let filterAction = new FilterAction()\n      filterAction.setIncludeStop(false)\n      filterAction.setDataProcessor(event.detail.dataProcessor)\n      \n      this.state.updateState(event.detail.dataProcessor)\n      this.state.updateState(event.detail.colorStore)\n      this.state.updateState(event.detail.geoData)\n      this.state.updateState(selectAction)\n      this.state.updateState(filterAction)\n      \n      this.applyState(State.fromState(this.state))\n      this.propagateState(State.fromState(this.state))\n    })\n    \n    this.paneCloseButton.addEventListener(\"click\", () => {\n      this.dispatchEvent(new Event(\"click-pane-close-button\"))\n    })\n    \n    this.addEventListener(\"individual-inspected\", (event) => {\n      event.stopPropagation()\n      this.applyActionFromTop(event.detail.action)\n    })\n  }\n  \n  applyActionFromTop(action) {\n    let startingPane = this\n    \n    while(startingPane.getParent() !== \"parent\") {\n      startingPane = startingPane.getParent()\n    }\n    \n    startingPane.applyAction(action)\n  }\n  \n  getParent() {\n    return this.parent\n  }\n  \n  setParent(newParent) {\n    this.parent = newParent\n  }\n    \n  addVisualization(visualization, componentName) {\n    this.visualization = visualization\n    this.visualizationType = componentName\n    this.appendChild(visualization)\n    this._bindListeners()\n  }\n  \n  applyState(state) {\n    this.state = state\n    this.visualization.applyAction(this.state.filterAction)\n    this.visualization.applyAction(this.state.selectAction)\n    this.visualization.applyAction(this.state.colorAction)\n    this.visualization.applyAction(this.state.inspectAction)\n    \n    this.state.localActions.forEach(action => this.visualization.applyAction(action))\n    if (this.visualization.setDataProcessor) {this.visualization.setDataProcessor(this.state.dataProcessor)}\n    if (this.visualization.setColorStore) {this.visualization.setColorStore(this.state.colorStore)}\n    if (this.visualization.setGeoData) {this.visualization.setGeoData(this.state.geoData)}\n  }\n  \n  propagateState(state) {\n    this.childPanes.forEach(child => {\n      child.applyState(State.fromState(state))\n      child.propagateState(State.fromState(state))\n    })\n  }\n  \n  setGeoData(geoData) {\n     if (this.visualization) {\n       if (typeof this.visualization.setGeoData === \"function\") {\n          this.visualization.setGeoData(deepCopy(geoData))\n       }\n    }\n    this.childPanes.forEach(child => {\n      child.setGeoData(deepCopy(geoData))\n    })\n  }\n  \n  async setData(data) {\n    this.data = deepCopy(data)\n    if (this.visualization) {\n      await this.visualization.setData(deepCopy(data))\n    }\n    this.childPanes.forEach(child => {\n      child.setData(deepCopy(data))\n    })\n  }\n  \n  setGlobalControlWidget(globalControlWidget) {\n    this.globalControlWidget = globalControlWidget\n  }\n  \n  getData() {\n    return this.data\n  }\n  \n  getVisualizationType() {\n    return this.visualizationType  \n  }\n  \n  getState() {\n    return this.state\n  }\n  \n  setState(state) {\n    this.state = deepCopy(state)\n  }\n  \n  getIndividualsSelection() {\n    return this.individualsSelection\n  }\n  \n  setIndividualsSelection(individualsSelection) {\n    this.individualsSelection = individualsSelection\n  }\n  \n  addChild(child) {\n    this.childPanes.push(child)\n  }\n  \n  removeChild(child) {\n    const index = this.childPanes.indexOf(child);\n    if (index > -1) {\n      this.childPanes.splice(index, 1);\n    }\n  }\n  \n  deleteFreehandSelectionChildren(freehandSelection) {\n    for (var i = this.childPanes.length - 1; i >= 0; i--) {\n      if (freehandSelection.color === this.childPanes[i].getIndividualsSelection().selectionColor) {\n        //color is chosen randomly, so it's actually not a completely safe way of identifying the panes\n        this.childPanes[i].onCloseButtonClicked()\n        this.removeChild(this.childPanes[i])\n      }\n    }\n  }\n\n  applyAction(action) {\n    this.state.updateState(deepCopy(action))\n    this.applyState(this.state) //this.state\n    \n    this.childPanes.forEach(child => child.applyAction(deepCopy(action)))\n  }\n  \n  setTitleBarColor(color) {\n    this.get(\".window-titlebar\").style.background = color\n  }\n  \n  setFocus() {\n    this.container.classList.remove(\"pane-unselected\")\n    this.container.classList.add(\"pane-selected\")\n    \n    if (typeof this.visualization.setLocalControls === \"function\") {\n        this.visualization.setLocalControls()\n    }\n  }\n  \n  removeFocus() {\n    this.container.classList.add(\"pane-unselected\")\n    this.container.classList.remove(\"pane-selected\")\n    \n    if (typeof this.visualization.setLocalControls === \"function\") {\n        this.visualization.unsetLocalControls()\n    }\n  }\n  \n  async onCloseButtonClicked(evt) {\n    this.childPanes.forEach(pane => pane.onCloseButtonClicked(evt))\n    super.onCloseButtonClicked(evt)\n  }\n  \n  _bindListeners() {\n    this.addEventListener(\"extent-changed\", () => {\n      let windowBarExtent = lively.getExtent(this.get(\".window-titlebar\"))\n      let windowBarHeight = windowBarExtent.y\n      clearTimeout(this.resizeTimer)\n      this.resizeTimer = setTimeout(() => {\n        let visualizationExtent = lively.getExtent(this).subPt(lively.pt(10, 10)).subPt(lively.pt(0, windowBarHeight)) // subtracting the window border\n        this.visualization.setExtent(visualizationExtent) \n        if (this.globalControlWidget) {\n          let controlWidgetExtent = lively.getExtent(this)\n          this.globalControlWidget.setExtent(lively.pt(200, controlWidgetExtent.y))\n        }\n      }, 250);\n    })\n    \n    this.addEventListener(\"local-actions-changed\", (event) => {\n      event.stopPropagation()\n      this.state.updateLocalActions(event.detail.localActions)\n    })\n  }\n\n}"]}