"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
 * Copyright 2021 The Kubernetes Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class FancyPipeline extends _react.default.PureComponent {
  linebreak() {
    return _react.default.createElement("span", {
      className: "kui--line-break"
    }, "\u00A0");
  }
  pipe(c) {
    return _react.default.createElement("strong", {
      className: "pre-wrap left-pad sub-text"
    }, c, " ");
  }
  /**
   * Pretty-print the command line with `pipeStages`
   * e.g. somePrefix -- foo | bar > baz
   */
  render() {
    const {
      prefix,
      stages,
      redirect,
      redirector,
      REPL
    } = this.props;
    return _react.default.createElement("span", {
      className: "repl-input-element flex-fill"
    }, prefix && _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("span", {
      className: "pre-wrap"
    }, prefix, " -- "), (stages.length > 0 || redirect) && _react.default.createElement(_react.default.Fragment, null, this.linebreak(), this.pipe('\u00a0'))), stages.map((pipePart, pidx, parts) => _react.default.createElement(_react.default.Fragment, {
      key: pidx
    }, pidx > 0 && this.pipe('|'), pipePart.map((word, widx) => widx === 0 ? _react.default.createElement("span", {
      key: widx,
      className: "color-base0C"
    }, word) : ` ${word}`), pidx < parts.length - 1 && this.linebreak())), redirect && _react.default.createElement(_react.default.Fragment, null, this.linebreak(), this.pipe(redirector), _react.default.createElement("span", {
      className: "clickable",
      onClick: () => REPL.pexec(`ls ${redirect}`)
    }, redirect)));
  }
}
exports.default = FancyPipeline;