保誠-保戶業務員媒合平台
Tomas
2022-05-19 957a1f10a06fdbb76f1a0ba94fe44126c613fee3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"use strict";
 
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; }
 
// Generated by CoffeeScript 2.5.1
var Block, Layout, SpecialString, cloneAndMergeDeep, i, len, prop, ref, terminalWidth;
Block = require('./layout/Block');
 
var _require = require('./tools');
 
cloneAndMergeDeep = _require.cloneAndMergeDeep;
SpecialString = require('./layout/SpecialString');
terminalWidth = require('./tools').getCols();
 
module.exports = Layout = function () {
  var self;
 
  var Layout = /*#__PURE__*/function () {
    function Layout() {
      var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var rootBlockConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
 
      _classCallCheck(this, Layout);
 
      var rootConfig;
      this._written = [];
      this._activeBlock = null;
      this._config = cloneAndMergeDeep(self._defaultConfig, config); // Every layout has a root block
 
      rootConfig = cloneAndMergeDeep(self._rootBlockDefaultConfig, rootBlockConfig);
      this._root = new Block(this, null, rootConfig, '__root');
 
      this._root._open();
    }
 
    _createClass(Layout, [{
      key: "getRootBlock",
      value: function getRootBlock() {
        return this._root;
      }
    }, {
      key: "_append",
      value: function _append(text) {
        return this._written.push(text);
      }
    }, {
      key: "_appendLine",
      value: function _appendLine(text) {
        var s;
 
        this._append(text);
 
        s = new SpecialString(text);
 
        if (s.length < this._config.terminalWidth) {
          this._append('<none>\n</none>');
        }
 
        return this;
      }
    }, {
      key: "get",
      value: function get() {
        this._ensureClosed();
 
        if (this._written[this._written.length - 1] === '<none>\n</none>') {
          this._written.pop();
        }
 
        return this._written.join("");
      }
    }, {
      key: "_ensureClosed",
      value: function _ensureClosed() {
        if (this._activeBlock !== this._root) {
          throw Error("Not all the blocks have been closed. Please call block.close() on all open blocks.");
        }
 
        if (this._root.isOpen()) {
          this._root.close();
        }
      }
    }]);
 
    return Layout;
  }();
 
  ;
  self = Layout;
  Layout._rootBlockDefaultConfig = {
    linePrependor: {
      options: {
        amount: 0
      }
    },
    lineAppendor: {
      options: {
        amount: 0
      }
    },
    blockPrependor: {
      options: {
        amount: 0
      }
    },
    blockAppendor: {
      options: {
        amount: 0
      }
    }
  };
  Layout._defaultConfig = {
    terminalWidth: terminalWidth
  };
  return Layout;
}.call(void 0);
 
ref = ['openBlock', 'write'];
 
for (i = 0, len = ref.length; i < len; i++) {
  prop = ref[i];
 
  (function () {
    var method;
    method = prop;
    return Layout.prototype[method] = function () {
      return this._root[method].apply(this._root, arguments);
    };
  })();
}