'use strict';

Liferay.Loader.define('frontend-taglib-clay$clay-pagination-bar@2.24.1/lib/ClayPaginationBar.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.ClayPaginationBar = 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 ClayPaginationBar.soy.
      // Please don't edit this file by hand.

      /**
       * @fileoverview Templates in namespace ClayPaginationBar.
       * @public
       */

      goog.module('ClayPaginationBar.incrementaldom');

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

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

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

      /**
       * @param {{
       *  currentPage: number,
       *  entries: !Array<{href: (!goog.soy.data.SanitizedContent|string), itemsPerPage: number, label: number}>,
       *  selectedEntry: number,
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  totalEntries: number,
       *  _handleItemsPerPageClicked: (*|null|undefined),
       *  _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 {!Array<{href: (!goog.soy.data.SanitizedContent|string), itemsPerPage: number, label: number}>} */
        var entries = soy.asserts.assertType(goog.isArray(opt_data.entries), 'entries', opt_data.entries, '!Array<{href: (!goog.soy.data.SanitizedContent|string), itemsPerPage: number, label: number}>');
        /** @type {number} */
        var selectedEntry = soy.asserts.assertType(goog.isNumber(opt_data.selectedEntry), 'selectedEntry', opt_data.selectedEntry, '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 totalEntries = soy.asserts.assertType(goog.isNumber(opt_data.totalEntries), 'totalEntries', opt_data.totalEntries, 'number');
        /** @type {*|null|undefined} */
        var _handleItemsPerPageClicked = opt_data._handleItemsPerPageClicked;
        /** @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_2897__soy2898 = '';
        /** @desc The word 'items' */
        var MSG_EXTERNAL_413346167952108153 = Liferay.Language.get('items');
        msg_2897__soy2898 += MSG_EXTERNAL_413346167952108153;

        incrementalDom.elementOpenStart('div');
        (function attributes__soy14() {
          incrementalDom.attr('class', 'clay-pagination-bar pagination-bar' + (elementClasses ? ' ' + elementClasses : ''));
          if (id) {
            incrementalDom.attr('id', id);
          }
        })();
        incrementalDom.elementOpenEnd();
        var selectedEntryItem__soy31 = entries[selectedEntry];
        var selectedEntryLabel__soy33 = '';
        selectedEntryLabel__soy33 += selectedEntryItem__soy31.label;
        selectedEntryLabel__soy33 += ' ';
        selectedEntryLabel__soy33 += msg_2897__soy2898;
        $templateAlias1({ elementClasses: 'pagination-items-per-page', events: { itemClicked: _handleItemsPerPageClicked }, items: entries, label: selectedEntryLabel__soy33, spritemap: spritemap }, null, opt_ijData);
        incrementalDom.elementOpenStart('div');
        incrementalDom.attr('class', 'pagination-results');
        incrementalDom.elementOpenEnd();
        var firstShowingEntry__soy50 = (currentPage - 1) * selectedEntryItem__soy31.label + 1;
        var lastShowingEntry__soy52 = currentPage * selectedEntryItem__soy31.label < totalEntries ? currentPage * selectedEntryItem__soy31.label : totalEntries;
        /** @desc Says which range of pages of the total are being showed */
        var MSG_EXTERNAL_5386263887961015823 = Liferay.Language.get('showing-x-to-x-of-x-entries');
	MSG_EXTERNAL_5386263887961015823 = MSG_EXTERNAL_5386263887961015823.replace(/{(\d+)}/g, '\x01$1\x01');

        var lastIndex_54 = 0,
            partRe_54 = /\x01\d+\x01/g,
            match_54;
        do {
          match_54 = partRe_54.exec(MSG_EXTERNAL_5386263887961015823) || undefined;
          incrementalDom.text(goog.string.unescapeEntities(MSG_EXTERNAL_5386263887961015823.substring(lastIndex_54, match_54 && match_54.index)));
          lastIndex_54 = partRe_54.lastIndex;
          switch (match_54 && match_54[0]) {
            case '\x012\x01':
              soyIdom.print(totalEntries);
              break;
            case '\x011\x01':
              soyIdom.print(lastShowingEntry__soy52);
              break;
            case '\x010\x01':
              soyIdom.print(firstShowingEntry__soy50);
              break;
          }
        } while (match_54);
        incrementalDom.elementClose('div');
        $templateAlias2({ baseHref: baseHref, currentPage: currentPage, events: { pageClicked: _handlePageClick }, spritemap: spritemap, totalPages: Math.ceil(totalEntries / selectedEntryItem__soy31.label) }, null, opt_ijData);
        incrementalDom.elementClose('div');
      }
      exports.render = $render;
      /**
       * @typedef {{
       *  currentPage: number,
       *  entries: !Array<{href: (!goog.soy.data.SanitizedContent|string), itemsPerPage: number, label: number}>,
       *  selectedEntry: number,
       *  spritemap: (!goog.soy.data.SanitizedContent|string),
       *  totalEntries: number,
       *  _handleItemsPerPageClicked: (*|null|undefined),
       *  _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 = 'ClayPaginationBar.render';
      }

      exports.render.params = ["currentPage", "entries", "selectedEntry", "spritemap", "totalEntries", "_handleItemsPerPageClicked", "_handlePageClick", "baseHref", "elementClasses", "id"];
      exports.render.types = { "currentPage": "int", "entries": "list<[\n\t\thref: string,\n\t\tlabel: int,\n\t\titemsPerPage: int\n\t]>", "selectedEntry": "int", "spritemap": "string", "totalEntries": "int", "_handleItemsPerPageClicked": "any", "_handlePageClick": "any", "baseHref": "string", "elementClasses": "string", "id": "string" };
      exports.templates = templates = exports;
      return exports;
    });

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

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

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

      return ClayPaginationBar;
    }(_metalComponent2.default);

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