Liferay.Loader.define("dynamic-data-mapping-form-web@3.0.87/admin/js/components/ShareFormModal/Link.es", ['module', 'exports', 'require', 'frontend-js-react-web$classnames', 'dynamic-data-mapping-form-web$clipboard', 'dynamic-data-mapping-form-builder/js/util/dom.es', 'frontend-js-metal-web$metal-jsx'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _clipboard = _interopRequireDefault(require("dynamic-data-mapping-form-web$clipboard"));

    var _dom = require("dynamic-data-mapping-form-builder/js/util/dom.es");

    var _metalJsx = _interopRequireWildcard(require("frontend-js-metal-web$metal-jsx"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

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

    function _defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
      }
    }

    function _createClass(Constructor, protoProps, staticProps) {
      if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;
    }

    function _possibleConstructorReturn(self, call) {
      if (call && (_typeof(call) === "object" || typeof call === "function")) {
        return call;
      }return _assertThisInitialized(self);
    }

    function _assertThisInitialized(self) {
      if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
      }return self;
    }

    function _get(target, property, receiver) {
      if (typeof Reflect !== "undefined" && Reflect.get) {
        _get = Reflect.get;
      } else {
        _get = function _get(target, property, receiver) {
          var base = _superPropBase(target, property);if (!base) return;var desc = Object.getOwnPropertyDescriptor(base, property);if (desc.get) {
            return desc.get.call(receiver);
          }return desc.value;
        };
      }return _get(target, property, receiver || target);
    }

    function _superPropBase(object, property) {
      while (!Object.prototype.hasOwnProperty.call(object, property)) {
        object = _getPrototypeOf(object);if (object === null) break;
      }return object;
    }

    function _getPrototypeOf(o) {
      _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
      };return _getPrototypeOf(o);
    }

    function _inherits(subClass, superClass) {
      if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
      }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });if (superClass) _setPrototypeOf(subClass, superClass);
    }

    function _setPrototypeOf(o, p) {
      _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
        o.__proto__ = p;return o;
      };return _setPrototypeOf(o, p);
    }

    var Link = /*#__PURE__*/function (_Component) {
      _inherits(Link, _Component);

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

        return _possibleConstructorReturn(this, _getPrototypeOf(Link).apply(this, arguments));
      }

      _createClass(Link, [{
        key: "attached",
        value: function attached() {
          this._clipboard = new _clipboard.default('.ddm-copy-clipboard');

          this._clipboard.on('success', this._handleClipboardSuccess.bind(this));
        }
      }, {
        key: "disposeInternal",
        value: function disposeInternal() {
          _get(_getPrototypeOf(Link.prototype), "disposeInternal", this).call(this);

          this._clipboard.destroy();
        }
      }, {
        key: "init",
        value: function init() {
          this.setState({
            success: false
          });
        }
      }, {
        key: "render",
        value: function render() {
          var _this$props = this.props,
              spritemap = _this$props.spritemap,
              url = _this$props.url;
          var success = this.state.success;
          var buttonClasses = (0, _classnames.default)('btn ddm-copy-clipboard', {
            'btn-secondary': !success,
            'btn-success': success
          });
          var formClasses = (0, _classnames.default)('share-form-modal-item-link form-group m-0', {
            'has-success': success
          });
          IncrementalDOM.elementOpen("div", null, null, "class", formClasses);
          IncrementalDOM.elementOpen("div", null, null, "class", "input-group");
          IncrementalDOM.elementOpen("div", null, null, "class", "input-group-item input-group-prepend");
          IncrementalDOM.elementVoid("input", null, null, "value", url, "class", "form-control", "readOnly", true, "ref", "shareFieldURL", "type", "text");
          iDOMHelpers.renderArbitrary(success && (IncrementalDOM.elementOpen("div", null, null, "class", "form-feedback-group"), (IncrementalDOM.elementOpen("div", null, null, "class", "form-feedback-item"), iDOMHelpers.renderArbitrary(Liferay.Language.get('copied-to-clipboard')), IncrementalDOM.elementClose("div")), IncrementalDOM.elementClose("div")));
          IncrementalDOM.elementClose("div");
          IncrementalDOM.elementOpen("span", null, null, "class", "input-group-append input-group-item input-group-item-shrink");
          IncrementalDOM.elementOpen("button", null, null, "class", buttonClasses, "data-clipboard-text", url, "type", "button");
          iDOMHelpers.renderArbitrary(success ? (IncrementalDOM.elementOpen("span", null, null, "class", "publish-button-success-icon pl-2 pr-2"), (IncrementalDOM.elementOpen("svg", null, null, "aria-hidden", "true", "class", 'lexicon-icon lexicon-icon-check'), IncrementalDOM.elementVoid("use", null, null, "xlink:href", "".concat(spritemap, "#check")), IncrementalDOM.elementClose("svg")), IncrementalDOM.elementClose("span")) : (IncrementalDOM.elementOpen("span", null, null, "class", "publish-button-text"), iDOMHelpers.renderArbitrary(Liferay.Language.get('copy')), IncrementalDOM.elementClose("span")));
          IncrementalDOM.elementClose("button");
          IncrementalDOM.elementClose("span");
          IncrementalDOM.elementClose("div");
          return IncrementalDOM.elementClose("div");
        }
      }, {
        key: "rendered",
        value: function rendered() {
          var _this = this;

          var success = this.state.success;

          if (success) {
            setTimeout(function () {
              var shareFieldURL = _this.element.querySelector('input');

              (0, _dom.selectText)(shareFieldURL);
            }, 30);
          }
        }
      }, {
        key: "_handleClipboardSuccess",
        value: function _handleClipboardSuccess() {
          this.setState({
            success: true
          });
        }
      }]);

      return Link;
    }(_metalJsx.default);

    Link.PROPS = {
      /**
       * @default undefined
       * @instance
       * @memberof Link
       * @type {!spritemap}
       */
      spritemap: _metalJsx.Config.string().required(),

      /**
       * @default undefined
       * @instance
       * @memberof Link
       * @type {!string}
       */
      url: _metalJsx.Config.string().required()
    };
    Link.STATE = {
      /**
       * @default false
       * @instance
       * @memberof Link
       * @type {!bool}
       */
      success: _metalJsx.Config.bool().value(false)
    };
    var _default = Link;
    exports.default = _default;
    //# sourceMappingURL=Link.es.js.map
  }
});
//# sourceMappingURL=Link.es.js.map