text: define(["exports", "../../../../@polymer/polymer/polymer-element.js", "../../../../@polymer/polymer/lib/legacy/polymer.dom.js", "../../../../@polymer/iron-ajax/iron-ajax.js", "../../../../@polymer/iron-list/iron-list.js", "../../../../@polymer/paper-button/paper-button.js", "../../../lrndesign-gallerycard/lrndesign-gallerycard.js", "../../../elmsln-loading/elmsln-loading.js"], function (_exports, _polymerElement, _polymerDom, _ironAjax, _ironList, _paperButton, _lrndesignGallerycard, _elmslnLoading) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.LrnappBlockRecentSubmissions = void 0;
  
    function _templateObject_63da6980c3a111e99204fd28bf05b7e9() {
      var data = babelHelpers.taggedTemplateLiteral(["\n      <style include=\"paper-item-styles\">\n        :host {\n          display: block;\n        }\n        paper-button {\n          width: 100%;\n        }\n      </style>\n      <iron-ajax\n        auto=\"\"\n        url=\"{{sourcePath}}\"\n        handle-as=\"json\"\n        last-response=\"{{response}}\"\n        on-response=\"handleResponse\"\n      ></iron-ajax>\n      <div id=\"loading\">\n        <h3>Loading..</h3>\n        <elmsln-loading color=\"grey-text\" size=\"large\"></elmsln-loading>\n      </div>\n      <iron-list items=\"[[_toArray(response.data)]]\" as=\"item\">\n        <template>\n          <paper-button on-click=\"_loadSubmissionUrl\">\n            <lrndesign-gallerycard\n              data-submission-id$=\"[[item.id]]\"\n              title=\"[[item.attributes.title]]\"\n              author=\"[[item.relationships.author.data]]\"\n              comments=\"[[item.meta.comment_count]]\"\n              image=\"[[item.display.image]]\"\n              icon=\"[[item.display.icon]]\"\n              class=\"ferpa-protect\"\n            >\n            </lrndesign-gallerycard>\n          </paper-button>\n        </template>\n      </iron-list>\n    "], ["\n      <style include=\"paper-item-styles\">\n        :host {\n          display: block;\n        }\n        paper-button {\n          width: 100%;\n        }\n      </style>\n      <iron-ajax\n        auto=\"\"\n        url=\"{{sourcePath}}\"\n        handle-as=\"json\"\n        last-response=\"{{response}}\"\n        on-response=\"handleResponse\"\n      ></iron-ajax>\n      <div id=\"loading\">\n        <h3>Loading..</h3>\n        <elmsln-loading color=\"grey-text\" size=\"large\"></elmsln-loading>\n      </div>\n      <iron-list items=\"[[_toArray(response.data)]]\" as=\"item\">\n        <template>\n          <paper-button on-click=\"_loadSubmissionUrl\">\n            <lrndesign-gallerycard\n              data-submission-id\\$=\"[[item.id]]\"\n              title=\"[[item.attributes.title]]\"\n              author=\"[[item.relationships.author.data]]\"\n              comments=\"[[item.meta.comment_count]]\"\n              image=\"[[item.display.image]]\"\n              icon=\"[[item.display.icon]]\"\n              class=\"ferpa-protect\"\n            >\n            </lrndesign-gallerycard>\n          </paper-button>\n        </template>\n      </iron-list>\n    "]);
  
      _templateObject_63da6980c3a111e99204fd28bf05b7e9 = function _templateObject_63da6980c3a111e99204fd28bf05b7e9() {
        return data;
      };
  
      return data;
    }
  
    var LrnappBlockRecentSubmissions =
    /*#__PURE__*/
    function (_PolymerElement) {
      babelHelpers.inherits(LrnappBlockRecentSubmissions, _PolymerElement);
  
      function LrnappBlockRecentSubmissions() {
        babelHelpers.classCallCheck(this, LrnappBlockRecentSubmissions);
        return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(LrnappBlockRecentSubmissions).apply(this, arguments));
      }
  
      babelHelpers.createClass(LrnappBlockRecentSubmissions, [{
        key: "_loadSubmissionUrl",
  
        /**
         * Handle tap on paper-button above to redirect to the correct submission url.
         */
        value: function _loadSubmissionUrl(e) {
          var normalizedEvent = (0, _polymerDom.dom)(e);
          var local = normalizedEvent.localTarget; // this will have the id of the current submission
  
          var active = local.getAttribute("data-submission-id"); // @todo need a cleaner integration but this at least goes the right place for now
  
          window.location.href = this.basePath + "lrnapp-studio-submission/submissions/" + active;
        }
      }, {
        key: "handleResponse",
        value: function handleResponse(e) {
          this.$.loading.hidden = true;
        }
      }, {
        key: "_getViewLink",
        value: function _getViewLink(nid) {
          return this.basePath + "lrnapp-studio-submission/submissions/" + nid;
        }
      }, {
        key: "_toArray",
        value: function _toArray(obj) {
          if (obj == null) {
            return [];
          }
  
          return Object.keys(obj).map(function (key) {
            return obj[key];
          });
        }
      }], [{
        key: "template",
        get: function get() {
          return (0, _polymerElement.html)(_templateObject_63da6980c3a111e99204fd28bf05b7e9());
        }
      }, {
        key: "tag",
        get: function get() {
          return "lrnapp-block-recent-submissions";
        }
      }, {
        key: "properties",
        get: function get() {
          return {
            elmslnCourse: {
              type: String
            },
            elmslnSection: {
              type: String
            },
            basePath: {
              type: String
            },
            csrfToken: {
              type: String
            },
            endPoint: {
              type: String
            },
            sourcePath: {
              type: String,
              notify: true
            },
            response: {
              type: Array,
              notify: true
            }
          };
        }
      }]);
      return LrnappBlockRecentSubmissions;
    }(_polymerElement.PolymerElement);
  
    _exports.LrnappBlockRecentSubmissions = LrnappBlockRecentSubmissions;
    window.customElements.define(LrnappBlockRecentSubmissions.tag, LrnappBlockRecentSubmissions);
  });