{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH1/src/internal/individuals-as-points/venn/force-center-simulation.js"],"names":["d3","ForceCenterSimulation","constructor","vennDiagram","forceCenters","forceCenterConnections","simulation","_createSimulation","start","setTimeout","alpha","restart","stop","update","force","forceLink","id","d","uuid","forceX","forceY","forceSimulation","forceManyBody","on","_tick","draw"],"mappings":";;;;;;AAAOA,Q;;;;;;;;;;;;;;;;;;AAEQ,YAAMC,qBAAN,CAA4B;;AAEzCC,oBAAYC,WAAZ,EAAyBC,YAAzB,EAAuCC,sBAAvC,EAA+D;AAC7D,eAAKF,WAAL,GAAmBA,WAAnB;AACA,eAAKG,UAAL,GAAkB,KAAKC,iBAAL,CAAuBH,YAAvB,EAAqCC,sBAArC,CAAlB;AACD;;AAED;AACA;AACA;;AAEAG,gBAAQ;AACNC,qBAAW,MAAM,KAAKH,UAAL,CAAgBI,KAAhB,CAAsB,GAAtB,EAA2BC,OAA3B,EAAjB,EAAuD,GAAvD;AACD;;AAEDC,eAAO;AACL,eAAKN,UAAL,CAAgBM,IAAhB;AACD;;AAEDC,eAAOR,sBAAP,EAA+B;AAC7B,eAAKC,UAAL,CACGQ,KADH,CACS,OADT,EACkBd,GAAGe,SAAH,CAAaV,sBAAb,EAAqCW,EAArC,CAAwCC,KAAKA,EAAEC,IAA/C,CADlB,EAEGJ,KAFH,CAES,GAFT,EAEcd,GAAGmB,MAAH,EAFd,EAGGL,KAHH,CAGS,GAHT,EAGcd,GAAGoB,MAAH,EAHd;;AAKA,eAAKZ,KAAL;AACD;;AAED;AACA;AACA;;AAEAD,0BAAkBH,YAAlB,EAAgCC,sBAAhC,EAAwD;AACtD,iBAAOL,GAAGqB,eAAH,CAAmBjB,YAAnB,EACJU,KADI,CACE,MADF,EACUd,GAAGe,SAAH,CAAaV,sBAAb,EAAqCW,EAArC,CAAwCC,KAAKA,EAAEC,IAA/C,CADV,EAEJJ,KAFI,CAEE,QAFF,EAEYd,GAAGsB,aAAH,EAFZ,EAGJR,KAHI,CAGE,GAHF,EAGOd,GAAGmB,MAAH,EAHP,EAIJL,KAJI,CAIE,GAJF,EAIOd,GAAGoB,MAAH,EAJP,EAKJG,EALI,CAKD,MALC,EAKO,MAAM,KAAKC,KAAL,CAAW,KAAKrB,WAAhB,CALb,CAAP;AAOD;;AAEDqB,cAAMrB,WAAN,EAAmB;AACjBA,sBAAYsB,IAAZ;AACD;AA5CwC;;yBAAtBxB,qB","file":"force-center-simulation.js","sourcesContent":["import d3 from \"src/external/d3.v5.js\";\n\nexport default class ForceCenterSimulation {\n  \n  constructor(vennDiagram, forceCenters, forceCenterConnections) {\n    this.vennDiagram = vennDiagram\n    this.simulation = this._createSimulation(forceCenters, forceCenterConnections)\n  }\n  \n  // ------------------------------------------\n  // Public Methods\n  // ------------------------------------------\n  \n  start() {\n    setTimeout(() => this.simulation.alpha(0.5).restart(), 250);\n  }\n  \n  stop() {\n    this.simulation.stop()\n  }\n  \n  update(forceCenterConnections) {\n    this.simulation\n      .force('links', d3.forceLink(forceCenterConnections).id(d => d.uuid))\n      .force(\"x\", d3.forceX())\n      .force(\"y\", d3.forceY())\n    \n    this.start()\n  }\n    \n  // ------------------------------------------\n  // Private Methods\n  // ------------------------------------------\n  \n  _createSimulation(forceCenters, forceCenterConnections) {\n    return d3.forceSimulation(forceCenters)\n      .force(\"link\", d3.forceLink(forceCenterConnections).id(d => d.uuid))\n      .force(\"charge\", d3.forceManyBody())\n      .force(\"x\", d3.forceX())\n      .force(\"y\", d3.forceY())\n      .on('tick', () => this._tick(this.vennDiagram) )\n\n  }\n  \n  _tick(vennDiagram) {\n    vennDiagram.draw()\n  }\n}"]}