"use strict";

function _jade_template_fn(locals) {
  locals = locals || {};;;
  var result_of_with = function ($attrs, $component, $helpers, Array, Object, String) {
    var h = require('panel').h;
    var __vjadeSafeCode = function __vjadeSafeCode(code) {
      return code || String(code);
    };
    return {
      value: h("div", {
        "class": Object.assign({}, {
          'toggle-blue': $attrs["color"] === "blue" || $attrs["blue"],
          'toggle-grey': $attrs["color"] === "grey",
          'toggle-large': $attrs["size"] === "large" || $attrs["large"],
          'toggle-small': $attrs["size"] === "small" || $attrs["small"],
          'toggle-square': $attrs["square"],
          'theme-lite': $attrs["theme"] === "lite"
        }, {
          'mp-toggle': true
        })
      }, function () {
        var __jade_nodes = [];
        __jade_nodes = __jade_nodes.concat(function () {
          var $$obj = $helpers.toggleOptions();
          var $$eachNodes;
          var $$iterated = false;
          if (Array.isArray($$obj)) {
            $$eachNodes = $$obj.reduce(function ($$eachNodes, toggleOption, $index) {
              $$iterated = true;
              return $$eachNodes.concat(function () {
                var __jade_nodes = [];
                var icon = toggleOption.icon,
                    iconSide = toggleOption.iconSide,
                    text = toggleOption.text;

                var hasTextAndIcon = icon && text.length;;
                __jade_nodes = __jade_nodes.concat(h("div", {
                  "on": {
                    click: function click() {
                      return toggleOption.disabled ? null : $helpers.selectOption(toggleOption.value);
                    }
                  },
                  "class": Object.assign({}, {
                    'mp-toggle-selected': toggleOption.value === $component.value,
                    'mp-toggle-disabled': toggleOption.disabled,
                    'mp-toggle-error': toggleOption.error,
                    'mp-toggle-text-and-icon': hasTextAndIcon
                  }, {
                    'mp-toggle-option': true
                  })
                }, function () {
                  var __jade_nodes = [];
                  __jade_nodes = __jade_nodes.concat(hasTextAndIcon ? function () {
                    var __jade_nodes = []; /*  to ensure that the toggle-text always remains in the middle we put the icon */
                    /*  on both sides of the text and hide the one we do not want to see */
                    __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                      "attrs": {
                        icon: icon
                      },
                      "class": {
                        hidden: iconSide === "right"
                      }
                    }));
                    __jade_nodes = __jade_nodes.concat(h("span", {
                      "class": {
                        'toggle-text': true
                      }
                    }, [__vjadeSafeCode(toggleOption.text)]));
                    __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                      "attrs": {
                        icon: icon
                      },
                      "class": {
                        hidden: iconSide === "left"
                      }
                    }));;
                    return __jade_nodes;
                  }.call(this) : icon ? function () {
                    var __jade_nodes = [];
                    __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                      "attrs": {
                        icon: icon
                      }
                    }));;
                    return __jade_nodes;
                  }.call(this) : function () {
                    var __jade_nodes = [];
                    __jade_nodes = __jade_nodes.concat(h("span", {
                      "class": {
                        'toggle-text': true
                      }
                    }, [__vjadeSafeCode(toggleOption.text)]));;
                    return __jade_nodes;
                  }.call(this));;
                  return __jade_nodes;
                }.call(this).filter(Boolean)));;
                return __jade_nodes;
              }.call(this));
            }, []);
          } else {
            $$eachNodes = [];
            for (var $$objKey in $$obj) {
              (function () {
                var $index = $$objKey;
                if ($$obj.hasOwnProperty($index)) {
                  $$iterated = true;
                  var toggleOption = $$obj[$index];
                  $$eachNodes = $$eachNodes.concat(function () {
                    var __jade_nodes = [];
                    var icon = toggleOption.icon,
                        iconSide = toggleOption.iconSide,
                        text = toggleOption.text;

                    var hasTextAndIcon = icon && text.length;;
                    __jade_nodes = __jade_nodes.concat(h("div", {
                      "on": {
                        click: function click() {
                          return toggleOption.disabled ? null : $helpers.selectOption(toggleOption.value);
                        }
                      },
                      "class": Object.assign({}, {
                        'mp-toggle-selected': toggleOption.value === $component.value,
                        'mp-toggle-disabled': toggleOption.disabled,
                        'mp-toggle-error': toggleOption.error,
                        'mp-toggle-text-and-icon': hasTextAndIcon
                      }, {
                        'mp-toggle-option': true
                      })
                    }, function () {
                      var __jade_nodes = [];
                      __jade_nodes = __jade_nodes.concat(hasTextAndIcon ? function () {
                        var __jade_nodes = []; /*  to ensure that the toggle-text always remains in the middle we put the icon */
                        /*  on both sides of the text and hide the one we do not want to see */
                        __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                          "attrs": {
                            icon: icon
                          },
                          "class": {
                            hidden: iconSide === "right"
                          }
                        }));
                        __jade_nodes = __jade_nodes.concat(h("span", {
                          "class": {
                            'toggle-text': true
                          }
                        }, [__vjadeSafeCode(toggleOption.text)]));
                        __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                          "attrs": {
                            icon: icon
                          },
                          "class": {
                            hidden: iconSide === "left"
                          }
                        }));;
                        return __jade_nodes;
                      }.call(this) : icon ? function () {
                        var __jade_nodes = [];
                        __jade_nodes = __jade_nodes.concat(h("svg-icon", {
                          "attrs": {
                            icon: icon
                          }
                        }));;
                        return __jade_nodes;
                      }.call(this) : function () {
                        var __jade_nodes = [];
                        __jade_nodes = __jade_nodes.concat(h("span", {
                          "class": {
                            'toggle-text': true
                          }
                        }, [__vjadeSafeCode(toggleOption.text)]));;
                        return __jade_nodes;
                      }.call(this));;
                      return __jade_nodes;
                    }.call(this).filter(Boolean)));;
                    return __jade_nodes;
                  }.call(this));
                }
              })();
            }
          }

          return $$eachNodes;
        }());;
        return __jade_nodes;
      }.call(this).filter(Boolean))
    };
  }.call(this, "$attrs" in locals ? locals.$attrs : typeof $attrs !== "undefined" ? $attrs : undefined, "$component" in locals ? locals.$component : typeof $component !== "undefined" ? $component : undefined, "$helpers" in locals ? locals.$helpers : typeof $helpers !== "undefined" ? $helpers : undefined, "Array" in locals ? locals.Array : typeof Array !== "undefined" ? Array : undefined, "Object" in locals ? locals.Object : typeof Object !== "undefined" ? Object : undefined, "String" in locals ? locals.String : typeof String !== "undefined" ? String : undefined);
  if (result_of_with) return result_of_with.value;
}
module.exports = _jade_template_fn;