import Listener from "./listener";

class MultiFacetBuilder {
  constructor(options, start = [], joinOperator = "OR") {
    this.current = start;
    this.options = options;
    this.joinOperator = joinOperator;
    this.listener = new Listener();
  }

  register(listener) {
    return this.listener.listen(listener);
  }

  notify() {
    this.listener.notify(l => {
      l(this);
    });
  }

  set(name, on) {
    if (on) {
      this.current = this.current.concat(name);
    } else {
      this.current = this.current.filter(n => n !== current);;
    }
    this.notify();
  }

  isSet(name) {
    return this.current.indexOf(name) !== -1;
  }

  get() {
    return this.current;
  }

  filter() {
    return "";
  }
}

export default MultiFacetBuilder;

@@ -539,17 +539,13 @@
 !== 
-current);
+name)
 ;%0A  
@@ -707,10 +707,108 @@
 urn 
-%22%22
+this.current%0A      .map(c =%3E %22(%22 + this.options%5Bc%5D + %22)%22)%0A      .join(%22 %22 + this.joinOperator + %22 %22)
 ;%0A  

implement filter for multifacetbulider, fix error