text: define(["exports", "../../lit/index.js", "../simple-icon/lib/simple-icon-button.js", "../simple-icon/simple-icon.js", "../simple-colors/simple-colors.js"], function (_exports, _index, _simpleIconButton, _simpleIcon, _simpleColors) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.StarRating = void 0;
  
    var _templateObject_2240af70942811ecb1937969798b231a, _templateObject2_2240af70942811ecb1937969798b231a, _templateObject3_2240af70942811ecb1937969798b231a, _templateObject4_2240af70942811ecb1937969798b231a, _templateObject5_2240af70942811ecb1937969798b231a;
  
    function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
  
    function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { babelHelpers.defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
  
    function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; }
  
    function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  
    /**
     * `star-rating`
     * `Rating display widget or button to do rating`
     *
     * @demo demo/index.html
     * @element star-rating
     */
    var StarRating = /*#__PURE__*/function (_SimpleColors) {
      babelHelpers.inherits(StarRating, _SimpleColors);
  
      var _super = _createSuper(StarRating);
  
      // these defaults in constructor assume that it's an empty star rating by default
      function StarRating() {
        var _this;
  
        babelHelpers.classCallCheck(this, StarRating);
        _this = _super.call(this);
        _this._calPercent = 0;
        _this.numStars = 5;
        _this.score = 10;
        _this.possible = 100;
        _this.dark = true;
        _this.contrast = 0;
        _this.accentColor = "yellow";
        return _this;
      }
  
      babelHelpers.createClass(StarRating, [{
        key: "render",
        value: function render() {
          return (0, _index.html)(_templateObject_2240af70942811ecb1937969798b231a || (_templateObject_2240af70942811ecb1937969798b231a = babelHelpers.taggedTemplateLiteral(["\n      <div class=\"wrapper\">\n        <div class=\"stars\">\n          ", "\n        </div>\n        <div class=\"rating\">\n          ", " (", "/", ")\n        </div>\n      </div>\n    "])), this.renderStar(this.numStars, this.interactive), this._calPercent, this.score, this.possible);
        }
      }, {
        key: "renderStar",
        value: function renderStar(amount, interactive) {
          if (amount === 0) {
            return (0, _index.html)(_templateObject2_2240af70942811ecb1937969798b231a || (_templateObject2_2240af70942811ecb1937969798b231a = babelHelpers.taggedTemplateLiteral([""])));
          }
  
          var count = 0;
          var content = [];
  
          while (count < amount) {
            var icon = "star";
  
            if (count + 1 <= amount * this._calPercent) {} else if (amount * this._calPercent - (count + 1) < -0.01 && amount * this._calPercent - (count + 1) >= -0.5) {
              icon = "star-half";
            } else {
              icon = "star-border";
            } // interactive so it's a button
  
  
            if (interactive) {
              content.push((0, _index.html)(_templateObject3_2240af70942811ecb1937969798b231a || (_templateObject3_2240af70942811ecb1937969798b231a = babelHelpers.taggedTemplateLiteral(["<simple-icon-button\n            @click=\"", "\"\n            icon=\"", "\"\n            accent-color=\"", "\"\n            ?dark=\"", "\"\n            contrast=\"", "\"\n            class=\"star\"\n            data-value=\"", "\"\n          ></simple-icon-button>"])), this.interactiveEvent, icon, this.accentColor, this.dark, this.contrast, Number(count + 1)));
            } else {
              content.push((0, _index.html)(_templateObject4_2240af70942811ecb1937969798b231a || (_templateObject4_2240af70942811ecb1937969798b231a = babelHelpers.taggedTemplateLiteral(["<simple-icon\n            icon=\"", "\"\n            accent-color=\"", "\"\n            ?dark=\"", "\"\n            contrast=\"", "\"\n            class=\"star\"\n          ></simple-icon>"])), icon, this.accentColor, this.dark, this.contrast));
            }
  
            count++;
          }
  
          return content;
        }
      }, {
        key: "interactiveEvent",
        value: function interactiveEvent(e) {
          this.dispatchEvent(new CustomEvent("star-rating-click", {
            bubbles: true,
            cancelable: true,
            detail: {
              value: e.target.getAttribute("data-value")
            }
          }));
        }
      }, {
        key: "updated",
        value: function updated(changedProperties) {
          var _this2 = this;
  
          if (babelHelpers.get(babelHelpers.getPrototypeOf(StarRating.prototype), "updated", this)) {
            babelHelpers.get(babelHelpers.getPrototypeOf(StarRating.prototype), "updated", this).call(this, changedProperties);
          } // run through properties that have changed in this change record. Probably just 1 but at initial setup
          // it could be all of them at the same time
  
  
          changedProperties.forEach(function (oldValue, propName) {
            // also sanity check that it's NOT 0 so we don't bust our Math via division by 0
            if (_this2.possible === 0) {
              _this2.possible = 1;
            } // https://stackoverflow.com/questions/6137986/javascript-roundoff-number-to-nearest-0-5
  
  
            if (["score", "possible"].includes(propName) && _this2.possible !== 0) {
              // this way when score or possible update, numStars will update automatically
              _this2._calPercent = Math.round(_this2.score / _this2.possible * 100) / 100;
            }
          });
        }
      }], [{
        key: "tag",
        get: function get() {
          return "star-rating";
        }
      }, {
        key: "styles",
        get: function get() {
          return [].concat(babelHelpers.toConsumableArray(babelHelpers.get(babelHelpers.getPrototypeOf(StarRating), "styles", this)), [(0, _index.css)(_templateObject5_2240af70942811ecb1937969798b231a || (_templateObject5_2240af70942811ecb1937969798b231a = babelHelpers.taggedTemplateLiteral(["\n        :host {\n          display: block;\n          font-size: 12px;\n          font-weight: normal;\n          --star-rating-padding-left: 12px;\n          --star-rating-margin: 0;\n          --star-rating-size: 24px;\n        }\n        .wrapper {\n          display: inline-flex;\n        }\n        .stars {\n          background-color: var(\n            --star-rating-background-color,\n            var(--simple-colors-default-theme-grey-9)\n          );\n        }\n        simple-icon,\n        simple-icon-button {\n          --simple-icon-color: var(\n            --star-rating-color,\n            var(--simple-colors-default-theme-accent-7)\n          );\n          --simple-icon-height: var(--star-rating-size, 24px);\n          --simple-icon-width: var(--star-rating-size, 24px);\n        }\n        .rating {\n          padding-left: var(--star-rating-padding-left);\n          margin: var(--star-rating-margin);\n          line-height: var(--star-rating-size, 24px);\n          vertical-align: center;\n        }\n        :host(:not([interactive])) simple-icon-button::part(button) {\n          cursor: unset;\n        }\n      "])))]);
        }
      }, {
        key: "properties",
        get: function get() {
          return _objectSpread(_objectSpread({}, babelHelpers.get(babelHelpers.getPrototypeOf(StarRating), "properties", this)), {}, {
            score: {
              type: Number
            },
            // so like <star-rating score="50" possible="100">
            possible: {
              type: Number
            },
            interactive: {
              type: Boolean,
              reflect: true
            },
            numStars: {
              type: Number,
              attribute: "num-stars"
            },
            _calPercent: {
              type: Number
            } // this value we'll calculate based on changes to score and possible
  
          });
        }
      }]);
      return StarRating;
    }(_simpleColors.SimpleColors);
  
    _exports.StarRating = StarRating;
    customElements.define(StarRating.tag, StarRating);
  });