laymur 0.1.40 → 0.1.42
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/Constraints/UIConstraint.d.ts +0 -2
- package/dist/Elements/UIDummy.d.ts +1 -2
- package/dist/Elements/UIElement.d.ts +16 -14
- package/dist/Elements/UIImage.d.ts +1 -2
- package/dist/Elements/UIProgress.d.ts +3 -3
- package/dist/Elements/UIScene.d.ts +1 -2
- package/dist/Elements/UIText.d.ts +3 -4
- package/dist/Layers/UILayer.d.ts +3 -3
- package/dist/Miscellaneous/UIBehavior.d.ts +1 -1
- package/dist/Miscellaneous/{UIMicroTransformations.d.ts → UIMicro.d.ts} +13 -11
- package/dist/Miscellaneous/microTransformationTools.d.ts +2 -2
- package/dist/Passes/UIComposer.d.ts +10 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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/microTransformationTools.ts","../src/Miscellaneous/UIBehavior.ts","../src/Miscellaneous/UIMicroTransformations.ts","../src/Materials/UIMaterial.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Layers/UILayer.ts","../src/Builders/UIConstraintContainerBuilder.ts","../src/Elements/UIScene.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/Builders/UIConstraintStackBuilder.ts","../src/Elements/UIDummy.ts","../src/Elements/UIImage.ts","../src/Materials/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/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 UIHeightOptions {\n height: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHeightConstraint extends UIConstraint {\n private readonly options: UIHeightOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIHeightOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n height: options?.height ?? element.height,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.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.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.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.options.rule),\n this.options.height,\n convertPowerToStrength(this.options.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","import { Matrix3, Vector3, type Object3D } from \"three\";\nimport type { UIMicroTransformations } from \"./UIMicroTransformations\";\n\nconst tempMatrixA = new Matrix3();\nconst tempMatrixB = new Matrix3();\nconst tempMatrixC = new Matrix3();\nconst tempMatrixD = new Matrix3();\nconst tempMatrixE = new Matrix3();\nconst tempVectorA = new Vector3();\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 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 const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n const translateToCenter = tempMatrixA.set(\n 1,\n 0,\n -centerX,\n 0,\n 1,\n -centerY,\n 0,\n 0,\n 1,\n );\n\n const scale = tempMatrixB.set(\n micro.scaleX,\n 0,\n 0,\n 0,\n micro.scaleY,\n 0,\n 0,\n 0,\n 1,\n );\n\n const rotation = tempMatrixC.set(\n Math.cos(micro.rotation),\n -Math.sin(micro.rotation),\n 0,\n Math.sin(micro.rotation),\n Math.cos(micro.rotation),\n 0,\n 0,\n 0,\n 1,\n );\n\n const translateFinal = tempMatrixD.set(\n 1,\n 0,\n micro.x + centerX,\n 0,\n 1,\n micro.y + centerY,\n 0,\n 0,\n 1,\n );\n\n const finalMatrix = tempMatrixE\n .multiplyMatrices(translateFinal, rotation)\n .multiply(scale)\n .multiply(translateToCenter);\n\n const point = tempVectorA.set(realX, realY, 1).applyMatrix3(finalMatrix);\n\n object.position.x = point.x;\n object.position.y = point.y;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","export enum UIBehavior {\n HIDDEN,\n VISIBLE,\n INTERACTIVE,\n}\n","import { MathUtils } from \"three\";\nimport type { UIElement } from \"../Elements/UIElement\";\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 constructor(private readonly owner: UIElement) {}\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 setAnchorByGlobalPosition(x: number, y: number): void {\n const deltaX = x - this.owner.x;\n const deltaY = y - this.owner.y;\n this.anchorXInternal = deltaX / this.owner.width;\n this.anchorYInternal = deltaY / this.owner.height;\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 type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map?: Texture) {\n super({\n uniforms: {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\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 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 lights: false,\n fog: false,\n });\n }\n\n public getTexture(): Texture | undefined {\n return this.uniforms.map.value;\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public setTexture(value: Texture | undefined): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(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","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 { Material, 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 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 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 render(renderer: WebGLRenderer, material: Material): void {\n mesh.material = material;\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 { Material, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n NoBlending,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\nimport type { UIPass } from \"./UIPass\";\n\nexport class UIComposer {\n public readonly passes: UIPass[] = [];\n\n private fromRenderTarget: WebGLRenderTarget;\n private toRenderTarget: WebGLRenderTarget;\n\n private readonly defaultMaterial = new UIMaterial();\n private readonly screen = new UIFullScreenQuad();\n\n private needsUpdateInternal = false;\n private lastPaddingHasChangedInternal = false;\n private lastPaddingInternal = 0;\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 this.fromRenderTarget.texture.generateMipmaps = false;\n this.toRenderTarget.texture.generateMipmaps = false;\n }\n\n public get needsUpdate(): boolean {\n return (\n (this.needsUpdateInternal && this.hasValuablePasses()) ||\n this.hasPassesNeedingUpdate()\n );\n }\n\n public get lastPaddingHasChanged(): boolean {\n return this.lastPaddingHasChangedInternal;\n }\n\n public get lastPadding(): number {\n return this.lastPaddingInternal;\n }\n\n public requestUpdate(): void {\n this.needsUpdateInternal = true;\n }\n\n public compose(\n renderer: WebGLRenderer,\n width: number,\n height: number,\n material: Material,\n canOverrideBlending = true,\n ): Material {\n const hasValuablePasses = this.hasValuablePasses();\n if (\n (!this.needsUpdateInternal || !hasValuablePasses) &&\n !this.hasPassesNeedingUpdate()\n ) {\n if (!hasValuablePasses) {\n this.lastPaddingHasChangedInternal = this.lastPaddingInternal !== 0;\n this.lastPaddingInternal = 0;\n }\n this.needsUpdateInternal = false;\n return hasValuablePasses ? this.defaultMaterial : material;\n }\n\n const padding = this.calculatePadding();\n this.lastPaddingHasChangedInternal = this.lastPaddingInternal !== padding;\n this.lastPaddingInternal = padding;\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.setScreenPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n\n const originalBlending = material.blending;\n if (canOverrideBlending) {\n material.blending = NoBlending;\n }\n this.screen.render(renderer, material);\n material.blending = originalBlending;\n\n const options = { width, height, padding };\n\n for (let i = 0; i < this.passes.length; i++) {\n const pass = this.passes[i];\n if (pass.needsUpdate || pass.isValuable) {\n this.reverseRenderTargets();\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n this.passes[i].render(renderer, this.fromRenderTarget.texture, options);\n }\n }\n\n this.needsUpdateInternal = false;\n this.defaultMaterial.setTexture(this.toRenderTarget.texture);\n return this.defaultMaterial;\n }\n\n public destroy(): void {\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n private hasValuablePasses(): boolean {\n return this.passes.some((p) => p.isValuable);\n }\n\n private hasPassesNeedingUpdate(): boolean {\n return this.passes.some((p) => p.needsUpdate);\n }\n\n private calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n private setScreenPadding(\n width: number,\n height: number,\n padding: number,\n ): void {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n\n private reverseRenderTargets(): 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: 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 protected lastPadding = 0;\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.micro = new UIMicroTransformations(this);\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 (\n this[needsRecalculation] ||\n this.micro[needsRecalculation] ||\n this.composer.lastPaddingHasChanged\n ) {\n applyMicroTransformations(\n this.object,\n this.micro,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composer.lastPadding,\n );\n\n this[needsRecalculation] = false;\n this.micro[needsRecalculation] = false;\n }\n }\n\n protected abstract [renderSymbol](renderer: WebGLRenderer): void;\n}\n","import { Eventail } from \"eventail\";\nimport {\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;\nconst DEFAULT_Z_INDEX = 500;\nconst clearColor = 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 enum UILayerEvent {\n ORIENTATION_CHANGED = \"orientationChanged\",\n}\n\nexport abstract class UILayer extends Eventail {\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 object.position.z = DEFAULT_Z_INDEX;\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(clearColor);\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[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 this.emit(UILayerEvent.ORIENTATION_CHANGED, this, this.orientation);\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport enum UIConstraintContainerDirection {\n FROM_LEFT_TOP,\n FROM_LEFT_BOTTOM,\n}\n\nexport interface UIConstraintContainerBuilderOptions {\n direction: UIConstraintContainerDirection;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport class UIConstraintContainerBuilder {\n public static build(\n container: UIElement,\n elementOne: UIElement,\n elementTwo: UIElement,\n options: Partial<UIConstraintContainerBuilderOptions> = {},\n ): {\n horizontalDistances: UIHorizontalDistanceConstraint[];\n verticalDistances: UIVerticalDistanceConstraint[];\n } {\n const direction =\n options.direction ?? UIConstraintContainerDirection.FROM_LEFT_TOP;\n\n const horizontalDistances: UIHorizontalDistanceConstraint[] = [];\n const verticalDistances: UIVerticalDistanceConstraint[] = [];\n\n horizontalDistances.push(\n new UIHorizontalDistanceConstraint(container, elementOne, {\n anchorOne: 0,\n anchorTwo: 0,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIHorizontalDistanceConstraint(container, elementTwo, {\n anchorOne: 1,\n anchorTwo: 1,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n const anchorOne =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 1 : 0;\n const anchorTwo =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 0 : 1;\n\n verticalDistances.push(\n new UIVerticalDistanceConstraint(container, elementOne, {\n anchorOne: anchorOne,\n anchorTwo: anchorOne,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIVerticalDistanceConstraint(container, elementTwo, {\n anchorOne: anchorTwo,\n anchorTwo: anchorTwo,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n return {\n horizontalDistances,\n verticalDistances,\n };\n }\n}\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n Mesh,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { needsRecalculation, renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\nexport enum UISceneUpdateBehavior {\n AUTO = \"AUTO\",\n PROPERTY = \"PROPERTY\",\n MANUAL = \"MANUAL\",\n}\n\nexport interface UISceneOptions {\n scene: Scene;\n camera: Camera;\n width: number;\n height: number;\n resolutionFactor: number;\n renderedByDefault: boolean;\n useDepth: boolean;\n clearColor: number;\n clearAlpha: number;\n updateBehavior: UISceneUpdateBehavior;\n}\n\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\nconst MIN_RESOLUTION_FACTOR = 0.1;\nconst MAX_RESOLUTION_FACTOR = 8;\nconst DEFAULT_WIDTH = 512;\nconst DEFAULT_HEIGHT = 512;\nconst DEFAULT_FOV = 75;\nconst DEFAULT_NEAR = 0.1;\nconst DEFAULT_FAR = 100;\nconst DEFAULT_UPDATE_BEHAVIOR = UISceneUpdateBehavior.PROPERTY;\nconst DEFAULT_CLEAR_COLOR = 0x000000;\nconst DEFAULT_CLEAR_ALPHA = 0;\nconst DEFAULT_RENDERED_BY_DEFAULT = false;\nconst DEFAULT_USE_DEPTH = true;\n\nexport class UIScene extends UIElement {\n private readonly material: UIMaterial;\n private readonly renderTarget: WebGLRenderTarget;\n\n private clearColorInternal: number;\n private clearAlphaInternal: number;\n\n private needsRenderInternal = false;\n private readonly updateBehaviorInternal: UISceneUpdateBehavior;\n private resolutionFactorInternal: number;\n\n private sceneInternal: Scene;\n private cameraInternal: Camera;\n\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n const resolutionFactor =\n options.resolutionFactor ?? DEFAULT_RESOLUTION_FACTOR;\n\n if (\n resolutionFactor < MIN_RESOLUTION_FACTOR ||\n resolutionFactor > MAX_RESOLUTION_FACTOR\n ) {\n throw new Error(\n `Invalid resolution factor: ${resolutionFactor}. Must be between ${MIN_RESOLUTION_FACTOR} and ${MAX_RESOLUTION_FACTOR}.`,\n );\n }\n\n const width = options.width ?? DEFAULT_WIDTH;\n const height = options.height ?? DEFAULT_HEIGHT;\n\n assertSize(\n width,\n height,\n `Invalid width or height: ${width}x${height}. Must be positive.`,\n );\n\n const renderTarget = new WebGLRenderTarget(\n width * resolutionFactor,\n height * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.useDepth ?? DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const material = new UIMaterial(renderTarget.texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_FOV,\n width / height,\n DEFAULT_NEAR,\n DEFAULT_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n\n this.updateBehaviorInternal =\n options.updateBehavior ?? DEFAULT_UPDATE_BEHAVIOR;\n\n if (options.renderedByDefault ?? DEFAULT_RENDERED_BY_DEFAULT) {\n this.needsRenderInternal = true;\n }\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n this.renderTarget = renderTarget;\n this.material = material;\n\n this.flushTransform();\n }\n\n public get needsRender(): boolean {\n return this.needsRenderInternal;\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composer.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composer.requestUpdate();\n }\n\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set resolutionFactor(value: number) {\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public override destroy(): void {\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n public requestRender(): void {\n this.needsRenderInternal = true;\n this.composer.requestUpdate();\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n if (\n this.needsRenderInternal ||\n this.updateBehaviorInternal === UISceneUpdateBehavior.AUTO\n ) {\n if (this[needsRecalculation]) {\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n }\n this.needsRenderInternal = false;\n renderer.setClearColor(this.clearColorInternal, this.clearAlpha);\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n }\n\n (this.object as Mesh).material = this.composer.compose(\n renderer,\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n this.material,\n );\n this.flushTransform();\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\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 options: UIWidthOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIWidthOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n width: options?.width ?? element.width,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.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.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.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.options.rule),\n this.options.width,\n convertPowerToStrength(this.options.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 proportion(\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 type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIHorizontalDistanceOptions } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport type { UIHorizontalProportionOptions } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport type { UIVerticalDistanceOptions } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIVerticalProportionOptions } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIConstraintStackBuilderOptions {\n distance: number;\n keepProportions: boolean;\n keepAlignment: boolean;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport interface UIConstraintStackBuilderResult<\n TDistance,\n TProportion,\n TCenter,\n> {\n distanceConstraints: TDistance[];\n proportionConstraints: TProportion[];\n alignmentConstraints: TCenter[];\n}\n\ninterface ConstraintConstructors<TDistance, TProportion, TCenter> {\n distanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TDistance;\n proportionConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalProportionOptions | UIVerticalProportionOptions>\n | undefined,\n ) => TProportion;\n centerDistanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TCenter;\n}\n\nexport class UIConstraintStackBuilder {\n public static buildHorizontal(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIHorizontalDistanceConstraint,\n UIHorizontalProportionConstraint,\n UIVerticalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIHorizontalDistanceConstraint,\n proportionConstraint: UIHorizontalProportionConstraint,\n centerDistanceConstraint: UIVerticalDistanceConstraint,\n });\n }\n\n public static buildVertical(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIVerticalDistanceConstraint,\n UIVerticalProportionConstraint,\n UIHorizontalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIVerticalDistanceConstraint,\n proportionConstraint: UIVerticalProportionConstraint,\n centerDistanceConstraint: UIHorizontalDistanceConstraint,\n });\n }\n\n private static buildStack<TDistance, TProportion, TCenter>(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n constructors: ConstraintConstructors<TDistance, TProportion, TCenter>,\n ): UIConstraintStackBuilderResult<TDistance, TProportion, TCenter> {\n const distances: TDistance[] = [];\n const proportions: TProportion[] = [];\n const centers: TCenter[] = [];\n\n for (let i = 0; i < elements.length - 1; i++) {\n const element = elements[i];\n const nextElement = elements[i + 1];\n\n distances.push(\n new constructors.distanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.distance,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n if (options.keepProportions !== false) {\n proportions.push(\n new constructors.proportionConstraint(element, nextElement, {\n power: options.power,\n orientation: options.orientation,\n }),\n );\n }\n\n if (options.keepAlignment !== false) {\n centers.push(\n new constructors.centerDistanceConstraint(element, nextElement, {\n power: options.power,\n anchorOne: 0,\n anchorTwo: 0,\n orientation: options.orientation,\n }),\n );\n }\n }\n\n return {\n distanceConstraints: distances,\n proportionConstraints: proportions,\n alignmentConstraints: centers,\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 = 1000;\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 this.flushTransform();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\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.textureInternal;\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composer.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composer.requestUpdate();\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composer.compose(\n renderer,\n this.textureInternal.image.width,\n this.textureInternal.image.height,\n this.material,\n );\n this.flushTransform();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(foregroundTexture: Texture, backgroundTexture?: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n background: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n backgroundColor: { value: new Color(1, 1, 1) },\n foregroundColor: { value: new Color(1, 1, 1) },\n color: { value: new Color(1, 1, 1) },\n backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n opacity: { value: 1 },\n angle: { value: 0 },\n direction: { 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 background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n lights: false,\n fog: false,\n });\n }\n\n public getProgress(): number {\n return this.uniforms.progress.value;\n }\n\n public getBackgroundTexture(): Texture | undefined {\n return this.uniforms.background.value;\n }\n\n public getForegroundTexture(): Texture {\n return this.uniforms.foreground.value;\n }\n\n public getBackgroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getBackgroundOpacity(): number {\n return this.uniforms.backgroundOpacity.value;\n }\n\n public getForegroundOpacity(): number {\n return this.uniforms.foregroundOpacity.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getAngle(): number {\n return this.uniforms.angle.value;\n }\n\n public getIsForwardDirection(): boolean {\n return this.uniforms.direction.value === 1;\n }\n\n public setProgress(value: number): void {\n this.uniforms.progress.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundTexture(value: Texture | undefined): void {\n this.uniforms.background.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundTexture(value: Texture): void {\n this.uniforms.foreground.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundOpacity(value: number): void {\n this.uniforms.backgroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundOpacity(value: number): void {\n this.uniforms.foregroundOpacity.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 setAngle(value: number): void {\n this.uniforms.angle.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setIsForwardDirection(value: boolean): void {\n this.uniforms.direction.value = value ? 1 : -1;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIProgressMaterial } from \"../Materials/UIProgressMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { renderSymbol } from \"../Miscellaneous/symbols\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\nexport interface UIProgressOptions {\n progress: number;\n isForegroundDirection: boolean;\n angle: number;\n color: number;\n opacity: number;\n backgroundColor: number;\n foregroundColor: number;\n backgroundOpacity: number;\n foregroundOpacity: number;\n}\n\nexport class UIProgress extends UIElement {\n private readonly material: UIProgressMaterial;\n private readonly imageWidth: number;\n private readonly imageHeight: number;\n\n constructor(\n layer: UILayer,\n textureForeground: Texture,\n textureBackground?: Texture,\n options: Partial<UIProgressOptions> = {},\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 backgroundWidth = textureBackground?.image?.width;\n const backgroundHeight = textureBackground?.image?.height;\n\n if (textureBackground) {\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\n const material = new UIProgressMaterial(\n textureForeground,\n textureBackground,\n );\n const object = new Mesh(geometry, material);\n\n if (options.progress) {\n material.setProgress(options.progress);\n }\n\n if (options.isForegroundDirection) {\n material.setIsForwardDirection(options.isForegroundDirection);\n }\n\n if (options.angle) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.color) {\n material.setColor(options.color);\n }\n\n if (options.opacity) {\n material.setOpacity(options.opacity);\n }\n\n if (options.backgroundColor) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(layer, object, 0, 0, imageWidth, imageHeight);\n\n this.material = material;\n this.imageWidth = imageWidth;\n this.imageHeight = imageHeight;\n\n this.flushTransform();\n }\n\n public get progress(): number {\n return this.material.getProgress();\n }\n\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n public set progress(value: number) {\n this.material.setProgress(value);\n this.composer.requestUpdate();\n }\n\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n this.composer.requestUpdate();\n }\n\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n this.composer.requestUpdate();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composer.requestUpdate();\n }\n\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n this.composer.requestUpdate();\n }\n\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n this.composer.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composer.requestUpdate();\n }\n\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n this.composer.requestUpdate();\n }\n\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n this.composer.requestUpdate();\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n public [renderSymbol](renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composer.compose(\n renderer,\n this.imageWidth,\n this.imageHeight,\n this.material,\n );\n this.flushTransform();\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 { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\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 { 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)[] | 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 const processedSpans = Array.isArray(spans) ? spans : [spans];\n\n for (const span of processedSpans) {\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(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composer.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composer.requestUpdate();\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.object as Mesh).material = this.composer.compose(\n renderer,\n this.texture.image.width,\n this.texture.image.height,\n this.material,\n );\n this.flushTransform();\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 UITextMultiSpanDescription {\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 | UITextMultiSpanDescription\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 isUITextMultiSpanDescription(\n obj: unknown,\n): obj is UITextMultiSpanDescription {\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 isUITextMultiSpanDescription,\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 (isUITextMultiSpanDescription(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 { 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(\"pointerdown\", 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(\"pointerdown\", 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: PointerEvent): 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\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 get isValuable(): 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","options","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","tempMatrixA","Matrix3","tempMatrixB","tempMatrixC","tempMatrixD","tempMatrixE","tempVectorA","Vector3","UIBehavior","DEFAULT_ANCHOR","UIMicroTransformations","owner","positionXInternal","positionYInternal","anchorXInternal","anchorYInternal","scaleXInternal","scaleYInternal","rotationInternal","x","y","anchorX","anchorY","scaleX","scaleY","angle","MathUtils","radToDeg","rotation","degToRad","setAnchorByGlobalPosition","deltaY","width","reset","UIMaterial","ShaderMaterial","uniforms","opacity","color","Color","vertexShader","fragmentShader","transparent","lights","fog","getTexture","getColor","getHex","getOpacity","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","render","renderer","material","left","right","bottom","top","updateProjectionMatrix","UIComposer","passes","defaultMaterial","screen","needsUpdateInternal","lastPaddingHasChangedInternal","lastPaddingInternal","parameters","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","texture","generateMipmaps","needsUpdate","hasValuablePasses","hasPassesNeedingUpdate","lastPaddingHasChanged","lastPadding","requestUpdate","compose","canOverrideBlending","padding","calculatePadding","widthWithPadding","heightWithPadding","setSize","setScreenPadding","setClearColor","setRenderTarget","clear","originalBlending","blending","NoBlending","pass","isValuable","reverseRenderTargets","dispose","p","reduce","UIElementEvent","UIElement","object","_b","_c","_d","_e","behaviorInternal","VISIBLE","composer","micro","zIndex","position","z","behavior","visible","HIDDEN","INTERACTIVE","flushTransform","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","realX","realY","realWidth","realHeight","centerX","centerY","translateToCenter","scale","cos","sin","translateFinal","finalMatrix","multiplyMatrices","point","applyMatrix3","applyMicroTransformations","clearColor","UILayerEvent","UIConstraintContainerDirection","UISceneUpdateBehavior","UILayer","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","dependencies","remove","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","ORIENTATION_CHANGED","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraint2DBuilder","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","UIConstraintContainerBuilder","build","container","direction","FROM_LEFT_TOP","horizontalDistances","verticalDistances","UIConstraintStackBuilder","buildHorizontal","buildStack","distanceConstraint","proportionConstraint","centerDistanceConstraint","buildVertical","constructors","distances","proportions","centers","nextElement","keepProportions","keepAlignment","distanceConstraints","proportionConstraints","alignmentConstraints","UIDummy","Object3D","UIImage","image","textureInternal","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","getProgress","getBackgroundTexture","getForegroundTexture","getBackgroundColor","getForegroundColor","getBackgroundOpacity","getForegroundOpacity","getAngle","getIsForwardDirection","setProgress","setBackgroundTexture","setForegroundTexture","setBackgroundColor","setForegroundColor","setBackgroundOpacity","setForegroundOpacity","setAngle","setIsForwardDirection","UIProgress","textureForeground","textureBackground","foregroundWidth","foregroundHeight","backgroundWidth","backgroundHeight","isForegroundDirection","imageWidth","imageHeight","isForwardDirection","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","processedSpans","isArray","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","isUITextMultiSpanDescription","every","isUITextSpan","isUIDummyDescription","UIElementBuilder","UIFitConstraint","DEFAULT_UPDATE_BEHAVIOR","PROPERTY","UIScene","resolutionFactor","renderTarget","useDepth","needsRenderInternal","sceneInternal","cameraInternal","PerspectiveCamera","resolutionFactorInternal","updateBehaviorInternal","updateBehavior","renderedByDefault","clearColorInternal","clearAlphaInternal","clearAlpha","needsRender","requestRender","AUTO","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIManualLayer","click","resize","UIPass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EAAO9D,UCATyf","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/UIConstraint.ts","../src/Constraints/UIConstraintPower.ts","../src/Constraints/UIConstraintRule.ts","../src/Constraints/UIHeightConstraint.ts","../node_modules/eventail/dist/index.js","../src/Miscellaneous/math.ts","../src/Miscellaneous/microTransformationTools.ts","../src/Miscellaneous/UIBehavior.ts","../src/Miscellaneous/UIMicro.ts","../src/Materials/UIMaterial.ts","../src/Miscellaneous/threeInstances.ts","../src/Passes/UIFullScreenQuad.ts","../src/Passes/UIComposer.ts","../src/Elements/UIElement.ts","../src/Layers/UILayer.ts","../src/Builders/UIConstraintContainerBuilder.ts","../src/Elements/UIScene.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/Builders/UIConstraintStackBuilder.ts","../src/Elements/UIDummy.ts","../src/Elements/UIImage.ts","../src/Materials/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/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 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","import { Strength } from \"kiwi.js\";\n\nconst HIGH_PRIORITY = 1000;\nconst MEDIUM_PRIORITY = 100;\nconst LOW_PRIORITY = 10;\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(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIConstraintPower.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIConstraintPower.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIConstraintPower.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIConstraintPower.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIConstraintPower.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIConstraintPower.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIConstraintPower.P7:\n return Strength.create(0, 0, 1);\n default:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\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 { 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 UIHeightOptions {\n height: number;\n power: UIConstraintPower;\n rule: UIConstraintRule;\n orientation: UIOrientation;\n}\n\nexport class UIHeightConstraint extends UIConstraint {\n private readonly options: UIHeightOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIHeightOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n height: options?.height ?? element.height,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.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.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.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.options.rule),\n this.options.height,\n convertPowerToStrength(this.options.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","import { Matrix3, Vector3, type Object3D } from \"three\";\nimport type { UIMicroInternal } from \"./UIMicro\";\n\nconst tempMatrixA = new Matrix3();\nconst tempMatrixB = new Matrix3();\nconst tempMatrixC = new Matrix3();\nconst tempMatrixD = new Matrix3();\nconst tempMatrixE = new Matrix3();\nconst tempVectorA = new Vector3();\n\nexport function applyMicroTransformations(\n object: Object3D,\n micro: UIMicroInternal,\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 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 const centerX = realX + anchorOffsetX;\n const centerY = realY + anchorOffsetY;\n\n const translateToCenter = tempMatrixA.set(\n 1,\n 0,\n -centerX,\n 0,\n 1,\n -centerY,\n 0,\n 0,\n 1,\n );\n\n const scale = tempMatrixB.set(\n micro.scaleX,\n 0,\n 0,\n 0,\n micro.scaleY,\n 0,\n 0,\n 0,\n 1,\n );\n\n const rotation = tempMatrixC.set(\n Math.cos(micro.rotation),\n -Math.sin(micro.rotation),\n 0,\n Math.sin(micro.rotation),\n Math.cos(micro.rotation),\n 0,\n 0,\n 0,\n 1,\n );\n\n const translateFinal = tempMatrixD.set(\n 1,\n 0,\n micro.x + centerX,\n 0,\n 1,\n micro.y + centerY,\n 0,\n 0,\n 1,\n );\n\n const finalMatrix = tempMatrixE\n .multiplyMatrices(translateFinal, rotation)\n .multiply(scale)\n .multiply(translateToCenter);\n\n const point = tempVectorA.set(realX, realY, 1).applyMatrix3(finalMatrix);\n\n object.position.x = point.x;\n object.position.y = point.y;\n object.rotation.z = micro.rotation;\n object.scale.x = realWidth * micro.scaleX;\n object.scale.y = realHeight * micro.scaleY;\n}\n","export enum UIMode {\n HIDDEN,\n VISIBLE,\n INTERACTIVE,\n}\n","import { MathUtils } from \"three\";\nimport type { UIElement } from \"../Elements/UIElement\";\n\nconst DEFAULT_POSITION = 0;\nconst DEFAULT_ANCHOR = 0.5;\nconst DEFAULT_SCALE = 1;\nconst DEFAULT_ROTATION = 0;\n\nexport class UIMicroInternal {\n public x = DEFAULT_POSITION;\n public y = DEFAULT_POSITION;\n public anchorX = DEFAULT_ANCHOR;\n public anchorY = DEFAULT_ANCHOR;\n public scaleX = DEFAULT_SCALE;\n public scaleY = DEFAULT_SCALE;\n public rotation = DEFAULT_ROTATION;\n public needsRecalculation = false;\n}\n\nexport class UIMicro {\n constructor(\n private readonly raw: UIMicroInternal,\n private readonly owner: UIElement,\n ) {}\n\n public get x(): number {\n return this.raw.x;\n }\n\n public get y(): number {\n return this.raw.y;\n }\n\n public get anchorX(): number {\n return this.raw.anchorX;\n }\n\n public get anchorY(): number {\n return this.raw.anchorY;\n }\n\n public get scaleX(): number {\n return this.raw.scaleX;\n }\n\n public get scaleY(): number {\n return this.raw.scaleY;\n }\n\n public get angle(): number {\n return MathUtils.radToDeg(this.raw.rotation);\n }\n\n public get rotation(): number {\n return this.raw.rotation;\n }\n\n public set x(value: number) {\n if (value !== this.raw.x) {\n this.raw.x = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set y(value: number) {\n if (value !== this.raw.y) {\n this.raw.y = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set anchorX(value: number) {\n if (value !== this.raw.anchorX) {\n this.raw.anchorX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set anchorY(value: number) {\n if (value !== this.raw.anchorY) {\n this.raw.anchorY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set scaleX(value: number) {\n if (value !== this.raw.scaleX) {\n this.raw.scaleX = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set scaleY(value: number) {\n if (value !== this.raw.scaleY) {\n this.raw.scaleY = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set angle(value: number) {\n const convertedValue = MathUtils.degToRad(value);\n if (convertedValue !== this.raw.rotation) {\n this.raw.rotation = convertedValue;\n this.raw.needsRecalculation = true;\n }\n }\n\n public set rotation(value: number) {\n if (value !== this.raw.rotation) {\n this.raw.rotation = value;\n this.raw.needsRecalculation = true;\n }\n }\n\n public setAnchorByGlobalPosition(x: number, y: number): void {\n const deltaX = x - this.owner.x;\n const deltaY = y - this.owner.y;\n const newAnchorX = deltaX / this.owner.width;\n const newAnchorY = deltaY / this.owner.height;\n\n if (newAnchorX !== this.raw.anchorX || newAnchorY !== this.raw.anchorY) {\n this.raw.anchorX = newAnchorX;\n this.raw.anchorY = newAnchorY;\n this.raw.needsRecalculation = true;\n }\n }\n\n public reset(): void {\n if (\n this.raw.x !== DEFAULT_POSITION ||\n this.raw.y !== DEFAULT_POSITION ||\n this.raw.anchorX !== DEFAULT_ANCHOR ||\n this.raw.anchorY !== DEFAULT_ANCHOR ||\n this.raw.scaleX !== DEFAULT_SCALE ||\n this.raw.scaleY !== DEFAULT_SCALE ||\n this.raw.rotation !== DEFAULT_ROTATION\n ) {\n this.raw.x = DEFAULT_POSITION;\n this.raw.y = DEFAULT_POSITION;\n this.raw.anchorX = DEFAULT_ANCHOR;\n this.raw.anchorY = DEFAULT_ANCHOR;\n this.raw.scaleX = DEFAULT_SCALE;\n this.raw.scaleY = DEFAULT_SCALE;\n this.raw.rotation = DEFAULT_ROTATION;\n this.raw.needsRecalculation = true;\n }\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial } from \"three\";\n\nexport class UIMaterial extends ShaderMaterial {\n constructor(map?: Texture) {\n super({\n uniforms: {\n map: { value: map },\n opacity: { value: 1.0 },\n color: { value: new Color(1.0, 1.0, 1.0) },\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 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 lights: false,\n fog: false,\n });\n }\n\n public getTexture(): Texture | undefined {\n return this.uniforms.map.value;\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public setTexture(value: Texture | undefined): void {\n this.uniforms.map.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(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","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 { Material, 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 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 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 render(renderer: WebGLRenderer, material: Material): void {\n mesh.material = material;\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 { Material, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n NoBlending,\n RGBAFormat,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { UIFullScreenQuad } from \"./UIFullScreenQuad\";\nimport type { UIPass } from \"./UIPass\";\n\nexport class UIComposerInternal {\n public readonly passes: UIPass[] = [];\n\n private fromRenderTarget: WebGLRenderTarget;\n private toRenderTarget: WebGLRenderTarget;\n\n private readonly defaultMaterial = new UIMaterial();\n private readonly screen = new UIFullScreenQuad();\n\n private needsUpdateInternal = false;\n private paddingHasChangedInternal = false;\n private paddingInternal = 0;\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 this.fromRenderTarget.texture.generateMipmaps = false;\n this.toRenderTarget.texture.generateMipmaps = false;\n }\n\n public get needsUpdate(): boolean {\n return (\n (this.needsUpdateInternal && this.hasValuablePasses()) ||\n this.hasPassesNeedingUpdate()\n );\n }\n\n public get paddingHasChanged(): boolean {\n return this.paddingHasChangedInternal;\n }\n\n public get padding(): number {\n return this.paddingInternal;\n }\n\n public requestUpdate(): void {\n this.needsUpdateInternal = true;\n }\n\n public compose(\n renderer: WebGLRenderer,\n width: number,\n height: number,\n material: Material,\n canOverrideBlending = true,\n ): Material {\n const hasValuablePasses = this.hasValuablePasses();\n if (\n (!this.needsUpdateInternal || !hasValuablePasses) &&\n !this.hasPassesNeedingUpdate()\n ) {\n if (!hasValuablePasses) {\n this.paddingHasChangedInternal = this.paddingInternal !== 0;\n this.paddingInternal = 0;\n }\n this.needsUpdateInternal = false;\n return hasValuablePasses ? this.defaultMaterial : material;\n }\n\n const padding = this.calculatePadding();\n this.paddingHasChangedInternal = this.paddingInternal !== padding;\n this.paddingInternal = padding;\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.setScreenPadding(width, height, padding);\n\n renderer.setClearColor(0x000000, 0);\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n\n const originalBlending = material.blending;\n if (canOverrideBlending) {\n material.blending = NoBlending;\n }\n this.screen.render(renderer, material);\n material.blending = originalBlending;\n\n const options = { width, height, padding };\n\n for (let i = 0; i < this.passes.length; i++) {\n const pass = this.passes[i];\n if (pass.needsUpdate || pass.isValuable) {\n this.reverseRenderTargets();\n renderer.setRenderTarget(this.toRenderTarget);\n renderer.clear(true, false, false);\n this.passes[i].render(renderer, this.fromRenderTarget.texture, options);\n }\n }\n\n this.needsUpdateInternal = false;\n this.defaultMaterial.setTexture(this.toRenderTarget.texture);\n return this.defaultMaterial;\n }\n\n public destroy(): void {\n this.fromRenderTarget.dispose();\n this.toRenderTarget.dispose();\n }\n\n private hasValuablePasses(): boolean {\n return this.passes.some((p) => p.isValuable);\n }\n\n private hasPassesNeedingUpdate(): boolean {\n return this.passes.some((p) => p.needsUpdate);\n }\n\n private calculatePadding(): number {\n return this.passes.reduce((a, p) => Math.max(a, p.padding), 0);\n }\n\n private setScreenPadding(\n width: number,\n height: number,\n padding: number,\n ): void {\n this.screen.paddingHorizontal = padding / width;\n this.screen.paddingVertical = padding / height;\n }\n\n private reverseRenderTargets(): void {\n const fromRenderTarget = this.fromRenderTarget;\n this.fromRenderTarget = this.toRenderTarget;\n this.toRenderTarget = fromRenderTarget;\n }\n}\n\nexport class UIComposer {\n constructor(private readonly raw: UIComposerInternal) {}\n\n public get passes(): UIPass[] {\n return this.raw.passes;\n }\n}\n","import { Eventail } from \"eventail\";\nimport { Variable } from \"kiwi.js\";\nimport type { WebGLRenderer } from \"three\";\nimport { MathUtils, 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 { UIMode } from \"../Miscellaneous/UIBehavior\";\nimport { UIMicro, UIMicroInternal } from \"../Miscellaneous/UIMicro\";\nimport { UIComposer, UIComposerInternal } from \"../Passes/UIComposer\";\n\nexport enum UIElementEvent {\n CLICK = \"click\",\n}\n\nexport abstract class UIElement extends Eventail {\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 public name = MathUtils.generateUUID();\n public readonly micro: UIMicro;\n public readonly composer: UIComposer;\n protected readonly microInternal = new UIMicroInternal();\n protected readonly composerInternal = new UIComposerInternal();\n\n protected modeInternal = UIMode.VISIBLE;\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.micro = new UIMicro(this.microInternal, this);\n this.composer = new UIComposer(this.composerInternal);\n\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 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 mode(): UIMode {\n return this.modeInternal;\n }\n\n protected get needsRecalculation(): boolean {\n return this[needsRecalculation];\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 mode(value: UIMode) {\n this.modeInternal = value;\n this.object.visible = value !== UIMode.HIDDEN;\n }\n\n public destroy(): void {\n this.composerInternal.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 [renderSymbol](renderer: WebGLRenderer, deltaTime: number): void {\n this.render(renderer, deltaTime);\n }\n\n public [clickSymbol](x: number, y: number): boolean {\n return this.click(x, y);\n }\n\n protected applyTransformations(): void {\n if (\n this[needsRecalculation] ||\n this.microInternal.needsRecalculation ||\n this.composerInternal.paddingHasChanged\n ) {\n applyMicroTransformations(\n this.object,\n this.microInternal,\n this.x,\n this.y,\n this.width,\n this.height,\n this.composerInternal.padding,\n );\n\n this[needsRecalculation] = false;\n this.microInternal.needsRecalculation = false;\n }\n }\n\n protected click(x: number, y: number): boolean {\n if (this.mode !== UIMode.INTERACTIVE) {\n return false;\n }\n\n this.applyTransformations();\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 abstract render(renderer: WebGLRenderer, deltaTime: number): void;\n}\n","import { Eventail } from \"eventail\";\nimport {\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 { UIMode } from \"../Miscellaneous/UIBehavior\";\nimport { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nconst MAX_Z_INDEX = 1000;\nconst DEFAULT_Z_INDEX = 500;\nconst clearColor = 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 enum UILayerEvent {\n ORIENTATION_CHANGED = \"orientationChanged\",\n}\n\nexport abstract class UILayer extends Eventail {\n public behavior = UIMode.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 object.position.z = DEFAULT_Z_INDEX;\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, deltaTime: number): void {\n if (this.behavior === UIMode.HIDDEN) {\n return;\n }\n\n const originalRenderTarget = renderer.getRenderTarget();\n const originalClearColor = renderer.getClearColor(clearColor);\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[renderSymbol](renderer, deltaTime);\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 !== UIMode.INTERACTIVE) {\n return;\n }\n\n const elements = [...this.elements.keys()]\n .filter((e: UIElement) => e.mode === UIMode.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 this.emit(UILayerEvent.ORIENTATION_CHANGED, this, this.orientation);\n }\n }\n}\n","import type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport enum UIConstraintContainerDirection {\n FROM_LEFT_TOP,\n FROM_LEFT_BOTTOM,\n}\n\nexport interface UIConstraintContainerBuilderOptions {\n direction: UIConstraintContainerDirection;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport class UIConstraintContainerBuilder {\n public static build(\n container: UIElement,\n elementOne: UIElement,\n elementTwo: UIElement,\n options: Partial<UIConstraintContainerBuilderOptions> = {},\n ): {\n horizontalDistances: UIHorizontalDistanceConstraint[];\n verticalDistances: UIVerticalDistanceConstraint[];\n } {\n const direction =\n options.direction ?? UIConstraintContainerDirection.FROM_LEFT_TOP;\n\n const horizontalDistances: UIHorizontalDistanceConstraint[] = [];\n const verticalDistances: UIVerticalDistanceConstraint[] = [];\n\n horizontalDistances.push(\n new UIHorizontalDistanceConstraint(container, elementOne, {\n anchorOne: 0,\n anchorTwo: 0,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIHorizontalDistanceConstraint(container, elementTwo, {\n anchorOne: 1,\n anchorTwo: 1,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n const anchorOne =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 1 : 0;\n const anchorTwo =\n direction === UIConstraintContainerDirection.FROM_LEFT_TOP ? 0 : 1;\n\n verticalDistances.push(\n new UIVerticalDistanceConstraint(container, elementOne, {\n anchorOne: anchorOne,\n anchorTwo: anchorOne,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n new UIVerticalDistanceConstraint(container, elementTwo, {\n anchorOne: anchorTwo,\n anchorTwo: anchorTwo,\n distance: 0,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n return {\n horizontalDistances,\n verticalDistances,\n };\n }\n}\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n Mesh,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\nexport enum UISceneUpdateBehavior {\n AUTO = \"AUTO\",\n PROPERTY = \"PROPERTY\",\n MANUAL = \"MANUAL\",\n}\n\nconst DEFAULT_RESOLUTION_FACTOR = 0.5;\nconst MIN_RESOLUTION_FACTOR = 0.1;\nconst MAX_RESOLUTION_FACTOR = 8;\nconst DEFAULT_WIDTH = 512;\nconst DEFAULT_HEIGHT = 512;\nconst DEFAULT_FOV = 75;\nconst DEFAULT_NEAR = 0.1;\nconst DEFAULT_FAR = 100;\nconst DEFAULT_UPDATE_BEHAVIOR = UISceneUpdateBehavior.PROPERTY;\nconst DEFAULT_CLEAR_COLOR = 0x000000;\nconst DEFAULT_CLEAR_ALPHA = 0;\nconst DEFAULT_RENDERED_BY_DEFAULT = false;\nconst DEFAULT_USE_DEPTH = true;\n\nexport interface UISceneOptions {\n scene: Scene;\n camera: Camera;\n width: number;\n height: number;\n resolutionFactor: number;\n renderedByDefault: boolean;\n useDepth: boolean;\n clearColor: number;\n clearAlpha: number;\n updateBehavior: UISceneUpdateBehavior;\n}\n\nexport class UIScene extends UIElement {\n private readonly material: UIMaterial;\n private readonly renderTarget: WebGLRenderTarget;\n\n private clearColorInternal: number;\n private clearAlphaInternal: number;\n\n private needsRenderInternal = false;\n private readonly updateBehaviorInternal: UISceneUpdateBehavior;\n private resolutionFactorInternal: number;\n\n private sceneInternal: Scene;\n private cameraInternal: Camera;\n\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n const resolutionFactor =\n options.resolutionFactor ?? DEFAULT_RESOLUTION_FACTOR;\n\n if (\n resolutionFactor < MIN_RESOLUTION_FACTOR ||\n resolutionFactor > MAX_RESOLUTION_FACTOR\n ) {\n throw new Error(\n `Invalid resolution factor: ${resolutionFactor}. Must be between ${MIN_RESOLUTION_FACTOR} and ${MAX_RESOLUTION_FACTOR}.`,\n );\n }\n\n const width = options.width ?? DEFAULT_WIDTH;\n const height = options.height ?? DEFAULT_HEIGHT;\n\n assertSize(\n width,\n height,\n `Invalid width or height: ${width}x${height}. Must be positive.`,\n );\n\n const renderTarget = new WebGLRenderTarget(\n width * resolutionFactor,\n height * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.useDepth ?? DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const material = new UIMaterial(renderTarget.texture);\n const object = new Mesh(geometry, material);\n\n super(layer, object, 0, 0, width, height);\n\n this.sceneInternal = options.scene ?? new Scene();\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n DEFAULT_FOV,\n width / height,\n DEFAULT_NEAR,\n DEFAULT_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n\n this.updateBehaviorInternal =\n options.updateBehavior ?? DEFAULT_UPDATE_BEHAVIOR;\n\n if (options.renderedByDefault ?? DEFAULT_RENDERED_BY_DEFAULT) {\n this.needsRenderInternal = true;\n }\n\n this.clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;\n this.clearAlphaInternal = options.clearAlpha ?? DEFAULT_CLEAR_ALPHA;\n\n this.renderTarget = renderTarget;\n this.material = material;\n\n this.applyTransformations();\n }\n\n public get needsRender(): boolean {\n return this.needsRenderInternal;\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n public get clearColor(): number {\n return this.clearColorInternal;\n }\n\n public get clearAlpha(): number {\n return this.clearAlphaInternal;\n }\n\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set clearColor(value: number) {\n if (this.clearColorInternal !== value) {\n this.clearColorInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set clearAlpha(value: number) {\n if (this.clearAlphaInternal !== value) {\n this.clearAlphaInternal = value;\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public set resolutionFactor(value: number) {\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n if (this.updateBehaviorInternal === UISceneUpdateBehavior.PROPERTY) {\n this.requestRender();\n }\n }\n }\n\n public override destroy(): void {\n this.material.dispose();\n this.renderTarget.dispose();\n super.destroy();\n }\n\n public requestRender(): void {\n this.needsRenderInternal = true;\n this.composerInternal.requestUpdate();\n }\n\n protected override render(renderer: WebGLRenderer): void {\n if (\n this.needsRenderInternal ||\n this.updateBehaviorInternal === UISceneUpdateBehavior.AUTO\n ) {\n this.needsRenderInternal = false;\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n renderer.setClearColor(this.clearColorInternal, this.clearAlpha);\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n }\n\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n this.material,\n );\n this.applyTransformations();\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\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 options: UIWidthOptions;\n private constraint?: Constraint;\n\n constructor(\n private readonly element: UIElement,\n options?: Partial<UIWidthOptions>,\n ) {\n super(element.layer, new Set([element]));\n\n this.options = {\n width: options?.width ?? element.width,\n power: resolvePower(options?.power),\n rule: resolveRule(options?.rule),\n orientation: resolveOrientation(options?.orientation),\n };\n\n if (\n this.options.orientation === UIOrientation.ALWAYS ||\n this.options.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.options.orientation !== UIOrientation.ALWAYS &&\n orientation !== this.options.orientation\n ) {\n this.destroyConstraints();\n }\n }\n\n public [enableConstraintSymbol](orientation: UIOrientation): void {\n if (\n this.options.orientation !== UIOrientation.ALWAYS &&\n orientation === this.options.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.options.rule),\n this.options.width,\n convertPowerToStrength(this.options.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 proportion(\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 type { UIConstraintPower } from \"../Constraints/UIConstraintPower\";\nimport type { UIHorizontalDistanceOptions } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../Constraints/UIHorizontalDistanceConstraint\";\nimport type { UIHorizontalProportionOptions } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../Constraints/UIHorizontalProportionConstraint\";\nimport type { UIVerticalDistanceOptions } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../Constraints/UIVerticalDistanceConstraint\";\nimport type { UIVerticalProportionOptions } from \"../Constraints/UIVerticalProportionConstraint\";\nimport { UIVerticalProportionConstraint } from \"../Constraints/UIVerticalProportionConstraint\";\nimport type { UIElement } from \"../Elements/UIElement\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport type { UIOrientation } from \"../Miscellaneous/UIOrientation\";\n\nexport interface UIConstraintStackBuilderOptions {\n distance: number;\n keepProportions: boolean;\n keepAlignment: boolean;\n power: UIConstraintPower;\n orientation: UIOrientation;\n}\n\nexport interface UIConstraintStackBuilderResult<\n TDistance,\n TProportion,\n TCenter,\n> {\n distanceConstraints: TDistance[];\n proportionConstraints: TProportion[];\n alignmentConstraints: TCenter[];\n}\n\ninterface ConstraintConstructors<TDistance, TProportion, TCenter> {\n distanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TDistance;\n proportionConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalProportionOptions | UIVerticalProportionOptions>\n | undefined,\n ) => TProportion;\n centerDistanceConstraint: new (\n elementOne: UIElement | UILayer,\n elementTwo: UIElement,\n options:\n | Partial<UIHorizontalDistanceOptions | UIVerticalDistanceOptions>\n | undefined,\n ) => TCenter;\n}\n\nexport class UIConstraintStackBuilder {\n public static buildHorizontal(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIHorizontalDistanceConstraint,\n UIHorizontalProportionConstraint,\n UIVerticalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIHorizontalDistanceConstraint,\n proportionConstraint: UIHorizontalProportionConstraint,\n centerDistanceConstraint: UIVerticalDistanceConstraint,\n });\n }\n\n public static buildVertical(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n ): UIConstraintStackBuilderResult<\n UIVerticalDistanceConstraint,\n UIVerticalProportionConstraint,\n UIHorizontalDistanceConstraint\n > {\n return this.buildStack(elements, options, {\n distanceConstraint: UIVerticalDistanceConstraint,\n proportionConstraint: UIVerticalProportionConstraint,\n centerDistanceConstraint: UIHorizontalDistanceConstraint,\n });\n }\n\n private static buildStack<TDistance, TProportion, TCenter>(\n elements: UIElement[],\n options: Partial<UIConstraintStackBuilderOptions>,\n constructors: ConstraintConstructors<TDistance, TProportion, TCenter>,\n ): UIConstraintStackBuilderResult<TDistance, TProportion, TCenter> {\n const distances: TDistance[] = [];\n const proportions: TProportion[] = [];\n const centers: TCenter[] = [];\n\n for (let i = 0; i < elements.length - 1; i++) {\n const element = elements[i];\n const nextElement = elements[i + 1];\n\n distances.push(\n new constructors.distanceConstraint(element, nextElement, {\n anchorOne: 1,\n anchorTwo: 0,\n distance: options.distance,\n power: options.power,\n orientation: options.orientation,\n }),\n );\n\n if (options.keepProportions !== false) {\n proportions.push(\n new constructors.proportionConstraint(element, nextElement, {\n power: options.power,\n orientation: options.orientation,\n }),\n );\n }\n\n if (options.keepAlignment !== false) {\n centers.push(\n new constructors.centerDistanceConstraint(element, nextElement, {\n power: options.power,\n anchorOne: 0,\n anchorTwo: 0,\n orientation: options.orientation,\n }),\n );\n }\n }\n\n return {\n distanceConstraints: distances,\n proportionConstraints: proportions,\n alignmentConstraints: centers,\n };\n }\n}\n","import { Object3D } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\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.applyTransformations();\n }\n\n protected override render(): void {\n this.applyTransformations();\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\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.applyTransformations();\n }\n\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.textureInternal.image.width,\n this.textureInternal.image.height,\n this.material,\n );\n this.applyTransformations();\n }\n}\n","import type { Texture } from \"three\";\nimport { Color, ShaderMaterial, UniformsUtils } from \"three\";\n\nexport class UIProgressMaterial extends ShaderMaterial {\n constructor(foregroundTexture: Texture, backgroundTexture?: Texture) {\n super({\n uniforms: UniformsUtils.merge([\n {\n background: { value: backgroundTexture },\n foreground: { value: foregroundTexture },\n progress: { value: 1 },\n backgroundColor: { value: new Color(1, 1, 1) },\n foregroundColor: { value: new Color(1, 1, 1) },\n color: { value: new Color(1, 1, 1) },\n backgroundOpacity: { value: 1 },\n foregroundOpacity: { value: 1 },\n opacity: { value: 1 },\n angle: { value: 0 },\n direction: { 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 background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n `,\n transparent: true,\n lights: false,\n fog: false,\n });\n }\n\n public getProgress(): number {\n return this.uniforms.progress.value;\n }\n\n public getBackgroundTexture(): Texture | undefined {\n return this.uniforms.background.value;\n }\n\n public getForegroundTexture(): Texture {\n return this.uniforms.foreground.value;\n }\n\n public getBackgroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getForegroundColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getColor(): number {\n return (this.uniforms.color.value as Color).getHex();\n }\n\n public getBackgroundOpacity(): number {\n return this.uniforms.backgroundOpacity.value;\n }\n\n public getForegroundOpacity(): number {\n return this.uniforms.foregroundOpacity.value;\n }\n\n public getOpacity(): number {\n return this.uniforms.opacity.value;\n }\n\n public getAngle(): number {\n return this.uniforms.angle.value;\n }\n\n public getIsForwardDirection(): boolean {\n return this.uniforms.direction.value === 1;\n }\n\n public setProgress(value: number): void {\n this.uniforms.progress.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundTexture(value: Texture | undefined): void {\n this.uniforms.background.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundTexture(value: Texture): void {\n this.uniforms.foreground.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setColor(value: number): void {\n (this.uniforms.color.value as Color).setHex(value);\n this.uniformsNeedUpdate = true;\n }\n\n public setBackgroundOpacity(value: number): void {\n this.uniforms.backgroundOpacity.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setForegroundOpacity(value: number): void {\n this.uniforms.foregroundOpacity.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 setAngle(value: number): void {\n this.uniforms.angle.value = value;\n this.uniformsNeedUpdate = true;\n }\n\n public setIsForwardDirection(value: boolean): void {\n this.uniforms.direction.value = value ? 1 : -1;\n this.uniformsNeedUpdate = true;\n }\n}\n","import type { Texture, WebGLRenderer } from \"three\";\nimport { MathUtils, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIProgressMaterial } from \"../Materials/UIProgressMaterial\";\nimport { assertSize } from \"../Miscellaneous/asserts\";\nimport { geometry } from \"../Miscellaneous/threeInstances\";\nimport { UIElement } from \"./UIElement\";\n\nexport interface UIProgressOptions {\n textureBackground: Texture;\n progress: number;\n isForegroundDirection: boolean;\n angle: number;\n color: number;\n opacity: number;\n backgroundColor: number;\n foregroundColor: number;\n backgroundOpacity: number;\n foregroundOpacity: number;\n}\n\nexport class UIProgress extends UIElement {\n private readonly material: UIProgressMaterial;\n private readonly imageWidth: number;\n private readonly imageHeight: number;\n\n constructor(\n layer: UILayer,\n textureForeground: Texture,\n options: Partial<UIProgressOptions> = {},\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 backgroundWidth = options.textureBackground?.image?.width;\n const backgroundHeight = options.textureBackground?.image?.height;\n\n if (options.textureBackground) {\n assertSize(\n backgroundWidth,\n backgroundHeight,\n `Invalid image dimensions - texture \"${options.textureBackground.name || \"unnamed\"}\" has invalid width (${backgroundWidth}) or height (${backgroundHeight}). Image dimensions must be non-zero positive numbers.`,\n );\n }\n\n const material = new UIProgressMaterial(\n textureForeground,\n options.textureBackground,\n );\n const object = new Mesh(geometry, material);\n\n if (options.progress) {\n material.setProgress(options.progress);\n }\n\n if (options.isForegroundDirection) {\n material.setIsForwardDirection(options.isForegroundDirection);\n }\n\n if (options.angle) {\n material.setAngle(MathUtils.degToRad(options.angle));\n }\n\n if (options.color) {\n material.setColor(options.color);\n }\n\n if (options.opacity) {\n material.setOpacity(options.opacity);\n }\n\n if (options.backgroundColor) {\n material.setBackgroundColor(options.backgroundColor);\n }\n\n if (options.foregroundColor) {\n material.setForegroundColor(options.foregroundColor);\n }\n\n if (options.backgroundOpacity) {\n material.setBackgroundOpacity(options.backgroundOpacity);\n }\n\n if (options.foregroundOpacity) {\n material.setForegroundOpacity(options.foregroundOpacity);\n }\n\n const imageWidth = backgroundWidth ?? foregroundWidth;\n const imageHeight = foregroundHeight ?? backgroundHeight;\n\n super(layer, object, 0, 0, imageWidth, imageHeight);\n\n this.material = material;\n this.imageWidth = imageWidth;\n this.imageHeight = imageHeight;\n\n this.applyTransformations();\n }\n\n public get progress(): number {\n return this.material.getProgress();\n }\n\n public get backgroundTexture(): Texture | undefined {\n return this.material.getBackgroundTexture();\n }\n\n public get foregroundTexture(): Texture {\n return this.material.getForegroundTexture();\n }\n\n public get backgroundColor(): number {\n return this.material.getBackgroundColor();\n }\n\n public get foregroundColor(): number {\n return this.material.getForegroundColor();\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get backgroundOpacity(): number {\n return this.material.getBackgroundOpacity();\n }\n\n public get foregroundOpacity(): number {\n return this.material.getForegroundOpacity();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public get angle(): number {\n return MathUtils.radToDeg(this.material.getAngle());\n }\n\n public get isForwardDirection(): boolean {\n return this.material.getIsForwardDirection();\n }\n\n public set progress(value: number) {\n this.material.setProgress(value);\n this.composerInternal.requestUpdate();\n }\n\n public set backgroundColor(value: number) {\n this.material.setBackgroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set foregroundColor(value: number) {\n this.material.setForegroundColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set backgroundOpacity(value: number) {\n this.material.setBackgroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n public set foregroundOpacity(value: number) {\n this.material.setForegroundOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\n }\n\n public set angle(value: number) {\n this.material.setAngle(MathUtils.degToRad(value));\n this.composerInternal.requestUpdate();\n }\n\n public set isForwardDirection(value: boolean) {\n this.material.setIsForwardDirection(value);\n this.composerInternal.requestUpdate();\n }\n\n public override destroy(): void {\n this.material.dispose();\n super.destroy();\n }\n\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.imageWidth,\n this.imageHeight,\n this.material,\n );\n this.applyTransformations();\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 { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Mesh } from \"three\";\nimport type { UILayer } from \"../Layers/UILayer\";\nimport { UIMaterial } from \"../Materials/UIMaterial\";\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 { 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 suggestedAspect = 0;\n\n constructor(\n layer: UILayer,\n spans: (UITextSpan | string)[] | 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 const processedSpans = Array.isArray(spans) ? spans : [spans];\n\n for (const span of processedSpans) {\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.applyTransformations();\n }\n\n public get color(): number {\n return this.material.getColor();\n }\n\n public get opacity(): number {\n return this.material.getOpacity();\n }\n\n public set color(value: number) {\n this.material.setColor(value);\n this.composerInternal.requestUpdate();\n }\n\n public set opacity(value: number) {\n this.material.setOpacity(value);\n this.composerInternal.requestUpdate();\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 applyTransformations(): void {\n super.applyTransformations();\n\n const currentAspect = this.width / this.height;\n if (this.suggestedAspect !== currentAspect) {\n this.suggestedAspect = 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.height = this.width / targetAspect;\n }\n }\n\n protected override render(renderer: WebGLRenderer): void {\n (this.object as Mesh).material = this.composerInternal.compose(\n renderer,\n this.texture.image.width,\n this.texture.image.height,\n this.material,\n );\n this.applyTransformations();\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 UITextMultiSpanDescription {\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 | UITextMultiSpanDescription\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 isUITextMultiSpanDescription(\n obj: unknown,\n): obj is UITextMultiSpanDescription {\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 isUITextMultiSpanDescription,\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.foreground, {\n textureBackground: value.background,\n });\n } else if (isUITextDescription(value)) {\n element = new UIText(layer, [value.text], {\n defaultStyle: value.style,\n });\n } else if (isUITextMultiSpanDescription(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 { 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 { UIMode } 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(\"pointerdown\", 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(\"pointerdown\", 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: PointerEvent): void => {\n if (this.behavior !== UIMode.INTERACTIVE) {\n return;\n }\n\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\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 get isValuable(): 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","isUIOrientation","obj","Object","values","some","v","resolveOrientation","orientation","ALWAYS","UIConstraint","constructor","layer","elements","destroy","HIGH_PRIORITY","UIConstraintPower","UIConstraintRule","isUIConstraintPower","resolvePower","power","P0","convertPowerToStrength","P1","P2","P3","P4","P5","P6","P7","isUIConstraintRule","resolveRule","rule","EQUAL","convertRuleToOperator","LESS","GREATER","UIHeightConstraint","element","options","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","tempMatrixA","Matrix3","tempMatrixB","tempMatrixC","tempMatrixD","tempMatrixE","tempVectorA","Vector3","UIMode","DEFAULT_ANCHOR","UIMicroInternal","x","y","anchorX","anchorY","scaleX","scaleY","rotation","UIMicro","raw","owner","angle","MathUtils","radToDeg","convertedValue","degToRad","setAnchorByGlobalPosition","newAnchorX","width","newAnchorY","reset","UIMaterial","ShaderMaterial","uniforms","opacity","color","Color","vertexShader","fragmentShader","transparent","lights","fog","getTexture","getColor","getHex","getOpacity","setTexture","uniformsNeedUpdate","setColor","setHex","setOpacity","geometry","PlaneGeometry","translate","scene","Scene","mesh","Mesh","UIFullScreenQuad","paddingHorizontalInternal","paddingVerticalInternal","camera","OrthographicCamera","updateCameraTransform","paddingHorizontal","paddingVertical","render","renderer","material","left","right","bottom","top","updateProjectionMatrix","UIComposerInternal","passes","defaultMaterial","screen","needsUpdateInternal","paddingHasChangedInternal","paddingInternal","parameters","format","RGBAFormat","minFilter","LinearFilter","magFilter","UnsignedByteType","depthBuffer","stencilBuffer","fromRenderTarget","WebGLRenderTarget","toRenderTarget","texture","generateMipmaps","needsUpdate","hasValuablePasses","hasPassesNeedingUpdate","paddingHasChanged","padding","requestUpdate","compose","canOverrideBlending","calculatePadding","widthWithPadding","heightWithPadding","setSize","setScreenPadding","setClearColor","setRenderTarget","clear","originalBlending","blending","NoBlending","pass","isValuable","reverseRenderTargets","dispose","p","reduce","UIComposer","UIElementEvent","UIElement","object","_b","_c","_d","_e","generateUUID","microInternal","composerInternal","modeInternal","VISIBLE","micro","composer","zIndex","position","z","mode","visible","HIDDEN","deltaTime","click","applyTransformations","realX","realY","realWidth","realHeight","centerX","centerY","translateToCenter","scale","cos","sin","translateFinal","finalMatrix","multiplyMatrices","point","applyMatrix3","applyMicroTransformations","INTERACTIVE","elementX","elementY","elementWidth","elementHeight","containsPoint","CLICK","clearColor","UILayerEvent","UIConstraintContainerDirection","UISceneUpdateBehavior","UILayer","behavior","solver","constraints","orientationPrivate","PORTRAIT","keys","has","variables","dependencies","remove","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","ORIENTATION_CHANGED","assertSameLayer","elementOne","elementTwo","assertSize","message","UIHorizontalDistanceConstraint","anchorOne","anchorTwo","distance","expressionOne","expressionTwo","UIHorizontalProportionConstraint","proportion","UIVerticalDistanceConstraint","UIVerticalProportionConstraint","UIWidthConstraint","UIConstraint2DBuilder","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","UIConstraintContainerBuilder","build","container","direction","FROM_LEFT_TOP","horizontalDistances","verticalDistances","UIConstraintStackBuilder","buildHorizontal","buildStack","distanceConstraint","proportionConstraint","centerDistanceConstraint","buildVertical","constructors","distances","proportions","centers","nextElement","keepProportions","keepAlignment","distanceConstraints","proportionConstraints","alignmentConstraints","UIDummy","Object3D","UIImage","image","textureInternal","UIProgressMaterial","foregroundTexture","backgroundTexture","UniformsUtils","merge","background","foreground","progress","backgroundColor","foregroundColor","backgroundOpacity","foregroundOpacity","getProgress","getBackgroundTexture","getForegroundTexture","getBackgroundColor","getForegroundColor","getBackgroundOpacity","getForegroundOpacity","getAngle","getIsForwardDirection","setProgress","setBackgroundTexture","setForegroundTexture","setBackgroundColor","setForegroundColor","setBackgroundOpacity","setForegroundOpacity","setAngle","setIsForwardDirection","UIProgress","textureForeground","foregroundWidth","foregroundHeight","backgroundWidth","textureBackground","backgroundHeight","isForegroundDirection","imageWidth","imageHeight","isForwardDirection","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","processedSpans","isArray","span","isSpanString","spanText","defaultStyle","wrappedLines","maxWidth","lines","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","wrapTextLines","textBlockSize","maxLineWidth","line","totalHeight","calculateTextBlockSize","resolvePadding","CanvasTexture","suggestedAspect","paddingTop","paddingLeft","currentY","currentX","renderTextLines","currentAspect","isUIProgressDescription","Texture","isUITextDescription","isUITextMultiSpanDescription","every","isUITextSpan","isUIDummyDescription","UIElementBuilder","UIFitConstraint","DEFAULT_UPDATE_BEHAVIOR","PROPERTY","UIScene","resolutionFactor","renderTarget","useDepth","needsRenderInternal","sceneInternal","cameraInternal","PerspectiveCamera","resolutionFactorInternal","updateBehaviorInternal","updateBehavior","renderedByDefault","clearColorInternal","clearAlphaInternal","clearAlpha","needsRender","requestRender","AUTO","UIFullScreenLayer","targetScreenHeight","onResize","calculateScale","window","innerWidth","innerHeight","onClick","rect","target","HTMLElement","getBoundingClientRect","offsetX","clientX","offsetY","clientY","addEventListener","tergetScreenHeight","removeEventListener","UIManualLayer","resize","UIPass"],"mappings":"yWAOO,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,KAAKE,MAAMG,OAClCL,KAAKE,MAAMgB,KAAKF,IAGhBhB,KAAKE,MAAMW,GAAKG,EAEbA,CACV,EAMDjB,EAAW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