laymur 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Builders/UICommonDoubleElementConstraintDescriptionInterfaces.d.ts +2 -2
- package/dist/Builders/UIConstraint2DBuilder.d.ts +40 -5
- package/dist/Builders/UIStackConstraintBuilder.d.ts +3 -3
- package/dist/Constraints/UIAspectConstraint.d.ts +2 -2
- package/dist/Constraints/UICoverConstraint.d.ts +2 -2
- package/dist/Constraints/UIFitConstraint.d.ts +2 -2
- package/dist/Constraints/UIHeightConstraint.d.ts +2 -2
- package/dist/Constraints/UIHorizontalDistanceConstraint.d.ts +2 -2
- package/dist/Constraints/UIHorizontalProportionConstraint.d.ts +2 -2
- package/dist/Constraints/UIVerticalDistanceConstraint.d.ts +2 -2
- package/dist/Constraints/UIVerticalProportionConstraint.d.ts +2 -2
- package/dist/Constraints/UIWidthConstraint.d.ts +2 -2
- package/dist/Elements/UIText.d.ts +2 -2
- package/dist/Passes/UIPass.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/Builders/UIConstraint2DBuilderInterfaces.d.ts +0 -62
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../node_modules/kiwi.js/es/maptype.js","../node_modules/kiwi.js/es/variable.js","../node_modules/kiwi.js/es/expression.js","../node_modules/kiwi.js/es/strength.js","../node_modules/kiwi.js/es/constraint.js","../node_modules/kiwi.js/es/solver.js","../src/Miscellaneous/symbols.ts","../src/Miscellaneous/UIOrientation.ts","../src/Constraints/UIConstraintPower.ts","../src/Constraints/UIConstraintRule.ts","../src/Constraints/UIConstraint.ts","../src/Constraints/UIHeightConstraint.ts","../node_modules/eventail/dist/index.js","../src/Miscellaneous/math.ts","../src/Miscellaneous/UIBehavior.ts","../src/Miscellaneous/UIMicroTransformations.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIDrawPass.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Miscellaneous/microTransformationTools.ts","../src/Layers/UILayer.ts","../src/Miscellaneous/asserts.ts","../src/Constraints/UIHorizontalDistanceConstraint.ts","../src/Constraints/UIHorizontalProportionConstraint.ts","../src/Constraints/UIVerticalDistanceConstraint.ts","../src/Constraints/UIVerticalProportionConstraint.ts","../src/Constraints/UIWidthConstraint.ts","../src/Builders/UIConstraint2DBuilder.ts","../src/Constraints/UIAspectConstraint.ts","../src/Constraints/UICoverConstraint.ts","../src/Builders/UICommonDoubleElementConstraintDescriptionInterfaces.ts","../src/Builders/UICommonSingleElementConstraintDescriptionInterfaces.ts","../src/Builders/UIConstraintBuilder.ts","../src/Elements/UIDummy.ts","../src/Passes/UIMaterial.ts","../src/Elements/UIImage.ts","../src/Passes/UIProgressMaterial.ts","../src/Elements/UIProgress.ts","../src/Miscellaneous/textTools.ts","../src/Elements/UIText.ts","../src/Builders/UIElementBuilderInterfaces.ts","../src/Elements/UITextInterfaces.ts","../src/Builders/UIElementBuilder.ts","../src/Builders/UIStackConstraintBuilder.ts","../src/Constraints/UIFitConstraint.ts","../src/Layers/UIFullScreenLayer.ts","../src/Layers/UIManualLayer.ts","../src/Passes/UIPass.ts"],"sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nexport function createMap() {\n return new IndexedMap();\n}\nvar IndexedMap = /** @class */ (function () {\n function IndexedMap() {\n this.index = {};\n this.array = [];\n }\n /**\n * Returns the number of items in the array.\n */\n IndexedMap.prototype.size = function () {\n return this.array.length;\n };\n /**\n * Returns true if the array is empty.\n */\n IndexedMap.prototype.empty = function () {\n return this.array.length === 0;\n };\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n IndexedMap.prototype.itemAt = function (index) {\n return this.array[index];\n };\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.contains = function (key) {\n return this.index[key.id()] !== undefined;\n };\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.find = function (key) {\n var i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n };\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n IndexedMap.prototype.setDefault = function (key, factory) {\n var i = this.index[key.id()];\n if (i === undefined) {\n var pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n };\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n IndexedMap.prototype.insert = function (key, value) {\n var pair = new Pair(key, value);\n var i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n };\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n IndexedMap.prototype.erase = function (key) {\n var i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n var pair = this.array[i];\n var last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n };\n /**\n * Create a copy of this associative array.\n */\n IndexedMap.prototype.copy = function () {\n var copy = new IndexedMap();\n for (var i = 0; i < this.array.length; i++) {\n var pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n };\n return IndexedMap;\n}());\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nvar Pair = /** @class */ (function () {\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n function Pair(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n Pair.prototype.copy = function () { return new Pair(this.first, this.second); };\n return Pair;\n}());\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nvar Variable = /** @class */ (function () {\n function Variable(name) {\n if (name === void 0) { name = \"\"; }\n this._value = 0.0;\n this._context = null;\n this._id = VarId++;\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n Variable.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n Variable.prototype.name = function () {\n return this._name;\n };\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n Variable.prototype.setName = function (name) {\n this._name = name;\n };\n /**\n * Returns the user context object of the variable.\n * @private\n */\n Variable.prototype.context = function () {\n return this._context;\n };\n /**\n * Set the user context object of the variable.\n * @private\n */\n Variable.prototype.setContext = function (context) {\n this._context = context;\n };\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n Variable.prototype.value = function () {\n return this._value;\n };\n /**\n * Set the value of the variable.\n * @private\n */\n Variable.prototype.setValue = function (value) {\n this._value = value;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Variable.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Variable.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Variable.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Variable.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n Variable.prototype.toJSON = function () {\n return {\n name: this._name,\n value: this._value,\n };\n };\n Variable.prototype.toString = function () {\n return this._context + \"[\" + this._name + \":\" + this._value + \"]\";\n };\n return Variable;\n}());\nexport { Variable };\n/**\n * The internal variable id counter.\n * @private\n */\nvar VarId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { createMap } from \"./maptype\";\nimport { Variable } from \"./variable\";\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nvar Expression = /** @class */ (function () {\n function Expression() {\n var parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n Expression.prototype.terms = function () {\n return this._terms;\n };\n /**\n * Returns the constant of the expression.\n * @private\n */\n Expression.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n Expression.prototype.value = function () {\n var result = this._constant;\n for (var i = 0, n = this._terms.size(); i < n; i++) {\n var pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Expression.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Expression.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Expression.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Expression.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n Expression.prototype.isConstant = function () {\n return this._terms.size() == 0;\n };\n Expression.prototype.toString = function () {\n var result = this._terms.array.map(function (pair) {\n return (pair.second + \"*\" + pair.first.toString());\n }).join(\" + \");\n if (!this.isConstant() && this._constant !== 0) {\n result += \" + \";\n }\n result += this._constant;\n return result;\n };\n return Expression;\n}());\nexport { Expression };\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n var constant = 0.0;\n var factory = function () { return 0.0; };\n var terms = createMap();\n for (var i = 0, n = args.length; i < n; ++i) {\n var item = args[i];\n if (typeof item === \"number\") {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n var terms2 = item.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error(\"array must have length 2\");\n }\n var value = item[0];\n var value2 = item[1];\n if (typeof value !== \"number\") {\n throw new Error(\"array item 0 must be a number\");\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += (value2.constant() * value);\n var terms2 = value2.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += (termPair.second * value);\n }\n }\n else {\n throw new Error(\"array item 1 must be a variable or expression\");\n }\n }\n else {\n throw new Error(\"invalid Expression argument: \" + item);\n }\n }\n return { terms: terms, constant: constant };\n}\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * @class Strength\n */\nvar Strength = /** @class */ (function () {\n function Strength() {\n }\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n Strength.create = function (a, b, c, w) {\n if (w === void 0) { w = 1.0; }\n var result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n };\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n Strength.clip = function (value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n };\n /**\n * The 'required' symbolic strength.\n */\n Strength.required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n Strength.strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n Strength.medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n Strength.weak = Strength.create(0.0, 0.0, 1.0);\n return Strength;\n}());\nexport { Strength };\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\nimport { Strength } from \"./strength\";\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nvar Constraint = /** @class */ (function () {\n function Constraint(expression, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n this._id = CnId++;\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if ((rhs === undefined) && (expression instanceof Expression)) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n Constraint.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n Constraint.prototype.expression = function () {\n return this._expression;\n };\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n Constraint.prototype.op = function () {\n return this._operator;\n };\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n Constraint.prototype.strength = function () {\n return this._strength;\n };\n Constraint.prototype.toString = function () {\n return this._expression.toString() + \" \" + [\"<=\", \">=\", \"=\"][this._operator] + \" 0 (\" + this._strength.toString() + \")\";\n };\n return Constraint;\n}());\nexport { Constraint };\n/**\n * The internal constraint id counter.\n * @private\n */\nvar CnId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Constraint, Operator } from \"./constraint\";\nimport { Expression } from \"./expression\";\nimport { createMap } from \"./maptype\";\nimport { Strength } from \"./strength\";\n/**\n * The constraint solver class.\n *\n * @class\n */\nvar Solver = /** @class */ (function () {\n /**\n * Construct a new Solver.\n */\n function Solver() {\n this._cnMap = createCnMap();\n this._rowMap = createRowMap();\n this._varMap = createVarMap();\n this._editMap = createEditMap();\n this._infeasibleRows = [];\n this._objective = new Row();\n this._artificial = null;\n this._idTick = 0;\n }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n Solver.prototype.createConstraint = function (lhs, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n var cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n };\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n Solver.prototype.addConstraint = function (constraint) {\n var cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error(\"duplicate constraint\");\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n var data = this._createRow(constraint);\n var row = data.row;\n var tag = data.tag;\n var subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error(\"unsatisfiable constraint\");\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error(\"unsatisfiable constraint\");\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n };\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n Solver.prototype.removeConstraint = function (constraint) {\n var cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error(\"unknown constraint\");\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n var marker = cnPair.second.marker;\n var rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n var leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"failed to find leaving row\");\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n };\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasConstraint = function (constraint) {\n return this._cnMap.contains(constraint);\n };\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n Solver.prototype.addEditVariable = function (variable, strength) {\n var editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error(\"duplicate edit variable\");\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error(\"bad required strength\");\n }\n var expr = new Expression(variable);\n var cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n var tag = this._cnMap.find(cn).second;\n var info = { tag: tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n };\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n Solver.prototype.removeEditVariable = function (variable) {\n var editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n this.removeConstraint(editPair.second.constraint);\n };\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasEditVariable = function (variable) {\n return this._editMap.contains(variable);\n };\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n Solver.prototype.suggestValue = function (variable, value) {\n var editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n var rows = this._rowMap;\n var info = editPair.second;\n var delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n var marker = info.tag.marker;\n var rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n var other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var rowPair_1 = rows.itemAt(i);\n var row = rowPair_1.second;\n var coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 &&\n rowPair_1.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair_1.first);\n }\n }\n this._dualOptimize();\n };\n /**\n * Update the values of the variables.\n */\n Solver.prototype.updateVariables = function () {\n var vars = this._varMap;\n var rows = this._rowMap;\n for (var i = 0, n = vars.size(); i < n; ++i) {\n var pair = vars.itemAt(i);\n var rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n };\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n Solver.prototype._getVarSymbol = function (variable) {\n var _this = this;\n var factory = function () { return _this._makeSymbol(SymbolType.External); };\n return this._varMap.setDefault(variable, factory).second;\n };\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n Solver.prototype._createRow = function (constraint) {\n var expr = constraint.expression();\n var row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n var terms = expr.terms();\n for (var i = 0, n = terms.size(); i < n; ++i) {\n var termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n var symbol = this._getVarSymbol(termPair.first);\n var basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n var objective = this._objective;\n var strength = constraint.strength();\n var tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge:\n {\n var coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n var slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n var error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq:\n {\n if (strength < Strength.required) {\n var errplus = this._makeSymbol(SymbolType.Error);\n var errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n var dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row: row, tag: tag };\n };\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._chooseSubject = function (row, tag) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n var type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n Solver.prototype._addWithArtificialVariable = function (row) {\n // Create and add the artificial variable to the tableau.\n var art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n var success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n var pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n var basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n var entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n };\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n Solver.prototype._substitute = function (symbol, row) {\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 &&\n pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n };\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n Solver.prototype._optimize = function (objective) {\n while (true) {\n var entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n var leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"the objective is unbounded\");\n }\n // pivot the entering symbol into the basis\n var row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n }\n };\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n Solver.prototype._dualOptimize = function () {\n var rows = this._rowMap;\n var infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n var leaving = infeasible.pop();\n var pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n var entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error(\"dual optimize failed\");\n }\n // pivot the entering symbol into the basis\n var row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n };\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n Solver.prototype._getEnteringSymbol = function (objective) {\n var cells = objective.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n Solver.prototype._getDualEnteringSymbol = function (row) {\n var ratio = Number.MAX_VALUE;\n var entering = INVALID_SYMBOL;\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n var c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n var coeff = this._objective.coefficientFor(symbol);\n var r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n };\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n Solver.prototype._getLeavingSymbol = function (entering) {\n var ratio = Number.MAX_VALUE;\n var found = INVALID_SYMBOL;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n var row = pair.second;\n var temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n var temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n };\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n Solver.prototype._getMarkerLeavingSymbol = function (marker) {\n var dmax = Number.MAX_VALUE;\n var r1 = dmax;\n var r2 = dmax;\n var invalid = INVALID_SYMBOL;\n var first = invalid;\n var second = invalid;\n var third = invalid;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var row = pair.second;\n var c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n var symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n var r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n var r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n };\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n Solver.prototype._removeConstraintEffects = function (cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n };\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n Solver.prototype._removeMarkerEffects = function (marker, strength) {\n var pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n };\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._anyPivotableSymbol = function (row) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n Solver.prototype._makeSymbol = function (type) {\n return new Symbol(type, this._idTick++);\n };\n return Solver;\n}());\nexport { Solver };\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n var eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nvar Symbol = /** @class */ (function () {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n function Symbol(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n Symbol.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the type of the symbol.\n */\n Symbol.prototype.type = function () {\n return this._type;\n };\n return Symbol;\n}());\n/**\n * A static invalid symbol\n * @private\n */\nvar INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nvar Row = /** @class */ (function () {\n /**\n * Construct a new Row.\n */\n function Row(constant) {\n if (constant === void 0) { constant = 0.0; }\n this._cellMap = createMap();\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n Row.prototype.cells = function () {\n return this._cellMap;\n };\n /**\n * Returns the constant for the row.\n */\n Row.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns true if the row is a constant value.\n */\n Row.prototype.isConstant = function () {\n return this._cellMap.empty();\n };\n /**\n * Returns true if the Row has all dummy symbols.\n */\n Row.prototype.allDummies = function () {\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n };\n /**\n * Create a copy of the row.\n */\n Row.prototype.copy = function () {\n var theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n };\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n Row.prototype.add = function (value) {\n return this._constant += value;\n };\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n Row.prototype.insertSymbol = function (symbol, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n var pair = this._cellMap.setDefault(symbol, function () { return 0.0; });\n if (nearZero(pair.second += coefficient)) {\n this._cellMap.erase(symbol);\n }\n };\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n Row.prototype.insertRow = function (other, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n this._constant += other._constant * coefficient;\n var cells = other._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n };\n /**\n * Remove a symbol from the row.\n */\n Row.prototype.removeSymbol = function (symbol) {\n this._cellMap.erase(symbol);\n };\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n Row.prototype.reverseSign = function () {\n this._constant = -this._constant;\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n };\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n Row.prototype.solveFor = function (symbol) {\n var cells = this._cellMap;\n var pair = cells.erase(symbol);\n var coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n };\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n Row.prototype.solveForEx = function (lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n };\n /**\n * Returns the coefficient for the given symbol.\n */\n Row.prototype.coefficientFor = function (symbol) {\n var pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n };\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n Row.prototype.substitute = function (symbol, row) {\n var pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n };\n return Row;\n}());\n","export const xSymbol = Symbol(\"xSymbol\");\nexport const ySymbol = Symbol(\"ySymbol\");\n\nexport const widthSymbol = Symbol(\"widthSymbol\");\nexport const heightSymbol = Symbol(\"heightSymbol\");\n\nexport const addUIElementSymbol = Symbol(\"addUIElementSymbol\");\nexport const removeUIElementSymbol = Symbol(\"removeUIElementSymbol\");\n\nexport const addUIConstraintSymbol = Symbol(\"addConstraintSymbol\");\nexport const removeUIConstraintSymbol = Symbol(\"removeUIConstraintSymbol\");\n\nexport const addConstraintSymbol = Symbol(\"addConstraintSymbol\");\nexport const removeConstraintSymbol = Symbol(\"removeConstraintSymbol\");\n\nexport const addVariableSymbol = Symbol(\"addVariableSymbol\");\nexport const removeVariableSymbol = Symbol(\"removeVariableSymbol\");\nexport const suggestVariableSymbol = Symbol(\"suggestVariableSymbol\");\n\nexport const disableConstraintSymbol = Symbol(\"disableConstraintSymbol\");\nexport const enableConstraintSymbol = Symbol(\"enableConstraintSymbol\");\n\nexport const needsRecalculation = Symbol(\"needsRecalculation\");\nexport const renderSymbol = Symbol(\"renderSymbol\");\n\nexport const clickSymbol = Symbol(\"clickSymbol\");\n","export enum UIOrientation {\n LANDSCAPE,\n PORTRAIT,\n ALWAYS,\n}\n\nexport function isUIOrientation(obj: unknown): obj is UIOrientation {\n return obj !== null && Object.values(UIOrientation).some((v) => v === obj);\n}\n\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","import { Strength } from \"kiwi.js\";\n\nexport enum UIConstraintPower {\n P0,\n P1,\n P2,\n P3,\n P4,\n P5,\n P6,\n P7,\n}\n\nexport function isUIConstraintPower(obj: unknown): obj is UIConstraintPower {\n return (\n obj !== null && Object.values(UIConstraintPower).some((v) => v === obj)\n );\n}\n\nexport function resolvePower(power?: UIConstraintPower): UIConstraintPower {\n return power ?? UIConstraintPower.P0;\n}\n\nexport function convertPowerToStrength(power?: UIConstraintPower): number {\n switch (power) {\n case UIConstraintPower.P0:\n return Strength.create(1000, 1000, 1000);\n case UIConstraintPower.P1:\n return Strength.create(100, 0, 0);\n case UIConstraintPower.P2:\n return Strength.create(10, 0, 0);\n case UIConstraintPower.P3:\n return Strength.create(0, 100, 0);\n case UIConstraintPower.P4:\n return Strength.create(0, 10, 0);\n case UIConstraintPower.P5:\n return Strength.create(0, 0, 100);\n case UIConstraintPower.P6:\n return Strength.create(0, 0, 10);\n case UIConstraintPower.P7:\n return Strength.create(0, 0, 1);\n default:\n return Strength.create(1000, 1000, 1000);\n }\n}\n","import { Operator } from \"kiwi.js\";\n\nexport enum UIConstraintRule {\n EQUAL = Operator.Eq,\n LESS = Operator.Le,\n GREATER = Operator.Ge,\n}\n\nexport function isUIConstraintRule(obj: unknown): obj is UIConstraintRule {\n return obj !== null && Object.values(UIConstraintRule).some((v) => v === obj);\n}\n\nexport function resolveRule(rule?: UIConstraintRule): UIConstraintRule {\n return rule ?? UIConstraintRule.EQUAL;\n}\n\nexport function convertRuleToOperator(rule?: UIConstraintRule): Operator {\n switch (rule) {\n case UIConstraintRule.EQUAL:\n return Operator.Eq;\n case UIConstraintRule.LESS:\n return Operator.Le;\n case UIConstraintRule.GREATER:\n return Operator.Ge;\n default:\n return Operator.Eq;\n }\n}\n","import type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeUIConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport abstract class UIConstraint {\n public name = \"\";\n\n constructor(\n public readonly layer: UILayer,\n elements: Set<UIElement>,\n ) {\n this.layer[addUIConstraintSymbol](this, elements);\n }\n\n public destroy(): void {\n this.layer[removeUIConstraintSymbol](this);\n }\n\n public abstract [disableConstraintSymbol](orientation: UIOrientation): void;\n public abstract [enableConstraintSymbol](orientation: UIOrientation): void;\n\n protected abstract buildConstraints(): void;\n protected abstract destroyConstraints(): void;\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIHeightParameters {\n height: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHeightConstraint extends UIConstraint {\n private readonly parameters: UIHeightParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIHeightParameters>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n height: parameters?.height ?? 100,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[heightSymbol]),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.height,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","/**\n * Default priority value for event listeners.\n * Lower values indicate higher priority.\n */\nconst DEFAULT_PRIORITY = 100;\n/**\n * A priority-based event emitter implementation.\n * The name \"Eventail\" is a combination of \"event\" + \"tail\", reflecting its queue-like nature.\n *\n * Features:\n * - Priority-based event listeners\n * - Context binding support\n * - One-time event listeners\n * - Type-safe event handling\n *\n * @example\n * ```typescript\n * const emitter = new Eventail();\n *\n * // Regular event listener\n * emitter.on('event', (data) => console.log(data));\n *\n * // One-time event listener with high priority\n * emitter.once('event', callback, context, 50);\n *\n * // Remove specific listener\n * emitter.off('event', callback);\n * ```\n */\nclass Eventail {\n constructor() {\n /** Map storing event listeners for each event type */\n this.listeners = new Map();\n }\n /**\n * Adds an event listener for the specified event type.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.on('data', (value) => console.log(value));\n * emitter.on('error', handleError, this, 50);\n * ```\n */\n on(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, false);\n return this;\n }\n /**\n * Adds a one-time event listener that will be removed after first execution.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.once('init', () => console.log('Initialized'));\n * ```\n */\n once(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, true);\n return this;\n }\n /**\n * Removes event listener(s) from the specified event type.\n *\n * @param type - The event type to remove listener(s) from\n * @param callback - Optional callback to remove specific listener\n * @param context - Optional context to match when removing\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * // Remove all listeners for 'data' event\n * emitter.off('data');\n *\n * // Remove specific listener\n * emitter.off('data', callback);\n *\n * // Remove listener with specific context\n * emitter.off('data', callback, context);\n * ```\n */\n off(type, callback, context) {\n const current = this.listeners.get(type);\n if (!current) {\n return this;\n }\n if (!callback) {\n this.listeners.delete(type);\n return this;\n }\n const filtered = current.filter((l) => l.callback !== callback ||\n (context !== undefined && l.context !== context));\n filtered.length\n ? this.listeners.set(type, filtered)\n : this.listeners.delete(type);\n return this;\n }\n /**\n * Emits an event, triggering all registered listeners in priority order.\n * Protected method to allow extension in derived classes.\n *\n * @param type - The event type to emit\n * @param args - Arguments to pass to the listeners\n * @returns Boolean indicating if the event had listeners\n *\n * @example\n * ```typescript\n * class MyEmitter extends Eventail {\n * public trigger(type: string, ...args: unknown[]) {\n * return this.emit(type, ...args);\n * }\n * }\n * ```\n */\n emit(type, ...args) {\n const current = this.listeners.get(type);\n if (!(current === null || current === void 0 ? void 0 : current.length)) {\n return false;\n }\n for (const listener of [...current]) {\n listener.callback.apply(listener.context, args);\n if (listener.once) {\n this.off(type, listener.callback, listener.context);\n }\n }\n return true;\n }\n /**\n * Internal method to add a new event listener with the specified configuration.\n * Maintains priority order and prevents duplicate listeners.\n *\n * @param type - Event type\n * @param callback - Event callback\n * @param context - Callback context\n * @param priority - Event priority\n * @param once - Whether it's a one-time listener\n * @throws {Error} If the listener already exists\n */\n addListener(type, callback, context, priority, once) {\n let list = this.listeners.get(type);\n if (!list) {\n list = [];\n this.listeners.set(type, list);\n }\n if (list.some((l) => l.callback === callback && l.context === context)) {\n throw new Error(\"Event listener already exists\");\n }\n const event = { callback, context, priority, once };\n let i = 0;\n while (i < list.length && list[i].priority <= priority) {\n i++;\n }\n list.splice(i, 0, event);\n }\n}\n\nexport { DEFAULT_PRIORITY, Eventail };\n//# sourceMappingURL=index.js.map\n","import { Box2, Vector2 } from \"three\";\n\nconst tempVector2 = new Vector2();\nconst tempBox2 = new Box2();\n\nexport function testElement(\n elementX: number,\n elementY: number,\n elementWidth: number,\n elementHeight: number,\n xClick: number,\n yClick: number,\n): boolean {\n tempVector2.set(xClick, yClick);\n\n tempBox2.min.set(elementX, elementY);\n tempBox2.max.set(elementWidth, elementHeight).add(tempBox2.min);\n return tempBox2.containsPoint(tempVector2);\n}\n","export enum UIBehavior {\n HIDDEN,\n VISIBLE,\n INTERACTIVE,\n}\n","import { MathUtils } from \"three\";\nimport { needsRecalculation } from \"./symbols\";\n\nconst DEFAULT_POSITION = 0;\nconst DEFAULT_ANCHOR = 0.5;\nconst DEFAULT_SCALE = 1;\nconst DEFAULT_ROTATION = 0;\n\nexport class UIMicroTransformations {\n public [needsRecalculation] = false;\n\n private positionXInternal = DEFAULT_POSITION;\n private positionYInternal = DEFAULT_POSITION;\n private anchorXInternal = DEFAULT_ANCHOR;\n private anchorYInternal = DEFAULT_ANCHOR;\n private scaleXInternal = DEFAULT_SCALE;\n private scaleYInternal = DEFAULT_SCALE;\n private rotationInternal = DEFAULT_ROTATION;\n\n public get x(): number {\n return this.positionXInternal;\n }\n\n public get y(): number {\n return this.positionYInternal;\n }\n\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n public set x(value: number) {\n this.positionXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set y(value: number) {\n this.positionYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set anchorX(value: number) {\n this.anchorXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set anchorY(value: number) {\n this.anchorYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set scaleX(value: number) {\n this.scaleXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set scaleY(value: number) {\n this.scaleYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set angle(value: number) {\n this.rotationInternal = MathUtils.degToRad(value);\n this[needsRecalculation] = true;\n }\n\n public set rotation(value: number) {\n this.rotationInternal = value;\n this[needsRecalculation] = true;\n }\n\n public reset(): void {\n this.positionXInternal = DEFAULT_POSITION;\n this.positionYInternal = DEFAULT_POSITION;\n this.anchorXInternal = DEFAULT_ANCHOR;\n this.anchorYInternal = DEFAULT_ANCHOR;\n this.scaleXInternal = DEFAULT_SCALE;\n this.scaleYInternal = DEFAULT_SCALE;\n this.rotationInternal = DEFAULT_ROTATION;\n this[needsRecalculation] = true;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = 0.5;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { ShaderMaterial, WebGLRenderer } from \"three\";\nimport { Mesh, OrthographicCamera, Scene } from \"three\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\n\nconst scene = new Scene();\nconst mesh = new Mesh(geometry);\nscene.add(mesh);\n\nexport class UIFullScreenQuad {\n private readonly camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n constructor(\n private materialInternal: ShaderMaterial,\n private paddingHorizontalInternal = 0,\n private paddingVerticalInternal = 0,\n ) {\n this.updateCameraTransform();\n }\n\n public get paddingHorizontal(): number {\n return this.paddingHorizontalInternal;\n }\n\n public get paddingVertical(): number {\n return this.paddingVerticalInternal;\n }\n\n public get material(): ShaderMaterial {\n return this.materialInternal;\n }\n\n public set paddingHorizontal(value: number) {\n if (this.paddingHorizontalInternal !== value) {\n this.paddingHorizontalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n public set paddingVertical(value: number) {\n if (this.paddingVerticalInternal !== value) {\n this.paddingVerticalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n public set material(value: ShaderMaterial) {\n this.materialInternal = value;\n }\n\n public render(renderer: WebGLRenderer): void {\n mesh.material = this.materialInternal;\n renderer.render(scene, this.camera);\n }\n\n private updateCameraTransform(): void {\n this.camera.left = -this.paddingHorizontalInternal;\n this.camera.right = 1 + this.paddingHorizontalInternal;\n this.camera.bottom = -this.paddingVerticalInternal;\n this.camera.top = 1 + this.paddingVerticalInternal;\n this.camera.updateProjectionMatrix();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Color, Matrix3, ShaderMaterial, UniformsUtils } from \"three\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\n\nexport class UIDrawPass {\n private readonly screen: UIFullScreenQuad;\n\n constructor() {\n this.screen = new UIFullScreenQuad(\n new ShaderMaterial({\n uniforms: UniformsUtils.merge([\n {\n map: { value: null },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n uvTransform: { value: new Matrix3() },\n },\n ]),\n vertexShader: /* glsl */ `\n uniform mat3 uvTransform;\n varying vec2 vUv;\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n }),\n );\n }\n\n public destroy(): void {\n this.screen.material.dispose();\n }\n\n public setPadding(width: number, height: number, padding: number): void {\n if (padding <= 0) {\n this.screen.paddingHorizontal = 0;\n this.screen.paddingVertical = 0;\n } else {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n }\n\n public render(renderer: WebGLRenderer, texture: Texture): void {\n this.screen.material.uniforms.map.value = texture;\n this.screen.material.uniformsNeedUpdate = true;\n this.screen.render(renderer);\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIDrawPass } from \"./UIDrawPass\";\nimport type { UIPass } from \"./UIPass\";\n\nexport class UIComposer {\n public readonly passes: UIPass[] = [];\n private readonly drawPass = new UIDrawPass();\n private fromRenderTarget: WebGLRenderTarget;\n private toRenderTarget: WebGLRenderTarget;\n\n constructor() {\n const parameters = {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: false,\n stencilBuffer: false,\n };\n this.fromRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.toRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n }\n\n public calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n public render(renderer: WebGLRenderer, texture: Texture): Texture {\n if (this.passes.length === 0) {\n return texture;\n }\n\n if (this.passes.every((p) => !p.needsUpdate)) {\n return this.fromRenderTarget.texture;\n }\n\n const padding = this.calculatePadding();\n\n const width = texture.image.width;\n const height = texture.image.height;\n\n const widthWithPadding = width + padding * 2;\n const heightWithPadding = height + padding * 2;\n\n this.fromRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.toRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.drawPass.setPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n\n renderer.setRenderTarget(this.fromRenderTarget);\n renderer.clearColor();\n\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clearColor();\n\n this.drawPass.render(renderer, texture);\n this.reverseTargets();\n\n for (const pass of this.passes) {\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clearColor();\n pass.render(renderer, this.fromRenderTarget.texture, {\n width,\n height,\n padding,\n });\n this.reverseTargets();\n }\n\n return this.fromRenderTarget.texture;\n }\n\n public destroy(): void {\n this.drawPass.destroy();\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n private reverseTargets(): void {\n const fromRenderTarget = this.fromRenderTarget;\n this.fromRenderTarget = this.toRenderTarget;\n this.toRenderTarget = fromRenderTarget;\n }\n}\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { WebGLRenderer } from \"three\";\nimport { type Object3D } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { testElement } from \"../Miscellaneous/math\";\nimport { applyMicroTransformations } from \"../Miscellaneous/microTransformationTools\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n heightSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UIMicroTransformations } from \"../Miscellaneous/UIMicroTransformations\";\nimport { UIComposer } from \"../Passes/UIComposer\";\nimport type { UIPass } from \"../Passes/UIPass\";\n\nexport enum UIElementEvent {\n CLICK = \"click\",\n}\n\nexport abstract class UIElement extends Eventail {\n public name = \"\";\n public readonly micro = new UIMicroTransformations();\n\n public [xSymbol] = new Variable(\"x\");\n public [ySymbol] = new Variable(\"y\");\n public [widthSymbol] = new Variable(\"width\");\n public [heightSymbol] = new Variable(\"height\");\n public [needsRecalculation] = false;\n\n protected behaviorInternal = UIBehavior.VISIBLE;\n protected readonly composer = new UIComposer();\n\n constructor(\n public readonly layer: UILayer,\n protected readonly object: Object3D,\n x: number,\n y: number,\n width: number,\n height: number,\n ) {\n super();\n this.layer[addUIElementSymbol](this, this.object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[widthSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n this.layer[addVariableSymbol](\n this,\n this[heightSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n this[widthSymbol].setValue(width);\n this[heightSymbol].setValue(height);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n this.layer[suggestVariableSymbol](this, this[widthSymbol], width);\n this.layer[suggestVariableSymbol](this, this[heightSymbol], height);\n }\n\n public get passes(): UIPass[] {\n return this.composer.passes;\n }\n\n public get x(): number {\n return this[xSymbol].value();\n }\n\n public get y(): number {\n return this[ySymbol].value();\n }\n\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n public get zIndex(): number {\n return this.object.position.z;\n }\n\n public get behavior(): UIBehavior {\n return this.behaviorInternal;\n }\n\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n public set width(value: number) {\n this.layer[suggestVariableSymbol](this, this[widthSymbol], value);\n }\n\n public set height(value: number) {\n this.layer[suggestVariableSymbol](this, this[heightSymbol], value);\n }\n\n public set zIndex(value: number) {\n this.object.position.z = value;\n }\n\n public set behavior(value: UIBehavior) {\n this.behaviorInternal = value;\n this.object.visible = value !== UIBehavior.HIDDEN;\n }\n\n public destroy(): void {\n this.composer.destroy();\n this.layer[removeVariableSymbol](this, this[heightSymbol]);\n this.layer[removeVariableSymbol](this, this[widthSymbol]);\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n public [clickSymbol](x: number, y: number): boolean {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return false;\n }\n\n this.flushTransform();\n if (testElement(this.x, this.y, this.width, this.height, x, y)) {\n this.emit(UIElementEvent.CLICK, this);\n return true;\n }\n\n return false;\n }\n\n protected flushTransform(): void {\n if (this[needsRecalculation] || this.micro[needsRecalculation]) {\n applyMicroTransformations(\n this.object,\n this.micro,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composer.calculatePadding(),\n );\n\n this[needsRecalculation] = false;\n this.micro[needsRecalculation] = false;\n }\n }\n\n protected abstract [renderSymbol](renderer: WebGLRenderer): void;\n}\n","import type { Object3D } from \"three\";\nimport type { UIMicroTransformations } from \"./UIMicroTransformations\";\n\nexport function applyMicroTransformations(\n object: Object3D,\n micro: UIMicroTransformations,\n x: number,\n y: number,\n width: number,\n height: number,\n padding: number,\n): void {\n const realX = x - padding;\n const realY = y - padding;\n\n const realWidth = width + padding * 2;\n const realHeight = height + padding * 2;\n\n const anchorOffsetX = realWidth * micro.anchorX;\n const anchorOffsetY = realHeight * micro.anchorY;\n\n const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n let localX = realX - centerX;\n let localY = realY - centerY;\n\n localX *= micro.scaleX;\n localY *= micro.scaleY;\n\n const cos = Math.cos(micro.rotation);\n const sin = Math.sin(micro.rotation);\n\n localX = localX * cos - localY * sin;\n localY = localX * sin + localY * cos;\n\n localX += micro.x;\n localY += micro.y;\n\n object.position.x = localX + centerX;\n object.position.y = localY + centerY;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","import {\n Constraint,\n Expression,\n Operator,\n Solver,\n Strength,\n Variable,\n} from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n addUIConstraintSymbol,\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n needsRecalculation,\n removeConstraintSymbol,\n removeUIConstraintSymbol,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nconst MAX_Z_INDEX = 1000;\nexport const color = new Color(0x000000);\n\ninterface VariableDescription {\n strength: number;\n suggestedValue: number;\n}\n\ninterface UIElementDescription {\n object: Object3D;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<UIConstraint>;\n}\n\ninterface UIConstraintDescription {\n elements: Set<UIElement>;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<Constraint>;\n}\n\nexport abstract class UILayer {\n public behavior = UIBehavior.VISIBLE;\n\n public readonly [xSymbol]: Variable = new Variable();\n public readonly [ySymbol]: Variable = new Variable();\n public readonly [widthSymbol]: Variable = new Variable();\n public readonly [heightSymbol]: Variable = new Variable();\n\n protected readonly scene = new Scene();\n protected readonly camera = new OrthographicCamera();\n protected solver? = new Solver();\n\n protected elements = new Map<UIElement, UIElementDescription>();\n protected constraints = new Map<UIConstraint, UIConstraintDescription>();\n\n protected constraintX?: Constraint;\n protected constraintY?: Constraint;\n protected constraintW?: Constraint;\n protected constraintH?: Constraint;\n\n protected orientationPrivate = UIOrientation.PORTRAIT;\n protected needsRecalculation = false;\n\n public get orientation(): UIOrientation {\n return this.orientationPrivate;\n }\n\n public destroy(): void {\n this.solver = undefined;\n for (const constraint of this.constraints.keys()) {\n constraint.destroy();\n }\n for (const element of this.elements.keys()) {\n element.destroy();\n }\n }\n\n public [addUIElementSymbol](element: UIElement, object: Object3D): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already added\");\n }\n\n this.elements.set(element, {\n object,\n variables: new Map(),\n constraints: new Set(),\n });\n\n this.scene.add(object);\n }\n\n public [removeUIElementSymbol](element: UIElement): void {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing element\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\"Constraints should be removed before removing element\");\n }\n\n this.elements.delete(element);\n this.scene.remove(dependencies.object);\n }\n\n public [addUIConstraintSymbol](\n constraint: UIConstraint,\n elements: Set<UIElement>,\n ): void {\n if (this.constraints.has(constraint)) {\n throw new Error(\"Constraint already added\");\n }\n\n for (const element of elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.add(constraint);\n }\n\n this.constraints.set(constraint, {\n elements,\n variables: new Map(),\n constraints: new Set(),\n });\n }\n\n public [removeUIConstraintSymbol](constraint: UIConstraint): void {\n const dependencies = this.constraints.get(constraint);\n if (dependencies === undefined) {\n throw new Error(\"Constraint not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing constraint\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\n \"Constraints should be removed before removing constraint\",\n );\n }\n\n for (const element of dependencies.elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.delete(constraint);\n }\n\n this.constraints.delete(constraint);\n }\n\n public [addConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before adding constraint you need to add it's owner\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint already exists\");\n }\n\n dependencies.constraints.add(constraint);\n this.solver?.addConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [removeConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before removing constraint you need to add it's owner\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint not found\");\n }\n\n dependencies.constraints.delete(constraint);\n this.solver?.removeConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [addVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n strength: number,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before adding variable you need to add it's owner\");\n }\n\n if (dependencies.variables.has(variable)) {\n throw new Error(\"Variable already exists\");\n }\n\n dependencies.variables.set(variable, {\n strength,\n suggestedValue: variable.value(),\n });\n this.solver?.addEditVariable(variable, strength);\n this.needsRecalculation = true;\n }\n\n public [removeVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before removing variable you need to add it's owner\");\n }\n\n if (!dependencies.variables.has(variable)) {\n throw new Error(\"Variable does not exist\");\n }\n\n dependencies.variables.delete(variable);\n this.solver?.removeEditVariable(variable);\n this.needsRecalculation = true;\n }\n\n public [suggestVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n value: number,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before suggesting variable you need to add it's owner\");\n }\n\n const description = dependencies.variables.get(variable);\n\n if (!description) {\n throw new Error(\"Variable does not exist\");\n }\n\n if (description.suggestedValue !== value) {\n description.suggestedValue = value;\n this.solver?.suggestValue(variable, value);\n this.needsRecalculation = true;\n }\n }\n\n public render(renderer: WebGLRenderer): void {\n if (this.behavior === UIBehavior.HIDDEN) {\n return;\n }\n\n const originalRenderTarget = renderer.getRenderTarget();\n const originalClearColor = renderer.getClearColor(color);\n const originalClearAlpha = renderer.getClearAlpha();\n\n if (this.needsRecalculation) {\n this.needsRecalculation = false;\n this.solver?.updateVariables();\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n }\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n\n for (const element of this.elements.keys()) {\n element[renderSymbol](renderer);\n }\n\n renderer.setRenderTarget(originalRenderTarget);\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.render(this.scene, this.camera);\n }\n\n protected clickInternal(x: number, y: number): void {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return;\n }\n\n const elements = [...this.elements.keys()]\n .filter((e: UIElement) => e.behavior === UIBehavior.INTERACTIVE)\n .sort((a: UIElement, b: UIElement) => a.zIndex - b.zIndex);\n\n for (const element of elements) {\n if (element[clickSymbol](x, y)) {\n break;\n }\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.applyCameraSize(width, height);\n this.rebuildLayerConstraints(width, height);\n this.updateOrientation(width, height);\n this.needsRecalculation = true;\n }\n\n protected applyCameraSize(width: number, height: number): void {\n this.camera.near = -MAX_Z_INDEX;\n this.camera.far = 0;\n this.camera.bottom = 0;\n this.camera.left = 0;\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n }\n\n protected rebuildLayerConstraints(width: number, height: number): void {\n if (this.constraintX) {\n this.solver?.removeConstraint(this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.solver?.removeConstraint(this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.solver?.removeConstraint(this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.solver?.removeConstraint(this.constraintH);\n this.constraintH = undefined;\n }\n\n this.constraintX = new Constraint(\n new Expression(this[xSymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintY = new Constraint(\n new Expression(this[ySymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintW = new Constraint(\n new Expression(this[widthSymbol]),\n Operator.Eq,\n width,\n Strength.required,\n );\n\n this.constraintH = new Constraint(\n new Expression(this[heightSymbol]),\n Operator.Eq,\n height,\n Strength.required,\n );\n\n this.solver?.addConstraint(this.constraintX);\n this.solver?.addConstraint(this.constraintY);\n this.solver?.addConstraint(this.constraintW);\n this.solver?.addConstraint(this.constraintH);\n }\n\n protected updateOrientation(width: number, height: number): void {\n const lastOrientation = this.orientationPrivate;\n this.orientationPrivate =\n width > height ? UIOrientation.LANDSCAPE : UIOrientation.PORTRAIT;\n\n if (lastOrientation !== this.orientationPrivate) {\n this.solver = undefined;\n\n for (const constraint of this.constraints.keys()) {\n constraint[enableConstraintSymbol](this.orientationPrivate);\n }\n for (const constraint of this.constraints.keys()) {\n constraint[disableConstraintSymbol](this.orientationPrivate);\n }\n\n this.solver = new Solver();\n const descriptions = [\n ...this.elements.values(),\n ...this.constraints.values(),\n ];\n\n for (const description of descriptions) {\n for (const [key, value] of description.variables.entries()) {\n this.solver.addEditVariable(key, value.strength);\n this.solver.suggestValue(key, value.suggestedValue);\n }\n }\n\n if (this.constraintX) {\n this.solver.addConstraint(this.constraintX);\n }\n if (this.constraintY) {\n this.solver.addConstraint(this.constraintY);\n }\n if (this.constraintW) {\n this.solver.addConstraint(this.constraintW);\n }\n if (this.constraintH) {\n this.solver.addConstraint(this.constraintH);\n }\n\n for (const dependency of this.constraints.values()) {\n for (const constraint of dependency.constraints.values()) {\n this.solver.addConstraint(constraint);\n }\n }\n }\n }\n}\n","import type { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\n\nexport function assertSameLayer(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n message?: string,\n): void {\n if (\n (elementOne instanceof UILayer ? elementOne : elementOne.layer) !==\n elementTwo.layer\n ) {\n throw new Error(\n message ??\n `Elements must be on the same layer - element \"${elementTwo.constructor.name}\" cannot interact with elements from a different layer`,\n );\n }\n}\n\nexport function assertSize(\n width: number,\n height: number,\n message?: string,\n): void {\n if (width <= 0 || height <= 0) {\n throw new Error(\n message ??\n `Invalid dimensions: width (${width}) and height (${height}) must both be positive numbers greater than 0`,\n );\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIHorizontalDistanceParameters {\n anchorOne: number;\n anchorTwo: number;\n distance: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHorizontalDistanceConstraint extends UIConstraint {\n private readonly parameters: UIHorizontalDistanceParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalDistanceParameters>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? 0.5,\n anchorTwo: parameters?.anchorTwo ?? 0.5,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n );\n\n const expressionTwo = new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n );\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIHorizontalProportionParameters {\n proportion: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHorizontalProportionConstraint extends UIConstraint {\n private readonly parameters: UIHorizontalProportionParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalProportionParameters>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.proportion,\n );\n const expressionTwo = new Expression(this.elementTwo[widthSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIVerticalDistanceParameters {\n anchorOne: number;\n anchorTwo: number;\n distance: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIVerticalDistanceConstraint extends UIConstraint {\n private readonly parameters: UIVerticalDistanceParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalDistanceParameters>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? 0.5,\n anchorTwo: parameters?.anchorTwo ?? 0.5,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n );\n\n const expressionTwo = new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n );\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIVerticalProportionParameters {\n proportion: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIVerticalProportionConstraint extends UIConstraint {\n private readonly parameters: UIVerticalProportionParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalProportionParameters>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(\n this.elementOne[heightSymbol],\n ).multiply(this.parameters.proportion);\n const expressionTwo = new Expression(this.elementTwo[heightSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIWidthParameters {\n width: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIWidthConstraint extends UIConstraint {\n private readonly parameters: UIWidthParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIWidthParameters>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n width: parameters?.width ?? 100,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[widthSymbol]),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.width,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type {\n UIDistance2DConstraint,\n UIDistance2DConstraintParameters,\n UIProportion2DConstraintParameters,\n UIProprtion2DConstraint,\n UISize2DConstraint,\n UISize2DConstraintParameters,\n} from \"./UIConstraint2DBuilderInterfaces\";\n\nexport class UIConstraintBuilder2D {\n public static size2D(\n parameters: UISize2DConstraintParameters,\n ): UISize2DConstraint {\n return {\n width: new UIWidthConstraint(parameters.element, {\n width: parameters.width,\n power: parameters.powerHorizontal,\n rule: parameters.ruleHorizontal,\n orientation: parameters.orientationHorizontal,\n }),\n height: new UIHeightConstraint(parameters.element, {\n height: parameters.height,\n power: parameters.powerVertical,\n rule: parameters.ruleVertical,\n orientation: parameters.orientationVertical,\n }),\n };\n }\n\n public static distance2D(\n parameters: UIDistance2DConstraintParameters,\n ): UIDistance2DConstraint {\n return {\n horizontal: new UIHorizontalDistanceConstraint(\n parameters.elementOne,\n parameters.elementTwo,\n {\n anchorOne: parameters.anchorHorizontalOne,\n anchorTwo: parameters.anchorHorizontalTwo,\n distance: parameters.distanceHorizontal,\n power: parameters.powerHorizontal,\n rule: parameters.ruleHorizontal,\n orientation: parameters.orientationHorizontal,\n },\n ),\n vertical: new UIVerticalDistanceConstraint(\n parameters.elementOne,\n parameters.elementTwo,\n {\n anchorOne: parameters.anchorVerticalOne,\n anchorTwo: parameters.anchorVerticalTwo,\n distance: parameters.distanceVertical,\n power: parameters.powerVertical,\n rule: parameters.ruleVertical,\n orientation: parameters.orientationVertical,\n },\n ),\n };\n }\n\n public static proportional2D(\n parameters: UIProportion2DConstraintParameters,\n ): UIProprtion2DConstraint {\n return {\n horizontal: new UIHorizontalProportionConstraint(\n parameters.elementOne,\n parameters.elementTwo,\n {\n proportion: parameters.proportionHorizontal,\n power: parameters.powerHorizontal,\n rule: parameters.ruleHorizontal,\n orientation: parameters.orientationHorizontal,\n },\n ),\n vertical: new UIVerticalProportionConstraint(\n parameters.elementOne,\n parameters.elementTwo,\n {\n proportion: parameters.proportionVertical,\n power: parameters.powerVertical,\n rule: parameters.ruleVertical,\n orientation: parameters.orientationVertical,\n },\n ),\n };\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIAspectParameters {\n aspect: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIAspectConstraint extends UIConstraint {\n private readonly parameters: UIAspectParameters;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIAspectParameters>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n aspect: parameters?.aspect ?? this.element.width / this.element.height,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expression = new Expression(this.element[widthSymbol]).plus(\n new Expression(this.element[heightSymbol]).multiply(\n -this.parameters.aspect,\n ),\n );\n\n this.constraint = new Constraint(\n expression,\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\nexport interface UICoverParameters {\n isStrict: boolean;\n horizontalAnchor: number;\n verticalAnchor: number;\n orientation: UIOrientation;\n}\n\nexport class UICoverConstraint extends UIConstraint {\n private readonly parameters: UICoverParameters;\n\n private constraintX?: Constraint;\n private constraintY?: Constraint;\n private constraintW?: Constraint;\n private constraintH?: Constraint;\n private constraintStrict?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UICoverParameters>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? 0.5,\n verticalAnchor: parameters?.verticalAnchor ?? 0.5,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (!this.parameters.isStrict) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { isUIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIConstraintRule } from \"../Constraints/UIConstraintRule\";\nimport { isUIConstraintRule } from \"../Constraints/UIConstraintRule\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\nimport { isUIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport type AtLeastOneNumber =\n | { x?: number; y: number }\n | { x: number; y?: number };\n\nexport type AtLeastOnePower =\n | { x?: UIConstraintPower; y: UIConstraintPower }\n | { x: UIConstraintPower; y?: UIConstraintPower };\n\nexport type AtLeastOneRule =\n | { x?: UIConstraintRule; y: UIConstraintRule }\n | { x: UIConstraintRule; y?: UIConstraintRule };\n\nexport interface UICommonDoubleElementConstraintDescription {\n elementOne: UIElement | UILayer;\n elementTwo: UIElement;\n}\n\nexport interface UICommonProportionalConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n proportion: AtLeastOneNumber;\n power?: AtLeastOnePower;\n rule?: AtLeastOneRule;\n orientation?: UIOrientation;\n}\n\nexport interface UICommonDistanceConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n distance: AtLeastOneNumber;\n anchorOne?: AtLeastOneNumber;\n anchorTwo?: AtLeastOneNumber;\n power?: AtLeastOnePower;\n rule?: AtLeastOneRule;\n orientation?: UIOrientation;\n}\n\nexport interface UICommonCoverConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n isStrict: boolean;\n anchor?: AtLeastOneNumber;\n}\n\nexport function isAtLeastOneNumber(obj: unknown): obj is AtLeastOneNumber {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && typeof obj.x === \"number\") ||\n (\"y\" in obj && typeof obj.y === \"number\"))\n );\n}\n\nexport function isAtLeastOnePower(obj: unknown): obj is AtLeastOnePower {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && isUIConstraintPower(obj.x)) ||\n (\"y\" in obj && isUIConstraintPower(obj.y)))\n );\n}\n\nexport function isAtLeastOneRule(obj: unknown): obj is AtLeastOneRule {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && isUIConstraintRule(obj.x)) ||\n (\"y\" in obj && isUIConstraintRule(obj.y)))\n );\n}\n\nexport function isUICommonDoubleElementConstraintDescription(\n obj: unknown,\n): obj is UICommonDoubleElementConstraintDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"elementOne\" in obj &&\n \"elementTwo\" in obj &&\n (obj.elementOne instanceof UIElement ||\n obj.elementOne instanceof UILayer) &&\n obj.elementTwo instanceof UIElement\n );\n}\n\nexport function isUICommonDistanceConstraintDescription(\n obj: unknown,\n): obj is UICommonDistanceConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"distance\" in obj &&\n isAtLeastOneNumber(obj.distance) &&\n (!(\"anchorOne\" in obj) ||\n (\"anchorOne\" in obj && isAtLeastOneNumber(obj.anchorOne))) &&\n (!(\"anchorTwo\" in obj) ||\n (\"anchorTwo\" in obj && isAtLeastOneNumber(obj.anchorTwo))) &&\n (!(\"power\" in obj) || isAtLeastOnePower(obj.power)) &&\n (!(\"rule\" in obj) || isAtLeastOneRule(obj.rule)) &&\n (!(\"orientation\" in obj) || isUIOrientation(obj.orientation))\n );\n}\n\nexport function isUICommonProportionalConstraintDescription(\n obj: unknown,\n): obj is UICommonProportionalConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"proportion\" in obj &&\n isAtLeastOneNumber(obj.proportion) &&\n (!(\"power\" in obj) || isAtLeastOnePower(obj.power)) &&\n (!(\"rule\" in obj) || isAtLeastOneRule(obj.rule)) &&\n (!(\"orientation\" in obj) || isUIOrientation(obj.orientation))\n );\n}\n\nexport function isUICommonCoverConstraintDescription(\n obj: unknown,\n): obj is UICommonCoverConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"isStrict\" in obj &&\n typeof obj.isStrict === \"boolean\" &&\n (!(\"anchor\" in obj) || (\"anchor\" in obj && isAtLeastOneNumber(obj.anchor)))\n );\n}\n","import type {\n UIConstraintPower} from \"../Constraints/UIConstraintPower\";\nimport {\n isUIConstraintPower\n} from \"../Constraints/UIConstraintPower\";\nimport type {\n UIConstraintRule} from \"../Constraints/UIConstraintRule\";\nimport {\n isUIConstraintRule\n} from \"../Constraints/UIConstraintRule\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UICommonSingleElementConstraintDescription {\n element: UIElement;\n power?: UIConstraintPower;\n rule?: UIConstraintRule;\n orientation?: UIOrientation;\n}\n\nexport interface UIWidthConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n width: number;\n}\n\nexport interface UIHeightConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n height: number;\n}\n\nexport interface UIKeepAspectConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n keepAspect: boolean;\n}\n\nexport interface UIKeepSizeConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n keepSize: boolean;\n}\n\nexport function isUICommonSingleElementConstraintDescription(\n obj: unknown,\n): obj is UICommonSingleElementConstraintDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"element\" in obj &&\n obj.element instanceof UIElement &&\n (!(\"power\" in obj) || isUIConstraintPower(obj.power)) &&\n (!(\"rule\" in obj) || isUIConstraintRule(obj.rule))\n );\n}\n\nexport function isUIWidthConstraintDescription(\n obj: unknown,\n): obj is UIWidthConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"width\" in obj &&\n typeof obj.width === \"number\"\n );\n}\n\nexport function isUIHeightConstraintDescription(\n obj: unknown,\n): obj is UIHeightConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\nexport function isUIKeepAspectConstraintDescription(\n obj: unknown,\n): obj is UIKeepAspectConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"keepAspect\" in obj &&\n typeof obj.keepAspect === \"boolean\"\n );\n}\n\nexport function isUIKeepSizeConstraintDescription(\n obj: unknown,\n): obj is UIKeepSizeConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"keepSize\" in obj &&\n typeof obj.keepSize === \"boolean\"\n );\n}\n","import { UIAspectConstraint } from \"../Constraints/UIAspectConstraint\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UICoverConstraint } from \"../Constraints/UICoverConstraint\";\nimport { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type {\n UICommonCoverConstraintDescription,\n UICommonDistanceConstraintDescription,\n UICommonProportionalConstraintDescription,\n} from \"./UICommonDoubleElementConstraintDescriptionInterfaces\";\nimport {\n isUICommonCoverConstraintDescription,\n isUICommonDistanceConstraintDescription,\n isUICommonProportionalConstraintDescription,\n} from \"./UICommonDoubleElementConstraintDescriptionInterfaces\";\nimport type {\n UIHeightConstraintDescription,\n UIKeepAspectConstraintDescription,\n UIKeepSizeConstraintDescription,\n UIWidthConstraintDescription,\n} from \"./UICommonSingleElementConstraintDescriptionInterfaces\";\nimport {\n isUIHeightConstraintDescription,\n isUIKeepAspectConstraintDescription,\n isUIKeepSizeConstraintDescription,\n isUIWidthConstraintDescription,\n} from \"./UICommonSingleElementConstraintDescriptionInterfaces\";\n\nexport type UIAnyCommonConstraintDescription =\n | UICommonProportionalConstraintDescription\n | UICommonDistanceConstraintDescription\n | UICommonCoverConstraintDescription\n | UIWidthConstraintDescription\n | UIHeightConstraintDescription\n | UIKeepAspectConstraintDescription\n | UIKeepSizeConstraintDescription;\n\nexport class UIConstraintBuilder {\n public static fromDescription(\n description:\n | Map<string, UIAnyCommonConstraintDescription>\n | Record<string, UIAnyCommonConstraintDescription>,\n ): Record<string, UIConstraint> {\n const entries =\n description instanceof Map\n ? description.entries()\n : Object.entries(description);\n const constraints = new Map<string, UIConstraint>();\n\n for (const [key, value] of entries) {\n if (constraints.has(key)) {\n throw new Error(\n `Duplicate constraint key \"${key}\" - each constraint must have a unique identifier`,\n );\n }\n\n if (isUIWidthConstraintDescription(value)) {\n UIConstraintBuilder.buildWidthConstraint(key, value, constraints);\n } else if (isUIHeightConstraintDescription(value)) {\n UIConstraintBuilder.buildHeightConstraint(key, value, constraints);\n } else if (isUIKeepAspectConstraintDescription(value)) {\n UIConstraintBuilder.buildKeepAspectConstraint(key, value, constraints);\n } else if (isUIKeepSizeConstraintDescription(value)) {\n UIConstraintBuilder.buildKeepSizeConstraint(key, value, constraints);\n } else if (isUICommonDistanceConstraintDescription(value)) {\n UIConstraintBuilder.buildDistanceConstraint(key, value, constraints);\n } else if (isUICommonProportionalConstraintDescription(value)) {\n UIConstraintBuilder.buildProportionalConstraint(\n key,\n value,\n constraints,\n );\n } else if (isUICommonCoverConstraintDescription(value)) {\n UIConstraintBuilder.buildCoverConstraint(key, value, constraints);\n } else {\n throw new Error(\n `Invalid constraint type for \"${key}\". Expected one of: Width, Height, KeepAspect, KeepSize, Distance, Proportional, or Cover constraint`,\n );\n }\n }\n\n return Object.fromEntries(constraints);\n }\n\n private static buildWidthConstraint(\n key: string,\n value: UIWidthConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIWidthConstraint(value.element, {\n width: value.width,\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildHeightConstraint(\n key: string,\n value: UIHeightConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIHeightConstraint(value.element, {\n height: value.height,\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildKeepAspectConstraint(\n key: string,\n value: UIKeepAspectConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIAspectConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildKeepSizeConstraint(\n key: string,\n value: UIKeepSizeConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n const newKeyWidth = key.replace(/(KeepSize|Keep)$/, \"\") + \"KeepWidth\";\n const newKeyHeight = key.replace(/(KeepSize|Keep)$/, \"\") + \"KeepHeight\";\n constraints.set(\n newKeyWidth,\n new UIWidthConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n constraints.set(\n newKeyHeight,\n new UIHeightConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildDistanceConstraint(\n key: string,\n value: UICommonDistanceConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n if (typeof value.distance.x === \"number\") {\n const newKey =\n key.replace(/(HorizontalDistance|Distance)$/, \"\") +\n \"HorizontalDistance\";\n constraints.set(\n newKey,\n new UIHorizontalDistanceConstraint(value.elementOne, value.elementTwo, {\n distance: value.distance.x,\n anchorOne: value.anchorOne?.x,\n anchorTwo: value.anchorTwo?.x,\n power: value.power?.x,\n rule: value.rule?.x,\n orientation: value.orientation,\n }),\n );\n }\n\n if (typeof value.distance.y === \"number\") {\n const newKey =\n key.replace(/(VerticalDistance|Distance)$/, \"\") + \"VerticalDistance\";\n constraints.set(\n newKey,\n new UIVerticalDistanceConstraint(value.elementOne, value.elementTwo, {\n distance: value.distance.y,\n anchorOne: value.anchorOne?.y,\n anchorTwo: value.anchorTwo?.y,\n power: value.power?.y,\n rule: value.rule?.y,\n orientation: value.orientation,\n }),\n );\n }\n }\n\n private static buildProportionalConstraint(\n key: string,\n value: UICommonProportionalConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n if (typeof value.proportion.x === \"number\") {\n const newKey =\n key.replace(\n /(HorizontalProportional|HorizontalProportion|Proportional|Proportion)$/,\n \"\",\n ) + \"HorizontalProportion\";\n\n constraints.set(\n newKey,\n new UIHorizontalProportionConstraint(\n value.elementOne,\n value.elementTwo,\n {\n proportion: value.proportion.x,\n power: value.power?.x,\n rule: value.rule?.x,\n orientation: value.orientation,\n },\n ),\n );\n }\n\n if (typeof value.proportion.y === \"number\") {\n const newKey =\n key.replace(\n /(VerticalProportional|VerticalProportion|Proportional|Proportion)$/,\n \"\",\n ) + \"VerticalProportion\";\n constraints.set(\n newKey,\n new UIVerticalProportionConstraint(value.elementOne, value.elementTwo, {\n proportion: value.proportion.y,\n power: value.power?.y,\n rule: value.rule?.y,\n orientation: value.orientation,\n }),\n );\n }\n }\n\n private static buildCoverConstraint(\n key: string,\n value: UICommonCoverConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UICoverConstraint(value.elementOne, value.elementTwo, {\n isStrict: value.isStrict,\n horizontalAnchor: value.anchor?.x,\n verticalAnchor: value.anchor?.y,\n }),\n );\n }\n}\n","import { Object3D } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { UIElement } from \"./UIElement\";\n\nconst DEFAULT_DUMMY_SIZE = 100;\n\nexport class UIDummy extends UIElement {\n constructor(\n layer: UILayer,\n width = DEFAULT_DUMMY_SIZE,\n height = DEFAULT_DUMMY_SIZE,\n ) {\n super(layer, new Object3D(), 0, 0, width, height);\n this.flushTransform();\n }\n\n public override [renderSymbol](): void {}\n}\n","import type { Texture } from \"three\";\nimport { Color, Matrix3, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n uvTransform: { value: new Matrix3() },\n },\n ]),\n vertexShader: /* glsl */ `\n uniform mat3 uvTransform;\n varying vec2 vUv;\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n });\n }\n\n public getTexture(): Texture {\n return this.uniforms.map.value;\n }\n\n public getColor(): Color {\n return this.uniforms.color.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getUVTransform(): Matrix3 {\n return this.uniforms.uvTransform.value;\n }\n\n public setTexture(value: Texture): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: Color): void {\n this.uniforms.color.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setUVTransform(value: Matrix3): void {\n this.uniforms.uvTransform.value = value;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Color, Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIMaterial } from \"../Passes/UIMaterial\";\nimport { UIElement } from \"./UIElement\";\n\nexport class UIImage extends UIElement {\n private readonly material: UIMaterial;\n private readonly textureInternal: Texture;\n\n constructor(layer: UILayer, texture: Texture) {\n const width = texture.image?.width;\n const height = texture.image?.height;\n\n assertSize(\n width,\n height,\n `Invalid image dimensions - texture \"${texture.name || \"unnamed\"}\" has invalid width (${width}) or height (${height}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.material = material;\n this.textureInternal = texture;\n\n this.flushTransform();\n }\n\n public get texture(): Texture {\n return this.material.getTexture();\n }\n\n public get color(): Color {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: Color) {\n this.material.setColor(value);\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n this.flushTransform();\n this.material.setTexture(\n this.composer.render(renderer, this.textureInternal),\n );\n }\n}\n","import type { Texture } from \"three\";\nimport { ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(backgroundTexture: Texture, foregroundTexture: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n map: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n },\n ]),\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform sampler2D foreground;\n uniform float progress;\n varying vec2 vUv;\n\n void main() {\n vec4 background = texture2D(map, vUv);\n vec4 foreground = texture2D(foreground, vUv);\n gl_FragColor = mix(background, foreground, step(vUv.x, progress));\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n });\n }\n}\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIProgressMaterial } from \"../Passes/UIProgressMaterial\";\nimport { UIElement } from \"./UIElement\";\n\nexport class UIProgress extends UIElement {\n private readonly material: UIProgressMaterial;\n private readonly textureBackground: Texture;\n private readonly textureForeground: Texture;\n\n constructor(\n layer: UILayer,\n textureBackground: Texture,\n textureForeground: Texture,\n ) {\n const backgroundWidth = textureBackground.image?.width;\n const backgroundHeight = textureBackground.image?.height;\n\n assertSize(\n backgroundWidth,\n backgroundHeight,\n `Invalid image dimensions - texture \"${textureBackground.name || \"unnamed\"}\" has invalid width (${backgroundWidth}) or height (${backgroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const foregroundWidth = textureForeground.image?.width;\n const foregroundHeight = textureForeground.image?.height;\n\n assertSize(\n foregroundWidth,\n foregroundHeight,\n `Invalid image dimensions - texture \"${textureForeground.name || \"unnamed\"}\" has invalid width (${foregroundWidth}) or height (${foregroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIProgressMaterial(\n textureBackground,\n textureForeground,\n );\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, backgroundWidth, backgroundHeight);\n\n this.material = material;\n this.textureBackground = textureBackground;\n this.textureForeground = textureForeground;\n\n this.flushTransform();\n }\n\n public get background(): Texture {\n return this.textureBackground;\n }\n\n public get foreground(): Texture {\n return this.textureForeground;\n }\n\n public get progress(): number {\n return this.material.uniforms.progress.value;\n }\n\n public set progress(value: number) {\n this.material.uniforms.progress.value = value;\n this.material.uniformsNeedUpdate = true;\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](): void {\n this.flushTransform();\n\n // this.material.setTexture(\n // this.composer.render(renderer, this.textureBackground),\n // );\n }\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextPadding,\n UITextSize,\n UITextStyle,\n} from \"../Elements/UITextInterfaces\";\n\nexport function resolvePadding(\n padding?: Partial<UITextPadding> | number,\n): UITextPadding {\n if (typeof padding === \"number\") {\n return {\n left: padding,\n right: padding,\n top: padding,\n bottom: padding,\n };\n }\n return {\n left: Math.max(padding?.left ?? 0, 0),\n right: Math.max(padding?.right ?? 0, 0),\n top: Math.max(padding?.top ?? 0, 0),\n bottom: Math.max(padding?.bottom ?? 0, 0),\n };\n}\n\nexport function resolveTextStyle(\n currentStyle?: Partial<UITextStyle>,\n baseStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize = Math.max(\n currentStyle?.fontSize ?? baseStyle?.fontSize ?? 16,\n 1,\n );\n const lineHeight =\n currentStyle?.lineHeight ?? baseStyle?.lineHeight ?? fontSize * 1.2;\n const shadowBlur = Math.max(\n currentStyle?.shadowBlur ?? baseStyle?.shadowBlur ?? 0,\n 0,\n );\n const strokeWidth = Math.max(\n currentStyle?.strokeWidth ?? baseStyle?.strokeWidth ?? 0,\n 0,\n );\n return {\n color: currentStyle?.color ?? baseStyle?.color ?? \"#000000\",\n fontFamily: currentStyle?.fontFamily ?? baseStyle?.fontFamily ?? \"Arial\",\n fontSize,\n fontStyle: currentStyle?.fontStyle ?? baseStyle?.fontStyle ?? \"normal\",\n fontWeight: currentStyle?.fontWeight ?? baseStyle?.fontWeight ?? \"normal\",\n lineHeight,\n\n enableShadow:\n currentStyle?.enableShadow ?? baseStyle?.enableShadow ?? false,\n shadowOffsetX: currentStyle?.shadowOffsetX ?? baseStyle?.shadowOffsetX ?? 0,\n shadowOffsetY: currentStyle?.shadowOffsetY ?? baseStyle?.shadowOffsetY ?? 0,\n shadowBlur,\n shadowColor:\n currentStyle?.shadowColor ?? baseStyle?.shadowColor ?? \"transparent\",\n\n enableStroke:\n currentStyle?.enableStroke ?? baseStyle?.enableStroke ?? false,\n strokeColor:\n currentStyle?.strokeColor ?? baseStyle?.strokeColor ?? \"transparent\",\n strokeWidth,\n };\n}\n\nexport function splitText(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) || [];\n}\n\nexport function measureTextChunk(\n context: CanvasRenderingContext2D,\n chunk: string,\n style: UITextStyle,\n): UIChunkMetrics {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (chunk === \"\\n\") {\n return {\n width: Math.ceil(0),\n height: style.lineHeight,\n baseline: 0,\n lineHeight: style.lineHeight,\n };\n }\n\n const metrics = context.measureText(chunk);\n const width = metrics.width;\n\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width: Math.ceil(width),\n height: height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function wrapTextLines(\n maxWidth: number,\n chunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const chunk of chunks) {\n if (chunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentWidth + chunk.metrics.width <= maxWidth ||\n currentLine.length === 0\n ) {\n currentLine.push(chunk);\n currentWidth += chunk.metrics.width;\n currentHeight = Math.max(currentHeight, chunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, chunk.metrics.baseline);\n currentLineHeight = Math.max(currentLineHeight, chunk.metrics.lineHeight);\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [chunk];\n currentWidth = chunk.metrics.width;\n currentHeight = chunk.metrics.height;\n currentBaseline = chunk.metrics.baseline;\n currentLineHeight = chunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\nexport function calculateTextBlockSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (i === 0) {\n totalHeight += line.height;\n } else {\n totalHeight += line.lineHeight;\n }\n\n if (i === lines.length - 1) {\n totalHeight += line.baseline;\n }\n }\n\n return {\n width: maxLineWidth,\n height: totalHeight,\n };\n}\n\nexport function renderText(\n x: number,\n y: number,\n text: string,\n style: UITextStyle,\n context: CanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeWidth;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: CanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n let currentX = paddingLeft;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderText(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { Color, WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n heightSymbol,\n renderSymbol,\n suggestVariableSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n calculateTextBlockSize,\n measureTextChunk,\n renderTextLines,\n resolvePadding,\n resolveTextStyle,\n splitText,\n wrapTextLines,\n} from \"../Miscellaneous/textTools\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIMaterial } from \"../Passes/UIMaterial\";\nimport { UIElement } from \"./UIElement\";\nimport type {\n UITextChunk,\n UITextPadding,\n UITextSize,\n UITextSpan,\n UITextStyle,\n} from \"./UITextInterfaces\";\nexport interface UITextParameters {\n maxWidth: number;\n padding: Partial<UITextPadding>;\n defaultStyle: Partial<UITextStyle>;\n}\n\nexport class UIText extends UIElement {\n private readonly material: UIMaterial;\n private readonly texture: CanvasTexture;\n\n private readonly canvas: HTMLCanvasElement;\n private readonly context: CanvasRenderingContext2D;\n\n private readonly textBlockSize: UITextSize;\n private readonly padding: UITextPadding;\n private lastSuggestedAspect = 0;\n\n constructor(\n layer: UILayer,\n spans: (UITextSpan | string)[],\n parameters: Partial<UITextParameters> = {},\n ) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"Failed to create canvas context\");\n }\n\n const chunks: UITextChunk[] = [];\n\n for (const span of spans) {\n const isSpanString = typeof span === \"string\";\n const spanText = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n parameters.defaultStyle,\n );\n\n for (const text of splitText(spanText)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const wrappedLines = wrapTextLines(parameters.maxWidth ?? 1024, chunks);\n const textBlockSize = calculateTextBlockSize(wrappedLines);\n\n const padding = resolvePadding(parameters.padding);\n\n canvas.width = textBlockSize.width + padding.left + padding.right;\n canvas.height = textBlockSize.height + padding.top + padding.bottom;\n\n const texture = new CanvasTexture(canvas);\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, textBlockSize.width, textBlockSize.height);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.textBlockSize = textBlockSize;\n this.padding = padding;\n\n renderTextLines(\n this.padding.top,\n this.padding.left,\n wrappedLines,\n this.context,\n );\n\n this.texture.needsUpdate = true;\n this.flushTransform();\n }\n\n public get color(): Color {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: Color) {\n this.material.setColor(value);\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n public override destroy(): void {\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n public override flushTransform(): void {\n super.flushTransform();\n\n const currentAspect = this.width / this.height;\n if (this.lastSuggestedAspect !== currentAspect) {\n this.lastSuggestedAspect = currentAspect;\n\n const targetAspect =\n (this.textBlockSize.width + this.padding.left + this.padding.right) /\n (this.textBlockSize.height + this.padding.top + this.padding.bottom);\n\n this.layer[suggestVariableSymbol](\n this,\n this[heightSymbol],\n this.width / targetAspect,\n );\n }\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n this.flushTransform();\n this.material.setTexture(this.composer.render(renderer, this.texture));\n }\n}\n","import { Texture } from \"three\";\nimport type { UITextSpan, UITextStyle } from \"../Elements/UITextInterfaces\";\nimport { isUITextSpan } from \"../Elements/UITextInterfaces\";\n\nexport interface UIImageDescription {\n texture: Texture;\n}\n\nexport interface UIProgressDescription {\n background: Texture;\n foreground: Texture;\n}\n\nexport interface UITextDescription {\n text: string;\n style?: Partial<UITextStyle>;\n}\n\nexport interface UITextEnancedDescription {\n spans: (UITextSpan | string)[];\n defaultStyle?: Partial<UITextStyle>;\n}\n\nexport interface UIDummyDescription {\n width?: number;\n height?: number;\n}\n\nexport type UIAnyElementDescription =\n | UIImageDescription\n | UIProgressDescription\n | UITextDescription\n | UITextEnancedDescription\n | UIDummyDescription;\n\nexport function isUIImageDescription(obj: unknown): obj is UIImageDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"texture\" in obj &&\n obj.texture instanceof Texture\n );\n}\n\nexport function isUIProgressDescription(\n obj: unknown,\n): obj is UIProgressDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"background\" in obj &&\n obj.background instanceof Texture &&\n \"foreground\" in obj &&\n obj.foreground instanceof Texture\n );\n}\n\nexport function isUITextDescription(obj: unknown): obj is UITextDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"text\" in obj &&\n typeof obj.text === \"string\"\n );\n}\n\nexport function isUITextEnhancedDescription(\n obj: unknown,\n): obj is UITextEnancedDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"spans\" in obj &&\n Array.isArray(obj.spans) &&\n obj.spans.every((span) => typeof span === \"string\" || isUITextSpan(span))\n );\n}\n\nexport function isUIDummyDescription(obj: unknown): obj is UIDummyDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n (!(\"width\" in obj) || typeof obj.width === \"number\") &&\n (!(\"height\" in obj) || typeof obj.height === \"number\")\n );\n}\n","export interface UITextStyle {\n color: string;\n\n fontFamily: string;\n fontSize: number;\n fontStyle: \"normal\" | \"italic\" | \"oblique\";\n fontWeight: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number;\n lineHeight: number;\n\n enableShadow: boolean;\n shadowOffsetX: number;\n shadowOffsetY: number;\n shadowBlur: number;\n shadowColor: string;\n\n enableStroke: boolean;\n strokeColor: string;\n strokeWidth: number;\n}\n\nexport interface UITextPadding {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\nexport interface UITextSize {\n width: number;\n height: number;\n}\n\nexport interface UIChunkMetrics {\n width: number;\n height: number;\n baseline: number;\n lineHeight: number;\n}\n\nexport interface UITextChunk {\n text: string;\n style: UITextStyle;\n metrics: UIChunkMetrics;\n}\n\nexport interface UITextLine {\n chunks: UITextChunk[];\n width: number;\n height: number;\n baseline: number;\n lineHeight: number;\n}\n\nexport interface UITextSpan {\n text: string;\n style?: Partial<UITextStyle>;\n}\n\nexport function isUITextSpan(obj?: unknown): obj is UITextSpan {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"text\" in obj &&\n typeof obj.text === \"string\"\n );\n}\n","import { Texture } from \"three\";\nimport { UIDummy } from \"../Elements/UIDummy\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport { UIImage } from \"../Elements/UIImage\";\nimport { UIProgress } from \"../Elements/UIProgress\";\nimport { UIText } from \"../Elements/UIText\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIAnyElementDescription } from \"./UIElementBuilderInterfaces\";\nimport {\n isUIDummyDescription,\n isUIImageDescription,\n isUIProgressDescription,\n isUITextDescription,\n isUITextEnhancedDescription,\n} from \"./UIElementBuilderInterfaces\";\n\nexport class UIElementBuilder {\n public static fromDescription(\n layer: UILayer,\n description:\n | Map<string, UIAnyElementDescription | Texture | String>\n | Record<string, UIAnyElementDescription | Texture | String>,\n ): Record<string, UIElement> {\n const entries =\n description instanceof Map\n ? description.entries()\n : Object.entries(description);\n const elements = new Map<string, UIElement>();\n\n for (const [key, value] of entries) {\n if (elements.has(key)) {\n throw new Error(\n `Duplicate element key \"${key}\" - each UI element must have a unique identifier`,\n );\n }\n let element: UIElement;\n\n if (value instanceof Texture) {\n element = new UIImage(layer, value);\n } else if (isUIImageDescription(value)) {\n element = new UIImage(layer, value.texture);\n } else if (typeof value === \"string\") {\n element = new UIText(layer, [value]);\n } else if (isUIProgressDescription(value)) {\n element = new UIProgress(layer, value.background, value.foreground);\n } else if (isUITextDescription(value)) {\n element = new UIText(layer, [value.text], {\n defaultStyle: value.style,\n });\n } else if (isUITextEnhancedDescription(value)) {\n element = new UIText(layer, value.spans, {\n defaultStyle: value.defaultStyle,\n });\n } else if (isUIDummyDescription(value)) {\n element = new UIDummy(layer, value.width, value.height);\n } else {\n throw new Error(\n `Invalid UI element type for \"${key}\". Expected one of: Texture, UIImage, String, UITextDescription, or UITextEnhancedDescription`,\n );\n }\n\n elements.set(key, element);\n }\n\n return Object.fromEntries(elements);\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIDummy } from \"../Elements/UIDummy\";\nimport type { UIElement } from \"../Elements/UIElement\";\n\nexport interface UIStackConstraintBuilderParameters {\n offset: number;\n elements: UIElement[];\n power?: UIConstraintPower;\n createDummy?: boolean;\n keepAlignment?: boolean;\n}\n\nexport interface UIStackConstraintBuilderHorizontalResult {\n dummy?: UIDummy;\n distanceConstraints: UIHorizontalDistanceConstraint[];\n proportionConstraints: UIHorizontalProportionConstraint[];\n centerConstraints: UIVerticalDistanceConstraint[];\n}\n\nexport interface UIStackConstraintBuilderVerticalResult {\n dummy?: UIDummy;\n distanceConstraints: UIVerticalDistanceConstraint[];\n proportionConstraints: UIVerticalProportionConstraint[];\n centerConstraints: UIHorizontalDistanceConstraint[];\n}\n\nexport class UIStackConstraintBuilder {\n public static buildHorizontal(\n parameters: UIStackConstraintBuilderParameters,\n ): UIStackConstraintBuilderHorizontalResult {\n const distanceConstraints = [];\n const proportionConstraints = [];\n const centerConstraints = [];\n\n for (let i = 0; i < parameters.elements.length - 1; i++) {\n const element = parameters.elements[i];\n const nextElement = parameters.elements[i + 1];\n\n distanceConstraints.push(\n new UIHorizontalDistanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: parameters.offset,\n power: parameters.power,\n }),\n );\n\n proportionConstraints.push(\n new UIHorizontalProportionConstraint(element, nextElement, {\n power: parameters.power,\n }),\n );\n\n if (parameters.keepAlignment !== false) {\n centerConstraints.push(\n new UIVerticalDistanceConstraint(element, nextElement, {\n power: parameters.power,\n anchorOne: 0,\n anchorTwo: 0,\n }),\n );\n }\n }\n\n return {\n dummy:\n parameters.createDummy !== false\n ? UIStackConstraintBuilder.createDummy(\n parameters.elements[0],\n parameters.elements[parameters.elements.length - 1],\n )\n : undefined,\n distanceConstraints,\n proportionConstraints,\n centerConstraints,\n };\n }\n\n public static buildVertical(\n parameters: UIStackConstraintBuilderParameters,\n ): UIStackConstraintBuilderVerticalResult {\n const distanceConstraints = [];\n const proportionConstraints = [];\n const centerConstraints = [];\n\n for (let i = 0; i < parameters.elements.length - 1; i++) {\n const element = parameters.elements[i];\n const nextElement = parameters.elements[i + 1];\n\n distanceConstraints.push(\n new UIVerticalDistanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: parameters.offset,\n power: parameters.power,\n }),\n );\n\n proportionConstraints.push(\n new UIVerticalProportionConstraint(element, nextElement, {\n power: parameters.power,\n }),\n );\n\n if (parameters.keepAlignment !== false) {\n centerConstraints.push(\n new UIHorizontalDistanceConstraint(element, nextElement, {\n power: parameters.power,\n }),\n );\n }\n }\n\n return {\n dummy:\n parameters.createDummy !== false\n ? UIStackConstraintBuilder.createDummy(\n parameters.elements[0],\n parameters.elements[parameters.elements.length - 1],\n )\n : undefined,\n distanceConstraints,\n proportionConstraints,\n centerConstraints,\n };\n }\n\n private static createDummy(\n firstElement: UIElement,\n lastElement: UIElement,\n ): UIDummy {\n const dummy = new UIDummy(lastElement.layer);\n\n new UIHorizontalDistanceConstraint(dummy, firstElement, {\n distance: 0,\n anchorOne: 0,\n anchorTwo: 0,\n });\n\n new UIVerticalDistanceConstraint(dummy, firstElement, {\n distance: 0,\n anchorOne: 0,\n anchorTwo: 0,\n });\n\n new UIHorizontalDistanceConstraint(dummy, lastElement, {\n distance: 0,\n anchorOne: 1,\n anchorTwo: 1,\n });\n\n new UIVerticalDistanceConstraint(dummy, lastElement, {\n distance: 0,\n anchorOne: 1,\n anchorTwo: 1,\n });\n\n return dummy;\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\nexport interface UIFitParameters {\n isStrict: boolean;\n horizontalAnchor: number;\n verticalAnchor: number;\n orientation: UIOrientation;\n}\n\nexport class UIFitConstraint extends UIConstraint {\n private readonly parameters: UIFitParameters;\n\n private constraintX?: Constraint;\n private constraintY?: Constraint;\n\n private constraintW?: Constraint;\n private constraintH?: Constraint;\n\n private constraintStrict?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIFitParameters>,\n ) {\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n assertSameLayer(elementOne, elementTwo);\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? 0.5,\n verticalAnchor: parameters?.verticalAnchor ?? 0.5,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (this.parameters.isStrict !== false) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UILayer } from \"./UILayer\";\n\nconst DEFAULT_SCREEN_HEIGHT = 1920;\n\nexport class UIFullScreenLayer extends UILayer {\n private targetScreenHeight?: number = DEFAULT_SCREEN_HEIGHT;\n\n constructor() {\n super();\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"click\", this.onClick);\n this.onResize();\n }\n\n public get tergetScreenHeight(): number | undefined {\n return this.targetScreenHeight;\n }\n\n public set tergetScreenHeight(value: number | undefined) {\n this.targetScreenHeight = value;\n this.resizeInternal(window.innerWidth, window.innerHeight);\n }\n\n public override destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"click\", this.onClick);\n super.destroy();\n }\n\n private calculateScale(): number {\n const targetHeight = this.tergetScreenHeight ?? window.innerHeight;\n return targetHeight / window.innerHeight;\n }\n\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onClick = (event: MouseEvent): void => {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return;\n }\n\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n const offsetX = rect ? event.clientX - rect.left : event.clientX;\n const offsetY = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(offsetX * scale, offsetY * scale);\n };\n}\n","import { UILayer } from \"./UILayer\";\n\nexport class UIManualLayer extends UILayer {\n public click(x: number, y: number): void {\n this.clickInternal(x, y);\n }\n\n public resize(width: number, height: number): void {\n this.resizeInternal(width, height);\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\n\nexport interface UIPassRenderParameters {\n width: number;\n height: number;\n padding: number;\n}\n\nexport abstract class UIPass {\n public abstract get padding(): number;\n public abstract get needsUpdate(): boolean;\n public abstract render(\n renderer: WebGLRenderer,\n texture: Texture,\n parameters: UIPassRenderParameters,\n ): void;\n}\n"],"names":["createMap","IndexedMap","this","index","array","prototype","size","length","empty","itemAt","contains","key","undefined","id","find","i","setDefault","factory","pair","Pair","push","insert","value","erase","last","pop","first","copy","second","Variable","name","_value","_context","_id","VarId","_name","setName","context","setContext","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","parsed","parseArgs","arguments","_terms","terms","_constant","constant","result","n","isConstant","map","join","args","item","j","k","terms2","termPair","Array","Error","value2","Operator","Strength","create","a","b","c","w","Math","max","min","clip","required","strong","medium","weak","SymbolType","Constraint","expression","operator","rhs","strength","CnId","_operator","_strength","_expression","op","Solver","_cnMap","_rowMap","_varMap","_editMap","_infeasibleRows","_objective","Row","_artificial","_idTick","createConstraint","lhs","cn","addConstraint","constraint","data","_createRow","row","tag","subject","_chooseSubject","type","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_optimize","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","addEditVariable","variable","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_dualOptimize","other","rowPair_1","coeff","coefficientFor","External","updateVariables","vars","_getVarSymbol","_this","_makeSymbol","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","r","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_type","_cellMap","theCopy","xSymbol","ySymbol","widthSymbol","heightSymbol","addUIElementSymbol","removeUIElementSymbol","addUIConstraintSymbol","removeUIConstraintSymbol","addConstraintSymbol","removeConstraintSymbol","addVariableSymbol","removeVariableSymbol","suggestVariableSymbol","disableConstraintSymbol","enableConstraintSymbol","needsRecalculation","renderSymbol","clickSymbol","UIOrientation","UIConstraintPower","UIConstraintRule","isUIOrientation","obj","Object","values","some","v","resolveOrientation","orientation","ALWAYS","UIConstraint","constructor","layer","elements","destroy","isUIConstraintPower","resolvePower","power","P0","convertPowerToStrength","P1","P2","P3","P4","P5","P6","P7","isUIConstraintRule","resolveRule","rule","EQUAL","convertRuleToOperator","LESS","GREATER","UIHeightConstraint","element","parameters","super","Set","height","_a","buildConstraints","destroyConstraints","Eventail","listeners","Map","on","callback","priority","addListener","once","off","current","get","delete","filtered","filter","l","set","emit","listener","apply","list","event","splice","tempVector2","Vector2","tempBox2","Box2","UIBehavior","DEFAULT_ANCHOR","UIMicroTransformations","positionXInternal","positionYInternal","anchorXInternal","anchorYInternal","scaleXInternal","scaleYInternal","rotationInternal","x","y","anchorX","anchorY","scaleX","scaleY","angle","MathUtils","radToDeg","rotation","degToRad","reset","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","materialInternal","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","material","render","renderer","left","right","bottom","top","updateProjectionMatrix","UIDrawPass","screen","ShaderMaterial","uniforms","UniformsUtils","merge","opacity","color","Color","uvTransform","Matrix3","vertexShader","fragmentShader","transparent","fog","lights","dispose","setPadding","width","padding","texture","uniformsNeedUpdate","UIComposer","passes","drawPass","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","calculatePadding","reduce","p","every","needsUpdate","image","widthWithPadding","heightWithPadding","setSize","setClearColor","setRenderTarget","clearColor","reverseTargets","pass","UIElementEvent","UIElement","object","micro","_b","_c","_d","_e","behaviorInternal","VISIBLE","composer","zIndex","position","z","behavior","visible","HIDDEN","INTERACTIVE","flushTransform","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","realX","realY","realWidth","realHeight","centerX","centerY","localX","localY","cos","sin","scale","applyMicroTransformations","UILayer","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","dependencies","remove","owner","suggestedValue","description","originalRenderTarget","getRenderTarget","originalClearColor","getClearColor","originalClearAlpha","getClearAlpha","setClearAlpha","clickInternal","e","sort","resizeInternal","applyCameraSize","rebuildLayerConstraints","updateOrientation","near","far","constraintX","constraintY","_f","constraintW","_g","constraintH","_h","_j","_k","_l","_m","lastOrientation","LANDSCAPE","descriptions","entries","dependency","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraintBuilder2D","size2D","powerHorizontal","ruleHorizontal","orientationHorizontal","powerVertical","ruleVertical","orientationVertical","distance2D","horizontal","anchorHorizontalOne","anchorHorizontalTwo","distanceHorizontal","vertical","anchorVerticalOne","anchorVerticalTwo","distanceVertical","proportional2D","proportionHorizontal","proportionVertical","UIAspectConstraint","aspect","newOrientation","UICoverConstraint","isStrict","horizontalAnchor","verticalAnchor","constraintStrict","isAtLeastOneNumber","isAtLeastOnePower","isAtLeastOneRule","isUICommonDoubleElementConstraintDescription","isUICommonDistanceConstraintDescription","isUICommonProportionalConstraintDescription","isUICommonCoverConstraintDescription","anchor","isUICommonSingleElementConstraintDescription","isUIHeightConstraintDescription","isUIKeepAspectConstraintDescription","keepAspect","isUIKeepSizeConstraintDescription","keepSize","UIConstraintBuilder","fromDescription","buildWidthConstraint","buildHeightConstraint","buildKeepAspectConstraint","buildKeepSizeConstraint","buildDistanceConstraint","buildProportionalConstraint","buildCoverConstraint","fromEntries","newKeyWidth","replace","newKeyHeight","newKey","UIDummy","Object3D","UIMaterial","getTexture","getColor","getOpacity","getUVTransform","setTexture","setColor","setOpacity","setUVTransform","UIImage","textureInternal","UIProgressMaterial","backgroundTexture","foregroundTexture","foreground","progress","UIProgress","textureBackground","textureForeground","backgroundWidth","backgroundHeight","foregroundWidth","foregroundHeight","background","resolveTextStyle","currentStyle","baseStyle","fontSize","lineHeight","shadowBlur","strokeWidth","fontFamily","fontStyle","_p","_o","fontWeight","_r","_q","enableShadow","_t","_s","shadowOffsetX","_v","_u","shadowOffsetY","_x","_w","shadowColor","_z","_y","enableStroke","_1","_0","strokeColor","_3","_2","splitText","text","match","measureTextChunk","chunk","style","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","UIText","spans","canvas","document","createElement","getContext","chunks","span","isSpanString","spanText","defaultStyle","wrappedLines","maxWidth","lines","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","wrapTextLines","textBlockSize","maxLineWidth","line","totalHeight","calculateTextBlockSize","resolvePadding","CanvasTexture","lastSuggestedAspect","paddingTop","paddingLeft","currentY","currentX","renderTextLines","currentAspect","isUIProgressDescription","Texture","isUITextDescription","isUITextEnhancedDescription","isArray","isUITextSpan","isUIDummyDescription","UIElementBuilder","UIStackConstraintBuilder","buildHorizontal","distanceConstraints","proportionConstraints","centerConstraints","nextElement","offset","keepAlignment","createDummy","buildVertical","firstElement","lastElement","UIFitConstraint","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIManualLayer","click","resize","UIPass"],"mappings":"qTAOO,SAASA,IACZ,OAAO,IAAIC,CACf,CACA,IAAIA,EAA4B,WAC5B,SAASA,IACLC,KAAKC,MAAQ,CAAE,EACfD,KAAKE,MAAQ,EACrB,CA8GI,OA1GAH,EAAWI,UAAUC,KAAO,WACxB,OAAOJ,KAAKE,MAAMG,MACrB,EAIDN,EAAWI,UAAUG,MAAQ,WACzB,OAA6B,IAAtBN,KAAKE,MAAMG,MACrB,EAMDN,EAAWI,UAAUI,OAAS,SAAUN,GACpC,OAAOD,KAAKE,MAAMD,EACrB,EAMDF,EAAWI,UAAUK,SAAW,SAAUC,GACtC,YAAgCC,IAAzBV,KAAKC,MAAMQ,EAAIE,KACzB,EAMDZ,EAAWI,UAAUS,KAAO,SAAUH,GAClC,IAAII,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,YAAaD,IAANG,OAAkBH,EAAYV,KAAKE,MAAMW,EACnD,EAUDd,EAAWI,UAAUW,WAAa,SAAUL,EAAKM,GAC7C,IAAIF,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,QAAUD,IAANG,EAAiB,CACjB,IAAIG,EAAO,IAAIC,EAAKR,EAAKM,KAGzB,OAFAf,KAAKC,MAAMQ,EAAIE,MAAQX,KAAKE,MAAMG,OAClCL,KAAKE,MAAMgB,KAAKF,GACTA,CACnB,CAEY,OAAOhB,KAAKE,MAAMW,EAEzB,EASDd,EAAWI,UAAUgB,OAAS,SAAUV,EAAKW,GACzC,IAAIJ,EAAO,IAAIC,EAAKR,EAAKW,GACrBP,EAAIb,KAAKC,MAAMQ,EAAIE,MAQvB,YAPUD,IAANG,GACAb,KAAKC,MAAMQ,EAAIE,MAAQX,K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AAU9qB,KAAKgqB,UACvCE,OAAOY,iBAAiB,QAAS9qB,KAAKqqB,SACtCrqB,KAAKgqB,WAGP,sBAAWe,GACT,OAAO/qB,KAAK+pB,mBAGd,sBAAWgB,CAAmB3pB,GAC5BpB,KAAK+pB,mBAAqB3oB,EAC1BpB,KAAK4b,eAAesO,OAAOC,WAAYD,OAAOE,aAGhC,OAAA3b,GACdyb,OAAOc,oBAAoB,SAAUhrB,KAAKgqB,UAC1CE,OAAOc,oBAAoB,QAAShrB,KAAKqqB,SACzCra,MAAMvB,UAGA,cAAAwb,SAEN,OADgD,QAA3B9Z,EAAAnQ,KAAK+qB,0BAAsB,IAAA5a,EAAAA,EAAA+Z,OAAOE,aACjCF,OAAOE,aC9B3B,MAAOa,WAAsB5Q,GAC1B,KAAA6Q,CAAMxY,EAAWC,GACtB3S,KAAKyb,cAAc/I,EAAGC,GAGjB,MAAAwY,CAAOnV,EAAe9F,GAC3BlQ,KAAK4b,eAAe5F,EAAO9F,UCATkb","x_google_ignoreList":[0,1,2,3,4,5,12]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/kiwi.js/es/maptype.js","../node_modules/kiwi.js/es/variable.js","../node_modules/kiwi.js/es/expression.js","../node_modules/kiwi.js/es/strength.js","../node_modules/kiwi.js/es/constraint.js","../node_modules/kiwi.js/es/solver.js","../src/Miscellaneous/symbols.ts","../src/Miscellaneous/UIOrientation.ts","../src/Constraints/UIConstraintPower.ts","../src/Constraints/UIConstraintRule.ts","../src/Constraints/UIConstraint.ts","../src/Constraints/UIHeightConstraint.ts","../node_modules/eventail/dist/index.js","../src/Miscellaneous/math.ts","../src/Miscellaneous/UIBehavior.ts","../src/Miscellaneous/UIMicroTransformations.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIDrawPass.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Miscellaneous/microTransformationTools.ts","../src/Layers/UILayer.ts","../src/Miscellaneous/asserts.ts","../src/Constraints/UIHorizontalDistanceConstraint.ts","../src/Constraints/UIHorizontalProportionConstraint.ts","../src/Constraints/UIVerticalDistanceConstraint.ts","../src/Constraints/UIVerticalProportionConstraint.ts","../src/Constraints/UIWidthConstraint.ts","../src/Builders/UIConstraint2DBuilder.ts","../src/Constraints/UIAspectConstraint.ts","../src/Constraints/UICoverConstraint.ts","../src/Builders/UICommonDoubleElementConstraintDescriptionInterfaces.ts","../src/Builders/UICommonSingleElementConstraintDescriptionInterfaces.ts","../src/Builders/UIConstraintBuilder.ts","../src/Elements/UIDummy.ts","../src/Passes/UIMaterial.ts","../src/Elements/UIImage.ts","../src/Passes/UIProgressMaterial.ts","../src/Elements/UIProgress.ts","../src/Miscellaneous/textTools.ts","../src/Elements/UIText.ts","../src/Builders/UIElementBuilderInterfaces.ts","../src/Elements/UITextInterfaces.ts","../src/Builders/UIElementBuilder.ts","../src/Builders/UIStackConstraintBuilder.ts","../src/Constraints/UIFitConstraint.ts","../src/Layers/UIFullScreenLayer.ts","../src/Layers/UIManualLayer.ts","../src/Passes/UIPass.ts"],"sourcesContent":["/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nexport function createMap() {\n return new IndexedMap();\n}\nvar IndexedMap = /** @class */ (function () {\n function IndexedMap() {\n this.index = {};\n this.array = [];\n }\n /**\n * Returns the number of items in the array.\n */\n IndexedMap.prototype.size = function () {\n return this.array.length;\n };\n /**\n * Returns true if the array is empty.\n */\n IndexedMap.prototype.empty = function () {\n return this.array.length === 0;\n };\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n IndexedMap.prototype.itemAt = function (index) {\n return this.array[index];\n };\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.contains = function (key) {\n return this.index[key.id()] !== undefined;\n };\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n IndexedMap.prototype.find = function (key) {\n var i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n };\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n IndexedMap.prototype.setDefault = function (key, factory) {\n var i = this.index[key.id()];\n if (i === undefined) {\n var pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n };\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n IndexedMap.prototype.insert = function (key, value) {\n var pair = new Pair(key, value);\n var i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n };\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n IndexedMap.prototype.erase = function (key) {\n var i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n var pair = this.array[i];\n var last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n };\n /**\n * Create a copy of this associative array.\n */\n IndexedMap.prototype.copy = function () {\n var copy = new IndexedMap();\n for (var i = 0; i < this.array.length; i++) {\n var pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n };\n return IndexedMap;\n}());\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nvar Pair = /** @class */ (function () {\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n function Pair(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n Pair.prototype.copy = function () { return new Pair(this.first, this.second); };\n return Pair;\n}());\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nvar Variable = /** @class */ (function () {\n function Variable(name) {\n if (name === void 0) { name = \"\"; }\n this._value = 0.0;\n this._context = null;\n this._id = VarId++;\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n Variable.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n Variable.prototype.name = function () {\n return this._name;\n };\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n Variable.prototype.setName = function (name) {\n this._name = name;\n };\n /**\n * Returns the user context object of the variable.\n * @private\n */\n Variable.prototype.context = function () {\n return this._context;\n };\n /**\n * Set the user context object of the variable.\n * @private\n */\n Variable.prototype.setContext = function (context) {\n this._context = context;\n };\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n Variable.prototype.value = function () {\n return this._value;\n };\n /**\n * Set the value of the variable.\n * @private\n */\n Variable.prototype.setValue = function (value) {\n this._value = value;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Variable.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Variable.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Variable.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Variable.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n Variable.prototype.toJSON = function () {\n return {\n name: this._name,\n value: this._value,\n };\n };\n Variable.prototype.toString = function () {\n return this._context + \"[\" + this._name + \":\" + this._value + \"]\";\n };\n return Variable;\n}());\nexport { Variable };\n/**\n * The internal variable id counter.\n * @private\n */\nvar VarId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { createMap } from \"./maptype\";\nimport { Variable } from \"./variable\";\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nvar Expression = /** @class */ (function () {\n function Expression() {\n var parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n Expression.prototype.terms = function () {\n return this._terms;\n };\n /**\n * Returns the constant of the expression.\n * @private\n */\n Expression.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n Expression.prototype.value = function () {\n var result = this._constant;\n for (var i = 0, n = this._terms.size(); i < n; i++) {\n var pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n };\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n Expression.prototype.plus = function (value) {\n return new Expression(this, value);\n };\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n Expression.prototype.minus = function (value) {\n return new Expression(this, typeof value === \"number\" ? -value : [-1, value]);\n };\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n Expression.prototype.multiply = function (coefficient) {\n return new Expression([coefficient, this]);\n };\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n Expression.prototype.divide = function (coefficient) {\n return new Expression([1 / coefficient, this]);\n };\n Expression.prototype.isConstant = function () {\n return this._terms.size() == 0;\n };\n Expression.prototype.toString = function () {\n var result = this._terms.array.map(function (pair) {\n return (pair.second + \"*\" + pair.first.toString());\n }).join(\" + \");\n if (!this.isConstant() && this._constant !== 0) {\n result += \" + \";\n }\n result += this._constant;\n return result;\n };\n return Expression;\n}());\nexport { Expression };\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n var constant = 0.0;\n var factory = function () { return 0.0; };\n var terms = createMap();\n for (var i = 0, n = args.length; i < n; ++i) {\n var item = args[i];\n if (typeof item === \"number\") {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n var terms2 = item.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error(\"array must have length 2\");\n }\n var value = item[0];\n var value2 = item[1];\n if (typeof value !== \"number\") {\n throw new Error(\"array item 0 must be a number\");\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += (value2.constant() * value);\n var terms2 = value2.terms();\n for (var j = 0, k = terms2.size(); j < k; j++) {\n var termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += (termPair.second * value);\n }\n }\n else {\n throw new Error(\"array item 1 must be a variable or expression\");\n }\n }\n else {\n throw new Error(\"invalid Expression argument: \" + item);\n }\n }\n return { terms: terms, constant: constant };\n}\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\n/**\n * @class Strength\n */\nvar Strength = /** @class */ (function () {\n function Strength() {\n }\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n Strength.create = function (a, b, c, w) {\n if (w === void 0) { w = 1.0; }\n var result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n };\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n Strength.clip = function (value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n };\n /**\n * The 'required' symbolic strength.\n */\n Strength.required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n Strength.strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n Strength.medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n Strength.weak = Strength.create(0.0, 0.0, 1.0);\n return Strength;\n}());\nexport { Strength };\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Expression } from \"./expression\";\nimport { Strength } from \"./strength\";\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nvar Constraint = /** @class */ (function () {\n function Constraint(expression, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n this._id = CnId++;\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if ((rhs === undefined) && (expression instanceof Expression)) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n Constraint.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n Constraint.prototype.expression = function () {\n return this._expression;\n };\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n Constraint.prototype.op = function () {\n return this._operator;\n };\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n Constraint.prototype.strength = function () {\n return this._strength;\n };\n Constraint.prototype.toString = function () {\n return this._expression.toString() + \" \" + [\"<=\", \">=\", \"=\"][this._operator] + \" 0 (\" + this._strength.toString() + \")\";\n };\n return Constraint;\n}());\nexport { Constraint };\n/**\n * The internal constraint id counter.\n * @private\n */\nvar CnId = 0;\n","/*-----------------------------------------------------------------------------\n| Copyright (c) 2014, Nucleic Development Team.\n|\n| Distributed under the terms of the Modified BSD License.\n|\n| The full license is in the file COPYING.txt, distributed with this software.\n|----------------------------------------------------------------------------*/\nimport { Constraint, Operator } from \"./constraint\";\nimport { Expression } from \"./expression\";\nimport { createMap } from \"./maptype\";\nimport { Strength } from \"./strength\";\n/**\n * The constraint solver class.\n *\n * @class\n */\nvar Solver = /** @class */ (function () {\n /**\n * Construct a new Solver.\n */\n function Solver() {\n this._cnMap = createCnMap();\n this._rowMap = createRowMap();\n this._varMap = createVarMap();\n this._editMap = createEditMap();\n this._infeasibleRows = [];\n this._objective = new Row();\n this._artificial = null;\n this._idTick = 0;\n }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n Solver.prototype.createConstraint = function (lhs, operator, rhs, strength) {\n if (strength === void 0) { strength = Strength.required; }\n var cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n };\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n Solver.prototype.addConstraint = function (constraint) {\n var cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error(\"duplicate constraint\");\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n var data = this._createRow(constraint);\n var row = data.row;\n var tag = data.tag;\n var subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error(\"unsatisfiable constraint\");\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error(\"unsatisfiable constraint\");\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n };\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n Solver.prototype.removeConstraint = function (constraint) {\n var cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error(\"unknown constraint\");\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n var marker = cnPair.second.marker;\n var rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n var leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"failed to find leaving row\");\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n };\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasConstraint = function (constraint) {\n return this._cnMap.contains(constraint);\n };\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n Solver.prototype.addEditVariable = function (variable, strength) {\n var editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error(\"duplicate edit variable\");\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error(\"bad required strength\");\n }\n var expr = new Expression(variable);\n var cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n var tag = this._cnMap.find(cn).second;\n var info = { tag: tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n };\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n Solver.prototype.removeEditVariable = function (variable) {\n var editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n this.removeConstraint(editPair.second.constraint);\n };\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n Solver.prototype.hasEditVariable = function (variable) {\n return this._editMap.contains(variable);\n };\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n Solver.prototype.suggestValue = function (variable, value) {\n var editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error(\"unknown edit variable\");\n }\n var rows = this._rowMap;\n var info = editPair.second;\n var delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n var marker = info.tag.marker;\n var rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n var other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var rowPair_1 = rows.itemAt(i);\n var row = rowPair_1.second;\n var coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 &&\n rowPair_1.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair_1.first);\n }\n }\n this._dualOptimize();\n };\n /**\n * Update the values of the variables.\n */\n Solver.prototype.updateVariables = function () {\n var vars = this._varMap;\n var rows = this._rowMap;\n for (var i = 0, n = vars.size(); i < n; ++i) {\n var pair = vars.itemAt(i);\n var rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n };\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n Solver.prototype._getVarSymbol = function (variable) {\n var _this = this;\n var factory = function () { return _this._makeSymbol(SymbolType.External); };\n return this._varMap.setDefault(variable, factory).second;\n };\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n Solver.prototype._createRow = function (constraint) {\n var expr = constraint.expression();\n var row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n var terms = expr.terms();\n for (var i = 0, n = terms.size(); i < n; ++i) {\n var termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n var symbol = this._getVarSymbol(termPair.first);\n var basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n var objective = this._objective;\n var strength = constraint.strength();\n var tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge:\n {\n var coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n var slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n var error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq:\n {\n if (strength < Strength.required) {\n var errplus = this._makeSymbol(SymbolType.Error);\n var errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n var dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row: row, tag: tag };\n };\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._chooseSubject = function (row, tag) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n var type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n Solver.prototype._addWithArtificialVariable = function (row) {\n // Create and add the artificial variable to the tableau.\n var art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n var success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n var pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n var basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n var entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n };\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n Solver.prototype._substitute = function (symbol, row) {\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 &&\n pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n };\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n Solver.prototype._optimize = function (objective) {\n while (true) {\n var entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n var leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error(\"the objective is unbounded\");\n }\n // pivot the entering symbol into the basis\n var row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n }\n };\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n Solver.prototype._dualOptimize = function () {\n var rows = this._rowMap;\n var infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n var leaving = infeasible.pop();\n var pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n var entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error(\"dual optimize failed\");\n }\n // pivot the entering symbol into the basis\n var row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n };\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n Solver.prototype._getEnteringSymbol = function (objective) {\n var cells = objective.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n Solver.prototype._getDualEnteringSymbol = function (row) {\n var ratio = Number.MAX_VALUE;\n var entering = INVALID_SYMBOL;\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var symbol = pair.first;\n var c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n var coeff = this._objective.coefficientFor(symbol);\n var r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n };\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n Solver.prototype._getLeavingSymbol = function (entering) {\n var ratio = Number.MAX_VALUE;\n var found = INVALID_SYMBOL;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n var row = pair.second;\n var temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n var temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n };\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n Solver.prototype._getMarkerLeavingSymbol = function (marker) {\n var dmax = Number.MAX_VALUE;\n var r1 = dmax;\n var r2 = dmax;\n var invalid = INVALID_SYMBOL;\n var first = invalid;\n var second = invalid;\n var third = invalid;\n var rows = this._rowMap;\n for (var i = 0, n = rows.size(); i < n; ++i) {\n var pair = rows.itemAt(i);\n var row = pair.second;\n var c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n var symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n var r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n var r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n };\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n Solver.prototype._removeConstraintEffects = function (cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n };\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n Solver.prototype._removeMarkerEffects = function (marker, strength) {\n var pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n };\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n Solver.prototype._anyPivotableSymbol = function (row) {\n var cells = row.cells();\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n var type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n };\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n Solver.prototype._makeSymbol = function (type) {\n return new Symbol(type, this._idTick++);\n };\n return Solver;\n}());\nexport { Solver };\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n var eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nvar Symbol = /** @class */ (function () {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n function Symbol(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n Symbol.prototype.id = function () {\n return this._id;\n };\n /**\n * Returns the type of the symbol.\n */\n Symbol.prototype.type = function () {\n return this._type;\n };\n return Symbol;\n}());\n/**\n * A static invalid symbol\n * @private\n */\nvar INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nvar Row = /** @class */ (function () {\n /**\n * Construct a new Row.\n */\n function Row(constant) {\n if (constant === void 0) { constant = 0.0; }\n this._cellMap = createMap();\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n Row.prototype.cells = function () {\n return this._cellMap;\n };\n /**\n * Returns the constant for the row.\n */\n Row.prototype.constant = function () {\n return this._constant;\n };\n /**\n * Returns true if the row is a constant value.\n */\n Row.prototype.isConstant = function () {\n return this._cellMap.empty();\n };\n /**\n * Returns true if the Row has all dummy symbols.\n */\n Row.prototype.allDummies = function () {\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n };\n /**\n * Create a copy of the row.\n */\n Row.prototype.copy = function () {\n var theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n };\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n Row.prototype.add = function (value) {\n return this._constant += value;\n };\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n Row.prototype.insertSymbol = function (symbol, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n var pair = this._cellMap.setDefault(symbol, function () { return 0.0; });\n if (nearZero(pair.second += coefficient)) {\n this._cellMap.erase(symbol);\n }\n };\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n Row.prototype.insertRow = function (other, coefficient) {\n if (coefficient === void 0) { coefficient = 1.0; }\n this._constant += other._constant * coefficient;\n var cells = other._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n };\n /**\n * Remove a symbol from the row.\n */\n Row.prototype.removeSymbol = function (symbol) {\n this._cellMap.erase(symbol);\n };\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n Row.prototype.reverseSign = function () {\n this._constant = -this._constant;\n var cells = this._cellMap;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n var pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n };\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n Row.prototype.solveFor = function (symbol) {\n var cells = this._cellMap;\n var pair = cells.erase(symbol);\n var coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (var i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n };\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n Row.prototype.solveForEx = function (lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n };\n /**\n * Returns the coefficient for the given symbol.\n */\n Row.prototype.coefficientFor = function (symbol) {\n var pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n };\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n Row.prototype.substitute = function (symbol, row) {\n var pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n };\n return Row;\n}());\n","export const xSymbol = Symbol(\"xSymbol\");\nexport const ySymbol = Symbol(\"ySymbol\");\n\nexport const widthSymbol = Symbol(\"widthSymbol\");\nexport const heightSymbol = Symbol(\"heightSymbol\");\n\nexport const addUIElementSymbol = Symbol(\"addUIElementSymbol\");\nexport const removeUIElementSymbol = Symbol(\"removeUIElementSymbol\");\n\nexport const addUIConstraintSymbol = Symbol(\"addConstraintSymbol\");\nexport const removeUIConstraintSymbol = Symbol(\"removeUIConstraintSymbol\");\n\nexport const addConstraintSymbol = Symbol(\"addConstraintSymbol\");\nexport const removeConstraintSymbol = Symbol(\"removeConstraintSymbol\");\n\nexport const addVariableSymbol = Symbol(\"addVariableSymbol\");\nexport const removeVariableSymbol = Symbol(\"removeVariableSymbol\");\nexport const suggestVariableSymbol = Symbol(\"suggestVariableSymbol\");\n\nexport const disableConstraintSymbol = Symbol(\"disableConstraintSymbol\");\nexport const enableConstraintSymbol = Symbol(\"enableConstraintSymbol\");\n\nexport const needsRecalculation = Symbol(\"needsRecalculation\");\nexport const renderSymbol = Symbol(\"renderSymbol\");\n\nexport const clickSymbol = Symbol(\"clickSymbol\");\n","export enum UIOrientation {\n LANDSCAPE,\n PORTRAIT,\n ALWAYS,\n}\n\nexport function isUIOrientation(obj: unknown): obj is UIOrientation {\n return obj !== null && Object.values(UIOrientation).some((v) => v === obj);\n}\n\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","import { Strength } from \"kiwi.js\";\n\nexport enum UIConstraintPower {\n P0,\n P1,\n P2,\n P3,\n P4,\n P5,\n P6,\n P7,\n}\n\nexport function isUIConstraintPower(obj: unknown): obj is UIConstraintPower {\n return (\n obj !== null && Object.values(UIConstraintPower).some((v) => v === obj)\n );\n}\n\nexport function resolvePower(power?: UIConstraintPower): UIConstraintPower {\n return power ?? UIConstraintPower.P0;\n}\n\nexport function convertPowerToStrength(power?: UIConstraintPower): number {\n switch (power) {\n case UIConstraintPower.P0:\n return Strength.create(1000, 1000, 1000);\n case UIConstraintPower.P1:\n return Strength.create(100, 0, 0);\n case UIConstraintPower.P2:\n return Strength.create(10, 0, 0);\n case UIConstraintPower.P3:\n return Strength.create(0, 100, 0);\n case UIConstraintPower.P4:\n return Strength.create(0, 10, 0);\n case UIConstraintPower.P5:\n return Strength.create(0, 0, 100);\n case UIConstraintPower.P6:\n return Strength.create(0, 0, 10);\n case UIConstraintPower.P7:\n return Strength.create(0, 0, 1);\n default:\n return Strength.create(1000, 1000, 1000);\n }\n}\n","import { Operator } from \"kiwi.js\";\n\nexport enum UIConstraintRule {\n EQUAL = Operator.Eq,\n LESS = Operator.Le,\n GREATER = Operator.Ge,\n}\n\nexport function isUIConstraintRule(obj: unknown): obj is UIConstraintRule {\n return obj !== null && Object.values(UIConstraintRule).some((v) => v === obj);\n}\n\nexport function resolveRule(rule?: UIConstraintRule): UIConstraintRule {\n return rule ?? UIConstraintRule.EQUAL;\n}\n\nexport function convertRuleToOperator(rule?: UIConstraintRule): Operator {\n switch (rule) {\n case UIConstraintRule.EQUAL:\n return Operator.Eq;\n case UIConstraintRule.LESS:\n return Operator.Le;\n case UIConstraintRule.GREATER:\n return Operator.Ge;\n default:\n return Operator.Eq;\n }\n}\n","import type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n addUIConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeUIConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport abstract class UIConstraint {\n public name = \"\";\n\n constructor(\n public readonly layer: UILayer,\n elements: Set<UIElement>,\n ) {\n this.layer[addUIConstraintSymbol](this, elements);\n }\n\n public destroy(): void {\n this.layer[removeUIConstraintSymbol](this);\n }\n\n public abstract [disableConstraintSymbol](orientation: UIOrientation): void;\n public abstract [enableConstraintSymbol](orientation: UIOrientation): void;\n\n protected abstract buildConstraints(): void;\n protected abstract destroyConstraints(): void;\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nconst DEFAULT_HEIGHT = 100;\n\nexport interface UIHeightOptions {\n height: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHeightConstraint extends UIConstraint {\n private readonly parameters: UIHeightOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIHeightOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n height: parameters?.height ?? DEFAULT_HEIGHT,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[heightSymbol]),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.height,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","/**\n * Default priority value for event listeners.\n * Lower values indicate higher priority.\n */\nconst DEFAULT_PRIORITY = 100;\n/**\n * A priority-based event emitter implementation.\n * The name \"Eventail\" is a combination of \"event\" + \"tail\", reflecting its queue-like nature.\n *\n * Features:\n * - Priority-based event listeners\n * - Context binding support\n * - One-time event listeners\n * - Type-safe event handling\n *\n * @example\n * ```typescript\n * const emitter = new Eventail();\n *\n * // Regular event listener\n * emitter.on('event', (data) => console.log(data));\n *\n * // One-time event listener with high priority\n * emitter.once('event', callback, context, 50);\n *\n * // Remove specific listener\n * emitter.off('event', callback);\n * ```\n */\nclass Eventail {\n constructor() {\n /** Map storing event listeners for each event type */\n this.listeners = new Map();\n }\n /**\n * Adds an event listener for the specified event type.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.on('data', (value) => console.log(value));\n * emitter.on('error', handleError, this, 50);\n * ```\n */\n on(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, false);\n return this;\n }\n /**\n * Adds a one-time event listener that will be removed after first execution.\n *\n * @param type - The event type to listen for\n * @param callback - The function to be called when the event is emitted\n * @param context - Optional this context for the callback\n * @param priority - Optional priority value (lower = higher priority)\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * emitter.once('init', () => console.log('Initialized'));\n * ```\n */\n once(type, callback, context, priority = DEFAULT_PRIORITY) {\n this.addListener(type, callback, context, priority, true);\n return this;\n }\n /**\n * Removes event listener(s) from the specified event type.\n *\n * @param type - The event type to remove listener(s) from\n * @param callback - Optional callback to remove specific listener\n * @param context - Optional context to match when removing\n * @returns The emitter instance for chaining\n *\n * @example\n * ```typescript\n * // Remove all listeners for 'data' event\n * emitter.off('data');\n *\n * // Remove specific listener\n * emitter.off('data', callback);\n *\n * // Remove listener with specific context\n * emitter.off('data', callback, context);\n * ```\n */\n off(type, callback, context) {\n const current = this.listeners.get(type);\n if (!current) {\n return this;\n }\n if (!callback) {\n this.listeners.delete(type);\n return this;\n }\n const filtered = current.filter((l) => l.callback !== callback ||\n (context !== undefined && l.context !== context));\n filtered.length\n ? this.listeners.set(type, filtered)\n : this.listeners.delete(type);\n return this;\n }\n /**\n * Emits an event, triggering all registered listeners in priority order.\n * Protected method to allow extension in derived classes.\n *\n * @param type - The event type to emit\n * @param args - Arguments to pass to the listeners\n * @returns Boolean indicating if the event had listeners\n *\n * @example\n * ```typescript\n * class MyEmitter extends Eventail {\n * public trigger(type: string, ...args: unknown[]) {\n * return this.emit(type, ...args);\n * }\n * }\n * ```\n */\n emit(type, ...args) {\n const current = this.listeners.get(type);\n if (!(current === null || current === void 0 ? void 0 : current.length)) {\n return false;\n }\n for (const listener of [...current]) {\n listener.callback.apply(listener.context, args);\n if (listener.once) {\n this.off(type, listener.callback, listener.context);\n }\n }\n return true;\n }\n /**\n * Internal method to add a new event listener with the specified configuration.\n * Maintains priority order and prevents duplicate listeners.\n *\n * @param type - Event type\n * @param callback - Event callback\n * @param context - Callback context\n * @param priority - Event priority\n * @param once - Whether it's a one-time listener\n * @throws {Error} If the listener already exists\n */\n addListener(type, callback, context, priority, once) {\n let list = this.listeners.get(type);\n if (!list) {\n list = [];\n this.listeners.set(type, list);\n }\n if (list.some((l) => l.callback === callback && l.context === context)) {\n throw new Error(\"Event listener already exists\");\n }\n const event = { callback, context, priority, once };\n let i = 0;\n while (i < list.length && list[i].priority <= priority) {\n i++;\n }\n list.splice(i, 0, event);\n }\n}\n\nexport { DEFAULT_PRIORITY, Eventail };\n//# sourceMappingURL=index.js.map\n","import { Box2, Vector2 } from \"three\";\n\nconst tempVector2 = new Vector2();\nconst tempBox2 = new Box2();\n\nexport function testElement(\n elementX: number,\n elementY: number,\n elementWidth: number,\n elementHeight: number,\n xClick: number,\n yClick: number,\n): boolean {\n tempVector2.set(xClick, yClick);\n\n tempBox2.min.set(elementX, elementY);\n tempBox2.max.set(elementWidth, elementHeight).add(tempBox2.min);\n return tempBox2.containsPoint(tempVector2);\n}\n","export enum UIBehavior {\n HIDDEN,\n VISIBLE,\n INTERACTIVE,\n}\n","import { MathUtils } from \"three\";\nimport { needsRecalculation } from \"./symbols\";\n\nconst DEFAULT_POSITION = 0;\nconst DEFAULT_ANCHOR = 0.5;\nconst DEFAULT_SCALE = 1;\nconst DEFAULT_ROTATION = 0;\n\nexport class UIMicroTransformations {\n public [needsRecalculation] = false;\n\n private positionXInternal = DEFAULT_POSITION;\n private positionYInternal = DEFAULT_POSITION;\n private anchorXInternal = DEFAULT_ANCHOR;\n private anchorYInternal = DEFAULT_ANCHOR;\n private scaleXInternal = DEFAULT_SCALE;\n private scaleYInternal = DEFAULT_SCALE;\n private rotationInternal = DEFAULT_ROTATION;\n\n public get x(): number {\n return this.positionXInternal;\n }\n\n public get y(): number {\n return this.positionYInternal;\n }\n\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n public set x(value: number) {\n this.positionXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set y(value: number) {\n this.positionYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set anchorX(value: number) {\n this.anchorXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set anchorY(value: number) {\n this.anchorYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set scaleX(value: number) {\n this.scaleXInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set scaleY(value: number) {\n this.scaleYInternal = value;\n this[needsRecalculation] = true;\n }\n\n public set angle(value: number) {\n this.rotationInternal = MathUtils.degToRad(value);\n this[needsRecalculation] = true;\n }\n\n public set rotation(value: number) {\n this.rotationInternal = value;\n this[needsRecalculation] = true;\n }\n\n public reset(): void {\n this.positionXInternal = DEFAULT_POSITION;\n this.positionYInternal = DEFAULT_POSITION;\n this.anchorXInternal = DEFAULT_ANCHOR;\n this.anchorYInternal = DEFAULT_ANCHOR;\n this.scaleXInternal = DEFAULT_SCALE;\n this.scaleYInternal = DEFAULT_SCALE;\n this.rotationInternal = DEFAULT_ROTATION;\n this[needsRecalculation] = true;\n }\n}\n","import { PlaneGeometry } from \"three\";\n\nconst GEOMETRY_SIZE = 1;\nconst GEOMETRY_OFFSET = 0.5;\n\nexport const geometry = new PlaneGeometry(\n GEOMETRY_SIZE,\n GEOMETRY_SIZE,\n).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);\n","import type { ShaderMaterial, WebGLRenderer } from \"three\";\nimport { Mesh, OrthographicCamera, Scene } from \"three\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\n\nconst scene = new Scene();\nconst mesh = new Mesh(geometry);\nscene.add(mesh);\n\nexport class UIFullScreenQuad {\n private readonly camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n constructor(\n private materialInternal: ShaderMaterial,\n private paddingHorizontalInternal = 0,\n private paddingVerticalInternal = 0,\n ) {\n this.updateCameraTransform();\n }\n\n public get paddingHorizontal(): number {\n return this.paddingHorizontalInternal;\n }\n\n public get paddingVertical(): number {\n return this.paddingVerticalInternal;\n }\n\n public get material(): ShaderMaterial {\n return this.materialInternal;\n }\n\n public set paddingHorizontal(value: number) {\n if (this.paddingHorizontalInternal !== value) {\n this.paddingHorizontalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n public set paddingVertical(value: number) {\n if (this.paddingVerticalInternal !== value) {\n this.paddingVerticalInternal = value;\n this.updateCameraTransform();\n }\n }\n\n public set material(value: ShaderMaterial) {\n this.materialInternal = value;\n }\n\n public render(renderer: WebGLRenderer): void {\n mesh.material = this.materialInternal;\n renderer.render(scene, this.camera);\n }\n\n private updateCameraTransform(): void {\n this.camera.left = -this.paddingHorizontalInternal;\n this.camera.right = 1 + this.paddingHorizontalInternal;\n this.camera.bottom = -this.paddingVerticalInternal;\n this.camera.top = 1 + this.paddingVerticalInternal;\n this.camera.updateProjectionMatrix();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Color, Matrix3, ShaderMaterial, UniformsUtils } from \"three\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\n\nexport class UIDrawPass {\n private readonly screen: UIFullScreenQuad;\n\n constructor() {\n this.screen = new UIFullScreenQuad(\n new ShaderMaterial({\n uniforms: UniformsUtils.merge([\n {\n map: { value: null },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n uvTransform: { value: new Matrix3() },\n },\n ]),\n vertexShader: /* glsl */ `\n uniform mat3 uvTransform;\n varying vec2 vUv;\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n }),\n );\n }\n\n public destroy(): void {\n this.screen.material.dispose();\n }\n\n public setPadding(width: number, height: number, padding: number): void {\n if (padding <= 0) {\n this.screen.paddingHorizontal = 0;\n this.screen.paddingVertical = 0;\n } else {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n }\n\n public render(renderer: WebGLRenderer, texture: Texture): void {\n this.screen.material.uniforms.map.value = texture;\n this.screen.material.uniformsNeedUpdate = true;\n this.screen.render(renderer);\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIDrawPass } from \"./UIDrawPass\";\nimport type { UIPass } from \"./UIPass\";\n\nexport class UIComposer {\n public readonly passes: UIPass[] = [];\n private readonly drawPass = new UIDrawPass();\n private fromRenderTarget: WebGLRenderTarget;\n private toRenderTarget: WebGLRenderTarget;\n\n constructor() {\n const parameters = {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: false,\n stencilBuffer: false,\n };\n this.fromRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n this.toRenderTarget = new WebGLRenderTarget(1, 1, parameters);\n }\n\n public calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n public render(renderer: WebGLRenderer, texture: Texture): Texture {\n if (this.passes.length === 0) {\n return texture;\n }\n\n if (this.passes.every((p) => !p.needsUpdate)) {\n return this.fromRenderTarget.texture;\n }\n\n const padding = this.calculatePadding();\n\n const width = texture.image.width;\n const height = texture.image.height;\n\n const widthWithPadding = width + padding * 2;\n const heightWithPadding = height + padding * 2;\n\n this.fromRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.toRenderTarget.setSize(widthWithPadding, heightWithPadding);\n this.drawPass.setPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n\n renderer.setRenderTarget(this.fromRenderTarget);\n renderer.clearColor();\n\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clearColor();\n\n this.drawPass.render(renderer, texture);\n this.reverseTargets();\n\n for (const pass of this.passes) {\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clearColor();\n pass.render(renderer, this.fromRenderTarget.texture, {\n width,\n height,\n padding,\n });\n this.reverseTargets();\n }\n\n return this.fromRenderTarget.texture;\n }\n\n public destroy(): void {\n this.drawPass.destroy();\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n private reverseTargets(): void {\n const fromRenderTarget = this.fromRenderTarget;\n this.fromRenderTarget = this.toRenderTarget;\n this.toRenderTarget = fromRenderTarget;\n }\n}\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { WebGLRenderer } from \"three\";\nimport { type Object3D } from \"three\";\nimport {\n convertPowerToStrength,\n UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { testElement } from \"../Miscellaneous/math\";\nimport { applyMicroTransformations } from \"../Miscellaneous/microTransformationTools\";\nimport {\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n heightSymbol,\n needsRecalculation,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UIMicroTransformations } from \"../Miscellaneous/UIMicroTransformations\";\nimport { UIComposer } from \"../Passes/UIComposer\";\nimport type { UIPass } from \"../Passes/UIPass\";\n\nexport enum UIElementEvent {\n CLICK = \"click\",\n}\n\nexport abstract class UIElement extends Eventail {\n public name = \"\";\n public readonly micro = new UIMicroTransformations();\n\n public [xSymbol] = new Variable(\"x\");\n public [ySymbol] = new Variable(\"y\");\n public [widthSymbol] = new Variable(\"width\");\n public [heightSymbol] = new Variable(\"height\");\n public [needsRecalculation] = false;\n\n protected behaviorInternal = UIBehavior.VISIBLE;\n protected readonly composer = new UIComposer();\n\n constructor(\n public readonly layer: UILayer,\n protected readonly object: Object3D,\n x: number,\n y: number,\n width: number,\n height: number,\n ) {\n super();\n this.layer[addUIElementSymbol](this, this.object);\n\n this.layer[addVariableSymbol](\n this,\n this[xSymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[ySymbol],\n convertPowerToStrength(UIConstraintPower.P7),\n );\n this.layer[addVariableSymbol](\n this,\n this[widthSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n this.layer[addVariableSymbol](\n this,\n this[heightSymbol],\n convertPowerToStrength(UIConstraintPower.P5),\n );\n\n this[xSymbol].setValue(x);\n this[ySymbol].setValue(y);\n this[widthSymbol].setValue(width);\n this[heightSymbol].setValue(height);\n\n this.layer[suggestVariableSymbol](this, this[xSymbol], x);\n this.layer[suggestVariableSymbol](this, this[ySymbol], y);\n this.layer[suggestVariableSymbol](this, this[widthSymbol], width);\n this.layer[suggestVariableSymbol](this, this[heightSymbol], height);\n }\n\n public get passes(): UIPass[] {\n return this.composer.passes;\n }\n\n public get x(): number {\n return this[xSymbol].value();\n }\n\n public get y(): number {\n return this[ySymbol].value();\n }\n\n public get width(): number {\n return this[widthSymbol].value();\n }\n\n public get height(): number {\n return this[heightSymbol].value();\n }\n\n public get zIndex(): number {\n return this.object.position.z;\n }\n\n public get behavior(): UIBehavior {\n return this.behaviorInternal;\n }\n\n public set x(value: number) {\n this.layer[suggestVariableSymbol](this, this[xSymbol], value);\n }\n\n public set y(value: number) {\n this.layer[suggestVariableSymbol](this, this[ySymbol], value);\n }\n\n public set width(value: number) {\n this.layer[suggestVariableSymbol](this, this[widthSymbol], value);\n }\n\n public set height(value: number) {\n this.layer[suggestVariableSymbol](this, this[heightSymbol], value);\n }\n\n public set zIndex(value: number) {\n this.object.position.z = value;\n }\n\n public set behavior(value: UIBehavior) {\n this.behaviorInternal = value;\n this.object.visible = value !== UIBehavior.HIDDEN;\n }\n\n public destroy(): void {\n this.composer.destroy();\n this.layer[removeVariableSymbol](this, this[heightSymbol]);\n this.layer[removeVariableSymbol](this, this[widthSymbol]);\n this.layer[removeVariableSymbol](this, this[ySymbol]);\n this.layer[removeVariableSymbol](this, this[xSymbol]);\n this.layer[removeUIElementSymbol](this);\n }\n\n public [clickSymbol](x: number, y: number): boolean {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return false;\n }\n\n this.flushTransform();\n if (testElement(this.x, this.y, this.width, this.height, x, y)) {\n this.emit(UIElementEvent.CLICK, this);\n return true;\n }\n\n return false;\n }\n\n protected flushTransform(): void {\n if (this[needsRecalculation] || this.micro[needsRecalculation]) {\n applyMicroTransformations(\n this.object,\n this.micro,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composer.calculatePadding(),\n );\n\n this[needsRecalculation] = false;\n this.micro[needsRecalculation] = false;\n }\n }\n\n protected abstract [renderSymbol](renderer: WebGLRenderer): void;\n}\n","import type { Object3D } from \"three\";\nimport type { UIMicroTransformations } from \"./UIMicroTransformations\";\n\nexport function applyMicroTransformations(\n object: Object3D,\n micro: UIMicroTransformations,\n x: number,\n y: number,\n width: number,\n height: number,\n padding: number,\n): void {\n const realX = x - padding;\n const realY = y - padding;\n\n const realWidth = width + padding * 2;\n const realHeight = height + padding * 2;\n\n const anchorOffsetX = realWidth * micro.anchorX;\n const anchorOffsetY = realHeight * micro.anchorY;\n\n const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n let localX = realX - centerX;\n let localY = realY - centerY;\n\n localX *= micro.scaleX;\n localY *= micro.scaleY;\n\n const cos = Math.cos(micro.rotation);\n const sin = Math.sin(micro.rotation);\n\n localX = localX * cos - localY * sin;\n localY = localX * sin + localY * cos;\n\n localX += micro.x;\n localY += micro.y;\n\n object.position.x = localX + centerX;\n object.position.y = localY + centerY;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","import {\n Constraint,\n Expression,\n Operator,\n Solver,\n Strength,\n Variable,\n} from \"kiwi.js\";\nimport type { Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n addUIConstraintSymbol,\n addUIElementSymbol,\n addVariableSymbol,\n clickSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n needsRecalculation,\n removeConstraintSymbol,\n removeUIConstraintSymbol,\n removeUIElementSymbol,\n removeVariableSymbol,\n renderSymbol,\n suggestVariableSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nconst MAX_Z_INDEX = 1000;\nexport const color = new Color(0x000000);\n\ninterface VariableDescription {\n strength: number;\n suggestedValue: number;\n}\n\ninterface UIElementDescription {\n object: Object3D;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<UIConstraint>;\n}\n\ninterface UIConstraintDescription {\n elements: Set<UIElement>;\n variables: Map<Variable, VariableDescription>;\n constraints: Set<Constraint>;\n}\n\nexport abstract class UILayer {\n public behavior = UIBehavior.VISIBLE;\n\n public readonly [xSymbol]: Variable = new Variable();\n public readonly [ySymbol]: Variable = new Variable();\n public readonly [widthSymbol]: Variable = new Variable();\n public readonly [heightSymbol]: Variable = new Variable();\n\n protected readonly scene = new Scene();\n protected readonly camera = new OrthographicCamera();\n protected solver? = new Solver();\n\n protected elements = new Map<UIElement, UIElementDescription>();\n protected constraints = new Map<UIConstraint, UIConstraintDescription>();\n\n protected constraintX?: Constraint;\n protected constraintY?: Constraint;\n protected constraintW?: Constraint;\n protected constraintH?: Constraint;\n\n protected orientationPrivate = UIOrientation.PORTRAIT;\n protected needsRecalculation = false;\n\n public get orientation(): UIOrientation {\n return this.orientationPrivate;\n }\n\n public destroy(): void {\n this.solver = undefined;\n for (const constraint of this.constraints.keys()) {\n constraint.destroy();\n }\n for (const element of this.elements.keys()) {\n element.destroy();\n }\n }\n\n public [addUIElementSymbol](element: UIElement, object: Object3D): void {\n if (this.elements.has(element)) {\n throw new Error(\"Element already added\");\n }\n\n this.elements.set(element, {\n object,\n variables: new Map(),\n constraints: new Set(),\n });\n\n this.scene.add(object);\n }\n\n public [removeUIElementSymbol](element: UIElement): void {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing element\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\"Constraints should be removed before removing element\");\n }\n\n this.elements.delete(element);\n this.scene.remove(dependencies.object);\n }\n\n public [addUIConstraintSymbol](\n constraint: UIConstraint,\n elements: Set<UIElement>,\n ): void {\n if (this.constraints.has(constraint)) {\n throw new Error(\"Constraint already added\");\n }\n\n for (const element of elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.add(constraint);\n }\n\n this.constraints.set(constraint, {\n elements,\n variables: new Map(),\n constraints: new Set(),\n });\n }\n\n public [removeUIConstraintSymbol](constraint: UIConstraint): void {\n const dependencies = this.constraints.get(constraint);\n if (dependencies === undefined) {\n throw new Error(\"Constraint not found\");\n }\n\n if (dependencies.variables.size > 0) {\n throw new Error(\"Variables should be removed before removing constraint\");\n }\n\n if (dependencies.constraints.size > 0) {\n throw new Error(\n \"Constraints should be removed before removing constraint\",\n );\n }\n\n for (const element of dependencies.elements) {\n const dependencies = this.elements.get(element);\n if (dependencies === undefined) {\n throw new Error(\"Element not found\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Something went wrong\");\n }\n\n dependencies.constraints.delete(constraint);\n }\n\n this.constraints.delete(constraint);\n }\n\n public [addConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before adding constraint you need to add it's owner\");\n }\n\n if (dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint already exists\");\n }\n\n dependencies.constraints.add(constraint);\n this.solver?.addConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [removeConstraintSymbol](\n owner: UIConstraint,\n constraint: Constraint,\n ): void {\n const dependencies = this.constraints.get(owner);\n if (dependencies === undefined) {\n throw new Error(\"Before removing constraint you need to add it's owner\");\n }\n\n if (!dependencies.constraints.has(constraint)) {\n throw new Error(\"Constraint not found\");\n }\n\n dependencies.constraints.delete(constraint);\n this.solver?.removeConstraint(constraint);\n this.needsRecalculation = true;\n }\n\n public [addVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n strength: number,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before adding variable you need to add it's owner\");\n }\n\n if (dependencies.variables.has(variable)) {\n throw new Error(\"Variable already exists\");\n }\n\n dependencies.variables.set(variable, {\n strength,\n suggestedValue: variable.value(),\n });\n this.solver?.addEditVariable(variable, strength);\n this.needsRecalculation = true;\n }\n\n public [removeVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before removing variable you need to add it's owner\");\n }\n\n if (!dependencies.variables.has(variable)) {\n throw new Error(\"Variable does not exist\");\n }\n\n dependencies.variables.delete(variable);\n this.solver?.removeEditVariable(variable);\n this.needsRecalculation = true;\n }\n\n public [suggestVariableSymbol](\n owner: UIElement | UIConstraint,\n variable: Variable,\n value: number,\n ): void {\n const dependencies =\n owner instanceof UIElement\n ? this.elements.get(owner)\n : this.constraints.get(owner);\n\n if (dependencies === undefined) {\n throw new Error(\"Before suggesting variable you need to add it's owner\");\n }\n\n const description = dependencies.variables.get(variable);\n\n if (!description) {\n throw new Error(\"Variable does not exist\");\n }\n\n if (description.suggestedValue !== value) {\n description.suggestedValue = value;\n this.solver?.suggestValue(variable, value);\n this.needsRecalculation = true;\n }\n }\n\n public render(renderer: WebGLRenderer): void {\n if (this.behavior === UIBehavior.HIDDEN) {\n return;\n }\n\n const originalRenderTarget = renderer.getRenderTarget();\n const originalClearColor = renderer.getClearColor(color);\n const originalClearAlpha = renderer.getClearAlpha();\n\n if (this.needsRecalculation) {\n this.needsRecalculation = false;\n this.solver?.updateVariables();\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n }\n\n for (const element of this.elements.keys()) {\n element[needsRecalculation] = true;\n }\n\n for (const element of this.elements.keys()) {\n element[renderSymbol](renderer);\n }\n\n renderer.setRenderTarget(originalRenderTarget);\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.render(this.scene, this.camera);\n }\n\n protected clickInternal(x: number, y: number): void {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return;\n }\n\n const elements = [...this.elements.keys()]\n .filter((e: UIElement) => e.behavior === UIBehavior.INTERACTIVE)\n .sort((a: UIElement, b: UIElement) => a.zIndex - b.zIndex);\n\n for (const element of elements) {\n if (element[clickSymbol](x, y)) {\n break;\n }\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.applyCameraSize(width, height);\n this.rebuildLayerConstraints(width, height);\n this.updateOrientation(width, height);\n this.needsRecalculation = true;\n }\n\n protected applyCameraSize(width: number, height: number): void {\n this.camera.near = -MAX_Z_INDEX;\n this.camera.far = 0;\n this.camera.bottom = 0;\n this.camera.left = 0;\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n }\n\n protected rebuildLayerConstraints(width: number, height: number): void {\n if (this.constraintX) {\n this.solver?.removeConstraint(this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.solver?.removeConstraint(this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.solver?.removeConstraint(this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.solver?.removeConstraint(this.constraintH);\n this.constraintH = undefined;\n }\n\n this.constraintX = new Constraint(\n new Expression(this[xSymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintY = new Constraint(\n new Expression(this[ySymbol]),\n Operator.Eq,\n 0,\n Strength.required,\n );\n\n this.constraintW = new Constraint(\n new Expression(this[widthSymbol]),\n Operator.Eq,\n width,\n Strength.required,\n );\n\n this.constraintH = new Constraint(\n new Expression(this[heightSymbol]),\n Operator.Eq,\n height,\n Strength.required,\n );\n\n this.solver?.addConstraint(this.constraintX);\n this.solver?.addConstraint(this.constraintY);\n this.solver?.addConstraint(this.constraintW);\n this.solver?.addConstraint(this.constraintH);\n }\n\n protected updateOrientation(width: number, height: number): void {\n const lastOrientation = this.orientationPrivate;\n this.orientationPrivate =\n width > height ? UIOrientation.LANDSCAPE : UIOrientation.PORTRAIT;\n\n if (lastOrientation !== this.orientationPrivate) {\n this.solver = undefined;\n\n for (const constraint of this.constraints.keys()) {\n constraint[enableConstraintSymbol](this.orientationPrivate);\n }\n for (const constraint of this.constraints.keys()) {\n constraint[disableConstraintSymbol](this.orientationPrivate);\n }\n\n this.solver = new Solver();\n const descriptions = [\n ...this.elements.values(),\n ...this.constraints.values(),\n ];\n\n for (const description of descriptions) {\n for (const [key, value] of description.variables.entries()) {\n this.solver.addEditVariable(key, value.strength);\n this.solver.suggestValue(key, value.suggestedValue);\n }\n }\n\n if (this.constraintX) {\n this.solver.addConstraint(this.constraintX);\n }\n if (this.constraintY) {\n this.solver.addConstraint(this.constraintY);\n }\n if (this.constraintW) {\n this.solver.addConstraint(this.constraintW);\n }\n if (this.constraintH) {\n this.solver.addConstraint(this.constraintH);\n }\n\n for (const dependency of this.constraints.values()) {\n for (const constraint of dependency.constraints.values()) {\n this.solver.addConstraint(constraint);\n }\n }\n }\n }\n}\n","import type { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\n\nexport function assertSameLayer(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n message?: string,\n): void {\n if (\n (elementOne instanceof UILayer ? elementOne : elementOne.layer) !==\n elementTwo.layer\n ) {\n throw new Error(\n message ??\n `Elements must be on the same layer - element \"${elementTwo.constructor.name}\" cannot interact with elements from a different layer`,\n );\n }\n}\n\nexport function assertSize(\n width: number,\n height: number,\n message?: string,\n): void {\n if (width <= 0 || height <= 0) {\n throw new Error(\n message ??\n `Invalid dimensions: width (${width}) and height (${height}) must both be positive numbers greater than 0`,\n );\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\nexport interface UIHorizontalDistanceOptions {\n anchorOne: number;\n anchorTwo: number;\n distance: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHorizontalDistanceConstraint extends UIConstraint {\n private readonly parameters: UIHorizontalDistanceOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n );\n\n const expressionTwo = new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n );\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIHorizontalProportionOptions {\n proportion: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHorizontalProportionConstraint extends UIConstraint {\n private readonly parameters: UIHorizontalProportionOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIHorizontalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.proportion,\n );\n const expressionTwo = new Expression(this.elementTwo[widthSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\nexport interface UIVerticalDistanceOptions {\n anchorOne: number;\n anchorTwo: number;\n distance: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIVerticalDistanceConstraint extends UIConstraint {\n private readonly parameters: UIVerticalDistanceOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalDistanceOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n anchorOne: parameters?.anchorOne ?? DEFAULT_ANCHOR,\n anchorTwo: parameters?.anchorTwo ?? DEFAULT_ANCHOR,\n distance: parameters?.distance ?? 0,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.anchorOne,\n ),\n );\n\n const expressionTwo = new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.anchorTwo,\n ),\n );\n\n this.constraint = new Constraint(\n expressionTwo.minus(expressionOne),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.distance,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIVerticalProportionOptions {\n proportion: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIVerticalProportionConstraint extends UIConstraint {\n private readonly parameters: UIVerticalProportionOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIVerticalProportionOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n proportion: parameters?.proportion ?? 1,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expressionOne = new Expression(\n this.elementOne[heightSymbol],\n ).multiply(this.parameters.proportion);\n const expressionTwo = new Expression(this.elementTwo[heightSymbol]);\n\n this.constraint = new Constraint(\n expressionOne.minus(expressionTwo),\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nconst DEFAULT_WIDTH = 100;\n\nexport interface UIWidthOptions {\n width: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIWidthConstraint extends UIConstraint {\n private readonly parameters: UIWidthOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIWidthOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n width: parameters?.width ?? DEFAULT_WIDTH,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraint = new Constraint(\n new Expression(this.element[widthSymbol]),\n convertRuleToOperator(this.parameters.rule),\n this.parameters.width,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIConstraintRule } from \"../Constraints/UIConstraintRule\";\nimport { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIType2D<T> {\n x?: T;\n y?: T;\n}\n\ninterface UIConstraint2DOptions {\n power: UIType2D<UIConstraintPower>;\n rule: UIType2D<UIConstraintRule>;\n orientation: UIType2D<UIOrientation>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n size: UIType2D<number>;\n}\n\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n anchorOne: UIType2D<number>;\n anchorTwo: UIType2D<number>;\n distance: UIType2D<number>;\n}\n\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n proportion: UIType2D<number>;\n}\n\nexport interface UIConstraint2DResult<TX, TY> {\n x: TX;\n y: TY;\n}\n\nexport class UIConstraint2DBuilder {\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n return {\n x: new UIWidthConstraint(element, {\n width: options.size?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIHeightConstraint(element, {\n height: options.size?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static distance(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options: Partial<UIConstraintSize2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n return {\n x: new UIHorizontalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.x,\n anchorTwo: options.anchorTwo?.x,\n distance: options.distance?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalDistanceConstraint(elementOne, elementTwo, {\n anchorOne: options.anchorOne?.y,\n anchorTwo: options.anchorTwo?.y,\n distance: options.distance?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n\n public static proportional(\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options: Partial<UIConstraintProportion2DOptions>,\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n return {\n x: new UIHorizontalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.x,\n power: options.power?.x,\n rule: options.rule?.x,\n orientation: options.orientation?.x,\n }),\n y: new UIVerticalProportionConstraint(elementOne, elementTwo, {\n proportion: options.proportion?.y,\n power: options.power?.y,\n rule: options.rule?.y,\n orientation: options.orientation?.y,\n }),\n };\n }\n}\n","import { Constraint, Expression } from \"kiwi.js\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\nimport type { UIConstraintPower } from \"./UIConstraintPower\";\nimport { convertPowerToStrength, resolvePower } from \"./UIConstraintPower\";\nimport type { UIConstraintRule } from \"./UIConstraintRule\";\nimport { convertRuleToOperator, resolveRule } from \"./UIConstraintRule\";\n\nexport interface UIAspectOptions {\n aspect: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIAspectConstraint extends UIConstraint {\n private readonly parameters: UIAspectOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n parameters?: Partial<UIAspectOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.parameters = {\n aspect: parameters?.aspect ?? this.element.width / this.element.height,\n power: resolvePower(parameters?.power),\n rule: resolveRule(parameters?.rule),\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](newOrientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n newOrientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n const expression = new Expression(this.element[widthSymbol]).plus(\n new Expression(this.element[heightSymbol]).multiply(\n -this.parameters.aspect,\n ),\n );\n\n this.constraint = new Constraint(\n expression,\n convertRuleToOperator(this.parameters.rule),\n 0,\n convertPowerToStrength(this.parameters.power),\n );\n\n this.layer[addConstraintSymbol](this, this.constraint);\n }\n\n protected destroyConstraints(): void {\n if (this.constraint) {\n this.layer[removeConstraintSymbol](this, this.constraint);\n this.constraint = undefined;\n }\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\nexport interface UICoverOptions {\n isStrict: boolean;\n horizontalAnchor: number;\n verticalAnchor: number;\n orientation: UIOrientation;\n}\n\nexport class UICoverConstraint extends UIConstraint {\n private readonly parameters: UICoverOptions;\n\n private constraintX?: Constraint;\n private constraintY?: Constraint;\n private constraintW?: Constraint;\n private constraintH?: Constraint;\n private constraintStrict?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UICoverOptions>,\n ) {\n assertSameLayer(elementOne, elementTwo);\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Le,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (!this.parameters.isStrict) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import {\n isUIConstraintPower,\n type UIConstraintPower,\n} from \"../Constraints/UIConstraintPower\";\nimport {\n isUIConstraintRule,\n type UIConstraintRule,\n} from \"../Constraints/UIConstraintRule\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\nimport { isUIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport type AtLeastOneNumber =\n | { x?: number; y: number }\n | { x: number; y?: number };\n\nexport type AtLeastOnePower =\n | { x?: UIConstraintPower; y: UIConstraintPower }\n | { x: UIConstraintPower; y?: UIConstraintPower };\n\nexport type AtLeastOneRule =\n | { x?: UIConstraintRule; y: UIConstraintRule }\n | { x: UIConstraintRule; y?: UIConstraintRule };\n\nexport interface UICommonDoubleElementConstraintDescription {\n elementOne: UIElement | UILayer;\n elementTwo: UIElement;\n}\n\nexport interface UICommonProportionalConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n proportion: AtLeastOneNumber;\n power?: AtLeastOnePower;\n rule?: AtLeastOneRule;\n orientation?: UIOrientation;\n}\n\nexport interface UICommonDistanceConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n distance: AtLeastOneNumber;\n anchorOne?: AtLeastOneNumber;\n anchorTwo?: AtLeastOneNumber;\n power?: AtLeastOnePower;\n rule?: AtLeastOneRule;\n orientation?: UIOrientation;\n}\n\nexport interface UICommonCoverConstraintDescription\n extends UICommonDoubleElementConstraintDescription {\n isStrict: boolean;\n anchor?: AtLeastOneNumber;\n}\n\nexport function isAtLeastOneNumber(obj: unknown): obj is AtLeastOneNumber {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && typeof obj.x === \"number\") ||\n (\"y\" in obj && typeof obj.y === \"number\"))\n );\n}\n\nexport function isAtLeastOnePower(obj: unknown): obj is AtLeastOnePower {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && isUIConstraintPower(obj.x)) ||\n (\"y\" in obj && isUIConstraintPower(obj.y)))\n );\n}\n\nexport function isAtLeastOneRule(obj: unknown): obj is AtLeastOneRule {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n ((\"x\" in obj && isUIConstraintRule(obj.x)) ||\n (\"y\" in obj && isUIConstraintRule(obj.y)))\n );\n}\n\nexport function isUICommonDoubleElementConstraintDescription(\n obj: unknown,\n): obj is UICommonDoubleElementConstraintDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"elementOne\" in obj &&\n \"elementTwo\" in obj &&\n (obj.elementOne instanceof UIElement ||\n obj.elementOne instanceof UILayer) &&\n obj.elementTwo instanceof UIElement\n );\n}\n\nexport function isUICommonDistanceConstraintDescription(\n obj: unknown,\n): obj is UICommonDistanceConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"distance\" in obj &&\n isAtLeastOneNumber(obj.distance) &&\n (!(\"anchorOne\" in obj) ||\n (\"anchorOne\" in obj && isAtLeastOneNumber(obj.anchorOne))) &&\n (!(\"anchorTwo\" in obj) ||\n (\"anchorTwo\" in obj && isAtLeastOneNumber(obj.anchorTwo))) &&\n (!(\"power\" in obj) || isAtLeastOnePower(obj.power)) &&\n (!(\"rule\" in obj) || isAtLeastOneRule(obj.rule)) &&\n (!(\"orientation\" in obj) || isUIOrientation(obj.orientation))\n );\n}\n\nexport function isUICommonProportionalConstraintDescription(\n obj: unknown,\n): obj is UICommonProportionalConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"proportion\" in obj &&\n isAtLeastOneNumber(obj.proportion) &&\n (!(\"power\" in obj) || isAtLeastOnePower(obj.power)) &&\n (!(\"rule\" in obj) || isAtLeastOneRule(obj.rule)) &&\n (!(\"orientation\" in obj) || isUIOrientation(obj.orientation))\n );\n}\n\nexport function isUICommonCoverConstraintDescription(\n obj: unknown,\n): obj is UICommonCoverConstraintDescription {\n return (\n isUICommonDoubleElementConstraintDescription(obj) &&\n \"isStrict\" in obj &&\n typeof obj.isStrict === \"boolean\" &&\n (!(\"anchor\" in obj) || (\"anchor\" in obj && isAtLeastOneNumber(obj.anchor)))\n );\n}\n","import type {\n UIConstraintPower} from \"../Constraints/UIConstraintPower\";\nimport {\n isUIConstraintPower\n} from \"../Constraints/UIConstraintPower\";\nimport type {\n UIConstraintRule} from \"../Constraints/UIConstraintRule\";\nimport {\n isUIConstraintRule\n} from \"../Constraints/UIConstraintRule\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UICommonSingleElementConstraintDescription {\n element: UIElement;\n power?: UIConstraintPower;\n rule?: UIConstraintRule;\n orientation?: UIOrientation;\n}\n\nexport interface UIWidthConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n width: number;\n}\n\nexport interface UIHeightConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n height: number;\n}\n\nexport interface UIKeepAspectConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n keepAspect: boolean;\n}\n\nexport interface UIKeepSizeConstraintDescription\n extends UICommonSingleElementConstraintDescription {\n keepSize: boolean;\n}\n\nexport function isUICommonSingleElementConstraintDescription(\n obj: unknown,\n): obj is UICommonSingleElementConstraintDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"element\" in obj &&\n obj.element instanceof UIElement &&\n (!(\"power\" in obj) || isUIConstraintPower(obj.power)) &&\n (!(\"rule\" in obj) || isUIConstraintRule(obj.rule))\n );\n}\n\nexport function isUIWidthConstraintDescription(\n obj: unknown,\n): obj is UIWidthConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"width\" in obj &&\n typeof obj.width === \"number\"\n );\n}\n\nexport function isUIHeightConstraintDescription(\n obj: unknown,\n): obj is UIHeightConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\nexport function isUIKeepAspectConstraintDescription(\n obj: unknown,\n): obj is UIKeepAspectConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"keepAspect\" in obj &&\n typeof obj.keepAspect === \"boolean\"\n );\n}\n\nexport function isUIKeepSizeConstraintDescription(\n obj: unknown,\n): obj is UIKeepSizeConstraintDescription {\n return (\n isUICommonSingleElementConstraintDescription(obj) &&\n \"keepSize\" in obj &&\n typeof obj.keepSize === \"boolean\"\n );\n}\n","import { UIAspectConstraint } from \"../Constraints/UIAspectConstraint\";\nimport type { UIConstraint } from \"../Constraints/UIConstraint\";\nimport { UICoverConstraint } from \"../Constraints/UICoverConstraint\";\nimport { UIHeightConstraint } from \"../Constraints/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../Constraints/UIWidthConstraint\";\nimport type {\n UICommonCoverConstraintDescription,\n UICommonDistanceConstraintDescription,\n UICommonProportionalConstraintDescription,\n} from \"./UICommonDoubleElementConstraintDescriptionInterfaces\";\nimport {\n isUICommonCoverConstraintDescription,\n isUICommonDistanceConstraintDescription,\n isUICommonProportionalConstraintDescription,\n} from \"./UICommonDoubleElementConstraintDescriptionInterfaces\";\nimport type {\n UIHeightConstraintDescription,\n UIKeepAspectConstraintDescription,\n UIKeepSizeConstraintDescription,\n UIWidthConstraintDescription,\n} from \"./UICommonSingleElementConstraintDescriptionInterfaces\";\nimport {\n isUIHeightConstraintDescription,\n isUIKeepAspectConstraintDescription,\n isUIKeepSizeConstraintDescription,\n isUIWidthConstraintDescription,\n} from \"./UICommonSingleElementConstraintDescriptionInterfaces\";\n\nexport type UIAnyCommonConstraintDescription =\n | UICommonProportionalConstraintDescription\n | UICommonDistanceConstraintDescription\n | UICommonCoverConstraintDescription\n | UIWidthConstraintDescription\n | UIHeightConstraintDescription\n | UIKeepAspectConstraintDescription\n | UIKeepSizeConstraintDescription;\n\nexport class UIConstraintBuilder {\n public static fromDescription(\n description:\n | Map<string, UIAnyCommonConstraintDescription>\n | Record<string, UIAnyCommonConstraintDescription>,\n ): Record<string, UIConstraint> {\n const entries =\n description instanceof Map\n ? description.entries()\n : Object.entries(description);\n const constraints = new Map<string, UIConstraint>();\n\n for (const [key, value] of entries) {\n if (constraints.has(key)) {\n throw new Error(\n `Duplicate constraint key \"${key}\" - each constraint must have a unique identifier`,\n );\n }\n\n if (isUIWidthConstraintDescription(value)) {\n UIConstraintBuilder.buildWidthConstraint(key, value, constraints);\n } else if (isUIHeightConstraintDescription(value)) {\n UIConstraintBuilder.buildHeightConstraint(key, value, constraints);\n } else if (isUIKeepAspectConstraintDescription(value)) {\n UIConstraintBuilder.buildKeepAspectConstraint(key, value, constraints);\n } else if (isUIKeepSizeConstraintDescription(value)) {\n UIConstraintBuilder.buildKeepSizeConstraint(key, value, constraints);\n } else if (isUICommonDistanceConstraintDescription(value)) {\n UIConstraintBuilder.buildDistanceConstraint(key, value, constraints);\n } else if (isUICommonProportionalConstraintDescription(value)) {\n UIConstraintBuilder.buildProportionalConstraint(\n key,\n value,\n constraints,\n );\n } else if (isUICommonCoverConstraintDescription(value)) {\n UIConstraintBuilder.buildCoverConstraint(key, value, constraints);\n } else {\n throw new Error(\n `Invalid constraint type for \"${key}\". Expected one of: Width, Height, KeepAspect, KeepSize, Distance, Proportional, or Cover constraint`,\n );\n }\n }\n\n return Object.fromEntries(constraints);\n }\n\n private static buildWidthConstraint(\n key: string,\n value: UIWidthConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIWidthConstraint(value.element, {\n width: value.width,\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildHeightConstraint(\n key: string,\n value: UIHeightConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIHeightConstraint(value.element, {\n height: value.height,\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildKeepAspectConstraint(\n key: string,\n value: UIKeepAspectConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UIAspectConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildKeepSizeConstraint(\n key: string,\n value: UIKeepSizeConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n const newKeyWidth = key.replace(/(KeepSize|Keep)$/, \"\") + \"KeepWidth\";\n const newKeyHeight = key.replace(/(KeepSize|Keep)$/, \"\") + \"KeepHeight\";\n constraints.set(\n newKeyWidth,\n new UIWidthConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n constraints.set(\n newKeyHeight,\n new UIHeightConstraint(value.element, {\n power: value.power,\n rule: value.rule,\n orientation: value.orientation,\n }),\n );\n }\n\n private static buildDistanceConstraint(\n key: string,\n value: UICommonDistanceConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n if (typeof value.distance.x === \"number\") {\n const newKey =\n key.replace(/(HorizontalDistance|Distance)$/, \"\") +\n \"HorizontalDistance\";\n constraints.set(\n newKey,\n new UIHorizontalDistanceConstraint(value.elementOne, value.elementTwo, {\n distance: value.distance.x,\n anchorOne: value.anchorOne?.x,\n anchorTwo: value.anchorTwo?.x,\n power: value.power?.x,\n rule: value.rule?.x,\n orientation: value.orientation,\n }),\n );\n }\n\n if (typeof value.distance.y === \"number\") {\n const newKey =\n key.replace(/(VerticalDistance|Distance)$/, \"\") + \"VerticalDistance\";\n constraints.set(\n newKey,\n new UIVerticalDistanceConstraint(value.elementOne, value.elementTwo, {\n distance: value.distance.y,\n anchorOne: value.anchorOne?.y,\n anchorTwo: value.anchorTwo?.y,\n power: value.power?.y,\n rule: value.rule?.y,\n orientation: value.orientation,\n }),\n );\n }\n }\n\n private static buildProportionalConstraint(\n key: string,\n value: UICommonProportionalConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n if (typeof value.proportion.x === \"number\") {\n const newKey =\n key.replace(\n /(HorizontalProportional|HorizontalProportion|Proportional|Proportion)$/,\n \"\",\n ) + \"HorizontalProportion\";\n\n constraints.set(\n newKey,\n new UIHorizontalProportionConstraint(\n value.elementOne,\n value.elementTwo,\n {\n proportion: value.proportion.x,\n power: value.power?.x,\n rule: value.rule?.x,\n orientation: value.orientation,\n },\n ),\n );\n }\n\n if (typeof value.proportion.y === \"number\") {\n const newKey =\n key.replace(\n /(VerticalProportional|VerticalProportion|Proportional|Proportion)$/,\n \"\",\n ) + \"VerticalProportion\";\n constraints.set(\n newKey,\n new UIVerticalProportionConstraint(value.elementOne, value.elementTwo, {\n proportion: value.proportion.y,\n power: value.power?.y,\n rule: value.rule?.y,\n orientation: value.orientation,\n }),\n );\n }\n }\n\n private static buildCoverConstraint(\n key: string,\n value: UICommonCoverConstraintDescription,\n constraints: Map<string, UIConstraint>,\n ): void {\n constraints.set(\n key,\n new UICoverConstraint(value.elementOne, value.elementTwo, {\n isStrict: value.isStrict,\n horizontalAnchor: value.anchor?.x,\n verticalAnchor: value.anchor?.y,\n }),\n );\n }\n}\n","import { Object3D } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { UIElement } from \"./UIElement\";\n\nconst DEFAULT_DUMMY_SIZE = 100;\n\nexport class UIDummy extends UIElement {\n constructor(\n layer: UILayer,\n width = DEFAULT_DUMMY_SIZE,\n height = DEFAULT_DUMMY_SIZE,\n ) {\n super(layer, new Object3D(), 0, 0, width, height);\n this.flushTransform();\n }\n\n public override [renderSymbol](): void {}\n}\n","import type { Texture } from \"three\";\nimport { Color, Matrix3, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\n uvTransform: { value: new Matrix3() },\n },\n ]),\n vertexShader: /* glsl */ `\n uniform mat3 uvTransform;\n varying vec2 vUv;\n void main() {\n vUv = (uvTransform * vec3(uv, 1)).xy;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n });\n }\n\n public getTexture(): Texture {\n return this.uniforms.map.value;\n }\n\n public getColor(): Color {\n return this.uniforms.color.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getUVTransform(): Matrix3 {\n return this.uniforms.uvTransform.value;\n }\n\n public setTexture(value: Texture): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: Color): void {\n this.uniforms.color.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setOpacity(value: number): void {\n this.uniforms.opacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setUVTransform(value: Matrix3): void {\n this.uniforms.uvTransform.value = value;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Color, Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIMaterial } from \"../Passes/UIMaterial\";\nimport { UIElement } from \"./UIElement\";\n\nexport class UIImage extends UIElement {\n private readonly material: UIMaterial;\n private readonly textureInternal: Texture;\n\n constructor(layer: UILayer, texture: Texture) {\n const width = texture.image?.width;\n const height = texture.image?.height;\n\n assertSize(\n width,\n height,\n `Invalid image dimensions - texture \"${texture.name || \"unnamed\"}\" has invalid width (${width}) or height (${height}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.material = material;\n this.textureInternal = texture;\n\n this.flushTransform();\n }\n\n public get texture(): Texture {\n return this.material.getTexture();\n }\n\n public get color(): Color {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: Color) {\n this.material.setColor(value);\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n this.flushTransform();\n this.material.setTexture(\n this.composer.render(renderer, this.textureInternal),\n );\n }\n}\n","import type { Texture } from \"three\";\nimport { ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(backgroundTexture: Texture, foregroundTexture: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n map: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n },\n ]),\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n `,\n fragmentShader: /* glsl */ `\n uniform sampler2D map;\n uniform sampler2D foreground;\n uniform float progress;\n varying vec2 vUv;\n\n void main() {\n vec4 background = texture2D(map, vUv);\n vec4 foreground = texture2D(foreground, vUv);\n gl_FragColor = mix(background, foreground, step(vUv.x, progress));\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n fog: false,\n lights: false,\n });\n }\n}\n","import type { Texture } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIProgressMaterial } from \"../Passes/UIProgressMaterial\";\nimport { UIElement } from \"./UIElement\";\n\nexport class UIProgress extends UIElement {\n private readonly material: UIProgressMaterial;\n private readonly textureBackground: Texture;\n private readonly textureForeground: Texture;\n\n constructor(\n layer: UILayer,\n textureBackground: Texture,\n textureForeground: Texture,\n ) {\n const backgroundWidth = textureBackground.image?.width;\n const backgroundHeight = textureBackground.image?.height;\n\n assertSize(\n backgroundWidth,\n backgroundHeight,\n `Invalid image dimensions - texture \"${textureBackground.name || \"unnamed\"}\" has invalid width (${backgroundWidth}) or height (${backgroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const foregroundWidth = textureForeground.image?.width;\n const foregroundHeight = textureForeground.image?.height;\n\n assertSize(\n foregroundWidth,\n foregroundHeight,\n `Invalid image dimensions - texture \"${textureForeground.name || \"unnamed\"}\" has invalid width (${foregroundWidth}) or height (${foregroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n\n const material = new UIProgressMaterial(\n textureBackground,\n textureForeground,\n );\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, backgroundWidth, backgroundHeight);\n\n this.material = material;\n this.textureBackground = textureBackground;\n this.textureForeground = textureForeground;\n\n this.flushTransform();\n }\n\n public get background(): Texture {\n return this.textureBackground;\n }\n\n public get foreground(): Texture {\n return this.textureForeground;\n }\n\n public get progress(): number {\n return this.material.uniforms.progress.value;\n }\n\n public set progress(value: number) {\n this.material.uniforms.progress.value = value;\n this.material.uniformsNeedUpdate = true;\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](): void {\n this.flushTransform();\n\n // this.material.setTexture(\n // this.composer.render(renderer, this.textureBackground),\n // );\n }\n}\n","import type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextPadding,\n UITextSize,\n UITextStyle,\n} from \"../Elements/UITextInterfaces\";\n\nexport function resolvePadding(\n padding?: Partial<UITextPadding> | number,\n): UITextPadding {\n if (typeof padding === \"number\") {\n return {\n left: padding,\n right: padding,\n top: padding,\n bottom: padding,\n };\n }\n return {\n left: Math.max(padding?.left ?? 0, 0),\n right: Math.max(padding?.right ?? 0, 0),\n top: Math.max(padding?.top ?? 0, 0),\n bottom: Math.max(padding?.bottom ?? 0, 0),\n };\n}\n\nexport function resolveTextStyle(\n currentStyle?: Partial<UITextStyle>,\n baseStyle?: Partial<UITextStyle>,\n): UITextStyle {\n const fontSize = Math.max(\n currentStyle?.fontSize ?? baseStyle?.fontSize ?? 16,\n 1,\n );\n const lineHeight =\n currentStyle?.lineHeight ?? baseStyle?.lineHeight ?? fontSize * 1.2;\n const shadowBlur = Math.max(\n currentStyle?.shadowBlur ?? baseStyle?.shadowBlur ?? 0,\n 0,\n );\n const strokeWidth = Math.max(\n currentStyle?.strokeWidth ?? baseStyle?.strokeWidth ?? 0,\n 0,\n );\n return {\n color: currentStyle?.color ?? baseStyle?.color ?? \"#000000\",\n fontFamily: currentStyle?.fontFamily ?? baseStyle?.fontFamily ?? \"Arial\",\n fontSize,\n fontStyle: currentStyle?.fontStyle ?? baseStyle?.fontStyle ?? \"normal\",\n fontWeight: currentStyle?.fontWeight ?? baseStyle?.fontWeight ?? \"normal\",\n lineHeight,\n\n enableShadow:\n currentStyle?.enableShadow ?? baseStyle?.enableShadow ?? false,\n shadowOffsetX: currentStyle?.shadowOffsetX ?? baseStyle?.shadowOffsetX ?? 0,\n shadowOffsetY: currentStyle?.shadowOffsetY ?? baseStyle?.shadowOffsetY ?? 0,\n shadowBlur,\n shadowColor:\n currentStyle?.shadowColor ?? baseStyle?.shadowColor ?? \"transparent\",\n\n enableStroke:\n currentStyle?.enableStroke ?? baseStyle?.enableStroke ?? false,\n strokeColor:\n currentStyle?.strokeColor ?? baseStyle?.strokeColor ?? \"transparent\",\n strokeWidth,\n };\n}\n\nexport function splitText(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) || [];\n}\n\nexport function measureTextChunk(\n context: CanvasRenderingContext2D,\n chunk: string,\n style: UITextStyle,\n): UIChunkMetrics {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (chunk === \"\\n\") {\n return {\n width: Math.ceil(0),\n height: style.lineHeight,\n baseline: 0,\n lineHeight: style.lineHeight,\n };\n }\n\n const metrics = context.measureText(chunk);\n const width = metrics.width;\n\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width: Math.ceil(width),\n height: height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: style.lineHeight,\n };\n}\n\nexport function wrapTextLines(\n maxWidth: number,\n chunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const chunk of chunks) {\n if (chunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentWidth + chunk.metrics.width <= maxWidth ||\n currentLine.length === 0\n ) {\n currentLine.push(chunk);\n currentWidth += chunk.metrics.width;\n currentHeight = Math.max(currentHeight, chunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, chunk.metrics.baseline);\n currentLineHeight = Math.max(currentLineHeight, chunk.metrics.lineHeight);\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [chunk];\n currentWidth = chunk.metrics.width;\n currentHeight = chunk.metrics.height;\n currentBaseline = chunk.metrics.baseline;\n currentLineHeight = chunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\nexport function calculateTextBlockSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (i === 0) {\n totalHeight += line.height;\n } else {\n totalHeight += line.lineHeight;\n }\n\n if (i === lines.length - 1) {\n totalHeight += line.baseline;\n }\n }\n\n return {\n width: maxLineWidth,\n height: totalHeight,\n };\n}\n\nexport function renderText(\n x: number,\n y: number,\n text: string,\n style: UITextStyle,\n context: CanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeWidth;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: CanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n let currentX = paddingLeft;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderText(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { Color, WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport {\n heightSymbol,\n renderSymbol,\n suggestVariableSymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n calculateTextBlockSize,\n measureTextChunk,\n renderTextLines,\n resolvePadding,\n resolveTextStyle,\n splitText,\n wrapTextLines,\n} from \"../Miscellaneous/textTools\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIMaterial } from \"../Passes/UIMaterial\";\nimport { UIElement } from \"./UIElement\";\nimport type {\n UITextChunk,\n UITextPadding,\n UITextSize,\n UITextSpan,\n UITextStyle,\n} from \"./UITextInterfaces\";\nexport interface UITextOptions {\n maxWidth: number;\n padding: Partial<UITextPadding>;\n defaultStyle: Partial<UITextStyle>;\n}\n\nconst DEFAULT_LINE_SIZE = 1024;\n\nexport class UIText extends UIElement {\n private readonly material: UIMaterial;\n private readonly texture: CanvasTexture;\n\n private readonly canvas: HTMLCanvasElement;\n private readonly context: CanvasRenderingContext2D;\n\n private readonly textBlockSize: UITextSize;\n private readonly padding: UITextPadding;\n private lastSuggestedAspect = 0;\n\n constructor(\n layer: UILayer,\n spans: (UITextSpan | string)[],\n parameters: Partial<UITextOptions> = {},\n ) {\n const canvas = document.createElement(\"canvas\");\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"Failed to create canvas context\");\n }\n\n const chunks: UITextChunk[] = [];\n\n for (const span of spans) {\n const isSpanString = typeof span === \"string\";\n const spanText = isSpanString ? span : span.text;\n const style = resolveTextStyle(\n isSpanString ? undefined : span.style,\n parameters.defaultStyle,\n );\n\n for (const text of splitText(spanText)) {\n const metrics = measureTextChunk(context, text, style);\n chunks.push({ text, style, metrics });\n }\n }\n\n const wrappedLines = wrapTextLines(\n parameters.maxWidth ?? DEFAULT_LINE_SIZE,\n chunks,\n );\n const textBlockSize = calculateTextBlockSize(wrappedLines);\n\n const padding = resolvePadding(parameters.padding);\n\n canvas.width = textBlockSize.width + padding.left + padding.right;\n canvas.height = textBlockSize.height + padding.top + padding.bottom;\n\n const texture = new CanvasTexture(canvas);\n\n const material = new UIMaterial(texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, textBlockSize.width, textBlockSize.height);\n\n this.material = material;\n this.texture = texture;\n\n this.canvas = canvas;\n this.context = context;\n\n this.textBlockSize = textBlockSize;\n this.padding = padding;\n\n renderTextLines(\n this.padding.top,\n this.padding.left,\n wrappedLines,\n this.context,\n );\n\n this.texture.needsUpdate = true;\n this.flushTransform();\n }\n\n public get color(): Color {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: Color) {\n this.material.setColor(value);\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n }\n\n public override destroy(): void {\n this.material.dispose();\n this.texture.dispose();\n this.canvas.remove();\n super.destroy();\n }\n\n public override flushTransform(): void {\n super.flushTransform();\n\n const currentAspect = this.width / this.height;\n if (this.lastSuggestedAspect !== currentAspect) {\n this.lastSuggestedAspect = currentAspect;\n\n const targetAspect =\n (this.textBlockSize.width + this.padding.left + this.padding.right) /\n (this.textBlockSize.height + this.padding.top + this.padding.bottom);\n\n this.layer[suggestVariableSymbol](\n this,\n this[heightSymbol],\n this.width / targetAspect,\n );\n }\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n this.flushTransform();\n this.material.setTexture(this.composer.render(renderer, this.texture));\n }\n}\n","import { Texture } from \"three\";\nimport type { UITextSpan, UITextStyle } from \"../Elements/UITextInterfaces\";\nimport { isUITextSpan } from \"../Elements/UITextInterfaces\";\n\nexport interface UIImageDescription {\n texture: Texture;\n}\n\nexport interface UIProgressDescription {\n background: Texture;\n foreground: Texture;\n}\n\nexport interface UITextDescription {\n text: string;\n style?: Partial<UITextStyle>;\n}\n\nexport interface UITextEnancedDescription {\n spans: (UITextSpan | string)[];\n defaultStyle?: Partial<UITextStyle>;\n}\n\nexport interface UIDummyDescription {\n width?: number;\n height?: number;\n}\n\nexport type UIAnyElementDescription =\n | UIImageDescription\n | UIProgressDescription\n | UITextDescription\n | UITextEnancedDescription\n | UIDummyDescription;\n\nexport function isUIImageDescription(obj: unknown): obj is UIImageDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"texture\" in obj &&\n obj.texture instanceof Texture\n );\n}\n\nexport function isUIProgressDescription(\n obj: unknown,\n): obj is UIProgressDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"background\" in obj &&\n obj.background instanceof Texture &&\n \"foreground\" in obj &&\n obj.foreground instanceof Texture\n );\n}\n\nexport function isUITextDescription(obj: unknown): obj is UITextDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"text\" in obj &&\n typeof obj.text === \"string\"\n );\n}\n\nexport function isUITextEnhancedDescription(\n obj: unknown,\n): obj is UITextEnancedDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"spans\" in obj &&\n Array.isArray(obj.spans) &&\n obj.spans.every((span) => typeof span === \"string\" || isUITextSpan(span))\n );\n}\n\nexport function isUIDummyDescription(obj: unknown): obj is UIDummyDescription {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n (!(\"width\" in obj) || typeof obj.width === \"number\") &&\n (!(\"height\" in obj) || typeof obj.height === \"number\")\n );\n}\n","export interface UITextStyle {\n color: string;\n\n fontFamily: string;\n fontSize: number;\n fontStyle: \"normal\" | \"italic\" | \"oblique\";\n fontWeight: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number;\n lineHeight: number;\n\n enableShadow: boolean;\n shadowOffsetX: number;\n shadowOffsetY: number;\n shadowBlur: number;\n shadowColor: string;\n\n enableStroke: boolean;\n strokeColor: string;\n strokeWidth: number;\n}\n\nexport interface UITextPadding {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\nexport interface UITextSize {\n width: number;\n height: number;\n}\n\nexport interface UIChunkMetrics {\n width: number;\n height: number;\n baseline: number;\n lineHeight: number;\n}\n\nexport interface UITextChunk {\n text: string;\n style: UITextStyle;\n metrics: UIChunkMetrics;\n}\n\nexport interface UITextLine {\n chunks: UITextChunk[];\n width: number;\n height: number;\n baseline: number;\n lineHeight: number;\n}\n\nexport interface UITextSpan {\n text: string;\n style?: Partial<UITextStyle>;\n}\n\nexport function isUITextSpan(obj?: unknown): obj is UITextSpan {\n return (\n obj !== null &&\n typeof obj === \"object\" &&\n \"text\" in obj &&\n typeof obj.text === \"string\"\n );\n}\n","import { Texture } from \"three\";\nimport { UIDummy } from \"../Elements/UIDummy\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport { UIImage } from \"../Elements/UIImage\";\nimport { UIProgress } from \"../Elements/UIProgress\";\nimport { UIText } from \"../Elements/UIText\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIAnyElementDescription } from \"./UIElementBuilderInterfaces\";\nimport {\n isUIDummyDescription,\n isUIImageDescription,\n isUIProgressDescription,\n isUITextDescription,\n isUITextEnhancedDescription,\n} from \"./UIElementBuilderInterfaces\";\n\nexport class UIElementBuilder {\n public static fromDescription(\n layer: UILayer,\n description:\n | Map<string, UIAnyElementDescription | Texture | String>\n | Record<string, UIAnyElementDescription | Texture | String>,\n ): Record<string, UIElement> {\n const entries =\n description instanceof Map\n ? description.entries()\n : Object.entries(description);\n const elements = new Map<string, UIElement>();\n\n for (const [key, value] of entries) {\n if (elements.has(key)) {\n throw new Error(\n `Duplicate element key \"${key}\" - each UI element must have a unique identifier`,\n );\n }\n let element: UIElement;\n\n if (value instanceof Texture) {\n element = new UIImage(layer, value);\n } else if (isUIImageDescription(value)) {\n element = new UIImage(layer, value.texture);\n } else if (typeof value === \"string\") {\n element = new UIText(layer, [value]);\n } else if (isUIProgressDescription(value)) {\n element = new UIProgress(layer, value.background, value.foreground);\n } else if (isUITextDescription(value)) {\n element = new UIText(layer, [value.text], {\n defaultStyle: value.style,\n });\n } else if (isUITextEnhancedDescription(value)) {\n element = new UIText(layer, value.spans, {\n defaultStyle: value.defaultStyle,\n });\n } else if (isUIDummyDescription(value)) {\n element = new UIDummy(layer, value.width, value.height);\n } else {\n throw new Error(\n `Invalid UI element type for \"${key}\". Expected one of: Texture, UIImage, String, UITextDescription, or UITextEnhancedDescription`,\n );\n }\n\n elements.set(key, element);\n }\n\n return Object.fromEntries(elements);\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIDummy } from \"../Elements/UIDummy\";\nimport type { UIElement } from \"../Elements/UIElement\";\n\nexport interface UIStackConstraintBuilderOptions {\n offset: number;\n elements: UIElement[];\n power?: UIConstraintPower;\n createDummy?: boolean;\n keepAlignment?: boolean;\n}\n\nexport interface UIStackConstraintBuilderHorizontalResult {\n dummy?: UIDummy;\n distanceConstraints: UIHorizontalDistanceConstraint[];\n proportionConstraints: UIHorizontalProportionConstraint[];\n centerConstraints: UIVerticalDistanceConstraint[];\n}\n\nexport interface UIStackConstraintBuilderVerticalResult {\n dummy?: UIDummy;\n distanceConstraints: UIVerticalDistanceConstraint[];\n proportionConstraints: UIVerticalProportionConstraint[];\n centerConstraints: UIHorizontalDistanceConstraint[];\n}\n\nexport class UIStackConstraintBuilder {\n public static buildHorizontal(\n options: UIStackConstraintBuilderOptions,\n ): UIStackConstraintBuilderHorizontalResult {\n const distanceConstraints = [];\n const proportionConstraints = [];\n const centerConstraints = [];\n\n for (let i = 0; i < options.elements.length - 1; i++) {\n const element = options.elements[i];\n const nextElement = options.elements[i + 1];\n\n distanceConstraints.push(\n new UIHorizontalDistanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.offset,\n power: options.power,\n }),\n );\n\n proportionConstraints.push(\n new UIHorizontalProportionConstraint(element, nextElement, {\n power: options.power,\n }),\n );\n\n if (options.keepAlignment !== false) {\n centerConstraints.push(\n new UIVerticalDistanceConstraint(element, nextElement, {\n power: options.power,\n anchorOne: 0,\n anchorTwo: 0,\n }),\n );\n }\n }\n\n return {\n dummy:\n options.createDummy !== false\n ? UIStackConstraintBuilder.createDummy(\n options.elements[0],\n options.elements[options.elements.length - 1],\n )\n : undefined,\n distanceConstraints,\n proportionConstraints,\n centerConstraints,\n };\n }\n\n public static buildVertical(\n options: UIStackConstraintBuilderOptions,\n ): UIStackConstraintBuilderVerticalResult {\n const distanceConstraints = [];\n const proportionConstraints = [];\n const centerConstraints = [];\n\n for (let i = 0; i < options.elements.length - 1; i++) {\n const element = options.elements[i];\n const nextElement = options.elements[i + 1];\n\n distanceConstraints.push(\n new UIVerticalDistanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.offset,\n power: options.power,\n }),\n );\n\n proportionConstraints.push(\n new UIVerticalProportionConstraint(element, nextElement, {\n power: options.power,\n }),\n );\n\n if (options.keepAlignment !== false) {\n centerConstraints.push(\n new UIHorizontalDistanceConstraint(element, nextElement, {\n power: options.power,\n }),\n );\n }\n }\n\n return {\n dummy:\n options.createDummy !== false\n ? UIStackConstraintBuilder.createDummy(\n options.elements[0],\n options.elements[options.elements.length - 1],\n )\n : undefined,\n distanceConstraints,\n proportionConstraints,\n centerConstraints,\n };\n }\n\n private static createDummy(\n firstElement: UIElement,\n lastElement: UIElement,\n ): UIDummy {\n const dummy = new UIDummy(lastElement.layer);\n\n new UIHorizontalDistanceConstraint(dummy, firstElement, {\n distance: 0,\n anchorOne: 0,\n anchorTwo: 0,\n });\n\n new UIVerticalDistanceConstraint(dummy, firstElement, {\n distance: 0,\n anchorOne: 0,\n anchorTwo: 0,\n });\n\n new UIHorizontalDistanceConstraint(dummy, lastElement, {\n distance: 0,\n anchorOne: 1,\n anchorTwo: 1,\n });\n\n new UIVerticalDistanceConstraint(dummy, lastElement, {\n distance: 0,\n anchorOne: 1,\n anchorTwo: 1,\n });\n\n return dummy;\n }\n}\n","import { Constraint, Expression, Operator, Strength } from \"kiwi.js\";\nimport { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { assertSameLayer } from \"../Miscellaneous/asserts\";\nimport {\n addConstraintSymbol,\n disableConstraintSymbol,\n enableConstraintSymbol,\n heightSymbol,\n removeConstraintSymbol,\n widthSymbol,\n xSymbol,\n ySymbol,\n} from \"../Miscellaneous/symbols\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../Miscellaneous/UIOrientation\";\nimport { UIConstraint } from \"./UIConstraint\";\n\nconst DEFAULT_ANCHOR = 0.5;\n\nexport interface UIFitOptions {\n isStrict: boolean;\n horizontalAnchor: number;\n verticalAnchor: number;\n orientation: UIOrientation;\n}\n\nexport class UIFitConstraint extends UIConstraint {\n private readonly parameters: UIFitOptions;\n\n private constraintX?: Constraint;\n private constraintY?: Constraint;\n\n private constraintW?: Constraint;\n private constraintH?: Constraint;\n\n private constraintStrict?: Constraint;\n\n constructor(\n private readonly elementOne: UIElement | UILayer,\n private readonly elementTwo: UIElement,\n parameters?: Partial<UIFitOptions>,\n ) {\n super(\n elementTwo.layer,\n new Set(\n elementOne instanceof UIElement\n ? [elementOne, elementTwo]\n : [elementTwo],\n ),\n );\n assertSameLayer(elementOne, elementTwo);\n\n this.parameters = {\n isStrict: parameters?.isStrict ?? true,\n horizontalAnchor: parameters?.horizontalAnchor ?? DEFAULT_ANCHOR,\n verticalAnchor: parameters?.verticalAnchor ?? DEFAULT_ANCHOR,\n orientation: resolveOrientation(parameters?.orientation),\n };\n\n if (\n this.parameters.orientation === UIOrientation.ALWAYS ||\n this.parameters.orientation === this.layer.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n public override destroy(): void {\n this.destroyConstraints();\n super.destroy();\n }\n\n public [disableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.parameters.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.parameters.orientation !== UIOrientation.ALWAYS &&\n orientation === this.parameters.orientation\n ) {\n this.buildConstraints();\n }\n }\n\n protected buildConstraints(): void {\n this.constraintX = new Constraint(\n new Expression(this.elementOne[xSymbol]).plus(\n new Expression(this.elementOne[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[xSymbol]).plus(\n new Expression(this.elementTwo[widthSymbol]).multiply(\n this.parameters.horizontalAnchor,\n ),\n ),\n );\n\n this.constraintY = new Constraint(\n new Expression(this.elementOne[ySymbol]).plus(\n new Expression(this.elementOne[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n Operator.Eq,\n new Expression(this.elementTwo[ySymbol]).plus(\n new Expression(this.elementTwo[heightSymbol]).multiply(\n this.parameters.verticalAnchor,\n ),\n ),\n );\n\n this.constraintW = new Constraint(\n new Expression(this.elementOne[widthSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[widthSymbol]),\n );\n\n this.constraintH = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Ge,\n new Expression(this.elementTwo[heightSymbol]),\n );\n\n this.layer[addConstraintSymbol](this, this.constraintX);\n this.layer[addConstraintSymbol](this, this.constraintY);\n\n this.layer[addConstraintSymbol](this, this.constraintW);\n this.layer[addConstraintSymbol](this, this.constraintH);\n\n if (this.parameters.isStrict !== false) {\n this.constraintStrict = new Constraint(\n new Expression(this.elementOne[heightSymbol]),\n Operator.Eq,\n new Expression(this.elementTwo[heightSymbol]),\n Strength.strong,\n );\n\n this.layer[addConstraintSymbol](this, this.constraintStrict);\n }\n }\n\n protected destroyConstraints(): void {\n if (this.constraintX) {\n this.layer[removeConstraintSymbol](this, this.constraintX);\n this.constraintX = undefined;\n }\n if (this.constraintY) {\n this.layer[removeConstraintSymbol](this, this.constraintY);\n this.constraintY = undefined;\n }\n if (this.constraintW) {\n this.layer[removeConstraintSymbol](this, this.constraintW);\n this.constraintW = undefined;\n }\n if (this.constraintH) {\n this.layer[removeConstraintSymbol](this, this.constraintH);\n this.constraintH = undefined;\n }\n if (this.constraintStrict) {\n this.layer[removeConstraintSymbol](this, this.constraintStrict);\n this.constraintStrict = undefined;\n }\n }\n}\n","import { UIBehavior } from \"../Miscellaneous/UIBehavior\";\nimport { UILayer } from \"./UILayer\";\n\nconst DEFAULT_SCREEN_HEIGHT = 1920;\n\nexport class UIFullScreenLayer extends UILayer {\n private targetScreenHeight?: number = DEFAULT_SCREEN_HEIGHT;\n\n constructor() {\n super();\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"click\", this.onClick);\n this.onResize();\n }\n\n public get tergetScreenHeight(): number | undefined {\n return this.targetScreenHeight;\n }\n\n public set tergetScreenHeight(value: number | undefined) {\n this.targetScreenHeight = value;\n this.resizeInternal(window.innerWidth, window.innerHeight);\n }\n\n public override destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"click\", this.onClick);\n super.destroy();\n }\n\n private calculateScale(): number {\n const targetHeight = this.tergetScreenHeight ?? window.innerHeight;\n return targetHeight / window.innerHeight;\n }\n\n private readonly onResize = (): void => {\n const scale = this.calculateScale();\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onClick = (event: MouseEvent): void => {\n if (this.behavior !== UIBehavior.INTERACTIVE) {\n return;\n }\n\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n const offsetX = rect ? event.clientX - rect.left : event.clientX;\n const offsetY = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.calculateScale();\n this.clickInternal(offsetX * scale, offsetY * scale);\n };\n}\n","import { UILayer } from \"./UILayer\";\n\nexport class UIManualLayer extends UILayer {\n public click(x: number, y: number): void {\n this.clickInternal(x, y);\n }\n\n public resize(width: number, height: number): void {\n this.resizeInternal(width, height);\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\n\nexport interface UIPassRenderOptions {\n width: number;\n height: number;\n padding: number;\n}\n\nexport abstract class UIPass {\n public abstract get padding(): number;\n public abstract get needsUpdate(): boolean;\n public abstract render(\n renderer: WebGLRenderer,\n texture: Texture,\n parameters: UIPassRenderOptions,\n ): void;\n}\n"],"names":["createMap","IndexedMap","this","index","array","prototype","size","length","empty","itemAt","contains","key","undefined","id","find","i","setDefault","factory","pair","Pair","push","insert","value","erase","last","pop","first","copy","second","Variable","name","_value","_context","_id","VarId","_name","setName","context","setContext","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","parsed","parseArgs","arguments","_terms","terms","_constant","constant","result","n","isConstant","map","join","args","item","j","k","terms2","termPair","Array","Error","value2","Operator","Strength","create","a","b","c","w","Math","max","min","clip","required","strong","medium","weak","SymbolType","Constraint","expression","operator","rhs","strength","CnId","_operator","_strength","_expression","op","Solver","_cnMap","_rowMap","_varMap","_editMap","_infeasibleRows","_objective","Row","_artificial","_idTick","createConstraint","lhs","cn","addConstraint","constraint","data","_createRow","row","tag","subject","_chooseSubject","type","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_optimize","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","addEditVariable","variable","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_dualOptimize","other","rowPair_1","coeff","coefficientFor","External","updateVariables","vars","_getVarSymbol","_this","_makeSymbol","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","r","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_type","_cellMap","theCopy","xSymbol","ySymbol","widthSymbol","heightSymbol","addUIElementSymbol","removeUIElementSymbol","addUIConstraintSymbol","removeUIConstraintSymbol","addConstraintSymbol","removeConstraintSymbol","addVariableSymbol","removeVariableSymbol","suggestVariableSymbol","disableConstraintSymbol","enableConstraintSymbol","needsRecalculation","renderSymbol","clickSymbol","UIOrientation","UIConstraintPower","UIConstraintRule","isUIOrientation","obj","Object","values","some","v","resolveOrientation","orientation","ALWAYS","UIConstraint","constructor","layer","elements","destroy","isUIConstraintPower","resolvePower","power","P0","convertPowerToStrength","P1","P2","P3","P4","P5","P6","P7","isUIConstraintRule","resolveRule","rule","EQUAL","convertRuleToOperator","LESS","GREATER","UIHeightConstraint","element","parameters","super","Set","height","_a","buildConstraints","destroyConstraints","Eventail","listeners","Map","on","callback","priority","addListener","once","off","current","get","delete","filtered","filter","l","set","emit","listener","apply","list","event","splice","tempVector2","Vector2","tempBox2","Box2","UIBehavior","DEFAULT_ANCHOR","UIMicroTransformations","positionXInternal","positionYInternal","anchorXInternal","anchorYInternal","scaleXInternal","scaleYInternal","rotationInternal","x","y","anchorX","anchorY","scaleX","scaleY","angle","MathUtils","radToDeg","rotation","degToRad","reset","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","materialInternal","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","material","render","renderer","left","right","bottom","top","updateProjectionMatrix","UIDrawPass","screen","ShaderMaterial","uniforms","UniformsUtils","merge","opacity","color","Color","uvTransform","Matrix3","vertexShader","fragmentShader","transparent","fog","lights","dispose","setPadding","width","padding","texture","uniformsNeedUpdate","UIComposer","passes","drawPass","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","calculatePadding","reduce","p","every","needsUpdate","image","widthWithPadding","heightWithPadding","setSize","setClearColor","setRenderTarget","clearColor","reverseTargets","pass","UIElementEvent","UIElement","object","micro","_b","_c","_d","_e","behaviorInternal","VISIBLE","composer","zIndex","position","z","behavior","visible","HIDDEN","INTERACTIVE","flushTransform","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","realX","realY","realWidth","realHeight","centerX","centerY","localX","localY","cos","sin","scale","applyMicroTransformations","UILayer","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","dependencies","remove","owner","suggestedValue","description","originalRenderTarget","getRenderTarget","originalClearColor","getClearColor","originalClearAlpha","getClearAlpha","setClearAlpha","clickInternal","e","sort","resizeInternal","applyCameraSize","rebuildLayerConstraints","updateOrientation","near","far","constraintX","constraintY","_f","constraintW","_g","constraintH","_h","_j","_k","_l","_m","lastOrientation","LANDSCAPE","descriptions","entries","dependency","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraint2DBuilder","options","proportional","UIAspectConstraint","aspect","newOrientation","UICoverConstraint","isStrict","horizontalAnchor","verticalAnchor","constraintStrict","isAtLeastOneNumber","isAtLeastOnePower","isAtLeastOneRule","isUICommonDoubleElementConstraintDescription","isUICommonDistanceConstraintDescription","isUICommonProportionalConstraintDescription","isUICommonCoverConstraintDescription","anchor","isUICommonSingleElementConstraintDescription","isUIHeightConstraintDescription","isUIKeepAspectConstraintDescription","keepAspect","isUIKeepSizeConstraintDescription","keepSize","UIConstraintBuilder","fromDescription","buildWidthConstraint","buildHeightConstraint","buildKeepAspectConstraint","buildKeepSizeConstraint","buildDistanceConstraint","buildProportionalConstraint","buildCoverConstraint","fromEntries","newKeyWidth","replace","newKeyHeight","newKey","UIDummy","Object3D","UIMaterial","getTexture","getColor","getOpacity","getUVTransform","setTexture","setColor","setOpacity","setUVTransform","UIImage","textureInternal","UIProgressMaterial","backgroundTexture","foregroundTexture","foreground","progress","UIProgress","textureBackground","textureForeground","backgroundWidth","backgroundHeight","foregroundWidth","foregroundHeight","background","resolveTextStyle","currentStyle","baseStyle","fontSize","lineHeight","shadowBlur","strokeWidth","fontFamily","fontStyle","_p","_o","fontWeight","_r","_q","enableShadow","_t","_s","shadowOffsetX","_v","_u","shadowOffsetY","_x","_w","shadowColor","_z","_y","enableStroke","_1","_0","strokeColor","_3","_2","splitText","text","match","measureTextChunk","chunk","style","font","baseline","metrics","measureText","ceil","actualBoundingBoxAscent","actualBoundingBoxDescent","renderText","strokeStyle","lineWidth","strokeText","fillStyle","fillText","UIText","spans","canvas","document","createElement","getContext","chunks","span","isSpanString","spanText","defaultStyle","wrappedLines","maxWidth","lines","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","wrapTextLines","textBlockSize","maxLineWidth","line","totalHeight","calculateTextBlockSize","resolvePadding","CanvasTexture","lastSuggestedAspect","paddingTop","paddingLeft","currentY","currentX","renderTextLines","currentAspect","isUIProgressDescription","Texture","isUITextDescription","isUITextEnhancedDescription","isArray","isUITextSpan","isUIDummyDescription","UIElementBuilder","UIStackConstraintBuilder","buildHorizontal","distanceConstraints","proportionConstraints","centerConstraints","nextElement","offset","keepAlignment","createDummy","buildVertical","firstElement","lastElement","UIFitConstraint","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIManualLayer","click","resize","UIPass"],"mappings":"qTAOO,SAASA,IACZ,OAAO,IAAIC,CACf,CACA,IAAIA,EAA4B,WAC5B,SAASA,IACLC,KAAKC,MAAQ,CAAE,EACfD,KAAKE,MAAQ,EACrB,CA8GI,OA1GAH,EAAWI,UAAUC,KAAO,WACxB,OAAOJ,KAAKE,MAAMG,MACrB,EAIDN,EAAWI,UAAUG,MAAQ,WACzB,OAA6B,IAAtBN,KAAKE,MAAMG,MACrB,EAMDN,EAAWI,UAAUI,OAAS,SAAUN,GACpC,OAAOD,KAAKE,MAAMD,EACrB,EAMDF,EAAWI,UAAUK,SAAW,SAAUC,GACtC,YAAgCC,IAAzBV,KAAKC,MAAMQ,EAAIE,KACzB,EAMDZ,EAAWI,UAAUS,KAAO,SAAUH,GAClC,IAAII,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,YAAaD,IAANG,OAAkBH,EAAYV,KAAKE,MAAMW,EACnD,EAUDd,EAAWI,UAAUW,WAAa,SAAUL,EAAKM,GAC7C,IAAIF,EAAIb,KAAKC,MAAMQ,EAAIE,MACvB,QAAUD,I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