'use strict';

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _jade_template_fn(locals) {
  locals = locals || {};;;
  var result_of_with = function ($helpers, Array, JSON, Object, String, builder, isAddingPropertyFilter, stagedCustomEvent) {
    var h = require('panel').h;
    var jade_mixins = {};
    jade_mixins['autoresizing-builder-filter-input'] = function (placeholder) {
      var block = this && this.block,
          attributes = this && this.attributes || {};

      return function () {
        var __jade_nodes = [];
        __jade_nodes = __jade_nodes.concat(h("mp-autoresizing-input", {
          "attrs": {
            'focus': true,
            'initial-width': 140,
            'input-style-overrides': JSON.stringify({
              'font-size': '16px'
            }),
            'placeholder': placeholder
          },
          "on": {
            input: $helpers.searchFilterInput
          },
          "hook": {
            insert: $helpers.addBuilderKeydownProxyEl
          },
          "props": {
            value: builder.searchFilter
          }
        }));;
        return __jade_nodes;
      }.call(this);
    };

    var __vjadeSafeCode = function __vjadeSafeCode(code) {
      return code || String(code);
    };
    return {
      value: h("div", {
        "class": {
          'mp-event-selector-wrapper': true
        }
      }, function () {
        var __jade_nodes = [];
        var eventLabel = $helpers.getEventLabel();
        __jade_nodes = __jade_nodes.concat(h("div", {
          "class": {
            'selector-section': true
          }
        }, function () {
          var __jade_nodes = [];
          __jade_nodes = __jade_nodes.concat(h("div", {
            "on": {
              click: $helpers.clickEventName
            },
            "class": {
              'event-clickable': true,
              'selector-event-name': true
            }
          }, function () {
            var __jade_nodes = [];
            __jade_nodes = __jade_nodes.concat($helpers.isEventsBuilderOpen() ? function () {
              var __jade_nodes = [];
              __jade_nodes = __jade_nodes.concat(jade_mixins['autoresizing-builder-filter-input'].call(this, eventLabel));;
              return __jade_nodes;
            }.call(this) : function () {
              var __jade_nodes = [];
              __jade_nodes = __jade_nodes.concat(h("span", [__vjadeSafeCode(eventLabel)]));;
              return __jade_nodes;
            }.call(this));
            __jade_nodes = __jade_nodes.concat(h("div", {
              "class": Object.assign({}, _defineProperty({}, $helpers.ELEMENTS_BY_CSS_CLASS.EVENT_DROPDOWN_PLACEHOLDER, true), {
                'event-builder-container': true
              })
            }));;
            return __jade_nodes;
          }.call(this).filter(Boolean)));
          var propertyFilters = $helpers.getPropertyFilters();
          var isAddingPropertyFilter = $helpers.isPropertyFilterMenuOpen(propertyFilters.length);
          __jade_nodes = __jade_nodes.concat(propertyFilters.length > 0 ? function () {
            var __jade_nodes = [];
            __jade_nodes = __jade_nodes.concat(h("div", {
              "class": {
                'property-filter-separator-label': true,
                'where-label': true
              }
            }, function () {
              var __jade_nodes = [];
              __jade_nodes = __jade_nodes.concat("where");;
              return __jade_nodes;
            }.call(this).filter(Boolean)));;
            return __jade_nodes;
          }.call(this) : undefined);
          __jade_nodes = __jade_nodes.concat(function () {
            var $$obj = propertyFilters;
            var $$eachNodes;
            var $$iterated = false;
            if (Array.isArray($$obj)) {
              $$eachNodes = $$obj.reduce(function ($$eachNodes, propertyFilter, propertyFilterIndex) {
                $$iterated = true;
                return $$eachNodes.concat(function () {
                  var __jade_nodes = [];
                  __jade_nodes = __jade_nodes.concat(h("div", {
                    "on": {
                      click: function click(ev) {
                        return $helpers.clickPropertyFilter(ev, propertyFilterIndex);
                      }
                    },
                    "class": {
                      'property-filter-clickable': true,
                      'property-filter': true
                    }
                  }, function () {
                    var __jade_nodes = [];
                    __jade_nodes = __jade_nodes.concat(h("div", {
                      "class": Object.assign({}, _defineProperty({}, $helpers.ELEMENTS_BY_CSS_CLASS.PROPERTY_FILTER_DROPDOWN_PLACEHOLDER, true), {
                        'property-filter-builder-container': true
                      })
                    }));
                    __jade_nodes = __jade_nodes.concat($helpers.isPropertyFilterMenuOpen(propertyFilterIndex) ? function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat(jade_mixins['autoresizing-builder-filter-input'].call(this, $helpers.truncateMiddle($helpers.getPropertyFilterLabel(propertyFilterIndex), 100)));;
                      return __jade_nodes;
                    }.call(this) : function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat(h("div", function () {
                        var __jade_nodes = [];
                        __jade_nodes = __jade_nodes.concat(function () {
                          var $$obj = $helpers.getPropertyFilterLabelParts(propertyFilterIndex);
                          var $$eachNodes;
                          var $$iterated = false;
                          if (Array.isArray($$obj)) {
                            $$eachNodes = $$obj.reduce(function ($$eachNodes, part, $index) {
                              $$iterated = true;
                              return $$eachNodes.concat(function () {
                                var __jade_nodes = [];
                                __jade_nodes = __jade_nodes.concat(h("span", {
                                  "attrs": {
                                    title: part.label
                                  },
                                  "class": Object.assign({}, {
                                    'highlight': part.highlight
                                  }, {
                                    'property-filter-label-part': true
                                  })
                                }, [__vjadeSafeCode($helpers.truncateMiddle(part.label, 25))]));;
                                return __jade_nodes;
                              }.call(this));
                            }, []);
                          } else {
                            $$eachNodes = [];
                            for (var $$objKey in $$obj) {
                              (function () {
                                var $index = $$objKey;
                                if ($$obj.hasOwnProperty($index)) {
                                  $$iterated = true;
                                  var part = $$obj[$index];
                                  $$eachNodes = $$eachNodes.concat(function () {
                                    var __jade_nodes = [];
                                    __jade_nodes = __jade_nodes.concat(h("span", {
                                      "attrs": {
                                        title: part.label
                                      },
                                      "class": Object.assign({}, {
                                        'highlight': part.highlight
                                      }, {
                                        'property-filter-label-part': true
                                      })
                                    }, [__vjadeSafeCode($helpers.truncateMiddle(part.label, 25))]));;
                                    return __jade_nodes;
                                  }.call(this));
                                }
                              })();
                            }
                          }

                          return $$eachNodes;
                        }());;
                        return __jade_nodes;
                      }.call(this).filter(Boolean)));;
                      return __jade_nodes;
                    }.call(this));
                    __jade_nodes = __jade_nodes.concat(h("div", {
                      "on": {
                        click: function click(ev) {
                          return $helpers.removePropertyFilter(ev, propertyFilterIndex);
                        }
                      },
                      "class": {
                        'property-filter-remove': true
                      }
                    }, function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                        "attrs": {
                          icon: 'x'
                        }
                      }));;
                      return __jade_nodes;
                    }.call(this).filter(Boolean)));;
                    return __jade_nodes;
                  }.call(this).filter(Boolean)));
                  __jade_nodes = __jade_nodes.concat(propertyFilterIndex !== propertyFilters.length - 1 ? function () {
                    var __jade_nodes = [];
                    __jade_nodes = __jade_nodes.concat(h("div", {
                      "class": {
                        'property-filter-separator-label': true
                      }
                    }, function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat("and");;
                      return __jade_nodes;
                    }.call(this).filter(Boolean)));;
                    return __jade_nodes;
                  }.call(this) : undefined);;
                  return __jade_nodes;
                }.call(this));
              }, []);
            } else {
              $$eachNodes = [];
              for (var $$objKey in $$obj) {
                (function () {
                  var propertyFilterIndex = $$objKey;
                  if ($$obj.hasOwnProperty(propertyFilterIndex)) {
                    $$iterated = true;
                    var propertyFilter = $$obj[propertyFilterIndex];
                    $$eachNodes = $$eachNodes.concat(function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat(h("div", {
                        "on": {
                          click: function click(ev) {
                            return $helpers.clickPropertyFilter(ev, propertyFilterIndex);
                          }
                        },
                        "class": {
                          'property-filter-clickable': true,
                          'property-filter': true
                        }
                      }, function () {
                        var __jade_nodes = [];
                        __jade_nodes = __jade_nodes.concat(h("div", {
                          "class": Object.assign({}, _defineProperty({}, $helpers.ELEMENTS_BY_CSS_CLASS.PROPERTY_FILTER_DROPDOWN_PLACEHOLDER, true), {
                            'property-filter-builder-container': true
                          })
                        }));
                        __jade_nodes = __jade_nodes.concat($helpers.isPropertyFilterMenuOpen(propertyFilterIndex) ? function () {
                          var __jade_nodes = [];
                          __jade_nodes = __jade_nodes.concat(jade_mixins['autoresizing-builder-filter-input'].call(this, $helpers.truncateMiddle($helpers.getPropertyFilterLabel(propertyFilterIndex), 100)));;
                          return __jade_nodes;
                        }.call(this) : function () {
                          var __jade_nodes = [];
                          __jade_nodes = __jade_nodes.concat(h("div", function () {
                            var __jade_nodes = [];
                            __jade_nodes = __jade_nodes.concat(function () {
                              var $$obj = $helpers.getPropertyFilterLabelParts(propertyFilterIndex);
                              var $$eachNodes;
                              var $$iterated = false;
                              if (Array.isArray($$obj)) {
                                $$eachNodes = $$obj.reduce(function ($$eachNodes, part, $index) {
                                  $$iterated = true;
                                  return $$eachNodes.concat(function () {
                                    var __jade_nodes = [];
                                    __jade_nodes = __jade_nodes.concat(h("span", {
                                      "attrs": {
                                        title: part.label
                                      },
                                      "class": Object.assign({}, {
                                        'highlight': part.highlight
                                      }, {
                                        'property-filter-label-part': true
                                      })
                                    }, [__vjadeSafeCode($helpers.truncateMiddle(part.label, 25))]));;
                                    return __jade_nodes;
                                  }.call(this));
                                }, []);
                              } else {
                                $$eachNodes = [];
                                for (var $$objKey in $$obj) {
                                  (function () {
                                    var $index = $$objKey;
                                    if ($$obj.hasOwnProperty($index)) {
                                      $$iterated = true;
                                      var part = $$obj[$index];
                                      $$eachNodes = $$eachNodes.concat(function () {
                                        var __jade_nodes = [];
                                        __jade_nodes = __jade_nodes.concat(h("span", {
                                          "attrs": {
                                            title: part.label
                                          },
                                          "class": Object.assign({}, {
                                            'highlight': part.highlight
                                          }, {
                                            'property-filter-label-part': true
                                          })
                                        }, [__vjadeSafeCode($helpers.truncateMiddle(part.label, 25))]));;
                                        return __jade_nodes;
                                      }.call(this));
                                    }
                                  })();
                                }
                              }

                              return $$eachNodes;
                            }());;
                            return __jade_nodes;
                          }.call(this).filter(Boolean)));;
                          return __jade_nodes;
                        }.call(this));
                        __jade_nodes = __jade_nodes.concat(h("div", {
                          "on": {
                            click: function click(ev) {
                              return $helpers.removePropertyFilter(ev, propertyFilterIndex);
                            }
                          },
                          "class": {
                            'property-filter-remove': true
                          }
                        }, function () {
                          var __jade_nodes = [];
                          __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                            "attrs": {
                              icon: 'x'
                            }
                          }));;
                          return __jade_nodes;
                        }.call(this).filter(Boolean)));;
                        return __jade_nodes;
                      }.call(this).filter(Boolean)));
                      __jade_nodes = __jade_nodes.concat(propertyFilterIndex !== propertyFilters.length - 1 ? function () {
                        var __jade_nodes = [];
                        __jade_nodes = __jade_nodes.concat(h("div", {
                          "class": {
                            'property-filter-separator-label': true
                          }
                        }, function () {
                          var __jade_nodes = [];
                          __jade_nodes = __jade_nodes.concat("and");;
                          return __jade_nodes;
                        }.call(this).filter(Boolean)));;
                        return __jade_nodes;
                      }.call(this) : undefined);;
                      return __jade_nodes;
                    }.call(this));
                  }
                })();
              }
            }

            return $$eachNodes;
          }());
          __jade_nodes = __jade_nodes.concat($helpers.hasSelectedEvent() ? function () {
            var __jade_nodes = [];
            __jade_nodes = __jade_nodes.concat(h("div", {
              "class": Object.assign({}, {
                'property-filter-pane-open': isAddingPropertyFilter
              }, {
                'property-filter-add-section': true,
                'property-filter-clickable': true
              })
            }, function () {
              var __jade_nodes = [];
              __jade_nodes = __jade_nodes.concat(h("div", {
                "class": Object.assign({}, _defineProperty({}, $helpers.ELEMENTS_BY_CSS_CLASS.PROPERTY_FILTER_DROPDOWN_PLACEHOLDER, true), {
                  'property-filter-builder-container': true
                })
              }));
              __jade_nodes = __jade_nodes.concat(h("div", {
                "class": {
                  'property-filter-search-wrapper': true
                }
              }, function () {
                var __jade_nodes = [];
                __jade_nodes = __jade_nodes.concat(h("div", {
                  "class": {
                    'property-filter-search-icon-wrapper': true
                  }
                }, function () {
                  var __jade_nodes = [];
                  __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                    "attrs": {
                      icon: 'search'
                    }
                  }));;
                  return __jade_nodes;
                }.call(this).filter(Boolean)));
                __jade_nodes = __jade_nodes.concat(h("input", {
                  "props": {
                    autoFocus: true,
                    placeholder: 'Search',
                    type: 'text',
                    value: builder.searchFilter
                  },
                  "on": {
                    input: $helpers.searchFilterInput
                  },
                  "class": Object.assign({}, {
                    'property-filter-search-active': isAddingPropertyFilter
                  }, {
                    'remove-chrome-form-style': true,
                    'property-filter-search-input': true
                  })
                }));;
                return __jade_nodes;
              }.call(this).filter(Boolean)));
              __jade_nodes = __jade_nodes.concat(h("mp-button", {
                "attrs": {
                  icon: 'plus',
                  size: 'small'
                },
                "on": {
                  click: $helpers.clickAddPropertyFilter
                },
                "class": {
                  'mp-button-secondary': true,
                  'property-filter-filter-button': true
                }
              }, function () {
                var __jade_nodes = [];
                __jade_nodes = __jade_nodes.concat("Filter");;
                return __jade_nodes;
              }.call(this).filter(Boolean)));;
              return __jade_nodes;
            }.call(this).filter(Boolean)));;
            return __jade_nodes;
          }.call(this) : undefined);;
          return __jade_nodes;
        }.call(this).filter(Boolean)));
        __jade_nodes = __jade_nodes.concat(stagedCustomEvent.eventSelectors.length > 1 ? function () {
          var __jade_nodes = [];
          __jade_nodes = __jade_nodes.concat(h("div", {
            "on": {
              click: function click() {
                return $helpers.removeSelector();
              }
            },
            "class": Object.assign({}, {
              'property-filter-pane-open': isAddingPropertyFilter
            }, {
              'selector-remove': true
            })
          }, function () {
            var __jade_nodes = [];
            __jade_nodes = __jade_nodes.concat(h("svg-icon", {
              "attrs": {
                icon: 'x'
              }
            }));;
            return __jade_nodes;
          }.call(this).filter(Boolean)));;
          return __jade_nodes;
        }.call(this) : undefined);;
        return __jade_nodes;
      }.call(this).filter(Boolean))
    };
  }.call(this, "$helpers" in locals ? locals.$helpers : typeof $helpers !== "undefined" ? $helpers : undefined, "Array" in locals ? locals.Array : typeof Array !== "undefined" ? Array : undefined, "JSON" in locals ? locals.JSON : typeof JSON !== "undefined" ? JSON : undefined, "Object" in locals ? locals.Object : typeof Object !== "undefined" ? Object : undefined, "String" in locals ? locals.String : typeof String !== "undefined" ? String : undefined, "builder" in locals ? locals.builder : typeof builder !== "undefined" ? builder : undefined, "isAddingPropertyFilter" in locals ? locals.isAddingPropertyFilter : typeof isAddingPropertyFilter !== "undefined" ? isAddingPropertyFilter : undefined, "stagedCustomEvent" in locals ? locals.stagedCustomEvent : typeof stagedCustomEvent !== "undefined" ? stagedCustomEvent : undefined);
  if (result_of_with) return result_of_with.value;
}
module.exports = _jade_template_fn;