{"version":3,"sources":["https://lively-kernel.org/lively4/swd21-pipes-and-filters/demos/swd21/pipes-and-filters/activeFilter.js"],"names":["ActiveFilter","constructor","pipeToObserve","outputPipe","pipe","activeFilterTimeout","whileCondition","filteredData","sleep","ms","Promise","resolve","setTimeout","activeFilterData","dataFromPipe","popElement","category","addElement","stop"],"mappings":";;;;;;;;AAAe,YAAMA,YAAN,CAAkB;;AAE/BC,oBAAYC,aAAZ,EAA2BC,UAA3B,EAAuC;AACrC,eAAKC,IAAL,GAAYF,aAAZ;AACA,eAAKC,UAAL,GAAkBA,UAAlB;AACA,eAAKE,mBAAL,GAA2B,IAA3B;AACA,eAAKC,cAAL,GAAsB,IAAtB;AACA,eAAKC,YAAL,GAAoB,EAApB;AACD;;AAEDC,cAAMC,EAAN,EAAU;AACR,iBAAO,IAAIC,OAAJ,CAAYC,WAAWC,WAAWD,OAAX,EAAoBF,EAApB,CAAvB,CAAP;AACD;;AAED,cAAMI,gBAAN,GAAyB;AACvB,eAAKP,cAAL,GAAsB,IAAtB;AACA,iBAAO,KAAKA,cAAZ,CAA2B,8BAA3B,EAA2D;AACzD,gBAAIQ,eAAe,KAAKV,IAAL,CAAUW,UAAV,EAAnB;AACA,gBAAGD,YAAH,EAAiB;AACf,kBAAIA,aAAaE,QAAb,KAA0B,OAA9B,EAAuC;AACrC,qBAAKb,UAAL,CAAgBc,UAAhB,CAA2BH,YAA3B;AACD;AACF;AACD,kBAAM,KAAKN,KAAL,CAAW,KAAKH,mBAAhB,CAAN;AACD;AACF;;AAEDa,eAAO;AACL,eAAKZ,cAAL,GAAsB,KAAtB;AACD;AA7B8B;;yBAAZN,Y;;;;;;;;6BAAAA,6C","file":"activeFilter.js","sourcesContent":["export default class ActiveFilter{\n  \n  constructor(pipeToObserve ,outputPipe) {\n    this.pipe = pipeToObserve;\n    this.outputPipe = outputPipe;\n    this.activeFilterTimeout = 1000;\n    this.whileCondition = true;\n    this.filteredData = [];\n  }\n  \n  sleep(ms) {\n    return new Promise(resolve => setTimeout(resolve, ms));\n  }\n  \n  async activeFilterData() {\n    this.whileCondition = true\n    while (this.whileCondition /*&& lively.isInBody(button)*/) {\n      var dataFromPipe = this.pipe.popElement();\n      if(dataFromPipe) {\n        if (dataFromPipe.category === \"fruit\") {\n          this.outputPipe.addElement(dataFromPipe)\n        }\n      }\n      await this.sleep(this.activeFilterTimeout)\n    }\n  }\n  \n  stop() {\n    this.whileCondition = false;\n  }\n}"]}