'use strict';

Liferay.Loader.define('frontend-taglib-clay$clay-pagination@2.24.1/lib/ClayPagination.soy', ['module', 'exports', 'require', 'frontend-js-metal-web$metal-component', 'frontend-js-metal-web$metal-soy'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.templates = exports.ClayPagination = undefined;

    var _metalComponent = require('frontend-js-metal-web$metal-component');

    var _metalComponent2 = _interopRequireDefault(_metalComponent);

    var _metalSoy = require('frontend-js-metal-web$metal-soy');

    var _metalSoy2 = _interopRequireDefault(_metalSoy);

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _classCallCheck(instance, Constructor) {
      if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
      }
    }

    function _possibleConstructorReturn(self, call) {
      if (!self) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }return call && (typeof call === "object" || typeof call === "function") ? call : self;
    }

    function _inherits(subClass, superClass) {
      if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
      }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
    } /* jshint ignore:start */

    var templates;
    goog.loadModule(function (exports) {
      var soy = goog.require('soy');

      goog.require('soydata');

      // This file was automatically generated from ClayPagination.soy.
      // Please don't edit this file by hand.

      /**
       * @fileoverview Templates in namespace ClayPagination.
       * @hassoydeltemplate {ClayDropdownBase.Content.idom}
       * @public
       */

      goog.module('ClayPagination.incrementaldom');

      goog.require('goog.soy.data.SanitizedContent');
      var incrementalDom = goog.require('incrementaldom');
      goog.require('soy');
      goog.require('soy.asserts');

      goog.require('soy.idom');

      var $templateAlias2 = _metalSoy2.default.getTemplate('ClayDropdownBase.incrementaldom', 'render');

      var $templateAlias3 = _metalSoy2.default.getTemplate('ClayDropdownItem.incrementaldom', 'render');

      var $templateAlias1 = _metalSoy2.default.getTemplate('ClayLink.incrementaldom', 'render');

      /**
       * @param {{
       *  currentPage: number,
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  totalPages: number,
       *  _handlePageClick: (*|null|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  elementClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  id: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }} opt_data
       * @param {Object<string, *>=} opt_ijData
       * @param {Object<string, *>=} opt_ijData_deprecated
       * @return {void}
       * @suppress {checkTypes}
       */
      function $render(opt_data, opt_ijData, opt_ijData_deprecated) {
        opt_ijData = opt_ijData_deprecated || opt_ijData;
        /** @type {number} */
        var currentPage = soy.asserts.assertType(goog.isNumber(opt_data.currentPage), 'currentPage', opt_data.currentPage, 'number');
        /** @type {!goog.soy.data.SanitizedContent|string} */
        var spritemap = soy.asserts.assertType(goog.isString(opt_data.spritemap) || opt_data.spritemap instanceof goog.soy.data.SanitizedContent, 'spritemap', opt_data.spritemap, '!goog.soy.data.SanitizedContent|string');
        /** @type {number} */
        var totalPages = soy.asserts.assertType(goog.isNumber(opt_data.totalPages), 'totalPages', opt_data.totalPages, 'number');
        /** @type {*|null|undefined} */
        var _handlePageClick = opt_data._handlePageClick;
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var baseHref = soy.asserts.assertType(opt_data.baseHref == null || goog.isString(opt_data.baseHref) || opt_data.baseHref instanceof goog.soy.data.SanitizedContent, 'baseHref', opt_data.baseHref, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var elementClasses = soy.asserts.assertType(opt_data.elementClasses == null || goog.isString(opt_data.elementClasses) || opt_data.elementClasses instanceof goog.soy.data.SanitizedContent, 'elementClasses', opt_data.elementClasses, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var id = soy.asserts.assertType(opt_data.id == null || goog.isString(opt_data.id) || opt_data.id instanceof goog.soy.data.SanitizedContent, 'id', opt_data.id, '!goog.soy.data.SanitizedContent|null|string|undefined');
        var msg_2790__soy2791 = '';
        /** @desc Help text to indicate that this link goes to the next page */
        var MSG_EXTERNAL_6079963799263542450 = Liferay.Language.get('next-page');
        msg_2790__soy2791 += MSG_EXTERNAL_6079963799263542450;
        var msg_2787__soy2788 = '';
        /** @desc Help text to indicate that this link goes to the previous page */
        var MSG_EXTERNAL_4434966298440793579 = Liferay.Language.get('previous-page');
        msg_2787__soy2788 += MSG_EXTERNAL_4434966298440793579;

        incrementalDom.elementOpenStart('ul');
        (function attributes__soy11() {
          incrementalDom.attr('class', 'clay-pagination pagination' + (elementClasses ? ' ' + elementClasses : ''));
          if (id) {
            incrementalDom.attr('id', id);
          }
        })();
        incrementalDom.elementOpenEnd();
        $item({ _handlePageClick: _handlePageClick, ariaLabel: '' + msg_2787__soy2788, baseHref: baseHref, icon: 'angle-left', page: currentPage > 1 ? currentPage - 1 : null, spritemap: spritemap }, null, opt_ijData);
        if (totalPages <= 5) {
          for (var page45 = 1; page45 < totalPages + 1; page45++) {
            $item({ _handlePageClick: _handlePageClick, active: page45 == currentPage, baseHref: baseHref, label: '' + page45, page: page45 }, null, opt_ijData);
          }
        } else {
          var fromOneToCurrent__soy57 = currentPage - 1;
          var fromCurrentToLast__soy59 = totalPages - currentPage;
          $item({ _handlePageClick: _handlePageClick, active: currentPage == 1, baseHref: baseHref, label: '1', page: 1 }, null, opt_ijData);
          if (fromOneToCurrent__soy57 < 4) {
            var page71Limit = currentPage == 1 ? 4 : currentPage;
            for (var page71 = 2; page71 < page71Limit; page71++) {
              $item({ _handlePageClick: _handlePageClick, baseHref: baseHref, label: '' + page71, page: page71 }, null, opt_ijData);
            }
          } else {
            $range({ _handlePageClick: _handlePageClick, baseHref: baseHref, endPage: currentPage == totalPages ? currentPage - 3 : currentPage - 1, initPage: 2 }, null, opt_ijData);
          }
          if (currentPage != 1 && currentPage != totalPages) {
            var currentRangeInit__soy92 = fromOneToCurrent__soy57 >= 4 ? currentPage - 1 : currentPage;
            var currentRangeEnd__soy94 = fromCurrentToLast__soy59 > 3 ? currentPage + 2 : currentPage + 1;

            for (var page96 = currentRangeInit__soy92; page96 < currentRangeEnd__soy94; page96++) {
              $item({ _handlePageClick: _handlePageClick, active: page96 == currentPage, baseHref: baseHref, label: '' + page96, page: page96 }, null, opt_ijData);
            }
          }
          if (fromCurrentToLast__soy59 <= 3) {
            for (var page110 = currentPage + 1; page110 < totalPages; page110++) {
              $item({ _handlePageClick: _handlePageClick, baseHref: baseHref, label: '' + page110, page: page110 }, null, opt_ijData);
            }
          } else {
            $range({ _handlePageClick: _handlePageClick, baseHref: baseHref, endPage: totalPages, initPage: currentPage == 1 ? 4 : currentPage + 2 }, null, opt_ijData);
          }

          for (var page128 = currentPage == totalPages ? totalPages - 3 : totalPages; page128 < totalPages + 1; page128++) {
            $item({ _handlePageClick: _handlePageClick, active: page128 == currentPage, baseHref: baseHref, label: '' + page128, page: page128 }, null, opt_ijData);
          }
        }
        $item({ _handlePageClick: _handlePageClick, ariaLabel: '' + msg_2790__soy2791, baseHref: baseHref, icon: 'angle-right', page: currentPage < totalPages ? currentPage + 1 : null, spritemap: spritemap }, null, opt_ijData);
        incrementalDom.elementClose('ul');
      }
      exports.render = $render;
      /**
       * @typedef {{
       *  currentPage: number,
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  totalPages: number,
       *  _handlePageClick: (*|null|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  elementClasses: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  id: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }}
       */
      $render.Params;
      if (goog.DEBUG) {
        $render.soyTemplateName = 'ClayPagination.render';
      }

      /**
       * @param {{
       *  _handlePageClick: (*|null|undefined),
       *  active: (boolean|null|undefined),
       *  ariaLabel: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  icon: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  label: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  page: (null|number|undefined),
       *  spritemap: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }} opt_data
       * @param {Object<string, *>=} opt_ijData
       * @param {Object<string, *>=} opt_ijData_deprecated
       * @return {void}
       * @suppress {checkTypes}
       */
      function $item(opt_data, opt_ijData, opt_ijData_deprecated) {
        opt_ijData = opt_ijData_deprecated || opt_ijData;
        opt_data = opt_data || {};
        /** @type {*|null|undefined} */
        var _handlePageClick = opt_data._handlePageClick;
        /** @type {boolean|null|undefined} */
        var active = soy.asserts.assertType(opt_data.active == null || goog.isBoolean(opt_data.active) || opt_data.active === 1 || opt_data.active === 0, 'active', opt_data.active, 'boolean|null|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var ariaLabel = soy.asserts.assertType(opt_data.ariaLabel == null || goog.isString(opt_data.ariaLabel) || opt_data.ariaLabel instanceof goog.soy.data.SanitizedContent, 'ariaLabel', opt_data.ariaLabel, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var baseHref = soy.asserts.assertType(opt_data.baseHref == null || goog.isString(opt_data.baseHref) || opt_data.baseHref instanceof goog.soy.data.SanitizedContent, 'baseHref', opt_data.baseHref, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var icon = soy.asserts.assertType(opt_data.icon == null || goog.isString(opt_data.icon) || opt_data.icon instanceof goog.soy.data.SanitizedContent, 'icon', opt_data.icon, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var label = soy.asserts.assertType(opt_data.label == null || goog.isString(opt_data.label) || opt_data.label instanceof goog.soy.data.SanitizedContent, 'label', opt_data.label, '!goog.soy.data.SanitizedContent|null|string|undefined');
        /** @type {null|number|undefined} */
        var page = soy.asserts.assertType(opt_data.page == null || goog.isNumber(opt_data.page), 'page', opt_data.page, 'null|number|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var spritemap = soy.asserts.assertType(opt_data.spritemap == null || goog.isString(opt_data.spritemap) || opt_data.spritemap instanceof goog.soy.data.SanitizedContent, 'spritemap', opt_data.spritemap, '!goog.soy.data.SanitizedContent|null|string|undefined');
        var href__soy163 = '';
        href__soy163 += baseHref ? baseHref : '#';
        href__soy163 += page ? page : '';

        incrementalDom.elementOpenStart('li');
        (function elementAttributes__soy180() {
          incrementalDom.attr('class', 'page-item' + (active ? ' active' : '') + (!page ? ' disabled' : ''));
          incrementalDom.attr('data-page', page);
          incrementalDom.attr('data-onclick', _handlePageClick);
        })();
        incrementalDom.elementOpenEnd();
        $templateAlias1({ ariaLabel: ariaLabel, elementClasses: 'page-link', href: href__soy163, icon: icon, label: label, spritemap: spritemap }, null, opt_ijData);
        incrementalDom.elementClose('li');
      }
      exports.item = $item;
      /**
       * @typedef {{
       *  _handlePageClick: (*|null|undefined),
       *  active: (boolean|null|undefined),
       *  ariaLabel: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  icon: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  label: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  page: (null|number|undefined),
       *  spritemap: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }}
       */
      $item.Params;
      if (goog.DEBUG) {
        $item.soyTemplateName = 'ClayPagination.item';
      }

      /**
       * @param {{
       *  endPage: number,
       *  initPage: number,
       *  _handlePageClick: (*|null|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }} opt_data
       * @param {Object<string, *>=} opt_ijData
       * @param {Object<string, *>=} opt_ijData_deprecated
       * @return {void}
       * @suppress {checkTypes}
       */
      function $range(opt_data, opt_ijData, opt_ijData_deprecated) {
        opt_ijData = opt_ijData_deprecated || opt_ijData;
        var $$temp;
        /** @type {number} */
        var endPage = soy.asserts.assertType(goog.isNumber(opt_data.endPage), 'endPage', opt_data.endPage, 'number');
        /** @type {number} */
        var initPage = soy.asserts.assertType(goog.isNumber(opt_data.initPage), 'initPage', opt_data.initPage, 'number');
        /** @type {*|null|undefined} */
        var _handlePageClick = opt_data._handlePageClick;
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        var baseHref = soy.asserts.assertType(opt_data.baseHref == null || goog.isString(opt_data.baseHref) || opt_data.baseHref instanceof goog.soy.data.SanitizedContent, 'baseHref', opt_data.baseHref, '!goog.soy.data.SanitizedContent|null|string|undefined');
        incrementalDom.elementOpen('li');

        $templateAlias2({ _handleItemClick: _handlePageClick, contentRenderer: 'pagination', elementClasses: 'page-item', items: [{ initPage: initPage, endPage: endPage, baseHref: ($$temp = baseHref) == null ? '#' : $$temp }], label: function param217() {
            incrementalDom.text('...');
          }, triggerClasses: 'page-link' }, null, opt_ijData);
        incrementalDom.elementClose('li');
      }
      exports.range = $range;
      /**
       * @typedef {{
       *  endPage: number,
       *  initPage: number,
       *  _handlePageClick: (*|null|undefined),
       *  baseHref: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }}
       */
      $range.Params;
      if (goog.DEBUG) {
        $range.soyTemplateName = 'ClayPagination.range';
      }

      /**
       * @param {{
       *  _handleItemClick: (*|null|undefined),
       *  _handleItemKeyDown: (*|null|undefined),
       *  contentRenderer: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  items: (!Array<?>|null|undefined),
       *  itemsIconAlignment: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  spritemap: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }} opt_data
       * @param {Object<string, *>=} opt_ijData
       * @param {Object<string, *>=} opt_ijData_deprecated
       * @return {void}
       * @suppress {checkTypes}
       */
      function __deltemplate_s221_dfcdd17c(opt_data, opt_ijData, opt_ijData_deprecated) {
        opt_ijData = opt_ijData_deprecated || opt_ijData;
        opt_data = opt_data || {};
        /** @type {*|null|undefined} */
        var _handleItemClick = opt_data._handleItemClick;
        /** @type {*|null|undefined} */
        opt_data._handleItemKeyDown;
        soy.asserts.assertType(opt_data.contentRenderer == null || goog.isString(opt_data.contentRenderer) || opt_data.contentRenderer instanceof goog.soy.data.SanitizedContent, 'contentRenderer', opt_data.contentRenderer, '!goog.soy.data.SanitizedContent|null|string|undefined');

        /** @type {!Array<?>|null|undefined} */
        var items = soy.asserts.assertType(opt_data.items == null || goog.isArray(opt_data.items), 'items', opt_data.items, '!Array<?>|null|undefined');
        /** @type {!goog.soy.data.SanitizedContent|null|string|undefined} */
        soy.asserts.assertType(opt_data.itemsIconAlignment == null || goog.isString(opt_data.itemsIconAlignment) || opt_data.itemsIconAlignment instanceof goog.soy.data.SanitizedContent, 'itemsIconAlignment', opt_data.itemsIconAlignment, '!goog.soy.data.SanitizedContent|null|string|undefined');
        soy.asserts.assertType(opt_data.spritemap == null || goog.isString(opt_data.spritemap) || opt_data.spritemap instanceof goog.soy.data.SanitizedContent, 'spritemap', opt_data.spritemap, '!goog.soy.data.SanitizedContent|null|string|undefined');

        if (items) {
          var baseHref__soy232 = items[0].baseHref;
          var endPage__soy234 = items[0].endPage;
          var initPage__soy236 = items[0].initPage;
          incrementalDom.elementOpenStart('ul');
          incrementalDom.attr('class', 'list-unstyled');
          incrementalDom.elementOpenEnd();

          for (var page238 = initPage__soy236; page238 < endPage__soy234; page238++) {
            $templateAlias3({ _handleItemClick: _handleItemClick, data: { page: page238 }, href: baseHref__soy232 + page238, label: '' + page238 }, null, opt_ijData);
          }
          incrementalDom.elementClose('ul');
        }
      }
      exports.__deltemplate_s221_dfcdd17c = __deltemplate_s221_dfcdd17c;
      /**
       * @typedef {{
       *  _handleItemClick: (*|null|undefined),
       *  _handleItemKeyDown: (*|null|undefined),
       *  contentRenderer: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  items: (!Array<?>|null|undefined),
       *  itemsIconAlignment: (!goog.soy.data.SanitizedContent|null|string|undefined),
       *  spritemap: (!goog.soy.data.SanitizedContent|null|string|undefined)
       * }}
       */
      __deltemplate_s221_dfcdd17c.Params;
      if (goog.DEBUG) {
        __deltemplate_s221_dfcdd17c.soyTemplateName = 'ClayPagination.__deltemplate_s221_dfcdd17c';
      }
      soy.$$registerDelegateFn(soy.$$getDelTemplateId('ClayDropdownBase.Content.idom'), 'pagination', 0, __deltemplate_s221_dfcdd17c);

      exports.render.params = ["currentPage", "spritemap", "totalPages", "_handlePageClick", "baseHref", "elementClasses", "id"];
      exports.render.types = { "currentPage": "int", "spritemap": "string", "totalPages": "int", "_handlePageClick": "any", "baseHref": "string", "elementClasses": "string", "id": "string" };
      exports.item.params = ["_handlePageClick", "active", "ariaLabel", "baseHref", "icon", "label", "page", "spritemap"];
      exports.item.types = { "_handlePageClick": "any", "active": "bool", "ariaLabel": "string", "baseHref": "string", "icon": "string", "label": "string", "page": "int", "spritemap": "string" };
      exports.range.params = ["endPage", "initPage", "_handlePageClick", "baseHref"];
      exports.range.types = { "endPage": "int", "initPage": "int", "_handlePageClick": "any", "baseHref": "string" };
      exports.templates = templates = exports;
      return exports;
    });

    var ClayPagination = function (_Component) {
      _inherits(ClayPagination, _Component);

      function ClayPagination() {
        _classCallCheck(this, ClayPagination);

        return _possibleConstructorReturn(this, (ClayPagination.__proto__ || Object.getPrototypeOf(ClayPagination)).apply(this, arguments));
      }

      return ClayPagination;
    }(_metalComponent2.default);

    _metalSoy2.default.register(ClayPagination, templates);
    exports.ClayPagination = ClayPagination;
    exports.templates = templates;
    exports.default = templates;
    /* jshint ignore:end */
    //# sourceMappingURL=ClayPagination.soy.js.map
  }
});
//# sourceMappingURL=ClayPagination.soy.js.map