+exports.Clo = exports.calculateTextWidthHeight = exports.hyphenTkTree = exports.filterEmptyString = exports.spacesToBreakpoint = exports.hyphenForClo = exports.splitCJKV = exports.twoReturnsToNewline = exports.ptToPx = exports.cjkvRegexPattern = exports.cjkvBlocksInRegex = exports.defaultFrameStyle = exports.defaultTextStyle = exports.A4_IN_PX = exports.Direction = void 0;
+const canva_1 = require("../canva");
+const jsdom_1 = require("jsdom");
+/**
+ * TYPES
+ */
+/**
+ * text direction
+ * LTR - left to right
+ * TTB - top to bottom
+ * etc.
+ */
+var Direction;
+(function (Direction) {
+ Direction[Direction["LTR"] = 0] = "LTR";
+ Direction[Direction["RTL"] = 1] = "RTL";
+ Direction[Direction["TTB"] = 2] = "TTB";
+ Direction[Direction["BTT"] = 3] = "BTT";
+})(Direction || (exports.Direction = Direction = {}));
+/**
+ * DEFAULT CONST PART
+ */
+exports.A4_IN_PX = { "width": 793.7,
+ "height": 1122.5 };
+exports.defaultTextStyle = {
+ family: "FreeSerif",
+ size: ptToPx(12),
+ textWeight: canva_1.TextWeight.REGULAR,
+ fontStyle: canva_1.FontStyle.ITALIC,
+};
+exports.defaultFrameStyle = {
+ directionInsideLine: Direction.LTR,
+ direction: Direction.TTB,
+ baseLineskip: ptToPx(15),
+ textStyle: exports.defaultTextStyle,
+ x: exports.A4_IN_PX.width * 0.10,
+ y: exports.A4_IN_PX.height * 0.10,
+ width: exports.A4_IN_PX.width * 0.80,
+ height: exports.A4_IN_PX.height * 0.80,
+ content: null,
+};
+/**
+ * definition for cjk scripts
+ * - Hani : Han Character
+ * - Hang : Hangul
+ * - Bopo : Bopomofo
+ * - Kana : Katakana
+ * - Hira : Hiragana
+*/
+exports.cjkvBlocksInRegex = ["Hani", "Hang", "Bopo", "Kana", "Hira"];
+exports.cjkvRegexPattern = new RegExp("((?:" +
+ exports.cjkvBlocksInRegex.map((x) => "\\p{Script_Extensions=" + x + "}").join("|") + ")+)", "gu");
+/**
+ * FUNCTION PART
+ */
+/**
+ * convert from ptToPx
+ * @param pt pt size value
+ * @returns the corresponding px value
+ */
+function ptToPx(pt) {
+ return pt * 4.0 / 3.0;
+}
+exports.ptToPx = ptToPx;
+/**
+ * REGISTER PART
+ */
+/**
+ * convert '\n\n' to newline command ["nl"]
+ * @param arr the input `tkTree`
+ * @param clo the `Clo` object
+ * @returns the input tktree
+ */
+function twoReturnsToNewline(arr, clo) {
+ var middle = [];
+ for (let i = 0; i < arr.length; i++) {
+ var item = arr[i];
+ if (!Array.isArray(item)) {
+ middle = middle.concat(item.split(/(\n\n)/g));
+ }
+ else {
+ middle.push(item);
+ }
+ }
+ var result = [];
+ for (let j = 0; j < middle.length; j++) {
+ var item = middle[j];
+ if (!Array.isArray(item) && item == "\n\n") {
+ result.push(["nl"]); // push a newline command to the result `tkTree`
+ }
+ else {
+ result.push(middle[j]);
+ }
+ }
+ return result;
+}
+exports.twoReturnsToNewline = twoReturnsToNewline;
+/**
+ * split CJKV and non-CJKV
+ *
+ * @param arr : input tkTree
+ * @returns a splitted tkTree (by CJK and NonCJK)
+ * - Examples:
+ * ```
+ * [`many臺中daylight`] => [`many`, `臺中`, `dahylight`]
+ * ```
+ */
+function splitCJKV(arr, clo) {
+ var result = [];